Skip to content

perf: deduplicate repeated dynamic reexport code#14748

Draft
JSerFeng wants to merge 1 commit into
mainfrom
fy/reexport-runtime-dedup
Draft

perf: deduplicate repeated dynamic reexport code#14748
JSerFeng wants to merge 1 commit into
mainfrom
fy/reexport-runtime-dedup

Conversation

@JSerFeng

Copy link
Copy Markdown
Contributor

Summary

  • Add a shared runtime helper for repeated dynamic export * code.
  • Keep the existing inline code path when a module has fewer than 16 dynamic star reexports.
  • Preserve the existing checked reexport implementation; sharing that path was measured but did not improve compressed size.

Dynamic star reexports currently emit the same getter collection loop for every dependency. This change moves that loop into __webpack_require__.re only when the helper cost is amortized, while keeping the low-cardinality output unchanged.

For 16 dynamic reexports in a production build with the SWC minimizer, compared with a mechanical old-inline baseline:

  • raw: 5520 -> 4997 bytes (-523 bytes)
  • gzip: 1722 -> 1713 bytes (-9 bytes)

The helper preserves source enumeration order, single and multiple exclusion handling, environment-specific getter capture, and the existing define-after-collection behavior.

Related links

N/A

Checklist

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

@github-actions

Copy link
Copy Markdown
Contributor

📦 Binary Size-limit

Comparing 114cfc8 to feat: support persistent cache for module hashes (#14717) by Gengkun

❌ Size increased by 20.00KB from 66.48MB to 66.50MB (⬆️0.03%)

@codspeed-hq

codspeed-hq Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 43 untouched benchmarks
⏩ 47 skipped benchmarks1


Comparing fy/reexport-runtime-dedup (114cfc8) with main (af1556e)

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.

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

📝 Rspack Ecosystem CI: Open

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

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.

1 participant