@babel/plugin-transform-block-scoped-functions

Examples

In

  1. {
  2. function name (n) {
  3. return n;
  4. }
  5. }
  6. name("Steve");

Out

  1. {
  2. let name = function (n) {
  3. return n;
  4. };
  5. }
  6. name("Steve");

Installation

  1. npm install --save-dev @babel/plugin-transform-block-scoped-functions

Usage

  1. {
  2. "plugins": ["@babel/plugin-transform-block-scoped-functions"]
  3. }

Via CLI

  1. babel --plugins @babel/plugin-transform-block-scoped-functions script.js

Via Node API

  1. require("@babel/core").transform("code", {
  2. plugins: ["@babel/plugin-transform-block-scoped-functions"]
  3. });