diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2020-02-20 14:58:05 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-19 22:58:05 -0500 |
commit | 6431622a6debc0443f9269fe0157571ec54701c0 (patch) | |
tree | 8657fe0eaeb492283f369c0813d46880683e5efb /cli/js/compiler_sourcefile.ts | |
parent | 0e579ee9dce917c1b783cea5506315f78b1e0a00 (diff) |
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.
Diffstat (limited to 'cli/js/compiler_sourcefile.ts')
-rw-r--r-- | cli/js/compiler_sourcefile.ts | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/cli/js/compiler_sourcefile.ts b/cli/js/compiler_sourcefile.ts index faa096ba8..23fefbf41 100644 --- a/cli/js/compiler_sourcefile.ts +++ b/cli/js/compiler_sourcefile.ts @@ -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); |