Skip to content

Conversation

@JSerFeng
Copy link
Contributor

Summary

Manually resolve exports that are star exported.

Improve NodeTargetPlugin support for module output.

Related links

Checklist

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

Copilot AI review requested due to automatic review settings December 16, 2025 18:10
@netlify
Copy link

netlify bot commented Dec 16, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 72d7db1
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/6942967b22533900093dd1ff

@github-actions github-actions bot added team The issue/pr is created by the member of Rspack. release: refactor labels Dec 16, 2025
@JSerFeng JSerFeng force-pushed the chore/add-more-tests branch from 755a144 to f8e7bd9 Compare December 16, 2025 18:12
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 refactors the ESM library plugin to manually resolve star-exported exports and improves NodeTargetPlugin to properly handle module output format. The key architectural changes include:

  • NodeTargetPlugin enhancement: Now accepts an outputModule parameter to switch between node-commonjs and module-import external types based on the output format
  • Star re-export resolution: Introduces a new resolve_re_export_star_from_unknown function that recursively collects exports from star re-exports, replacing the previous complex re-export linking logic
  • Export linking simplification: Replaces the multi-hundred-line link_re_export function with a more direct approach that resolves all exports (including star exports) upfront and then generates the appropriate bindings

Reviewed changes

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

Show a summary per file
File Description
crates/rspack_plugin_externals/src/node_target_plugin.rs Added output_module parameter to switch external type between node-commonjs and module-import
packages/rspack/src/builtin-plugin/NodeTargetPlugin.ts Updated to accept and pass outputModule parameter
packages/rspack/src/rspackOptionsApply.ts Pass output.module flag to NodeTargetPlugin
packages/rspack/src/builtin-plugin/EsmLibraryPlugin.ts Sets output.module = true to mark ESM output
crates/rspack_plugin_esm_library/src/link.rs Major refactoring: removed link_re_export, added resolve_re_export_star_from_unknown, simplified export linking logic
crates/rspack_plugin_esm_library/src/render.rs Reordered import sources to appear before runtime/decl/render sources; added support for decl_before_exports
crates/rspack_plugin_esm_library/src/chunk_link.rs Added decl_before_exports field to store variable declarations needed before exports
crates/rspack/src/builder/*.rs Updated builder to pass output_module parameter with proper default handling
crates/rspack_binding_api/src/raw_options/raw_builtins/mod.rs Updated binding API to handle boolean parameter for NodeTargetPlugin
crates/node_binding/rspack.wasi*.js Removed redundant explicit re-exports (cleanup)
tests/rspack-test/esmOutputCases/** Updated test snapshots reflecting new export resolution behavior; reorganized some tests

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

@JSerFeng JSerFeng force-pushed the chore/add-more-tests branch from f8e7bd9 to 21a52e8 Compare December 16, 2025 18:14
@github-actions
Copy link
Contributor

github-actions bot commented Dec 16, 2025

Rsdoctor Bundle Diff Analysis

Found 5 project(s) in monorepo.

📊 Quick Summary (Click to expand)
Project Total Size Change
react-10k 5.7 MB ➡️ 0 B (0.0%)
react-1k 823.4 KB ➡️ 0 B (0.0%)
react-5k 2.7 MB ➡️ 0 B (0.0%)
ui-components 2.1 MB ➡️ 0 B (0.0%)
rome 984.3 KB ➡️ 0 B (0.0%)
📋 Detailed Reports (Click to expand)

📁 react-10k

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

📌 Baseline Commit: 3058658f38 | PR: #12487

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: 3058658f38 | PR: #12487

Metric Current Baseline Change
📊 Total Size 823.4 KB 823.4 KB 0 B (0.0%)
📄 JavaScript 823.4 KB 823.4 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

📁 react-5k

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

📌 Baseline Commit: 3058658f38 | PR: #12487

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: 3058658f38 | PR: #12487

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

📁 rome

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

📌 Baseline Commit: 3058658f38 | PR: #12487

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

Generated by Rsdoctor GitHub Action

@github-actions
Copy link
Contributor

github-actions bot commented Dec 16, 2025

📦 Binary Size-limit

Comparing 72d7db1 to chore: release v1.7.0-beta.0 (#12487) by CPunisher

🎉 Size decreased by 28.13KB from 48.29MB to 48.26MB (⬇️0.06%)

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 16, 2025

CodSpeed Performance Report

Merging #12476 will not alter performance

Comparing chore/add-more-tests (72d7db1) with main (3058658)

Summary

✅ 17 untouched

@JSerFeng JSerFeng force-pushed the chore/add-more-tests branch from 21a52e8 to 826b33d Compare December 16, 2025 18:54
Timeless0911
Timeless0911 previously approved these changes Dec 17, 2025
@JSerFeng JSerFeng force-pushed the chore/add-more-tests branch 4 times, most recently from f597c08 to 8f836c1 Compare December 17, 2025 11:24
Manually resolve exports that are star exported.
Improve NodeTargetPlugin support for module output.
@JSerFeng JSerFeng force-pushed the chore/add-more-tests branch from 8f836c1 to 72d7db1 Compare December 17, 2025 11:39
@JSerFeng JSerFeng enabled auto-merge (squash) December 17, 2025 11:49
@JSerFeng JSerFeng merged commit a0fc091 into main Dec 17, 2025
52 checks passed
@JSerFeng JSerFeng deleted the chore/add-more-tests branch December 17, 2025 12:01
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