You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
3.8 KiB
1 line
3.8 KiB
4 weeks ago
|
{"version":3,"names":["_helperPluginUtils","require","_core","_default","exports","default","declare","api","assertVersion","name","manipulateOptions","_","parser","plugins","push","visitor","ExportNamedDeclaration","path","_exported$name","node","scope","specifiers","index","t","isExportDefaultSpecifier","isExportNamespaceSpecifier","nodes","exportNamedDeclaration","shift","source","specifier","exported","uid","generateUidIdentifier","value","importDeclaration","importNamespaceSpecifier","cloneNode","exportSpecifier","length","replaceWithMultiple","registerDeclaration"],"sources":["../src/index.ts"],"sourcesContent":["import { declare } from \"@babel/helper-plugin-utils\";\nimport { types as t } from \"@babel/core\";\n\nexport default declare(api => {\n api.assertVersion(REQUIRED_VERSION(7));\n\n return {\n name: \"transform-export-namespace-from\",\n manipulateOptions: process.env.BABEL_8_BREAKING\n ? undefined\n : (_, parser) => parser.plugins.push(\"exportNamespaceFrom\"),\n\n visitor: {\n ExportNamedDeclaration(path) {\n const { node, scope } = path;\n const { specifiers } = node;\n\n const index = t.isExportDefaultSpecifier(specifiers[0]) ? 1 : 0;\n if (!t.isExportNamespaceSpecifier(specifiers[index])) return;\n\n const nodes = [];\n\n if (index === 1) {\n nodes.push(\n t.exportNamedDeclaration(null, [specifiers.shift()], node.source),\n );\n }\n\n const specifier = specifiers.shift();\n const { exported } = specifier;\n const uid = scope.generateUidIdentifier(\n // @ts-expect-error Identifier ?? StringLiteral\n exported.name ?? exported.value,\n );\n\n nodes.push(\n t.importDeclaration(\n [t.importNamespaceSpecifier(uid)],\n t.cloneNode(node.source),\n ),\n t.exportNamedDeclaration(null, [\n t.exportSpecifier(t.cloneNode(uid), exported),\n ]),\n );\n\n if (node.specifiers.length >= 1) {\n nodes.push(node);\n }\n\n const [importDeclaration] = path.replaceWithMultiple(nodes);\n path.scope.registerDeclaration(importDeclaration);\n },\n },\n };\n});\n"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,O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