3.0.0-alpha6 and 2.11.1const webpack = require('webpack');
const path = require('path');
const WebpackDevServer = require('webpack-dev-server');
const configs = [
{
mode: 'production',
entry: {
foo: require.resolve('./foo.js')
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, './public')
},
}
]
const compiler = webpack(configs);
const devServer = new WebpackDevServer(compiler, {
publicPath: '/public/'
});
devServer.listen(9999, 'localhost', err => {
if (err) {
return console.log(err);
}
});
foo.js
console.log('foo');
Should start the dev server
Throws the below error
/Users/robrichard/projects/dibs-scripts/node_modules/tapable/lib/Tapable.js:63
throw new Error(`Plugin could not be registered at '${name}'. Hook was not found.\n` +
^
Error: Plugin could not be registered at 'compile'. Hook was not found.
BREAKING CHANGE: There need to exist a hook at 'this.hooks'. To create a compatiblity layer for this hook, hook into 'this._pluginCompat'.
at MultiCompiler.plugin (/Users/robrichard/projects/dibs-scripts/node_modules/tapable/lib/Tapable.js:63:9)
at MultiCompiler.deprecated [as plugin] (internal/util.js:52:15)
at plugins (/Users/robrichard/projects/dibs-scripts/node_modules/webpack-dev-server/lib/plugins.js:53:12)
at new DevServer (/Users/robrichard/projects/dibs-scripts/node_modules/webpack-dev-server/lib/DevServer.js:61:5)
at Object.<anonymous> (/Users/robrichard/projects/dibs-scripts/webpack.js:19:19)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Function.Module.runMain (module.js:676:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
Run the script posted above
@sokra how should we tackled MultiCompiler for wds hooks. 馃
Have the same issue :(
@sokra Is there anything we can do? Now that webpack@4 is out of the door, this will block so many upgrades. @TheLarkInn If you have any idea on how to solve it, I'm happy to help.
Same issue here
by changing line 69 of lib/Server.js to the following The build works again for MultiCompiler:
compiler.compilers.forEach((comp) => {
comp.plugin('compile', invalidPlugin);
comp.plugin('invalid', invalidPlugin);
comp.plugin('done', (stats) => {
this._sendStats(this.sockets, stats.toJson(clientStats));
this._stats = stats;
});
});
I think the approach to handling deprecated plugin vs. hooks needs to be updated on webpack side. However, it would be nice if wds could switch to hooks of webpack > 4?
I published [email protected] with experimental support for MultiCompiler. Please test it and report if it works correctly. I would like at least 2-3 reports because I have never used MultiCompiler myself 馃槃.
Thanks for the hint @janhommes.
Hey @SpaceK33z! It works on my side. I cannot fully test it, because some plugins are still failing, but we don鈥檛 get this error anymore! 馃憤
Works for me @SpaceK33z,
No problems with project 1 of 4, had to use the patch from (https://medium.com/webpack/webpack-4-released-today-6cdb994702d4
==> yarn add html-webpack-plugin@webpack-contrib/html-webpack-plugin
馃憤
Hey @SpaceK33z,
3 different projects work fine on my end.
Thanks
馃憤馃憤馃憤
@SpaceK33z works for me as well. Thanks for the fast fix!
Thanks for testing everyone! I will publish the release tonight.
[email protected] has been published with the fix.
Most helpful comment
@sokra Is there anything we can do? Now that
webpack@4is out of the door, this will block so many upgrades. @TheLarkInn If you have any idea on how to solve it, I'm happy to help.