feat(ivy): track compilation scope dependencies for components (#30238)

To support skipping analysis of a file containing a component
we need to know that none of the declarations that might affect
its ngtsc compilation have not changed. The files that we need to
check are those that contain classes from the `CompilationScope`
of the component. These classes are already tracked in the
`LocalModuleScopeRegistry`.

This commit modifies the `IvyCompilation` class to record the
files that are in each declared class's `CompilationScope` via
a new method, `recordNgModuleScopeDependencies()`, that is called
after all the handlers have been "resolved".

Further, if analysis is skipped for a declared class, then we need
to recover the analysis from the previous compilation run. To
support this, the `IncrementalState` class has been updated to
expose the `MetadataReader` and `MetadataRegistry` interfaces.
This is included in the `metaRegistry` object to capture these analyses,
and also in the `localMetaReader` as a fallback to use if the
current compilation analysis was skipped.

PR Close #30238
This commit is contained in:
Pete Bacon Darwin
2019-05-08 15:10:50 +01:00
committed by Alex Rickabaugh
parent 0a0b4c1d8f
commit 411524d341
6 changed files with 111 additions and 22 deletions

View File

@ -460,12 +460,14 @@ export class NgtscProgram implements api.Program {
const evaluator = new PartialEvaluator(this.reflector, checker, this.incrementalState);
const dtsReader = new DtsMetadataReader(checker, this.reflector);
const localMetaRegistry = new LocalMetadataRegistry();
const localMetaReader = new CompoundMetadataReader([localMetaRegistry, this.incrementalState]);
const depScopeReader = new MetadataDtsModuleScopeResolver(dtsReader, aliasGenerator);
const scopeRegistry = new LocalModuleScopeRegistry(
localMetaRegistry, depScopeReader, this.refEmitter, aliasGenerator);
const metaRegistry = new CompoundMetadataRegistry([localMetaRegistry, scopeRegistry]);
localMetaReader, depScopeReader, this.refEmitter, aliasGenerator);
const metaRegistry =
new CompoundMetadataRegistry([localMetaRegistry, scopeRegistry, this.incrementalState]);
this.metaReader = new CompoundMetadataReader([localMetaRegistry, dtsReader]);
this.metaReader = new CompoundMetadataReader([localMetaReader, dtsReader]);
// If a flat module entrypoint was specified, then track references via a `ReferenceGraph`
@ -504,8 +506,8 @@ export class NgtscProgram implements api.Program {
];
return new IvyCompilation(
handlers, checker, this.reflector, this.importRewriter, this.incrementalState,
this.perfRecorder, this.sourceToFactorySymbols);
handlers, this.reflector, this.importRewriter, this.incrementalState, this.perfRecorder,
this.sourceToFactorySymbols, scopeRegistry);
}
private get reflector(): TypeScriptReflectionHost {