Skip to content

Commit cbe2f06

Browse files
TheLarkInnsokra
authored andcommitted
feat(perf): added initial setup for perf plugins, need to configure test cases and stats output based on perf props
1 parent 52bfdab commit cbe2f06

32 files changed

Lines changed: 504 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
MIT License http://www.opensource.org/licenses/mit-license.php
3+
Author Sean Larkin @thelarkinn
4+
*/
5+
var EmittedAssetSizeWarningPlugin = require('./EmittedAssetSizeWarningPlugin.js');
6+
7+
function EmittedAssetSizeLimitPlugin(performanceOptions) {
8+
this.maxAssetSize = performanceOptions.maxAssetSize;
9+
this.hints = performanceOptions.hints;
10+
}
11+
12+
module.exports = EmittedAssetSizeLimitPlugin;
13+
14+
EmittedAssetSizeLimitPlugin.prototype.apply = function(compiler) {
15+
var sizeLimit = this.maxAssetSize;
16+
var hints = this.hints;
17+
compiler.plugin("after-emit", function(compilation, callback) {
18+
for (var asset in compilation.assets) {
19+
if (sizeLimit < compilation.assets[asset].size() && hints) {
20+
compilation.warnings.push(new Error("EmmittedAssetSizeWarning: " + "This asset exceeds " + sizeLimit + "kB. Consider reducing the size for optimal web performance."));
21+
}
22+
}
23+
24+
callback();
25+
});
26+
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
MIT License http://www.opensource.org/licenses/mit-license.php
3+
Author Sean Larkin @thelarkinn
4+
*/
5+
function EmittedAssetSizeWarningPlugin(warningMessage) {
6+
this.warningMessage = warningMessage;
7+
debugger;
8+
}
9+
module.exports = EmittedAssetSizeWarningPlugin;
10+
11+
EmittedAssetSizeWarningPlugin.prototype.apply = function(compiler) {
12+
compiler.plugin("compilation", function(compilation) {
13+
debugger;
14+
compilation.warnings.push(new Error("EmmittedAssetSizeWarning: " + this.warningMessage));
15+
16+
});
17+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = function a() {
2+
return "This is a";
3+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = function b() {
2+
require("./a");
3+
return "This is c";
4+
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Hash: 8e46421d7f7a7d266a00
2+
Time: Xms
3+
Asset Size Chunks Chunk Names
4+
48c8b1dae03a37363ec8.js 4.17 kB 1 [emitted]
5+
2fa7af5012a3d8b778dd.js 2.22 kB 2 [emitted]
6+
a5b577236621262c2bcf.js 1.93 kB 3 [emitted]
7+
88d78642a86768757078.js 977 bytes 4 [emitted]
8+
Entrypoint main = 48c8b1dae03a37363ec8.js a5b577236621262c2bcf.js 88d78642a86768757078.js 2fa7af5012a3d8b778dd.js
9+
chunk {1} 48c8b1dae03a37363ec8.js 1.8 kB [entry] [rendered]
10+
> aggressive-splitted main [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js
11+
[0] (webpack)/test/statsCases/aggressive-splitting-entry/b.js 899 bytes {1} [built]
12+
[1] (webpack)/test/statsCases/aggressive-splitting-entry/c.js 899 bytes {1} [built]
13+
chunk {2} 2fa7af5012a3d8b778dd.js 1.91 kB [initial] [rendered]
14+
> aggressive-splitted main [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js
15+
[4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js 112 bytes {2} [built]
16+
[6] (webpack)/test/statsCases/aggressive-splitting-entry/f.js 899 bytes {2} [built]
17+
[7] (webpack)/test/statsCases/aggressive-splitting-entry/g.js 899 bytes {2} [built]
18+
chunk {3} a5b577236621262c2bcf.js 1.8 kB [initial] [rendered] [recorded]
19+
> aggressive-splitted main [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js
20+
[2] (webpack)/test/statsCases/aggressive-splitting-entry/d.js 899 bytes {3} [built]
21+
[5] (webpack)/test/statsCases/aggressive-splitting-entry/a.js 899 bytes {3} [built]
22+
chunk {4} 88d78642a86768757078.js 899 bytes [initial] [rendered]
23+
> aggressive-splitted main [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js
24+
[3] (webpack)/test/statsCases/aggressive-splitting-entry/e.js 899 bytes {4} [built]
25+
26+
WARNING in EmmittedAssetSizeWarning: This asset exceeds 250kB. Consider reducing the size for optimal web performance.
27+
28+
WARNING in EmmittedAssetSizeWarning: This asset exceeds 250kB. Consider reducing the size for optimal web performance.
29+
30+
WARNING in EmmittedAssetSizeWarning: This asset exceeds 250kB. Consider reducing the size for optimal web performance.
31+
32+
WARNING in EmmittedAssetSizeWarning: This asset exceeds 250kB. Consider reducing the size for optimal web performance.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
Hash: a562f01542f9b2e2ad89
2+
Time: Xms
3+
Asset Size Chunks Chunk Names
4+
7434ce273df5c166f742.js 1.93 kB 0 [emitted]
5+
11324f155de813ceb658.js 1.95 kB 1 [emitted]
6+
5ae9e18455b866684bd0.js 1.94 kB 2 [emitted]
7+
e91ec4902ca3057b42bb.js 1.93 kB 3 [emitted]
8+
0947f0875d56ab0bfe02.js 977 bytes 4 [emitted]
9+
6335d9dcc7fa048743b7.js 7.15 kB 6 [emitted] main
10+
cf500be0e585f01d2ccb.js 983 bytes 9 [emitted]
11+
a7bfb642a544b4302cc4.js 975 bytes 11 [emitted]
12+
Entrypoint main = 6335d9dcc7fa048743b7.js
13+
chunk {0} 7434ce273df5c166f742.js 1.8 kB {6} [recorded]
14+
> aggressive-splitted duplicate [9] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 4:0-51
15+
> aggressive-splitted duplicate [9] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 5:0-44
16+
> aggressive-splitted duplicate [9] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 6:0-72
17+
[5] (webpack)/test/statsCases/aggressive-splitting-on-demand/f.js 899 bytes {0} [built]
18+
[6] (webpack)/test/statsCases/aggressive-splitting-on-demand/g.js 901 bytes {0} [built]
19+
chunk {1} 11324f155de813ceb658.js 1.8 kB {6}
20+
> aggressive-splitted duplicate [9] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 3:0-30
21+
> aggressive-splitted duplicate [9] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 5:0-44
22+
> aggressive-splitted duplicate [9] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 6:0-72
23+
[3] (webpack)/test/statsCases/aggressive-splitting-on-demand/d.js 899 bytes {1} [built]
24+
[4] (webpack)/test/statsCases/aggressive-splitting-on-demand/e.js 899 bytes {1} [built]
25+
chunk {2} 5ae9e18455b866684bd0.js 1.8 kB {6} [recorded]
26+
> aggressive-splitted duplicate [9] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 4:0-51
27+
> aggressive-splitted duplicate [9] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 6:0-72
28+
[10] (webpack)/test/statsCases/aggressive-splitting-on-demand/j.js 901 bytes {2} [built]
29+
[11] (webpack)/test/statsCases/aggressive-splitting-on-demand/k.js 899 bytes {2} [built]
30+
chunk {3} e91ec4902ca3057b42bb.js 1.8 kB {6}
31+
> aggressive-splitted duplicate [9] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 4:0-51
32+
> aggressive-splitted duplicate [9] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 6:0-72
33+
[7] (webpack)/test/statsCases/aggressive-splitting-on-demand/h.js 899 bytes {3} [built]
34+
[8] (webpack)/test/statsCases/aggressive-splitting-on-demand/i.js 899 bytes {3} [built]
35+
chunk {4} 0947f0875d56ab0bfe02.js 899 bytes {6} [rendered]
36+
> aggressive-splitted duplicate [9] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 2:0-23
37+
> aggressive-splitted duplicate [9] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 3:0-30
38+
[2] (webpack)/test/statsCases/aggressive-splitting-on-demand/c.js 899 bytes {4} [built]
39+
chunk {6} 6335d9dcc7fa048743b7.js (main) 248 bytes [entry] [rendered]
40+
> main [9] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js
41+
[9] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 248 bytes {6} [built]
42+
chunk {9} cf500be0e585f01d2ccb.js 899 bytes {6}
43+
> aggressive-splitted duplicate [9] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 2:0-23
44+
> aggressive-splitted duplicate [9] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 5:0-44
45+
> aggressive-splitted duplicate [9] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 6:0-72
46+
[1] (webpack)/test/statsCases/aggressive-splitting-on-demand/b.js 899 bytes {9} [built]
47+
chunk {11} a7bfb642a544b4302cc4.js 899 bytes {6}
48+
> [9] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 1:0-16
49+
[0] (webpack)/test/statsCases/aggressive-splitting-on-demand/a.js 899 bytes {11} [built]
50+
51+
WARNING in EmmittedAssetSizeWarning: This asset exceeds 250kB. Consider reducing the size for optimal web performance.
52+
53+
WARNING in EmmittedAssetSizeWarning: This asset exceeds 250kB. Consider reducing the size for optimal web performance.
54+
55+
WARNING in EmmittedAssetSizeWarning: This asset exceeds 250kB. Consider reducing the size for optimal web performance.
56+
57+
WARNING in EmmittedAssetSizeWarning: This asset exceeds 250kB. Consider reducing the size for optimal web performance.
58+
59+
WARNING in EmmittedAssetSizeWarning: This asset exceeds 250kB. Consider reducing the size for optimal web performance.
60+
61+
WARNING in EmmittedAssetSizeWarning: This asset exceeds 250kB. Consider reducing the size for optimal web performance.
62+
63+
WARNING in EmmittedAssetSizeWarning: This asset exceeds 250kB. Consider reducing the size for optimal web performance.
64+
65+
WARNING in EmmittedAssetSizeWarning: This asset exceeds 250kB. Consider reducing the size for optimal web performance.

test/statsCases/chunks/actual.txt

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
Hash: 160bbe49f674da1a2284
2+
Time: Xms
3+
Asset Size Chunks Chunk Names
4+
0.bundle.js 251 bytes 0 [emitted]
5+
1.bundle.js 106 bytes 1 [emitted]
6+
2.bundle.js 200 bytes 2 [emitted]
7+
bundle.js 5.7 kB 3 [emitted] main
8+
chunk {0} 0.bundle.js 54 bytes {3} [rendered]
9+
> [5] (webpack)/test/statsCases/chunks/index.js 3:0-16
10+
[2] (webpack)/test/statsCases/chunks/c.js 54 bytes {0} [built]
11+
amd require ./c [5] (webpack)/test/statsCases/chunks/index.js 3:0-16
12+
[] -> factory:Xms building:Xms = Xms
13+
chunk {1} 1.bundle.js 22 bytes {3} [rendered]
14+
> [5] (webpack)/test/statsCases/chunks/index.js 2:0-16
15+
[1] (webpack)/test/statsCases/chunks/b.js 22 bytes {1} [built]
16+
amd require ./b [5] (webpack)/test/statsCases/chunks/index.js 2:0-16
17+
[] -> factory:Xms building:Xms = Xms
18+
chunk {2} 2.bundle.js 44 bytes {0} [rendered]
19+
> [2] (webpack)/test/statsCases/chunks/c.js 1:0-52
20+
[3] (webpack)/test/statsCases/chunks/d.js 22 bytes {2} [built]
21+
require.ensure item ./d [2] (webpack)/test/statsCases/chunks/c.js 1:0-52
22+
[] -> factory:Xms building:Xms = Xms
23+
[4] (webpack)/test/statsCases/chunks/e.js 22 bytes {2} [built]
24+
require.ensure item ./e [2] (webpack)/test/statsCases/chunks/c.js 1:0-52
25+
[] -> factory:Xms building:Xms = Xms
26+
chunk {3} bundle.js (main) 73 bytes [entry] [rendered]
27+
> main [5] (webpack)/test/statsCases/chunks/index.js
28+
[0] (webpack)/test/statsCases/chunks/a.js 22 bytes {3} [built]
29+
cjs require ./a [5] (webpack)/test/statsCases/chunks/index.js 1:0-14
30+
[] -> factory:Xms building:Xms = Xms
31+
[5] (webpack)/test/statsCases/chunks/index.js 51 bytes {3} [built]
32+
factory:Xms building:Xms = Xms
33+
[0] (webpack)/test/statsCases/chunks/a.js 22 bytes {3} [built]
34+
cjs require ./a [5] (webpack)/test/statsCases/chunks/index.js 1:0-14
35+
[] -> factory:Xms building:Xms = Xms
36+
[1] (webpack)/test/statsCases/chunks/b.js 22 bytes {1} [built]
37+
amd require ./b [5] (webpack)/test/statsCases/chunks/index.js 2:0-16
38+
[] -> factory:Xms building:Xms = Xms
39+
[2] (webpack)/test/statsCases/chunks/c.js 54 bytes {0} [built]
40+
amd require ./c [5] (webpack)/test/statsCases/chunks/index.js 3:0-16
41+
[] -> factory:Xms building:Xms = Xms
42+
[3] (webpack)/test/statsCases/chunks/d.js 22 bytes {2} [built]
43+
require.ensure item ./d [2] (webpack)/test/statsCases/chunks/c.js 1:0-52
44+
[] -> factory:Xms building:Xms = Xms
45+
[4] (webpack)/test/statsCases/chunks/e.js 22 bytes {2} [built]
46+
require.ensure item ./e [2] (webpack)/test/statsCases/chunks/c.js 1:0-52
47+
[] -> factory:Xms building:Xms = Xms
48+
[5] (webpack)/test/statsCases/chunks/index.js 51 bytes {3} [built]
49+
factory:Xms building:Xms = Xms
50+
51+
WARNING in EmmittedAssetSizeWarning: This asset exceeds 250kB. Consider reducing the size for optimal web performance.
52+
53+
WARNING in EmmittedAssetSizeWarning: This asset exceeds 250kB. Consider reducing the size for optimal web performance.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Hash: 6c781fe6bf412ba6435b
2+
Time: Xms
3+
Asset Size Chunks Chunk Names
4+
main.js 2.43 kB 0 [emitted] main
5+
chunk {0} main.js (main) 0 bytes [entry] [rendered]
6+
[0] (webpack)/test/statsCases/color-disabled/index.js 0 bytes {0} [built]
7+
8+
WARNING in EmmittedAssetSizeWarning: This asset exceeds 250kB. Consider reducing the size for optimal web performance.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Hash: <CLR=BOLD>6c781fe6bf412ba6435b</CLR>
2+
Time: <CLR=BOLD>X</CLR>ms
3+
<CLR=BOLD>Asset</CLR> <CLR=BOLD>Size</CLR> <CLR=BOLD>Chunks</CLR> <CLR=39,BOLD><CLR=22> <CLR=BOLD>Chunk Names</CLR>
4+
<CLR=32>main.js</CLR> 2.43 kB <CLR=BOLD>0</CLR> <CLR=32>[emitted]</CLR> main
5+
chunk {<CLR=33>0</CLR>} <CLR=32>main.js</CLR> (main) 0 bytes<CLR=33> [entry]</CLR><CLR=32> [rendered]</CLR>
6+
[0] <CLR=BOLD>(webpack)/test/statsCases/color-enabled-custom/index.js</CLR> 0 bytes {<CLR=33>0</CLR>}<CLR=32> [built]</CLR>
7+
8+
<CLR=33>WARNING in EmmittedAssetSizeWarning: This asset exceeds 250kB. Consider reducing the size for optimal web performance.</CLR>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Hash: <CLR=BOLD>6c781fe6bf412ba6435b</CLR>
2+
Time: <CLR=BOLD>X</CLR>ms
3+
<CLR=BOLD>Asset</CLR> <CLR=BOLD>Size</CLR> <CLR=BOLD>Chunks</CLR> <CLR=39,BOLD><CLR=22> <CLR=BOLD>Chunk Names</CLR>
4+
<CLR=32,BOLD>main.js</CLR> 2.43 kB <CLR=BOLD>0</CLR> <CLR=32,BOLD>[emitted]</CLR> main
5+
chunk {<CLR=33,BOLD>0</CLR>} <CLR=32,BOLD>main.js</CLR> (main) 0 bytes<CLR=33,BOLD> [entry]</CLR><CLR=32,BOLD> [rendered]</CLR>
6+
[0] <CLR=BOLD>(webpack)/test/statsCases/color-enabled/index.js</CLR> 0 bytes {<CLR=33,BOLD>0</CLR>}<CLR=32,BOLD> [built]</CLR>
7+
8+
<CLR=33,BOLD>WARNING in EmmittedAssetSizeWarning: This asset exceeds 250kB. Consider reducing the size for optimal web performance.</CLR>

0 commit comments

Comments
 (0)