You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: run on webpack's shared threads via compiler.worker() - #769
Depends on webpack/webpack#23374 (compiler.worker(), experiments.threads and the numWorkers option).
Today the plugin starts a jest-worker pool per compilation and ends it afterwards. webpack now owns one thread pool per process, shared with loader threads and other compilers and kept alive across watch rebuilds. On a webpack that has compiler.worker(), the plugin uses it, lazily: compiler.worker() is called only when the first asset needs a worker, and the plugin never starts or ends threads.
constworker=compiler.worker(require.resolve("./minify"),{
numWorkers,// from `parallel`; ignored when `experiments.threads` configures the pool});awaitworker.run("minify",options);// or "transform"
experiments.threads off: numWorkers asks webpack for up to that many threads (capped at cores − 1), so minification stays parallel, on webpack's threads instead of jest-worker.
experiments.threads on: the configured pool applies.
jest-worker stays only for webpack without compiler.worker() and for minimizers that need child processes (supportsWorkerThreads() === false: swcMinify, esbuildMinify, minifyHtmlNode, swcMinifyHtml, swcMinifyHtmlFragment).
Measured locally with experiments.threads off (150 assets, terser, 4 cores → 3 threads, webpack from #23374, fresh process per run, median):
jest-worker
compiler.worker
Production build (n=10): time / CPU
10.3 s / 36.8 s
10.0 s / 35.8 s
Production build: peak RSS
700 MB
749 MB (within run spread)
Watch, 5 builds (n=5): time / CPU
49.5 s / 172 s
39.6 s / 127 s
Watch, 5 builds: peak RSS
888 MB
1,140 MB
Watch trades memory for CPU: reused threads keep warm heaps instead of respawning each build.
What kind of change does this PR introduce?
feat
Did you add tests for your changes?
Yes: test/compiler-worker.test.js. The stubbed tests run on any webpack and cover numWorkers, the inline-function transform path and both jest-worker fallbacks; the real compiler.worker tests (threads on and off) skip until a webpack release ships it, and pass against webpack linked from #23374. The parallel suites hide compiler.worker() so they keep covering the jest-worker path.
Does this PR introduce a breaking change?
No. On webpack without compiler.worker() the plugin behaves as before.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
README parallel section updated.
Use of AI
Yes. Claude Code wrote the change, the tests and the benchmark, which were reviewed and run locally.
✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.51%. Comparing base (59e1a1c) to head (c03dbab). ⚠️ Report is 1 commits behind head on main.
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.
No actionable comments were generated in the recent review.
Walkthrough
The plugin uses webpack’s worker pool when compiler.worker() is available and worker threads are supported. Otherwise, it uses jest-worker. Cleanup ends only the tracked Jest worker. New tests cover worker selection, output, and pool reuse. The type definitions describe the shared worker API, and a Changeset declares a minor release.
Merge Risk: Low · previous review bd816
When webpack provides compiler.worker(), minification now runs on webpack's worker threads, and older webpack versions keep using jest-worker. The remaining open question is whether builds without experiments.threads still minify in parallel on the new path. That depends on upstream webpack behavior this review could not inspect. If webpack runs that path inline, those builds would lose parallelism but would still produce correct output.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "feat: run on webpack's shared threads via compiler.worker()" names the main change. The PR adds support for webpack's compiler.worker() so minimizers run on webpack's shared thread pool ins…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "feat: run on webpack's shared threads via compiler.worker()" names the main change. The PR adds support for webpack's compiler.worker() so minimizers run on webpack's shared thread pool instead of jest-worker when the API exists. The title is specific, concise, and matches the changeset, including the changeset note, the index.js worker selection, the types, the README, and the tests.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 5e0417dc-1c6d-4574-b9e1-87800afbf75e
Commits
Reviewing files that changed from the base of the PR and between 3538ff6 and bd81615.
Files selected for processing: 4
.changeset/compiler-worker-threads.md
README.md
src/index.js
test/compiler-worker.test.js
Files skipped from review as they are similar to previous changes: 2
.changeset/compiler-worker-threads.md
README.md
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: de555875-d688-4afc-933d-c6b15f2950dd
Commits
Reviewing files that changed from the base of the PR and between 317e853 and 819fa22.
Files selected for processing: 4
.changeset/compiler-worker-threads.md
src/index.js
test/compiler-worker.test.js
types/index.d.ts
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: d012616e-38b0-475f-8023-5bcac894eea2
Commits
Reviewing files that changed from the base of the PR and between a3bfeb2 and b60fac7.
Files selected for processing: 9
.changeset/compiler-worker-threads.md
README.md
src/index.js
test/compiler-worker.test.js
test/helpers/hideCompilerWorker.js
test/helpers/index.js
test/parallel-option.test.js
test/parallel-stage.test.js
types/index.d.ts
Files skipped from review as they are similar to previous changes: 1
.changeset/compiler-worker-threads.md
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
Webpack's shared pool lives as long as the compiler and is shared with loader threads, so the plugin no longer starts and ends its own jest-worker pool per compilation. jest-worker stays for older webpack, threads off, and minimizers that need child processes.
alexander-akait
changed the title
feat: use compiler.worker() when experiments.threads is enabled
feat: run on webpack's shared threads via compiler.worker()
Nov 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Depends on webpack/webpack#23374 (
compiler.worker(),experiments.threadsand thenumWorkersoption).Today the plugin starts a
jest-workerpool per compilation and ends it afterwards. webpack now owns one thread pool per process, shared with loader threads and other compilers and kept alive across watch rebuilds. On a webpack that hascompiler.worker(), the plugin uses it, lazily:compiler.worker()is called only when the first asset needs a worker, and the plugin never starts or ends threads.experiments.threadsoff:numWorkersasks webpack for up to that many threads (capped at cores − 1), so minification stays parallel, on webpack's threads instead ofjest-worker.experiments.threadson: the configured pool applies.jest-workerstays only for webpack withoutcompiler.worker()and for minimizers that need child processes (supportsWorkerThreads() === false:swcMinify,esbuildMinify,minifyHtmlNode,swcMinifyHtml,swcMinifyHtmlFragment).Measured locally with
experiments.threadsoff (150 assets, terser, 4 cores → 3 threads, webpack from #23374, fresh process per run, median):Watch trades memory for CPU: reused threads keep warm heaps instead of respawning each build.
What kind of change does this PR introduce?
feat
Did you add tests for your changes?
Yes:
test/compiler-worker.test.js. The stubbed tests run on any webpack and covernumWorkers, the inline-functiontransformpath and bothjest-workerfallbacks; the realcompiler.workertests (threads on and off) skip until a webpack release ships it, and pass against webpack linked from #23374. Theparallelsuites hidecompiler.worker()so they keep covering thejest-workerpath.Does this PR introduce a breaking change?
No. On webpack without
compiler.worker()the plugin behaves as before.If relevant, what needs to be documented once your changes are merged or what have you already documented?
README
parallelsection updated.Use of AI
Yes. Claude Code wrote the change, the tests and the benchmark, which were reviewed and run locally.
🤖 Generated with Claude Code
https://claude.ai/code/session_013FhutPfFxa3dMMtdTmt63i
Summary by CodeRabbit
paralleloption documentation to explain how worker counts are controlled with webpack threads.