333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"use strict";
 
exports.__esModule = true;
 
exports.default = function (_ref) {
  var t = _ref.types;
 
  function build(node, nodes, scope) {
    var first = node.specifiers[0];
    if (!t.isExportNamespaceSpecifier(first) && !t.isExportDefaultSpecifier(first)) return;
 
    var specifier = node.specifiers.shift();
    var uid = scope.generateUidIdentifier(specifier.exported.name);
 
    var newSpecifier = void 0;
    if (t.isExportNamespaceSpecifier(specifier)) {
      newSpecifier = t.importNamespaceSpecifier(uid);
    } else {
      newSpecifier = t.importDefaultSpecifier(uid);
    }
 
    nodes.push(t.importDeclaration([newSpecifier], node.source));
    nodes.push(t.exportNamedDeclaration(null, [t.exportSpecifier(uid, specifier.exported)]));
 
    build(node, nodes, scope);
  }
 
  return {
    inherits: require("babel-plugin-syntax-export-extensions"),
 
    visitor: {
      ExportNamedDeclaration: function ExportNamedDeclaration(path) {
        var node = path.node,
            scope = path.scope;
 
        var nodes = [];
        build(node, nodes, scope);
        if (!nodes.length) return;
 
        if (node.specifiers.length >= 1) {
          nodes.push(node);
        }
        path.replaceWithMultiple(nodes);
      }
    }
  };
};
 
module.exports = exports["default"];