In my current project I have a lot of global variables: (not declared with var)
HELLO = 'Hello';
I installed babel so I can use all the ES next functions, but it seems babel doesn't now how to deal with global variables
.babelrc
{
"presets": [
[
"@babel/preset-env",
{
"modules": "commonjs"
}
]
],
"plugins": ["angularjs-annotate"]
}
UPDATE!!
Seems that it comes from babel transpiling.
Babel added: "use strict"; . That's why my code failed
Ok. It takes me a while to figure it out.
here's the solution: Add that to the plugins in .babelrc
"plugins": [
["@babel/plugin-transform-modules-commonjs", {
"strictMode": false
}],
"angularjs-annotate"
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With