Repository navigation
Commit 6c822b0
authored
feat(javascript): fold assignments, inline conditional callees, flatten name-passing calls and fold literal built-ins in the minifier (#22584)
* feat(javascript): fold assignments to locals into their first read in the minifier
Claude-Session: https://claude.ai/code/session_01ViD41i2KdwwGxrDk7yrjeD
* feat(javascript): read a copied binding in place of a copy written through in the minifier
Claude-Session: https://claude.ai/code/session_01ViD41i2KdwwGxrDk7yrjeD
* feat(javascript): fold `RegExp` of literals, `Object.keys` of object literals and unsafe-math `+` and `Math.pow` in the minifier
Claude-Session: https://claude.ai/code/session_01ViD41i2KdwwGxrDk7yrjeD
* feat(javascript): inline functions a conditional callee chooses and flatten calls passed their parameters' own names in the minifier
Claude-Session: https://claude.ai/code/session_01ViD41i2KdwwGxrDk7yrjeD
* fix(javascript): record a copied binding as captured where its read replaces a copy in the minifier
A function reading `y` in place of a `let` copy never listed `y` among the bindings it captures, so inlining it into a function declaring that name again read the inner binding instead.
Claude-Session: https://claude.ai/code/session_01ViD41i2KdwwGxrDk7yrjeD
* fix(javascript): stop at a conditional's test when inlining a function into a callee it chooses in the minifier
The guard read `parent.condition`, which conditional nodes do not have, so a function read as a conditional's test in another function was inlined there too.
Claude-Session: https://claude.ai/code/session_01ViD41i2KdwwGxrDk7yrjeD
* fix(javascript): keep built-in rewrites off assigned globals and BigInt operands in the minifier
The `RegExp`, `Object.keys` and `Math.pow` rewrites now skip a global the program assigns, and dropping a unary `+` under `unsafe_math` keeps the left one so two BigInts still throw.
Claude-Session: https://claude.ai/code/session_01ViD41i2KdwwGxrDk7yrjeD
* fix(javascript): keep the JSDoc of `globalMayBeRebound` on its function in the minifier
Claude-Session: https://claude.ai/code/session_01ViD41i2KdwwGxrDk7yrjeD
* fix(javascript): keep the minifier's new folds where they pay and off patched built-ins
Claude-Session: https://claude.ai/code/session_01ViD41i2KdwwGxrDk7yrjeD
* fix(javascript): keep a `let` assignment before its own declaration
Folding an assignment to a function's `let` into a later read could move
it past `let x;` in the same block, so `{ x = 1; let x; return x; }` no
longer threw. The collapse scan now stops at the target's own `let`.
Claude-Session: https://claude.ai/code/session_01ViD41i2KdwwGxrDk7yrjeD1 parent 0027179 commit 6c822b0
6 files changed
Lines changed: 912 additions & 63 deletions
File tree
- lib/javascript
- test
- helpers
- specCases
- unitCases
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1644 | 1644 | | |
1645 | 1645 | | |
1646 | 1646 | | |
| 1647 | + | |
| 1648 | + | |
1647 | 1649 | | |
1648 | 1650 | | |
1649 | 1651 | | |
| |||
0 commit comments