mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
fix: mis-detecting imports on JavaScript when there is no checkJs (#4040)
This PR fixes an issue where we recursively analysed imports on plain JS files in the compiler irrespective of "checkJs" being true. This caused problems where when analysing the imports of those files, we would mistake some import like structures (AMD/CommonJS) as dependencies and try to resolve the "modules" even though the compiler would not actually look at those files.
This commit is contained in:
parent
0e579ee9dc
commit
6431622a6d
7 changed files with 46 additions and 13 deletions
|
@ -91,7 +91,7 @@ export class SourceFile {
|
|||
}
|
||||
|
||||
/** Process the imports for the file and return them. */
|
||||
imports(): Array<[string, string]> {
|
||||
imports(checkJs: boolean): Array<[string, string]> {
|
||||
if (this.processed) {
|
||||
throw new Error("SourceFile has already been processed.");
|
||||
}
|
||||
|
@ -102,6 +102,7 @@ export class SourceFile {
|
|||
log(`Skipping imports for "${this.filename}"`);
|
||||
return [];
|
||||
}
|
||||
|
||||
const preProcessedFileInfo = ts.preProcessFile(
|
||||
this.sourceCode,
|
||||
true,
|
||||
|
@ -131,7 +132,13 @@ export class SourceFile {
|
|||
getMappedModuleName(importedFile, typeDirectives)
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
} else if (
|
||||
!(
|
||||
!checkJs &&
|
||||
(this.mediaType === MediaType.JavaScript ||
|
||||
this.mediaType === MediaType.JSX)
|
||||
)
|
||||
) {
|
||||
process(importedFiles);
|
||||
}
|
||||
process(referencedFiles);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue