You can search for cross-fetch in the chrome devtools you will see that it's get bundled.
Expected behavior
It should be striped from the browser envs
The problem is in that if condition, bundlers usually replacing typeof window with "object" for browser env (atleast Next.js does), so the deopt of this optimization is the second or condition typeof window.document === 'undefined'
if (typeof require !== 'undefined' && (typeof window === 'undefined' || typeof window.document === 'undefined')) {
var f = fetchApi || require('cross-fetch')
if (f.default) f = f.default
exports.default = f
module.exports = exports.default
}
🐛 Bug Report
cross-fetch
is ment to be use only in node env (based on the code here), but when I bundle a client app, this lib is inside the bundle.To Reproduce
https://pzz539.csb.app/
You can search for cross-fetch in the chrome devtools you will see that it's get bundled.
Expected behavior
It should be striped from the browser envs
The problem is in that if condition, bundlers usually replacing
typeof window
with"object"
for browser env (atleast Next.js does), so the deopt of this optimization is the secondor
conditiontypeof window.document === 'undefined'
Your Environment