-
-
Notifications
You must be signed in to change notification settings - Fork 740
refactor: optimize runtime multiple line string literal #12381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for rspack canceled.
|
There was a problem hiding this 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.
Rsdoctor Bundle Diff AnalysisFound 5 project(s) in monorepo. 📁 react-10kPath:
📦 Download Diff Report: react-10k Bundle Diff 📁 react-1kPath:
📦 Download Diff Report: react-1k Bundle Diff 📁 react-5kPath:
📦 Download Diff Report: react-5k Bundle Diff 📁 romePath:
📦 Download Diff Report: rome Bundle Diff 📁 ui-componentsPath:
📦 Download Diff Report: ui-components Bundle Diff Generated by Rsdoctor GitHub Action |
📦 Binary Size-limit
🙈 Size remains the same at 47.69MB |
CodSpeed Performance ReportMerging #12381 will not alter performanceComparing Summary
|
🤖 AI Generated
📝 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 patternscrates/rspack_core/src/runtime_template.rs- Core RuntimeTemplate API refinementsPlugins:
crates/rspack_plugin_banner/src/lib.rscrates/rspack_plugin_devtool/src/eval_source_map_dev_tool_plugin.rscrates/rspack_plugin_esm_library/src/dependency/dyn_import.rscrates/rspack_plugin_esm_library/src/link.rscrates/rspack_plugin_esm_library/src/render.rscrates/rspack_plugin_extract_css/src/plugin.rscrates/rspack_plugin_javascript/src/dependency/esm/esm_export_imported_specifier_dependency.rscrates/rspack_plugin_javascript/src/plugin/mod.rscrates/rspack_plugin_library/src/system_library_plugin.rscrates/rspack_plugin_module_info_header/src/lib.rscrates/rspack_plugin_runtime/src/common_js_chunk_format.rscrates/rspack_plugin_runtime/src/runtime_module/export_require.rscrates/rspack_plugin_sri/src/runtime.rs✨ Benefits
🧪 Testing