lquixada / cross-fetch

Universal WHATWG Fetch API for Node, Browsers and React Native.
MIT License
1.67k stars 104 forks source link

Don't bundle whatwg-fetch in browser entry #51

Closed jacobrask closed 5 years ago

jacobrask commented 5 years ago

Instead of bundling the entire whatwg-fetch, could it be a require() call, like in isomorphic-fetch and isomorphic-unfetch?

The browser field is the default entry point for all Webpack builds, which means that anyone using Webpack and accidentally including some other package that also pulls in whatwg-fetch will get duplicate copies.

lquixada commented 5 years ago

You're right! the issue with importing/requiring whatwg-fetch is that it's going to polyfill your environment. It's not going to be an option anymore, it will be mandatory. Although there will be duplicate code in node_modules, it's going to be a very small one. So it's a cheap price to pay to have a clean ponyfill.

jacobrask commented 5 years ago

Ok, I see the reason then, but whatwg-fetch is almost 8kB, I wouldn't consider that negligible, it all adds up in a large project.

lquixada commented 5 years ago

Unfortunately I don't see any alternative to that. Closing the issue.