Skip to content

Commit 3c5418d

Browse files
committed
fix(@ngtools/webpack): change of CSS no longer breaks rebuild
Fixes #4326 Fixes #4329
1 parent 601f9b3 commit 3c5418d

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

packages/@ngtools/webpack/src/compiler_host.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,10 @@ export class WebpackCompilerHost implements ts.CompilerHost {
187187
}
188188

189189
invalidate(fileName: string): void {
190-
this._files[fileName] = null;
191-
this._changedFiles[fileName] = true;
190+
if (fileName in this._files) {
191+
this._files[fileName] = null;
192+
this._changedFiles[fileName] = true;
193+
}
192194
}
193195

194196
fileExists(fileName: string): boolean {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import {
2+
killAllProcesses,
3+
exec,
4+
waitForAnyProcessOutputToMatch,
5+
silentExecAndWaitForOutputToMatch
6+
} from '../../utils/process';
7+
import {appendToFile} from '../../utils/fs';
8+
9+
10+
export default function() {
11+
if (process.platform.startsWith('win')) {
12+
return Promise.resolve();
13+
}
14+
15+
return silentExecAndWaitForOutputToMatch('ng', ['serve'], /webpack: bundle is now VALID|webpack: Compiled successfully./)
16+
// Should trigger a rebuild.
17+
.then(() => exec('touch', 'src/main.ts'))
18+
.then(() => waitForAnyProcessOutputToMatch(/webpack: bundle is now INVALID|webpack: Compiling.../, 1000))
19+
.then(() => waitForAnyProcessOutputToMatch(/webpack: bundle is now VALID|webpack: Compiled successfully./, 5000))
20+
.then(() => appendToFile('src/app/app.component.css', ':host { color: blue; }'))
21+
.then(() => waitForAnyProcessOutputToMatch(/webpack: bundle is now INVALID|webpack: Compiling.../, 1000))
22+
.then(() => waitForAnyProcessOutputToMatch(/webpack: bundle is now VALID|webpack: Compiled successfully./, 5000))
23+
.then(() => killAllProcesses(), (err: any) => {
24+
killAllProcesses();
25+
throw err;
26+
});
27+
}

0 commit comments

Comments
 (0)