Consider adding back browser field in v3
See original GitHub issuev3 removed the browser field, but I believe this should be reconsidered.
The recommended alternative to use cross-fetch is not ideal. Since cross-fetch
ships as a ponyfill, any usage via import (import fetch from "cross-fetch"
) will cause webpack to include an unnecessary cross-fetch ponyfill in the bundle for environments with native fetch.
Scenario:
A user is bundling using webpack and depending on an SDK library that uses fetch
internally. The SDK library is intended to support both node and modern browsers. Which fetch
package should the SDK library use?
- node-fetch v2: Webpack includes
browser.js
from node-fetch which is a tiny wrapper around the native fetch - node-fetch v3: Webpack includes
src/index.js
which is not intended to be used in the browser - cross-fetch: Webpack includes the entire whatwg-fetch ponyfill and it will be used instead of native fetch
Removing browser.js from this package leaves no way for the SDK library to support modern browsers without also forcing unnecessary code in the end-user bundle
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:19 (4 by maintainers)
Top Results From Across the Web
Field 'browser' doesn't contain a valid alias configuration
I tried adding a browser field to my package.json but that didn't seem to do any good. webpack.config.js import path from ' ...
Read more >How To Create A Browser Back Button In Divi
In this tutorial I will show you how to use a normal Divi Button module as a browser back button to always go...
Read more >Focus Order - Understanding Success Criterion 2.4.3 - W3C
2.4.3 Focus Order: If a Web page can be navigated sequentially and the navigation sequences ... they are added or removed from the...
Read more >Using HTTP cookies - MDN Web Docs
The browser may store the cookie and send it back to the same ... Cookies from the same domain are no longer considered...
Read more >Web browser - Wikipedia
A web browser is application software for accessing websites. When a user requests a web page from a particular website, the browser retrieves...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Also strong negative from me. The
"browser"
key was never standardized. It’s a made-up key that most JS bundlers adopted, but not consistently. I cannot count the hours of maintenance pain that the “browser” field caused for obscure use cases. It might make your life easier ifnode-fetch
added it, but it’s a gateway to maintenance hell.Node.js now created a standard that will be a much better fit to server different code for different environments: conditional exports. But to my knowledge none of the bundlers adopted the standard yet.
Strong negative,
node-fetch
is never intended for browser side, you are your best judge as to what polyfill / global export / global fetch is acceptable, we should not be the judge.