From 6976de7f6ea59b4c093393637e3064ce8d61b0d6 Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Mon, 10 Sep 2018 10:06:54 -0700 Subject: [PATCH] Try to warm TypeScript --- js/compiler.ts | 17 ++++++++++++----- js/main.ts | 4 ++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/js/compiler.ts b/js/compiler.ts index 8db4d1b4b2e11f..d13e4dc37a365a 100644 --- a/js/compiler.ts +++ b/js/compiler.ts @@ -159,6 +159,7 @@ export class DenoCompiler // A reference to the `./os.ts` module, so it can be monkey patched during // testing private _os: Os = os; + private _program?: ts.Program; // Contains a queue of modules that have been resolved, but not yet // run private _runQueue: ModuleMetaData[] = []; @@ -415,21 +416,27 @@ export class DenoCompiler } this._service = this._ts.createLanguageService(this); this._setupSourceMaps(); + this._program = this._ts.createProgram({ + host: this, + options: this._options, + rootNames: [] + }); } // Deno specific compiler API compileProgram(rootModuleMetaData: ModuleMetaData) { this._log("compiler.compileProgram", rootModuleMetaData.fileName); - const program = this._ts.createProgram({ - rootNames: [rootModuleMetaData.fileName], + this._program = this._ts.createProgram({ + host: this, + oldProgram: this._program, options: this._options, - host: this + rootNames: [rootModuleMetaData.fileName] }); - const emitResult = program.emit(); + const emitResult = this._program.emit(); const diagnostics = [ - ...this._ts.getPreEmitDiagnostics(program), + ...this._ts.getPreEmitDiagnostics(this._program), ...emitResult.diagnostics ]; if (diagnostics.length > 0) { diff --git a/js/main.ts b/js/main.ts index 47b5355d011bcc..47ccfc4015c9f8 100644 --- a/js/main.ts +++ b/js/main.ts @@ -31,11 +31,12 @@ function onGlobalError( os.exit(1); } +const compiler = DenoCompiler.instance(); + /* tslint:disable-next-line:no-default-export */ export default function denoMain() { libdeno.recv(handleAsyncMsgFromRust); libdeno.setGlobalErrorHandler(onGlobalError); - const compiler = DenoCompiler.instance(); // First we send an empty "Start" message to let the privlaged side know we // are ready. The response should be a "StartRes" message containing the CLI @@ -68,7 +69,6 @@ export default function denoMain() { os.exit(0); } - compiler.run(inputFn, `${cwd}/`); if (cwd) { compiler.setCwd(cwd); }