From fc907e2f81698d89502fb2ee0375e6d98a492c13 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Thu, 9 Sep 2021 23:33:34 -0700 Subject: current --- src/node-fallbacks/@vercel_fetch.js | 11 ++++++++--- src/node-fallbacks/isomorphic-fetch.js | 2 +- src/node-fallbacks/node-fetch.js | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src/node-fallbacks') diff --git a/src/node-fallbacks/@vercel_fetch.js b/src/node-fallbacks/@vercel_fetch.js index 5ab626670..95314ba9e 100644 --- a/src/node-fallbacks/@vercel_fetch.js +++ b/src/node-fallbacks/@vercel_fetch.js @@ -1,6 +1,8 @@ // This is just a no-op. Intent is to prevent importing a bunch of stuff that isn't relevant. -module.exports = (wrapper = Bun.fetch) => { - return async function vercelFetch(url, opts = {}) { +module.exports = ( + wrapper = "Bun" in globalThis ? Bun.fetch : globalThis.fetch +) => { + async function vercelFetch(url, opts = {}) { // Convert Object bodies to JSON if they are JS objects if ( opts.body && @@ -27,5 +29,8 @@ module.exports = (wrapper = Bun.fetch) => { err.opts = opts; throw err; } - }; + } + + vercelFetch.default = vercelFetch; + return vercelFetch; }; diff --git a/src/node-fallbacks/isomorphic-fetch.js b/src/node-fallbacks/isomorphic-fetch.js index 0bbe50ebf..96cbd72fb 100644 --- a/src/node-fallbacks/isomorphic-fetch.js +++ b/src/node-fallbacks/isomorphic-fetch.js @@ -1 +1 @@ -export default Bun.fetch; +export default "Bun" in globalThis ? Bun.fetch : globalThis.fetch; diff --git a/src/node-fallbacks/node-fetch.js b/src/node-fallbacks/node-fetch.js index 0bbe50ebf..96cbd72fb 100644 --- a/src/node-fallbacks/node-fetch.js +++ b/src/node-fallbacks/node-fetch.js @@ -1 +1 @@ -export default Bun.fetch; +export default "Bun" in globalThis ? Bun.fetch : globalThis.fetch; -- cgit v1.2.3