Description
- This is a bug
- This is a modification request
Code
In Server.js, the signature of the constructor is "(options={}, compiler)".
For reasons I have not looked into, there is a temporary code (signaled by a TODO), that reverses those two if options.hooks is true. I'm guessing essentially making it work with (options, compiler) as well as (compiler, options).
But compiler does not have a default value, unlike options. So if you call
new WebpackDevServer(compiler)
without options, options will be undefined, which throws an error when calling validate.
new WebpackDevServer(compiler, {})
works.
This used to work in our pipeline and stopped working suddenly, not sure what caused it, probably an update somewhere.
Please paste the results of webpack-cli info
here, and mention other relevant information
System:
OS: macOS Mojave 10.14.6
CPU: (8) x64 Intel(R) Core(TM) i5-8279U CPU @ 2.40GHz
Memory: 1.72 GB / 16.00 GB
Binaries:
Node: 14.16.1 - /usr/local/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 6.14.12 - /usr/local/bin/npm
Browsers:
Brave Browser: 81.1.8.95
Chrome: 92.0.4515.159
Chrome Canary: 95.0.4609.3
Firefox Developer Edition: 92.0
Safari: 14.1.2
Packages:
clean-webpack-plugin: ^4.0.0-alpha.0 => 4.0.0-alpha.0
copy-webpack-plugin: ^5.1.2 => 5.1.2
dotenv-webpack: ^7.0.2 => 7.0.3
html-webpack-plugin: ^5.3.1 => 5.3.2
webpack: ^5.35.1 => 5.50.0
webpack-bundle-analyzer: ^4.4.1 => 4.4.2
webpack-cli: ^4.7.0 => 4.8.0
webpack-dev-server: ^4.0.0-beta.3 => 4.0.0-rc.0
webpack-modules: ^1.0.0 => 1.0.0
Expected Behavior
I can call WebpackDevServer with only a compiler without passing options
Actual Behavior
If you just call new WebpackDevServer(compiler) it will throw an error, even though
new WebpackDevServer(compiler, {})
and
new WebpackDevServer(undefined, compiler)
work
For Bugs; How can we reproduce the behavior?
see above snippet.