Skip to content
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

Added a more updated alternative to isomorphic-fetch. #272

Closed
wants to merge 1 commit into from
Closed

Added a more updated alternative to isomorphic-fetch. #272

wants to merge 1 commit into from

Conversation

lquixada
Copy link

@lquixada lquixada commented Oct 18, 2017

isomorphic-fetch hasn't been updated for a while, so cross-fetch was created in order to provide a more updated, flexible and fixed alternative to the community.

@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@lquixada lquixada changed the title Dropped isomorphic-fetch in favor of cross-fetch (React Native compatible). Added a more updated alternative to isomorphic-fetch. Nov 2, 2017
module.exports = require('isomorphic-fetch');
}
// Add a universal fetch polyfill (React Native compatible)
require('cross-fetch/polyfill')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I never really wanted to use a polyfill here - requiring ideally shouldn't mutate global state.

Would it maybe make sense to to not require the polyfill here if global.fetch exists (basically what we had here before and only replace the require('isomorphic-fetch') call?

I actually forget which of our users are even using this. I think it's just relay-classic and I'm sure they aren't depending on it actually being a polyfill so it's probably ok. We were also already deferring to ReactNative's or the browser if in those environments without polyfilling. What do you think?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally agree with not touching the global state. I only suggested the polyfill because requiring isomorphic-fetch do that automatically. So I wanted to do a 1:1 conversion.

However, for the sake of consistency, I think it's better to depend on one implementation, be it the native one or the third-party one. The code in question relies on both leading to the same problem polyfill faces as sindresorhus discusses here.

For instance, if fetch spec receives a new feature and it's deployed to the browser, the chosen fallback library might not follow that improvement or might take long to publish it.

So, my suggestion is to use only the native fetch (consistent but gets some environments uncovered), to use only a third-party library (consistent but adds more codebase) or to leave this decision to the users.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @zpao! any news on this matter?

@lquixada
Copy link
Author

upgraded the isomorphic-fetch alternative to version 3.

@lquixada lquixada closed this Oct 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants