A babel-plugin
that translates global assignment statements into setting property statements for global objects.
npm install --save-dev babel-plugin-global-assignment
{
"plugins": [
[
"babel-plugin-global-assignment", {
"globalObject": "window"
}
]
]
}
- globalObject: Specify global object name.
in
foo = true
function () {
bar = true
let baz = false
baz = true
}
out
window.foo = true
function () {
window.bar = true
let baz = false
baz = true
}