Skip to content

refactor: render runtime globals with runtime template#12144

Merged
LingyuCoder merged 1 commit intomainfrom
refactor/name-in-ejs
Nov 10, 2025
Merged

refactor: render runtime globals with runtime template#12144
LingyuCoder merged 1 commit intomainfrom
refactor/name-in-ejs

Conversation

@LingyuCoder
Copy link
Copy Markdown
Contributor

Summary

Should render all RuntimeGlobals by sending params to dojang templates.

Related links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings November 10, 2025 11:16
@github-actions github-actions bot added the team The issue/pr is created by the member of Rspack. label Nov 10, 2025
@netlify
Copy link
Copy Markdown

netlify bot commented Nov 10, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 3d53b65
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/6911c97b42f33a0007fb4b01

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_globals function and supporting infrastructure in runtime_template.rs to 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.

@github-actions
Copy link
Copy Markdown
Contributor

📦 Binary Size-limit

Comparing 3d53b65 to fix: loader order of nested rules (#12132) by nilptr

❌ Size increased by 6.25KB from 48.08MB to 48.09MB (⬆️0.01%)

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Nov 10, 2025

CodSpeed Performance Report

Merging #12144 will not alter performance

Comparing refactor/name-in-ejs (3d53b65) with main (c57e2db)

Summary

✅ 17 untouched

@LingyuCoder LingyuCoder changed the title refactor: render runtime globals with params refactor: render runtime globals with runtime template Nov 10, 2025
@LingyuCoder LingyuCoder enabled auto-merge (squash) November 10, 2025 13:05
@LingyuCoder LingyuCoder merged commit 5409f3f into main Nov 10, 2025
79 of 81 checks passed
@LingyuCoder LingyuCoder deleted the refactor/name-in-ejs branch November 10, 2025 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: refactor team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants