Skip to content

feat(runtime): introduce experimental.runtimeMode#14254

Open
LingyuCoder wants to merge 1 commit into
mainfrom
codex/runtime-proxy-context-redesign
Open

feat(runtime): introduce experimental.runtimeMode#14254
LingyuCoder wants to merge 1 commit into
mainfrom
codex/runtime-proxy-context-redesign

Conversation

@LingyuCoder

@LingyuCoder LingyuCoder commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Introduce experiments.runtimeMode as an experimental runtime rendering mode.

This PR adds the rspack runtime context path and updates runtime code generation so runtime globals can be rendered through __rspack_context in rspack mode while preserving the existing webpack-compatible runtime output by default.

Main changes:

  • Add runtime proxy metadata collection for tree/module/runtime requirements.
  • Render runtime context declarations, lexical runtime globals, and context field assignments for rspack mode.
  • Generate execute-module runtime source using the same runtime module source rendering path.
  • Teach parser runtime requirements and nested require/context handling about rspack runtime mode.
  • Update chunk loading, CSS loading, HMR, library, and runtime module templates to use the new runtime context path only when rspack mode is enabled.
  • Avoid forcing optional helpers such as SCRIPT_NONCE; nonce code is emitted only when the runtime requirement is actually present.
  • Add runtime-mode focused config/hot test suites and snapshots.

@LingyuCoder LingyuCoder changed the title [codex] Implement rspack runtime context mode refactor Jun 2, 2026
@LingyuCoder LingyuCoder changed the title refactor refactor(runtime): introduce rspack context Jun 2, 2026
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

📦 Binary Size-limit

