Skip to content

refactor(esm-library): remove redundant module marking#14875

Merged
JSerFeng merged 1 commit into
mainfrom
codex/dedupe-esm-module-marking
Jul 21, 2026
Merged

refactor(esm-library): remove redundant module marking#14875
JSerFeng merged 1 commit into
mainfrom
codex/dedupe-esm-module-marking

Conversation

@JSerFeng

Copy link
Copy Markdown
Contributor

Summary

  • Remove the obsolete scope-hoisting module-map construction from finish_modules; entry exports are still marked as used at this stage.
  • Keep the final module marking in optimize_dependencies, after dependency-graph adjustments and before the map's first consumers.
  • Register the ESM library optimize_dependencies hook only once.

Previously, the module map built during finish_modules was overwritten before it was consumed, while the same optimize_dependencies hook was registered twice. This caused redundant full-module traversals without changing the final rendering state.

Testing

  • cargo fmt --all --check
  • corepack pnpm run build:binding:dev
  • corepack pnpm exec rstest EsmOutput.test.js (458 tests passed)
  • cargo clippy -p rspack_plugin_esm_library --all-targets --all-features
  • git diff --check

Related links

N/A

Checklist

  • Tests updated (not required; covered by the existing ESM output suite).
  • Documentation updated (not required).

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

📝 Rspack Ecosystem CI: Open

suite result
rsdoctor ✅ success
rsbuild ✅ success
plugin ✅ success
devserver ✅ success
rspress ✅ success
rstest ✅ success
modernjs ✅ success
rslib ✅ success
lynx-stack ✅ success
examples ❌ failure
rsbuild-rsc-plugin ✅ success

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

📦 Binary Size-limit

Comparing 1331d36 to fix: include output path in chunk render cache keys (#14877) by Gengkun

🎉 Size decreased by 8.00KB from 66.64MB to 66.64MB (⬇️0.01%)

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Rsdoctor Bundle Diff Analysis

Found 5 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Gzip Size Change Gzip Change
popular-libs 1.7 MB 552.1 KB 0 0
react-10k 5.6 MB 1.3 MB 0 0
react-1k 823.1 KB 217.0 KB 0 0
react-5k 2.7 MB 663.8 KB 0 0
ui-components 4.9 MB 1.4 MB 0 0

Generated by Rsdoctor GitHub Action

@codspeed-hq

codspeed-hq Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 43 untouched benchmarks
⏩ 47 skipped benchmarks1


Comparing codex/dedupe-esm-module-marking (1331d36) with main (439df0f)

Open in CodSpeed

Footnotes

  1. 47 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@JSerFeng
JSerFeng force-pushed the codex/dedupe-esm-module-marking branch from ac68d9c to 1331d36 Compare July 21, 2026 03:13
@JSerFeng
JSerFeng marked this pull request as ready for review July 21, 2026 06:31
Copilot AI review requested due to automatic review settings July 21, 2026 06:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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’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.

@JSerFeng
JSerFeng merged commit a0e983a into main Jul 21, 2026
39 checks passed
@JSerFeng
JSerFeng deleted the codex/dedupe-esm-module-marking branch July 21, 2026 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants