Open sontek opened 5 years ago
I am getting same error. (webpack 4.8.3)
Whenever I use new HardSourceWebpackPlugin()
webpack works. But ExcludeModulePlugin
variant does not.
Note that I am using mini-css-extract-plugin
.
ExcludeModulePlugin
is used like this (I've taken this from README)
new HardSourceWebpackPlugin.ExcludeModulePlugin([
{
// HardSource works with mini-css-extract-plugin but due to how
// mini-css emits assets, assets are not emitted on repeated builds with
// mini-css and hard-source together. Ignoring the mini-css loader
// modules, but not the other css loader modules, excludes the modules
// that mini-css needs rebuilt to output assets every time.
test: /mini-css-extract-plugin[\\/]dist[\\/]loader/,
},
]),
Error:
TypeError: Cannot read property 'tap' of undefined
at compilerHooks.afterPlugins.tap (/var/docker/assets/node_modules/hard-source-webpack-plugin/lib/ExcludeModulePlugin.js:40:50)
at SyncHook.eval [as call] (eval at create (/var/docker/assets/node_modules/tapable/lib/HookCodeFactory.js:17:12), <anonymous>:7:1)
at SyncHook.lazyCompileHook [as _call] (/var/docker/assets/node_modules/tapable/lib/Hook.js:35:21)
at WebpackOptionsApply.process (/var/docker/assets/node_modules/webpack/lib/WebpackOptionsApply.js:363:31)
at webpack (/var/docker/assets/node_modules/webpack/lib/webpack.js:42:48)
at processOptions (/var/docker/assets/node_modules/webpack-cli/bin/webpack.js:437:16)
at yargs.parse (/var/docker/assets/node_modules/webpack-cli/bin/webpack.js:513:3)
at Object.parse (/var/docker/assets/node_modules/yargs/yargs.js:552:18)
at /var/docker/assets/node_modules/webpack-cli/bin/webpack.js:218:8
at Object.<anonymous> (/var/docker/assets/node_modules/webpack-cli/bin/webpack.js:515:3)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
at Module.require (internal/modules/cjs/loader.js:598:17)
at require (internal/modules/cjs/helpers.js:11:18)
at Object.<anonymous> (/var/docker/assets/node_modules/webpack/bin/webpack.js:80:2)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:695:10)
at startup (internal/bootstrap/node.js:201:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:516:3)
It looks like that I won't need ExcludeModulePlugin
, because, in my case, line at https://github.com/mzgoddard/hard-source-webpack-plugin/blob/master/index.js#L480 evaluates to true... Is my assumption correct @mzgoddard ?
I was able to get this working by changing my configuration. The way I interpreted the README, I thought you used a plugin like so:
plugins: [
new HardSourceWebpackPlugin.ExcludeModulePlugin([
// ... settings
]),
]
BUT, it is required to first add just the hardsource plugin itself, and THEN add subsequent plugins
plugins: [
new HardSourceWebpackPlugin(),
new HardSourceWebpackPlugin.ExcludeModulePlugin([
// ... settings
]),
]
I also get this error even though I'm loading this way
new HardSourceWebpackPlugin(),
new HardSourceWebpackPlugin.ExcludeModulePlugin([
// ... settings
]),
If you are using 'speed-measure-webpack-plugin'... removing it fixed this problem for me.
@rsbowers I also fixed this problem after removed it... 'speed-measure-webpack-plugin' affects compiler hooks, but i do not know the reason...
If you are using 'speed-measure-webpack-plugin'... removing it fixed this problem for me.
thank you
new HardSourceWebpackPlugin(),
new HardSourceWebpackPlugin.ParallelModulePlugin({
// How to launch the extra processes. Default:
fork: (fork, compiler, webpackBin) => fork(
webpackBin(),
['--config', __filename], {
silent: true,
}
),
numWorkers: () => 4,
minModules: 20,
}),
The production and packaging are completed directly, no errors are reported, but the printing is not actually finished. why is it so?
Expected Behavior
Actual Behavior
Is an error being thrown?
Steps to Reproduce
Use this snippet:
Operating System, Node, and NPM dependency versions