You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why does Parcel bundler create a "global" variable in the browser? Is it safe setting it as undefined? Will it break anything Parcel cares about?
#4721
Hi, so I was trying to use an SDK that is used on the browser-primarily and inside node for server calls. At the moment I'm using their frontend JS and at this time since it's used for both front/back it has to check if it's being used in the browser OR node like so...
const isBrowser = new Function("return typeof window !== 'undefined'") // eslint-disable-line
const isNode = new Function("return typeof global !== 'undefined'") // eslint-disable-line
The problem is when trying to use their SDK Parcel defines a "global" variable which causes the isNode to return true, even though it's in the browser. Why does Parcel define "global" in the browser? I noticed an object called Window, but not sure what it's used for. As a hotfix at this time, I set global = undefined just so the SDK I was given works when it's attempted to be called. Will this break anything with Parcel or cause issues? -- Just making sure I don't shoot myself in the foot later.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, so I was trying to use an SDK that is used on the browser-primarily and inside node for server calls. At the moment I'm using their frontend JS and at this time since it's used for both front/back it has to check if it's being used in the browser OR node like so...
The problem is when trying to use their SDK Parcel defines a "global" variable which causes the
isNode
to return true, even though it's in the browser. Why does Parcel define "global" in the browser? I noticed an object called Window, but not sure what it's used for. As a hotfix at this time, I setglobal = undefined
just so the SDK I was given works when it's attempted to be called. Will this break anything with Parcel or cause issues? -- Just making sure I don't shoot myself in the foot later.Beta Was this translation helpful? Give feedback.
All reactions