@christiango/unbarrel 0.10.4 → 0.11.0
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/lib/fixIssuesInBarrelFile.d.ts +4 -1
- package/lib/fixIssuesInBarrelFile.d.ts.map +1 -1
- package/lib/fixIssuesInBarrelFile.js +110 -178
- package/lib/fixIssuesInBarrelFile.js.map +1 -1
- package/lib/flattenExportStar.d.ts +1 -2
- package/lib/flattenExportStar.d.ts.map +1 -1
- package/lib/flattenExportStar.js +4 -6
- package/lib/flattenExportStar.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Fixes any issues in the
|
|
2
|
+
* Fixes any issues in the specified barrel file.
|
|
3
|
+
* This includes flattening `export *` statements into explicit named exports
|
|
4
|
+
* and resolving exports that reference other barrel files to point directly
|
|
5
|
+
* to their true source modules. The file is modified in place.
|
|
3
6
|
* @param absoluteFilePath - the absolute path of the barrel file to fix
|
|
4
7
|
*/
|
|
5
8
|
export declare function fixIssuesInBarrelFile(absoluteFilePath: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixIssuesInBarrelFile.d.ts","sourceRoot":"","sources":["../src/fixIssuesInBarrelFile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fixIssuesInBarrelFile.d.ts","sourceRoot":"","sources":["../src/fixIssuesInBarrelFile.ts"],"names":[],"mappings":"AAqFA;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,gBAAgB,EAAE,MAAM,QAsG7D"}
|
|
@@ -46,204 +46,136 @@ const getExportDefinitionFromReExport_1 = require("./getExportDefinitionFromReEx
|
|
|
46
46
|
const parseUtils_1 = require("./parseUtils");
|
|
47
47
|
const getIssuesInBarrelFile_1 = require("./getIssuesInBarrelFile");
|
|
48
48
|
const importUtils_1 = require("./importUtils");
|
|
49
|
-
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if (!barrelRefNames.has(exportedName)) {
|
|
101
|
-
unchangedSpecifiers.push(specifier);
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
// Resolve this export to its true source
|
|
105
|
-
const resolved = (0, getExportDefinitionFromReExport_1.getExportDefinitionFromReExport)(absoluteFilePath, {
|
|
106
|
-
type: importedName === 'default' ? 'defaultExport' : 'namedExport',
|
|
107
|
-
importedName,
|
|
108
|
-
exportedName,
|
|
109
|
-
importPath: sourcePath,
|
|
110
|
-
typeOnly,
|
|
111
|
-
});
|
|
112
|
-
const newSpecifier = t.exportSpecifier(t.identifier(resolved.importedName), t.identifier(resolved.exportedName));
|
|
113
|
-
if (resolved.typeOnly || typeOnly) {
|
|
114
|
-
newSpecifier.exportKind = 'type';
|
|
49
|
+
/** After all the processing has been done */
|
|
50
|
+
function cleanupExportsInAST(ast) {
|
|
51
|
+
// Map to the first export statement with a given path
|
|
52
|
+
const pathToExportMap = new Map();
|
|
53
|
+
(0, traverse_1.default)(ast, {
|
|
54
|
+
ExportNamedDeclaration(path) {
|
|
55
|
+
if (path.node.source) {
|
|
56
|
+
if (path.node.specifiers.length === 0) {
|
|
57
|
+
// If there are no specifiers left, remove the export statement
|
|
58
|
+
path.remove();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const existingExportForPath = pathToExportMap.get(path.node.source.value);
|
|
62
|
+
if (existingExportForPath) {
|
|
63
|
+
// If we have seen the same path already, merge the specifiers and remove the current one
|
|
64
|
+
const specifiersSet = new Map();
|
|
65
|
+
for (const specifier of existingExportForPath.node.specifiers) {
|
|
66
|
+
if (specifier.type === 'ExportSpecifier' && specifier.exported.type === 'Identifier') {
|
|
67
|
+
specifiersSet.set(specifier.exported.name, specifier);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// If the existing export statement is an export type {} statement, let's switch it to export { type foo } style statements for better merging
|
|
71
|
+
if (existingExportForPath.node.exportKind === 'type') {
|
|
72
|
+
existingExportForPath.node.exportKind = 'value';
|
|
73
|
+
for (const specifier of existingExportForPath.node.specifiers) {
|
|
74
|
+
if (specifier.type === 'ExportSpecifier') {
|
|
75
|
+
specifier.exportKind = 'type';
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
for (const specifier of path.node.specifiers) {
|
|
80
|
+
if (specifier.type === 'ExportSpecifier' && specifier.exported.type === 'Identifier') {
|
|
81
|
+
const exportedName = specifier.exported.name;
|
|
82
|
+
const existingSpecifier = specifiersSet.get(exportedName);
|
|
83
|
+
if (!existingSpecifier) {
|
|
84
|
+
specifiersSet.set(exportedName, specifier);
|
|
85
|
+
existingExportForPath.node.specifiers.push(specifier);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
// If we've seen the specifier already, we need to make sure that if it was a type only export and this one is a value export we upgrade to a value export
|
|
89
|
+
if (existingSpecifier.exportKind === 'type' && specifier.exportKind !== 'type') {
|
|
90
|
+
existingSpecifier.exportKind = 'value';
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
path.remove();
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
pathToExportMap.set(path.node.source.value, path);
|
|
99
|
+
}
|
|
115
100
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
resolvedByPath.set(resolved.importPath, list);
|
|
119
|
-
}
|
|
120
|
-
// Build replacement statements
|
|
121
|
-
const newStatements = [];
|
|
122
|
-
if (unchangedSpecifiers.length > 0) {
|
|
123
|
-
newStatements.push(t.exportNamedDeclaration(null, unchangedSpecifiers, t.stringLiteral(sourcePath)));
|
|
124
|
-
}
|
|
125
|
-
for (const [importPath, specifiers] of resolvedByPath) {
|
|
126
|
-
newStatements.push(t.exportNamedDeclaration(null, specifiers, t.stringLiteral(importPath)));
|
|
127
|
-
}
|
|
128
|
-
if (newStatements.length > 0) {
|
|
129
|
-
nodePath.replaceWithMultiple(newStatements);
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
nodePath.remove();
|
|
133
|
-
}
|
|
134
|
-
}
|
|
101
|
+
},
|
|
102
|
+
});
|
|
135
103
|
}
|
|
136
104
|
/**
|
|
137
|
-
* Fixes any issues in the
|
|
105
|
+
* Fixes any issues in the specified barrel file.
|
|
106
|
+
* This includes flattening `export *` statements into explicit named exports
|
|
107
|
+
* and resolving exports that reference other barrel files to point directly
|
|
108
|
+
* to their true source modules. The file is modified in place.
|
|
138
109
|
* @param absoluteFilePath - the absolute path of the barrel file to fix
|
|
139
110
|
*/
|
|
140
111
|
function fixIssuesInBarrelFile(absoluteFilePath) {
|
|
141
112
|
const ast = (0, parseUtils_1.parseTypescriptFile)(absoluteFilePath);
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const existingStatementsByPath = new Map();
|
|
145
|
-
const exportStarPaths = [];
|
|
146
|
-
const allFlattenedExports = [];
|
|
147
|
-
const barrelRefExportsToFix = [];
|
|
148
|
-
const barrelFileRefs = new Set();
|
|
113
|
+
const exportStatements = [];
|
|
114
|
+
let astModified = false;
|
|
149
115
|
(0, traverse_1.default)(ast, {
|
|
150
116
|
ExportNamedDeclaration(path) {
|
|
151
117
|
if (!path.node.source)
|
|
152
118
|
return;
|
|
153
119
|
const sourcePath = path.node.source.value;
|
|
154
|
-
|
|
155
|
-
path,
|
|
156
|
-
sourcePath,
|
|
157
|
-
};
|
|
158
|
-
existingStatementsByPath.set(namedExport.sourcePath, namedExport);
|
|
159
|
-
let hasBarrelRef = false;
|
|
160
|
-
path.node.specifiers.forEach((specifier, i) => {
|
|
161
|
-
if (specifier.type === 'ExportSpecifier' && specifier.exported.type === 'Identifier') {
|
|
162
|
-
const exportedName = specifier.exported.name;
|
|
163
|
-
const importedName = specifier.local.name;
|
|
164
|
-
existingExportsByName.set(exportedName, {
|
|
165
|
-
namedExport,
|
|
166
|
-
specifierIndex: i,
|
|
167
|
-
typeOnly: specifier.exportKind === 'type' || path.node.exportKind === 'type',
|
|
168
|
-
});
|
|
169
|
-
// Check if this specifier is a barrel file reference
|
|
170
|
-
if ((0, importUtils_1.isInternalModule)(sourcePath) && (0, getIssuesInBarrelFile_1.isBarrelFileReference)(absoluteFilePath, sourcePath, importedName)) {
|
|
171
|
-
barrelFileRefs.add(exportedName);
|
|
172
|
-
hasBarrelRef = true;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
if (hasBarrelRef) {
|
|
177
|
-
barrelRefExportsToFix.push(path);
|
|
178
|
-
}
|
|
120
|
+
exportStatements.push({ type: 'exportNamedDeclaration', sourcePath, nodePath: path });
|
|
179
121
|
},
|
|
180
122
|
ExportAllDeclaration(path) {
|
|
181
|
-
|
|
182
|
-
const flattened = (0, flattenExportStar_1.flattenExportStar)(absoluteFilePath, path.node.source.value, isExportTypeStar);
|
|
183
|
-
exportStarPaths.push(path);
|
|
184
|
-
allFlattenedExports.push(...flattened);
|
|
123
|
+
exportStatements.push({ type: 'exportStar', sourcePath: path.node.source.value, nodePath: path });
|
|
185
124
|
},
|
|
186
125
|
});
|
|
187
|
-
//
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
if (!existing)
|
|
204
|
-
return true;
|
|
205
|
-
// Upgrade type-only to value export
|
|
206
|
-
if (existing.typeOnly && !exp.typeOnly) {
|
|
207
|
-
toRemove.push(existing);
|
|
208
|
-
return true;
|
|
209
|
-
}
|
|
210
|
-
return false;
|
|
211
|
-
});
|
|
212
|
-
// Remove specifiers being upgraded from type to value
|
|
213
|
-
for (const { namedExport, specifierIndex } of toRemove) {
|
|
214
|
-
const specifiers = namedExport.path.node.specifiers;
|
|
215
|
-
if (specifiers.length === 1) {
|
|
216
|
-
namedExport.path.remove();
|
|
217
|
-
existingStatementsByPath.delete(namedExport.sourcePath);
|
|
218
|
-
}
|
|
219
|
-
else {
|
|
220
|
-
specifiers.splice(specifierIndex, 1);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
// Group filtered exports and create/update statements
|
|
224
|
-
const grouped = groupExportsByPath(filteredExports);
|
|
225
|
-
const newStatements = [];
|
|
226
|
-
for (const [importPath, exps] of grouped) {
|
|
227
|
-
const existing = existingStatementsByPath.get(importPath);
|
|
228
|
-
if (existing) {
|
|
229
|
-
existing.path.node.specifiers.push(...exps.map(createExportSpecifier));
|
|
126
|
+
// Now go through all export statements and perform the flattening of export star and resolving of re-exports
|
|
127
|
+
for (const exportStatement of exportStatements) {
|
|
128
|
+
if (exportStatement.type === 'exportStar') {
|
|
129
|
+
const flattened = (0, flattenExportStar_1.flattenExportStar)(absoluteFilePath, exportStatement.nodePath.node.source.value);
|
|
130
|
+
const exportNamedDeclarations = [];
|
|
131
|
+
const isTypeOnlyExportStar = exportStatement.nodePath.node.exportKind === 'type';
|
|
132
|
+
for (const resolvedModuleDefinition of flattened) {
|
|
133
|
+
const specifier = t.exportSpecifier(t.identifier(resolvedModuleDefinition.importedName), t.identifier(resolvedModuleDefinition.exportedName));
|
|
134
|
+
// For export type star statements, make all the generated specifiers type only
|
|
135
|
+
if (resolvedModuleDefinition.typeOnly || isTypeOnlyExportStar) {
|
|
136
|
+
specifier.exportKind = 'type';
|
|
137
|
+
}
|
|
138
|
+
exportNamedDeclarations.push(t.exportNamedDeclaration(null, [specifier], t.stringLiteral(resolvedModuleDefinition.importPath)));
|
|
139
|
+
}
|
|
140
|
+
exportStatement.nodePath.replaceWithMultiple(exportNamedDeclarations);
|
|
141
|
+
astModified = true;
|
|
230
142
|
}
|
|
231
143
|
else {
|
|
232
|
-
|
|
144
|
+
for (const specifier of exportStatement.nodePath.node.specifiers) {
|
|
145
|
+
if (specifier.type === 'ExportSpecifier' && specifier.exported.type === 'Identifier') {
|
|
146
|
+
const exportedName = specifier.exported.name;
|
|
147
|
+
const importedName = specifier.local.name;
|
|
148
|
+
// If this export points to another barrel file, let's replace it with a direct reference to the true source module
|
|
149
|
+
if ((0, importUtils_1.isInternalModule)(exportStatement.sourcePath) &&
|
|
150
|
+
(0, getIssuesInBarrelFile_1.isBarrelFileReference)(absoluteFilePath, exportStatement.sourcePath, importedName)) {
|
|
151
|
+
const typeOnly = specifier.exportKind === 'type' || exportStatement.nodePath.node.exportKind === 'type';
|
|
152
|
+
const resolvedExport = (0, getExportDefinitionFromReExport_1.getExportDefinitionFromReExport)(absoluteFilePath, {
|
|
153
|
+
type: importedName === 'default' ? 'defaultExport' : 'namedExport',
|
|
154
|
+
importedName,
|
|
155
|
+
exportedName,
|
|
156
|
+
importPath: exportStatement.sourcePath,
|
|
157
|
+
typeOnly,
|
|
158
|
+
});
|
|
159
|
+
// Add a new export statement to the true path
|
|
160
|
+
const newSpecifier = t.exportSpecifier(t.identifier(resolvedExport.importedName), t.identifier(resolvedExport.exportedName));
|
|
161
|
+
// Preserve the type-only flag
|
|
162
|
+
if (resolvedExport.typeOnly) {
|
|
163
|
+
newSpecifier.exportKind = 'type';
|
|
164
|
+
}
|
|
165
|
+
exportStatement.nodePath.insertAfter(t.exportNamedDeclaration(null, [newSpecifier], t.stringLiteral(resolvedExport.importPath)));
|
|
166
|
+
// Remove the specifier from the current export statement
|
|
167
|
+
exportStatement.nodePath.node.specifiers = exportStatement.nodePath.node.specifiers.filter((s) => s !== specifier);
|
|
168
|
+
astModified = true;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
233
172
|
}
|
|
234
173
|
}
|
|
235
|
-
//
|
|
236
|
-
if (
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
exportStarPaths[0].remove();
|
|
241
|
-
}
|
|
242
|
-
for (let i = 1; i < exportStarPaths.length; i++) {
|
|
243
|
-
exportStarPaths[i].remove();
|
|
174
|
+
// Write output if any changes were made
|
|
175
|
+
if (astModified) {
|
|
176
|
+
cleanupExportsInAST(ast);
|
|
177
|
+
const output = (0, generator_1.default)(ast, { retainLines: false, comments: true });
|
|
178
|
+
fs.writeFileSync(absoluteFilePath, output.code, 'utf8');
|
|
244
179
|
}
|
|
245
|
-
// Write output
|
|
246
|
-
const output = (0, generator_1.default)(ast, { retainLines: false, comments: true });
|
|
247
|
-
fs.writeFileSync(absoluteFilePath, output.code, 'utf8');
|
|
248
180
|
}
|
|
249
181
|
//# sourceMappingURL=fixIssuesInBarrelFile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixIssuesInBarrelFile.js","sourceRoot":"","sources":["../src/fixIssuesInBarrelFile.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"fixIssuesInBarrelFile.js","sourceRoot":"","sources":["../src/fixIssuesInBarrelFile.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4FA,sDAsGC;AAlMD,4CAA8B;AAE9B,+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EH,8CAA8C;wBAC9C,MAAM,YAAY,GAAG,CAAC,CAAC,eAAe,CACpC,CAAC,CAAC,UAAU,CAAC,cAAc,CAAC,YAAY,CAAC,EACzC,CAAC,CAAC,UAAU,CAAC,cAAc,CAAC,YAAY,CAAC,CAC1C,CAAC;wBAEF,8BAA8B;wBAC9B,IAAI,cAAc,CAAC,QAAQ,EAAE,CAAC;4BAC5B,YAAY,CAAC,UAAU,GAAG,MAAM,CAAC;wBACnC,CAAC;wBAED,eAAe,CAAC,QAAQ,CAAC,WAAW,CAClC,CAAC,CAAC,sBAAsB,CAAC,IAAI,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,aAAa,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAC3F,CAAC;wBAEF,yDAAyD;wBACzD,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,GAAG,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CACxF,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CACvB,CAAC;wBAEF,WAAW,GAAG,IAAI,CAAC;oBACrB,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,wCAAwC;IACxC,IAAI,WAAW,EAAE,CAAC;QAChB,mBAAmB,CAAC,GAAG,CAAC,CAAC;QACzB,MAAM,MAAM,GAAG,IAAA,mBAAQ,EAAC,GAAG,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACrE,EAAE,CAAC,aAAa,CAAC,gBAAgB,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC1D,CAAC;AACH,CAAC"}
|
|
@@ -3,7 +3,6 @@ import { ResolvedModuleDefinition } from './getExportDefinitionFromReExport';
|
|
|
3
3
|
* Takes an export star and gets the list of fully resolved named exports that are currently reachable by the export *
|
|
4
4
|
* @param absolutePathOfBarrelFile - The absolute path of the barrel file with the export * in it
|
|
5
5
|
* @param importPath - The relative path of the module that is being referenced by the export *
|
|
6
|
-
* @param isExportTypeStar - If true, all exports will be marked as type-only (for `export type *` statements)
|
|
7
6
|
*/
|
|
8
|
-
export declare function flattenExportStar(absolutePathOfBarrelFile: string, importPath: string
|
|
7
|
+
export declare function flattenExportStar(absolutePathOfBarrelFile: string, importPath: string): ResolvedModuleDefinition[];
|
|
9
8
|
//# sourceMappingURL=flattenExportStar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flattenExportStar.d.ts","sourceRoot":"","sources":["../src/flattenExportStar.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmC,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAG9G
|
|
1
|
+
{"version":3,"file":"flattenExportStar.d.ts","sourceRoot":"","sources":["../src/flattenExportStar.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmC,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAG9G;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,wBAAwB,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,wBAAwB,EAAE,CAmClH"}
|
package/lib/flattenExportStar.js
CHANGED
|
@@ -9,9 +9,8 @@ const getAllExportDefinitionsReachableFromModule_1 = require("./getAllExportDefi
|
|
|
9
9
|
* Takes an export star and gets the list of fully resolved named exports that are currently reachable by the export *
|
|
10
10
|
* @param absolutePathOfBarrelFile - The absolute path of the barrel file with the export * in it
|
|
11
11
|
* @param importPath - The relative path of the module that is being referenced by the export *
|
|
12
|
-
* @param isExportTypeStar - If true, all exports will be marked as type-only (for `export type *` statements)
|
|
13
12
|
*/
|
|
14
|
-
function flattenExportStar(absolutePathOfBarrelFile, importPath
|
|
13
|
+
function flattenExportStar(absolutePathOfBarrelFile, importPath) {
|
|
15
14
|
const result = [];
|
|
16
15
|
const importAbsolutePath = (0, importUtils_1.getAbsolutePathOfImport)(absolutePathOfBarrelFile, importPath);
|
|
17
16
|
const moduleExports = (0, getExportsFromModule_1.getExportsFromModule)(importAbsolutePath);
|
|
@@ -22,18 +21,17 @@ function flattenExportStar(absolutePathOfBarrelFile, importPath, isExportTypeSta
|
|
|
22
21
|
exportedName: importName,
|
|
23
22
|
importedName: importName,
|
|
24
23
|
importPath,
|
|
25
|
-
|
|
26
|
-
typeOnly: isExportTypeStar || definition.typeOnly,
|
|
24
|
+
typeOnly: definition.typeOnly,
|
|
27
25
|
});
|
|
28
26
|
}
|
|
29
27
|
for (const reExport of moduleExports.reExports) {
|
|
30
28
|
if (reExport.type === 'exportAll') {
|
|
31
29
|
const reachableExports = (0, getAllExportDefinitionsReachableFromModule_1.getAllExportDefinitionsReachableFromModule)((0, importUtils_1.getAbsolutePathOfImport)(absolutePathOfBarrelFile, reExport.importPath), absolutePathOfBarrelFile);
|
|
32
|
-
result.push(...reachableExports.map((exp) => ({ ...exp, typeOnly:
|
|
30
|
+
result.push(...reachableExports.map((exp) => ({ ...exp, typeOnly: exp.typeOnly })));
|
|
33
31
|
}
|
|
34
32
|
else {
|
|
35
33
|
const resolved = (0, getExportDefinitionFromReExport_1.getExportDefinitionFromReExport)((0, importUtils_1.getAbsolutePathOfImport)(absolutePathOfBarrelFile, reExport.importPath), reExport);
|
|
36
|
-
result.push({ ...resolved, typeOnly:
|
|
34
|
+
result.push({ ...resolved, typeOnly: resolved.typeOnly });
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
37
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flattenExportStar.js","sourceRoot":"","sources":["../src/flattenExportStar.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"flattenExportStar.js","sourceRoot":"","sources":["../src/flattenExportStar.ts"],"names":[],"mappings":";;AAUA,8CAmCC;AA7CD,iEAA8D;AAC9D,+CAAwD;AACxD,uFAA8G;AAC9G,6GAA0G;AAE1G;;;;GAIG;AACH,SAAgB,iBAAiB,CAAC,wBAAgC,EAAE,UAAkB;I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