ztoben / assets-webpack-plugin

Webpack plugin that emits a json file with assets paths
https://www.npmjs.com/package/assets-webpack-plugin
MIT License
958 stars 104 forks source link

fix: the source is not available on afterEmit #392

Closed lebleb closed 3 years ago

lebleb commented 3 years ago

Problem:

Plugin show an error with Webpack 5.

Error: Content and Map of this Source is not available (only size() is supported)

Why?

Webpack 5 release, replaces the source of assets with SizeOnlySource. Official announce => https://webpack.js.org/blog/2020-10-10-webpack-5-release/#sizeonlysource-after-emit

Key idea:

Only "emit" called before "AfterEmit" has a source for assets. Use the "emit" hook only if there is hook support. So the old version of the Webpack will continue to use the "afterEmit" hook with the old plugin apply.

Closes #327

ssick commented 3 years ago

Nice work 👍🏼

ztoben commented 3 years ago

This looks like it'll work, when I get a chance to test it out I'll get a new version published. Thank you!!

tonietto commented 3 years ago

I tested on my end and it fixes the issue! 🙌

ztoben commented 3 years ago

Out in v7.1.0 now 🎉