Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When can webpack 5 be perfectly supported? #174

Open
zhaoky opened this issue Jul 8, 2021 · 10 comments
Open

When can webpack 5 be perfectly supported? #174

zhaoky opened this issue Jul 8, 2021 · 10 comments

Comments

@zhaoky
Copy link

zhaoky commented Jul 8, 2021

It is a great plugin.

@kud
Copy link

kud commented Aug 13, 2021

I'm using Webpack 5 and I don't have any issue using this plugin. What's your issue?

@g3tr1ght
Copy link

@kud This is the issue #170

@7iomka
Copy link

7iomka commented Aug 30, 2021

(node:4422) [DEP_WEBPACK_COMPILATION_NORMAL_MODULE_LOADER_HOOK] DeprecationWarning: Compilation.hooks.normalModuleLoader was moved to NormalModule.getCompilationHooks(compilation).loader at getNormalModuleLoader (node_modules/webpack/lib/Compilation.js:408:39) at Object.get normalModuleLoader [as normalModuleLoader] (node_modules/webpack/lib/Compilation.js:841:12) at genProxy (node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:124:34) at node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:152:19 at Array.reduce (<anonymous>) at wrapHooks (node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:151:38) at Object.get (node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:221:18) at Proxy.<anonymous> (node_modules/ignore-emit-webpack-plugin/index.js:64:33) at node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:52:19 at Hook.eval [as call] (eval at create (node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:98:1)

@duckscofield
Copy link

I do need this in webpack 5 with CRA V5 ~

@w-t-w
Copy link

w-t-w commented Sep 19, 2022

@kud This is the issue #170

I need terser-webpack-plugin and css-minimizer-webpack-plugin, what should I do in this case?

@g3tr1ght
Copy link

@w-t-w I'm guessing you can simply instantiate both plugins and be on your own with minimization:

const TerserPlugin = require("terser-webpack-plugin");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");

module.exports = {
  optimization: {
    minimize: true,
    minimizer: [new TerserPlugin(), new CssMinimizerPlugin()],
  },
};

Initialize TerserPlugin to your own taste https://webpack.js.org/plugins/terser-webpack-plugin/#options

So that minimizer array doesn't have an '...' item and speed measure plugin would work for you.

@w-t-w
Copy link

w-t-w commented Nov 15, 2022

@g3tr1ght So I have to download terser-webpack-plugin without the convenience of webpack mode:'production',
but this is not solving the problem, is it? It's sort of bypassing the problem, right?

@g3tr1ght
Copy link

g3tr1ght commented Nov 16, 2022

@w-t-w terser-webpack-plugin is a transitive dependency for you in any case, you either pin it in your package.json and instantiate yourself (make it direct dependency) or let webpack instantiate it for you (keep it transitive). In either case, this dependency will end up installed: https://github.com/webpack/webpack/blob/main/package.json#L29
Also you aren't losing the convenience of webpack mode:'production'. It'll still apply to the config all production optimizations, except optimization.minimizer portion as you overrode it (if you'll follow the example above).

Here's what '...' option in optimization.minimizer does: https://github.com/webpack/webpack/blob/main/lib/config/defaults.js#L77-L114.
As you can see from the function A definition, it's pretty basic, whenever it stumbles upon '...', it'll add the default option, which is provided here: https://github.com/webpack/webpack/blob/main/lib/config/defaults.js#L1160-L1174. So if you have optimization.minimizer = ['...', new CssMinimizerPlugin()] (which is what you originally wanted to use), webpack will effectively "convert" it into: optimization.minimizer = [new TerserPlugin({ terserOptions: { compress: { passes: 2 } } }), new CssMinimizerPlugin()].

Which means it actually solves the problem. I understand it's a workaround, but the end result is identical to the webpack "baseline". And more so, serious projects usually have a good number of customizations which override webpack default production optimizations.

@ssmartin
Copy link

(node:4422) [DEP_WEBPACK_COMPILATION_NORMAL_MODULE_LOADER_HOOK] DeprecationWarning: Compilation.hooks.normalModuleLoader was moved to NormalModule.getCompilationHooks(compilation).loader at getNormalModuleLoader (node_modules/webpack/lib/Compilation.js:408:39) at Object.get normalModuleLoader [as normalModuleLoader] (node_modules/webpack/lib/Compilation.js:841:12) at genProxy (node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:124:34) at node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:152:19 at Array.reduce (<anonymous>) at wrapHooks (node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:151:38) at Object.get (node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:221:18) at Proxy.<anonymous> (node_modules/ignore-emit-webpack-plugin/index.js:64:33) at node_modules/speed-measure-webpack-plugin/WrappedPlugin/index.js:52:19 at Hook.eval [as call] (eval at create (node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:98:1)

any updates on this?

@andfaulkner
Copy link

@ssmartin I'm also still getting this on every build, and it's driving me nuts.

Everything is working and the build runs just fine, I just consistently get that warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants