feat: support prefetch and preload in css extract plugin#12237
Merged
feat: support prefetch and preload in css extract plugin#12237
Conversation
✅ Deploy Preview for rspack canceled.
|
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for CSS prefetch and preload functionality in the CSS extract plugin by introducing a new createLink runtime plugin hook. The implementation refactors CSS runtime modules to use EJS templates for better maintainability and consistency.
- Introduces
createLinkhook to allow plugins (like SRI) to modify link tag creation - Refactors CSS loading runtime modules to use EJS templates instead of string concatenation
- Adds prefetch and preload handlers for CSS chunks in both extract and standard CSS plugins
Reviewed Changes
Copilot reviewed 27 out of 28 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/rspack/src/builtin-plugin/RuntimePlugin.ts | Adds createLink hook definition and registration for TypeScript API |
| packages/rspack/etc/core.api.md | Updates public API documentation to include new createLink hook |
| crates/rspack_plugin_sri/src/util.rs | Adds debug logging (should be removed) |
| crates/rspack_plugin_sri/src/runtime.rs | Fixes crossOrigin string quoting in generated JavaScript |
| crates/rspack_plugin_sri/src/integrity.rs | Improves error message to include invalid hash function name |
| crates/rspack_plugin_extract_css/src/runtime/with_loading.js | Removes old template file (replaced by EJS) |
| crates/rspack_plugin_extract_css/src/runtime/*.ejs | Adds new EJS templates for modular CSS loading, prefetch, and preload |
| crates/rspack_plugin_extract_css/src/runtime.rs | Refactors to use EJS templates and adds prefetch/preload support with createLink hook integration |
| crates/rspack_plugin_css/src/runtime/mod.rs | Refactors to use EJS templates and adds prefetch/preload support with createLink hook integration |
| crates/rspack_plugin_css/src/runtime/*.ejs | Adds/updates EJS templates for CSS loading, prefetch, and preload |
| crates/rspack_plugin_runtime/src/drive.rs | Defines CreateLinkData struct and hook for runtime link creation |
| crates/rspack_binding_api/src/runtime.rs | Adds JsCreateLinkData binding type for Node.js API |
| crates/rspack_binding_api/src/plugins/*.rs | Registers createLink hook taps and interceptors |
| crates/node_binding/napi-binding.d.ts | Adds TypeScript definitions for createLink hook (with type errors) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
crates/rspack_plugin_css/src/runtime/css_loading_with_prefetch_link.ejs
Outdated
Show resolved
Hide resolved
Contributor
📦 Binary Size-limit
❌ Size increased by 51.13KB from 47.57MB to 47.62MB (⬆️0.10%) |
LingyuCoder
commented
Nov 19, 2025
CodSpeed Performance ReportMerging #12237 will not alter performanceComparing Summary
|
JSerFeng
approved these changes
Nov 19, 2025
hardfist
reviewed
Nov 19, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
createLinkruntime plugin hooks to make sure the sri plugin can handle subresource integrity during creating link tags.Related links
Checklist