webpack-subresource-integrity icon indicating copy to clipboard operation
webpack-subresource-integrity copied to clipboard

Interoperability with resource hints

Open ivany4 opened this issue 2 years ago • 3 comments

Compilation breaks when webpack-subresource-integrity is used together with html-webpack-preconnect-plugin that injects <link rel="preconnect" href="..." /> tag. SRI plugin tries to download the given file (which in this case is not a file but origin domain for preconnecting) and fails with a very obscure error:

ERROR in   Error: ENOENT: no such file or directory, open '<output path>  <preconnect origin URL>'
- plugin.ts:374 Plugin.processTag
  [...]/[webpack-subresource-integrity]/plugin.ts:374:5

- plugin.ts:110 
  [...]/[webpack-subresource-integrity]/plugin.ts:110:30

- Array.forEach

- plugin.ts:110 Plugin.handleHwpBodyTags
  [...]/[webpack-subresource-integrity]/plugin.ts:110:10

- index.ts:183 
  [...]/[webpack-subresource-integrity]/index.ts:183:18


 - new Promise

I see the mentions of <link rel="preload"> in the documentation, but not other types.

I realize that other resource hints, described in this document, currently marked as a working draft. But they also work in some browsers: https://caniuse.com/?search=preconnect

Webpack 5.71.0 html-webpack-plugin 5.5.0 webpack-subresource-integrity 5.1.0 html-webpack-preconnect-plugin 1.2.1

This was not a problem with webpack-subresource-integrity v1.

ivany4 avatar Apr 03 '22 18:04 ivany4

I'll see that I can include a fix for this in the next release. Could you create a demo repository that shows this problem?

jscheid avatar Apr 04 '22 12:04 jscheid

@ivany4 never mind, I can put the test case together myself no problem.

jscheid avatar Apr 04 '22 20:04 jscheid

@ivany4 never mind, I can put the test case together myself no problem.

Thanks, much appreciated!

ivany4 avatar Apr 05 '22 15:04 ivany4