Skip to main content

@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 install --save-dev @babel/plugin-transform-block-scoped-functions

Usage

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"],
});