refactor: processing more string concatenation in runtime template part 1#12225
refactor: processing more string concatenation in runtime template part 1#12225LingyuCoder merged 3 commits intomainfrom
Conversation
✅ Deploy Preview for rspack canceled.
|
There was a problem hiding this comment.
Pull Request Overview
This PR refactors runtime module template processing by moving string concatenation logic from Rust code into EJS runtime templates. This improves maintainability by centralizing template logic and avoiding dead code in Rust.
Key changes:
- Refactored multiple runtime modules to use template variables instead of Rust string concatenation
- Adopted underscore-prefixed naming convention for template variables
- Moved conditional logic into EJS templates using
<% if %>blocks - Updated test snapshots to reflect changes in generated runtime code
Reviewed Changes
Copilot reviewed 44 out of 46 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/rspack-test/statsOutputCases/* | Updated snapshot hashes reflecting changed runtime output |
| tests/rspack-test/statsAPICases/*.js | Modified tests to normalize dynamic size values for consistency |
| crates/rspack_plugin_runtime/src/runtime_module/runtime/*.ejs | Refactored templates to handle string concatenation and conditional logic |
| crates/rspack_plugin_runtime/src/runtime_module/*.rs | Simplified Rust code by passing boolean/string flags instead of pre-concatenated strings |
| crates/rspack_plugin_runtime/src/runtime_module/runtime/make_namespace_object.js | Removed dead code file |
Comments suppressed due to low confidence (1)
crates/rspack_plugin_runtime/src/runtime_module/load_script.rs:1
- [nitpick] The import
cow_utils::CowUtilsis removed but this appears to be intentional as part of the refactoring away from string manipulation in Rust code. Ensure that this dependency can be removed from Cargo.toml if it's no longer used elsewhere in the crate.
use std::ptr::NonNull;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
crates/rspack_plugin_runtime/src/runtime_module/runtime/import_scripts_chunk_loading.ejs
Show resolved
Hide resolved
crates/rspack_plugin_runtime/src/runtime_module/import_scripts_chunk_loading.rs
Outdated
Show resolved
Hide resolved
crates/rspack_plugin_runtime/src/runtime_module/runtime/load_script_create_script.ejs
Show resolved
Hide resolved
crates/rspack_plugin_runtime/src/runtime_module/runtime/jsonp_chunk_loading.ejs
Outdated
Show resolved
Hide resolved
📦 Binary Size-limit
🎉 Size decreased by 5.50KB from 47.48MB to 47.47MB (⬇️0.01%) |
CodSpeed Performance ReportMerging #12225 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