Skip to content

Commit c65fb74

Browse files
authored
Merge pull request webpack#6736 from mc-zone/improvment/performance-falsy-at-non-web-target
Make the `performance` default to false while at non-web target. Close webpack#6715
2 parents 12b3751 + 2ecd323 commit c65fb74

File tree

4 files changed

+178
-11
lines changed

4 files changed

+178
-11
lines changed

lib/WebpackOptionsDefaulter.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ const isProductionLikeMode = options => {
1313
return options.mode === "production" || !options.mode;
1414
};
1515

16+
const isWebLikeTarget = options => {
17+
return options.target === "web" || options.target === "webworker";
18+
};
19+
1620
class WebpackOptionsDefaulter extends OptionsDefaulter {
1721
constructor() {
1822
super();
@@ -166,17 +170,14 @@ class WebpackOptionsDefaulter extends OptionsDefaulter {
166170
this.set("node.__filename", "mock");
167171
this.set("node.__dirname", "mock");
168172

169-
this.set(
170-
"performance",
171-
"make",
172-
options => (isProductionLikeMode(options) ? false : undefined)
173-
);
174-
this.set("performance", "call", value => {
175-
if (typeof value === "boolean") {
176-
return value;
177-
} else {
178-
return Object.assign({}, value);
179-
}
173+
this.set("performance", "call", (value, options) => {
174+
if (value === false) return false;
175+
if (
176+
value === undefined &&
177+
(!isProductionLikeMode(options) || !isWebLikeTarget(options))
178+
)
179+
return false;
180+
return Object.assign({}, value);
180181
});
181182
this.set("performance.maxAssetSize", 250000);
182183
this.set("performance.maxEntrypointSize", 250000);
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
Hash: df3a0090d24670ebd17d7094466a296a7ae4ae823f59070ac8deb95011d223ef01d5f7db6f7b0912f47482563c8b6b9dc4955fdf2e3a0c7c308a998f9bab5b59aa119495c443
2+
Child
3+
Hash: df3a0090d24670ebd17d
4+
Time: Xms
5+
Built at: Thu Jan 01 1970 00:00:00 GMT
6+
Asset Size Chunks Chunk Names
7+
warning.pro-web.js 296 KiB 0 [emitted] [big] main
8+
Entrypoint main [big] = warning.pro-web.js
9+
[0] ./index.js 293 KiB {0} [built]
10+
11+
WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
12+
This can impact web performance.
13+
Assets:
14+
warning.pro-web.js (296 KiB)
15+
16+
WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
17+
Entrypoints:
18+
main (296 KiB)
19+
warning.pro-web.js
20+
21+
22+
WARNING in webpack performance recommendations:
23+
You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application.
24+
For more info visit https://webpack.js.org/guides/code-splitting/
25+
Child
26+
Hash: 7094466a296a7ae4ae82
27+
Time: Xms
28+
Built at: Thu Jan 01 1970 00:00:00 GMT
29+
Asset Size Chunks Chunk Names
30+
warning.pro-webworker.js 296 KiB 0 [emitted] [big] main
31+
Entrypoint main [big] = warning.pro-webworker.js
32+
[0] ./index.js 293 KiB {0} [built]
33+
34+
WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
35+
This can impact web performance.
36+
Assets:
37+
warning.pro-webworker.js (296 KiB)
38+
39+
WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
40+
Entrypoints:
41+
main (296 KiB)
42+
warning.pro-webworker.js
43+
44+
45+
WARNING in webpack performance recommendations:
46+
You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application.
47+
For more info visit https://webpack.js.org/guides/code-splitting/
48+
Child
49+
Hash: 3f59070ac8deb95011d2
50+
Time: Xms
51+
Built at: Thu Jan 01 1970 00:00:00 GMT
52+
Asset Size Chunks Chunk Names
53+
no-warning.pro-node.js 296 KiB 0 [emitted] main
54+
Entrypoint main = no-warning.pro-node.js
55+
[0] ./index.js 293 KiB {0} [built]
56+
Child
57+
Hash: 23ef01d5f7db6f7b0912
58+
Time: Xms
59+
Built at: Thu Jan 01 1970 00:00:00 GMT
60+
Asset Size Chunks Chunk Names
61+
no-warning.dev-web.js 1.72 MiB main [emitted] main
62+
Entrypoint main = no-warning.dev-web.js
63+
[./index.js] 293 KiB {main} [built]
64+
Child
65+
Hash: f47482563c8b6b9dc495
66+
Time: Xms
67+
Built at: Thu Jan 01 1970 00:00:00 GMT
68+
Asset Size Chunks Chunk Names
69+
no-warning.dev-node.js 1.72 MiB main [emitted] main
70+
Entrypoint main = no-warning.dev-node.js
71+
[./index.js] 293 KiB {main} [built]
72+
Child
73+
Hash: 5fdf2e3a0c7c308a998f
74+
Time: Xms
75+
Built at: Thu Jan 01 1970 00:00:00 GMT
76+
Asset Size Chunks Chunk Names
77+
no-warning.dev-web-with-limit-set.js 1.72 MiB main [emitted] [big] main
78+
Entrypoint main [big] = no-warning.dev-web-with-limit-set.js
79+
[./index.js] 293 KiB {main} [built]
80+
Child
81+
Hash: 9bab5b59aa119495c443
82+
Time: Xms
83+
Built at: Thu Jan 01 1970 00:00:00 GMT
84+
Asset Size Chunks Chunk Names
85+
warning.pro-node-with-hints-set.js 296 KiB 0 [emitted] [big] main
86+
Entrypoint main [big] = warning.pro-node-with-hints-set.js
87+
[0] ./index.js 293 KiB {0} [built]
88+
89+
WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
90+
This can impact web performance.
91+
Assets:
92+
warning.pro-node-with-hints-set.js (296 KiB)
93+
94+
WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
95+
Entrypoints:
96+
main (296 KiB)
97+
warning.pro-node-with-hints-set.js
98+
99+
100+
WARNING in webpack performance recommendations:
101+
You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application.
102+
For more info visit https://webpack.js.org/guides/code-splitting/
Binary file not shown.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
module.exports = [
2+
{
3+
entry: "./index",
4+
mode: "production",
5+
target: "web",
6+
output: {
7+
filename: "warning.pro-web.js"
8+
}
9+
},
10+
{
11+
entry: "./index",
12+
mode: "production",
13+
target: "webworker",
14+
output: {
15+
filename: "warning.pro-webworker.js"
16+
}
17+
},
18+
{
19+
entry: "./index",
20+
mode: "production",
21+
target: "node",
22+
output: {
23+
filename: "no-warning.pro-node.js"
24+
}
25+
},
26+
{
27+
entry: "./index",
28+
mode: "development",
29+
target: "web",
30+
output: {
31+
filename: "no-warning.dev-web.js"
32+
}
33+
},
34+
{
35+
entry: "./index",
36+
mode: "development",
37+
target: "node",
38+
output: {
39+
filename: "no-warning.dev-node.js"
40+
}
41+
},
42+
{
43+
entry: "./index",
44+
mode: "development",
45+
target: "web",
46+
performance: {
47+
maxAssetSize: 100
48+
},
49+
output: {
50+
filename: "no-warning.dev-web-with-limit-set.js"
51+
}
52+
},
53+
{
54+
entry: "./index",
55+
mode: "production",
56+
target: "node",
57+
performance: {
58+
hints: "warning"
59+
},
60+
output: {
61+
filename: "warning.pro-node-with-hints-set.js"
62+
}
63+
}
64+
];

0 commit comments

Comments
 (0)