perf(compiler): don’t emit summaries for jit by default
This re-adds the flag `enableSummariesForJit` to the compiler options that already existed in Angular 4.
This commit is contained in:

committed by
Alex Rickabaugh

parent
0038712474
commit
b0868915ae
@ -98,7 +98,9 @@ export class AotCompiler {
|
||||
if (this._options.allowEmptyCodegenFiles || file.directives.length || file.pipes.length ||
|
||||
file.injectables.length || file.ngModules.length || file.exportsNonSourceFiles) {
|
||||
genFileNames.push(ngfactoryFilePath(file.fileName, true));
|
||||
genFileNames.push(summaryForJitFileName(file.fileName, true));
|
||||
if (this._options.enableSummariesForJit) {
|
||||
genFileNames.push(summaryForJitFileName(file.fileName, true));
|
||||
}
|
||||
}
|
||||
const fileSuffix = splitTypescriptSuffix(file.fileName, true)[1];
|
||||
file.directives.forEach((dirSymbol) => {
|
||||
@ -376,7 +378,9 @@ export class AotCompiler {
|
||||
metadata: this._metadataResolver.getInjectableSummary(ref) !.type
|
||||
}))
|
||||
];
|
||||
const forJitOutputCtx = this._createOutputContext(summaryForJitFileName(srcFileName, true));
|
||||
const forJitOutputCtx = this._options.enableSummariesForJit ?
|
||||
this._createOutputContext(summaryForJitFileName(srcFileName, true)) :
|
||||
null;
|
||||
const {json, exportAs} = serializeSummaries(
|
||||
srcFileName, forJitOutputCtx, this._summaryResolver, this._symbolResolver, symbolSummaries,
|
||||
typeData);
|
||||
@ -387,11 +391,11 @@ export class AotCompiler {
|
||||
]));
|
||||
});
|
||||
const summaryJson = new GeneratedFile(srcFileName, summaryFileName(srcFileName), json);
|
||||
if (this._options.enableSummariesForJit) {
|
||||
return [summaryJson, this._codegenSourceModule(srcFileName, forJitOutputCtx)];
|
||||
const result = [summaryJson];
|
||||
if (forJitOutputCtx) {
|
||||
result.push(this._codegenSourceModule(srcFileName, forJitOutputCtx));
|
||||
}
|
||||
|
||||
return [summaryJson];
|
||||
return result;
|
||||
}
|
||||
|
||||
private _compileModule(outputCtx: OutputContext, ngModule: CompileNgModuleMetadata): void {
|
||||
|
@ -14,7 +14,6 @@ export interface AotCompilerOptions {
|
||||
translations?: string;
|
||||
missingTranslation?: MissingTranslationStrategy;
|
||||
enableLegacyTemplate?: boolean;
|
||||
/** TODO(tbosch): remove this flag as it is always on in the new ngc */
|
||||
enableSummariesForJit?: boolean;
|
||||
preserveWhitespaces?: boolean;
|
||||
fullTemplateTypeCheck?: boolean;
|
||||
|
@ -15,14 +15,14 @@ import {ResolvedStaticSymbol, StaticSymbolResolver} from './static_symbol_resolv
|
||||
import {summaryForJitFileName, summaryForJitName} from './util';
|
||||
|
||||
export function serializeSummaries(
|
||||
srcFileName: string, forJitCtx: OutputContext, summaryResolver: SummaryResolver<StaticSymbol>,
|
||||
symbolResolver: StaticSymbolResolver, symbols: ResolvedStaticSymbol[], types: {
|
||||
srcFileName: string, forJitCtx: OutputContext | null,
|
||||
summaryResolver: SummaryResolver<StaticSymbol>, symbolResolver: StaticSymbolResolver,
|
||||
symbols: ResolvedStaticSymbol[], types: {
|
||||
summary: CompileTypeSummary,
|
||||
metadata: CompileNgModuleMetadata | CompileDirectiveMetadata | CompilePipeMetadata |
|
||||
CompileTypeMetadata
|
||||
}[]): {json: string, exportAs: {symbol: StaticSymbol, exportAs: string}[]} {
|
||||
const toJsonSerializer = new ToJsonSerializer(symbolResolver, summaryResolver, srcFileName);
|
||||
const forJitSerializer = new ForJitSerializer(forJitCtx, symbolResolver);
|
||||
|
||||
// for symbols, we use everything except for the class metadata itself
|
||||
// (we keep the statics though), as the class metadata is contained in the
|
||||
@ -33,18 +33,20 @@ export function serializeSummaries(
|
||||
|
||||
// Add type summaries.
|
||||
types.forEach(({summary, metadata}) => {
|
||||
forJitSerializer.addSourceType(summary, metadata);
|
||||
toJsonSerializer.addSummary(
|
||||
{symbol: summary.type.reference, metadata: undefined, type: summary});
|
||||
});
|
||||
toJsonSerializer.unprocessedSymbolSummariesBySymbol.forEach((summary) => {
|
||||
if (summaryResolver.isLibraryFile(summary.symbol.filePath) && summary.type) {
|
||||
forJitSerializer.addLibType(summary.type);
|
||||
}
|
||||
});
|
||||
|
||||
const {json, exportAs} = toJsonSerializer.serialize();
|
||||
forJitSerializer.serialize(exportAs);
|
||||
if (forJitCtx) {
|
||||
const forJitSerializer = new ForJitSerializer(forJitCtx, symbolResolver);
|
||||
types.forEach(({summary, metadata}) => { forJitSerializer.addSourceType(summary, metadata); });
|
||||
toJsonSerializer.unprocessedSymbolSummariesBySymbol.forEach((summary) => {
|
||||
if (summaryResolver.isLibraryFile(summary.symbol.filePath) && summary.type) {
|
||||
forJitSerializer.addLibType(summary.type);
|
||||
}
|
||||
});
|
||||
forJitSerializer.serialize(exportAs);
|
||||
}
|
||||
return {json, exportAs};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user