source: trip-planner-front/node_modules/@babel/plugin-proposal-export-namespace-from/lib/index.js@ eed0bf8

Last change on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.7 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7
8var _helperPluginUtils = require("@babel/helper-plugin-utils");
9
10var _pluginSyntaxExportNamespaceFrom = require("@babel/plugin-syntax-export-namespace-from");
11
12var _core = require("@babel/core");
13
14var _default = (0, _helperPluginUtils.declare)(api => {
15 api.assertVersion(7);
16 return {
17 name: "proposal-export-namespace-from",
18 inherits: _pluginSyntaxExportNamespaceFrom.default,
19 visitor: {
20 ExportNamedDeclaration(path) {
21 var _exported$name;
22
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 = exported.name) != null ? _exported$name : exported.value);
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
57exports.default = _default;
Note: See TracBrowser for help on using the repository browser.