fix(ivy): recompile component when template changes in ngc watch mode (#33551)
When the Angular compiler is operated through the ngc binary in watch mode, changing a template in an external file would not cause the component to be recompiled if Ivy is enabled. There was a problem with how a cached compiler host was present that was unaware of the changed resources, therefore failing to trigger a recompilation of a component whenever its template changes. This commit fixes the issue by ensuring that information about modified resources is correctly available to the cached compiler host. Fixes #32869 PR Close #33551
This commit is contained in:
@ -153,7 +153,7 @@ export function performWatchCompilation(host: PerformWatchHost):
|
||||
}
|
||||
|
||||
// Invoked to perform initial compilation or re-compilation in watch mode
|
||||
function doCompilation(modifiedResourceFiles?: Set<string>): Diagnostics {
|
||||
function doCompilation(): Diagnostics {
|
||||
if (!cachedOptions) {
|
||||
cachedOptions = host.readConfiguration();
|
||||
}
|
||||
@ -197,8 +197,12 @@ export function performWatchCompilation(host: PerformWatchHost):
|
||||
return ce.content !;
|
||||
};
|
||||
// Provide access to the file paths that triggered this rebuild
|
||||
cachedCompilerHost.getModifiedResourceFiles =
|
||||
modifiedResourceFiles !== undefined ? () => modifiedResourceFiles : undefined;
|
||||
cachedCompilerHost.getModifiedResourceFiles = function() {
|
||||
if (timerHandleForRecompilation === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return timerHandleForRecompilation.modifiedResourceFiles;
|
||||
};
|
||||
}
|
||||
ignoreFilesForWatch.clear();
|
||||
const oldProgram = cachedProgram;
|
||||
@ -287,7 +291,7 @@ export function performWatchCompilation(host: PerformWatchHost):
|
||||
function recompile() {
|
||||
host.reportDiagnostics(
|
||||
[createMessageDiagnostic('File change detected. Starting incremental compilation.')]);
|
||||
doCompilation(timerHandleForRecompilation !.modifiedResourceFiles);
|
||||
doCompilation();
|
||||
timerHandleForRecompilation = undefined;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user