makes detection of CommonJS environments more robust
globalThis is the official way to refer to the global scope and is supported by almost all environments:
engine
self
globalThis
Node.js
✖
✔
QuickJS
✖
✔
SpiderMonkey
✖
✔
Modern browsers
✔
✔
Deno
✔
✔
IE11
✔
✖
The notable exception is IE11, which will need to use a polyfill. If IE11 support was previously promised or assumed, then this would be a breaking change.
This PR:
self
withglobalThis
globalThis
is the official way to refer to the global scope and is supported by almost all environments:The notable exception is IE11, which will need to use a polyfill. If IE11 support was previously promised or assumed, then this would be a breaking change.