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

[bug] URL is not a constructor #37

Open
webpack-bot opened this issue Jul 26, 2017 · 13 comments
Open

[bug] URL is not a constructor #37

webpack-bot opened this issue Jul 26, 2017 · 13 comments

Comments

@webpack-bot
Copy link

Do you want to request a feature or report a bug?

Bug with WHATWG URL API provided by native url module.

What is the current behavior?

// ES6

import { URL } from 'url';

console.log(typeof URL); // undefined
// CommonJS

const { URL } = require('url');

console.log(typeof URL); // undefined

If the current behavior is a bug, please provide the steps to reproduce.
I provided code above, is it a normal behavior and we should use Web API URL or WHATWG URL API should be provided through url module?

What is the expected behavior?

// ES6 modules

import { URL } from 'url';

console.log(typeof URL); // function
// CommonJS modules

const { URL } = require('url');

console.log(typeof URL); // function

Please mention your webpack and Operating System version.

node 8.2.1
webpack 3.3.0
macOS Sierra 10.12.6


This issue was moved from webpack/webpack#5372 by @sokra. Orginal issue was by @zalishchuk.

node-url exports it as exports.Url instead of exports.URL

@mightyiam
Copy link

It seems an eco-system winner is the url-parse package.

@davydof
Copy link

davydof commented Jun 27, 2019

any update?

@redbrain
Copy link

Having this issue on a production app. A fix would be nice to see.
Mentioning @defunctzombie because they're the only clear maintainer.

@defunctzombie

This comment has been minimized.

@ljharb

This comment has been minimized.

@defunctzombie
Copy link
Owner

I've added @ljharb you as a collaborator.

@ljharb

This comment has been minimized.

@ljharb ljharb closed this as completed Jan 27, 2021
@ljharb ljharb reopened this Jan 27, 2021
@defunctzombie

This comment has been minimized.

@ljharb
Copy link
Collaborator

ljharb commented Jan 28, 2021

I'll address this as part of the "node catchup" described in #53.

@Lazauya

This comment was marked as outdated.

@ljharb

This comment was marked as resolved.

@Lazauya

This comment was marked as outdated.

@MrMYHuang
Copy link

I browserify url to my package url-myh by adding this:
https://github.com/MrMYHuang/node-url/blob/66254d75eb169565d1290aae43337b0973a5fa87/url.js#L774

It works well with a combination of webpack 5 + node-polyfill-webpack-plugin-myh (using url-myh) + node-downloader-helper + memfs-myh. This is an example: https://github.com/MrMYHuang/taa

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

8 participants