1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = void 0;
|
7 |
|
8 | var _helperPluginUtils = require("@babel/helper-plugin-utils");
|
9 |
|
10 | var _pluginSyntaxExportNamespaceFrom = _interopRequireDefault(require("@babel/plugin-syntax-export-namespace-from"));
|
11 |
|
12 | var _core = require("@babel/core");
|
13 |
|
14 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15 |
|
16 | var _default = (0, _helperPluginUtils.declare)(api => {
|
17 | api.assertVersion(7);
|
18 | return {
|
19 | name: "proposal-export-namespace-from",
|
20 | inherits: _pluginSyntaxExportNamespaceFrom.default,
|
21 | visitor: {
|
22 | ExportNamedDeclaration(path) {
|
23 | const {
|
24 | node,
|
25 | scope
|
26 | } = path;
|
27 | const {
|
28 | specifiers
|
29 | } = node;
|
30 | const index = _core.types.isExportDefaultSpecifier(specifiers[0]) ? 1 : 0;
|
31 | if (!_core.types.isExportNamespaceSpecifier(specifiers[index])) return;
|
32 | const nodes = [];
|
33 |
|
34 | if (index === 1) {
|
35 | nodes.push(_core.types.exportNamedDeclaration(null, [specifiers.shift()], node.source));
|
36 | }
|
37 |
|
38 | const specifier = specifiers.shift();
|
39 | const {
|
40 | exported
|
41 | } = specifier;
|
42 | const uid = scope.generateUidIdentifier(exported.name);
|
43 | nodes.push(_core.types.importDeclaration([_core.types.importNamespaceSpecifier(uid)], _core.types.cloneNode(node.source)), _core.types.exportNamedDeclaration(null, [_core.types.exportSpecifier(_core.types.cloneNode(uid), exported)]));
|
44 |
|
45 | if (node.specifiers.length >= 1) {
|
46 | nodes.push(node);
|
47 | }
|
48 |
|
49 | const [importDeclaration] = path.replaceWithMultiple(nodes);
|
50 | path.scope.registerDeclaration(importDeclaration);
|
51 | }
|
52 |
|
53 | }
|
54 | };
|
55 | });
|
56 |
|
57 | exports.default = _default; |
\ | No newline at end of file |