summaryrefslogtreecommitdiff
path: root/cli/js
diff options
context:
space:
mode:
Diffstat (limited to 'cli/js')
-rw-r--r--cli/js/compiler.ts16
-rw-r--r--cli/js/compiler_imports.ts19
-rw-r--r--cli/js/compiler_sourcefile.ts11
3 files changed, 33 insertions, 13 deletions
diff --git a/cli/js/compiler.ts b/cli/js/compiler.ts
index 4ca2887c6..3db0e2f52 100644
--- a/cli/js/compiler.ts
+++ b/cli/js/compiler.ts
@@ -105,13 +105,6 @@ async function tsCompilerOnMessage({
type: CompilerRequestType[request.type]
});
- // This will recursively analyse all the code for other imports,
- // requesting those from the privileged side, populating the in memory
- // cache which will be used by the host, before resolving.
- const resolvedRootModules = await processImports(
- rootNames.map(rootName => [rootName, rootName])
- );
-
// When a programme is emitted, TypeScript will call `writeFile` with
// each file that needs to be emitted. The Deno compiler host delegates
// this, to make it easier to perform the right actions, which vary
@@ -141,6 +134,15 @@ async function tsCompilerOnMessage({
diagnostics = processConfigureResponse(configResult, configPath);
}
+ // This will recursively analyse all the code for other imports,
+ // requesting those from the privileged side, populating the in memory
+ // cache which will be used by the host, before resolving.
+ const resolvedRootModules = await processImports(
+ rootNames.map(rootName => [rootName, rootName]),
+ undefined,
+ host.getCompilationSettings().checkJs
+ );
+
let emitSkipped = true;
// if there was a configuration and no diagnostics with it, we will continue
// to generate the program and possibly emit it.
diff --git a/cli/js/compiler_imports.ts b/cli/js/compiler_imports.ts
index 042c0a1ae..09b2d4ba1 100644
--- a/cli/js/compiler_imports.ts
+++ b/cli/js/compiler_imports.ts
@@ -120,7 +120,8 @@ function getMediaType(filename: string): MediaType {
export function processLocalImports(
sources: Record<string, string>,
specifiers: Array<[string, string]>,
- referrer?: string
+ referrer?: string,
+ checkJs = false
): string[] {
if (!specifiers.length) {
return [];
@@ -143,7 +144,12 @@ export function processLocalImports(
});
sourceFile.cache(specifiers[i][0], referrer);
if (!sourceFile.processed) {
- processLocalImports(sources, sourceFile.imports(), sourceFile.url);
+ processLocalImports(
+ sources,
+ sourceFile.imports(checkJs),
+ sourceFile.url,
+ checkJs
+ );
}
}
return moduleNames;
@@ -157,7 +163,8 @@ export function processLocalImports(
* that should be actually resolved. */
export async function processImports(
specifiers: Array<[string, string]>,
- referrer?: string
+ referrer?: string,
+ checkJs = false
): Promise<string[]> {
if (!specifiers.length) {
return [];
@@ -172,7 +179,11 @@ export async function processImports(
SourceFile.get(sourceFileJson.url) || new SourceFile(sourceFileJson);
sourceFile.cache(specifiers[i][0], referrer);
if (!sourceFile.processed) {
- await processImports(sourceFile.imports(), sourceFile.url);
+ await processImports(
+ sourceFile.imports(checkJs),
+ sourceFile.url,
+ checkJs
+ );
}
}
return resolvedSources;
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);