Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webpack 5 install 'url' and 'events' as a dependency #1598

Closed
1 of 2 tasks
debs-obrien opened this issue Dec 12, 2018 · 2 comments · Fixed by #1599
Closed
1 of 2 tasks

webpack 5 install 'url' and 'events' as a dependency #1598

debs-obrien opened this issue Dec 12, 2018 · 2 comments · Fixed by #1599

Comments

@debs-obrien
Copy link
Member

debs-obrien commented Dec 12, 2018

  • Operating System: Mac OS
  • Node Version: v10.11.0
  • NPM Version: 6.4.1
  • webpack Version: 5
  • webpack-dev-server Version: 3.1.10
  • This is a bug
  • This is a modification request

Code

  // webpack.config.js
var path = require('path');

module.exports = {
    //...
    devServer: {
        contentBase: path.join(__dirname, 'dist'),
        compress: true,
        port: 9000,
    },
    resolve: {
        alias: {
            'url': false,
            'events' : false
        }
    }
};

Expected Behavior

Actual Behavior

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need these module and configure a polyfill for it.

If you want to include a polyfill, you need to install 'url'.
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.alias: { "url": false }

ERROR in (webpack)/hot/emitter.js 1:19-36
Module not found: Error: Can't resolve 'events' in '/Users/debbieobrien/webpack/node_modules/webpack/hot'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need these module and configure a polyfill for it.

If you want to include a polyfill, you need to install 'events'.
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.alias: { "events": false }
 @ (webpack)-dev-server/client?http://localhost:9000 226:21-51
ℹ 「wdm」: Failed to compile.

after adding the alias to the webpack.config I get this error

 「wds」: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.resolve.alias should be one of these:
   object { <key>: string } | [object { alias?, name?, onlyModule? }]
   -> Redirect module requests
   Details:
    * configuration.resolve.alias['url'] should be a string.
      -> New request
    * configuration.resolve.alias['events'] should be a string.
      -> New request
    * configuration.resolve.alias should be an array:
      [object { alias?, name?, onlyModule? }]

For Bugs; How can we reproduce the behavior?

Run the webpack-dev-server in next branch

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

@debs-obrien debs-obrien changed the title webpack 5 Breaking Change webpack 5 install 'url' and 'events' as a dependency Dec 12, 2018
@TheLarkInn
Copy link
Member

This is a good second timer issue to PR.

It can be a pain because you have to:
Clone, make change, build, then yarn link, and then link locally in a webpack 5 project but since fix is the easy part I'll mark this as Help Wanted

@glenjamin
Copy link
Contributor

The fix for events needs to go into webpack itself, see webpack/webpack#8494

glenjamin added a commit to glenjamin/webpack-dev-server that referenced this issue Dec 13, 2018
This was referenced Mar 7, 2021
This was referenced Mar 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants