ES2015 block scoped functions transform

Ensure function declarations at the block level are block scoped

安装

npm install --save-dev babel-plugin-transform-es2015-block-scoped-functions

用法

通过 .babelrc(推荐)

.babelrc

{
  "plugins": ["transform-es2015-block-scoped-functions"]
}

通过 CLI

babel --plugins transform-es2015-block-scoped-functions script.js

通过 Node API

require("babel-core").transform("code", {
  plugins: ["transform-es2015-block-scoped-functions"]
});