8000 fix(@angular-devkit/build-angular): update `critters` to version `0.0… · angular-robot/angular-cli@7f36f8b · GitHub
[go: up one dir, main page]

Skip to content

Commit 7f36f8b

Browse files
alan-agius4filipesilva
authored andcommitted
fix(@angular-devkit/build-angular): update critters to version 0.0.12
This change brings in a security fix causes was causes by an outdated dependency. See GoogleChromeLabs/critters#82 for more information. Also, remote stylesheets are excluded from processing, were previously this caused build failures. Closes angular#20794
1 parent fefc115 commit 7f36f8b

File tree

8 files changed

+83
-45
lines changed

8 files changed

+83
-45
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
"conventional-commits-parser": "^3.0.0",
144144
"copy-webpack-plugin": "6.3.2",
145145
"core-js": "3.8.3",
146-
"critters": "0.0.7",
146+
"critters": "0.0.12",
147147
"css-loader": "5.0.1",
148148
"cssnano": "5.0.2",
149149
"debug": "^4.1.1",

packages/angular_devkit/build_angular/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"circular-dependency-plugin": "5.2.2",
3131
"copy-webpack-plugin": "6.3.2",
3232
"core-js": "3.8.3",
33-
"critters": "0.0.7",
33+
"critters": "0.0.12",
3434
"css-loader": "5.0.1",
3535
"cssnano": "5.0.2",
3636
"file-loader": "6.2.0",

packages/angular_devkit/build_angular/src/app-shell/app-shell_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ describe('AppShell Builder', () => {
290290
const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(fileName)));
291291

292292
expect(content).toContain('app-shell works!');
293-
expect(content).toContain('p{color:#000;}');
293+
expect(content).toContain('p{color:#000}');
294294
expect(content).toMatch(/<link rel="stylesheet" href="styles\.[a-z0-9]+\.css" media="print" onload="this\.media='all'">/);
295295
});
296296
});

packages/angular_devkit/build_angular/src/browser/specs/inline-critical-css-optimization_spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,20 @@ describe('Browser Builder inline critical CSS optimization', () => {
3939
const { files } = await browserBuild(architect, host, target, overrides);
4040
const html = await files['index.html'];
4141
expect(html).toContain(`<link rel="stylesheet" href="styles.css" media="print" onload="this.media='all'">`);
42-
expect(html).toContain(`body{color:#000;}`);
42+
expect(html).toContain(`body{color:#000}`);
4343
});
4444

4545
it('works with deployUrl', async () => {
4646
const { files } = await browserBuild(architect, host, target, { ...overrides, deployUrl: 'http://cdn.com/' });
4747
const html = await files['index.html'];
4848
expect(html).toContain(`<link rel="stylesheet" href="http://cdn.com/styles.css" media="print" onload="this.media='all'">`);
49-
expect(html).toContain(`body{color:#000;}`);
49+
expect(html).toContain(`body{color:#000}`);
5050
});
5151

5252
it('should not inline critical css when option is disabled', async () => {
5353
const { files } = await browserBuild(architect, host, target, { optimization: false });
5454
const html = await files['index.html'];
5555
expect(html).toContain(`<link rel="stylesheet" href="styles.css">`);
56-
expect(html).not.toContain(`body{color:#000;}`);
56+
expect(html).not.toContain(`body{color:#000}`);
5757
});
5858
});

