GeezerVison is showing github.com — perf(javascript): compress in the node printer's one pass, behind a switch by alexander-akait · Pull Request #22928 · webpack/webpack
Conversation
alexander-akait
commented
Oct 26, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
The JS minifier spends most of its time in terser's compressor. This adds a one-pass minify, like the HTML and CSS minifiers: the SoA tree is parsed, mangled and compressed while the node printer prints it. It sits behind the internal modules.onePass switch, which is off, so the default output is unchanged (byte-identical on 4,200 corpus files).
In the one pass:
- Unused code: drops what nothing reads, transitively.
- Constants: inlines and folds constants.
- Moves: reads aliases as what they name, and moves a function used once to its call.
collapse_vars: folds a statement into the next statement's first read.
- Smaller rewrites: terser's local ones (
==null, typeof x<"u", !0, let, …).
It prints twice by default; compress.passes asks for more. A TODO notes deprecating passes once one print matches.
Before = default path, after = one pass (compress: {}), 6 libraries:
|
Wall |
CPU |
Peak memory |
Gzip |
| before |
3,485 ms |
5,495 ms |
813 MB |
455,114 |
| after |
941 ms |
1,477 ms |
514 MB |
456,847 (+0.38%) |
Gzip is still 0.38% behind (smaller on three and acorn, behind on prettier), so the switch stays off for now.
What kind of change does this PR introduce?
perf
Did you add tests for your changes?
Yes, test/unitCases/javascript/printer.unittest.js (one-pass cases for each rewrite and its guards). All 672 terser expect_stdout cases print the same output from the one pass as from their input.
Does this PR introduce a breaking change?
No, the switch is off by default.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
n/a
Use of AI
Written with Claude Code: implementation, tests and measurements, reviewed by the author.
Generated by Claude Code
Summary by CodeRabbit
- New Features
- Added an optional minification mode that combines compression and output generation when compatible settings are enabled; other configurations continue to use the existing mode.
- Minification can simplify eligible aliases and single-use functions, fold constants, remove unused declarations and expressions, combine declarations, and print some
const declarations as let.
- When applicable, minification can repeat the generated output to honor configured compression passes.
- Tests
- Added coverage for one-pass minification across compression, mangling, formatting, comments, declarations, literals, and modules.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
This PR is packaged and the instant preview of its latest commit is available.
Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@22928
yarn add -D webpack@https://pkg.pr.new/webpack@22928
pnpm add -D webpack@https://pkg.pr.new/webpack@22928
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Types CoverageCoverage after merging perf/javascript-one-pass-minify into main will be
Coverage Report| File | Stmts | Branches | Funcs | Lines | Uncovered Lines |
|---|
| bin | | webpack.js | 98.84% | 100% | 100% | 98.84% | 113 | | declarations | | WebpackOptions.ts | 99.94% | 100% | 100% | 99.94% | 4266 | | examples | | build-common.js | 100% | 100% | 100% | 100% | | | buildAll.js | 100% | 100% | 100% | 100% | | | examples.js | 100% | 100% | 100% | 100% | | | template-common.js | 98.21% | 100% | 100% | 98.21% | 72 | | examples/custom-javascript-parser | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/custom-javascript-parser/internals | | acorn-parse.js | 100% | 100% | 100% | 100% | | | meriyah-parse.js | 100% | 100% | 100% | 100% | | | oxc-parse.js | 100% | 100% | 100% | 100% | | | examples/markdown | | webpack.config.mjs | 100% | 100% | 100% | 100% | | | examples/module-federation | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/reexport-components | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/ssr | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/typescript | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/typescript-non-erasable | | test.filter.js | 50% | 100% | 100% | 50% | 5 | | examples/virtual-modules | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/wasm-bindgen-esm | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/wasm-complex | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/wasm-emscripten | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/wasm-simple | | test.filter.js | 100% | 100% | 100% | 100% | | | examples/wasm-simple-source-phase | | test.filter.js | 100% | 100% | 100% | 100% | | | lib | | Chunk.js | 100% | 100% | 100% | 100% | | | Compilation.js | 98.74% | 100% | 100% | 98.74% | 1823, 2135, 2142, 2150, 2172, 2175, 3161, 3720, 3763, 4358, 4362, 4488, 4509, 4634, 4671, 4678, 4731–4732, 4736, 4741, 4757–4758, 4772–4773, 4778–4779, 5307, 5333, 6254, 6271, 6289, 6305, 6320, 6345, 6348, 6760, 6763–6764, 6769, 6784, 6867, 6891, 883–884 | | Compiler.js | 98.81% | 100% | 100% | 98.81% | 1107, 1144, 1147, 1323–1324, 1332, 848, 932, 972 | | Dependency.js | 100% | 100% | 100% | 100% | | | DependencyTemplate.js | 100% | 100% | 100% | 100% | | | EntryPlugin.js | 100% | 100% | 100% | 100% | | | Entrypoint.js | 100% | 100% | 100% | 100% | | | ExternalsPlugin.js | 100% | 100% | 100% | 100% | | | FileSystemInfo.js | 100% | 100% | 100% | 100% | | | InitFragment.js | 100% | 100% | 100% | 100% | | | LibraryTemplatePlugin.js | 100% | 100% | 100% | 100% | | | ModuleFilenameHelpers.js | 100% | 100% | 100% | 100% | | | ModuleNotFoundError.js | 100% | 100% | 100% | 100% | | | MultiCompiler.js | 98.91% | 100% | 100% | 98.91% | 489, 561, 748, 813 | | NormalModule.js | 100% | 100% | 100% | 100% | | | NullFactory.js | 100% | 100% | 100% | 100% | | | ProgressPlugin.js | 100% | 100% | 100% | 100% | | | RawModule.js | 100% | 100% | 100% | 100% | | | RequestShortener.js | 100% | 100% | 100% | 100% | | | SingleEntryPlugin.js | 100% | 100% | 100% | 100% | | | WebpackError.js | 100% | 100% | 100% | 100% | | | index.js | 100% | 100% | 100% | 100% | | | webpack.js | 98.59% | 100% | 100% | 98.59% | 306, 308 | | lib/asset | | AssetBytesGenerator.js | 100% | 100% | 100% | 100% | | | AssetBytesParser.js | 91.67% | 100% | 100% | 91.67% | 27 | | AssetGenerator.js | 100% | 100% | 100% | 100% | | | AssetModule.js | 100% | 100% | 100% | 100% | | | AssetModulesPlugin.js | 98.45% | 100% | 100% | 98.45% | 334, 360, 363, 493, 58 | | AssetParser.js | 96.15% | 100% | 100% | 96.15% | 47 | | AssetSourceGenerator.js | 100% | 100% | 100% | 100% | | | AssetSourceParser.js | 91.67% | 100% | 100% | 91.67% | 27 | | RawDataUrlModule.js | 100% | 100% | 100% | 100% | | | WebManifestGenerator.js | 100% | 100% | 100% | 100% | | | WebManifestParser.js | 100% | 100% | 100% | 100% | | | lib/async-modules | | AsyncModuleHelpers.js | 100% | 100% | 100% | 100% | | | AwaitDependenciesInitFragment.js | 100% | 100% | 100% | 100% | | | InferAsyncModulesPlugin.js | 100% | 100% | 100% | 100% | | | isGeneratorLowered.js | 100% | 100% | 100% | 100% | | | lib/bun | | BunTargetPlugin.js | 100% | 100% | 100% | 100% | | | lib/cache | | AddBuildDependenciesPlugin.js | 100% | 100% | 100% | 100% | | | AddManagedPathsPlugin.js | 100% | 100% | 100% | 100% | | | Cache.js | 98.25% | 100% | 100% | 98.25% | 104 | | CacheFacade.js | 100% | 100% | 100% | 100% | | | IdleFileCachePlugin.js | 97.92% | 100% | 100% | 97.92% | 75, 87, 95 | | MemoryCachePlugin.js | 92% | 100% | 100% | 92% | 33, 42 | | MemoryWithGcCachePlugin.js | 93.42% | 100% | 100% | 93.42% | 106, 120–121, 130, 88 | | PackFileCacheStrategy.js | 96.54% | 100% | 100% | 96.54% | 1304, 1404, 1408, 1470, 1716, 1796, 1819, 1849, 684, 703, 713–715, 717, 733–734, 739, 742, 744, 749, 754, 779, 785, 819, 825, 831, 836, 847, 856, 861–862, 864, 881, 887–888, 890 | | ResolverCachePlugin.js | 100% | 100% | 100% | 100% | | | getLazyHashedEtag.js | 100% | 100% | 100% | 100% | | | mergeEtags.js | 100% | 100% | 100% | 100% | | | lib/config | | OptionsApply.js | 100% | 100% | 100% | 100% | | | PlatformPlugin.js | 100% | 100% | 100% | 100% | | | WebpackOptionsApply.js | 100% | 100% | 100% | 100% | | | WebpackOptionsDefaulter.js | 100% | 100% | 100% | 100% | | | browserslistTargetHandler.js | 100% | 100% | 100% | 100% | | | cli.js | 98.89% | 100% | 100% | 98.89% | 114, 549, 581, 631 | | defaults.js | 99.59% | 100% | 100% | 99.59% | 1633–1635, 1643, 288, 548 | | defineConfig.js | 100% | 100% | 100% | 100% | | | getClaimedAssetTypes.js | 100% | 100% | 100% | 100% | | | normalization.js | 99.14% | 100% | 100% | 99.14% | 285–286, 356, 371 | | target.js | 100% | 100% | 100% | 100% | | | validateSchema.js | 94.67% | 100% | 100% | 94.67% | 100, 87, 89, 98 | | lib/container | | ContainerEntryDependency.js | 100% | 100% | 100% | 100% | | | ContainerEntryModule.js | 100% | 100% | 100% | 100% | | | ContainerEntryModuleFactory.js | 100% | 100% | 100% | 100% | | | ContainerExposedDependency.js | 100% | 100% | 100% | 100% | | | ContainerPlugin.js | 100% | 100% | 100% | 100% | | | ContainerReferencePlugin.js | 100% | 100% | 100% | 100% | | | FallbackDependency.js | 100% | 100% | 100% | 100% | | | FallbackItemDependency.js | 100% | 100% | 100% | 100% | | | FallbackModule.js | 100% | 100% | 100% | 100% | | | FallbackModuleFactory.js | 100% | 100% | 100% | 100% | | | HoistContainerReferencesPlugin.js | 100% | 100% | 100% | 100% | | | ModuleFederationPlugin.js | 100% | 100% | 100% | 100% | | | RemoteModule.js | 100% | 100% | 100% | 100% | | | RemoteRuntimeModule.js | 100% | 100% | 100% | 100% | | | RemoteToExternalDependency.js | 100% | 100% | 100% | 100% | | | declaredRemotes.js | 100% | 100% | 100% | 100% | | | moduleFederationHooks.js | 100% | 100% | 100% | 100% | | | options.js | 100% | 100% | 100% | 100% | | | lib/context | | ContextExclusionPlugin.js | 100% | 100% | 100% | 100% | | | ContextModule.js | 99.88% | 100% | 100% | 99.88% | 1495 | | ContextModuleFactory.js | 95.70% | 100% | 100% | 95.70% | 230, 257, 276, 280–281, 289, 466, 487, 492, 534, 543, 545, 549, 552, 558–559 | | ContextReplacementPlugin.js | 100% | 100% | 100% | 100% | | | lib/css | | CssGenerator.js | 99.29% | 100% | 100% | 99.29% | 1085, 129, 305, 837 | | CssInjectStyleRuntimeModule.js | 100% | 100% | 100% | 100% | | | CssLoadingRuntimeModule.js | 100% | 100% | 100% | 100% | | | CssModule.js | 100% | 100% | 100% | 100% | | | CssModulesPlugin.js | 98.72% | 100% | 100% | 98.72% | 217, 418, 432, 445, 458, 481, 494, 507, 520 | | CssParser.js | 99.76% | 100% | 100% | 99.76% | 1122, 2457, 3104, 3107, 3113, 3545, 975 | | CssServerStylesRuntimeModule.js | 100% | 100% | 100% | 100% | | | conventions.js | 100% | 100% | 100% | 100% | | | cssMinify.js | 100% | 100% | 100% | 100% | | | data.js | 99.84% | 100% | 100% | 99.84% | 229, 5605 | | syntax-parser.js | 99.71% | 100% | 100% | 99.71% | 11159–11160, 11716–11717, 11754, 11964, 12013, 14534, 14595–14598, 14703–14704, 14802–14803, 15576, 15871, 15873, 16428, 16821, 16863, 19289, 3066, 3068, 3073, 3086, 3843, 3849 | | syntax-printer.js | 99.33% | 100% | 100% | 99.33% | 2619–2620, 2622–2623, 2625–2626, 2631, 2895–2898, 2991, 355, 3692, 4117, 4253, 4931, 5246, 6139, 723 | | syntax.js | 100% | 100% | 100% | 100% | | | topologicalSort.js | 100% | 100% | 100% | 100% | | | lib/debug | | ProfilingPlugin.js | 100% | 100% | 100% | 100% | | | lib/define | | DefinePlugin.js | 99.42% | 100% | 100% | 99.42% | 1488, 936, 938, 943, 967 | | DotenvPlugin.js | 97.61% | 100% | 100% | 97.61% | 276, 395, 443, 456–457 | | EnvironmentPlugin.js | 100% | 100% | 100% | 100% | | | lib/deno | | DenoTargetPlugin.js | 100% | 100% | 100% | 100% | | | lib/dependencies | | ConstDependency.js | 100% | 100% | 100% | 100% | | | ContextElementDependency.js | 100% | 100% | 100% | 100% | | | NullDependency.js | 100% | 100% | 100% | 100% | | | lib/dependencies/amd | | AMDDefineDependency.js | 100% | 100% | 100% | 100% | | | AMDDefineDependencyParserPlugin.js | 100% | 100% | 100% | 100% | | | AMDPlugin.js | 99.31% | 100% | 100% | 99.31% | 54 | | AMDRequireArrayDependency.js | 100% | 100% | 100% | 100% | | | AMDRequireContextDependency.js | 100% | 100% | 100% | 100% | | | AMDRequireDependenciesBlock.js | 100% | 100% | 100% | 100% | | | AMDRequireDependenciesBlockParserPlugin.js | 100% | 100% | 100% | 100% | | | AMDRequireDependency.js | 100% | 100% | 100% | 100% | | | AMDRequireItemDependency.js | 100% | 100% | 100% | 100% | | | AMDRuntimeModules.js | 95.45% | 100% | 100% | 95.45% | 65 | | LocalModule.js | 100% | 100% | 100% | 100% | | | LocalModuleDependency.js | 100% | 100% | 100% | 100% | | | LocalModulesHelpers.js | 100% | 100% | 100% | 100% | | | RequireJsStuffPlugin.js | 100% | 100% | 100% | 100% | | | UnsupportedDependency.js | 100% | 100% | 100% | 100% | | | lib/dependencies/commonjs | | CommonJsDependencyHelpers.js | 98.63% | 100% | 100% | 98.63% | 43 | | CommonJsExportRequireDependency.js | 99.21% | 100% | 100% | 99.21% | 413, 415, 417 | | |
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
codecov
Bot
commented
Oct 26, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.97%. Comparing base (9831760) to head (9812cdc).
Additional details and impacted files
@@ Coverage Diff @@
## main #22928 +/- ##
==========================================
+ Coverage 96.94% 96.97% +0.03%
==========================================
Files 778 778
Lines 146674 148166 +1492
Branches 50846 51610 +764
==========================================
+ Hits 142189 143681 +1492
Misses 4485 4485
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.
🚀 New features to boost your workflow:
- ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Generated code size
Comparing base (9831760) to head (84531ef). Merging this pull request will not change the code webpack generates.
| What moved |
Tests |
Assets |
Gzip |
Raw |
Test edit |
| Changed, test untouched |
0 |
0 |
— |
— |
— |
| Changed, test edited |
0 |
0 |
— |
— |
— |
| New |
0 |
0 |
— |
— |
— |
| Deleted |
0 |
0 |
— |
— |
— |
| Unchanged |
— |
9356 |
— |
— |
— |
Read Changed, test untouched first: the test is byte-identical on both sides, so webpack generated the difference. Changed, test edited moved partly because the test did — Test edit is how many bytes the test gained, and a bundle that grew by less is not a regression. New and Deleted are whole files, not deltas — a new asset was created, not grown, so it reads gray (⚪ added) — and adding tests cannot bury a real change. Gzip decides, because that is what users download; raw is the tiebreak, and brotli and zstd are per asset below.
No asset changed size.
No runtime gained or lost a runtime module.
Built test/configCases with the defaults a user gets: 2303 test(s), 9356 asset(s), 102 emitted nothing.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Oct 26, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

