question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Avoid import when targets support native `fetch`

See original GitHub issue

We can use this.project.targets to determine if the whatg-fetch polyfill is required for the browser builds, and avoid app.importing it when it is not needed.

See browser support. Roughly includes all evergreen browsers (FireFox, Edge, Chrome, Safari)…

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
rwjbluecommented, Nov 26, 2018

@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”…

0reactions
xg-wangcommented, Dec 19, 2018

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Trying to use fetch and pass in mode: no-cors - Stack Overflow
So I am trying to pass in an object, to my Fetch which will disable ... in practice the scenario that's for is...
Read more >
Using fetch with TypeScript - Kent C. Dodds
When migrating some code to TypeScript, I ran into a few little hurdles I want to share with you. The use case: In...
Read more >
Fetch Standard
The goal is to unify fetching across the web platform and provide consistent handling of everything that involves, including: URL schemes ...
Read more >
API Docs | fetch-mock - Wheresrhys
fetch -mock allows mocking http requests made using fetch or a library imitating its api, such as node-fetch or fetch-ponyfill. It supports most...
Read more >
Fetch API - MDN Web Docs
The Fetch API provides an interface for fetching resources (including across ... The following browsers shipped an outdated native fetch, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found