refactor: processing more string concatenation in runtime template part 2#12235
refactor: processing more string concatenation in runtime template part 2#12235LingyuCoder merged 4 commits intomainfrom
Conversation
✅ Deploy Preview for rspack canceled.
|
There was a problem hiding this comment.
Pull Request Overview
This PR continues the refactoring effort to move string concatenation logic from Rust code into EJS runtime templates. This approach improves maintainability by consolidating runtime code generation in templates rather than having it scattered across Rust source files.
- Migrated
get_unique_id.jstoget_unique_id.ejstemplate with dynamic bundler name/version - Extracted link prefetch/preload code into dedicated EJS templates for both module and JSONP chunk loading
- Simplified conditional logic in templates by moving string concatenation from Rust to EJS
- Removed
cow_utilsdependency from affected modules
Reviewed Changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
crates/rspack_plugin_runtime/src/runtime_module/rspack_unique_id.rs |
Refactored to use EJS template rendering instead of string replacement with cow_utils |
crates/rspack_plugin_runtime/src/runtime_module/module_chunk_loading.rs |
Added new prefetch/preload link templates and migrated link generation code from Rust to EJS |
crates/rspack_plugin_runtime/src/runtime_module/jsonp_chunk_loading.rs |
Added new prefetch/preload link templates and migrated link generation code from Rust to EJS |
crates/rspack_plugin_runtime/src/runtime_module/load_script.rs |
Simplified template variable handling by moving conditional logic to EJS template |
crates/rspack_plugin_runtime/src/runtime_module/runtime/get_unique_id.ejs |
New template for generating unique ID with dynamic bundler info |
crates/rspack_plugin_runtime/src/runtime_module/runtime/get_unique_id.js |
Removed in favor of EJS template approach |
crates/rspack_plugin_runtime/src/runtime_module/runtime/module_chunk_loading.ejs |
Updated to handle _with_on_chunk_load condition inline |
crates/rspack_plugin_runtime/src/runtime_module/runtime/module_chunk_loading_with_preload_link.ejs |
New template for module preload link generation |
crates/rspack_plugin_runtime/src/runtime_module/runtime/module_chunk_loading_with_prefetch_link.ejs |
New template for module prefetch link generation |
crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_preload_link.ejs |
New template for JSONP preload link generation |
crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading_with_prefetch_link.ejs |
New template for JSONP prefetch link generation |
crates/rspack_plugin_runtime/src/runtime_module/runtime/load_script.ejs |
Updated to handle unique prefix conditional inline |
crates/rspack_plugin_runtime/src/runtime_module/runtime/load_script_create_script.ejs |
Updated to use SCRIPT_NONCE constant instead of __webpack_require__.nc |
tests/rspack-test/statsOutputCases/split-chunks/__snapshots__/stats.txt |
Updated snapshot to reflect new code generation |
tests/rspack-test/statsOutputCases/immutable/__snapshots__/stats.txt |
Updated content hash due to runtime code changes |
tests/rspack-test/esmOutputCases/split-chunks/export-temp-runtime/__snapshots__/esm.snap.txt |
Updated snapshot showing trailing space from template conditional |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
crates/rspack_plugin_runtime/src/runtime_module/runtime/module_chunk_loading.ejs
Outdated
Show resolved
Hide resolved
📦 Binary Size-limit
❌ Size increased by 4.88KB from 47.48MB to 47.48MB (⬆️0.01%) |
CodSpeed Performance ReportMerging #12235 will not alter performanceComparing Summary
|
Summary
Should process all string concatenation in runtime templates of runtime modules and avoid processing them in rust dead code.
Related links
Checklist