1
0
Fork 0
management/front/dkha-web-sz-main/node_modules/@babel/plugin-transform-function-name/lib/index.js

36 lines
1.2 KiB
JavaScript
Raw Normal View History

2023-12-18 13:12:25 +08:00
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
2024-01-16 21:26:16 +08:00
var _helperCompilationTargets = require("@babel/helper-compilation-targets");
var _helperPluginUtils = require("@babel/helper-plugin-utils");
var _helperFunctionName = require("@babel/helper-function-name");
var _default = exports.default = (0, _helperPluginUtils.declare)(api => {
2023-12-18 13:12:25 +08:00
api.assertVersion(7);
2024-01-16 21:26:16 +08:00
const supportUnicodeId = !(0, _helperCompilationTargets.isRequired)("transform-unicode-escapes", api.targets());
2023-12-18 13:12:25 +08:00
return {
name: "transform-function-name",
visitor: {
FunctionExpression: {
exit(path) {
if (path.key !== "value" && !path.parentPath.isObjectProperty()) {
2024-01-16 21:26:16 +08:00
const replacement = (0, _helperFunctionName.default)(path);
2023-12-18 13:12:25 +08:00
if (replacement) path.replaceWith(replacement);
}
}
},
ObjectProperty(path) {
const value = path.get("value");
if (value.isFunction()) {
2024-01-16 21:26:16 +08:00
const newNode = (0, _helperFunctionName.default)(value, false, supportUnicodeId);
2023-12-18 13:12:25 +08:00
if (newNode) value.replaceWith(newNode);
}
}
}
};
});
2024-01-16 21:26:16 +08:00
//# sourceMappingURL=index.js.map