babel/packages/babel-plugin-transform-function-name
Axel Nyffenegger bd98041321 Fix function name computation for literal values (#7435)
* Fix name computation for literal values

* Add more computed literal test cases

* Always return a string in getNameFromLiteralId

- Also concatenate quasis id for regex literal

* Add a test clarifying function name for template literals

* Remove useless else ifs
2018-04-09 21:00:55 -04:00
..
2018-04-02 18:19:30 -04:00

@babel/plugin-transform-function-name

Apply ES2015 function.name semantics to all functions

Examples

In

let number = (x) => x

Out

var number = function number(x) {
  return x;
};

Installation

npm install --save-dev @babel/plugin-transform-function-name

Usage

.babelrc

{
  "plugins": ["@babel/plugin-transform-function-name"]
}

Via CLI

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

Via Node API

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