refactor: unify runtime globals render modes#14762
Conversation
📦 Binary Size-limit
❌ Size increased by 24.00KB from 66.51MB to 66.53MB (⬆️0.04%) |
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
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 unifiedRuntimeCodeTemplate. - Introduces
RuntimeGlobalsRenderMode/RuntimeTemplateRenderModeand 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.
This comment was marked as outdated.
This comment was marked as outdated.
aa258ea to
0af5acb
Compare
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. |
Summary
RuntimeGlobalsRenderModefor webpack, rspack context, and rspack lexical identifier renderingRuntimeTemplateRenderModeto select the module, runtime module, and chunk render-mode combination for each runtime modeRuntimeTemplatefactory methods