Closed xiaoxiangmoe closed 3 years ago
Did you run into an error?
Yes! I'm using @angular/cli which using webpack as bundler.
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?
https://github.com/wooorm/refractor/blob/0e49fc33bfac9ae201a815a1e33b3a53152cf73a/core.js#L9-L14
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
?
Another polyfill for globalThis: https://github.com/ungap/global-this/blob/master/index.js
https://github.com/wooorm/refractor/blob/0e49fc33bfac9ae201a815a1e33b3a53152cf73a/core.js#L221
In browsers we have no
global
, but we haveglobalThis
both in browsers and nodejs