| | |
| | | Object.defineProperty(exports, "__esModule", { |
| | | value: true |
| | | }); |
| | | exports.getExportSpecifierName = getExportSpecifierName; |
| | | exports.default = void 0; |
| | | exports.getExportSpecifierName = getExportSpecifierName; |
| | | |
| | | var _helperPluginUtils = require("@babel/helper-plugin-utils"); |
| | | |
| | |
| | | |
| | | var _helperValidatorIdentifier = require("@babel/helper-validator-identifier"); |
| | | |
| | | const buildTemplate = (0, _core.template)(` |
| | | const buildTemplate = _core.template.statement(` |
| | | SYSTEM_REGISTER(MODULE_NAME, SOURCES, function (EXPORT_IDENTIFIER, CONTEXT_IDENTIFIER) { |
| | | "use strict"; |
| | | BEFORE_BODY; |
| | |
| | | }; |
| | | }); |
| | | `); |
| | | const buildExportAll = (0, _core.template)(` |
| | | |
| | | const buildExportAll = _core.template.statement(` |
| | | for (var KEY in TARGET) { |
| | | if (KEY !== "default" && KEY !== "__esModule") EXPORT_OBJ[KEY] = TARGET[KEY]; |
| | | } |
| | | `); |
| | | |
| | | const MISSING_PLUGIN_WARNING = `\ |
| | | WARNING: Dynamic import() transformation must be enabled using the |
| | | @babel/plugin-proposal-dynamic-import plugin. Babel 8 will |
| | |
| | | } else if (path.isClassDeclaration()) { |
| | | variableIds.push(_core.types.cloneNode(path.node.id)); |
| | | path.replaceWith(_core.types.expressionStatement(_core.types.assignmentExpression("=", _core.types.cloneNode(path.node.id), _core.types.toExpression(path.node)))); |
| | | } else if (path.isVariableDeclaration()) { |
| | | path.node.kind = "var"; |
| | | } else if (path.isImportDeclaration()) { |
| | | const source = path.node.source.value; |
| | | pushModule(source, "imports", path.node.specifiers); |
| | |
| | | path.remove(); |
| | | } else if (path.isExportDefaultDeclaration()) { |
| | | const declar = path.get("declaration"); |
| | | const id = declar.node.id; |
| | | |
| | | if (declar.isClassDeclaration()) { |
| | | const id = declar.node.id; |
| | | |
| | | if (id) { |
| | | exportNames.push("default"); |
| | | exportValues.push(scope.buildUndefinedNode()); |
| | |
| | | removedPaths.push(path); |
| | | } |
| | | } else if (declar.isFunctionDeclaration()) { |
| | | const id = declar.node.id; |
| | | |
| | | if (id) { |
| | | beforeBody.push(declar.node); |
| | | exportNames.push("default"); |
| | |
| | | if (declar.node) { |
| | | path.replaceWith(declar); |
| | | |
| | | if (path.isFunction()) { |
| | | if (declar.isFunction()) { |
| | | const node = declar.node; |
| | | const name = node.id.name; |
| | | addExportName(name, name); |
| | |
| | | exportNames.push(name); |
| | | exportValues.push(_core.types.cloneNode(node.id)); |
| | | removedPaths.push(path); |
| | | } else if (path.isClass()) { |
| | | } else if (declar.isClass()) { |
| | | const name = declar.node.id.name; |
| | | exportNames.push(name); |
| | | exportValues.push(scope.buildUndefinedNode()); |
| | |
| | | path.replaceWith(_core.types.expressionStatement(_core.types.assignmentExpression("=", _core.types.cloneNode(declar.node.id), _core.types.toExpression(declar.node)))); |
| | | addExportName(name, name); |
| | | } else { |
| | | if (declar.isVariableDeclaration()) { |
| | | declar.node.kind = "var"; |
| | | } |
| | | |
| | | for (const name of Object.keys(declar.getBindingIdentifiers())) { |
| | | addExportName(name, name); |
| | | } |
| | |
| | | exportValues.push(scope.buildUndefinedNode()); |
| | | } |
| | | } |
| | | }, null); |
| | | }); |
| | | |
| | | if (variableIds.length) { |
| | | beforeBody.unshift(_core.types.variableDeclaration("var", variableIds.map(id => _core.types.variableDeclarator(id)))); |