Skip to content

fix: should render export name when re-export from different modules#12886

Merged
JSerFeng merged 1 commit intomainfrom
fix/multiple-re-export-shared
Jan 29, 2026
Merged

fix: should render export name when re-export from different modules#12886
JSerFeng merged 1 commit intomainfrom
fix/multiple-re-export-shared

Conversation

@JSerFeng
Copy link
Copy Markdown
Contributor

Summary

Should render correct export name when re-export from different modules

Related links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings January 29, 2026 09:56
@github-actions github-actions bot added team The issue/pr is created by the member of Rspack. release: bug fix release: bug related release(mr only) labels Jan 29, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_export to consistently reuse an existing export name for non-strict exports and simplify the strict/non-strict conflict handling logic.
  • Tightened where strict_exports is 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-namespace ESM 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.

@github-actions
Copy link
Copy Markdown
Contributor

Rsdoctor Bundle Diff Analysis

Found 5 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Change
react-10k 5.7 MB 0
react-1k 825.5 KB 0
react-5k 2.7 MB 0
rome 984.2 KB 0
ui-components 2.3 MB 0

Generated by Rsdoctor GitHub Action

@github-actions
Copy link
Copy Markdown
Contributor

📦 Binary Size-limit

Comparing eff4cb2 to fix: fix used exports for global entry that inject to async entrypoints (#12883) by Gengkun

🎉 Size decreased by 1.13KB from 48.31MB to 48.30MB (⬇️0.00%)

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Jan 29, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing fix/multiple-re-export-shared (eff4cb2) with main (a5d5ed2)

Summary

✅ 16 untouched benchmarks
⏩ 1 skipped benchmark1

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

@JSerFeng JSerFeng merged commit eb52426 into main Jan 29, 2026
58 checks passed
@JSerFeng JSerFeng deleted the fix/multiple-re-export-shared branch January 29, 2026 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants