Skip to content

Conversation

@JSerFeng
Copy link
Contributor

@JSerFeng JSerFeng commented Dec 11, 2025

Summary

related issue: web-infra-dev/rsbuild#6746

Should first look into the export_map for concatenated modules, then find the internal name of it. Use export_info of ref module instead of current module

Related links

Checklist

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

Note

Resolve normal re-exports via the referenced module’s export info/export_map (including externals and concatenated modules), and add a test covering deep re-exports with a new lib4 export.

  • ESM linking:
    • Normal re-exports: Derive export_name from get_target(item.export_info) and use the referenced module’s exports info to compute the used name (instead of the current module).
    • External modules: Pass the computed export_name as ids when re-exporting from external modules.
    • Concatenated modules: Resolve internal_name by mapping export_name through export_map before lookup.
  • Tests:
    • Update deep re-exports ESM case to re-export lib4, adjusting snapshot and assertions.

Written by Cursor Bugbot for commit 35ac638. This will update automatically on new commits. Configure here.

Copilot AI review requested due to automatic review settings December 11, 2025 09:49
@netlify
Copy link

netlify bot commented Dec 11, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 35ac638
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/693a955c3cb85a0008c4c2a7

@github-actions github-actions bot added release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack. labels Dec 11, 2025
Copy link
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 an issue with ESM module re-exports where the wrong name was being used for concatenated modules. The fix ensures that when re-exporting from a concatenated module, the code first looks into the export_map to find the exported name, then retrieves the internal name. The key change is to use the export info of the referenced module instead of the current module when determining the used name for re-exports.

Key changes:

  • Updated logic to correctly resolve export names through the export_map for concatenated modules
  • Changed to use referenced module's export info instead of current module's export info when determining used names
  • Added test case for re-exporting a renamed export (lib_local as lib4)

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
crates/rspack_plugin_esm_library/src/link.rs Core fix: Updated re-export logic to use ref module's export info and properly resolve names through export_map for concatenated modules
tests/rspack-test/esmOutputCases/re-exports/deep-re-exports-esm/lib3.js Added test case: exports local variable lib_local as renamed export lib4
tests/rspack-test/esmOutputCases/re-exports/deep-re-exports-esm/index.js Updated test assertions to verify the new lib4 export
tests/rspack-test/esmOutputCases/re-exports/deep-re-exports-esm/snapshots/esm.snap.txt Updated snapshot showing correct output with lib_local as lib4 in exports

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@JSerFeng JSerFeng force-pushed the fix/esm-lib-missing-exports branch from 0312ed3 to 35ac638 Compare December 11, 2025 09:56
@github-actions
Copy link
Contributor

Rsdoctor Bundle Diff Analysis

Found 5 project(s) in monorepo.

📁 react-10k

Path: ../build-tools-performance/cases/react-10k/dist/rsdoctor-data.json

📌 Baseline Commit: b73f59a9a4 | PR: #12420

Metric Current Baseline Change
📊 Total Size 5.7 MB 5.7 MB 0 B (0.0%)
📄 JavaScript 5.7 MB 5.7 MB 0 B (0.0%)
🎨 CSS 21.0 B 21.0 B 0 B (0.0%)
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: react-10k Bundle Diff

📁 react-1k

Path: ../build-tools-performance/cases/react-1k/dist/rsdoctor-data.json

📌 Baseline Commit: b73f59a9a4 | PR: #12420

Metric Current Baseline Change
📊 Total Size 823.6 KB 823.6 KB 0 B (0.0%)
📄 JavaScript 823.6 KB 823.6 KB 0 B (0.0%)
🎨 CSS 0 B 0 B N/A
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: react-1k Bundle Diff

📁 rome

Path: ../build-tools-performance/cases/rome/dist/rsdoctor-data.json

📌 Baseline Commit: b73f59a9a4 | PR: #12420

Metric Current Baseline Change
📊 Total Size 984.3 KB 984.3 KB 0 B (0.0%)
📄 JavaScript 984.3 KB 984.3 KB 0 B (0.0%)
🎨 CSS 0 B 0 B N/A
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: rome Bundle Diff

📁 react-5k

Path: ../build-tools-performance/cases/react-5k/dist/rsdoctor-data.json

📌 Baseline Commit: b73f59a9a4 | PR: #12420

Metric Current Baseline Change
📊 Total Size 2.7 MB 2.7 MB 0 B (0.0%)
📄 JavaScript 2.7 MB 2.7 MB 0 B (0.0%)
🎨 CSS 21.0 B 21.0 B 0 B (0.0%)
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: react-5k Bundle Diff

📁 ui-components

Path: ../build-tools-performance/cases/ui-components/dist/rsdoctor-data.json

📌 Baseline Commit: b73f59a9a4 | PR: #12420

Metric Current Baseline Change
📊 Total Size 2.1 MB 2.1 MB 0 B (0.0%)
📄 JavaScript 2.0 MB 2.0 MB 0 B (0.0%)
🎨 CSS 83.0 KB 83.0 KB 0 B (0.0%)
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: ui-components Bundle Diff

Generated by Rsdoctor GitHub Action

@github-actions
Copy link
Contributor

📦 Binary Size-limit

Comparing 35ac638 to chore: improve AGENTS.md and add project architecture documentation (#12420) by harpsealjs

❌ Size increased by 640bytes from 48.21MB to 48.21MB (⬆️0.00%)

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 11, 2025

CodSpeed Performance Report

Merging #12423 will not alter performance

Comparing fix/esm-lib-missing-exports (35ac638) with main (b73f59a)

Summary

✅ 17 untouched

@JSerFeng JSerFeng enabled auto-merge (squash) December 11, 2025 10:40
@JSerFeng JSerFeng merged commit b48a33a into main Dec 11, 2025
55 checks passed
@JSerFeng JSerFeng deleted the fix/esm-lib-missing-exports branch December 11, 2025 10:40
@github-actions github-actions bot mentioned this pull request Dec 11, 2025
2 tasks
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