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
@ -6,6 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {AbsoluteFsPath} from '@angular/compiler-cli/src/ngtsc/path';
|
||||
|
||||
import {NgtscTestEnvironment} from './env';
|
||||
|
||||
describe('ngtsc incremental compilation', () => {
|
||||
@ -69,6 +71,33 @@ describe('ngtsc incremental compilation', () => {
|
||||
expect(written).not.toContain('/component2.js');
|
||||
});
|
||||
|
||||
it('should rebuild components whose templates have changed', () => {
|
||||
env.write('component1.ts', `
|
||||
import {Component} from '@angular/core';
|
||||
|
||||
@Component({selector: 'cmp', templateUrl: './component1.template.html'})
|
||||
export class Cmp1 {}
|
||||
`);
|
||||
env.write('component1.template.html', 'cmp1');
|
||||
env.write('component2.ts', `
|
||||
import {Component} from '@angular/core';
|
||||
|
||||
@Component({selector: 'cmp2', templateUrl: './component2.template.html'})
|
||||
export class Cmp2 {}
|
||||
`);
|
||||
env.write('component2.template.html', 'cmp2');
|
||||
|
||||
env.driveMain();
|
||||
|
||||
// Make a change to Cmp1 template
|
||||
env.flushWrittenFileTracking();
|
||||
env.write('component1.template.html', 'changed');
|
||||
env.driveMain();
|
||||
const written = env.getFilesWrittenSinceLastFlush();
|
||||
expect(written).toContain('/component1.js');
|
||||
expect(written).not.toContain('/component2.js');
|
||||
});
|
||||
|
||||
it('should rebuild components whose partial-evaluation dependencies have changed', () => {
|
||||
env.write('component1.ts', `
|
||||
import {Component} from '@angular/core';
|
||||
@ -222,4 +251,4 @@ function setupFooBarProgram(env: NgtscTestEnvironment) {
|
||||
`);
|
||||
env.driveMain();
|
||||
env.flushWrittenFileTracking();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user