Latest Results
fix(es/minifier): Drop unused callbacks passed to empty functions (#12684)
**Description:**
Calls to known empty functions in comma expressions can retain unused
callback bodies. For the reproduction in #12683, enabling `toplevel`
should produce `console.log(42);`, matching Terser, but currently leaves
the empty calls and their callbacks in the output.
Reduce calls in non-final sequence positions when the callee is an
identifier and every argument is a function expression, arrow function,
or literal, without spreads. Require both `reduce_vars` and
`side_effects`, reuse the existing function analysis, and preserve
reference-sensitive sequence behavior.
Add six focused fixture groups covering the exact issue reproduction,
annotated wrappers, argument effects, reference semantics, and each
disabled optimization option. Three fixtures also check execution before
and after two minifications.
Validation:
- `cargo test -p swc_ecma_minifier --no-fail-fast`: 8,099 passed.
- `./scripts/exec.sh` in `crates/swc_ecma_minifier`: 2,620 passed.
- `cargo clippy --all --all-targets -- -D warnings`, `cargo fmt --all`,
and `git diff --check` passed.
**Related issue (if exists):**
Fixes #12683
Downstream report: https://github.com/web-infra-dev/rspack/issues/16445
Co-authored-by: Craig Macomber (Microsoft) <42876482+CraigMacomber@users.noreply.github.com>
Co-authored-by: Donny/강동윤 <kdy.1997.dev@gmail.com> fix(es/minifier): Preserve `this` and inferred names in sequence expressions (#12693)
<!-- Note: CI script will automatically rebase your PR so please do not
rebase unless required -->
**Description:**
Two optimizations change the meaning of a sequence expression when they
remove its `0` placeholder.
1. `Expr::directness_matters` did not include `super` property access.
The optimizer changed `(0, super.method)()` to `super.method()`. This
changes `this` from `undefined` to the current object. The same error
occurs for ``(0, super.method)`` `` and for `super` in object literals.
This PR adds `Expr::SuperProp` to `directness_matters`.
2. The Pure pass changed `(0, function () {})` to `function () {}`. When
the value is assigned in `var f = ...`, `{ k: ... }`, a class field, a
pattern default, or a logical assignment, the function then gets an
inferred name. This breaks `keep_fnames` and `keep_classnames`. Now the
Pure pass keeps the `0` in front of an anonymous function, arrow
function, or class when the matching option is on. The output does not
change when the options are off.
I found these errors while I reviewed #12684. That PR replaces calls to
empty functions in a sequence with `0`. After that PR, the same errors
also occur for inputs that work today.
Two new fixtures cover the changes: `seq-super-callee` and
`seq-keep-names`. Each fixture checks the output snapshot. It also
compares the stdout of the original code with the stdout of the code
after two minifications (`expected.repeat-stdout`).
Local validation:
- `cargo fmt --all`: done.
- `cargo test -p swc_ecma_minifier --no-fail-fast`: passed.
- `./scripts/exec.sh` in `crates/swc_ecma_minifier`: passed.
- `cargo test -p swc_ecma_ast -p swc_ecma_transforms_optimization
--no-fail-fast`: passed.
- `cargo clippy -p swc_ecma_ast -p swc_ecma_minifier -p
swc_ecma_transforms_optimization --all-targets -- -D warnings`: passed.
- `cargo clippy --all --all-targets -- -D warnings`: not completed. The
build of `openssl-sys` failed because `pkg-config` is not installed on
this machine.
- CI and review: pending.
**Related issue (if exists):**
None.
---------
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com> Latest Branches
0%
0%
LingyuCoder:seal/fix-noop-sequence-calls 0%
kdy1/pr-12684-regression-inputs © 2026 CodSpeed Technology