webpack-bundle-tracker icon indicating copy to clipboard operation
webpack-bundle-tracker copied to clipboard

Integrity can only be used if the physical files exist

Open karolyi opened this issue 1 year ago • 1 comments

Hey,

I've turned on integrity and experienced errors so far with:

  • using webpack-dev-server that only stores the files in-memory since they will get rebuilt upon change
  • sourcemap files that aren't built or not in the place the bundle tracker thinks they are

Tracking this bug leads to https://github.com/django-webpack/webpack-bundle-tracker/blob/4596d47632253ce557ea416d92c17265a3c286f8/lib/index.js#L31 where the readFileSync gets a path that doesn't exist and raises an exception that isn't handled.

This results in webpack silently hanging upon building the bundle with integrities.

Disclaimer: I'm not a webpack dev, just a guy who tries to use this plugin with django, emitting the integrity values in templates. If not otherwise solvable, unavailable integrity calculations should at least raise an error so guys like me would know what happened.

karolyi avatar Jul 28 '24 12:07 karolyi

I have something in the works for this. PR coming up.

karolyi avatar Jul 28 '24 17:07 karolyi

Integrity calculation has been revamped at https://github.com/django-webpack/webpack-bundle-tracker/pull/132, now we'll always use the content from the in-memory asset that webpack emits, which won't break with webpack-dev-server. An example with a similar setting has been updated on the django-webpack-loader side https://github.com/django-webpack/django-webpack-loader/blob/v3.2.2/examples/hot-reload/webpack.config.js.

rvlb avatar Nov 05 '25 12:11 rvlb