webpack-dev-server should work with webpack 5 and webpack-cli

Created on 5 Sep 2019  路  8Comments  路  Source: webpack/webpack-dev-server

  • Operating System: MacOS 10.15
  • Node Version: 8.15.0
  • NPM Version: yarn 1.17.3
  • webpack Version: 5.0.0-alpha.23
  • webpack-dev-server Version: 3.8.0
  • Browser: None yet
  • [x] This is a bug
  • [ ] This is a modification request

Code

// webpack.config.js
// Here is a minimal config that fails
{
    target: 'web',
    mode: IS_DEV ? 'development' : 'production',
    context: path.resolve('./src'),
    resolve: {
        extensions: ['.js', '.ts', '.tsx']
    }
}

Expected Behavior

webpack-dev-server should be able to work with webpack 5.

Actual Behavior

I am running [email protected] and [email protected] alongside [email protected].

Simply running the $ yarn webpack-dev-server command is launching the server correctly, but as soon as I pass it our actual config file with $ yarn webpack-dev-server --config <path-to-config>.js, it is failing with the following error:

/node_modules/webpack-cli/bin/utils/convert-argv.js:140
        if (webpackConfigurationValidationErrors.length) {
                                                 ^

TypeError: Cannot read property 'length' of undefined
    at processConfiguredOptions (/node_modules/webpack-cli/bin/utils/convert-argv.js:140:44)
    at module.exports (/node_modules/webpack-cli/bin/utils/convert-argv.js:131:10)
    at Object.<anonymous> (/node_modules/webpack-dev-server/bin/webpack-dev-server.js:84:40)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Function.Module.runMain (module.js:694:10)
    at startup (bootstrap_node.js:204:16)

I tried removing most of the config, but it seems to fail as soon as a config file is passed.

For Bugs; How can we reproduce the behavior?

Starting [email protected] with [email protected] and [email protected] with the --config flag.

For Features; What is the motivation and/or use-case for the feature?

Adding long-term support for webpack 5 to benefit from its major updates.

Most helpful comment

https://github.com/webpack/webpack-dev-server/blob/c9e9178a4882e414a6b9616baa35e8dbf7b2dd75/bin/webpack-dev-server.js#L61

webpack-cli/bin/ no longer exists as of (https://github.com/webpack/webpack-cli/commit/82407e5e1fee2ce7e8dd4cfa9596b99ed0cde4fc). This is a blocker for at least [email protected]. Is there a workaround...?

All 8 comments

We need setup webpack@5 in CI to ensure all works fine, i think only cli broken

+1

Indeed, this is now resolved using [email protected] with [email protected].
Thanks @evilebottnawi

Keep open until we set up CI

https://github.com/webpack/webpack-dev-server/blob/c9e9178a4882e414a6b9616baa35e8dbf7b2dd75/bin/webpack-dev-server.js#L61

webpack-cli/bin/ no longer exists as of (https://github.com/webpack/webpack-cli/commit/82407e5e1fee2ce7e8dd4cfa9596b99ed0cde4fc). This is a blocker for at least [email protected]. Is there a workaround...?

@JoshuaKGoldberg we try to solve this for next release

im getting..
warning " > [email protected]" has incorrect peer dependency "webpack@^4.0.0".

guessing its down to this thread still being open

@jasonwilliams ignore this, we update peerDeps field after stable release

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Ky6uk picture Ky6uk  路  3Comments

adiachenko picture adiachenko  路  3Comments

MJ111 picture MJ111  路  3Comments

Jack-Works picture Jack-Works  路  3Comments

daryn-k picture daryn-k  路  3Comments