babel/packages/babel-plugin-transform-function-name
Diogo Franco 81811bf1b9 Fix transform-arrow-functions in { spec: true } shadowing (#6760)
* Fix transform-arrow-functions in { spec: true } shadowing

The function name matching the variable declaration name could
shadow the actual function object inside the generated function,
leading to invalid behavior due to holding a reference to the
original unbound function.

* Combine it with transform-function-name just to be sure in spec: false

* Revert "Fix transform-arrow-functions in { spec: true } shadowing"

This reverts commit 1cafe2561d0b0ddd181b956a85eb074621da12e8.

* Much simpler version of the above fix

* Missing fixture updates

* Avoid using rest/spread to make the tests pass on node 4

* ...actually update _all_ the fixtures
2017-11-08 17:21:30 -05:00
..
2017-11-03 16:03:01 -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/transform-function-name"]
}

Via CLI

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

Via Node API

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