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

URL interface #132

Closed
ghost opened this issue Oct 14, 2019 · 6 comments
Closed

URL interface #132

ghost opened this issue Oct 14, 2019 · 6 comments
Labels
wontfix This will not be worked on

Comments

@ghost
Copy link

ghost commented Oct 14, 2019

Other projects like Deno support this:

> new URL('https://github.com')
URL { _parts: { protocol, username, password, hostname, port, path, query,
hash}, _searchParams: URLSearchParams { params: [], url: [Circular], append:
[Function], delete: [Function], set: [Function] } }

However Hermes does not:

>> new URL('https://github.com')
ReferenceError: Property 'URL' doesn't exist

https://developer.mozilla.org/docs/Web/API/URL

@tmikov
Copy link
Contributor

tmikov commented Oct 14, 2019

Thank you for pointing this our. Hermes doesn't currently implement the URL constructor because it is part of the web platform (https://spec.whatwg.org/), not ECMAScript, and Hermes is not supposed to run in browsers.

With that said, we realize that it can be a useful feature. Implementing in Hermes however would be a non-trivial binary size increase of Hermes, which would affect everybody, even apps that don't need it.

We recommend using a polyfill like https://www.npmjs.com/package/whatwg-url or https://www.npmjs.com/package/url-polyfill .

For more context a similar issue is being tracked at facebook/react-native#16434 .

@dzek69
Copy link

dzek69 commented Oct 14, 2019

IMO React Native shouldn't expose global URL then, because it does a lot of other things are build to be browser-compatible like fetch (and bare XMLHttpRequest), alert, requestAnimationFrame.

Keeping SOME compatible globals and having some well-known but incompatible is counter-intuitive.

And it's hard to fix issues caused by that sometimes (because if some library depends on global URL the only thing I can do is to override URL with compatible solution... while possibly breaking things that depended on non-compatible global implementation...).

I'd suggest in the next breaking release of RN to rename that non compatible global into something else.

To keep conversation clean - upvote if you agree. Discuss if you have different views/solutions.

@tmikov
Copy link
Contributor

tmikov commented Oct 14, 2019

I agree. In fact I am not entirely sure that RN exposes a global URL. Does it? It has an URL module, but I didn't see code installing it in the global object (but I could have missed it).

I think it would be more constructive to discuss this in the RN issue rather than here.

@tmikov tmikov added the wontfix This will not be worked on label Oct 21, 2019
@tmikov
Copy link
Contributor

tmikov commented Oct 21, 2019

Closing for now with "wontfix". If in the future our thinking changes, we can revisit.

@tmikov tmikov closed this as completed Oct 21, 2019
@vicary
Copy link

vicary commented Apr 20, 2020

For others ended up here in the future. The recommended polyfills doesn't even work, both throws when calling new URL(...).

@tmikov
Copy link
Contributor

tmikov commented Jul 28, 2023

FYI, #1072 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants