-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
url
is not a valid polyfill for Node's native url
#7801
Comments
Out of curiosity: how is this related to parcel? |
Because Parcel explicitly uses the npm url library in Node emulation. See here. Parcel assumes that it is exactly the same as the native library, when it is not. |
If you do The So please describe exactly the code you're using which doesn't work. |
I'm confused. I don't see any package anywhere called |
(That was a typo, it should have been Yes, so this is essentially the same request as defunctzombie/node-url#33 |
So it seems like the solution is to use |
If you are targetting modern browsers and modern node with your code, simply use the Otherwise, yes: import |
I'm talking about what Parcel does to other packages during Node emulation, not how I should build my packages. Specifically in the case of Node emulation. Packages that use |
Yeah, we might have to fork |
Actually, I think that this package might just be the perfect candidate. It seems widely used and stable. |
But that's a polyfill for |
|
No:
|
You are very correct, sir. So it seems a fork would be needed after all. |
🐛 bug report
Name describes it. Namely, the titular object is
URL
in Node, notUrl
as it is in url. This means that using code that callsnew URL
does not work. The npm url also does not parse the url when creating the url.🎛 Configuration
Any configuration, though obviously the polyfill will only apply when the URL lib is invoked.
🤔 Expected Behavior
You should be able to use any of the Node URL lib's code.
😯 Current Behavior
new URL
does not work due to wrong name.💁 Possible Solution
I made a patch locally by copying
https://github.com/defunctzombie/node-url
and changing the export fromUrl
toURL
and making the constructor parse the url.🔦 Context
Just kinda annoying.
Conclusion
This seems like a relatively simple fix. I'm thinking just a new npm package that forks/leverages existing URL parsing packages so that actual syntax parity is met with the native Node URL module.
The text was updated successfully, but these errors were encountered: