-
-
Notifications
You must be signed in to change notification settings - Fork 80
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
Avoid import when targets support native fetch
#45
Comments
I agree, but there was some fear for two things:
|
I'm not sure what you mean here.
I believe that someone was working on this already, do you recall that? |
I mean that @stefanpenner was concerned that perhaps people in development had modern targets and things work but when they deploy to prod, with the polyfill, something is different in some subtle way. I don't buy that argument a lot tho.
I recall, it was me 🤣 . I really need to come back to that. |
I am curious to understand why fetch will not work with pretender? Pretender just replaces the XHR layer with Fake XHR AFAIU. If fetch (with the polyfill) is calling XHR under the hood, you don't need a pretender-fetch. Example: if you use jQuery.ajax pretender doesn't do anything special. |
The goal of this issue is to avoid including the polyfill at all, when the browsers that the application supports already have native |
Agreed, my question is more around to understand why pretender will not work with |
Pretender currently only captures requests that go through XHR. When native fetch is used its requests will no longer funnel through XHR and therefore Pretender will not be able to intercept. @cibernox has a spike for a "fake fetch" (akin to FakeXHR which pretender uses now), which should address this concern (though I actually do not consider it a blocker). |
@rwjblue Sorry I didn't notice the issue. Seems there's still no update on pretender fetch, but it's already 2 years from that issue. I was wondering whould we begin to provide an option to use native fetch. |
This is supported after v5.1.0 #63 |
Just out of curiosity, is the polyfill still included in the vendor file at all time, correct? |
@mydea - Yes, totally agreed. @xg-wang - This issue was created to track avoiding the include the polyfill at all in |
Released as v6.4.0 🎉 As mentioned in readme, to avoid bundling redundant polyfill assets just set // ember-cli-build.js
let app = new EmberAddon(defaults, {
// Add options here
'ember-fetch': {
preferNative: true
}
}); Browser targets supports for Thanks @mydea for landing this feature! |
We can use
this.project.targets
to determine if thewhatg-fetch
polyfill is required for the browser builds, and avoidapp.import
ing it when it is not needed.See browser support. Roughly includes all evergreen browsers (FireFox, Edge, Chrome, Safari)...
The text was updated successfully, but these errors were encountered: