# worker

Forked-worker entry script for the dependency pre-pass. Sits behind the [`runPrePass`](https://www.hyperfrontend.dev/docs/libraries/builder/bundle/dependencies/#api-runPrePass) orchestrator in [`bundle/dependencies/pre-pass.ts`](../pre-pass.ts).

The worker reads a serializable [`PrePassWorkerJob`](https://www.hyperfrontend.dev/docs/libraries/builder/bundle/dependencies/worker/#api-PrePassWorkerJob) from `process.argv[2]` and reconstructs [`RollupOptions`](https://rollupjs.org/javascript-api/#rollup-rollup) for one of four [`kind`](https://www.hyperfrontend.dev/docs/libraries/builder/bundle/dependencies/worker/#api-PrePassWorkerJob-prop-kind)s: the npm JS pre-pass ([`json`](https://www.npmjs.com/package/@rollup/plugin-json) + [`nodeResolve`](https://www.npmjs.com/package/@rollup/plugin-node-resolve) + [`commonjs`](https://www.npmjs.com/package/@rollup/plugin-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`](https://www.hyperfrontend.dev/docs/libraries/builder/bundle/dependencies/worker/#api-PrePassWorkerJob-prop-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.

---

Canonical page: https://www.hyperfrontend.dev/docs/libraries/builder/bundle/dependencies/worker/
This file: https://www.hyperfrontend.dev/docs/libraries/builder/bundle/dependencies/worker.md
Documentation index: https://www.hyperfrontend.dev/llms.txt
