Latest Results
fix(es/minifier): mark properties assigned through destructuring targets as mutated (#12398)
**Description:**
With `hoist_props`, a property that is only written through a
destructuring assignment
target (`[o.n] = [2]`, `({ x: o.n } = obj)`) was treated as never
written, so it was
hoisted and its initial value inlined into the assignment target itself,
producing invalid
JavaScript (`[1]=[2]`).
The usage analyzer already marks `o` as property-mutated for `o.n = v`
via
`mark_mutation_if_member`, but the `AssignTarget::Pat` branch of
`visit_assign_expr` and
the for-in/for-of heads never did. This PR walks the pattern and marks
every member target
at any depth (array, object, default, rest) the same way. It only ever
over-preserves.
The extra work runs only for assignments with a pattern on the left and
for-in/for-of
heads, as a single walk of the pattern.
The existing `issues/11084` fixture runs without `hoist_props`, which is
why the original
report still reproduced. With `@swc/core` 1.16.2 default options it
breaks inside any
function body (e.g. an IIFE), and at the top level once `toplevel` is
enabled.
This also updates `issues/9739`: its snapshot had frozen the same bug
through variable
inlining (`[arr[0], arr[1]] = …` became writes to fresh array literals,
so `arr` was never
swapped). The new output keeps the swap.
**Testing:**
- `issue_12397_hoist_props_destructuring_member_targets` (exec test, 9
variants) fails
without the change and passes with it.
- `cargo test -p swc_ecma_minifier --no-fail-fast`: 0 failures across
all test binaries.
- `cargo clippy -p swc_ecma_minifier --all-targets -- -D warnings`:
clean.
Fixes #12397. Follow-up of #11084 / #11221. fix(nodejs): complete Amaro REPL support APIs (#12395)
**Description:**
Complete the four Node.js/Amaro support requests in
`@swc/nodejs-support-wasm`. An input such as `import fs from "node:fs"`
now declares `fs`, so later REPL inputs can use it. Static imports use
local declarations instead of rewriting references within a single
input; existing import hoisting, export validation, and import
attributes are preserved.
Add `tokenize` for compact highlighting tokens and `findTopLevelAwaits`
for module-scope await locations, including `for await` and `await
using`. Both support strings and UTF-8 `Uint8Array` inputs, with
JavaScript UTF-16 coordinates. Also recognize `SyntaxError::Unexpected`
with `<eof>` as recoverable. Include TypeScript declarations,
documentation, shared Rust/WASM fixtures, and executable REPL coverage.
**BREAKING CHANGE:**
In `@swc/nodejs-support-wasm`, transformed default and named imports now
capture initial export values in local `const` bindings rather than
rewriting reads into live namespace property accesses. Namespace imports
retain the module namespace object. This matches the requested REPL
behavior.
**Validation:**
- `cargo fmt --all`
- `cargo clippy --all --all-targets -- -D warnings`
- `cargo test -p binding_nodejs_support_wasm`: 20 passed
- Node.js support WASM test script: 57 passed in both default and
`nightly` feature builds
- Core, minifier, TypeScript, and AST viewer WASM test scripts: all
passed
- `packages/core`: `pnpm build:dev` and `pnpm test`; 119 passed, 3
skipped by the existing configuration
- Checked 525 incremental REPL input prefixes for valid, non-overlapping
token ranges
Rust commands ran with `RUSTC_WRAPPER=` because the configured `sccache`
executable is unavailable locally.
**Related issue (if exists):**
Closes #12378. Latest Branches
0%
baltasarblanco:fix/12397-hoist-props-destructuring-targets 0%
pederbe:learn/5394-import-validation 0%
kdy1/fix-nodejs-support-12378 © 2026 CodSpeed Technology