Avatar for the swc-project user
swc-project
swc
BlogDocsChangelog

Performance History

Latest Results

fix(es/minifier): Avoid generating mangled property names that collide with existing properties (#11839) ## What's the problem this PR addresses? Closes #11027. When `jsc.minify.mangle.props` is enabled, the property mangler can rename a property in a subclass to a name that already exists as a property of a base class (or of any other object in the program), producing observable shadowing at runtime. Minimal repro from the issue: ```js class Class1 { e = 1; } class Class2 extends Class1 { someField = 2; } console.log(new Class2().e); // expected: 1 ``` Before the fix, `someField` was mangled to `e`, so `new Class2().e` returned `2` instead of the inherited `1`. ## How did you fix it? Root cause is in `crates/swc_ecma_minifier/src/pass/mangle_props.rs`. The state already builds an `unmangleable` set containing both reserved DOM/JS property names (loaded from `domprops.json` / `jsprops.json`) and all property names seen in the program. But `gen_name` called `Base54Chars::encode` directly, which only skips JavaScript reserved words — it never consults `unmangleable`. In the repro, `e` is present in `domprops.json`, so `Class1.e` is correctly preserved by `is_reserved`. The encoder then walks `a, b, c, ...` and may emit `e` for `someField`, colliding with the inherited property. The fix advances the encoder in a loop until it produces a candidate not in `unmangleable`. The set already aggregates exactly what we need to avoid, so no extra bookkeeping is needed. In practice this is 0-2 extra `encode` calls per generated name. ## Testing - Added `issue_11027_inherited_class_property_collision` in `crates/swc_ecma_minifier/tests/mangle.rs` using the existing `assert_mangled` harness with `props` mangling enabled (the fixture-based suite at `tests/mangle/**` does not enable property mangling, so an inline test is the right vehicle here, in line with the other `props`-related tests in this file). - `cargo test -p swc_ecma_minifier --test mangle` passes (2217 tests). - `./scripts/exec.sh` passes (2129/2130, 1 ignored, unchanged). - `cargo fmt --all` and `cargo clippy -p swc_ecma_minifier --all-targets -- -D warnings` clean. --------- Co-authored-by: DongYun Kang <kdy.1997.dev@gmail.com>
main
10 hours ago
test(es/minifier): Cover mangle props runtime collisions
baltasarblanco:fix/11027-mangle-props-name-collision
11 hours ago
use fx
Austaras:main
1 day ago
feat(ecma): add node and scope ids
kdy1/node-scope-ids
1 day ago
fix(swc_cli): preserve watch input roots
kdy1/issue-4017-cli-comment-fixes
1 day ago

Latest Branches

CodSpeed Performance Gauge
0%
fix(es/minifier): Avoid generating mangled property names that collide with existing properties#11839
11 hours ago
5efb4e2
baltasarblanco:fix/11027-mangle-props-name-collision
CodSpeed Performance Gauge
0%
feat(es/minifier): Fine grained effect analysis of class#11814
6 days ago
2d8a87d
Austaras:main
CodSpeed Performance Gauge
+4%
1 day ago
eaac5da
kdy1/node-scope-ids
© 2026 CodSpeed Technology
Home Terms Privacy Docs