Skip to content

refactor: unify runtime globals render modes#14762

Merged
LingyuCoder merged 3 commits into
mainfrom
seal/runtime-template-render-modes
Jul 14, 2026
Merged

refactor: unify runtime globals render modes#14762
LingyuCoder merged 3 commits into
mainfrom
seal/runtime-template-render-modes

Conversation

@LingyuCoder

@LingyuCoder LingyuCoder commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • introduce RuntimeGlobalsRenderMode for webpack, rspack context, and rspack lexical identifier rendering
  • introduce RuntimeTemplateRenderMode to select the module, runtime module, and chunk render-mode combination for each runtime mode
  • route module, runtime module, and chunk generation through scenario-specific RuntimeTemplate factory methods
  • unify chunk and runtime-module code templates, remove the obsolete runtime-module code mode and boolean rendering flags, and derive legacy runtime module identifiers from the render mode

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

📦 Binary Size-limit

Comparing 0af5acb to fix(fs): include paths in native filesystem errors (#14760) by hardfist

❌ Size increased by 24.00KB from 66.51MB to 66.53MB (⬆️0.04%)

@codspeed-hq

codspeed-hq Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 43 untouched benchmarks
⏩ 47 skipped benchmarks1


Comparing seal/runtime-template-render-modes (0af5acb) with main (cfa680e)

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 marked this pull request as ready for review July 13, 2026 10:47
@LingyuCoder LingyuCoder requested a review from ahabhgk as a code owner July 13, 2026 10:47
Copilot AI review requested due to automatic review settings July 13, 2026 10:47

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

Note

Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.

Refactors runtime template APIs to clarify how runtime globals are rendered across module, runtime-module, and chunk generation scenarios, unifying rspack/webpack render-mode handling.

Changes:

  • Replaces the old “runtime code template” with explicit runtime-module vs chunk template factories and render-mode mappings.
  • Migrates many plugins/modules from ChunkCodeTemplate / lifetime’d templates to a unified RuntimeCodeTemplate.
  • Introduces RuntimeGlobalsRenderMode / RuntimeTemplateRenderMode and updates runtime globals/variables rendering accordingly.

Reviewed changes

Copilot reviewed 46 out of 46 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
crates/rspack_plugin_wasm/src/loading_plugin.rs Switches to the runtime-module code template factory.
crates/rspack_plugin_runtime/src/runtime_plugin.rs Uses runtime-module code template when adding runtime modules.
crates/rspack_plugin_runtime/src/runtime_module/utils.rs Updates runtime-global rendering logic to use render-mode enum.
crates/rspack_plugin_runtime/src/runtime_module/require_js_chunk_loading.rs Updates template parameter type to unified RuntimeCodeTemplate.
crates/rspack_plugin_runtime/src/runtime_module/readfile_chunk_loading.rs Updates template parameter type to unified RuntimeCodeTemplate.
crates/rspack_plugin_runtime/src/runtime_module/module_chunk_loading.rs Updates template parameter type to unified RuntimeCodeTemplate.
crates/rspack_plugin_runtime/src/runtime_module/jsonp_chunk_loading.rs Updates template parameter type to unified RuntimeCodeTemplate.
crates/rspack_plugin_runtime/src/runtime_module/import_scripts_chunk_loading.rs Updates template parameter type to unified RuntimeCodeTemplate.
crates/rspack_plugin_runtime/src/runtime_module/export_require.rs Selects runtime-module ID based on render mode rather than prefix string.
crates/rspack_plugin_runtime/src/runtime_module/async_module.rs Uses render-mode enum instead of uses_lexical_runtime_globals().
crates/rspack_plugin_runtime/src/module_chunk_format.rs Replaces ChunkCodeTemplate usage with RuntimeCodeTemplate.
crates/rspack_plugin_runtime/src/helpers.rs Replaces ChunkCodeTemplate usage with RuntimeCodeTemplate.
crates/rspack_plugin_runtime/src/common_js_chunk_format.rs Replaces ChunkCodeTemplate usage with RuntimeCodeTemplate.
crates/rspack_plugin_runtime/src/array_push_callback_chunk_format.rs Replaces ChunkCodeTemplate usage with RuntimeCodeTemplate.
crates/rspack_plugin_rstest/src/plugin.rs Uses runtime-module code template for runtime module source customization.
crates/rspack_plugin_rslib/src/plugin.rs Switches render hook template type to unified RuntimeCodeTemplate.
crates/rspack_plugin_module_info_header/src/lib.rs Switches render hook template type to unified RuntimeCodeTemplate.
crates/rspack_plugin_mf/src/lib.rs Updates MF runtime ident selection to use render-mode enum.
crates/rspack_plugin_mf/src/container/federation_data_runtime_module.rs Updates template parameter type to unified RuntimeCodeTemplate.
crates/rspack_plugin_mf/src/container/embed_federation_runtime_plugin.rs Switches render hook template type to unified RuntimeCodeTemplate.
crates/rspack_plugin_library/src/umd_library_plugin.rs Switches render hook template type to unified RuntimeCodeTemplate.
crates/rspack_plugin_library/src/system_library_plugin.rs Switches render hook template type to unified RuntimeCodeTemplate.
crates/rspack_plugin_library/src/module_library_plugin.rs Switches startup render hook template type to unified RuntimeCodeTemplate.
crates/rspack_plugin_library/src/jsonp_library_plugin.rs Switches render hook template type to unified RuntimeCodeTemplate.
crates/rspack_plugin_library/src/export_property_library_plugin.rs Switches startup render hook template type to unified RuntimeCodeTemplate.
crates/rspack_plugin_library/src/assign_library_plugin.rs Switches render/startup hook template types to unified RuntimeCodeTemplate.
crates/rspack_plugin_library/src/amd_library_plugin.rs Switches render hook template type to unified RuntimeCodeTemplate.
crates/rspack_plugin_javascript/src/runtime_context.rs Updates runtime-module rendering pipeline to no longer require passing a chunk template.
crates/rspack_plugin_javascript/src/runtime.rs Unifies runtime module generation paths and uses runtime-module code template factory.
crates/rspack_plugin_javascript/src/plugin/url_plugin.rs Switches render hook template type to unified RuntimeCodeTemplate.
crates/rspack_plugin_javascript/src/plugin/runtime_context.rs Switches runtime-context rendering conditions to render-mode driven logic.
crates/rspack_plugin_javascript/src/plugin/mod.rs Routes webpack vs rspack bootstrap/require paths via template render mode.
crates/rspack_plugin_javascript/src/plugin/drive.rs Updates JS plugin hook signatures to accept RuntimeCodeTemplate.
crates/rspack_plugin_javascript/src/plugin/api_plugin.rs Switches render hook template type to unified RuntimeCodeTemplate.
crates/rspack_plugin_esm_library/src/runtime.rs Uses render-mode enum in runtime-module logic.
crates/rspack_plugin_esm_library/src/render.rs Uses render-mode enum for require/context decisions and updates template types.
crates/rspack_plugin_esm_library/src/plugin.rs Updates hook signature template type to RuntimeCodeTemplate.
crates/rspack_plugin_esm_library/src/chunk_link.rs Updates template parameter type to unified RuntimeCodeTemplate.
crates/rspack_plugin_devtool/src/eval_source_map_dev_tool_plugin.rs Updates devtool hook template type to unified RuntimeCodeTemplate.
crates/rspack_plugin_devtool/src/eval_dev_tool_module_plugin.rs Updates devtool hook template type to unified RuntimeCodeTemplate.
crates/rspack_plugin_css/src/plugin/impl_plugin_for_css_plugin.rs Switches runtime template creation to runtime-module code template factory.
crates/rspack_core/src/runtime_template.rs Introduces render-mode enums, unifies code templates, and refactors template factories.
crates/rspack_core/src/runtime_module.rs Updates RuntimeModuleGenerateContext to use unified RuntimeCodeTemplate.
crates/rspack_core/src/runtime_globals.rs Removes runtime_variable_to_string in favor of render-mode driven rendering.
crates/rspack_core/src/options/experiments/mod.rs Removes RuntimeMode::uses_runtime_context helper (superseded by render modes).
crates/rspack_binding_api/src/plugins/interceptor.rs Updates runtime-module template creation and adjusts runtime-module name normalization.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/rspack_core/src/runtime_template.rs
Comment thread crates/rspack_core/src/runtime_template.rs
Comment thread crates/rspack_binding_api/src/plugins/interceptor.rs
Comment thread crates/rspack_binding_api/src/plugins/interceptor.rs
@LingyuCoder LingyuCoder changed the title refactor: clarify runtime template render modes refactor: unify runtime globals render modes Jul 13, 2026
@github-actions

This comment was marked as outdated.

@LingyuCoder LingyuCoder force-pushed the seal/runtime-template-render-modes branch from aa258ea to 0af5acb Compare July 13, 2026 13:39
@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

📝 Rspack Ecosystem CI: Open

suite result
plugin ✅ success
modernjs ✅ success
devserver ✅ success
examples ✅ success
lynx-stack ✅ success
rsbuild ✅ success
rslib ✅ success
rspress ⏹️ cancelled
rsbuild-rsc-plugin ✅ success
rstest ✅ success
rsdoctor ✅ success

@LingyuCoder

LingyuCoder commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

Open

📝 Rspack Ecosystem CI: Open

suite result
plugin ✅ success
modernjs ✅ success
devserver ✅ success
examples ✅ success
lynx-stack ✅ success
rsbuild ✅ success
rslib ✅ success
rspress ⏹️ cancelled
rsbuild-rsc-plugin ✅ success
rstest ✅ success
rsdoctor ✅ success

Seems to be an issue of network of CI and had passed by a retry https://github.com/rstackjs/rstack-ecosystem-ci/actions/runs/29254660127.

@LingyuCoder LingyuCoder enabled auto-merge (squash) July 14, 2026 02:49
@LingyuCoder LingyuCoder merged commit 1d04823 into main Jul 14, 2026
38 checks passed
@LingyuCoder LingyuCoder deleted the seal/runtime-template-render-modes branch July 14, 2026 04:52
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