summaryrefslogtreecommitdiff
path: root/node_modules/@babel/helper-wrap-function/lib/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/@babel/helper-wrap-function/lib/index.js')
-rw-r--r--node_modules/@babel/helper-wrap-function/lib/index.js22
1 files changed, 10 insertions, 12 deletions
diff --git a/node_modules/@babel/helper-wrap-function/lib/index.js b/node_modules/@babel/helper-wrap-function/lib/index.js
index 3c7b997a..00faacc6 100644
--- a/node_modules/@babel/helper-wrap-function/lib/index.js
+++ b/node_modules/@babel/helper-wrap-function/lib/index.js
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = wrapFunction;
-var _helperFunctionName = require("@babel/helper-function-name");
var _template = require("@babel/template");
var _t = require("@babel/types");
const {
@@ -50,7 +49,7 @@ function classOrObjectMethod(path, callId) {
node.generator = false;
path.get("body.body.0.argument.callee.arguments.0").unwrapFunctionEnvironment();
}
-function plainFunction(inPath, callId, noNewArrows, ignoreFunctionLength) {
+function plainFunction(inPath, callId, noNewArrows, ignoreFunctionLength, hadName) {
let path = inPath;
let node;
let functionId = null;
@@ -83,7 +82,7 @@ function plainFunction(inPath, callId, noNewArrows, ignoreFunctionLength) {
}
const wrapperArgs = {
NAME: functionId || null,
- REF: path.scope.generateUidIdentifier(functionId ? functionId.name : "ref"),
+ REF: path.scope.generateUidIdentifier(hadName ? functionId.name : "ref"),
FUNCTION: built,
PARAMS: params
};
@@ -93,17 +92,10 @@ function plainFunction(inPath, callId, noNewArrows, ignoreFunctionLength) {
path.insertAfter(container[1]);
} else {
let container;
- if (functionId) {
+ if (hadName) {
container = buildNamedExpressionWrapper(wrapperArgs);
} else {
container = buildAnonymousExpressionWrapper(wrapperArgs);
- const returnFn = container.callee.body.body[1].argument;
- (0, _helperFunctionName.default)({
- node: returnFn,
- parent: path.parent,
- scope: path.scope
- });
- functionId = returnFn.id;
}
if (functionId || !ignoreFunctionLength && params.length) {
path.replaceWith(container);
@@ -116,7 +108,13 @@ function wrapFunction(path, callId, noNewArrows = true, ignoreFunctionLength = f
if (path.isMethod()) {
classOrObjectMethod(path, callId);
} else {
- plainFunction(path, callId, noNewArrows, ignoreFunctionLength);
+ const hadName = "id" in path.node && !!path.node.id;
+ {
+ var _path, _path$ensureFunctionN;
+ (_path$ensureFunctionN = (_path = path).ensureFunctionName) != null ? _path$ensureFunctionN : _path.ensureFunctionName = require("@babel/traverse").NodePath.prototype.ensureFunctionName;
+ }
+ path = path.ensureFunctionName(false);
+ plainFunction(path, callId, noNewArrows, ignoreFunctionLength, hadName);
}
}