summaryrefslogtreecommitdiff
path: root/cli/js/compiler_host.ts
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2020-01-12 22:20:33 +1100
committerBartek IwaƄczuk <biwanczuk@gmail.com>2020-01-12 12:20:33 +0100
commit737ab94ea1bdf65eeef323ea37e84bcf430fb92c (patch)
treeb6a239195a960557a5d32f1762886f77a71a9104 /cli/js/compiler_host.ts
parent8fac8ab130b3cb8a93d7e0e37fa1ea6ea4cc2e4a (diff)
Create an old program to be used in snapshot. (#3644)
Diffstat (limited to 'cli/js/compiler_host.ts')
-rw-r--r--cli/js/compiler_host.ts10
1 files changed, 6 insertions, 4 deletions
diff --git a/cli/js/compiler_host.ts b/cli/js/compiler_host.ts
index 89f5f506d..576273bbd 100644
--- a/cli/js/compiler_host.ts
+++ b/cli/js/compiler_host.ts
@@ -18,7 +18,7 @@ export interface ConfigureResponse {
diagnostics?: ts.Diagnostic[];
}
-const ASSETS = "$asset$";
+export const ASSETS = "$asset$";
/** Options that need to be used when generating a bundle (either trusted or
* runtime). */
@@ -129,11 +129,11 @@ export class Host implements ts.CompilerHost {
private _writeFile: WriteFileCallback;
private _getAsset(filename: string): SourceFile {
- const sourceFile = SourceFile.get(filename);
+ const url = filename.split("/").pop()!;
+ const sourceFile = SourceFile.get(url);
if (sourceFile) {
return sourceFile;
}
- const url = filename.split("/").pop()!;
const name = url.includes(".") ? url : `${url}.d.ts`;
const sourceCode = sendSync(dispatch.OP_FETCH_ASSET, { name });
return new SourceFile({
@@ -238,13 +238,15 @@ export class Host implements ts.CompilerHost {
: SourceFile.get(fileName);
assert(sourceFile != null);
if (!sourceFile.tsSourceFile) {
+ assert(sourceFile.sourceCode != null);
sourceFile.tsSourceFile = ts.createSourceFile(
fileName,
sourceFile.sourceCode,
languageVersion
);
+ delete sourceFile.sourceCode;
}
- return sourceFile!.tsSourceFile;
+ return sourceFile.tsSourceFile;
} catch (e) {
if (onError) {
onError(String(e));