@wyw-in-js/transform 1.0.6 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/cache.js +160 -12
- package/esm/cache.js.map +1 -1
- package/esm/debug/fileReporter.js.map +1 -1
- package/esm/module.js +59 -5
- package/esm/module.js.map +1 -1
- package/esm/plugins/shaker.js +152 -13
- package/esm/plugins/shaker.js.map +1 -1
- package/esm/shaker.js +51 -23
- package/esm/shaker.js.map +1 -1
- package/esm/transform/BaseEntrypoint.js +3 -1
- package/esm/transform/BaseEntrypoint.js.map +1 -1
- package/esm/transform/Entrypoint.js +68 -20
- package/esm/transform/Entrypoint.js.map +1 -1
- package/esm/transform/EvaluatedEntrypoint.js.map +1 -1
- package/esm/transform/actions/BaseAction.js +2 -1
- package/esm/transform/actions/BaseAction.js.map +1 -1
- package/esm/transform/actions/actionRunner.js +2 -2
- package/esm/transform/actions/actionRunner.js.map +1 -1
- package/esm/transform/barrelManifest.js +291 -0
- package/esm/transform/barrelManifest.js.map +1 -0
- package/esm/transform/generators/getExports.js +5 -0
- package/esm/transform/generators/getExports.js.map +1 -1
- package/esm/transform/generators/processEntrypoint.js +31 -1
- package/esm/transform/generators/processEntrypoint.js.map +1 -1
- package/esm/transform/generators/resolveImports.js +29 -5
- package/esm/transform/generators/resolveImports.js.map +1 -1
- package/esm/transform/generators/rewriteBarrelImports.js +733 -0
- package/esm/transform/generators/rewriteBarrelImports.js.map +1 -0
- package/esm/transform/generators/transform.js +154 -21
- package/esm/transform/generators/transform.js.map +1 -1
- package/esm/transform/types.js.map +1 -1
- package/esm/transform.js +45 -23
- package/esm/transform.js.map +1 -1
- package/esm/utils/collectTemplateDependencies.js +9 -0
- package/esm/utils/collectTemplateDependencies.js.map +1 -1
- package/lib/cache.js +163 -12
- package/lib/cache.js.map +1 -1
- package/lib/debug/fileReporter.js.map +1 -1
- package/lib/module.js +61 -7
- package/lib/module.js.map +1 -1
- package/lib/plugins/shaker.js +152 -13
- package/lib/plugins/shaker.js.map +1 -1
- package/lib/shaker.js +58 -26
- package/lib/shaker.js.map +1 -1
- package/lib/transform/BaseEntrypoint.js +3 -1
- package/lib/transform/BaseEntrypoint.js.map +1 -1
- package/lib/transform/Entrypoint.js +69 -20
- package/lib/transform/Entrypoint.js.map +1 -1
- package/lib/transform/EvaluatedEntrypoint.js.map +1 -1
- package/lib/transform/actions/BaseAction.js +2 -1
- package/lib/transform/actions/BaseAction.js.map +1 -1
- package/lib/transform/actions/actionRunner.js +2 -2
- package/lib/transform/actions/actionRunner.js.map +1 -1
- package/lib/transform/barrelManifest.js +300 -0
- package/lib/transform/barrelManifest.js.map +1 -0
- package/lib/transform/generators/getExports.js +5 -0
- package/lib/transform/generators/getExports.js.map +1 -1
- package/lib/transform/generators/processEntrypoint.js +31 -1
- package/lib/transform/generators/processEntrypoint.js.map +1 -1
- package/lib/transform/generators/resolveImports.js +29 -5
- package/lib/transform/generators/resolveImports.js.map +1 -1
- package/lib/transform/generators/rewriteBarrelImports.js +743 -0
- package/lib/transform/generators/rewriteBarrelImports.js.map +1 -0
- package/lib/transform/generators/transform.js +158 -22
- package/lib/transform/generators/transform.js.map +1 -1
- package/lib/transform/types.js.map +1 -1
- package/lib/transform.js +45 -23
- package/lib/transform.js.map +1 -1
- package/lib/utils/collectTemplateDependencies.js +9 -0
- package/lib/utils/collectTemplateDependencies.js.map +1 -1
- package/package.json +8 -4
- package/types/cache.d.ts +23 -2
- package/types/cache.js +170 -10
- package/types/debug/fileReporter.d.ts +1 -0
- package/types/module.d.ts +3 -0
- package/types/module.js +65 -5
- package/types/plugins/shaker.js +161 -16
- package/types/shaker.d.ts +10 -1
- package/types/shaker.js +56 -28
- package/types/transform/BaseEntrypoint.d.ts +3 -1
- package/types/transform/BaseEntrypoint.js +5 -1
- package/types/transform/Entrypoint.d.ts +10 -1
- package/types/transform/Entrypoint.js +81 -23
- package/types/transform/EvaluatedEntrypoint.d.ts +2 -0
- package/types/transform/actions/BaseAction.d.ts +2 -1
- package/types/transform/actions/BaseAction.js +3 -1
- package/types/transform/actions/actionRunner.js +2 -2
- package/types/transform/barrelManifest.d.ts +42 -0
- package/types/transform/barrelManifest.js +300 -0
- package/types/transform/generators/getExports.js +5 -0
- package/types/transform/generators/processEntrypoint.js +29 -1
- package/types/transform/generators/resolveImports.js +29 -5
- package/types/transform/generators/rewriteBarrelImports.d.ts +15 -0
- package/types/transform/generators/rewriteBarrelImports.js +815 -0
- package/types/transform/generators/transform.js +148 -19
- package/types/transform/types.d.ts +3 -0
- package/types/transform.js +47 -23
- package/types/utils/collectTemplateDependencies.js +9 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
/* eslint-disable no-continue, @typescript-eslint/no-use-before-define */
|
|
2
|
+
import traverse from '@babel/traverse';
|
|
3
|
+
import { getBindingIdentifiers } from '@babel/types';
|
|
4
|
+
const isTypeOnlyImport = statement => {
|
|
5
|
+
if (statement.importKind === 'type') {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
if (statement.specifiers.length === 0) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
return statement.specifiers.every(specifier => specifier.type === 'ImportSpecifier' && specifier.importKind === 'type');
|
|
12
|
+
};
|
|
13
|
+
const isTypeOnlyExport = statement => statement.exportKind === 'type';
|
|
14
|
+
const getModuleExportName = node => node.type === 'Identifier' ? node.name : node.value;
|
|
15
|
+
const isTypeOnlyStatement = statement => {
|
|
16
|
+
switch (statement.type) {
|
|
17
|
+
case 'EmptyStatement':
|
|
18
|
+
case 'TSDeclareFunction':
|
|
19
|
+
case 'TSInterfaceDeclaration':
|
|
20
|
+
case 'TSTypeAliasDeclaration':
|
|
21
|
+
return true;
|
|
22
|
+
default:
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
function collectExportNamedDeclaration(statement, reexports, explicitExports) {
|
|
27
|
+
if (!statement.source) {
|
|
28
|
+
return isTypeOnlyExport(statement);
|
|
29
|
+
}
|
|
30
|
+
if (isTypeOnlyExport(statement)) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
const source = statement.source.value;
|
|
34
|
+
for (const specifier of statement.specifiers) {
|
|
35
|
+
if (specifier.type === 'ExportSpecifier') {
|
|
36
|
+
if (specifier.exportKind === 'type') {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
explicitExports.add(getModuleExportName(specifier.exported));
|
|
40
|
+
reexports.push(getNamedReexport(specifier, source));
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (specifier.type === 'ExportDefaultSpecifier') {
|
|
44
|
+
explicitExports.add(getModuleExportName(specifier.exported));
|
|
45
|
+
reexports.push(getDefaultReexport(specifier, source));
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (specifier.type === 'ExportNamespaceSpecifier') {
|
|
49
|
+
explicitExports.add(getModuleExportName(specifier.exported));
|
|
50
|
+
reexports.push(getNamespaceReexport(specifier, source));
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
return statement.specifiers.length > 0;
|
|
56
|
+
}
|
|
57
|
+
function getNamedReexport(specifier, source) {
|
|
58
|
+
return {
|
|
59
|
+
exported: getModuleExportName(specifier.exported),
|
|
60
|
+
imported: getModuleExportName(specifier.local),
|
|
61
|
+
kind: 'named',
|
|
62
|
+
source
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function getDefaultReexport(specifier, source) {
|
|
66
|
+
return {
|
|
67
|
+
exported: getModuleExportName(specifier.exported),
|
|
68
|
+
imported: 'default',
|
|
69
|
+
kind: 'named',
|
|
70
|
+
source
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function getNamespaceReexport(specifier, source) {
|
|
74
|
+
return {
|
|
75
|
+
exported: getModuleExportName(specifier.exported),
|
|
76
|
+
kind: 'namespace',
|
|
77
|
+
source
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const collectImportBinding = (statement, imports) => {
|
|
81
|
+
if (statement.importKind === 'type') {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
if (statement.specifiers.length === 0) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
let sawValueImport = false;
|
|
88
|
+
for (const specifier of statement.specifiers) {
|
|
89
|
+
if (specifier.type === 'ImportSpecifier' && specifier.importKind === 'type') {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
sawValueImport = true;
|
|
93
|
+
if (specifier.type === 'ImportSpecifier') {
|
|
94
|
+
imports.set(specifier.local.name, {
|
|
95
|
+
imported: getImportSpecifierName(specifier),
|
|
96
|
+
kind: 'named',
|
|
97
|
+
source: statement.source.value
|
|
98
|
+
});
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (specifier.type === 'ImportDefaultSpecifier') {
|
|
102
|
+
imports.set(specifier.local.name, {
|
|
103
|
+
imported: 'default',
|
|
104
|
+
kind: 'named',
|
|
105
|
+
source: statement.source.value
|
|
106
|
+
});
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
imports.set(specifier.local.name, {
|
|
110
|
+
kind: 'namespace',
|
|
111
|
+
source: statement.source.value
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
return sawValueImport || isTypeOnlyImport(statement);
|
|
115
|
+
};
|
|
116
|
+
const getImportSpecifierName = specifier => getModuleExportName(specifier.imported);
|
|
117
|
+
const getLocalDeclarationNames = declaration => {
|
|
118
|
+
if (declaration.type === 'VariableDeclaration' || declaration.type === 'FunctionDeclaration' || declaration.type === 'ClassDeclaration') {
|
|
119
|
+
return Object.keys(getBindingIdentifiers(declaration));
|
|
120
|
+
}
|
|
121
|
+
if (declaration.type === 'TSEnumDeclaration' || declaration.type === 'TSModuleDeclaration') {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
return [];
|
|
125
|
+
};
|
|
126
|
+
const collectLocalExportNamedDeclaration = (statement, importedBindings, passthroughCandidates, explicitExports) => {
|
|
127
|
+
let complete = true;
|
|
128
|
+
if (isTypeOnlyExport(statement)) {
|
|
129
|
+
return {
|
|
130
|
+
complete: true,
|
|
131
|
+
ok: true
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
if (statement.declaration) {
|
|
135
|
+
const names = getLocalDeclarationNames(statement.declaration);
|
|
136
|
+
if (names === null) {
|
|
137
|
+
return {
|
|
138
|
+
complete: false,
|
|
139
|
+
ok: false
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
for (const name of names) {
|
|
143
|
+
explicitExports.add(name);
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
complete: names.length === 0,
|
|
147
|
+
ok: true
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
for (const specifier of statement.specifiers) {
|
|
151
|
+
if (specifier.type !== 'ExportSpecifier') {
|
|
152
|
+
return {
|
|
153
|
+
complete: false,
|
|
154
|
+
ok: false
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
if (specifier.exportKind === 'type') {
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
const exported = getModuleExportName(specifier.exported);
|
|
161
|
+
explicitExports.add(exported);
|
|
162
|
+
if (specifier.local.type !== 'Identifier') {
|
|
163
|
+
complete = false;
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
if (!importedBindings.has(specifier.local.name)) {
|
|
167
|
+
complete = false;
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
if (!passthroughCandidates.has(specifier.local.name)) {
|
|
171
|
+
passthroughCandidates.set(specifier.local.name, []);
|
|
172
|
+
}
|
|
173
|
+
passthroughCandidates.get(specifier.local.name).push(exported);
|
|
174
|
+
}
|
|
175
|
+
return {
|
|
176
|
+
complete: complete && statement.specifiers.length > 0,
|
|
177
|
+
ok: true
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
const collectPassthroughReexports = (ast, importedBindings, passthroughCandidates, reexports) => {
|
|
181
|
+
let complete = true;
|
|
182
|
+
const bindingReferenceCounts = new Map();
|
|
183
|
+
traverse(ast, {
|
|
184
|
+
Program(path) {
|
|
185
|
+
for (const localName of passthroughCandidates.keys()) {
|
|
186
|
+
bindingReferenceCounts.set(localName, path.scope.getBinding(localName)?.referencePaths.length ?? -1);
|
|
187
|
+
}
|
|
188
|
+
path.stop();
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
for (const [localName, exportedNames] of passthroughCandidates) {
|
|
192
|
+
if (bindingReferenceCounts.get(localName) !== exportedNames.length) {
|
|
193
|
+
complete = false;
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
const imported = importedBindings.get(localName);
|
|
197
|
+
for (const exported of exportedNames) {
|
|
198
|
+
if (imported.kind === 'namespace') {
|
|
199
|
+
reexports.push({
|
|
200
|
+
exported,
|
|
201
|
+
kind: 'namespace',
|
|
202
|
+
source: imported.source
|
|
203
|
+
});
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
reexports.push({
|
|
207
|
+
exported,
|
|
208
|
+
imported: imported.imported,
|
|
209
|
+
kind: 'named',
|
|
210
|
+
source: imported.source
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return {
|
|
215
|
+
complete,
|
|
216
|
+
ok: true
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
function analyzeBarrelProgram(ast) {
|
|
220
|
+
const reexports = [];
|
|
221
|
+
const explicitExports = new Set();
|
|
222
|
+
const exportAll = [];
|
|
223
|
+
const importedBindings = new Map();
|
|
224
|
+
const passthroughCandidates = new Map();
|
|
225
|
+
let complete = true;
|
|
226
|
+
for (const statement of ast.program.body) {
|
|
227
|
+
if (statement.type === 'ImportDeclaration') {
|
|
228
|
+
if (!collectImportBinding(statement, importedBindings)) {
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
if (statement.type === 'ExportNamedDeclaration') {
|
|
234
|
+
if (statement.source) {
|
|
235
|
+
if (!collectExportNamedDeclaration(statement, reexports, explicitExports)) {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
const localResult = collectLocalExportNamedDeclaration(statement, importedBindings, passthroughCandidates, explicitExports);
|
|
241
|
+
if (!localResult.ok) {
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
complete = complete && localResult.complete;
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
if (statement.type === 'ExportAllDeclaration') {
|
|
248
|
+
if (statement.exportKind === 'type') {
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
if (!statement.source) {
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
254
|
+
exportAll.push(getExportAllSource(statement));
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
if (statement.type === 'ExportDefaultDeclaration') {
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
if (!isTypeOnlyStatement(statement)) {
|
|
261
|
+
return null;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
const passthroughResult = collectPassthroughReexports(ast, importedBindings, passthroughCandidates, reexports);
|
|
265
|
+
if (!passthroughResult.ok) {
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
complete = complete && passthroughResult.complete;
|
|
269
|
+
if (reexports.length === 0 && exportAll.length === 0) {
|
|
270
|
+
return null;
|
|
271
|
+
}
|
|
272
|
+
return {
|
|
273
|
+
complete,
|
|
274
|
+
explicitExports: [...explicitExports],
|
|
275
|
+
exportAll,
|
|
276
|
+
kind: 'barrel',
|
|
277
|
+
reexports
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
const getExportAllSource = statement => statement.source.value;
|
|
281
|
+
export function analyzeBarrelFile(ast) {
|
|
282
|
+
const result = analyzeBarrelProgram(ast);
|
|
283
|
+
if (!result) {
|
|
284
|
+
return {
|
|
285
|
+
kind: 'ineligible',
|
|
286
|
+
reason: 'impure'
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
return result;
|
|
290
|
+
}
|
|
291
|
+
//# sourceMappingURL=barrelManifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"barrelManifest.js","names":["traverse","getBindingIdentifiers","isTypeOnlyImport","statement","importKind","specifiers","length","every","specifier","type","isTypeOnlyExport","exportKind","getModuleExportName","node","name","value","isTypeOnlyStatement","collectExportNamedDeclaration","reexports","explicitExports","source","add","exported","push","getNamedReexport","getDefaultReexport","getNamespaceReexport","imported","local","kind","collectImportBinding","imports","sawValueImport","set","getImportSpecifierName","getLocalDeclarationNames","declaration","Object","keys","collectLocalExportNamedDeclaration","importedBindings","passthroughCandidates","complete","ok","names","has","get","collectPassthroughReexports","ast","bindingReferenceCounts","Map","Program","path","localName","scope","getBinding","referencePaths","stop","exportedNames","analyzeBarrelProgram","Set","exportAll","program","body","localResult","getExportAllSource","passthroughResult","analyzeBarrelFile","result","reason"],"sources":["../../src/transform/barrelManifest.ts"],"sourcesContent":["/* eslint-disable no-continue, @typescript-eslint/no-use-before-define */\nimport traverse from '@babel/traverse';\nimport { getBindingIdentifiers } from '@babel/types';\nimport type {\n ClassDeclaration,\n Declaration,\n ExportAllDeclaration,\n ExportDefaultSpecifier,\n ExportNamedDeclaration,\n ExportNamespaceSpecifier,\n ExportSpecifier,\n File,\n FunctionDeclaration,\n Identifier,\n ImportDeclaration,\n ImportSpecifier,\n Program,\n StringLiteral,\n VariableDeclaration,\n} from '@babel/types';\n\nexport type BarrelSkipReason =\n | 'custom-evaluator'\n | 'empty'\n | 'ignored'\n | 'impure'\n | 'namespace-barrel'\n | 'unknown-star';\n\nexport type BarrelBlockedReason =\n | 'ambiguous'\n | 'cycle'\n | 'namespace-barrel'\n | 'unknown-star'\n | 'unresolved';\n\nexport type BarrelResolvedBinding =\n | {\n imported: string;\n kind: 'named';\n source: string;\n }\n | {\n kind: 'namespace';\n source: string;\n };\n\nexport type BarrelManifestExport =\n | BarrelResolvedBinding\n | {\n kind: 'blocked';\n reason: BarrelBlockedReason;\n };\n\nexport type BarrelManifest = {\n complete: boolean;\n exports: Record<string, BarrelManifestExport>;\n kind: 'barrel';\n};\n\nexport type BarrelManifestCacheEntry =\n | BarrelManifest\n | {\n kind: 'ineligible';\n reason: BarrelSkipReason;\n };\n\nexport type RawBarrelReexport =\n | {\n exported: string;\n imported: string;\n kind: 'named';\n source: string;\n }\n | {\n exported: string;\n kind: 'namespace';\n source: string;\n };\n\nexport type RawBarrelManifest = {\n complete: boolean;\n explicitExports: string[];\n exportAll: string[];\n kind: 'barrel';\n reexports: RawBarrelReexport[];\n};\n\ntype LocalImportBinding =\n | {\n imported: string;\n kind: 'named';\n source: string;\n }\n | {\n kind: 'namespace';\n source: string;\n };\n\nconst isTypeOnlyImport = (statement: ImportDeclaration): boolean => {\n if (statement.importKind === 'type') {\n return true;\n }\n\n if (statement.specifiers.length === 0) {\n return false;\n }\n\n return statement.specifiers.every(\n (specifier) =>\n specifier.type === 'ImportSpecifier' && specifier.importKind === 'type'\n );\n};\n\nconst isTypeOnlyExport = (statement: ExportNamedDeclaration): boolean =>\n statement.exportKind === 'type';\n\nconst getModuleExportName = (node: Identifier | StringLiteral): string =>\n node.type === 'Identifier' ? node.name : node.value;\n\nconst isTypeOnlyStatement = (statement: Program['body'][number]): boolean => {\n switch (statement.type) {\n case 'EmptyStatement':\n case 'TSDeclareFunction':\n case 'TSInterfaceDeclaration':\n case 'TSTypeAliasDeclaration':\n return true;\n default:\n return false;\n }\n};\n\nfunction collectExportNamedDeclaration(\n statement: ExportNamedDeclaration,\n reexports: RawBarrelReexport[],\n explicitExports: Set<string>\n): boolean {\n if (!statement.source) {\n return isTypeOnlyExport(statement);\n }\n\n if (isTypeOnlyExport(statement)) {\n return true;\n }\n\n const source = statement.source.value;\n for (const specifier of statement.specifiers) {\n if (specifier.type === 'ExportSpecifier') {\n if (specifier.exportKind === 'type') {\n continue;\n }\n\n explicitExports.add(getModuleExportName(specifier.exported));\n reexports.push(getNamedReexport(specifier, source));\n continue;\n }\n\n if (specifier.type === 'ExportDefaultSpecifier') {\n explicitExports.add(getModuleExportName(specifier.exported));\n reexports.push(getDefaultReexport(specifier, source));\n continue;\n }\n\n if (specifier.type === 'ExportNamespaceSpecifier') {\n explicitExports.add(getModuleExportName(specifier.exported));\n reexports.push(getNamespaceReexport(specifier, source));\n continue;\n }\n\n return false;\n }\n\n return statement.specifiers.length > 0;\n}\n\nfunction getNamedReexport(\n specifier: ExportSpecifier,\n source: string\n): RawBarrelReexport {\n return {\n exported: getModuleExportName(specifier.exported),\n imported: getModuleExportName(specifier.local),\n kind: 'named',\n source,\n };\n}\n\nfunction getDefaultReexport(\n specifier: ExportDefaultSpecifier,\n source: string\n): RawBarrelReexport {\n return {\n exported: getModuleExportName(specifier.exported),\n imported: 'default',\n kind: 'named',\n source,\n };\n}\n\nfunction getNamespaceReexport(\n specifier: ExportNamespaceSpecifier,\n source: string\n): RawBarrelReexport {\n return {\n exported: getModuleExportName(specifier.exported),\n kind: 'namespace',\n source,\n };\n}\n\nconst collectImportBinding = (\n statement: ImportDeclaration,\n imports: Map<string, LocalImportBinding>\n): boolean => {\n if (statement.importKind === 'type') {\n return true;\n }\n\n if (statement.specifiers.length === 0) {\n return false;\n }\n\n let sawValueImport = false;\n for (const specifier of statement.specifiers) {\n if (\n specifier.type === 'ImportSpecifier' &&\n specifier.importKind === 'type'\n ) {\n continue;\n }\n\n sawValueImport = true;\n\n if (specifier.type === 'ImportSpecifier') {\n imports.set(specifier.local.name, {\n imported: getImportSpecifierName(specifier),\n kind: 'named',\n source: statement.source.value,\n });\n continue;\n }\n\n if (specifier.type === 'ImportDefaultSpecifier') {\n imports.set(specifier.local.name, {\n imported: 'default',\n kind: 'named',\n source: statement.source.value,\n });\n continue;\n }\n\n imports.set(specifier.local.name, {\n kind: 'namespace',\n source: statement.source.value,\n });\n }\n\n return sawValueImport || isTypeOnlyImport(statement);\n};\n\nconst getImportSpecifierName = (specifier: ImportSpecifier): string =>\n getModuleExportName(specifier.imported);\n\nconst getLocalDeclarationNames = (\n declaration: Declaration\n): string[] | null => {\n if (\n declaration.type === 'VariableDeclaration' ||\n declaration.type === 'FunctionDeclaration' ||\n declaration.type === 'ClassDeclaration'\n ) {\n return Object.keys(\n getBindingIdentifiers(\n declaration as\n | VariableDeclaration\n | FunctionDeclaration\n | ClassDeclaration\n )\n );\n }\n\n if (\n declaration.type === 'TSEnumDeclaration' ||\n declaration.type === 'TSModuleDeclaration'\n ) {\n return null;\n }\n\n return [];\n};\n\nconst collectLocalExportNamedDeclaration = (\n statement: ExportNamedDeclaration,\n importedBindings: Map<string, LocalImportBinding>,\n passthroughCandidates: Map<string, string[]>,\n explicitExports: Set<string>\n): { complete: boolean; ok: boolean } => {\n let complete = true;\n\n if (isTypeOnlyExport(statement)) {\n return {\n complete: true,\n ok: true,\n };\n }\n\n if (statement.declaration) {\n const names = getLocalDeclarationNames(statement.declaration);\n if (names === null) {\n return {\n complete: false,\n ok: false,\n };\n }\n\n for (const name of names) {\n explicitExports.add(name);\n }\n\n return {\n complete: names.length === 0,\n ok: true,\n };\n }\n\n for (const specifier of statement.specifiers) {\n if (specifier.type !== 'ExportSpecifier') {\n return {\n complete: false,\n ok: false,\n };\n }\n\n if (specifier.exportKind === 'type') {\n continue;\n }\n\n const exported = getModuleExportName(specifier.exported);\n explicitExports.add(exported);\n\n if (specifier.local.type !== 'Identifier') {\n complete = false;\n continue;\n }\n\n if (!importedBindings.has(specifier.local.name)) {\n complete = false;\n continue;\n }\n\n if (!passthroughCandidates.has(specifier.local.name)) {\n passthroughCandidates.set(specifier.local.name, []);\n }\n passthroughCandidates.get(specifier.local.name)!.push(exported);\n }\n\n return {\n complete: complete && statement.specifiers.length > 0,\n ok: true,\n };\n};\n\nconst collectPassthroughReexports = (\n ast: File,\n importedBindings: Map<string, LocalImportBinding>,\n passthroughCandidates: Map<string, string[]>,\n reexports: RawBarrelReexport[]\n): { complete: boolean; ok: boolean } => {\n let complete = true;\n const bindingReferenceCounts = new Map<string, number>();\n\n traverse(ast, {\n Program(path) {\n for (const localName of passthroughCandidates.keys()) {\n bindingReferenceCounts.set(\n localName,\n path.scope.getBinding(localName)?.referencePaths.length ?? -1\n );\n }\n path.stop();\n },\n });\n\n for (const [localName, exportedNames] of passthroughCandidates) {\n if (bindingReferenceCounts.get(localName) !== exportedNames.length) {\n complete = false;\n continue;\n }\n\n const imported = importedBindings.get(localName)!;\n for (const exported of exportedNames) {\n if (imported.kind === 'namespace') {\n reexports.push({\n exported,\n kind: 'namespace',\n source: imported.source,\n });\n continue;\n }\n\n reexports.push({\n exported,\n imported: imported.imported,\n kind: 'named',\n source: imported.source,\n });\n }\n }\n\n return {\n complete,\n ok: true,\n };\n};\n\nfunction analyzeBarrelProgram(ast: File): RawBarrelManifest | null {\n const reexports: RawBarrelReexport[] = [];\n const explicitExports = new Set<string>();\n const exportAll: string[] = [];\n const importedBindings = new Map<string, LocalImportBinding>();\n const passthroughCandidates = new Map<string, string[]>();\n let complete = true;\n\n for (const statement of ast.program.body) {\n if (statement.type === 'ImportDeclaration') {\n if (!collectImportBinding(statement, importedBindings)) {\n return null;\n }\n continue;\n }\n\n if (statement.type === 'ExportNamedDeclaration') {\n if (statement.source) {\n if (\n !collectExportNamedDeclaration(statement, reexports, explicitExports)\n ) {\n return null;\n }\n continue;\n }\n\n const localResult = collectLocalExportNamedDeclaration(\n statement,\n importedBindings,\n passthroughCandidates,\n explicitExports\n );\n if (!localResult.ok) {\n return null;\n }\n complete = complete && localResult.complete;\n continue;\n }\n\n if (statement.type === 'ExportAllDeclaration') {\n if (statement.exportKind === 'type') {\n continue;\n }\n\n if (!statement.source) {\n return null;\n }\n\n exportAll.push(getExportAllSource(statement));\n continue;\n }\n\n if (statement.type === 'ExportDefaultDeclaration') {\n return null;\n }\n\n if (!isTypeOnlyStatement(statement)) {\n return null;\n }\n }\n\n const passthroughResult = collectPassthroughReexports(\n ast,\n importedBindings,\n passthroughCandidates,\n reexports\n );\n if (!passthroughResult.ok) {\n return null;\n }\n complete = complete && passthroughResult.complete;\n\n if (reexports.length === 0 && exportAll.length === 0) {\n return null;\n }\n\n return {\n complete,\n explicitExports: [...explicitExports],\n exportAll,\n kind: 'barrel',\n reexports,\n };\n}\n\nconst getExportAllSource = (statement: ExportAllDeclaration): string =>\n statement.source.value;\n\nexport function analyzeBarrelFile(\n ast: File\n): BarrelManifestCacheEntry | RawBarrelManifest {\n const result = analyzeBarrelProgram(ast);\n\n if (!result) {\n return {\n kind: 'ineligible',\n reason: 'impure',\n };\n }\n\n return result;\n}\n"],"mappings":"AAAA;AACA,OAAOA,QAAQ,MAAM,iBAAiB;AACtC,SAASC,qBAAqB,QAAQ,cAAc;AAiGpD,MAAMC,gBAAgB,GAAIC,SAA4B,IAAc;EAClE,IAAIA,SAAS,CAACC,UAAU,KAAK,MAAM,EAAE;IACnC,OAAO,IAAI;EACb;EAEA,IAAID,SAAS,CAACE,UAAU,CAACC,MAAM,KAAK,CAAC,EAAE;IACrC,OAAO,KAAK;EACd;EAEA,OAAOH,SAAS,CAACE,UAAU,CAACE,KAAK,CAC9BC,SAAS,IACRA,SAAS,CAACC,IAAI,KAAK,iBAAiB,IAAID,SAAS,CAACJ,UAAU,KAAK,MACrE,CAAC;AACH,CAAC;AAED,MAAMM,gBAAgB,GAAIP,SAAiC,IACzDA,SAAS,CAACQ,UAAU,KAAK,MAAM;AAEjC,MAAMC,mBAAmB,GAAIC,IAAgC,IAC3DA,IAAI,CAACJ,IAAI,KAAK,YAAY,GAAGI,IAAI,CAACC,IAAI,GAAGD,IAAI,CAACE,KAAK;AAErD,MAAMC,mBAAmB,GAAIb,SAAkC,IAAc;EAC3E,QAAQA,SAAS,CAACM,IAAI;IACpB,KAAK,gBAAgB;IACrB,KAAK,mBAAmB;IACxB,KAAK,wBAAwB;IAC7B,KAA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AY;MAClBwC,MAAM,EAAE;IACV,CAAC;EACH;EAEA,OAAOD,MAAM;AACf","ignoreList":[]}
|
|
@@ -60,11 +60,16 @@ export function* getExports() {
|
|
|
60
60
|
const resolvedImports = yield* this.getNext('resolveImports', entrypoint, {
|
|
61
61
|
imports: new Map(withWildcardReexport.map(i => [i.source, []]))
|
|
62
62
|
});
|
|
63
|
+
const dependencyFilenames = resolvedImports.flatMap(dependency => dependency.resolved ? [dependency.resolved] : []);
|
|
63
64
|
const importedEntrypoints = findExportsInImports(entrypoint, resolvedImports);
|
|
64
65
|
for (const importedEntrypoint of importedEntrypoints) {
|
|
65
66
|
const exports = yield* this.getNext('getExports', importedEntrypoint.entrypoint, undefined);
|
|
66
67
|
result.push(...exports);
|
|
67
68
|
}
|
|
69
|
+
cache.add('exports', entrypoint.name, result);
|
|
70
|
+
cache.setCacheDependencies('exports', entrypoint.name, dependencyFilenames);
|
|
71
|
+
entrypoint.log(`exports: %o`, result);
|
|
72
|
+
return result;
|
|
68
73
|
}
|
|
69
74
|
entrypoint.log(`exports: %o`, result);
|
|
70
75
|
cache.add('exports', entrypoint.name, result);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getExports.js","names":["collectExportsAndImports","findExportsInImports","entrypoint","imports","results","imp","resolved","Error","source","newEntrypoint","createChild","push","import","getExports","services","cache","loadedAndParsed","ast","undefined","log","name","has","get","withWildcardReexport","result","babel","traverse","Program","path","exports","reexports","Object","keys","forEach","token","e","exported","filter","length","resolvedImports","getNext","Map","map","i","importedEntrypoints","importedEntrypoint","add"],"sources":["../../../src/transform/generators/getExports.ts"],"sourcesContent":["import type { IReexport } from '../../utils/collectExportsAndImports';\nimport { collectExportsAndImports } from '../../utils/collectExportsAndImports';\nimport type { Entrypoint } from '../Entrypoint';\nimport type { IEntrypointDependency } from '../Entrypoint.types';\nimport type { IGetExportsAction, SyncScenarioForAction } from '../types';\n\nexport function findExportsInImports(\n entrypoint: Entrypoint,\n imports: IEntrypointDependency[]\n): { entrypoint: Entrypoint; import: string }[] {\n const results: {\n entrypoint: Entrypoint;\n import: string;\n }[] = [];\n\n for (const imp of imports) {\n const { resolved } = imp;\n if (!resolved) {\n throw new Error(`Could not resolve import ${imp.source}`);\n }\n\n const newEntrypoint = entrypoint.createChild(resolved, []);\n\n if (newEntrypoint === 'loop') {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n results.push({\n entrypoint: newEntrypoint,\n import: imp.source,\n });\n }\n\n return results;\n}\n\nexport function* getExports(\n this: IGetExportsAction\n): SyncScenarioForAction<IGetExportsAction> {\n const {\n entrypoint,\n services: { cache },\n } = this;\n const { loadedAndParsed } = entrypoint;\n if (loadedAndParsed.ast === undefined) {\n return [];\n }\n\n entrypoint.log(`get exports from %s`, entrypoint.name);\n\n if (cache.has('exports', entrypoint.name)) {\n return cache.get('exports', entrypoint.name)!;\n }\n\n let withWildcardReexport: IReexport[] = [];\n const result: string[] = [];\n\n this.services.babel.traverse(loadedAndParsed.ast!, {\n Program(path) {\n const { exports, reexports } = collectExportsAndImports(path, 'disabled');\n Object.keys(exports).forEach((token) => {\n result.push(token);\n });\n\n reexports.forEach((e) => {\n if (e.exported !== '*') {\n result.push(e.exported);\n }\n });\n\n withWildcardReexport = reexports.filter((e) => e.exported === '*');\n },\n });\n\n if (withWildcardReexport.length) {\n const resolvedImports = yield* this.getNext('resolveImports', entrypoint, {\n imports: new Map(withWildcardReexport.map((i) => [i.source, []])),\n });\n\n const importedEntrypoints = findExportsInImports(\n entrypoint,\n resolvedImports\n );\n\n for (const importedEntrypoint of importedEntrypoints) {\n const exports = yield* this.getNext(\n 'getExports',\n importedEntrypoint.entrypoint,\n undefined\n );\n\n result.push(...exports);\n }\n }\n\n entrypoint.log(`exports: %o`, result);\n\n cache.add('exports', entrypoint.name, result);\n\n return result;\n}\n"],"mappings":"AACA,SAASA,wBAAwB,QAAQ,sCAAsC;AAK/E,OAAO,SAASC,oBAAoBA,CAClCC,UAAsB,EACtBC,OAAgC,E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AAC4B,IAAI,EAAE,UAAU,CAAC;MACzEG,MAAM,CAACC,IAAI,CAACH,OAAO,CAAC,CAACI,OAAO,CAAEC,KAAK,IAAK;QACtCV,MAAM,CAACb,IAAI,CAACuB,KAAK,CAAC;MACpB,CAAC,CAAC;MAEFJ,SAAS,CAACG,OAAO,CAAEE,CAAC,IAAK;QACvB,IAAIA,CAAC,CAACC,QAAQ,KAAK,GAAG,EAAE;UACtBZ,MAAM,CAACb,IAAI,CAACwB,CAAC,CAACC,QAAQ,CAAC;QACzB;MACF,CAAC,CAAC;MAEFb,oBAAoB,GAAGO,SAAS,CAACO,MAAM,CAAEF,CAAC,IAAKA,CAAC,CAACC,QAAQ,KAAK,GAAG,CAAC;IACpE;EACF,CAAC,CAAC;EAEF,IAAIb,oBAAoB,CAACe,MAAM,EAAE;IAC/B,MAAMC,eAAe,GAAG,OAAO,IAAI,CAACC,OAAO,CAAC,gBAAgB,EAAEtC,UAAU,EAAE;MACxEC,OAAO,EAAE,IAAIsC,GAAG,CAAClB,oBAAoB,CAACmB,GAAG,CAAEC,CAAC,IAAK,CAACA,CAAC,CAACnC,MAAM,EAAE,EAAE,CAAC,CAAC;IAClE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"getExports.js","names":["collectExportsAndImports","findExportsInImports","entrypoint","imports","results","imp","resolved","Error","source","newEntrypoint","createChild","push","import","getExports","services","cache","loadedAndParsed","ast","undefined","log","name","has","get","withWildcardReexport","result","babel","traverse","Program","path","exports","reexports","Object","keys","forEach","token","e","exported","filter","length","resolvedImports","getNext","Map","map","i","dependencyFilenames","flatMap","dependency","importedEntrypoints","importedEntrypoint","add","setCacheDependencies"],"sources":["../../../src/transform/generators/getExports.ts"],"sourcesContent":["import type { IReexport } from '../../utils/collectExportsAndImports';\nimport { collectExportsAndImports } from '../../utils/collectExportsAndImports';\nimport type { Entrypoint } from '../Entrypoint';\nimport type { IEntrypointDependency } from '../Entrypoint.types';\nimport type { IGetExportsAction, SyncScenarioForAction } from '../types';\n\nexport function findExportsInImports(\n entrypoint: Entrypoint,\n imports: IEntrypointDependency[]\n): { entrypoint: Entrypoint; import: string }[] {\n const results: {\n entrypoint: Entrypoint;\n import: string;\n }[] = [];\n\n for (const imp of imports) {\n const { resolved } = imp;\n if (!resolved) {\n throw new Error(`Could not resolve import ${imp.source}`);\n }\n\n const newEntrypoint = entrypoint.createChild(resolved, []);\n\n if (newEntrypoint === 'loop') {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n results.push({\n entrypoint: newEntrypoint,\n import: imp.source,\n });\n }\n\n return results;\n}\n\nexport function* getExports(\n this: IGetExportsAction\n): SyncScenarioForAction<IGetExportsAction> {\n const {\n entrypoint,\n services: { cache },\n } = this;\n const { loadedAndParsed } = entrypoint;\n if (loadedAndParsed.ast === undefined) {\n return [];\n }\n\n entrypoint.log(`get exports from %s`, entrypoint.name);\n\n if (cache.has('exports', entrypoint.name)) {\n return cache.get('exports', entrypoint.name)!;\n }\n\n let withWildcardReexport: IReexport[] = [];\n const result: string[] = [];\n\n this.services.babel.traverse(loadedAndParsed.ast!, {\n Program(path) {\n const { exports, reexports } = collectExportsAndImports(path, 'disabled');\n Object.keys(exports).forEach((token) => {\n result.push(token);\n });\n\n reexports.forEach((e) => {\n if (e.exported !== '*') {\n result.push(e.exported);\n }\n });\n\n withWildcardReexport = reexports.filter((e) => e.exported === '*');\n },\n });\n\n if (withWildcardReexport.length) {\n const resolvedImports = yield* this.getNext('resolveImports', entrypoint, {\n imports: new Map(withWildcardReexport.map((i) => [i.source, []])),\n });\n const dependencyFilenames = resolvedImports.flatMap((dependency) =>\n dependency.resolved ? [dependency.resolved] : []\n );\n\n const importedEntrypoints = findExportsInImports(\n entrypoint,\n resolvedImports\n );\n\n for (const importedEntrypoint of importedEntrypoints) {\n const exports = yield* this.getNext(\n 'getExports',\n importedEntrypoint.entrypoint,\n undefined\n );\n\n result.push(...exports);\n }\n\n cache.add('exports', entrypoint.name, result);\n cache.setCacheDependencies('exports', entrypoint.name, dependencyFilenames);\n\n entrypoint.log(`exports: %o`, result);\n\n return result;\n }\n\n entrypoint.log(`exports: %o`, result);\n\n cache.add('exports', entrypoint.name, result);\n\n return result;\n}\n"],"mappings":"AACA,SAASA,wBAAwB,QAAQ,sCAAsC;AAK/E,OAAO,SAASC,oBAAoBA,CAClCC,UAAsB,EACtBC,OAAgC,EACc;EAC9C,MAAMC,OAGH,GAAG,EAAE;EAER,KAAK,MAAMC,GAAG,IAAIF,OAAO,EAAE;IACzB,MAAM;MAAEG;IAAS,CAAC,GAAGD,GAAG;IACxB,IAAI,CAACC,QAAQ,EAAE;MACb,MAAM,IAAIC,KAAK,CAAC,4BAA4BF,GAAG,CAACG,MAAM,EAAE,CAAC;IAC3D;IAEA,MAAMC,aAAa,GAAGP,UAAU,CAACQ,WAAW,CAACJ,QAAQ,EAAE,EAAE,CAAC;IAE1D,IAAIG,aAAa,KAAK,MAAM,EAAE;MAC5B;MACA;IACF;IAEAL,OAAO,CAACO,IAAI,CAAC;MACXT,UAAU,EAAEO,aAAa;MACzBG,MAAM,EAAEP,GAAG,CAACG;IACd,CAAC,CAAC;EACJ;EAEA,OAAOJ,OAAO;AAChB;AAEA,OAAO,UAAUS,UAAUA,CAAA,EAEiB;EAC1C,MAAM;IACJX,UAAU;IACVY,QAAQ,EAAE;MAAEC;IAAM;EACpB,CAAC,GAAG,IAAI;EACR,MAAM;IAAEC;EAAgB,CAAC,GAAGd,UAAU;EACtC,IAAIc,eAAe,CAACC,GAAG,KAAKC,SAAS,EAAE;IACrC,OAAO,EAAE;EACX;EAEAhB,UAAU,CAACiB,GAAG,CAAC,qBAAqB,EAAEjB,UAAU,CAACkB,IAAI,CAAC;EAEtD,IAAIL,KAAK,CAACM,GAAG,CAAC,SAAS,EAAEnB,UAAU,CAACkB,IAAI,CAAC,EAAE;IACzC,OAAOL,KAAK,CAACO,GAAG,CAAC,SAAS,EAAEpB,UAAU,CAACkB,IAAI,CAAC;EAC9C;EAEA,IAAIG,oBAAiC,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pD,MAAMlB,OAAO,GAAG,OAAO,IAAI,CAACW,OAAO,CACjC,YAAY,EACZQ,kBAAkB,CAAC9C,UAAU,EAC7BgB,SACF,CAAC;MAEDM,MAAM,CAACb,IAAI,CAAC,GAAGkB,OAAO,CAAC;IACzB;IAEAd,KAAK,CAACkC,GAAG,CAAC,SAAS,EAAE/C,UAAU,CAACkB,IAAI,EAAEI,MAAM,CAAC;IAC7CT,KAAK,CAACmC,oBAAoB,CAAC,SAAS,EAAEhD,UAAU,CAACkB,IAAI,EAAEwB,mBAAmB,CAAC;IAE3E1C,UAAU,CAACiB,GAAG,CAAC,aAAa,EAAEK,MAAM,CAAC;IAErC,OAAOA,MAAM;EACf;EAEAtB,UAAU,CAACiB,GAAG,CAAC,aAAa,EAAEK,MAAM,CAAC;EAErCT,KAAK,CAACkC,GAAG,CAAC,SAAS,EAAE/C,UAAU,CAACkB,IAAI,EAAEI,MAAM,CAAC;EAE7C,OAAOA,MAAM;AACf","ignoreList":[]}
|
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
function _usingCtx2() { var r = "function" == typeof SuppressedError ? SuppressedError : function (r, e) { var n = Error(); return n.name = "SuppressedError", n.error = r, n.suppressed = e, n; }, e = {}, n = []; function using(r, e) { if (null != e) { if (Object(e) !== e) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined."); if (r) var o = e[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")]; if (void 0 === o && (o = e[Symbol.dispose || Symbol.for("Symbol.dispose")], r)) var t = o; if ("function" != typeof o) throw new TypeError("Object is not disposable."); t && (o = function () { try { t.call(e); } catch (r) { return Promise.reject(r); } }), n.push({ v: e, d: o, a: r }); } else r && n.push({ d: e, a: r }); return e; } return { e: e, u: using.bind(null, !1), a: using.bind(null, !0), d: function () { var o, t = this.e, s = 0; function next() { for (; o = n.pop();) try { if (!o.a && 1 === s) return s = 0, n.push(o), Promise.resolve().then(next); if (o.d) { var r = o.d.call(o.v); if (o.a) return s |= 2, Promise.resolve(r).then(next, err); } else s |= 1; } catch (r) { return err(r); } if (1 === s) return t !== e ? Promise.reject(t) : Promise.resolve(); if (t !== e) throw t; } function err(n) { return t = t !== e ? new r(n, t) : n, next(); } return next(); } }; }
|
|
2
|
+
import { shaker } from '../../shaker';
|
|
2
3
|
import { isAborted } from '../actions/AbortError';
|
|
4
|
+
import { analyzeBarrelFile } from '../barrelManifest';
|
|
5
|
+
const shouldSkipExplodeReexports = action => {
|
|
6
|
+
const {
|
|
7
|
+
loadedAndParsed,
|
|
8
|
+
only
|
|
9
|
+
} = action.entrypoint;
|
|
10
|
+
if (only.length === 1 && only[0] === '__wywPreval') {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
if (loadedAndParsed.evaluator !== shaker || !loadedAndParsed.ast) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
const barrelAnalysis = analyzeBarrelFile(loadedAndParsed.ast);
|
|
17
|
+
return barrelAnalysis.kind === 'barrel' && barrelAnalysis.complete;
|
|
18
|
+
};
|
|
19
|
+
|
|
3
20
|
/**
|
|
4
21
|
* The first stage of processing an entrypoint.
|
|
5
22
|
* This stage is responsible for:
|
|
@@ -13,14 +30,25 @@ export function* processEntrypoint() {
|
|
|
13
30
|
log
|
|
14
31
|
} = this.entrypoint;
|
|
15
32
|
log('start processing (only: %o)', only);
|
|
33
|
+
this.entrypoint.beginProcessing();
|
|
16
34
|
try {
|
|
17
35
|
try {
|
|
18
36
|
var _usingCtx = _usingCtx2();
|
|
19
37
|
const abortSignal = _usingCtx.u(this.createAbortSignal());
|
|
20
|
-
|
|
38
|
+
if (shouldSkipExplodeReexports(this)) {
|
|
39
|
+
log('skip explodeReexports for pure barrel');
|
|
40
|
+
} else {
|
|
41
|
+
yield ['explodeReexports', this.entrypoint, undefined, abortSignal];
|
|
42
|
+
}
|
|
21
43
|
const result = yield* this.getNext('transform', this.entrypoint, undefined, abortSignal);
|
|
22
44
|
this.entrypoint.assertNotSuperseded();
|
|
23
45
|
this.entrypoint.setTransformResult(result);
|
|
46
|
+
const supersededWith = this.entrypoint.applyDeferredSupersede();
|
|
47
|
+
if (supersededWith) {
|
|
48
|
+
log('processing finished, deferred only detected; schedule next attempt');
|
|
49
|
+
yield* this.getNext('processEntrypoint', supersededWith, undefined, null);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
24
52
|
log('entrypoint processing finished');
|
|
25
53
|
} catch (_) {
|
|
26
54
|
_usingCtx.e = _;
|
|
@@ -35,6 +63,8 @@ export function* processEntrypoint() {
|
|
|
35
63
|
}
|
|
36
64
|
log(`Unhandled error: %O`, e);
|
|
37
65
|
throw e;
|
|
66
|
+
} finally {
|
|
67
|
+
this.entrypoint.endProcessing();
|
|
38
68
|
}
|
|
39
69
|
}
|
|
40
70
|
//# sourceMappingURL=processEntrypoint.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processEntrypoint.js","names":["isAborted","
|
|
1
|
+
{"version":3,"file":"processEntrypoint.js","names":["shaker","isAborted","analyzeBarrelFile","shouldSkipExplodeReexports","action","loadedAndParsed","only","entrypoint","length","evaluator","ast","barrelAnalysis","kind","complete","processEntrypoint","log","beginProcessing","_usingCtx","_usingCtx2","abortSignal","u","createAbortSignal","undefined","result","getNext","assertNotSuperseded","setTransformResult","supersededWith","applyDeferredSupersede","_","e","d","endProcessing"],"sources":["../../../src/transform/generators/processEntrypoint.ts"],"sourcesContent":["import { shaker } from '../../shaker';\nimport { isAborted } from '../actions/AbortError';\nimport { analyzeBarrelFile } from '../barrelManifest';\nimport type { IProcessEntrypointAction, SyncScenarioForAction } from '../types';\n\nconst shouldSkipExplodeReexports = (\n action: IProcessEntrypointAction\n): boolean => {\n const { loadedAndParsed, only } = action.entrypoint;\n if (only.length === 1 && only[0] === '__wywPreval') {\n return true;\n }\n\n if (loadedAndParsed.evaluator !== shaker || !loadedAndParsed.ast) {\n return false;\n }\n\n const barrelAnalysis = analyzeBarrelFile(loadedAndParsed.ast);\n return barrelAnalysis.kind === 'barrel' && barrelAnalysis.complete;\n};\n\n/**\n * The first stage of processing an entrypoint.\n * This stage is responsible for:\n * - scheduling the explodeReexports action\n * - scheduling the transform action\n * - rescheduling itself if the entrypoint is superseded\n */\nexport function* processEntrypoint(\n this: IProcessEntrypointAction\n): SyncScenarioForAction<IProcessEntrypointAction> {\n const { only, log } = this.entrypoint;\n log('start processing (only: %o)', only);\n\n this.entrypoint.beginProcessing();\n\n try {\n using abortSignal = this.createAbortSignal();\n\n if (shouldSkipExplodeReexports(this)) {\n log('skip explodeReexports for pure barrel');\n } else {\n yield ['explodeReexports', this.entrypoint, undefined, abortSignal];\n }\n const result = yield* this.getNext(\n 'transform',\n this.entrypoint,\n undefined,\n abortSignal\n );\n\n this.entrypoint.assertNotSuperseded();\n\n this.entrypoint.setTransformResult(result);\n\n const supersededWith = this.entrypoint.applyDeferredSupersede();\n if (supersededWith) {\n log('processing finished, deferred only detected; schedule next attempt');\n yield* this.getNext('processEntrypoint', supersededWith, undefined, null);\n return;\n }\n\n log('entrypoint processing finished');\n } catch (e) {\n if (isAborted(e) && this.entrypoint.supersededWith) {\n log('processing aborted, schedule the next attempt');\n yield* this.getNext(\n 'processEntrypoint',\n this.entrypoint.supersededWith,\n undefined,\n null\n );\n\n return;\n }\n\n log(`Unhandled error: %O`, e);\n throw e;\n } finally {\n this.entrypoint.endProcessing();\n }\n}\n"],"mappings":";AAAA,SAASA,MAAM,QAAQ,cAAc;AACrC,SAASC,SAAS,QAAQ,uBAAuB;AACjD,SAASC,iBAAiB,QAAQ,mBAAmB;AAGrD,MAAMC,0BAA0B,GAC9BC,MAAgC,IACpB;EACZ,MAAM;IAAEC,eAAe;IAAEC;EAAK,CAAC,GAAGF,MAAM,CAACG,UAAU;EACnD,IAAID,IAAI,CAACE,MAAM,KAAK,CAAC,IAAIF,IAAI,CAAC,CAAC,CAAC,KAAK,aAAa,EAAE;IAClD,OAAO,IAAI;EACb;EAEA,IAAID,eAAe,CAACI,SAAS,KAAKT,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GAAG,CAAC,gCAAgC,CAAC;IAAC,SAAAc,CAAA;MAAAZ,SAAA,CAAAa,CAAA,GAAAD,CAAA;IAAA;MAAAZ,SAAA,CAAAc,CAAA;IAAA;EACvC,EAAC,OAAOD,CAAC,EAAE;IACV,IAAI7B,SAAS,CAAC6B,CAAC,CAAC,IAAI,IAAI,CAACvB,UAAU,CAACoB,cAAc,EAAE;MAClDZ,GAAG,CAAC,+CAA+C,CAAC;MACpD,OAAO,IAAI,CAACS,OAAO,CACjB,mBAAmB,EACnB,IAAI,CAACjB,UAAU,CAACoB,cAAc,EAC9BL,SAAS,EACT,IACF,CAAC;MAED;IACF;IAEAP,GAAG,CAAC,qBAAqB,EAAEe,CAAC,CAAC;IAC7B,MAAMA,CAAC;EACT,CAAC,SAAS;IACR,IAAI,CAACvB,UAAU,CAACyB,aAAa,CAAC,CAAC;EACjC;AACF","ignoreList":[]}
|
|
@@ -38,11 +38,12 @@ function applyImportOverrides(services, entrypoint, resolvedImports) {
|
|
|
38
38
|
};
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
function emitDependency(emitter, entrypoint, imports) {
|
|
41
|
+
function emitDependency(emitter, entrypoint, imports, phase) {
|
|
42
42
|
emitter.single({
|
|
43
43
|
type: 'dependency',
|
|
44
44
|
file: entrypoint.name,
|
|
45
45
|
only: entrypoint.only,
|
|
46
|
+
phase,
|
|
46
47
|
imports: imports.map(({
|
|
47
48
|
resolved,
|
|
48
49
|
only
|
|
@@ -62,6 +63,9 @@ function filterUnresolved(entrypoint, resolvedImports) {
|
|
|
62
63
|
return true;
|
|
63
64
|
});
|
|
64
65
|
}
|
|
66
|
+
function getPreResolvedImports(preResolved) {
|
|
67
|
+
return new Map((preResolved ?? []).map(dependency => [dependency.source, dependency]));
|
|
68
|
+
}
|
|
65
69
|
|
|
66
70
|
/**
|
|
67
71
|
* Synchronously resolves specified imports with a provided resolver.
|
|
@@ -77,15 +81,25 @@ export function* syncResolveImports(resolve) {
|
|
|
77
81
|
}
|
|
78
82
|
} = this;
|
|
79
83
|
const listOfImports = Array.from(imports?.entries() ?? []);
|
|
84
|
+
const preResolvedImports = getPreResolvedImports(this.data.preResolved);
|
|
80
85
|
const {
|
|
81
86
|
log
|
|
82
87
|
} = entrypoint;
|
|
83
88
|
if (listOfImports.length === 0) {
|
|
84
|
-
emitDependency(eventEmitter, entrypoint, []);
|
|
89
|
+
emitDependency(eventEmitter, entrypoint, [], this.data.phase);
|
|
85
90
|
log('%s has no imports', entrypoint.name);
|
|
86
91
|
return [];
|
|
87
92
|
}
|
|
88
93
|
const resolvedImports = listOfImports.map(([source, only]) => {
|
|
94
|
+
const preResolved = preResolvedImports.get(source);
|
|
95
|
+
if (preResolved) {
|
|
96
|
+
const mergedOnly = mergeOnly(preResolved.only, only);
|
|
97
|
+
log('[sync-resolve] ♻️ %s -> %s (only: %o)', source, preResolved.resolved, mergedOnly);
|
|
98
|
+
return {
|
|
99
|
+
...preResolved,
|
|
100
|
+
only: mergedOnly
|
|
101
|
+
};
|
|
102
|
+
}
|
|
89
103
|
let resolved = null;
|
|
90
104
|
try {
|
|
91
105
|
resolved = resolve(source, entrypoint.name, getStack(entrypoint));
|
|
@@ -101,7 +115,7 @@ export function* syncResolveImports(resolve) {
|
|
|
101
115
|
});
|
|
102
116
|
const overriddenImports = applyImportOverrides(this.services, entrypoint, resolvedImports);
|
|
103
117
|
const filteredImports = filterUnresolved(entrypoint, overriddenImports);
|
|
104
|
-
emitDependency(eventEmitter, entrypoint, filteredImports);
|
|
118
|
+
emitDependency(eventEmitter, entrypoint, filteredImports, this.data.phase);
|
|
105
119
|
return filteredImports;
|
|
106
120
|
}
|
|
107
121
|
|
|
@@ -119,11 +133,12 @@ export async function* asyncResolveImports(resolve) {
|
|
|
119
133
|
}
|
|
120
134
|
} = this;
|
|
121
135
|
const listOfImports = Array.from(imports?.entries() ?? []);
|
|
136
|
+
const preResolvedImports = getPreResolvedImports(this.data.preResolved);
|
|
122
137
|
const {
|
|
123
138
|
log
|
|
124
139
|
} = entrypoint;
|
|
125
140
|
if (listOfImports.length === 0) {
|
|
126
|
-
emitDependency(eventEmitter, entrypoint, []);
|
|
141
|
+
emitDependency(eventEmitter, entrypoint, [], this.data.phase);
|
|
127
142
|
log('%s has no imports', entrypoint.name);
|
|
128
143
|
return [];
|
|
129
144
|
}
|
|
@@ -145,6 +160,15 @@ export async function* asyncResolveImports(resolve) {
|
|
|
145
160
|
};
|
|
146
161
|
};
|
|
147
162
|
const resolvedImports = await Promise.all(listOfImports.map(([source, importsOnly]) => {
|
|
163
|
+
const preResolved = preResolvedImports.get(source);
|
|
164
|
+
if (preResolved) {
|
|
165
|
+
const mergedOnly = mergeOnly(preResolved.only, importsOnly);
|
|
166
|
+
log('[async-resolve] ♻️ %s (%o) in %s -> %s', source, mergedOnly, entrypoint.name, preResolved.resolved);
|
|
167
|
+
return {
|
|
168
|
+
...preResolved,
|
|
169
|
+
only: mergedOnly
|
|
170
|
+
};
|
|
171
|
+
}
|
|
148
172
|
const cached = entrypoint.getDependency(source);
|
|
149
173
|
if (cached) {
|
|
150
174
|
return {
|
|
@@ -181,7 +205,7 @@ export async function* asyncResolveImports(resolve) {
|
|
|
181
205
|
log('resolved %d imports', resolvedImports.length);
|
|
182
206
|
const overriddenImports = applyImportOverrides(this.services, entrypoint, resolvedImports);
|
|
183
207
|
const filteredImports = filterUnresolved(entrypoint, overriddenImports);
|
|
184
|
-
emitDependency(eventEmitter, entrypoint, filteredImports);
|
|
208
|
+
emitDependency(eventEmitter, entrypoint, filteredImports, this.data.phase);
|
|
185
209
|
return filteredImports;
|
|
186
210
|
}
|
|
187
211
|
//# sourceMappingURL=resolveImports.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveImports.js","names":["getFileIdx","getStack","isSuperSet","mergeOnly","applyImportOverrideToOnly","getImportOverride","resolveMockSpecifier","toImportKey","applyImportOverrides","services","entrypoint","resolvedImports","overrides","options","pluginOptions","importOverrides","Object","keys","length","root","importer","name","stack","map","dependency","key","source","resolved","override","nextOnly","only","nextResolved","mock","emitDependency","emitter","imports","single","type","file","from","what","fileIdx","filterUnresolved","filter","i","log","syncResolveImports","resolve","data","eventEmitter","listOfImports","Array","entries","err","overriddenImports","filteredImports","asyncResolveImports","getResolveTask","Promise","all","importsOnly","cached","getDependency","task","newTask","then","res","merged","addResolveTask","resolveTask"],"sources":["../../../src/transform/generators/resolveImports.ts"],"sourcesContent":["/* eslint-disable no-continue,no-await-in-loop,require-yield */\nimport { getFileIdx } from '../../utils/getFileIdx';\nimport type { Entrypoint } from '../Entrypoint';\nimport { getStack, isSuperSet, mergeOnly } from '../Entrypoint.helpers';\nimport type { IEntrypointDependency } from '../Entrypoint.types';\nimport {\n applyImportOverrideToOnly,\n getImportOverride,\n resolveMockSpecifier,\n toImportKey,\n} from '../../utils/importOverrides';\nimport type {\n AsyncScenarioForAction,\n IResolveImportsAction,\n Services,\n SyncScenarioForAction,\n} from '../types';\n\nfunction applyImportOverrides(\n services: Services,\n entrypoint: Entrypoint,\n resolvedImports: IEntrypointDependency[]\n): IEntrypointDependency[] {\n const overrides = services.options.pluginOptions.importOverrides;\n if (!overrides || Object.keys(overrides).length === 0) {\n return resolvedImports;\n }\n\n const { root } = services.options;\n const importer = entrypoint.name;\n const stack = getStack(entrypoint);\n\n return resolvedImports.map((dependency) => {\n const { key } = toImportKey({\n source: dependency.source,\n resolved: dependency.resolved,\n root,\n });\n const override = getImportOverride(overrides, key);\n if (!override) {\n return dependency;\n }\n\n const nextOnly = applyImportOverrideToOnly(dependency.only, override);\n const nextResolved = override.mock\n ? resolveMockSpecifier({\n mock: override.mock,\n importer,\n root,\n stack,\n })\n : dependency.resolved;\n\n return {\n ...dependency,\n only: nextOnly,\n resolved: nextResolved,\n };\n });\n}\n\nfunction emitDependency(\n emitter: Services['eventEmitter'],\n entrypoint: IResolveImportsAction['entrypoint'],\n imports: IEntrypointDependency[]\n) {\n emitter.single({\n type: 'dependency',\n file: entrypoint.name,\n only: entrypoint.only,\n imports: imports.map(({ resolved, only }) => ({\n from: resolved,\n what: only,\n })),\n fileIdx: getFileIdx(entrypoint.name),\n });\n}\n\nfunction filterUnresolved(\n entrypoint: Entrypoint,\n resolvedImports: IEntrypointDependency[]\n): IEntrypointDependency[] {\n return resolvedImports.filter((i): i is IEntrypointDependency => {\n if (i.resolved === null) {\n entrypoint.log(\n `[resolve] ✅ %s in %s is ignored`,\n i.source,\n entrypoint.name\n );\n return false;\n }\n\n return true;\n });\n}\n\n/**\n * Synchronously resolves specified imports with a provided resolver.\n */\nexport function* syncResolveImports(\n this: IResolveImportsAction,\n resolve: (what: string, importer: string, stack: string[]) => string\n): SyncScenarioForAction<IResolveImportsAction> {\n const {\n data: { imports },\n entrypoint,\n services: { eventEmitter },\n } = this;\n const listOfImports = Array.from(imports?.entries() ?? []);\n const { log } = entrypoint;\n\n if (listOfImports.length === 0) {\n emitDependency(eventEmitter, entrypoint, []);\n\n log('%s has no imports', entrypoint.name);\n return [];\n }\n\n const resolvedImports = listOfImports.map(([source, only]) => {\n let resolved: string | null = null;\n try {\n resolved = resolve(source, entrypoint.name, getStack(entrypoint));\n log('[sync-resolve] ✅ %s -> %s (only: %o)', source, resolved, only);\n } catch (err) {\n log('[sync-resolve] ❌ cannot resolve %s: %O', source, err);\n }\n\n return {\n source,\n only,\n resolved,\n };\n });\n\n const overriddenImports = applyImportOverrides(\n this.services,\n entrypoint,\n resolvedImports\n );\n const filteredImports = filterUnresolved(entrypoint, overriddenImports);\n emitDependency(eventEmitter, entrypoint, filteredImports);\n\n return filteredImports;\n}\n\n/**\n * Asynchronously resolves specified imports with a provided resolver.\n */\nexport async function* asyncResolveImports(\n this: IResolveImportsAction,\n resolve: (\n what: string,\n importer: string,\n stack: string[]\n ) => Promise<string | null>\n): AsyncScenarioForAction<IResolveImportsAction> {\n const {\n data: { imports },\n entrypoint,\n services: { eventEmitter },\n } = this;\n const listOfImports = Array.from(imports?.entries() ?? []);\n const { log } = entrypoint;\n\n if (listOfImports.length === 0) {\n emitDependency(eventEmitter, entrypoint, []);\n\n log('%s has no imports', entrypoint.name);\n return [];\n }\n\n log('resolving %d imports', listOfImports.length);\n\n const getResolveTask = async (\n source: string,\n only: string[]\n ): Promise<IEntrypointDependency> => {\n let resolved: string | null = null;\n try {\n resolved = await resolve(source, entrypoint.name, getStack(entrypoint));\n } catch (err) {\n log(\n '[async-resolve] ❌ cannot resolve %s in %s: %O',\n source,\n entrypoint.name,\n err\n );\n }\n\n if (resolved !== null) {\n log(\n '[async-resolve] ✅ %s (%o) in %s -> %s',\n source,\n only,\n entrypoint.name,\n resolved\n );\n }\n\n return {\n source,\n only,\n resolved,\n };\n };\n\n const resolvedImports = await Promise.all<IEntrypointDependency>(\n listOfImports.map(([source, importsOnly]) => {\n const cached = entrypoint.getDependency(source);\n if (cached) {\n return {\n source,\n only: mergeOnly(cached.only, importsOnly),\n resolved: cached.resolved,\n };\n }\n\n const task = entrypoint.getResolveTask(source);\n if (task) {\n // If we have cached task, we need to merge only…\n const newTask = task.then((res) => {\n if (isSuperSet(res.only, importsOnly)) {\n return res;\n }\n\n // Is this branch even possible?\n const merged = mergeOnly(res.only, importsOnly);\n\n log('merging imports %o and %o: %o', importsOnly, res.only, merged);\n\n return { ...res, only: merged };\n });\n\n // … and update the cache\n entrypoint.addResolveTask(source, newTask);\n return newTask;\n }\n\n const resolveTask = getResolveTask(source, importsOnly);\n\n entrypoint.addResolveTask(source, resolveTask);\n\n return resolveTask;\n })\n );\n\n log('resolved %d imports', resolvedImports.length);\n\n const overriddenImports = applyImportOverrides(\n this.services,\n entrypoint,\n resolvedImports\n );\n const filteredImports = filterUnresolved(entrypoint, overriddenImports);\n emitDependency(eventEmitter, entrypoint, filteredImports);\n return filteredImports;\n}\n"],"mappings":"AAAA;AACA,SAASA,UAAU,QAAQ,wBAAwB;AAEnD,SAASC,QAAQ,EAAEC,UAAU,EAAEC,SAAS,QAAQ,uBAAuB;AAEvE,SACEC,yBAAyB,EACzBC,iBAA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AAI,CAAEC,GAAG,IAAK;QACjC,IAAIhE,UAAU,CAACgE,GAAG,CAACpC,IAAI,EAAE8B,WAAW,CAAC,EAAE;UACrC,OAAOM,GAAG;QACZ;;QAEA;QACA,MAAMC,MAAM,GAAGhE,SAAS,CAAC+D,GAAG,CAACpC,IAAI,EAAE8B,WAAW,CAAC;QAE/Cf,GAAG,CAAC,+BAA+B,EAAEe,WAAW,EAAEM,GAAG,CAACpC,IAAI,EAAEqC,MAAM,CAAC;QAEnE,OAAO;UAAE,GAAGD,GAAG;UAAEpC,IAAI,EAAEqC;QAAO,CAAC;MACjC,CAAC,CAAC;;MAEF;MACAzD,UAAU,CAAC0D,cAAc,CAAC1C,MAAM,EAAEsC,OAAO,CAAC;MAC1C,OAAOA,OAAO;IAChB;IAEA,MAAMK,WAAW,GAAGZ,cAAc,CAAC/B,MAAM,EAAEkC,WAAW,CAAC;IAEvDlD,UAAU,CAAC0D,cAAc,CAAC1C,MAAM,EAAE2C,WAAW,CAAC;IAE9C,OAAOA,WAAW;EACpB,CAAC,CACH,CAAC;EAEDxB,GAAG,CAAC,qBAAqB,EAAElC,eAAe,CAACO,MAAM,CAAC;EAElD,MAAMoC,iBAAiB,GAAG9C,oBAAoB,CAC5C,IAAI,CAACC,QAAQ,EACbC,UAAU,EACVC,eACF,CAAC;EACD,MAAM4C,eAAe,GAAGb,gBAAgB,CAAChC,UAAU,EAAE4C,iBAAiB,CAAC;EACvErB,cAAc,CAACgB,YAAY,EAAEvC,UAAU,EAAE6C,eAAe,CAAC;EACzD,OAAOA,eAAe;AACxB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"resolveImports.js","names":["getFileIdx","getStack","isSuperSet","mergeOnly","applyImportOverrideToOnly","getImportOverride","resolveMockSpecifier","toImportKey","applyImportOverrides","services","entrypoint","resolvedImports","overrides","options","pluginOptions","importOverrides","Object","keys","length","root","importer","name","stack","map","dependency","key","source","resolved","override","nextOnly","only","nextResolved","mock","emitDependency","emitter","imports","phase","single","type","file","from","what","fileIdx","filterUnresolved","filter","i","log","getPreResolvedImports","preResolved","Map","syncResolveImports","resolve","data","eventEmitter","listOfImports","Array","entries","preResolvedImports","get","mergedOnly","err","overriddenImports","filteredImports","asyncResolveImports","getResolveTask","Promise","all","importsOnly","cached","getDependency","task","newTask","then","res","merged","addResolveTask","resolveTask"],"sources":["../../../src/transform/generators/resolveImports.ts"],"sourcesContent":["/* eslint-disable no-continue,no-await-in-loop,require-yield */\nimport { getFileIdx } from '../../utils/getFileIdx';\nimport type { Entrypoint } from '../Entrypoint';\nimport { getStack, isSuperSet, mergeOnly } from '../Entrypoint.helpers';\nimport type { IEntrypointDependency } from '../Entrypoint.types';\nimport {\n applyImportOverrideToOnly,\n getImportOverride,\n resolveMockSpecifier,\n toImportKey,\n} from '../../utils/importOverrides';\nimport type {\n AsyncScenarioForAction,\n IResolveImportsAction,\n Services,\n SyncScenarioForAction,\n} from '../types';\n\nfunction applyImportOverrides(\n services: Services,\n entrypoint: Entrypoint,\n resolvedImports: IEntrypointDependency[]\n): IEntrypointDependency[] {\n const overrides = services.options.pluginOptions.importOverrides;\n if (!overrides || Object.keys(overrides).length === 0) {\n return resolvedImports;\n }\n\n const { root } = services.options;\n const importer = entrypoint.name;\n const stack = getStack(entrypoint);\n\n return resolvedImports.map((dependency) => {\n const { key } = toImportKey({\n source: dependency.source,\n resolved: dependency.resolved,\n root,\n });\n const override = getImportOverride(overrides, key);\n if (!override) {\n return dependency;\n }\n\n const nextOnly = applyImportOverrideToOnly(dependency.only, override);\n const nextResolved = override.mock\n ? resolveMockSpecifier({\n mock: override.mock,\n importer,\n root,\n stack,\n })\n : dependency.resolved;\n\n return {\n ...dependency,\n only: nextOnly,\n resolved: nextResolved,\n };\n });\n}\n\nfunction emitDependency(\n emitter: Services['eventEmitter'],\n entrypoint: IResolveImportsAction['entrypoint'],\n imports: IEntrypointDependency[],\n phase?: IResolveImportsAction['data']['phase']\n) {\n emitter.single({\n type: 'dependency',\n file: entrypoint.name,\n only: entrypoint.only,\n phase,\n imports: imports.map(({ resolved, only }) => ({\n from: resolved,\n what: only,\n })),\n fileIdx: getFileIdx(entrypoint.name),\n });\n}\n\nfunction filterUnresolved(\n entrypoint: Entrypoint,\n resolvedImports: IEntrypointDependency[]\n): IEntrypointDependency[] {\n return resolvedImports.filter((i): i is IEntrypointDependency => {\n if (i.resolved === null) {\n entrypoint.log(\n `[resolve] ✅ %s in %s is ignored`,\n i.source,\n entrypoint.name\n );\n return false;\n }\n\n return true;\n });\n}\n\nfunction getPreResolvedImports(\n preResolved: IResolveImportsAction['data']['preResolved']\n): Map<string, IEntrypointDependency> {\n return new Map(\n (preResolved ?? []).map((dependency) => [dependency.source, dependency])\n );\n}\n\n/**\n * Synchronously resolves specified imports with a provided resolver.\n */\nexport function* syncResolveImports(\n this: IResolveImportsAction,\n resolve: (what: string, importer: string, stack: string[]) => string\n): SyncScenarioForAction<IResolveImportsAction> {\n const {\n data: { imports },\n entrypoint,\n services: { eventEmitter },\n } = this;\n const listOfImports = Array.from(imports?.entries() ?? []);\n const preResolvedImports = getPreResolvedImports(this.data.preResolved);\n const { log } = entrypoint;\n\n if (listOfImports.length === 0) {\n emitDependency(eventEmitter, entrypoint, [], this.data.phase);\n\n log('%s has no imports', entrypoint.name);\n return [];\n }\n\n const resolvedImports = listOfImports.map(([source, only]) => {\n const preResolved = preResolvedImports.get(source);\n if (preResolved) {\n const mergedOnly = mergeOnly(preResolved.only, only);\n log(\n '[sync-resolve] ♻️ %s -> %s (only: %o)',\n source,\n preResolved.resolved,\n mergedOnly\n );\n return {\n ...preResolved,\n only: mergedOnly,\n };\n }\n\n let resolved: string | null = null;\n try {\n resolved = resolve(source, entrypoint.name, getStack(entrypoint));\n log('[sync-resolve] ✅ %s -> %s (only: %o)', source, resolved, only);\n } catch (err) {\n log('[sync-resolve] ❌ cannot resolve %s: %O', source, err);\n }\n\n return {\n source,\n only,\n resolved,\n };\n });\n\n const overriddenImports = applyImportOverrides(\n this.services,\n entrypoint,\n resolvedImports\n );\n const filteredImports = filterUnresolved(entrypoint, overriddenImports);\n emitDependency(eventEmitter, entrypoint, filteredImports, this.data.phase);\n\n return filteredImports;\n}\n\n/**\n * Asynchronously resolves specified imports with a provided resolver.\n */\nexport async function* asyncResolveImports(\n this: IResolveImportsAction,\n resolve: (\n what: string,\n importer: string,\n stack: string[]\n ) => Promise<string | null>\n): AsyncScenarioForAction<IResolveImportsAction> {\n const {\n data: { imports },\n entrypoint,\n services: { eventEmitter },\n } = this;\n const listOfImports = Array.from(imports?.entries() ?? []);\n const preResolvedImports = getPreResolvedImports(this.data.preResolved);\n const { log } = entrypoint;\n\n if (listOfImports.length === 0) {\n emitDependency(eventEmitter, entrypoint, [], this.data.phase);\n\n log('%s has no imports', entrypoint.name);\n return [];\n }\n\n log('resolving %d imports', listOfImports.length);\n\n const getResolveTask = async (\n source: string,\n only: string[]\n ): Promise<IEntrypointDependency> => {\n let resolved: string | null = null;\n try {\n resolved = await resolve(source, entrypoint.name, getStack(entrypoint));\n } catch (err) {\n log(\n '[async-resolve] ❌ cannot resolve %s in %s: %O',\n source,\n entrypoint.name,\n err\n );\n }\n\n if (resolved !== null) {\n log(\n '[async-resolve] ✅ %s (%o) in %s -> %s',\n source,\n only,\n entrypoint.name,\n resolved\n );\n }\n\n return {\n source,\n only,\n resolved,\n };\n };\n\n const resolvedImports = await Promise.all<IEntrypointDependency>(\n listOfImports.map(([source, importsOnly]) => {\n const preResolved = preResolvedImports.get(source);\n if (preResolved) {\n const mergedOnly = mergeOnly(preResolved.only, importsOnly);\n log(\n '[async-resolve] ♻️ %s (%o) in %s -> %s',\n source,\n mergedOnly,\n entrypoint.name,\n preResolved.resolved\n );\n return {\n ...preResolved,\n only: mergedOnly,\n };\n }\n\n const cached = entrypoint.getDependency(source);\n if (cached) {\n return {\n source,\n only: mergeOnly(cached.only, importsOnly),\n resolved: cached.resolved,\n };\n }\n\n const task = entrypoint.getResolveTask(source);\n if (task) {\n // If we have cached task, we need to merge only…\n const newTask = task.then((res) => {\n if (isSuperSet(res.only, importsOnly)) {\n return res;\n }\n\n // Is this branch even possible?\n const merged = mergeOnly(res.only, importsOnly);\n\n log('merging imports %o and %o: %o', importsOnly, res.only, merged);\n\n return { ...res, only: merged };\n });\n\n // … and update the cache\n entrypoint.addResolveTask(source, newTask);\n return newTask;\n }\n\n const resolveTask = getResolveTask(source, importsOnly);\n\n entrypoint.addResolveTask(source, resolveTask);\n\n return resolveTask;\n })\n );\n\n log('resolved %d imports', resolvedImports.length);\n\n const overriddenImports = applyImportOverrides(\n this.services,\n entrypoint,\n resolvedImports\n );\n const filteredImports = filterUnresolved(entrypoint, overriddenImports);\n emitDependency(eventEmitter, entrypoint, filteredImports, this.data.phase);\n return filteredImports;\n}\n"],"mappings":"AAAA;AACA,SAASA,UAAU,QAAQ,wBAAwB;AAEnD,SAASC,QAAQ,EAAEC,UAAU,EAAEC,SAAS,QAAQ,uBAAuB;AAEvE,SACEC,yBAAyB,EACzBC,iBAAiB,EACjBC,oBAAoB,EACpBC,WAAW,QACN,6BAA6B;AAQpC,SAASC,oBAAoBA,CAC3BC,QAAkB,EAClBC,UAAsB,EACtBC,eAAwC,EACf;EACzB,MAAMC,SAAS,GAAGH,QAAQ,CAACI,OAAO,CAACC,aAAa,CAACC,eAAe;EAChE,IAAI,CAACH,SAAS,IAAII,MAAM,CAACC,IAAI,CAACL,SAAS,CAAC,CAACM,MAAM,KAAK,CAAC,EAAE;IACrD,OAAOP,eAAe;EACxB;EAEA,MAAM;IAAEQ;EAAK,CAAC,GAAGV,QAAQ,CAACI,OAAO;EACjC,MAAMO,QAAQ,GAAGV,UAAU,CAACW,IAAI;EAChC,MAAMC,KAAK,GAAGrB,QAAQ,CAACS,UAAU,CAAC;EAElC,OAAOC,eAAe,CAACY,GAAG,CAAEC,UAAU,IAAK;IACzC,MAAM;MAAEC;IAAI,CAAC,GAAGlB,WAAW,CAAC;MAC1BmB,MAAM,EAAEF,UAAU,CAACE,MAAM;MACzBC,QAAQ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