Note
Reviews paused
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.
Use the following commands to manage reviews:
@coderabbitai resume to resume automatic reviews.
@coderabbitai review to trigger a single review.
Use the checkboxes below for quick actions:
- ▶️ Resume reviews
- 🔍 Trigger review
Walkthrough
-
The change adds an opt-in path that compresses and prints parsed JavaScript syntax trees together. Scope analysis identifies eligible aliases and function moves. The printer applies compression transformations, and unit tests check output and printer walks.
Changes: One-pass syntax-tree minification
| Layer / File(s) |
Summary |
Binding and reference analysis lib/javascript/ScopeAnalyzer.js |
The analyzer records writes and reference kinds. When enabled, it identifies eligible aliases and function moves and returns their analysis results. |
One-pass selection and mangling lib/javascript/syntax-printer.js |
The driver selects the one-pass path under its option constraints. Tree mangling supplies names and analysis results to the printer. Eligible results can be printed repeatedly to honor compression passes. |
Compression analysis and printer setup lib/javascript/syntax-printer.js |
The node printer receives names and compression options. It tracks removable declarations and foldable values, and filters comment flags for compressed output. |
Compressed output and validation lib/javascript/syntax-printer.js, test/unitCases/javascript/printer.unittest.js |
The printer emits eligible declaration, expression, alias, and function transformations. Tests check expected one-pass output and printer-walk counts. |
Suggested labels: area: build-perf
Suggested reviewers: aryanraj45
Priority: Normal
Change: Refactor
Merge Risk: Moderate · up to 8f6bd
-
When one-pass minification is enabled, some programs can lose an observable side effect before an error. Fix the collapse guard before merging unless that behavior is explicitly accepted.
Pre-merge checks: 3 · 1
-
Failed checks: 1 inconclusive
| Check name |
Status |
Explanation |
Resolution |
| Title check |
 |
