source: trip-planner-front/node_modules/@babel/generator/lib/generators/modules.js

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

initial commit

  • Property mode set to 100644
File size: 4.9 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.ImportSpecifier = ImportSpecifier;
7exports.ImportDefaultSpecifier = ImportDefaultSpecifier;
8exports.ExportDefaultSpecifier = ExportDefaultSpecifier;
9exports.ExportSpecifier = ExportSpecifier;
10exports.ExportNamespaceSpecifier = ExportNamespaceSpecifier;
11exports.ExportAllDeclaration = ExportAllDeclaration;
12exports.ExportNamedDeclaration = ExportNamedDeclaration;
13exports.ExportDefaultDeclaration = ExportDefaultDeclaration;
14exports.ImportDeclaration = ImportDeclaration;
15exports.ImportAttribute = ImportAttribute;
16exports.ImportNamespaceSpecifier = ImportNamespaceSpecifier;
17
18var t = require("@babel/types");
19
20function ImportSpecifier(node) {
21 if (node.importKind === "type" || node.importKind === "typeof") {
22 this.word(node.importKind);
23 this.space();
24 }
25
26 this.print(node.imported, node);
27
28 if (node.local && node.local.name !== node.imported.name) {
29 this.space();
30 this.word("as");
31 this.space();
32 this.print(node.local, node);
33 }
34}
35
36function ImportDefaultSpecifier(node) {
37 this.print(node.local, node);
38}
39
40function ExportDefaultSpecifier(node) {
41 this.print(node.exported, node);
42}
43
44function ExportSpecifier(node) {
45 this.print(node.local, node);
46
47 if (node.exported && node.local.name !== node.exported.name) {
48 this.space();
49 this.word("as");
50 this.space();
51 this.print(node.exported, node);
52 }
53}
54
55function ExportNamespaceSpecifier(node) {
56 this.token("*");
57 this.space();
58 this.word("as");
59 this.space();
60 this.print(node.exported, node);
61}
62
63function ExportAllDeclaration(node) {
64 this.word("export");
65 this.space();
66
67 if (node.exportKind === "type") {
68 this.word("type");
69 this.space();
70 }
71
72 this.token("*");
73 this.space();
74 this.word("from");
75 this.space();
76 this.print(node.source, node);
77 this.printAssertions(node);
78 this.semicolon();
79}
80
81function ExportNamedDeclaration(node) {
82 if (this.format.decoratorsBeforeExport && t.isClassDeclaration(node.declaration)) {
83 this.printJoin(node.declaration.decorators, node);
84 }
85
86 this.word("export");
87 this.space();
88 ExportDeclaration.apply(this, arguments);
89}
90
91function ExportDefaultDeclaration(node) {
92 if (this.format.decoratorsBeforeExport && t.isClassDeclaration(node.declaration)) {
93 this.printJoin(node.declaration.decorators, node);
94 }
95
96 this.word("export");
97 this.space();
98 this.word("default");
99 this.space();
100 ExportDeclaration.apply(this, arguments);
101}
102
103function ExportDeclaration(node) {
104 if (node.declaration) {
105 const declar = node.declaration;
106 this.print(declar, node);
107 if (!t.isStatement(declar)) this.semicolon();
108 } else {
109 if (node.exportKind === "type") {
110 this.word("type");
111 this.space();
112 }
113
114 const specifiers = node.specifiers.slice(0);
115 let hasSpecial = false;
116
117 for (;;) {
118 const first = specifiers[0];
119
120 if (t.isExportDefaultSpecifier(first) || t.isExportNamespaceSpecifier(first)) {
121 hasSpecial = true;
122 this.print(specifiers.shift(), node);
123
124 if (specifiers.length) {
125 this.token(",");
126 this.space();
127 }
128 } else {
129 break;
130 }
131 }
132
133 if (specifiers.length || !specifiers.length && !hasSpecial) {
134 this.token("{");
135
136 if (specifiers.length) {
137 this.space();
138 this.printList(specifiers, node);
139 this.space();
140 }
141
142 this.token("}");
143 }
144
145 if (node.source) {
146 this.space();
147 this.word("from");
148 this.space();
149 this.print(node.source, node);
150 this.printAssertions(node);
151 }
152
153 this.semicolon();
154 }
155}
156
157function ImportDeclaration(node) {
158 this.word("import");
159 this.space();
160
161 if (node.importKind === "type" || node.importKind === "typeof") {
162 this.word(node.importKind);
163 this.space();
164 }
165
166 const specifiers = node.specifiers.slice(0);
167
168 if (specifiers != null && specifiers.length) {
169 for (;;) {
170 const first = specifiers[0];
171
172 if (t.isImportDefaultSpecifier(first) || t.isImportNamespaceSpecifier(first)) {
173 this.print(specifiers.shift(), node);
174
175 if (specifiers.length) {
176 this.token(",");
177 this.space();
178 }
179 } else {
180 break;
181 }
182 }
183
184 if (specifiers.length) {
185 this.token("{");
186 this.space();
187 this.printList(specifiers, node);
188 this.space();
189 this.token("}");
190 }
191
192 this.space();
193 this.word("from");
194 this.space();
195 }
196
197 this.print(node.source, node);
198 this.printAssertions(node);
199 {
200 var _node$attributes;
201
202 if ((_node$attributes = node.attributes) != null && _node$attributes.length) {
203 this.space();
204 this.word("with");
205 this.space();
206 this.printList(node.attributes, node);
207 }
208 }
209 this.semicolon();
210}
211
212function ImportAttribute(node) {
213 this.print(node.key);
214 this.token(":");
215 this.space();
216 this.print(node.value);
217}
218
219function ImportNamespaceSpecifier(node) {
220 this.token("*");
221 this.space();
222 this.word("as");
223 this.space();
224 this.print(node.local, node);
225}
Note: See TracBrowser for help on using the repository browser.