Version 3.2.0 includes a fix for "global" in node environments. Recent versions of rollup enforce a "no top-level this" rule and forces this to be undefined.
I see a message like this:
(!) `this` has been rewritten to `undefined`
https://rollupjs.org/guide/en/#error-this-is-undefined
node_modules/whatwg-fetch/fetch.js
2: return self
3: // eslint-disable-next-line no-invalid-this
4: })(typeof self !== 'undefined' ? self : this)
^
5: var support = {
6: searchParams: 'URLSearchParams' in global,
I'm using Rollup to bundle a polyfill for older browsers.
FWIW, this is the globalThis fallback chain that babel adds to my code any time I use global.
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
I believe that babel just uses whatever cores-js does for globalThis
Version 3.2.0 includes a fix for "global" in node environments. Recent versions of rollup enforce a "no top-level this" rule and forces
thisto beundefined.I see a message like this:
I'm using Rollup to bundle a polyfill for older browsers.
FWIW, this is the
globalThisfallback chain that babel adds to my code any time I useglobal.I believe that babel just uses whatever
cores-jsdoes forglobalThis