Skip to content

feat: reserve exports/module names in the mangler runtime test#185

Merged
Dunqing merged 1 commit into
mainfrom
mangler-reserved-exports
Jul 2, 2026
Merged

feat: reserve exports/module names in the mangler runtime test#185
Dunqing merged 1 commit into
mainfrom
mangler-reserved-exports

Conversation

@Dunqing

@Dunqing Dunqing commented Jul 2, 2026

Copy link
Copy Markdown
Member

Node's cjs-module-lexer detects a CommonJS module's named exports by lexically scanning for exports.<name> = / module.exports token patterns — no scope analysis. UMD / CommonJS wrappers bind exports / module as ordinary function parameters, and mangling renames them, erasing every named export the lexer can see: import { queue } from "async" fails the mangler runtime test (failing run).

Renaming these is ecosystem-standard (esbuild / terser / swc all do it by default), so oxc keeps its default behavior and instead provides MangleOptions::reserved — the terser mangle.reserved equivalent, added in oxc-project/oxc#24041. This suite imports prebuilt dists directly, so pass ["exports", "module"].

Depends on oxc-project/oxc#24041 (merged). The mangler job also needs oxc-project/oxc#24033 to pass its idempotency phase.

Node's cjs-module-lexer detects a CommonJS module's named exports by
lexically scanning for `exports.<name> =` / `module.exports` patterns.
UMD / CommonJS wrappers bind these as function parameters, and mangling
renames them, erasing every named export the lexer can see —
`import { queue } from "async"` then fails the runtime test. Renaming is
ecosystem-standard (esbuild / terser / swc do the same), so oxc keeps
default behavior and provides `MangleOptions::reserved`
(oxc-project/oxc#24041, the terser `mangle.reserved` equivalent); pass
`["exports", "module"]` here since this suite imports prebuilt dists
directly.
@Dunqing
Dunqing merged commit d8ecf11 into main Jul 2, 2026
13 of 15 checks passed
@Dunqing
Dunqing deleted the mangler-reserved-exports branch July 2, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant