Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/@ngtools/webpack/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,11 @@ export class AotPlugin implements Tapable {
this._program = ts.createProgram(
this._rootFilePath, this._compilerOptions, this._compilerHost, this._program);
})
.then(() => {
// Re-diagnose changed files.
const changedFilePaths = this._compilerHost.getChangedFilePaths();
changedFilePaths.forEach(filePath => this.diagnose(filePath));
})
.then(() => {
if (this._typeCheck) {
const diagnostics = this._program.getGlobalDiagnostics();
Expand Down Expand Up @@ -461,7 +466,9 @@ export class AotPlugin implements Tapable {
});
})
.then(() => {
this._compilerHost.resetChangedFileTracker();
if (this._compilation.errors == 0) {
this._compilerHost.resetChangedFileTracker();
}

cb();
}, (err: any) => {
Expand Down
14 changes: 13 additions & 1 deletion tests/e2e/tests/build/rebuild-deps-type-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function() {
`))
// Should trigger a rebuild, no error expected.
.then(() => waitForAnyProcessOutputToMatch(doneRe, 10000))
// Create and import files.
// Make an invalid version of the file.
.then(() => wait(2000))
.then(() => writeFile('src/funky2.ts', `
export function funky(value: number): number {
Expand All @@ -54,6 +54,18 @@ export default function() {
throw new Error('Expected an error but none happened.');
}
})
// Change an UNRELATED file and the error should still happen.
.then(() => wait(2000))
.then(() => appendToFile('src/app/app.module.ts', `
function anything(): number {}
`))
// Should trigger a rebuild, this time an error is expected.
.then(() => waitForAnyProcessOutputToMatch(doneRe, 10000))
.then(({ stdout }) => {
if (!/ERROR in .*\/src\/main\.ts \(/.test(stdout)) {
throw new Error('Expected an error but none happened.');
}
})
// Fix the error!
.then(() => writeFile('src/funky2.ts', `
export function funky(value: string): string {
Expand Down