lquixada / cross-fetch

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

Doesn't work with browser es module loading #46

Open kevinsimper opened 5 years ago

kevinsimper commented 5 years ago

I used polymer to bundle the code, it will load the node-ponyfill.js

I know this is maybe not the intention with the library, it can just be confusing for new beginners that want to use a library that does backsupport old browser while at the same time uses just fetch with the new es module loading.

https://github.com/kevinsimper/cross-fetch-esm-test

https://cross-fetch-es-module.surge.sh/

https://github.com/Polymer/tools/tree/master/packages/cli

seangwright commented 7 months ago

I'm having the same issue when using graphql-request with @web/dev-server

The error I'm seeing is

Uncaught SyntaxError: The requested module './../../../cross-fetch/dist/browser-ponyfill.js' does not provide an export named 'default'
import crossFetch, * as CrossFetch from './../../../cross-fetch/dist/browser-ponyfill.js'; // error here in /node_modules/graphql-request/build/esm/index.js