Skip to content

Conversation

@LingyuCoder
Copy link
Contributor

🤖 AI Generated

Note: This PR is generated by AI.

📝 Description

This PR optimizes the usage of RuntimeTemplate API across multiple plugins in the Rspack codebase. The refactoring improves code consistency and maintainability by standardizing the way plugins interact with the RuntimeTemplate.

🔧 Changes

Modified Files (15 total)

Core:

  • crates/rspack_core/src/chunk_graph/mod.rs - Updated RuntimeTemplate usage patterns
  • crates/rspack_core/src/runtime_template.rs - Core RuntimeTemplate API refinements

Plugins:

  • crates/rspack_plugin_banner/src/lib.rs
  • crates/rspack_plugin_devtool/src/eval_source_map_dev_tool_plugin.rs
  • crates/rspack_plugin_esm_library/src/dependency/dyn_import.rs
  • crates/rspack_plugin_esm_library/src/link.rs
  • crates/rspack_plugin_esm_library/src/render.rs
  • crates/rspack_plugin_extract_css/src/plugin.rs
  • crates/rspack_plugin_javascript/src/dependency/esm/esm_export_imported_specifier_dependency.rs
  • crates/rspack_plugin_javascript/src/plugin/mod.rs
  • crates/rspack_plugin_library/src/system_library_plugin.rs
  • crates/rspack_plugin_module_info_header/src/lib.rs
  • crates/rspack_plugin_runtime/src/common_js_chunk_format.rs
  • crates/rspack_plugin_runtime/src/runtime_module/export_require.rs
  • crates/rspack_plugin_sri/src/runtime.rs

✨ Benefits

  • Improved code consistency across the plugin system
  • Better maintainability for future development
  • Standardized RuntimeTemplate API patterns
  • No functional changes, purely refactoring

🧪 Testing

  • All existing tests should pass
  • No breaking changes introduced

Copilot AI review requested due to automatic review settings December 5, 2025 11:02
@netlify
Copy link

netlify bot commented Dec 5, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit dd87512
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/6932bbc36cb8d7000836c295

@github-actions github-actions bot added team The issue/pr is created by the member of Rspack. release: refactor labels Dec 5, 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 refactors string formatting across 15 files in the Rspack codebase by converting traditional string literals with escaped newlines (\n) to raw string literals (r#"..."#). This is a pure refactoring that improves code readability by making multi-line string content more visually apparent, without changing any runtime behavior.

Key changes:

  • Converted format strings from escaped newline style to raw string literals
  • Applied consistently across core runtime templates and multiple plugin modules
  • Preserved all existing indentation, whitespace, and formatting in generated output

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/rspack_core/src/runtime_template.rs Updated basic_function, returning_function, and module loading template methods to use raw strings
crates/rspack_core/src/chunk_graph/mod.rs Converted debug output table formatting to raw string literal
crates/rspack_plugin_javascript/src/plugin/mod.rs Refactored module cache, require function, and startup function templates to raw strings
crates/rspack_plugin_javascript/src/dependency/esm/esm_export_imported_specifier_dependency.rs Updated reexport statement formatting to raw string
crates/rspack_plugin_esm_library/src/render.rs Converted module cache, require function, and factory declarations to raw strings
crates/rspack_plugin_esm_library/src/link.rs Updated namespace object source generation to raw string
crates/rspack_plugin_esm_library/src/dependency/dyn_import.rs Refactored dynamic import then expression to raw string
crates/rspack_plugin_runtime/src/runtime_module/export_require.rs Converted export require template to raw string
crates/rspack_plugin_runtime/src/common_js_chunk_format.rs Updated CommonJS chunk loading template to raw string
crates/rspack_plugin_library/src/system_library_plugin.rs Refactored SystemJS setter function template to raw string
crates/rspack_plugin_module_info_header/src/lib.rs Converted module info header comment generation to raw string
crates/rspack_plugin_extract_css/src/plugin.rs Updated CSS module header comment to raw string
crates/rspack_plugin_devtool/src/eval_source_map_dev_tool_plugin.rs Refactored source map footer generation to raw string
crates/rspack_plugin_banner/src/lib.rs Converted multi-line comment wrapper to raw string
crates/rspack_plugin_sri/src/runtime.rs Updated SRI attribute injection template to raw string

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

Rsdoctor Bundle Diff Analysis

Found 5 project(s) in monorepo.

📁 react-10k

Path: ../build-tools-performance/cases/react-10k/dist/rsdoctor-data.json

📌 Baseline Commit: 5041023cba | PR: #12380

Metric Current Baseline Change
📊 Total Size 5.7 MB 5.7 MB 0 B (0.0%)
📄 JavaScript 5.7 MB 5.7 MB 0 B (0.0%)
🎨 CSS 21.0 B 21.0 B 0 B (0.0%)
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: react-10k Bundle Diff

📁 react-1k

Path: ../build-tools-performance/cases/react-1k/dist/rsdoctor-data.json

📌 Baseline Commit: 5041023cba | PR: #12380

Metric Current Baseline Change
📊 Total Size 823.6 KB 823.6 KB 0 B (0.0%)
📄 JavaScript 823.6 KB 823.6 KB 0 B (0.0%)
🎨 CSS 0 B 0 B N/A
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: react-1k Bundle Diff

📁 react-5k

Path: ../build-tools-performance/cases/react-5k/dist/rsdoctor-data.json

📌 Baseline Commit: 5041023cba | PR: #12380

Metric Current Baseline Change
📊 Total Size 2.7 MB 2.7 MB 0 B (0.0%)
📄 JavaScript 2.7 MB 2.7 MB 0 B (0.0%)
🎨 CSS 21.0 B 21.0 B 0 B (0.0%)
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: react-5k Bundle Diff

📁 rome

Path: ../build-tools-performance/cases/rome/dist/rsdoctor-data.json

📌 Baseline Commit: 5041023cba | PR: #12380

Metric Current Baseline Change
📊 Total Size 984.3 KB 984.3 KB 0 B (0.0%)
📄 JavaScript 984.3 KB 984.3 KB 0 B (0.0%)
🎨 CSS 0 B 0 B N/A
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: rome Bundle Diff

📁 ui-components

Path: ../build-tools-performance/cases/ui-components/dist/rsdoctor-data.json

📌 Baseline Commit: 5041023cba | PR: #12380

Metric Current Baseline Change
📊 Total Size 2.1 MB 2.1 MB 0 B (0.0%)
📄 JavaScript 2.0 MB 2.0 MB 0 B (0.0%)
🎨 CSS 83.0 KB 83.0 KB 0 B (0.0%)
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: ui-components Bundle Diff

Generated by Rsdoctor GitHub Action

@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

📦 Binary Size-limit

Comparing dd87512 to fix: extracted comments should be behind the shebang (#12380) by CPunisher

🙈 Size remains the same at 47.69MB

@LingyuCoder LingyuCoder changed the title refactor: optimize RuntimeTemplate API usage across plugins refactor: optimize runtime multiple line string literal Dec 5, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Dec 5, 2025

CodSpeed Performance Report

Merging #12381 will not alter performance

Comparing refactor/runtime-template-optimization (dd87512) with main (5041023)

Summary

✅ 17 untouched

@LingyuCoder LingyuCoder requested a review from hardfist December 8, 2025 02:42
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