Comparing e867c35 to refactor: swc exp for javascript parser plugin (#14256) by CPunisher

❌ Size increased by 88.13KB from 62.60MB to 62.68MB (⬆️0.14%)

@github-actions

github-actions Bot commented Jun 2, 2026

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.3 KB -3.0 B (-0.0%) 0
react-10k 5.6 MB 1.3 MB -73.0 B (-0.0%) -18.0 B (-0.0%)
react-1k 822.7 KB 218.2 KB -73.0 B (-0.0%) -21.0 B (-0.0%)
react-5k 2.7 MB 669.1 KB -73.0 B (-0.0%) -15.0 B (-0.0%)
ui-components 4.8 MB 1.4 MB -3.0 B (-0.0%) 0
📋 Detailed Reports (Click to expand)

📁 popular-libs

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

📌 Baseline Commit: 1fd4fca45e | PR: #14256

Metric Current Baseline Change
📊 Total Size 1.7 MB 1.7 MB -3.0 B (-0.0%)
🗜️ Gzip Size 551.3 KB 551.3 KB 0
📄 JavaScript 1.7 MB 1.7 MB -3.0 B (-0.0%)
🎨 CSS 0 B 0 B 0
🌐 HTML 289.0 B 289.0 B 0
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: popular-libs Bundle Diff

📁 react-10k

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

📌 Baseline Commit: 1fd4fca45e | PR: #14256

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

📦 Download Diff Report: react-10k Bundle Diff

📁 react-1k

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

📌 Baseline Commit: 1fd4fca45e | PR: #14256

Metric Current Baseline Change
📊 Total Size 822.7 KB 822.8 KB -73.0 B (-0.0%)
🗜️ Gzip Size 218.2 KB 218.3 KB -21.0 B (-0.0%)
📄 JavaScript 822.4 KB 822.4 KB -73.0 B (-0.0%)
🎨 CSS 0 B 0 B 0
🌐 HTML 328.0 B 328.0 B 0
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: react-1k Bundle Diff

📁 react-5k

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

📌 Baseline Commit: 1fd4fca45e | PR: #14256

Metric Current Baseline Change
📊 Total Size 2.7 MB 2.7 MB -73.0 B (-0.0%)
🗜️ Gzip Size 669.1 KB 669.1 KB -15.0 B (-0.0%)
📄 JavaScript 2.7 MB 2.7 MB -73.0 B (-0.0%)
🎨 CSS 21.0 B 21.0 B 0
🌐 HTML 328.0 B 328.0 B 0
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: react-5k Bundle Diff

📁 ui-components

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

📌 Baseline Commit: 1fd4fca45e | PR: #14256

Metric Current Baseline Change
📊 Total Size 4.8 MB 4.8 MB -3.0 B (-0.0%)
🗜️ Gzip Size 1.4 MB 1.4 MB 0
📄 JavaScript 4.7 MB 4.7 MB -3.0 B (-0.0%)
🎨 CSS 111.7 KB 111.7 KB 0
🌐 HTML 328.0 B 328.0 B 0
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: ui-components Bundle Diff

🤖 AI Degradation Analysis (Click to expand)

📁 popular-libs

📊 Size Changes

No significant regressions detected 🎉
(Total bundle: 1,806,629 → 1,806,626 bytes | Δ -0.00016%)

🔍 Root Cause Analysis

  • No code changes detected: modules and packages arrays are empty (0 added, 0 removed, 0 changed).
  • The negligible size difference (-3 bytes) is likely due to build timestamp or whitespace variations.

⚠️ Risk Assessment

Overall severity: Low

  • Initial chunk size is effectively unchanged (1,806,340 → 1,806,337 bytes), posing no risk to load performance.

💡 Optimization Suggestions

  1. Verify Commit Content: Confirm intended source code changes were included in this build, as the bundle is identical to baseline.
  2. Maintain Standards: Continue current tree-shaking and code-splitting configurations; they are stable.
  3. CI Thresholds: Ensure bundle size budgets allow for minor noise to prevent false positives in future checks.

Analysis by qwen3.5-plus

📁 react-10k

📊 Size Changes

No significant regressions detected 🎉
Win: Total bundle size decreased by 73 bytes (5,861,109 → 5,861,036).

🔍 Root Cause Analysis

  • No modules or packages were added, removed, or changed in the diff.
  • The negligible size reduction (73 bytes) across all assets suggests build metadata or hash variation rather than code changes.

⚠️ Risk Assessment

Overall severity: Low

  • Initial chunk size decreased slightly (745,709 → 745,636 bytes); zero negative impact on Time to Interactive.

💡 Optimization Suggestions

  1. No immediate actions required; the bundle is stable.
  2. Verify build reproducibility if exact byte-for-byte consistency is expected across CI runs.
  3. Continue monitoring for actual module-level changes in future PRs.

Analysis by qwen3.5-plus

📁 react-1k

📊 Size Changes

No significant regressions detected 🎉. Total bundle size decreased slightly (842,508 → 842,435 bytes).

🔍 Root Cause Analysis

  • No modules or packages were added, removed, or changed in this diff.
  • Minor size variance is attributed to build metadata or hashing differences.

⚠️ Risk Assessment

Overall severity: Low

  • Initial chunk stable at 775,950 bytes (Δ -73 bytes); no impact on Time to Interactive.

💡 Optimization Suggestions

  1. No immediate actions required; bundle health is stable.
  2. Maintain current code-splitting strategy for future features.

Analysis by qwen3.5-plus

📁 react-5k

📊 Size Changes

No significant regressions detected 🎉.
Win: Total bundle size decreased by 73 bytes (2,793,999 → 2,793,926). Initial JS also decreased slightly (525,088 → 525,015 bytes).

🔍 Root Cause Analysis

  • No module or package changes detected in the diff data (modules.changed is empty).
  • Variance likely attributed to build hash updates or negligible content shifts.

⚠️ Risk Assessment

Overall severity: Low

  • Initial chunk size reduced by 73 bytes, ensuring no negative impact on Time to Interactive (TTI) or load performance.

💡 Optimization Suggestions

  1. No immediate actions required; bundle health is stable.
  2. Maintain current code-splitting and tree-shaking configurations.
  3. Continue monitoring for deltas >10 KB in future PRs to catch regressions early.

Analysis by qwen3.5-plus

📁 ui-components

📊 Size Changes

No significant regressions detected 🎉. Total bundle size slightly decreased from 5,079,179 bytes to 5,079,176 bytes (-3 bytes).

🔍 Root Cause Analysis

  • No module or package changes detected in the diff (added/removed/changed lists are empty).
  • JS initial chunk remained effectively stable (4,964,432 → 4,964,429 bytes).
  • CSS assets unchanged at 114,419 bytes.

⚠️ Risk Assessment

Overall severity: Low

  • Negligible total size delta (-0.00006%) with no impact on initial chunk load performance or asset count.

💡 Optimization Suggestions

  1. No immediate action required; bundle health is stable.
  2. Continue monitoring future diffs for new dependency additions that might impact the initial chunk.
  3. Maintain current tree-shaking configurations as no bloat was introduced.

Analysis by qwen3.5-plus

Generated by Rsdoctor GitHub Action

@codspeed-hq

codspeed-hq Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will improve performance by 11.64%

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚠️ 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

⚡ 2 improved benchmarks
❌ 1 regressed benchmark
✅ 49 untouched benchmarks
⏩ 40 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation rust@create_chunk_assets 3.2 ms 3.3 ms -3.07%
WallTime bundle@threejs-10x-development 308.7 ms 223.7 ms +37.99%
Simulation rust@persistent_cache_restore@basic-react-development 15.8 ms 15.2 ms +4.02%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing codex/runtime-proxy-context-redesign (e867c35) with main (1fd4fca)

Open in CodSpeed

Footnotes

  1. 40 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 force-pushed the codex/runtime-proxy-context-redesign branch from 14633c9 to 59afc1b Compare June 4, 2026 04:49
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 4, 2026

Copy link
Copy Markdown

Deploying rspack with  Cloudflare Pages  Cloudflare Pages

Latest commit: 55a76d8
Status: ✅  Deploy successful!
Preview URL: https://ec6512e6.rspack-v2.pages.dev
Branch Preview URL: https://codex-runtime-proxy-context.rspack-v2.pages.dev

View logs

@LingyuCoder LingyuCoder force-pushed the codex/runtime-proxy-context-redesign branch from 5172147 to 55a76d8 Compare June 8, 2026 12:24
@LingyuCoder LingyuCoder changed the title refactor(runtime): introduce rspack context feat(runtime): introduce experimental.runtimeMode Jun 9, 2026
@LingyuCoder LingyuCoder force-pushed the codex/runtime-proxy-context-redesign branch from 0cc26f1 to e867c35 Compare June 9, 2026 07:50
@LingyuCoder LingyuCoder marked this pull request as ready for review June 9, 2026 07:52
Copilot AI review requested due to automatic review settings June 9, 2026 07:52

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.

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e867c3553b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if parser.compiler_options.experiments.runtime_mode != ExperimentRuntimeMode::Rspack {
return None;
}
static_require_member_chain(parser, for_name, members, member_expr.span, false)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve trailing require member chains

When experiments.runtimeMode is 'rspack' and code reads a static chain beyond a known runtime global, such as __webpack_require__.g.document or __webpack_require__.m.foo, members.first() only maps the first property but this call passes the full member_expr.span, so the dependency replaces the entire chain with __rspack_context.g/.m and drops the trailing property. This changes the generated code for those inputs; use the member ranges to replace only the __webpack_require__.<prop> prefix or bail out when there are additional members.

Useful? React with 👍 / 👎.

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