Skip to content

Commit 873d7d4

Browse files
committed
show preload and prefetch in stats
1 parent 3417da5 commit 873d7d4

File tree

5 files changed

+36
-5
lines changed

5 files changed

+36
-5
lines changed

lib/Stats.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@ class Stats {
546546
const parents = new Set();
547547
const children = new Set();
548548
const siblings = new Set();
549+
const childIdByOrder = chunk.getChildIdsByOrders();
549550
for (const chunkGroup of chunk.groupsIterable) {
550551
for (const parentGroup of chunkGroup.parentsIterable) {
551552
for (const chunk of parentGroup.chunks) {
@@ -574,7 +575,8 @@ class Stats {
574575
hash: chunk.renderedHash,
575576
siblings: Array.from(siblings).sort(),
576577
parents: Array.from(parents).sort(),
577-
children: Array.from(children).sort()
578+
children: Array.from(children).sort(),
579+
childrenByOrder: childIdByOrder
578580
};
579581
if (showChunkModules) {
580582
obj.modules = chunk
@@ -1142,6 +1144,19 @@ class Stats {
11421144
colors.yellow(id);
11431145
colors.normal("}<");
11441146
}
1147+
if (chunk.childrenByOrder) {
1148+
for (const name of Object.keys(chunk.childrenByOrder)) {
1149+
const children = chunk.childrenByOrder[name];
1150+
colors.normal(" ");
1151+
colors.magenta(`(${name}:`);
1152+
for (const id of children) {
1153+
colors.normal(" {");
1154+
colors.yellow(id);
1155+
colors.normal("}");
1156+
}
1157+
colors.magenta(")");
1158+
}
1159+
}
11451160
if (chunk.entry) {
11461161
colors.yellow(" [entry]");
11471162
} else if (chunk.initial) {

test/statsCases/prefetch/expected.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,11 @@ prefetched3.js 130 bytes 3 [emitted] prefetched3
66
main.js 9.69 KiB 4 [emitted] main
77
inner.js 136 bytes 5 [emitted] inner
88
inner2.js 201 bytes 6 [emitted] inner2
9-
Entrypoint main = main.js (prefetch: prefetched2.js prefetched.js prefetched3.js)
9+
Entrypoint main = main.js (prefetch: prefetched2.js prefetched.js prefetched3.js)
10+
chunk {0} prefetched.js (prefetched) 228 bytes <{4}> >{5}< >{6}< (prefetch: {6} {5}) [rendered]
11+
chunk {1} normal.js (normal) 0 bytes <{4}> [rendered]
12+
chunk {2} prefetched2.js (prefetched2) 0 bytes <{4}> [rendered]
13+
chunk {3} prefetched3.js (prefetched3) 0 bytes <{4}> [rendered]
14+
chunk {4} main.js (main) 436 bytes >{0}< >{1}< >{2}< >{3}< (prefetch: {2} {0} {3}) [entry] [rendered]
15+
chunk {5} inner.js (inner) 0 bytes <{0}> [rendered]
16+
chunk {6} inner2.js (inner2) 0 bytes <{0}> [rendered]

test/statsCases/prefetch/webpack.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module.exports = {
44
stats: {
55
all: false,
66
assets: true,
7-
entrypoints: true
7+
entrypoints: true,
8+
chunks: true
89
}
910
};

test/statsCases/preload/expected.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,11 @@ preloaded3.js 130 bytes 3 [emitted] preloaded3
66
main.js 9.81 KiB 4 [emitted] main
77
inner.js 136 bytes 5 [emitted] inner
88
inner2.js 201 bytes 6 [emitted] inner2
9-
Entrypoint main = main.js (preload: preloaded2.js preloaded.js preloaded3.js)
9+
Entrypoint main = main.js (preload: preloaded2.js preloaded.js preloaded3.js)
10+
chunk {0} preloaded.js (preloaded) 226 bytes <{4}> >{5}< >{6}< (preload: {6} {5}) [rendered]
11+
chunk {1} normal.js (normal) 0 bytes <{4}> [rendered]
12+
chunk {2} preloaded2.js (preloaded2) 0 bytes <{4}> [rendered]
13+
chunk {3} preloaded3.js (preloaded3) 0 bytes <{4}> [rendered]
14+
chunk {4} main.js (main) 424 bytes >{0}< >{1}< >{2}< >{3}< (preload: {2} {0} {3}) [entry] [rendered]
15+
chunk {5} inner.js (inner) 0 bytes <{0}> [rendered]
16+
chunk {6} inner2.js (inner2) 0 bytes <{0}> [rendered]

test/statsCases/preload/webpack.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module.exports = {
44
stats: {
55
all: false,
66
assets: true,
7-
entrypoints: true
7+
entrypoints: true,
8+
chunks: true
89
}
910
};

0 commit comments

Comments
 (0)