The untransformed `let` keyword causes problems for older parsers. I understand using `let` instead of `var` ensures each getter function has its own binding for the KEY variable, but the same can be accomplished (with less code) using a `.forEach` callback function, and this way there's no need to worry about generating a unique name for the `key` variable.
babel-plugin-transform-es2015-modules-commonjs
Installation
$ npm install babel-plugin-transform-es2015-modules-commonjs
Usage
Via .babelrc (Recommended)
.babelrc
// without options
{
"plugins": ["transform-es2015-modules-commonjs"]
}
// with options
{
"plugins": [
["transform-es2015-modules-commonjs", {
"allowTopLevelThis": true
}]
]
}
Via CLI
$ babel --plugins transform-es2015-modules-commonjs script.js
Via Node API
require("babel-core").transform("code", {
plugins: ["transform-es2015-modules-commonjs"]
});