lquixada / cross-fetch

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

Fix: 500 error browser ponyfill doesnt export default sveltekit #125

Closed mavdotjs closed 2 years ago

mavdotjs commented 2 years ago

Hi! ๐Ÿ‘‹

Firstly, thanks for your work on this project! ๐Ÿ™‚

Today I used patch-package to patch cross-fetch@3.1.4 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/cross-fetch/dist/browser-ponyfill.js b/node_modules/cross-fetch/dist/browser-ponyfill.js
index f26eb09..7e3ef50 100644
--- a/node_modules/cross-fetch/dist/browser-ponyfill.js
+++ b/node_modules/cross-fetch/dist/browser-ponyfill.js
@@ -545,10 +545,11 @@ delete __self__.fetch.polyfill;
 // Choose between native implementation (global) or custom implementation (__self__)
 // var ctx = global.fetch ? global : __self__;
 var ctx = __self__; // this line disable service worker support temporarily
-exports = ctx.fetch // To enable: import fetch from 'cross-fetch'
-exports.default = ctx.fetch // For TypeScript consumers without esModuleInterop.
-exports.fetch = ctx.fetch // To enable: import {fetch} from 'cross-fetch'
-exports.Headers = ctx.Headers
-exports.Request = ctx.Request
-exports.Response = ctx.Response
-module.exports = exports
+// exports = ctx.fetch // To enable: import fetch from 'cross-fetch'
+// exports.default = ctx.fetch // For TypeScript consumers without esModuleInterop.
+// exports.fetch = ctx.fetch // To enable: import {fetch} from 'cross-fetch'
+// exports.Headers = ctx.Headers
+// exports.Request = ctx.Request
+// exports.Response = ctx.Response
+// module.exports = exports
+export default ctx
\ No newline at end of file

This issue body was partially generated by patch-package.