Skip to content

Commit

Permalink
Try to warm TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
kitsonk committed Sep 10, 2018
1 parent 59fadc4 commit 6976de7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
17 changes: 12 additions & 5 deletions js/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [];
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions js/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -68,7 +69,6 @@ export default function denoMain() {
os.exit(0);
}

compiler.run(inputFn, `${cwd}/`);
if (cwd) {
compiler.setCwd(cwd);
}
Expand Down

0 comments on commit 6976de7

Please sign in to comment.