refactor: render runtime globals with runtime template#12144
refactor: render runtime globals with runtime template#12144LingyuCoder merged 1 commit intomainfrom
Conversation
✅ Deploy Preview for rspack canceled.
|
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the runtime template system to use a placeholder-based approach for runtime globals instead of hardcoded values. The change introduces a regex-based replacement mechanism that converts placeholders like $$RUNTIME_GLOBAL_REQUIRE$$ to their actual runtime global values (e.g., __webpack_require__).
Key changes:
- Added
replace_runtime_globalsfunction and supporting infrastructure inruntime_template.rsto handle placeholder replacement - Updated EJS templates to use placeholders for runtime globals instead of hardcoded strings
- Modified Rust runtime modules to pass necessary parameters to templates for non-placeholder values
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
crates/rspack_core/src/runtime_template.rs |
Implements regex-based runtime global placeholder replacement system with new static patterns and helper functions |
crates/rspack_plugin_runtime/src/runtime_module/runtime/startup_entrypoint_with_async.ejs |
Replaces hardcoded __webpack_require__ and __webpack_require__.s with runtime global placeholders |
crates/rspack_plugin_runtime/src/runtime_module/runtime/startup_entrypoint.ejs |
Replaces hardcoded runtime globals with placeholders matching async variant |
crates/rspack_plugin_runtime/src/runtime_module/runtime/on_chunk_loaded.ejs |
Replaces hardcoded __webpack_require__.O with placeholder, removing workaround comment for template engine limitation |
crates/rspack_plugin_runtime/src/runtime_module/runtime/module_chunk_loading_with_hmr.ejs |
Converts hardcoded module/runtime property names to template parameters |
crates/rspack_plugin_runtime/src/runtime_module/runtime/module_chunk_loading.ejs |
Replaces hardcoded __webpack_ids__, __webpack_modules__, __webpack_runtime__ with template parameters |
crates/rspack_plugin_runtime/src/runtime_module/runtime/make_deferred_namespace_object.ejs |
Converts hardcoded cache and exports references to template parameters |
crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading.ejs |
Replaces hardcoded __webpack_require__.l with LOAD_SCRIPT template variable |
crates/rspack_plugin_runtime/src/runtime_module/runtime/async_module.ejs |
Converts hardcoded webpack symbol strings to template parameters and fixes require reference |
crates/rspack_plugin_runtime/src/runtime_module/module_chunk_loading.rs |
Adds template parameters for _ids, _modules, _runtime to support template refactoring |
crates/rspack_plugin_runtime/src/runtime_module/make_deferred_namespace_object_runtime.rs |
Adds template parameters for module_cache and deferred_exports |
crates/rspack_plugin_runtime/src/runtime_module/async_module.rs |
Adds template parameters for webpack symbol strings and module cache |
crates/rspack_plugin_css/src/runtime/css_loading_with_loading.ejs |
Replaces hardcoded __webpack_require__.m with MODULE_FACTORIES template variable |
crates/rspack_plugin_css/src/runtime/css_loading_with_hmr.ejs |
Converts hardcoded references to use template variables for module factories and HMR handlers |
crates/rspack_plugin_css/src/runtime/css_loading.ejs |
Replaces hardcoded webpack require references with proper template variables for require, public path, and script nonce |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📦 Binary Size-limit
❌ Size increased by 6.25KB from 48.08MB to 48.09MB (⬆️0.01%) |
CodSpeed Performance ReportMerging #12144 will not alter performanceComparing Summary
|
Summary
Should render all
RuntimeGlobalsby sending params to dojang templates.Related links
Checklist