packages/angular_devkit/build_angular/src/dev-server/inline-critical-css-optimization_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('Dev Server Builder inline critical CSS optimization', () => {
4343
mergeMap(async output => {
4444
expect(output.success).toBe(true);
4545
const response = await fetch(`${output.baseUrl}/index.html`);
46-
expect(await response.text()).toContain(`body{color:#000;}`);
46+
expect(await response.text()).toContain(`body{color:#000}`);
4747
}),
4848
).toPromise();
4949

packages/angular_devkit/build_angular/src/utils/index-file/inline-critical-css.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@ class CrittersExtended extends Critters {
2323
readonly warnings: string[] = [];
2424
readonly errors: string[] = [];
2525

26-
constructor(private readonly optionsExtended: InlineCriticalCssProcessorOptions & InlineCriticalCssProcessOptions) {
26+
constructor(
27+
private readonly optionsExtended: InlineCriticalCssProcessorOptions &
28+
InlineCriticalCssProcessOptions,
29+
) {
2730
super({
2831
logger: {
2932
warn: (s: string) => this.warnings.push(s),
3033
error: (s: string) => this.errors.push(s),
31-
log: () => { },
32-
info: () => { },
34+
log: () => {},
35+
info: () => {},
3336
},
3437
path: optionsExtended.outputPath,
3538
publicPath: optionsExtended.deployUrl,
@@ -44,18 +47,20 @@ class CrittersExtended extends Critters {
4447
} as any);
4548
}
4649

47-
protected readFile(path: string): Promise<string> {
50+
public readFile(path: string): Promise<string> {
4851
const readAsset = this.optionsExtended.readAsset;
4952

5053
return readAsset ? readAsset(path) : readFile(path, 'utf-8');
5154
}
5255
}
5356

5457
export class InlineCriticalCssProcessor {
55-
constructor(protected readonly options: InlineCriticalCssProcessorOptions) { }
58+
constructor(protected readonly options: InlineCriticalCssProcessorOptions) {}
5659

57-
async process(html: string, options: InlineCriticalCssProcessOptions)
58-
: Promise<{ content: string, warnings: string[], errors: string[] }> {
60+
async process(
61+
html: string,
62+
options: InlineCriticalCssProcessOptions,
63+
): Promise<{ content: string; warnings: string[]; errors: string[] }> {
5964
const critters = new CrittersExtended({ ...this.options, ...options });
6065
const content = await critters.process(html);
6166

packages/angular_devkit/build_angular/src/utils/index-file/inline-critical-css_spec.ts

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,10 @@ describe('InlineCriticalCssProcessor', () => {
5353
expect(content).toContain(`<link href="theme.css" rel="stylesheet" media="print" onload="this.media='all'">`);
5454
expect(content).not.toContain('color: blue');
5555
expect(tags.stripIndents`${content}`).toContain(tags.stripIndents`
56-
<style>body {
57-
margin: 0;
58-
}
59-
60-
html {
61-
color: white;
62-
}</style>
63-
`);
56+
<style>
57+
body { margin: 0; }
58+
html { color: white; }
59+
</style>`);
6460
});
6561

6662
it('should inline critical css when using deployUrl', async () => {
@@ -76,14 +72,10 @@ describe('InlineCriticalCssProcessor', () => {
7672
expect(content).toContain(`<link href="http://cdn.com/styles.css" rel="stylesheet" media="print" onload="this.media='all'">`);
7773
expect(content).toContain(`<link href="http://cdn.com/theme.css" rel="stylesheet" media="print" onload="this.media='all'">`);
7874
expect(tags.stripIndents`${content}`).toContain(tags.stripIndents`
79-
<style>body {
80-
margin: 0;
81-
}
82-
83-
html {
84-
color: white;
85-
}</style>
86-
`);
75+
<style>
76+
body { margin: 0; }
77+
html { color: white; }
78+
</style>`);
8779
});
8880

8981
it('should compress inline critical css when minify is enabled', async () => {
@@ -98,6 +90,6 @@ describe('InlineCriticalCssProcessor', () => {
9890

9991
expect(content).toContain(`<link href="styles.css" rel="stylesheet" media="print" onload="this.media='all'">`);
10092
expect(content).toContain(`<link href="theme.css" rel="stylesheet" media="print" onload="this.media='all'">`);
101-
expect(content).toContain('<style>body{margin:0;}html{color:white;}</style>');
93+
expect(content).toContain('<style>body{margin:0}html{color:white}</style>');
10294
});
10395
});

yarn.lock

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3912,15 +3912,16 @@ create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7:
39123912
safe-buffer "^5.0.1"
39133913
sha.js "^2.4.8"
39143914

3915-
critters@0.0.7:
3916-
version "0.0.7"
3917-
resolved "https://registry.yarnpkg.com/critters/-/critters-0.0.7.tgz#548b470360f4f3c51e622de3b7aa733c8f0b17bf"
3918-
integrity sha512-qUF2SaAWFYjNPdCcPpu68p2DnHiosia84yx5mPTlUMQjkjChR+n6sO1/I7yn2U2qNDgSPTd2SoaTIDQcUL+EwQ==
3915+
critters@0.0.12:
3916+
version "0.0.12"
3917+
resolved "https://registry.yarnpkg.com/critters/-/critters-0.0.12.tgz#32baa87526e053a41b67e19921673ed92264e2ab"
3918+
integrity sha512-ujxKtKc/mWpjrOKeaACTaQ1aP0O31M0ZPWhfl85jZF1smPU4Ivb9va5Ox2poif4zVJQQo0LCFlzGtEZAsCAPcw==
39193919
dependencies:
39203920
chalk "^4.1.0"
3921-
css "^3.0.0"
3921+
css-select "^4.1.3"
39223922
parse5 "^6.0.1"
39233923
parse5-htmlparser2-tree-adapter "^6.0.1"
3924+
postcss "^8.3.7"
39243925
pretty-bytes "^5.3.0"
39253926

39263927
cross-spawn@^6.0.0:
@@ -4036,6 +4037,17 @@ css-select@^3.1.2:
40364037
domutils "^2.4.3"
40374038
nth-check "^2.0.0"
40384039

4040+
css-select@^4.1.3:
4041+
version "4.1.3"
4042+
resolved "https://registry.yarnpkg.com/css-select/-/css-select-4.1.3.tgz#a70440f70317f2669118ad74ff105e65849c7067"
4043+
integrity sha512-gT3wBNd9Nj49rAbmtFHj1cljIAOLYSX1nZ8CB7TBO3INYckygm5B7LISU/szY//YmdiSLbJvDLOx9VnMVpMBxA==
4044+
dependencies:
4045+
boolbase "^1.0.0"
4046+
css-what "^5.0.0"
4047+
domhandler "^4.2.0"
4048+
domutils "^2.6.0"
4049+
nth-check "^2.0.0"
4050+
40394051
css-selector-tokenizer@^0.7.1:
40404052
version "0.7.3"
40414053
resolved "https://registry.yarnpkg.com/css-selector-tokenizer/-/css-selector-tokenizer-0.7.3.tgz#735f26186e67c749aaf275783405cf0661fae8f1"
@@ -4070,6 +4082,11 @@ css-what@^4.0.0:
40704082
resolved "https://registry.yarnpkg.com/css-what/-/css-what-4.0.0.tgz#35e73761cab2eeb3d3661126b23d7aa0e8432233"
40714083
integrity sha512-teijzG7kwYfNVsUh2H/YN62xW3KK9YhXEgSlbxMlcyjPNvdKJqFx5lrwlJgoFP1ZHlB89iGDlo/JyshKeRhv5A==
40724084

4085+
css-what@^5.0.0:
4086+
version "5.1.0"
4087+
resolved "https://registry.yarnpkg.com/css-what/-/css-what-5.1.0.tgz#3f7b707aadf633baf62c2ceb8579b545bb40f7fe"
4088+
integrity sha512-arSMRWIIFY0hV8pIxZMEfmMI47Wj3R/aWpZDDxWYCPEiOMv6tfOrnpDtgxBYPEQD4V0Y/958+1TdC3iWTFcUPw==
4089+
40734090
css@^2.0.0:
40744091
version "2.2.4"
40754092
resolved "https://registry.yarnpkg.com/css/-/css-2.2.4.tgz#c646755c73971f2bba6a601e2cf2fd71b1298929"
@@ -4080,15 +4097,6 @@ css@^2.0.0:
40804097
source-map-resolve "^0.5.2"
40814098
urix "^0.1.0"
40824099

4083-
css@^3.0.0:
4084-
version "3.0.0"
4085-
resolved "https://registry.yarnpkg.com/css/-/css-3.0.0.tgz#4447a4d58fdd03367c516ca9f64ae365cee4aa5d"
4086-
integrity sha512-DG9pFfwOrzc+hawpmqX/dHYHJG+Bsdb0klhyi1sDneOgGOXy9wQIC8hzyVp1e4NRYDBdxcylvywPkkXCHAzTyQ==
4087-
dependencies:
4088-
inherits "^2.0.4"
4089-
source-map "^0.6.1"
4090-
source-map-resolve "^0.6.0"
4091-
40924100
cssauron@^1.4.0:
40934101
version "1.4.0"
40944102
resolved "https://registry.yarnpkg.com/cssauron/-/cssauron-1.4.0.tgz#a6602dff7e04a8306dc0db9a551e92e8b5662ad8"
@@ -4663,6 +4671,15 @@ domutils@^2.4.3:
46634671
domelementtype "^2.2.0"
46644672
domhandler "^4.2.0"
46654673

4674+
domutils@^2.6.0:
4675+
version "2.8.0"
4676+
resolved "https://registry.yarnpkg.com/domutils/-/domutils-2.8.0.tgz#4437def5db6e2d1f5d6ee859bd95ca7d02048135"
4677+
integrity sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A==
4678+
dependencies:
4679+
dom-serializer "^1.0.1"
4680+
domelementtype "^2.2.0"
4681+
domhandler "^4.2.0"
4682+
46664683
dot-prop@^5.1.0, dot-prop@^5.2.0:
46674684
version "5.3.0"
46684685
resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-5.3.0.tgz#90ccce708cd9cd82cc4dc8c3ddd9abdd55b20e88"
@@ -8068,6 +8085,11 @@ nanoid@^3.1.23:
80688085
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.23.tgz#f744086ce7c2bc47ee0a8472574d5c78e4183a81"
80698086
integrity sha512-FiB0kzdP0FFVGDKlRLEQ1BgDzU87dy5NnzjeW9YZNt+/c3+q82EQDUwniSAUxp/F0gFNI1ZhKU1FqYsMuqZVnw==
80708087

8088+
nanoid@^3.1.30:
8089+
version "3.1.30"
8090+
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.30.tgz#63f93cc548d2a113dc5dfbc63bfa09e2b9b64362"
8091+
integrity sha512-zJpuPDwOv8D2zq2WRoMe1HsfZthVewpel9CAvTfc/2mBD1uUT/agc5f7GHGWXlYkFvi1mVxe4IjvP2HNrop7nQ==
8092+
80718093
nanomatch@^1.2.9:
80728094
version "1.2.13"
80738095
resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119"
@@ -9007,6 +9029,11 @@ performance-now@^2.1.0:
90079029
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
90089030
integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=
90099031

9032+
picocolors@^1.0.0:
9033+
version "1.0.0"
9034+
resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c"
9035+
integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==
9036+
90109037
picomatch@^2.0.4, picomatch@^2.0.5, picomatch@^2.2.1, picomatch@^2.2.2:
90119038
version "2.2.2"
90129039
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad"
@@ -9675,6 +9702,15 @@ postcss@^8.1.4:
96759702
nanoid "^3.1.20"
96769703
source-map "^0.6.1"
96779704

9705+
postcss@^8.3.7:
9706+
version "8.3.11"
9707+
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.3.11.tgz#c3beca7ea811cd5e1c4a3ec6d2e7599ef1f8f858"
9708+
integrity sha512-hCmlUAIlUiav8Xdqw3Io4LcpA1DOt7h3LSTAC4G6JGHFFaWzI6qvFt9oilvl8BmkbBRX1IhM90ZAmpk68zccQA==
9709+
dependencies:
9710+
nanoid "^3.1.30"
9711+
picocolors "^1.0.0"
9712+
source-map-js "^0.6.2"
9713+
96789714
prelude-ls@~1.1.2:
96799715
version "1.1.2"
96809716
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
@@ -10996,6 +11032,11 @@ source-list-map@^2.0.0, source-list-map@^2.0.1:
1099611032
resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.1.tgz#3993bd873bfc48479cca9ea3a547835c7c154b34"
1099711033
integrity sha512-qnQ7gVMxGNxsiL4lEuJwe/To8UnK7fAnmbGEEH8RpLouuKbeEm0lhbQVFIrNSuB+G7tVrAlVsZgETT5nljf+Iw==
1099811034

11035+
source-map-js@^0.6.2:
11036+
version "0.6.2"
11037+
resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-0.6.2.tgz#0bb5de631b41cfbda6cfba8bd05a80efdfd2385e"
11038+
integrity sha512-/3GptzWzu0+0MBQFrDKzw/DvvMTUORvgY6k6jd/VS6iCR4RDTKWH6v6WPwQoUO8667uQEf9Oe38DxAYWY5F/Ug==
11039+
1099911040
source-map-loader@1.1.3:
1100011041
version "1.1.3"
1100111042
resolved "https://registry.yarnpkg.com/source-map-loader/-/source-map-loader-1.1.3.tgz#7dbc2fe7ea09d3e43c51fd9fc478b7f016c1f820"

0 commit comments

Comments
 (0)
0