Skip to content

refactor: processing more string concatenation in runtime template part 2#12235

Merged
LingyuCoder merged 4 commits intomainfrom
refactor/runtime-template-part-2
Nov 19, 2025
Merged

refactor: processing more string concatenation in runtime template part 2#12235
LingyuCoder merged 4 commits intomainfrom
refactor/runtime-template-part-2

Conversation

@LingyuCoder
Copy link
Contributor

Summary

Should process all string concatenation in runtime templates of runtime modules and avoid processing them in rust dead code.

Related links

Checklist

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

Copilot AI review requested due to automatic review settings November 18, 2025 12:01
@netlify
Copy link

netlify bot commented Nov 18, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit bbaeb70
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/691d49c674c1190008dd72f0

@github-actions github-actions bot added release: refactor team The issue/pr is created by the member of Rspack. labels Nov 18, 2025
Copy link
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 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.js to get_unique_id.ejs template 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_utils dependency 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.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 18, 2025

📦 Binary Size-limit

Comparing bbaeb70 to fix: should inject prefetch startup in entry chunk instead of runtime chunk (#12233) by harpsealjs

❌ Size increased by 4.88KB from 47.48MB to 47.48MB (⬆️0.01%)

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 18, 2025

CodSpeed Performance Report

Merging #12235 will not alter performance

Comparing refactor/runtime-template-part-2 (bbaeb70) with main (0b8a3bb)

Summary

✅ 17 untouched

@LingyuCoder LingyuCoder enabled auto-merge (squash) November 19, 2025 03:49
@LingyuCoder LingyuCoder merged commit 5dfcba5 into main Nov 19, 2025
47 checks passed
@LingyuCoder LingyuCoder deleted the refactor/runtime-template-part-2 branch November 19, 2025 06:13
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