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

Performance History

Latest Results

fix(es/minifier): Do not reassociate inexact float multiplications (#12657) <!-- Note: CI script will automatically rebase your PR so please do not rebase unless required --> **Description:** The expression simplifier folded `(a * b) * c` into `a * (b * c)` for any numeric constants `b` and `c`. Floating-point multiplication is not associative, so this changed program results. For example, `x * 24 * 60 * 60` became `24 * x * 3600`. For `x = 365.2425`, the original returns `31556951.999999996` and the minified code returns `31556952`. This changed results in moment and luxon. `unsafe_math` did not affect this fold. Now `*` is reassociated only when the result is the same for every value of `a`: - `b` or `c` is `1` or `-1`. - `b` and `c` are powers of two with a magnitude of at least `1`, and their product is finite. Powers of two with a magnitude less than `1` are not folded. They can round a subnormal intermediate result, or overflow only in `(a * b) * c` (for example `x * 4 * 0.25`). The `&`, `|` and `^` operators are still reassociated, because they are exact on int32 values. Changes: - `swc_ecma_transforms_optimization`: add `is_exact_mul_reassociation` and use it in the `*` arm of `optimize_bin_expr`. `test_fold_arithmetic2` expected `y * 2.25 * 3` to become `y * 6.75` and `z * 24 * 60 * 60 * 1000` to become `z * 86400000`. Both expectations encoded the bug, so they now expect no fold. A new `test_fold_mul_reassociation` covers the exact and inexact cases. - `swc_ecma_minifier`: add the `issues/12634` fixture with `expected.repeat-stdout`. It runs the original and minified code and compares the output. The fixture fails without the fix. Four existing snapshots now keep the original factors, for example `1000 * hours * 60 * 60` in moment. Local validation on `8ae2c5330c` (the code change; the next commit only adds the changeset): - `cargo test -p swc_ecma_transforms_optimization`: passed. - `cargo test -p swc_ecma_minifier`: passed. - `crates/swc_ecma_minifier/scripts/exec.sh`: passed. - `cargo fmt --all` and `cargo clippy --all --all-targets -- -D warnings`: passed. **Related issue (if exists):** Closes #12634 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: baltasarblanco <252781095+baltasarblanco@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
main
37 minutes ago
fix(es/minifier): Fold never-assigned variables in conditions (#12650) **Description:** The minifier kept a branch that depends on a variable that is declared without an initializer and is never assigned. For example: ```js let transform; globalThis.process = (value) => transform ? transform(value) + ":UNREACHABLE_FEATURE_BRANCH" : value; ``` Before this change, the output kept `transform ? ... : value`. After this change, the output is `globalThis.process = (value) => value;`, and the unused `let transform;` declaration is removed. Such a variable always reads as `undefined`, also inside closures. The optimizer now records these variables and replaces a reference with `void 0` only at positions where the value lets the expression fold: - `if` tests and conditional expression tests - the operand of `!` and `typeof` - the left operand of `&&`, `||`, and `??` - `==`, `!=`, `===`, and `!==` comparisons where both operands are constant - the base of an optional chain (`x?.y`, `x?.()`) Other references keep the variable. A mangled name is shorter than `void 0`, so a full replacement makes the output larger. For example, `get-intrinsic` declares `var undefined;` and reads it many times. The optimizer does not record a variable in these cases: - it is assigned anywhere, or it is updated with `++` or `--` - it is read above its declaration (TDZ) - it is exported, or it is a top-level variable without `toplevel` - it is a parameter, a catch parameter, a `for` head binding, or `arguments` - its scope contains `eval` or `with` This change also folds `void 0 ?? x` to `x` in the pure optimizer. New fixtures are in `tests/fixture/issues/12643`. The `runtime` fixture compares Node.js output before and after two minifications. Updated outputs: - `issues/8844`: `let x; x?.x?.();` is removed. - `next/target-es2015`: an unused `devBuildPromiseResolve` callback is removed. - `pass-1/issue-6405`: the dead `if (val)` block is removed. - `terser/.../issue_1670_2`: the IIFE remains with `passes: 2`. With `passes: 3`, the output is `console.log("PASS")` again. **Validation:** - `cargo test -p swc_ecma_minifier` passed. - `./scripts/exec.sh` in `crates/swc_ecma_minifier` passed. - `cargo fmt --all` and `cargo clippy --all --all-targets -- -D warnings` passed. These results cover the source changes and fixtures. The changeset commit was added after these runs. Closes #12643 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
main
1 hour ago
test(swc): Make stack trace tests independent of the Node.js version (#12654) **Description:** The stack trace fixtures in `crates/swc/tests/stacktrace` match the stderr format of Node.js 20, which the `cargo-test` CI job uses. With other Node.js versions, the tests fail. With the version in `.node-version` (26), all 13 tests fail locally. The source-mapped stack traces are the same. Only the Node.js output format is different: | Difference | Node.js 20 | Node.js 22 | Node.js 24 and 26 | | --- | --- | --- | --- | | Blank lines after the `^` line | 2 | 2 | 1 | | `at TracingChannel.traceSync (node:diagnostics_channel:…)` frame | No | Yes | No | | Source-mapped function name in `issue-1685` | `console` | `console` | `Object.console` | `extract_node_stack_trace` now: - Removes blank lines. - Removes frames of all `node:` built-in modules, not only `node:internal`. - Removes the `Object.` receiver prefix from frame names. I regenerated the 13 `stacks.txt` files with `UPDATE=1`. The changes remove the blank lines and the `Object.` prefix. The file paths, line numbers and column numbers do not change. **Validation:** - `cargo test -p swc --test source_map -- stacktrace`: 13 passed with each of Node.js 20.20.2, 22.19.0, 24.20.0 and 26.8.1. Before this change, Node.js 22 failed 12 tests, and Node.js 24 and 26 failed 13 tests. - `cargo clippy -p swc --test source_map -- -D warnings`: passed. - `cargo fmt --all`: no changes. **Related issue (if exists):** None. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
main
3 hours ago

Latest Branches

CodSpeed Performance Gauge
0%
fix(es/minifier): Do not reassociate inexact float multiplications#12657
1 hour ago
7f7067e
kdy1/fix-issue-12634
CodSpeed Performance Gauge
0%
1 hour ago
a1e4736
kdy1/remove-claude-md
CodSpeed Performance Gauge
0%
4 hours ago
baa95c1
kdy1/fix-issue-12643
© 2026 CodSpeed Technology
Home Terms Privacy Docs