@hyperfrontend/builder/bundle/rollup/worker

worker

Forked-worker entry script for per-entry rollup invocations. Sits behind the dispatchRollupWorker orchestrator in bundle/rollup/dispatch.ts.

The worker reads a serializable RollupBuildDescriptor from process.argv[2], reconstructs RollupOptions using the same plugin factories the parent would have used in-process, 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, keeping the parent bounded across libraries with many entries (per-entry rollup invocations accumulate ~150-225MB heap and V8 retains freed pages even after explicit GC).

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

API Reference

ƒ Functions

§function

runRollupWorkerJob(job: RollupBuildDescriptor): Promise<RollupWorkerReport>

Runs a single rollup invocation as described by job and writes the resulting report to job.reportPath.
Use this to drive the worker logic in-process; use dispatchRollupWorker to run the same job in a forked Node process.

Parameters

NameTypeDescription
§job
RollupBuildDescriptor
Descriptor describing the rollup invocation.

Returns

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

Example

Driving the worker logic in-process for a fixture

const report = await runRollupWorkerJob({ format: 'esm', inputFile: '/abs/in.ts', ... })

Interfaces

§interface

RollupBuildDescriptor

Serializable rollup-build descriptor: the contract between the parent orchestrator and a forked worker. Every field must round-trip through JSON.stringify / JSON.parse — no functions, no class instances.
The worker reconstructs RollupOptions from the descriptor using the same plugin factories the parent would have used in-process.

Properties

§bin:RollupWorkerBin
Bin-output config carried by ESM / CJS descriptors that emit an executable bin. null for non-bin entries.
§bundle:RollupWorkerBundleOutput
Bundle-output config carried by IIFE / UMD descriptors. null for esm/cjs.
§bundledDepsPlugin:RollupWorkerBundledDepsPlugin
When set: install the externalize-bundled-deps plugin (esm/cjs only).
§bundleWorkspaceDeps:boolean
When true, workspace deps are inlined; otherwise treated as external.
§external:string[]
Pre-resolved external package list.
§format:RollupWorkerFormat
Output format.
§inputFile:string
Absolute path to the source TS/JS entry.
§outputDir:string
Absolute directory the worker writes its output(s) under.
§projectRoot:string
Absolute project root threaded into the typescript plugin.
§reportPath:string
Absolute path the worker writes its JSON report to.
§sourcemap:boolean
Sourcemap toggle threaded into the rollup output.
§tsConfigPath:string
Absolute tsconfig path threaded into the typescript plugin.
§workspaceRoot:string
Absolute workspace root threaded into the typescript plugin.
§workspaceRoutes:WorkspaceBundledDepRoute[]
Workspace bundled-dep routes consumed by the externalize plugin. When non-empty, imports of these workspace packages (and matching sub-paths) are rerouted to the corresponding _dependencies/<packageName>(/<sub>)?/index.<ext> chunk. Empty array for descriptors that do not opt into workspace-dep hoisting.
§interface

RollupWorkerBundleOutput

Bundle-output configuration carried by IIFE / UMD descriptors.
Captures the format-specific output knobs the worker needs to reconstruct OutputOptions for a self-contained browser bundle.

Properties

§amdId?:string
UMD-only AMD module identifier.
§globalName:string
Global variable name exposed by the bundle.
§globals?:Record<string, string>
Global names mapped onto the external dependencies.
§minify:boolean
Emit a minified twin alongside the unminified bundle.
§interface

RollupWorkerReport

Memory + size summary written to reportPath when the 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
Total on-disk size of every emitted output, in bytes.

Types

§type

RollupWorkerFormat

Output format the rollup worker produces.
type RollupWorkerFormat = "esm" | "cjs" | "iife" | "umd"