web 3d图形渲染器
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.

58 lines
1.8 KiB

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