fix: preserve included external import declarations#10009
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
1b44a53 to
d93e068
Compare
|
Could you please file an issue with a minimal reproduction first? I’m not sure what you’re trying to fix. We’ve updated our CONTRIBUTING.md, https://github.com/rolldown/rolldown/blob/main/docs/contribution-guide/index.md, and in the future we may close such PRs. |
|
@IWANABETHATGUY Apologies for not creating the issue first and for not providing enough context in the PR description. I filed a minimal issue here: #10013 The original failure was found while bundling Storybook. I used Codex to help reduce that failure into a minimal reproduction, but I reviewed and adjusted the test case and fix by hand. The reduced case shows that with |
This PR aims to fix a case where the finalizer removed an included external import declaration.
The finalizer handles both
importdeclarations andexport ... fromdeclarations.Previously, when an import record did not resolve to an internal module, the finalizer removed the statement. That is not safe for an included external import declaration: the imported bindings may still be referenced by code that survived tree-shaking.
This showed up with
strictExecutionOrderbecause module bodies can be moved into__esmMinwrappers. The wrapper body could still contain code like:while the corresponding top-level import had been removed:
This keeps included unresolved/external
ImportDeclarations in the output, while leaving unresolvedexport ... fromhandling unchanged.