Skip to content

feat: support prefetch and preload in css extract plugin#12237

Merged
hardfist merged 4 commits intomainfrom
feat/mini-css-extract-preload
Nov 19, 2025
Merged

feat: support prefetch and preload in css extract plugin#12237
hardfist merged 4 commits intomainfrom
feat/mini-css-extract-preload

Conversation

@LingyuCoder
Copy link
Contributor

Summary

  • support prefetch and preload in css extract plugin.
  • refactor css runtime module and css extract runtime module to process string concatenation in render templates.
  • add createLink runtime plugin hooks to make sure the sri plugin can handle subresource integrity during creating link tags.

Related links

Checklist

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

@LingyuCoder LingyuCoder requested a review from JSerFeng November 19, 2025 08:28
Copilot AI review requested due to automatic review settings November 19, 2025 08:28
@github-actions github-actions bot added release: feature release: feature related release(mr only) team The issue/pr is created by the member of Rspack. labels Nov 19, 2025
@netlify
Copy link

netlify bot commented Nov 19, 2025

Deploy Preview for rspack canceled.

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

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 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 createLink hook 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.

@github-actions
Copy link
Contributor

📦 Binary Size-limit

Comparing a6b719a to fix: persistent cache watch missing dependencies changes (#12228) by jinrui

❌ Size increased by 51.13KB from 47.57MB to 47.62MB (⬆️0.10%)

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 19, 2025

CodSpeed Performance Report

Merging #12237 will not alter performance

Comparing feat/mini-css-extract-preload (a6b719a) with main (510e054)

Summary

✅ 17 untouched

@hardfist hardfist merged commit aa49744 into main Nov 19, 2025
45 of 47 checks passed
@hardfist hardfist deleted the feat/mini-css-extract-preload branch November 19, 2025 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: feature release: feature related release(mr only) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants