fix(ivy): ensure that changes to component resources trigger incremental builds (#30954)
Optimizations to skip compiling source files that had not changed did not account for the case where only a resource file changes, such as an external template or style file. Now we track such dependencies and trigger a recompilation if any of the previously tracked resources have changed. This will require a change on the CLI side to provide the list of resource files that changed to trigger the current compilation by implementing `CompilerHost.getModifiedResourceFiles()`. Closes #30947 PR Close #30954
This commit is contained in:

committed by
Kara Erickson

parent
dc613b336d
commit
48def92cad
@ -43,7 +43,6 @@ export class NgtscProgram implements api.Program {
|
||||
private compilation: IvyCompilation|undefined = undefined;
|
||||
private factoryToSourceInfo: Map<string, FactoryInfo>|null = null;
|
||||
private sourceToFactorySymbols: Map<string, Set<string>>|null = null;
|
||||
private host: ts.CompilerHost;
|
||||
private _coreImportsFrom: ts.SourceFile|null|undefined = undefined;
|
||||
private _importRewriter: ImportRewriter|undefined = undefined;
|
||||
private _reflector: TypeScriptReflectionHost|undefined = undefined;
|
||||
@ -68,20 +67,23 @@ export class NgtscProgram implements api.Program {
|
||||
private incrementalState: IncrementalState;
|
||||
private typeCheckFilePath: AbsoluteFsPath;
|
||||
|
||||
private modifiedResourceFiles: Set<string>|null;
|
||||
|
||||
constructor(
|
||||
rootNames: ReadonlyArray<string>, private options: api.CompilerOptions,
|
||||
host: api.CompilerHost, oldProgram?: NgtscProgram) {
|
||||
private host: api.CompilerHost, oldProgram?: NgtscProgram) {
|
||||
if (shouldEnablePerfTracing(options)) {
|
||||
this.perfTracker = PerfTracker.zeroedToNow();
|
||||
this.perfRecorder = this.perfTracker;
|
||||
}
|
||||
|
||||
this.modifiedResourceFiles =
|
||||
this.host.getModifiedResourceFiles && this.host.getModifiedResourceFiles() || null;
|
||||
this.rootDirs = getRootDirs(host, options);
|
||||
this.closureCompilerEnabled = !!options.annotateForClosureCompiler;
|
||||
this.resourceManager = new HostResourceLoader(host, options);
|
||||
const shouldGenerateShims = options.allowEmptyCodegenFiles || false;
|
||||
const normalizedRootNames = rootNames.map(n => AbsoluteFsPath.from(n));
|
||||
this.host = host;
|
||||
if (host.fileNameToModuleName !== undefined) {
|
||||
this.fileToModuleHost = host as FileToModuleHost;
|
||||
}
|
||||
@ -159,7 +161,8 @@ export class NgtscProgram implements api.Program {
|
||||
this.incrementalState = IncrementalState.fresh();
|
||||
} else {
|
||||
this.incrementalState = IncrementalState.reconcile(
|
||||
oldProgram.incrementalState, oldProgram.reuseTsProgram, this.tsProgram);
|
||||
oldProgram.incrementalState, oldProgram.reuseTsProgram, this.tsProgram,
|
||||
this.modifiedResourceFiles);
|
||||
}
|
||||
}
|
||||
|
||||
@ -498,7 +501,7 @@ export class NgtscProgram implements api.Program {
|
||||
this.reflector, evaluator, metaRegistry, this.metaReader !, scopeRegistry, this.isCore,
|
||||
this.resourceManager, this.rootDirs, this.options.preserveWhitespaces || false,
|
||||
this.options.i18nUseExternalIds !== false, this.moduleResolver, this.cycleAnalyzer,
|
||||
this.refEmitter, this.defaultImportTracker),
|
||||
this.refEmitter, this.defaultImportTracker, this.incrementalState),
|
||||
new DirectiveDecoratorHandler(
|
||||
this.reflector, evaluator, metaRegistry, this.defaultImportTracker, this.isCore),
|
||||
new InjectableDecoratorHandler(
|
||||
|
Reference in New Issue
Block a user