waysact / webpack-subresource-integrity

Webpack plugin for enabling Subresource Integrity.
MIT License
357 stars 46 forks source link

SRI breaks real contenthash filename generation #152

Closed zlk89 closed 3 years ago

zlk89 commented 3 years ago

Reproducible steps

  1. Git clone https://github.com/zlk89/webpack-reprods/tree/json-encoding-sri
  2. Go to json-encoding-sri branch
  3. yarn
  4. yarn compile - you will find a file 4d606cb93b59421d4129.js (line 10 is JSON.parse('{"key":"value","key2":"value2","key3":"value","key4":"value2","key5":"value")
  5. Change webpack version from 5.24.0 to 5.21.2 which it doesn't have this improvement
  6. yarn again
  7. yarn compile - you will find the file 4d606cb93b59421d4129.js again, but the file content is different (line 10 is JSON.parse("{\"key\":\"value\",\"key2\":\"value2\",\"key3\":\"value\",\"key4\":\"value2\")

Why it is related with SRI plugin?

If you comment out SRI plugin in webpack config, this issue doesn't happen any more. In step 7, there will be no 4d606cb93b59421d4129.js file, instead, it creates a new file with different filename

jscheid commented 3 years ago

I can reproduce this, discussing a fix over at https://github.com/webpack/webpack/pull/12642

jscheid commented 3 years ago

@zlk89 if you like you can test the fix with the tarball found at the bottom of this page, planning to roll a release soon as well.

zlk89 commented 3 years ago

thanks for the quick fix. Verified that it generates different filenames now!

jscheid commented 3 years ago

Thanks for the bug report. Released in v5.0.0-alpha.4.