Add function name to spec-transformed arrow functions (#5620)

While it may appear that this should be done by es2015-function-name,
another way to think about it is that es2015-function-name implements
the naming that javascript engines are supposed to do; and javascript
engines cannot name function expressions that are the object of a
member expression.
This commit is contained in:
Diogo Franco
2017-05-03 11:50:37 +09:00
committed by GitHub
parent 79c1eed8c1
commit 86a53773f1
9 changed files with 58 additions and 13 deletions

View File

@@ -1,5 +1,4 @@
// I don't know if this is a bug with arrow-functions spec: true
// or with function-name, but the functions are missing their names.
// These are actually handled by transform-es2015-arrow-function
const x = () => x;
const y = x => x();
const z = { z: () => y(x) }.z;

View File

@@ -1,16 +1,15 @@
var _this = this;
// I don't know if this is a bug with arrow-functions spec: true
// or with function-name, but the functions are missing their names.
const x = function () {
// These are actually handled by transform-es2015-arrow-function
const x = function x() {
babelHelpers.newArrowCheck(this, _this);
return x;
}.bind(this);
const y = function (x) {
const y = function y(x) {
babelHelpers.newArrowCheck(this, _this);
return x();
}.bind(this);
const z = { z: function z() {
babelHelpers.newArrowCheck(this, _this);
return y(x);
}.bind(this) }.z;
}.bind(this) }.z;