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

remove direct es6-promise dependency #41

Closed
CharlesKuncheria opened this issue Apr 17, 2020 · 6 comments
Closed

remove direct es6-promise dependency #41

CharlesKuncheria opened this issue Apr 17, 2020 · 6 comments

Comments

@CharlesKuncheria
Copy link

Would you consider removing es6-promise dependency and let consumer provide es6-promise polyfill

@josh08h
Copy link

josh08h commented Apr 30, 2020

Bump.

@jonbern
Copy link
Owner

jonbern commented Jun 20, 2020

I agree that it would be great to be able to remove the es6-promise dependency.

Do you have any suggestions for an elegant way for the consumer to provide a promise polyfill?

As far as I can tell, it's currently only IE that lacks Promise functionality, which means it still needs to be provided for backwards functionality. At the same time, I feel that having to provide a Promise dependency in the constructor function is somewhat clunky.

Maybe it would be a better approach to try to find a more lightweight Promise polyfill? es6-promise is currently 315 kB, while promise-polyfill is 42.5 kB (https://www.npmjs.com/package/promise-polyfill).

@ptolemybarnes
Copy link
Contributor

Hey @jonbern, what do you think about pushing the responsibility of polyfilling Promise on to the consumer? The way I see it fetch-retry is a small package for doing a very specific job and needn't be concerned with polyfilling the environment. https://github.com/matthew-andrews/isomorphic-fetch has the same policy (though perhaps bad example, looks unmaintained).

This would be a breaking change of course.

@jonbern
Copy link
Owner

jonbern commented Jun 23, 2020

I think that's a very valid point.

Given that all browsers except IE support promises, and also that IE is the only browser that doesn't support the Fetch API, I would think it should be safe to leave responsibility of adding the necessary polyfills to the user code.

https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise

@ptolemybarnes
Copy link
Contributor

ptolemybarnes commented Jun 23, 2020

I guess yet another option would be to offer 2 exports: one with the polyfill and one without (a bit like cross-fetch). That way you could avoid a breaking change. Still, for the reasons I already mentioned I would probably take the breaking change to remove the dependency altogether.

@jonbern
Copy link
Owner

jonbern commented Jun 27, 2020

I have created a new major version without the es6-promise dependency.

Thanks for bringing up the issue, and for providing valuable input and good suggestions.

https://github.com/jonbern/fetch-retry/releases/tag/4.0.0

@jonbern jonbern closed this as completed Jun 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants