Skip to content

Conversation

@JSerFeng
Copy link
Contributor

@JSerFeng JSerFeng commented Oct 20, 2025

Summary

Preserve_modules now supported by splitting specific modules into single chunk

  • Use optimizeChunks hook to split, not using splitChunks because it's performance is not expected

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)

if local is already exported
- if strict: error
- if not strict: use already exported name

if local is not exported
- if exported name is already exported and strict: error
- if exported name is already exported and not strict: find new name to export
- if exported name is not exported, export with that name

Related links

Checklist

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

@JSerFeng JSerFeng requested a review from LingyuCoder as a code owner October 20, 2025 03:11
Copilot AI review requested due to automatic review settings October 20, 2025 03:11
@JSerFeng JSerFeng requested a review from hardfist as a code owner October 20, 2025 03:11
@netlify
Copy link

netlify bot commented Oct 20, 2025

Deploy Preview for rspack ready!

Name Link
🔨 Latest commit c7bd199
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/68f7618e0a81b60008bcf65a
😎 Deploy Preview https://deploy-preview-11921--rspack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions bot added the release: feature release: feature related release(mr only) label Oct 20, 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

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.

@github-actions github-actions bot added the team The issue/pr is created by the member of Rspack. label Oct 20, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Oct 20, 2025

📦 Binary Size-limit

Comparing c7bd199 to test: display error location in jsdom (#11937) by harpsealjs

❌ Size increased by 50.75KB from 47.73MB to 47.78MB (⬆️0.10%)

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 20, 2025

CodSpeed Performance Report

Merging #11921 will not alter performance

Comparing esm-lib-plugin (c7bd199) with main (126822e)

Summary

✅ 17 untouched

@JSerFeng JSerFeng force-pushed the esm-lib-plugin branch 5 times, most recently from f655c17 to 54911ca Compare October 21, 2025 08:03
@hardfist hardfist merged commit 0eb1382 into main Oct 21, 2025
68 of 74 checks passed
@hardfist hardfist deleted the esm-lib-plugin branch October 21, 2025 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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