Skip to content

Commit 9afaa3a

Browse files
Broccohansl
authored andcommitted
fix(@ngtools/webpack): change of CSS no longer breaks rebuild (#4334)
Fixes #4326 Fixes #4329
1 parent 601f9b3 commit 9afaa3a

File tree

3 files changed

+166
-2
lines changed

3 files changed

+166
-2
lines changed

Diff for: 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 {

Diff for: packages/angular-cli/lib/config/schema.d.ts

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
export interface CliConfig {
2+
/**
3+
* The global configuration of the project.
4+
*/
5+
project?: {
6+
version?: string;
7+
name?: string;
8+
};
9+
/**
10+
* Properties of the different applications in this project.
11+
*/
12+
apps?: {
13+
root?: string;
14+
outDir?: string;
15+
assets?: (string | string[]);
16+
deployUrl?: string;
17+
index?: string;
18+
main?: string;
19+
polyfills?: string;
20+
test?: string;
21+
tsconfig?: string;
22+
prefix?: string;
23+
mobile?: boolean;
24+
/**
25+
* Global styles to be included in the build.
26+
*/
27+
styles?: (string | {
28+
input?: string;
29+
[name: string]: any;
30+
})[];
31+
/**
32+
* Options to pass to style preprocessors
33+
*/
34+
stylePreprocessorOptions?: {
35+
/**
36+
* Paths to include. Paths will be resolved to project root.
37+
*/
38+
includePaths?: string[];
39+
};
40+
/**
41+
* Global scripts to be included in the build.
42+
*/
43+
scripts?: (string | {
44+
input: string;
45+
[name: string]: any;
46+
})[];
47+
/**
48+
* Name and corresponding file for environment config.
49+
*/
50+
environments?: {
51+
[name: string]: any;
52+
};
53+
}[];
54+
/**
55+
* Configuration reserved for installed third party addons.
56+
*/
57+
addons?: {
58+
[name: string]: any;
59+
}[];
60+
/**
61+
* Configuration reserved for installed third party packages.
62+
*/
63+
packages?: {
64+
[name: string]: any;
65+
}[];
66+
e2e?: {
67+
protractor?: {
68+
config?: string;
69+
};
70+
};
71+
/**
72+
* Properties to be passed to TSLint.
73+
*/
74+
lint?: {
75+
files: string;
76+
project: string;
77+
tslintConfig?: string;
78+
}[];
79+
test?: {
80+
karma?: {
81+
config?: string;
82+
};
83+
};
84+
defaults?: {
85+
styleExt?: string;
86+
prefixInterfaces?: boolean;
87+
poll?: number;
88+
viewEncapsulation?: string;
89+
changeDetection?: string;
90+
inline?: {
91+
style?: boolean;
92+
template?: boolean;
93+
};
94+
spec?: {
95+
class?: boolean;
96+
component?: boolean;
97+
directive?: boolean;
98+
module?: boolean;
99+
pipe?: boolean;
100+
service?: boolean;
101+
};
102+
/**
103+
* Properties to be passed to the serve command
104+
*/
105+
serve?: {
106+
/**
107+
* The port the application will be served on
108+
*/
109+
port?: number;
110+
/**
111+
* The host the application will be served on
112+
*/
113+
host?: string;
114+
};
115+
};
116+
/**
117+
* Allow people to disable console warnings.
118+
*/
119+
warnings?: {
120+
/**
121+
* Show a warning when the node version is incompatible.
122+
*/
123+
nodeDeprecation?: boolean;
124+
/**
125+
* Show a warning when the user installed angular-cli.
126+
*/
127+
packageDeprecation?: boolean;
128+
/**
129+
* Show a warning when the global version is newer than the local one.
130+
*/
131+
versionMismatch?: boolean;
132+
};
133+
}

Diff for: tests/e2e/tests/build/rebuild-css-change.ts

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

0 commit comments

Comments
 (0)