This repository was archived by the owner on Feb 6, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -163,6 +163,11 @@ export class TypeScriptFileProcessor implements FileProcessor {
163
163
}
164
164
}
165
165
166
+ const includes = await this . includesFromNearestTsconfigFile ( file ) ;
167
+ for ( const include of includes ) {
168
+ importedFiles . add ( include ) ;
169
+ }
170
+
166
171
return Promise . resolve ( importedFiles ) ;
167
172
}
168
173
@@ -189,6 +194,33 @@ export class TypeScriptFileProcessor implements FileProcessor {
189
194
} ,
190
195
) ;
191
196
197
+ private async includesFromNearestTsconfigFile ( file : Path ) : Promise < string [ ] > {
198
+ const tsconfigPath = ts . findConfigFile (
199
+ path . dirname ( file ) ,
200
+ ts . sys . fileExists ,
201
+ ) ;
202
+ if ( ! tsconfigPath || ! tsconfigPath . startsWith ( this . rootDir ) ) {
203
+ return [ ] ;
204
+ }
205
+
206
+ const json = ts . parseJsonText (
207
+ tsconfigPath ,
208
+ await fs . promises . readFile ( tsconfigPath , 'utf-8' ) ,
209
+ ) ;
210
+ const parsed = ts . parseJsonSourceFileConfigFileContent (
211
+ json ,
212
+ ts . sys ,
213
+ path . dirname ( tsconfigPath ) ,
214
+ ) ;
215
+ return parsed . fileNames . filter (
216
+ ( fileName ) =>
217
+ // only include .d.ts files. all other references should be made using `import` or `require`.
218
+ fileName . endsWith ( '.d.ts' ) &&
219
+ // files do not depend on themselves
220
+ fileName !== file ,
221
+ ) ;
222
+ }
223
+
192
224
// Finds an implicit 'import' in the entry point object literal, like:
193
225
//
194
226
// export const entryPoint: DynamicEntryPoint = {
You can’t perform that action at this time.
0 commit comments