@babel/plugin-transform-function-name

function-name - 图1info

This plugin is included in @babel/preset-env

Examples

In

JavaScript

  1. let number = x => x;

Out

JavaScript

  1. var number = function number(x) {
  2. return x;
  3. };

Installation

  • npm
  • Yarn
  • pnpm
  1. npm install --save-dev @babel/plugin-transform-function-name
  1. yarn add --dev @babel/plugin-transform-function-name
  1. pnpm add --save-dev @babel/plugin-transform-function-name

Usage

babel.config.json

  1. {
  2. "plugins": ["@babel/plugin-transform-function-name"]
  3. }

Via CLI

Shell

  1. babel --plugins @babel/plugin-transform-function-name script.js

Via Node API

JavaScript

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