@hyperfrontend/builder/bundle/dependencies/worker

worker

Forked-worker entry script for the dependency pre-pass. Sits behind the runPrePass orchestrator in bundle/dependencies/pre-pass.ts.

The worker reads a serializable PrePassWorkerJob from process.argv[2] and reconstructs RollupOptions for one of four kinds: the npm JS pre-pass (json + nodeResolve + commonjs), the npm d.ts pre-pass (rollup-plugin-dts), the workspace-source JS pre-pass (the same JS chain plus @rollup/plugin-typescript driving the dep's tsconfig), or the workspace-source d.ts pre-pass (rollup-plugin-dts driven by that tsconfig). It then runs rollup() → bundle.write() → bundle.close(), writes a JSON report to job.reportPath, and exits. Process isolation reclaims the rollup-invocation heap and RSS at exit so each dep is pre-passed in a fresh address space, keeping the parent bounded across the full dep set.

runPrePassWorkerJob(job) is exported so callers and tests can drive the worker logic without spawning a new Node process.

API Reference

ƒ Functions

§function

runPrePassWorkerJob(job: PrePassWorkerJob): Promise<PrePassWorkerReport>

Runs a single pre-pass rollup invocation as described by job and writes the resulting report to job.reportPath.
Public so callers (and tests) can drive the worker logic without spawning a new Node process.

Parameters

NameTypeDescription
§job
PrePassWorkerJob
Job spec describing the rollup invocation.

Returns

Promise<PrePassWorkerReport>
The on-disk report data the worker would have persisted.

Example

Driving the worker logic in-process for a fixture

const report = await runPrePassWorkerJob({ kind: 'js', dep: 'rollup', ... })

Interfaces

§interface

PrePassWorkerJob

Job spec consumed by the pre-pass worker via process.argv[2].
Each invocation produces exactly one rollup output and one JSON report at reportPath so the parent orchestrator can collect per-job statistics.

Properties

§dep:string
Dep package name (or workspace specifier) being pre-passed.
§depsRoot?:string
Absolute path to the project's _dependencies/ root. Required when npmDeps or workspaceRoutes is non-empty.
§format:"cjs" | "esm"
Output format. JS jobs must use 'esm' or 'cjs'. dts jobs always use 'es' internally.
§inputPath:string
Absolute path to the dep's entry (main / module for JS, types for dts, source .ts for workspace-*).
§kind:PrePassWorkerJobKind
Pre-pass kind. js and dts run the npm-dep pipeline; workspace-js and workspace-dts add @rollup/plugin-typescript (or rollup-plugin-dts's tsconfig integration) so TypeScript source workspace deps can be hoisted.
§npmDeps?:string[]
NPM bundled-dep names consumed by the canonical externalize plugin to rewrite cross-dep imports to relative paths under depsRoot.
§otherDeps:string[]
Other deps in the pre-pass set; marked external so cross-dep imports stay link-time. Prefix-matched.
§otherWorkspaceSpecifiers?:string[]
Sub-path-mode workspace specifiers in the pre-pass set; matched as exact specifier only (e.g. @hyperfrontend/immutable-api-utils/built-in-copy/array). Used by workspace-* jobs so sibling sub-paths externalize cleanly without also externalizing every other sub-path on the same package.
§outputPath:string
Absolute path to the output file.
§reportPath:string
Absolute path where the worker writes its JSON report.
§selfDtsPath?:string
Absolute path to the input file's owning entry directory (used to compute sibling specifiers).
§selfSrcPath?:string
Owning entry's srcPath (used for diagnostics). Empty string for the package root.
§siblingEntries?:SiblingEntry[]
Sibling-entry descriptors used by the per-entry dts pass to externalize imports that resolve into another entry's directory. Empty / omitted for dep pre-pass jobs.
§tsConfigPath?:string
Absolute path to the project's tsconfig (workspace-* jobs only).
§workspaceRoot?:string
Absolute workspace root used as baseUrl for path-mapping resolution (workspace-* jobs only).
§workspaceRoutes?:WorkspaceBundledDepRoute[]
Workspace bundled-dep routes consumed by the canonical externalize plugin. For self-pre-pass jobs (workspace-js / workspace-dts) this excludes the specifier or package being built so the chunk inlines its own internals.
§interface

PrePassWorkerReport

Memory + size summary written to reportPath when a worker exits cleanly.

Properties

§durationMs:number
Worker wall-clock duration in ms.
§endHeapMB:number
process.memoryUsage().heapUsed in MB at end of bundle.
§endRssMB:number
process.memoryUsage().rss in MB at end of bundle.
§outputSize:number
Final on-disk size of the rollup output, in bytes.