Skip to content

refactor: export lexical runtime globals for esm chunks#14741

Draft
LingyuCoder wants to merge 6 commits into
mainfrom
seal/stacked-lexical-runtime-globals
Draft

refactor: export lexical runtime globals for esm chunks#14741
LingyuCoder wants to merge 6 commits into
mainfrom
seal/stacked-lexical-runtime-globals

Conversation

@LingyuCoder

Copy link
Copy Markdown
Contributor

Summary

  • add a lexical runtime-global rendering mode for the ESM output + split runtime chunk case
  • export runtime module globals as lexical __rspack_* bindings from the runtime chunk instead of mounting them on __rspack_context
  • import those lexical bindings from runtime chunks at ESM library render/link sites, including setter helpers such as __rspack_set_*
  • refresh runtime-mode ESM output snapshots

Context

This is stacked on #14740. The base PR only enables the RuntimeModeEsmOutput context import coverage and fixes modern ESM chunk loading. This PR contains the lexical runtime-global export/import behavior needed for tree shaking when downstream consumers depend on the ESM output runtime chunk.

The behavior is scoped to output module builds using Rspack runtime mode with a split modern-module runtime chunk.

Checks

  • pnpm run build:binding:dev
  • pnpm run test:unit

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

📦 Binary Size-limit

Comparing bf0ef18 to fix: respect runtime mode in mf identifiers (#14782) by harpsealjs

❌ Size increased by 73.63KB from 66.55MB to 66.63MB (⬆️0.11%)

@github-actions

Copy link
Copy Markdown
Contributor

Rsdoctor Bundle Diff Analysis

Found 5 projects in monorepo, 5 projects with changes.

📊 Quick Summary
Project Total Size Gzip Size Change Gzip Change
popular-libs 1.7 MB 551.5 KB - -
react-10k 5.6 MB 1.3 MB - -
react-5k 2.7 MB 663.8 KB - -
react-1k 823.1 KB 217.0 KB - -
ui-components 4.9 MB 1.4 MB - -
📋 Detailed Reports (Click to expand)

📁 popular-libs

Path: ../build-tools-performance/cases/popular-libs/dist/rsdoctor-data.json

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

Metric Current Baseline Change
📊 Total Size 1.7 MB - -
🗜️ Gzip Size 551.5 KB - -
📄 JavaScript 1.7 MB - -
🎨 CSS 0 B - -
🌐 HTML 289.0 B - -
📁 Other Assets 0 B - -

📁 react-10k

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

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

Metric Current Baseline Change
📊 Total Size 5.6 MB - -
🗜️ Gzip Size 1.3 MB - -
📄 JavaScript 5.6 MB - -
🎨 CSS 21.0 B - -
🌐 HTML 328.0 B - -
📁 Other Assets 0 B - -

📁 react-5k

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

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

Metric Current Baseline Change
📊 Total Size 2.7 MB - -
🗜️ Gzip Size 663.8 KB - -
📄 JavaScript 2.7 MB - -
🎨 CSS 21.0 B - -
🌐 HTML 328.0 B - -
📁 Other Assets 0 B - -

📁 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 - -

📁 ui-components

Path: ../build-tools-performance/cases/ui-components/dist/rsdoctor-data.json

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

Metric Current Baseline Change
📊 Total Size 4.9 MB - -
🗜️ Gzip Size 1.4 MB - -
📄 JavaScript 4.8 MB - -
🎨 CSS 112.1 KB - -
🌐 HTML 328.0 B - -
📁 Other Assets 0 B - -

Generated by Rsdoctor GitHub Action

Base automatically changed from seal/lexical-runtime-exports to main July 10, 2026 03:52
@LingyuCoder LingyuCoder changed the title fix: export lexical runtime globals for esm chunks refactor: export lexical runtime globals for esm chunks Jul 13, 2026
@LingyuCoder LingyuCoder changed the base branch from main to seal/runtime-template-render-modes July 13, 2026 11:45
@LingyuCoder LingyuCoder force-pushed the seal/runtime-template-render-modes branch from aa258ea to 0af5acb Compare July 13, 2026 13:39
@LingyuCoder LingyuCoder force-pushed the seal/stacked-lexical-runtime-globals branch from 2dbde1d to 40f063b Compare July 13, 2026 14:20
@codspeed-hq

codspeed-hq Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will improve performance by 2.22%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 42 untouched benchmarks
⏩ 47 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation rust@create_module_hashes 8.5 ms 8.3 ms +2.22%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing seal/stacked-lexical-runtime-globals (bf0ef18) with main (27ff319)

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.

Base automatically changed from seal/runtime-template-render-modes to main July 14, 2026 04:52
@LingyuCoder LingyuCoder force-pushed the seal/stacked-lexical-runtime-globals branch from 40f063b to afc24cb Compare July 14, 2026 06:10
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