When convert a const, let or any other block-bound binding to a var we forget to update the scope info. This confuses other transforms that may come after this as to which scope does the binding belongs to. This also uncovered an issue where duplicate block-scoped bindings were allowed to co-exist.
babel-plugin-transform-es2015-block-scoping
Compile ES2015 block scoping (const and let) to ES5
Installation
$ npm install babel-plugin-transform-es2015-block-scoping
Usage
Via .babelrc (Recommended)
.babelrc
{
"plugins": ["transform-es2015-block-scoping"]
}
Via CLI
$ babel --plugins transform-es2015-block-scoping script.js
Via Node API
require("babel-core").transform("code", {
plugins: ["transform-es2015-block-scoping"]
});