lucasfeliciano / fetch-everywhere

WHATWG Fetch API, for ALL JavaScript environments!
MIT License
52 stars 13 forks source link

Discussion to change the polyfill approach #5

Closed lucasfeliciano closed 1 year ago

lucasfeliciano commented 8 years ago

I'm tending to make the polyfill optional.

The Idea is to use like:

import fetch from 'fetch-everywhere';

This will check the environment and depending on the environment it will export one of these:

Also we have a option to apply the polyfill:

require('fetch-everywhere').polyfill()

Doing that we will apply fetch to the global scope.

montogeek commented 8 years ago

At this moment i am using it like import 'fetch-everywhere' because these reasons https://github.com/wheresrhys/fetch-mock#fetch-is-assigned-to-a-local-variable-not-a-global

lucasfeliciano commented 8 years ago

@montogeek

In this case you will do like this:

require('fetch-everywhere').polyfill();

I don't think it is a good practice mess with the global object, so if we could keep things in the local scope it is better.

For cases that you need to use in the global scope you can do it explicitly calling the polyfill() method