The title uses the conventional-commit form perf(javascript): ..., and perf is an allowed type. It matches the main change: one-pass compression in the node printer, gated behind a switch (`module… |
Confirm the source branch name starts with the perf prefix. If the branch uses a different prefix, rename the branch or change the title type so they match. No change is needed to the title text otherwise. |
Passed checks: 3 passed
-
| Check name |
Status |
Explanation |
| Description Check |
 |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| 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 uses the conventional-commit form perf(javascript): ..., and perf is an allowed type. It matches the main change: one-pass compression in the node printer, gated behind a switch (modules.onePass, off by default). The title is specific and accurate. The title check requirement also says the type must match the branch prefix. The branch name was not provided in the context, so that part cannot be verified.
Resolution
Confirm the source branch name starts with the perf prefix. If the branch uses a different prefix, rename the branch or change the title type so they match. No change is needed to the title text otherwise.
- 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.
❤️ Share
-
Comment @coderabbitai help to get the list of available commands.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
codspeed
Bot
commented
Oct 26, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Merging this PR will not alter performance
1 warning, 1 note
⚠️ 117 benchmarks are dominated by system calls
System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.
Learn more about system calls
See affected benchmarks
ℹ️ 46 benchmarks have no flamegraph
The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.
See affected benchmarks
✅ 351 untouched benchmarks
Comparing perf/javascript-one-pass-minify (9812cdc) with main (9831760)
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Oct 27, 2026
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
area: build-perf
Build time and memory of webpack itself
area: parser
JavaScript parsing and dependency analysis (lib/javascript, lib/dependencies)
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|