Reland "Create an old program to be used in snapshot." (#3747)

* read CLI assets from disk during snapshotting
This commit is contained in:
Bartek Iwańczuk 2020-01-22 20:18:01 +01:00 committed by GitHub
parent 3c47718959
commit bd9561f4de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 126 additions and 64 deletions

View file

@ -6,6 +6,7 @@ import "./globals.ts";
import "./ts_global.d.ts";
import { TranspileOnlyResult } from "./compiler_api.ts";
import { oldProgram } from "./compiler_bootstrap.ts";
import { setRootExports } from "./compiler_bundler.ts";
import {
defaultBundlerOptions,
@ -142,7 +143,12 @@ self.bootstrapTsCompiler = function tsCompilerMain(): void {
// to generate the program and possibly emit it.
if (!diagnostics || (diagnostics && diagnostics.length === 0)) {
const options = host.getCompilationSettings();
const program = ts.createProgram(rootNames, options, host);
const program = ts.createProgram({
rootNames,
options,
host,
oldProgram
});
diagnostics = ts
.getPreEmitDiagnostics(program)
@ -220,11 +226,12 @@ self.bootstrapTsCompiler = function tsCompilerMain(): void {
}
host.mergeOptions(...compilerOptions);
const program = ts.createProgram(
const program = ts.createProgram({
rootNames,
host.getCompilationSettings(),
host
);
options: host.getCompilationSettings(),
host,
oldProgram
});
if (bundle) {
setRootExports(program, rootNames[0]);