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

Error when compiling webpack #168

Closed
damusix opened this issue Dec 3, 2022 · 3 comments
Closed

Error when compiling webpack #168

damusix opened this issue Dec 3, 2022 · 3 comments

Comments

@damusix
Copy link
Contributor

damusix commented Dec 3, 2022

ERROR in ./node_modules/@riotjs/route/route.esm.js 729:18-38
Module not found: Error: Can't resolve 'url' in '/Users/alonso/projects/upm/electron-app/node_modules/@riotjs/route'

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 this module and configure a polyfill for it.

Culprit is in route.esm.js

const parseURL = function parseURL() {
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
    args[_key] = arguments[_key];
  }

  return isNode ? require('url').parse(...args) : new URL(...args); // <---
};

This fixes it

const parseURL = function parseURL() {
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
    args[_key] = arguments[_key];
  }

  return new URL(...args); // <---
};

Any reason to require('url') since URL is standard in both Node and Browser?

@GianlucaGuarini
Copy link
Member

The legacy Nodejs url module didn't require the base like the URL instance does. It's an ergonomic decision that I will need to re-evaluate in https://github.com/GianlucaGuarini/rawth/

Stay tuned :)

@JaredCHall
Copy link

I was able to fix this in webpack 5.75 by running npm install url.

@GianlucaGuarini
Copy link
Member

Fixed in v9.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants