Skip to content

fix(runtime): preserve collision-free createRequire imports - #14994

Merged
LingyuCoder merged 3 commits into
mainfrom
seal/remove-redundant-create-require-alias
Jul 30, 2026
Merged

LingyuCoder merged 3 commits into
mainfrom
seal/remove-redundant-create-require-alias

Conversation

@LingyuCoder

Copy link
Copy Markdown
Contributor

Summary

  • rename the HMR-local createRequire helper to a runtime-specific identifier
  • keep collision-free createRequire imports from node:module unaliased in modern-module output
  • add executable coverage for both webpack and rspack runtime modes

Why

RspackExport reserves variables declared by runtime modules before linking top-level bindings. The generic HMR helper name reserved createRequire for every chunk, even when HMR was not emitted, causing external imports to use a longer generated alias. Giving the HMR helper a runtime-specific name removes that false collision without adding scans or allocations to the chunk/module linking hot path.

This avoids approximately 59 raw bytes / 15 gzip bytes per affected output reported in the Rslib integration corpus.

Related links

Checklist

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

@github-actions

This comment was marked as off-topic.

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

📦 Binary Size-limit

Comparing e0bb127 to chore: migrate Rstest and Rspress to Rstack CLI (#14998) by Jiahan Chen

🙈 Size remains the same at 66.74MB

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Rsdoctor Bundle Diff Analysis

Found 5 projects in monorepo, 1 project 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 - -
react-5k 2.7 MB 663.8 KB 0 0
ui-components 4.9 MB 1.4 MB 0 0
📋 Detailed Reports (Click to expand)

📁 react-1k

Path: ../build-tools-performance/cases/react-1k/dist/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 823.1 KB - -
🗜️ Gzip Size 217.0 KB - -
📄 JavaScript 822.7 KB - -
🎨 CSS 0 B - -
🌐 HTML 328.0 B - -
📁 Other Assets 0 B - -

Generated by Rsdoctor GitHub Action

@codspeed

codspeed Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 46 untouched benchmarks
⏩ 47 skipped benchmarks1


Comparing seal/remove-redundant-create-require-alias (e0bb127) with main (a187415)

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.

@LingyuCoder LingyuCoder changed the title perf: preserve collision-free createRequire imports fix(runtime): preserve collision-free createRequire imports Jul 30, 2026
@web-infra-dev web-infra-dev deleted a comment from github-actions Bot Jul 30, 2026
@LingyuCoder
LingyuCoder requested a review from stormslowly July 30, 2026 04:51
@LingyuCoder
LingyuCoder enabled auto-merge (squash) July 30, 2026 05:01
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying rspack with  Cloudflare Pages  Cloudflare Pages

Latest commit: e0bb127
Status: ✅  Deploy successful!
Preview URL: https://284d6eb6.rspack-v2.pages.dev
Branch Preview URL: https://seal-remove-redundant-create.rspack-v2.pages.dev

View logs

@LingyuCoder
LingyuCoder merged commit 6413be5 into main Jul 30, 2026
39 checks passed
@LingyuCoder
LingyuCoder deleted the seal/remove-redundant-create-require-alias branch July 30, 2026 05:46
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.

2 participants