unused-webpack-plugin icon indicating copy to clipboard operation
unused-webpack-plugin copied to clipboard

Error with webpack v5

Open imathews opened this issue 4 years ago • 2 comments

We just updated to webpack v5, and unfortunately had to pull unused-webpack-plugin out of our plugins because it seems to be incompatible with the changes in v5. We're seeing the following error when including this plugin in our webpack configuration:

assets/node_modules/unused-files-webpack-plugin/lib/index__8.0.0__.js:105
    compiler.plugin(`after-emit`, (compilation, done) =>
             ^

TypeError: compiler.plugin is not a function
    at UnusedFilesWebpackPlugin.apply (assets/node_modules/unused-files-webpack-plugin/lib/index__8.0.0__.js:105:14)
    at createCompiler (assets/node_modules/webpack/lib/webpack.js:69:12)
    at create (assets/node_modules/webpack/lib/webpack.js:113:15)
    at webpack (assets/node_modules/webpack/lib/webpack.js:137:31)
    at f (assets/node_modules/webpack/lib/index.js:35:15)

imathews avatar Dec 03 '20 17:12 imathews

You might want to checkout https://github.com/MQuy/webpack-deadcode-plugin It's quite similar to this but has more features. I recently helped to add webpack 5 support to that project.

With that being said, I was able to use this project with webpack 5 as well. It should have handled the new webpack 4/5 syntax: https://github.com/MatthieuLemoine/unused-webpack-plugin/blob/b309510e1524498422d6e4026759503d41a53940/index.js#L30-L31

paradite avatar May 30 '21 06:05 paradite

Any news?

balovbohdan avatar Jun 14 '21 13:06 balovbohdan