fix: should render export name when re-export from different modules#12886
fix: should render export name when re-export from different modules#12886
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes how the ESM library plugin resolves and reuses export names when the same module is re-exported from multiple entry modules, and adds a regression test to cover that behavior.
Changes:
- Adjusted
EsmLibraryPlugin::add_chunk_exportto consistently reuse an existing export name for non-strict exports and simplify the strict/non-strict conflict handling logic. - Tightened where
strict_exportsis applied when wiring entry exports (especially for external and concatenated modules) so that conflicts on entry export names are detected correctly. - Added a new
export-shared-namespaceESM output test (including snapshot) to cover re-exporting the same namespace from multiple entries.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
tests/rspack-test/esmOutputCases/basic/export-shared-namespace/shared.js |
Defines a simple shared module (a, b) used as the source of the namespace re-exports for the new test. |
tests/rspack-test/esmOutputCases/basic/export-shared-namespace/rspack.config.js |
Configures a test build with two entry points (main and index) to exercise shared namespace re-exports. |
tests/rspack-test/esmOutputCases/basic/export-shared-namespace/main.js |
Re-exports the shared module as namespace ns1 from one entry, participating in the shared-namespace test scenario. |
tests/rspack-test/esmOutputCases/basic/export-shared-namespace/index.js |
Re-exports the same shared module as namespace ns2 from another entry, testing name reuse across modules. |
tests/rspack-test/esmOutputCases/basic/export-shared-namespace/__snapshots__/esm.snap.txt |
Captures the expected ESM output: a single shared_js.mjs namespace export (ns1) and correct re-export aliasing (ns1 as ns2) from separate entry chunks. |
crates/rspack_plugin_esm_library/src/link.rs |
Updates add_chunk_export and its call sites to correctly handle repeated exports of the same local symbol, apply strict export conflict checks in the right places, and support the new shared-namespace re-export behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Rsdoctor Bundle Diff AnalysisFound 5 projects in monorepo, 0 projects with changes. 📊 Quick Summary
Generated by Rsdoctor GitHub Action |
📦 Binary Size-limit
🎉 Size decreased by 1.13KB from 48.31MB to 48.30MB (⬇️0.00%) |
CodSpeed Performance ReportMerging this PR will not alter performanceComparing Summary
Footnotes
|
Summary
Should render correct export name when re-export from different modules
Related links
Checklist