perf(compiler): only emit changed files for incremental compilation

For now, we always create all generated files, but diff them
before we pass them to TypeScript.

For the user files, we compare the programs and only emit changed
TypeScript files.

This also adds more diagnostic messages if the `—diagnostics` flag
is passed to the command line.
This commit is contained in:
Tobias Bosch
2017-09-29 15:02:11 -07:00
committed by Alex Rickabaugh
parent b0868915ae
commit 745b59f49c
15 changed files with 424 additions and 94 deletions

View File

@ -8,6 +8,8 @@
import * as ts from 'typescript';
import {DEFAULT_ERROR_CODE, Diagnostic, SOURCE} from './api';
export const GENERATED_FILES = /(.*?)\.(ngfactory|shim\.ngstyle|ngstyle|ngsummary)\.(js|d\.ts|ts)$/;
export const enum StructureIsReused {Not = 0, SafeModules = 1, Completely = 2}
@ -15,4 +17,15 @@ export const enum StructureIsReused {Not = 0, SafeModules = 1, Completely = 2}
// Note: This is an internal property in TypeScript. Use it only for assertions and tests.
export function tsStructureIsReused(program: ts.Program): StructureIsReused {
return (program as any).structureIsReused;
}
}
export function createMessageDiagnostic(messageText: string): ts.Diagnostic&Diagnostic {
return {
file: undefined,
start: undefined,
length: undefined,
category: ts.DiagnosticCategory.Message, messageText,
code: DEFAULT_ERROR_CODE,
source: SOURCE,
};
}