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

44 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 _helperPluginUtils = require("@babel/helper-plugin-utils");
var _core = require("@babel/core");
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
function transformStatementList(paths) {
2023-12-18 13:12:25 +08:00
for (const path of paths) {
if (!path.isFunctionDeclaration()) continue;
2024-01-16 21:26:16 +08:00
const func = path.node;
const declar = _core.types.variableDeclaration("let", [_core.types.variableDeclarator(func.id, _core.types.toExpression(func))]);
2023-12-18 13:12:25 +08:00
declar._blockHoist = 2;
func.id = null;
path.replaceWith(declar);
}
}
return {
name: "transform-block-scoped-functions",
visitor: {
BlockStatement(path) {
const {
node,
parent
} = path;
2024-01-16 21:26:16 +08:00
if (_core.types.isFunction(parent, {
2023-12-18 13:12:25 +08:00
body: node
2024-01-16 21:26:16 +08:00
}) || _core.types.isExportDeclaration(parent)) {
2023-12-18 13:12:25 +08:00
return;
}
2024-01-16 21:26:16 +08:00
transformStatementList(path.get("body"));
2023-12-18 13:12:25 +08:00
},
SwitchCase(path) {
2024-01-16 21:26:16 +08:00
transformStatementList(path.get("consequent"));
2023-12-18 13:12:25 +08:00
}
}
};
});
2024-01-16 21:26:16 +08:00
//# sourceMappingURL=index.js.map