Bug: Can we change global to globalThis?
xiaoxiangmoe opened this issue · comments
Line 221 in 0e49fc3
In browsers we have no global
, but we have globalThis
both in browsers and nodejs
Did you run into an error?
Hmm. Do you know if angular/cli is using webpack 5 now?
This line has been in there since the beginning, millions of users have used it just fine, so I’m assuming bundlers have always added it, but also know that webpack 5 changed some similar things.
No, angular/cli use webpack 4. Maybe we should support webpack 5, also.
In that case, I’m assuming this still works fine in webpack 5 (because that’s been out a bit and nobody else raised an issue for it), but that angular/cli is the root problem.
Regardless, I’d appreciate a PR!
Oh btw, sorry I forgot: I’m not sure globalThis
is a good idea. As it doesn’t work everywhere, and that could be a breaking change.
I think we’re already getting the global scope somewhere else in the code. Perhaps use that?
Lines 9 to 14 in 0e49fc3
Do you mean we should use ctx
?
I think that’d do the trick yeah. But maybe that’d also need to support Node’s global
?
see #37
Another polyfill for globalThis: https://github.com/ungap/global-this/blob/master/index.js