Skip to content

Commit 0220e4e

Browse files
fix(javascript): keep minified code running as written where terser diverged (#22726)
* fix(javascript): keep minified code running as written where terser diverged Differential runs over the corpora against oxc and swc, plus terser's ufuzz programs, found seven programs terser's output changes: a `let` assigned in a later initializer, `undefined` as a pattern target, a negative BigInt base, a global accessor merged across a conditional, a block's function in a loop test (Annex B), an async function's thenable and a `RegExp` holding a NUL. Also inline a block's `const` and a boolean read more than once, fold comparisons of a fresh object, and stop counting an alias as a call in `keepsConstantCall` (terser#1637). Claude-Session: https://claude.ai/code/session_01ViD41i2KdwwGxrDk7yrjeD * chore(changeset): fold the minifier equivalence entry into the pending one Claude-Session: https://claude.ai/code/session_01ViD41i2KdwwGxrDk7yrjeD * fix(javascript): keep a block's const where eval or with pins its function The JavaScript fuzzer (seeds 6 and 7) found a block const function copied into its call with its body dropped, its declaration kept by `with`. Also retire minify-corpora entries CI no longer reports. Claude-Session: https://claude.ai/code/session_01ViD41i2KdwwGxrDk7yrjeD * test(javascript): settle the async thenable test without microtaskMode vm's microtaskMode needs Node 14.6; the Node 10 baseline drains the shared microtask queue before the next macrotask instead. Claude-Session: https://claude.ai/code/session_01ViD41i2KdwwGxrDk7yrjeD
1 parent 67578f0 commit 0220e4e

7 files changed

Lines changed: 381 additions & 52 deletions

File tree

‎.changeset/110-minifier-output-growth.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"webpack": patch
33
---
44

5-
Keep minified JavaScript from growing where inlining or mangling copied names.
5+
Keep minified JavaScript from growing, or from running unlike its source.

‎lib/javascript/ScopeAnalyzer.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,6 +1682,8 @@ class CompressorVariable extends MinifierVariable {
16821682
this.inUseRun = 0;
16831683
/** @type {CompressorNode | undefined} the name a copy of it was set from, kept where a write through the copy dropped `fixed` */
16841684
this.copyOf = undefined;
1685+
/** @type {boolean} whether `reduce_vars` met a read of it before any value was set */
1686+
this.readUnset = false;
16851687
}
16861688
}
16871689

0 commit comments

Comments
 (0)