Babel plugin for transforming
globalThis
.
npm install babel-plugin-transform-globalthis --save-dev
Use it via available plugin activation options.
For .babelrc
file:
{
"plugins": ["babel-plugin-transform-globalthis"]
}
Then, in your code:
/* Before */
globalThis.becky;
/* After */
// Ommited for simplicity - here goes `globalThis` ponyfill
var _globalThis = {};
_globalThis.becky;
Check test fixtures (actual and expected) for more examples.
- A horrifying
globalThis
polyfill in universal JavaScript by @mathias @ungap/global-this
by @WebReflection
MIT © Ivan Nikolić