@babel/plugin-transform-block-scoped-functions
NOTE: This plugin is included in
@babel/preset-env
Examples
In
JavaScript
{
function name(n) {
return n;
}
}
name("Steve");
Out
JavaScript
{
let name = function(n) {
return n;
};
}
name("Steve");
Installation
- npm
- Yarn
npm install --save-dev @babel/plugin-transform-block-scoped-functions
yarn add --dev @babel/plugin-transform-block-scoped-functions
Usage
With a configuration file (Recommended)
babel.config.json
{
"plugins": ["@babel/plugin-transform-block-scoped-functions"]
}
Via CLI
Shell
babel --plugins @babel/plugin-transform-block-scoped-functions script.js
Via Node API
JavaScript
require("@babel/core").transformSync("code", {
plugins: ["@babel/plugin-transform-block-scoped-functions"],
});