fix: not try to add integrity to tags with remote url#12262
Conversation
✅ Deploy Preview for rspack canceled.
|
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue where the Subresource Integrity (SRI) plugin was attempting to add integrity attributes to script and link tags with remote URLs (http/https), which would fail since the build system cannot compute integrity hashes for external resources not part of the build output.
Key Changes
- Added logic to skip SRI processing for tags with remote URLs (http/https protocol) that don't match the publicPath
- Implemented the fix consistently in both TypeScript (for HtmlRspackPlugin/HtmlWebpackPlugin integration) and Rust (for native implementation)
- Added comprehensive test coverage for both plugin types to verify remote URLs are excluded from integrity processing while local bundles still receive integrity attributes
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/rspack/src/builtin-plugin/SubresourceIntegrityPlugin.ts | Added URL parsing logic to skip remote URLs in the processTag method |
| crates/rspack_plugin_sri/src/html.rs | Added equivalent Rust implementation to skip remote URLs in process_tag function |
| crates/rspack_plugin_sri/Cargo.toml | Added url crate dependency for URL parsing, minor formatting adjustment to lints section |
| Cargo.lock | Updated to include url dependency for rspack_plugin_sri |
| tests/rspack-test/configCases/sri/remote-src/rspack.config.js | Added test configurations for both HtmlRspackPlugin and HtmlWebpackPlugin to verify remote URLs are excluded |
| tests/rspack-test/configCases/sri/remote-src/index.js | Added minimal test entry point |
| tests/rspack-test/configCases/sri/remote-src/test.config.js | Configured test to skip runtime tests (noTests: true) since verification is done via compilation hooks |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📦 Binary Size-limit
❌ Size increased by 512bytes from 47.63MB to 47.63MB (⬆️0.00%) |
CodSpeed Performance ReportMerging #12262 will not alter performanceComparing Summary
|
|
@LingyuCoder |
Summary
fix #12251
Related links
Checklist