-
-
Notifications
You must be signed in to change notification settings - Fork 733
feat: EsmLibraryPlugin supports preserveModules #11921
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 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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
Add preserveModules support to EsmLibraryPlugin, enabling splitting specified modules into individual chunks and ensuring their exports are surfaced correctly.
- Add EsmLibraryPlugin option preserveModules (path), wire through Node bindings, and implement chunk splitting in Rust
- Update ESM linking/rendering to ensure proper export symbol handling and deterministic namespace emission
- Extend test tools to configure plugin options; add new tests and snapshots for preserve-modules; clean up snapshot runtimes
Reviewed Changes
Copilot reviewed 32 out of 33 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/rspack-test/esmOutputCases/re-exports/re-export-external/snapshots/esm.snap.txt | Snapshot cleanup (remove empty runtime). |
| tests/rspack-test/esmOutputCases/re-exports/deep-re-exports-esm/snapshots/esm.snap.txt | Snapshot cleanup (remove empty runtime). |
| tests/rspack-test/esmOutputCases/preserve-modules/conflict-symbol/test.config.js | Add test config with preserveModules path. |
| tests/rspack-test/esmOutputCases/preserve-modules/conflict-symbol/src/index.js | Test for preserved modules and strict export symbols. |
| tests/rspack-test/esmOutputCases/preserve-modules/conflict-symbol/src/demo/other.js | Additional test module for conflict case. |
| tests/rspack-test/esmOutputCases/preserve-modules/conflict-symbol/src/demo/index.js | Additional test module for conflict case. |
| tests/rspack-test/esmOutputCases/preserve-modules/conflict-symbol/rspack.config.js | Rspack config for conflict test. |
| tests/rspack-test/esmOutputCases/preserve-modules/conflict-symbol/snapshots/esm.snap.txt | Snapshot for conflict-symbol preserve-modules. |
| tests/rspack-test/esmOutputCases/preserve-modules/basic/test.config.js | Add test config with preserveModules path. |
| tests/rspack-test/esmOutputCases/preserve-modules/basic/src/index.js | Basic preserve-modules test entry. |
| tests/rspack-test/esmOutputCases/preserve-modules/basic/src/demo/index.js | Basic preserve-modules demo module. |
| tests/rspack-test/esmOutputCases/preserve-modules/basic/rspack.config.js | Rspack config for basic preserve-modules. |
| tests/rspack-test/esmOutputCases/preserve-modules/basic/other2/index.js | Ancillary module for basic test. |
| tests/rspack-test/esmOutputCases/preserve-modules/basic/other1/index.js | Ancillary module for basic test. |
| tests/rspack-test/esmOutputCases/preserve-modules/basic/snapshots/esm.snap.txt | Snapshot for basic preserve-modules. |
| tests/rspack-test/esmOutputCases/externals/externals-import-render/snapshots/esm.snap.txt | Snapshot cleanup (remove empty runtime). |
| tests/rspack-test/esmOutputCases/dynamic-import/import-self/snapshots/esm.snap.txt | Snapshot cleanup (remove empty runtime). |
| tests/rspack-test/esmOutputCases/deconflict/other-chunk-local/snapshots/esm.snap.txt | Snapshot cleanup (remove empty runtime). |
| tests/rspack-test/esmOutputCases/deconflict/deconflit-local/snapshots/esm.snap.txt | Snapshot cleanup (remove empty runtime). |
| packages/rspack/src/builtin-plugin/EsmLibraryPlugin.ts | Add options to plugin and forward to builtin. |
| packages/rspack/etc/core.api.md | Update API docs for EsmLibraryPlugin options. |
| packages/rspack-test-tools/src/type.ts | Add esmLibPluginOptions to test config type. |
| packages/rspack-test-tools/src/case/esm-output.ts | Inject EsmLibraryPlugin options into tests; adjust bundle discovery. |
| packages/rspack-test-tools/etc/test-tools.api.md | Update public test-tools API docs. |
| crates/rspack_plugin_esm_library/src/render.rs | Mark runtime chunks; deterministic namespace order; restructure add() emission. |
| crates/rspack_plugin_esm_library/src/preserve_modules.rs | Implement module splitting and entry wiring for preserveModules. |
| crates/rspack_plugin_esm_library/src/plugin.rs | Wire preserveModules option; remove empty runtimes; hook optimize_chunks. |
| crates/rspack_plugin_esm_library/src/link.rs | Improve export symbol management; link for preserved modules; various fixes. |
| crates/rspack_plugin_esm_library/src/lib.rs | Register preserve_modules module. |
| crates/rspack_plugin_esm_library/src/chunk_link.rs | Change exports set to ordered set. |
| crates/rspack_binding_api/src/raw_options/raw_builtins/raw_esm_lib.rs | Define RawEsmLibraryPlugin for Node binding. |
| crates/rspack_binding_api/src/raw_options/raw_builtins/mod.rs | Hook up RawEsmLibraryPlugin to EsmLibraryPlugin constructor. |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
📦 Binary Size-limit
❌ Size increased by 50.75KB from 47.73MB to 47.78MB (⬆️0.10%) |
f4b81bf to
9c35dc4
Compare
CodSpeed Performance ReportMerging #11921 will not alter performanceComparing Summary
|
f655c17 to
54911ca
Compare
54911ca to
7885fdd
Compare
Summary
Preserve_modules now supported by splitting specific modules into single chunk
Make them export their symbols, main changes is in add_chunk_export, it can now export local to different names
For add_chunk_export(local, exported_name, strict)
Related links
Checklist