Comments (12)
@mydea - Yes, totally agreed.
@xg-wang - This issue was created to track avoiding the include the polyfill at all in vendor.js
, but AFAICT the fix added in #63 will still continue to ship the polyfill but will avoid using it if native fetch is present. I'm reopening this issue so that we can track the vendor.js "slim down"...
from ember-fetch.
I agree, but there was some fear for two things:
- Possible edge cases in which the polyfill doesn't behave perfectly
- The problem that pretender.js will not work with fetch, and it is VERY popular. We need pretender-fetch to happen.
from ember-fetch.
Possible edge cases in which the polyfill doesn't behave perfectly
I'm not sure what you mean here.
The problem that pretender.js will not work with fetch, and it is VERY popular. We need pretender-fetch to happen.
I believe that someone was working on this already, do you recall that?
from ember-fetch.
I'm not sure what you mean here.
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 believe that someone was working on this already, do you recall that?
I recall, it was me 🤣 . I really need to come back to that.
from ember-fetch.
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.
from ember-fetch.
If fetch (with the polyfill) is calling XHR under the hood, you don't need a pretender-fetch.
The goal of this issue is to avoid including the polyfill at all, when the browsers that the application supports already have native fetch
.
from ember-fetch.
Agreed, my question is more around to understand why pretender will not work with fetch
in testing (if your tests are already running against browsers that support fetch)? pretender should be agnostic to the high-level network interface being used (whether fetch/jQuery.ajax) etc.
from ember-fetch.
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).
from ember-fetch.
@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.
from ember-fetch.
This is supported after v5.1.0 #63
from ember-fetch.
Just out of curiosity, is the polyfill still included in the vendor file at all time, correct?
Wouldn't it be nice to not even include it, if all browser targets have it?
from ember-fetch.
Released as v6.4.0 🎉
As mentioned in readme, to avoid bundling redundant polyfill assets just set preferNative
to true
// ember-cli-build.js
let app = new EmberAddon(defaults, {
// Add options here
'ember-fetch': {
preferNative: true
}
});
Browser targets supports for fetch
and abortcontroller
are checked from caniuse-api. ember-fetch
will then load only the necessary polyfills and its own wrapper 😄
Thanks @mydea for landing this feature!
from ember-fetch.
Related Issues (20)
- Version 6.7.2 onwards seems not to transpile to es5 (Caused IE11 Blank screen, with no console errors) HOT 2
- Could not find module `fetch` imported from `prog/instance-initializers/setup-fetch` HOT 2
- Operation outputFileSync is not allowed to use HOT 15
- Where are all the response headers? HOT 2
- Inconsistent Headers objects with preferNative HOT 1
- fetch is not defined - maybe your browser targets are not covering everything you need HOT 31
- v8.0.3 contains `yarn-error.log` file
- Ember 3.27+ issues deprecation for accessing `window.Ember` HOT 1
- Could not find module `rsvp` imported from `fetch` HOT 6
- Version 8.1.0 not released to NPM? HOT 1
- Migration from jquery.ajax $.ajaxSettings.traditional = true. How remove [] from params
- Dropping Node 10, older versions of Ember
- Archive this repo? HOT 16
- Deprecation warning for assign() from ember/polyfills
- Failed to execute 'fetch' on 'Window': Failed to read the 'signal' property from 'RequestInit': Failed to convert value to 'AbortSignal'.
- ember-polyfills.deprecate-assign deprication in Ember 4.4
- ember-fetch `input` type parameter is incorrect
- Upgrade package "node-fetch" to fix
- `Error: cannot find module rsvp imported from fetch`: Ember 4.12 + embroider-optimized scenario HOT 1
- Maintenance, V2, modern `fetch`, etc
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-fetch.