GeezerVison is showing github.com — fix(minify): keep a `|0` beside `>>>` where its side may be a BigInt by alexander-akait · Pull Request #23246 · webpack/webpack
Conversation
alexander-akait
commented
Nov 10, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
Follows #23227 and fixes the three CodeRabbit findings left open there.
(~v|0)>>>c() printed ~v>>>c(). For v = 1n, | throws before c() runs, >>> only after. The |0 now goes only where its side can't be a BigInt (a non-BigInt literal; !, typeof, void or delete; - or ~ of a number; arithmetic with a number), or where the other side of >>> is a number, which reads nothing the conversion could move past.
- Under
unsafe, `${1}` printed ""+1. The constant fold now runs first and prints "1".
knownBranch and pickedOperand cleared foldsAtPrint instead of restoring it, so a known conditional inside findDropped switched print-time evaluation off for the rest of that walk. Both now restore the outer value, as valueAtPrint does. I found no input whose output this changes: the 14,274 corpus rows and 720 generated programs print the same.
var c=0;function f(v){try{return(~v|0)>>>(c++,1)}catch(e){return c}}console.log(f(1n))
// before: …return~v>>>(c++,1)… prints 1, the source prints 0
// after: …return(~v|0)>>>(c++,1)… prints 0
console.log(`${1}`) // compress: {unsafe: true}
// before: console.log(""+1); after: console.log("1");
All 14,274 corpus rows: none grows, none unlisted turns worse than its rival. The vm runtime results match main, and real files (typescript, lodash, react-dom, three, acorn, terser) print byte-identical.
What kind of change does this PR introduce?
fix
Did you add tests for your changes?
Yes: fixtures one-pass-minify-of-statement-sequences-should-drop-a-0-an-operand-of-takes-2 (BigInt sides with a side-effecting count) and …-print-a-template-of-one-3 (unsafe templates of constants), with rows in test/unitCases/javascript/printer.unittest.js. The existing >>> row now expects (v++|0)>>>s and (~v|0)>>>s kept. optimization/minify-string-shift-folds passes unchanged. No test covers the foldsAtPrint restore, as no input showed a difference.
Does this PR introduce a breaking change?
No.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
n/a. The pending .changeset/256-javascript-minify-string-shift-folds.md already covers these folds.
Use of AI
Written with Claude Code: it reproduced each finding on main, wrote the fixes and tests, and gated them on the whole corpus, the vm runtime check and real files. The long suites are left to CI.
Generated by Claude Code
Summary by CodeRabbit
- Bug Fixes
- Improved JavaScript minification for shift and bitwise expressions, preserving coercion behavior and evaluation order—including when BigInt operations can throw.
- Corrected handling of constant template literals so constant substitutions are rendered as strings while dynamic substitutions retain their behavior.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
`(~v|0)>>>c()` printed `~v>>>c()`: for `v = 1n`, `|` throws before
`c()` runs, `>>>` only after. A `|0` now goes where its side is a
literal, `!`, `typeof`, `void` or `delete`, `-` or `~` of a number,
or arithmetic with a number, or where the other side of `>>>` is a number.
Also print a template whose substitution folds as that string before the
`unsafe` `""+x` form, and restore `foldsAtPrint` after `knownBranch`
and `pickedOperand` instead of clearing it.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Reports for 9aaf819, computed by this pull request's own code. Each section updates when its workflow finishes.
Preview package
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@23246
yarn add -D webpack@https://pkg.pr.new/webpack@23246
pnpm add -D webpack@https://pkg.pr.new/webpack@23246
From Preview package run #12601.
Generated code size
Comparing base (444601d) to head (9aaf819). 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 |
— |
10352 |
— |
— |
— |
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.
Sample apps
No sample app changed size.
26 unchanged app(s)
| App |
Gzip |
Gzip change |
Raw |
Raw change |
library amd |
1.38 KiB |
— |
2.68 KiB |
— |
library amd-require |
1.38 KiB |
— |
2.67 KiB |
— |
library assign |
1.38 KiB |
— |
2.67 KiB |
— |
library assign-properties |
1.42 KiB |
— |
2.80 KiB |
— |
library commonjs |
1.38 KiB |
— |
2.66 KiB |
— |
library commonjs-module |
1.38 KiB |
— |
2.67 KiB |
— |
library commonjs-static |
1.55 KiB |
— |
3.54 KiB |
— |
library commonjs2 |
1.38 KiB |
— |
2.67 KiB |
— |
library global |
1.38 KiB |
— |
2.66 KiB |
— |
library jsonp |
1.37 KiB |
— |
2.66 KiB |
— |
library module |
1.21 KiB |
— |
2.35 KiB |
— |
library self |
1.38 KiB |
— |
2.66 KiB |
— |
library system |
1.41 KiB |
— |
2.73 KiB |
— |
library this |
1.38 KiB |
— |
2.66 KiB |
— |
library umd |
1.44 KiB |
— |
2.86 KiB |
— |
library umd2 |
1.44 KiB |
— |
2.86 KiB |
— |
library var |
1.38 KiB |
— |
2.67 KiB |
— |
library window |
1.38 KiB |
— |
2.66 KiB |
— |
node-ssr |
96.36 KiB |
— |
371.30 KiB |
— |
node-ssr-esm |
96.61 KiB |
— |
372.00 KiB |
— |
react-100 |
32.17 KiB |
— |
150.55 KiB |
— |
react-1k |
73.34 KiB |
— |
907.38 KiB |
— |
react-1k-esm |
72.54 KiB |
— |
906.44 KiB |
— |
react-5k |
191.49 KiB |
— |
4.08 MiB |
— |
webworker |
36.60 KiB |
— |
95.02 KiB |
— |
webworker-esm |
35.67 KiB |
— |
94.21 KiB |
— |
No asset changed size.
No runtime gained or lost a runtime module.
Built test/configCases with the defaults a user gets, and the apps in test/sizeCoreReports (apps/): 2497 test(s), 10352 asset(s), 107 emitted nothing.
From Generated code size run #7236.
Types Coverage
Typed lines: 99.69% (181019 of 181575)
| Kind |
Base |
Head |
Change |
any |
48 |
48 |
— |
unknown |
50 |
50 |
— |
object |
18 |
18 |
— |
Function |
1 |
1 |
— |
| untyped |
98 |
98 |
— |
any counts EXPECTED_ANY, a written any and the any TypeScript infers where no type is written, such as const map = new Map() or const list = []. unknown counts a written unknown; ThrownValue, the unknown a throw or a rejected promise hands on, is left out. object counts EXPECTED_OBJECT and Object, Function counts EXPECTED_FUNCTION. Untyped counts the identifiers whose type is or holds any, wherever it comes from; the any TypeScript's built-in lib and Node.js's @types/node write in their own signatures, such as the replacer of String#replace or a stream's chunk, is left out, and so is the open fallback beside declared fields, such as KnownBuildInfo & Record<string, any>, though reading a key no field declares is counted.
This pull request adds or removes no escape hatch, any or untyped identifier.
55 file(s) in lib/, hot/, declarations/ and bin/ still have an escape hatch, `any` or untyped identifiers
| File |
Typed lines |
any |
unknown |
object |
Function |
untyped |
lib/Compilation.js |
99.75% |
5 |
|
|
|
15 |
lib/logging/createConsoleLogger.js |
99.00% |
|
|
|
|
15 |
lib/module/NormalModuleFactory.js |
99.41% |
|
|
|
|
15 |
declarations/WebpackOptions.ts |
100.00% |
12 |
|
|
|
2 |
lib/module/NormalModule.js |
99.55% |
4 |
|
|
|
9 |
lib/javascript/syntax-parser.js |
100.00% |
|
10 |
|
|
|
lib/asset/AssetModulesPlugin.js |
99.38% |
|
|
|
|
9 |
lib/Compiler.js |
100.00% |
2 |
4 |
|
|
|
lib/javascript/syntax-printer.js |
100.00% |
|
1 |
5 |
|
|
lib/loaders/LoaderPlugin.js |
99.42% |
|
|
|
|
6 |
lib/util/SourceProcessor.js |
100.00% |
|
6 |
|
|
|
lib/dependencies/amd/AMDPlugin.js |
99.31% |
|
|
|
|
5 |
lib/dependencies/amd/AMDRuntimeModules.js |
95.45% |
|
|
|
|
4 |
lib/javascript/JavascriptModulesPlugin.js |
100.00% |
|
|
|
|
4 |
lib/loaders/LoaderOptionsPlugin.js |
100.00% |
4 |
|
|
|
|
lib/module/Module.js |
100.00% |
4 |
|
|
|
|
lib/resolve/getResolveOptionsKey.js |
100.00% |
|
4 |
|
|
|
lib/serialization/ObjectMiddleware.js |
100.00% |
|
|
4 |
|
|
lib/util/SortableSet.js |
100.00% |
|
4 |
|
|
|
lib/config/normalization.js |
99.57% |
|
|
|
|
3 |
lib/css/syntax-parser.js |
100.00% |
|
3 |
|
|
|
lib/hmr/HotModuleReplacement.runtime.js |
100.00% |
|
2 |
1 |
|
|
lib/html/syntax-parser.js |
100.00% |
|
3 |
|
|
|
lib/javascript/JavascriptParser.js |
100.00% |
|
|
1 |
|
2 |
lib/stats/StatsFactory.js |
100.00% |
2 |
|
1 |
|
|
lib/config/defineConfig.js |
100.00% |
2 |
|
|
|
|
lib/css/syntax.js |
100.00% |
|
2 |
|
|
|
lib/define/DefinePlugin.js |
100.00% |
|
1 |
|
1 |
|
lib/hmr/HotModuleReplacementPlugin.js |
100.00% |
|
1 |
|
|
1 |
lib/hmr/JavascriptHotModuleReplacement.runtime.js |
100.00% |
|
|
2 |
|
|
lib/html/syntax.js |
100.00% |
|
2 |
|
|
|
lib/index.js |
100.00% |
2 |
|
|
|
|
lib/loaders/LoaderRunner.js |
100.00% |
2 |
|
|
|
|
lib/module/Parser.js |
100.00% |
2 |
|
|
|
|
lib/node/nodeConsole.js |
100.00% |
|
2 |
|
|
|
lib/rules/BasicEffectRulePlugin.js |
93.75% |
|
|
|
|
2 |
lib/rules/UseEffectRulePlugin.js |
99.06% |
|
|
|
|
2 |
lib/util/cleverMerge.js |
100.00% |
|
|
2 |
|
|
lib/util/implicitTypeLoaderFallback.js |
100.00% |
|
|
|
|
2 |
lib/config/WebpackOptionsApply.js |
100.00% |
|
|
|
|
1 |
lib/config/cli.js |
100.00% |
1 |
|
|
|
|
lib/dependencies/import/ImportParserPlugin.js |
100.00% |
|
1 |
|
|
|
lib/dll/DllReferencePlugin.js |
100.00% |
1 |
|
|
|
|
lib/errors/JSONParseError.js |
100.00% |
|
|
|
|
1 |
lib/graph/ModuleGraph.js |
100.00% |
1 |
|
|
|
|
lib/javascript/syntax.js |
100.00% |
|
1 |
|
|
|
lib/logging/Logger.js |
100.00% |
1 |
|
|
|
|
lib/output/ManifestPlugin.js |
100.00% |
1 |
|
|
|
|
lib/serialization/types.js |
100.00% |
|
|
1 |
|
|
lib/stats/DefaultStatsFactoryPlugin.js |
100.00% |
|
1 |
|
|
|
lib/stats/StatsPrinter.js |
100.00% |
1 |
|
|
|
|
lib/template/Template.js |
100.00% |
1 |
|
|
|
|
lib/util/magicComment.js |
100.00% |
|
1 |
|
|
|
lib/util/makeSerializable.js |
100.00% |
|
|
1 |
|
|
lib/util/terminalColors.js |
100.00% |
|
1 |
|
|
|
From Types Coverage run #3498.
Module loading
How many files a fresh Node.js process loads (require or import) to do each thing below; a change from the pull request's base is marked 🔴 when it grew and 🟢 when it shrank. Every file is startup time, so fewer is better. webpack files are this package's own (lib/, hot/); node_modules files are its dependencies'.
| What the process does |
webpack files |
node_modules files |
require("webpack") |
2 |
0 |
import "webpack" |
2 |
0 |
| JavaScript syntax |
11 |
0 |
| CSS syntax |
12 |
0 |
| HTML syntax |
11 |
0 |
| XML syntax |
11 |
0 |
| JavaScript minifier |
12 |
0 |
| CSS minifier |
14 |
0 |
| HTML minifier |
19 |
0 |
| XML minifier |
14 |
0 |
| JSON minifier |
1 |
0 |
| development build |
439 |
103 |
| production build |
446 |
133 |
| watch with HMR, one rebuild |
449 |
110 |
From Module loading run #742.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review.
Walkthrough
-
The JavaScript syntax printer now restores nested folding state, applies explicit safety checks when simplifying unsigned right shifts, and runs constant-template folding before the empty-string addition check. Regression tests and fixtures cover shift evaluation and template substitutions.
Changes: JavaScript printer folding
| Layer / File(s) |
Summary |
Restore nested folding state lib/javascript/syntax-printer.js |
knownBranch and pickedOperand now restore the prior foldsAtPrint value after evaluating expressions. |
Check unsigned right-shift operands lib/javascript/syntax-printer.js, test/unitCases/javascript/printer.unittest.js, test/fixtures/javascript/one-pass-minify-of-statement-sequences-should-drop-a-0-an-operand-of-takes-2/index.js |
shiftsSafelyBare now applies explicit type and conversion checks. shiftedOperandOf also permits the simplification when the opposite operand is a numeric literal. Tests and a fixture cover retained coercions and evaluation order. |
Reorder template and empty-string folding lib/javascript/syntax-printer.js, test/unitCases/javascript/printer.unittest.js, test/fixtures/javascript/one-pass-minify-of-statement-sequences-should-print-a-template-of-one-3/index.js |
The printsAddedToEmpty check now runs after constant-template folding. Tests and a fixture cover constant and nonconstant template substitutions. |
Suggested labels: area: parser
Suggested reviewers: aryanraj45
Change: Bug fix
Merge Risk: Minimal · up to 9aaf8
-
No merge-blocking issue is established for the printer changes; merge after normal checks.
Pre-merge checks: 3 · 1
-
Failed checks: 1 inconclusive
| Check name |
Status |
Explanation |
Resolution |
| Title check |
 |
The title uses the required fix(minify): subject form and describes the BigInt-related |0 change. The branch prefix is not provided, so its match cannot be verified. |
Provide the branch name or branch prefix to confirm that fix matches it. |
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. |
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning Some tools did not complete. Review the errors below.
ast-grep (0.51.1)
-
lib/javascript/syntax-printer.js
-
ast-grep timed out on this file
test/unitCases/javascript/printer.unittest.js
-
ast-grep timed out on this file
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
-
Recent review info
-
Run configuration
-
Commits
-
Reviewing files that changed from the base of the PR and between 444601d and 9aaf819.
Files ignored due to path filters: 1
-
test/unitCases/javascript/__snapshots__/invariants.unittest.js.snap is excluded by !**/*.snap, !test/**/__snapshots__/**
Files selected for processing: 4
-
lib/javascript/syntax-printer.js
test/fixtures/javascript/one-pass-minify-of-statement-sequences-should-drop-a-0-an-operand-of-takes-2/index.js
test/fixtures/javascript/one-pass-minify-of-statement-sequences-should-print-a-template-of-one-3/index.js
test/unitCases/javascript/printer.unittest.js
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
|
Sorry, something went wrong.
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
ℹ️ 38 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 fix/minify-shift-fold-follow-ups (9aaf819) with main (444601d)
|
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.
Assignees
No one assigned
Labels
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.
|