Skip to content

Conversation

@LingyuCoder
Copy link
Contributor

Summary

This pull request improves the handling of exports when ESM modules re-export CommonJS modules. The changes refactor the exports_info implementation to simplify the codebase and fix issues with nested exports warnings.

The main improvements include:

  • Refactored exports_info code to reduce complexity and improve maintainability (net reduction of ~108 lines)
  • Added comprehensive test cases for ESM reexporting CommonJS modules with default exports
  • Fixed missing export warnings for nested exports in ESM-CommonJS interop scenarios

Checklist

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

- Add test cases for ESM reexporting CommonJS modules
- Refactor exports_info code to simplify implementation
- Fix missing export warnings for nested exports
Copilot AI review requested due to automatic review settings December 30, 2025 04:09
@netlify
Copy link

netlify bot commented Dec 30, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 3f66c10
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/6953505e4837b800083895b8

@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 30, 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 pull request refactors the exports_info implementation by removing the redirect_to mechanism, simplifying the codebase and fixing issues with nested exports warnings in ESM-CommonJS interop scenarios.

  • Removes the redirect_to field and all associated logic from ExportsInfoData, eliminating approximately 108 lines of code
  • Adds comprehensive test coverage for ESM reexporting CommonJS modules with default exports
  • Updates export ordering in warning messages (now shows alphabetically sorted exports)

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/rspack_core/src/exports/exports_info.rs Removes redirect_to field from ExportsInfoData struct and simplifies related methods by removing redirect logic
crates/rspack_core/src/exports/exports_info_getter.rs Removes all redirect_to handling logic from getter methods, simplifying export info traversal
crates/rspack_core/src/exports/exports_info_setter.rs Removes set_redirect_name_to method that was used to manage redirect relationships
crates/rspack_plugin_javascript/src/plugin/flag_dependency_exports_plugin.rs Simplifies export merging logic by removing redirect_to checks and updating merge_exports to set exports_info directly
crates/rspack_plugin_javascript/src/plugin/flag_dependency_usage_plugin.rs Removes redirect_to check from has_nested determination logic
crates/rspack_plugin_merge_duplicate_chunks/src/lib.rs Removes redirect_to check from is_equally_used function, simplifying equality comparison
tests/rspack-test/normalCases/parsing/missing-export-warning-nested/warnings.js Updates expected export ordering in warning messages from "default, d" to "d, default"
tests/rspack-test/normalCases/parsing/esm-commonjs-interop/index.js Adds test cases for ESM reexporting CommonJS modules with default exports
tests/rspack-test/normalCases/parsing/esm-commonjs-interop/lib.js Adds CommonJS module with named and default exports
tests/rspack-test/normalCases/parsing/esm-commonjs-interop/reexport.js Adds ESM module that reexports CommonJS module as namespace
tests/rspack-test/normalCases/parsing/esm-commonjs-interop/warnings.js Adds expected warning for missing nested export in reexported CommonJS module

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

@github-actions
Copy link
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 823.4 KB 0
react-5k 2.7 MB 0
rome 984.3 KB 0
ui-components 2.1 MB 0

Generated by Rsdoctor GitHub Action

@github-actions
Copy link
Contributor

📦 Binary Size-limit

Comparing 3f66c10 to refactor: refine exports info for CJS and ESM interop (#12577) by harpsealjs

❌ Size increased by 3.75KB from 48.00MB to 48.00MB (⬆️0.01%)

@LingyuCoder LingyuCoder changed the title fix: improve ESM-CommonJS interop exports handling refactor: remove redirect_to in exports info Dec 30, 2025
@github-actions github-actions bot added release: refactor and removed release: bug fix release: bug related release(mr only) labels Dec 30, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 30, 2025

📝 Ecosystem CI detail: Open

suite result
rspress ✅ success
examples ✅ success
devserver ✅ success
rslib ✅ success
modernjs ❌ failure
rstest ✅ success
rsdoctor ✅ success
rsbuild ✅ success
nuxt ✅ success
plugin ✅ success
lynx-stack ❌ failure

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 30, 2025

CodSpeed Performance Report

Merging #12581 will not alter performance

Comparing fix/esm-commonjs-interop-exports (3f66c10) with main (4ecc031)

Summary

✅ 16 untouched
⏩ 1 skipped1

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.

@LingyuCoder LingyuCoder merged commit ae64ee9 into main Dec 30, 2025
64 checks passed
@LingyuCoder LingyuCoder deleted the fix/esm-commonjs-interop-exports branch December 30, 2025 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: refactor 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