-
-
Notifications
You must be signed in to change notification settings - Fork 757
refactor(esm-lib-plugin): manually resolve exports that re star-exported, and improve NodeTargetPlugin for module output #12476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for rspack canceled.
|
755a144 to
f8e7bd9
Compare
There was a problem hiding this 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
outputModuleparameter to switch betweennode-commonjsandmodule-importexternal types based on the output format - Star re-export resolution: Introduces a new
resolve_re_export_star_from_unknownfunction 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_exportfunction 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.
f8e7bd9 to
21a52e8
Compare
Rsdoctor Bundle Diff AnalysisFound 5 project(s) in monorepo. 📊 Quick Summary (Click to expand)
📋 Detailed Reports (Click to expand)📁 react-10kPath:
📦 Download Diff Report: react-10k Bundle Diff 📁 react-1kPath:
📦 Download Diff Report: react-1k Bundle Diff 📁 react-5kPath:
📦 Download Diff Report: react-5k Bundle Diff 📁 ui-componentsPath:
📦 Download Diff Report: ui-components Bundle Diff 📁 romePath:
📦 Download Diff Report: rome Bundle Diff Generated by Rsdoctor GitHub Action |
📦 Binary Size-limit
🎉 Size decreased by 28.13KB from 48.29MB to 48.26MB (⬇️0.06%) |
CodSpeed Performance ReportMerging #12476 will not alter performanceComparing Summary
|
21a52e8 to
826b33d
Compare
f597c08 to
8f836c1
Compare
Manually resolve exports that are star exported. Improve NodeTargetPlugin support for module output.
8f836c1 to
72d7db1
Compare
Summary
Manually resolve exports that are star exported.
Improve NodeTargetPlugin support for module output.
Related links
Checklist