Skip to content

fix(transform-shaker): fix export * as ns handling and guard structural children#816

Merged
layershifter merged 3 commits intomainfrom
fix/vm-error-wrapping-and-shaker-structural-children
Mar 13, 2026
Merged

fix(transform-shaker): fix export * as ns handling and guard structural children#816
layershifter merged 3 commits intomainfrom
fix/vm-error-wrapping-and-shaker-structural-children

Conversation

@layershifter
Copy link
Member

@layershifter layershifter commented Mar 13, 2026

Summary

  • Fix export * as ns handling — graph builder now correctly treats export * as ns from "module" as a named export (not a wildcard re-export), preventing incorrect tree-shaking behavior.
  • Guard structural children from removalremoveDeadCode() no longer removes syntactically required children (source, exported on export/import declarations, CatchClause.param, LabeledStatement.label, loop test expressions), preventing invalid ESM output.

Test plan

  • npx nx test transform-shaker — all tests pass (includes 2 new export * as ns tests)
  • npx nx test webpack-plugin — all tests pass (no regressions)

🤖 Generated with Claude Code

@layershifter layershifter requested a review from a team as a code owner March 13, 2026 12:43
@github-actions
Copy link

github-actions bot commented Mar 13, 2026

📊 Bundle size report

✅ No changes found

@layershifter layershifter force-pushed the fix/vm-error-wrapping-and-shaker-structural-children branch from e9e9aee to 4a9cec1 Compare March 13, 2026 13:26
layershifter and others added 2 commits March 13, 2026 17:28
…aker structural child removal

- Wrap vm.runInContext() errors in Module.evaluate() as proper host Error instances
  with filename context, fixing NonErrorEmittedError in webpack
- Add ExportAllDeclaration.exported edge in graph builder, distinguishing
  `export * as ns` (named export) from `export *` (wildcard re-export)
- Guard syntactically required children (source, exported) from removal in
  removeDeadCode(), preventing invalid ESM output

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@layershifter layershifter force-pushed the fix/vm-error-wrapping-and-shaker-structural-children branch from 4a9cec1 to 20ab490 Compare March 13, 2026 16:28
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@layershifter layershifter changed the title fix(transform,transform-shaker): wrap VM errors, fix shaker structural child removal fix(transform-shaker): fix export * as ns handling and guard structural children Mar 13, 2026
@layershifter layershifter enabled auto-merge (squash) March 13, 2026 16:31
@layershifter layershifter merged commit f3b5e3f into main Mar 13, 2026
4 checks passed
@layershifter layershifter deleted the fix/vm-error-wrapping-and-shaker-structural-children branch March 13, 2026 16:45
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.

2 participants