speed-measure-webpack-plugin icon indicating copy to clipboard operation
speed-measure-webpack-plugin copied to clipboard

When can webpack 5 be perfectly supported?

Open zhaoky opened this issue 4 years ago • 10 comments

It is a great plugin.

zhaoky avatar Jul 08 '21 12:07 zhaoky

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

kud avatar Aug 13 '21 10:08 kud

@kud This is the issue https://github.com/stephencookdev/speed-measure-webpack-plugin/issues/170

g3tr1ght avatar Aug 25 '21 01:08 g3tr1ght

(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)

7iomka avatar Aug 30 '21 06:08 7iomka

I do need this in webpack 5 with CRA V5 ~

duckscofield avatar Jan 11 '22 08:01 duckscofield

@kud This is the issue #170

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

w-t-w avatar Sep 19 '22 17:09 w-t-w

@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.

g3tr1ght avatar Oct 17 '22 03:10 g3tr1ght

@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?

w-t-w avatar Nov 15 '22 23:11 w-t-w

@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.

g3tr1ght avatar Nov 16 '22 22:11 g3tr1ght

(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?

ssmartin avatar Nov 29 '22 11:11 ssmartin

@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.

andfaulkner avatar Apr 12 '23 09:04 andfaulkner