-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Use web_sys::Url instead of url::Url on wasm32 targets #2050
Comments
I've had a look into this:
I'd lean towards making One could go for |
A couple of unsorted thoughts:
|
Yeah, breaking APIs is the biggest blocker for all of this. I've also had a look into whether something could be done on the |
So at least for now, I don't think we can make this specific change. We might remove |
On
wasm32
,url
adds 279KB to the compiled binary size. A significant chunk of that is because of IDN support, which requires a large look-up table.wasm32
targets haveweb_sys::Url
, which provides similar functionality tourl::Url
at much a smaller binary size. It even supports IDN on modern browsers, which have their own internal look-up table.reqwest
should be able to useweb_sys::Url
instead ofurl::Url
onwasm32
targets, or some other genericurl::Url
-like trait.Detail / background
There have been attempts in the
url
crate to makeidna
support optional to cut down most of this size, however they have been rolled back, and progress appears stalled.The current upstream-recommended work-around is to patch out the
idna
crate with a replacement which implements the same API. There aren't any browser/JS APIs which provide IDN support in a way that could replace theidna
crate. One could break IDNA support entirely – but that's not great.However,
wasm32
targets do expose theweb_sys::Url
type, which supports IDN just fine on modern browsers.The request here is for
reqwest
to be able to useweb_sys::Url
instead ofurl::Url
onwasm32
targets.That look-up table overhead exists on all other platforms as well, and it may be better to have
reqwest
define a trait that allows easily swapping out theUrl
implementation.The text was updated successfully, but these errors were encountered: