Skip to content

Commit fee639c

Browse files
feat(minify): drop unread call arguments and fold Object.keys and .length (#22871)
* fix(minify): read a local function handed the global object or a built-in Its parameter stands for what it is handed, so `patch(Array)` writing `C.prototype` or `patch(globalThis)` writing `g.Number` counts, while a helper that only reads, as `isGlobal(globalThis)`, still folds. Claude-Session: https://claude.ai/code/session_01ViD41i2KdwwGxrDk7yrjeD * feat(minify): read `arguments[i]` as its parameter without `reduce_vars`, and `[-0]` as `[0]` Where nothing writes the parameter or the `arguments` object, as swc does; closes swc's `12209` and `arguments-canonical-index` gaps. Claude-Session: https://claude.ai/code/session_01ViD41i2KdwwGxrDk7yrjeD * feat(minify): drop unread call arguments and fold `Object.keys`, `.length` and `Array(-0)` Trim arguments past a known function's or constructor's parameters, and write `0` for one an unused parameter takes, where terser leaves them; fold `Object.keys` without `reduce_vars` once the probe finds no write of `Object`, `Math` calls of another's result, and a known function's `length` under `unsafe`. Closes eleven of swc's gaps and two of oxc's. Claude-Session: https://claude.ai/code/session_01ViD41i2KdwwGxrDk7yrjeD * fix(minify): read a parameter as the object handed it, whatever its name, and keep `Array(-0)` where `Array` is written A function handed a second, different object counts as patching it. Claude-Session: https://claude.ai/code/session_01ViD41i2KdwwGxrDk7yrjeD * fix(minify): resolve no callee or global write where the program reads `eval` An `eval` may write any binding unseen, as swc's `issue_11684_nested_eval_preserves_constructor_arguments` does. Retire the twelve terser cases the trimmed arguments closed. Claude-Session: https://claude.ai/code/session_01ViD41i2KdwwGxrDk7yrjeD * perf(minify): release the probe's function and name tables once a program is compressed Claude-Session: https://claude.ai/code/session_01ViD41i2KdwwGxrDk7yrjeD * test: import the ParserOptions type the SyntaxTree tests use Ported from #22875, which fixes the `lint` failure on `main`. Claude-Session: https://claude.ai/code/session_01ViD41i2KdwwGxrDk7yrjeD * fix(minify): follow a name set to a local function when it is handed a global `const alias = patch; alias(Array)` no longer lets a prototype patch go unseen. Claude-Session: https://claude.ai/code/session_01ViD41i2KdwwGxrDk7yrjeD
1 parent 0bd77d3 commit fee639c

7 files changed

Lines changed: 645 additions & 65 deletions

File tree

‎.changeset/060-minify-swc-gaps.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"webpack": minor
3+
---
4+
5+
Drop unread call arguments and fold `Object.keys` and `.length` when minifying.

0 commit comments

Comments
 (0)