refactor(esm-library): remove redundant module marking#14875
Conversation
📦 Binary Size-limit
🎉 Size decreased by 8.00KB from 66.64MB to 66.64MB (⬇️0.01%) |
Rsdoctor Bundle Diff AnalysisFound 5 projects in monorepo, 0 projects with changes. 📊 Quick Summary
Generated by Rsdoctor GitHub Action |
Merging this PR will not alter performance
Comparing Footnotes
|
ac68d9c to
1331d36
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors the ESM library plugin’s module-marking flow to avoid redundant work: it removes an obsolete module-map construction from finish_modules, keeps the authoritative marking in optimize_dependencies (after dependency-graph mutations), and eliminates a duplicate optimize_dependencies hook registration.
Changes:
- Removed the redundant scope-hoisting module-map build/update from
finish_modules, keeping only the entry-exports “used” marking there. - Kept module marking consolidated in
optimize_dependencies, so the map is built once at the stage where the dependency graph is finalized. - Removed the duplicate
compilation_hooks.optimize_dependencies.tap(...)registration to avoid running the hook twice.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
finish_modules; entry exports are still marked as used at this stage.optimize_dependencies, after dependency-graph adjustments and before the map's first consumers.optimize_dependencieshook only once.Previously, the module map built during
finish_moduleswas overwritten before it was consumed, while the sameoptimize_dependencieshook was registered twice. This caused redundant full-module traversals without changing the final rendering state.Testing
cargo fmt --all --checkcorepack pnpm run build:binding:devcorepack pnpm exec rstest EsmOutput.test.js(458 tests passed)cargo clippy -p rspack_plugin_esm_library --all-targets --all-featuresgit diff --checkRelated links
N/A
Checklist