Skip to content

Commit

Permalink
show preload and prefetch in stats
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Apr 17, 2018
1 parent 3417da5 commit 873d7d4
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 5 deletions.
17 changes: 16 additions & 1 deletion lib/Stats.js
Expand Up @@ -546,6 +546,7 @@ class Stats {
const parents = new Set();
const children = new Set();
const siblings = new Set();
const childIdByOrder = chunk.getChildIdsByOrders();
for (const chunkGroup of chunk.groupsIterable) {
for (const parentGroup of chunkGroup.parentsIterable) {
for (const chunk of parentGroup.chunks) {
Expand Down Expand Up @@ -574,7 +575,8 @@ class Stats {
hash: chunk.renderedHash,
siblings: Array.from(siblings).sort(),
parents: Array.from(parents).sort(),
children: Array.from(children).sort()
children: Array.from(children).sort(),
childrenByOrder: childIdByOrder
};
if (showChunkModules) {
obj.modules = chunk
Expand Down Expand Up @@ -1142,6 +1144,19 @@ class Stats {
colors.yellow(id);
colors.normal("}<");
}
if (chunk.childrenByOrder) {
for (const name of Object.keys(chunk.childrenByOrder)) {
const children = chunk.childrenByOrder[name];
colors.normal(" ");
colors.magenta(`(${name}:`);
for (const id of children) {
colors.normal(" {");
colors.yellow(id);
colors.normal("}");
}
colors.magenta(")");
}
}
if (chunk.entry) {
colors.yellow(" [entry]");
} else if (chunk.initial) {
Expand Down
9 changes: 8 additions & 1 deletion test/statsCases/prefetch/expected.txt
Expand Up @@ -6,4 +6,11 @@ prefetched3.js 130 bytes 3 [emitted] prefetched3
main.js 9.69 KiB 4 [emitted] main
inner.js 136 bytes 5 [emitted] inner
inner2.js 201 bytes 6 [emitted] inner2
Entrypoint main = main.js (prefetch: prefetched2.js prefetched.js prefetched3.js)
Entrypoint main = main.js (prefetch: prefetched2.js prefetched.js prefetched3.js)
chunk {0} prefetched.js (prefetched) 228 bytes <{4}> >{5}< >{6}< (prefetch: {6} {5}) [rendered]
chunk {1} normal.js (normal) 0 bytes <{4}> [rendered]
chunk {2} prefetched2.js (prefetched2) 0 bytes <{4}> [rendered]
chunk {3} prefetched3.js (prefetched3) 0 bytes <{4}> [rendered]
chunk {4} main.js (main) 436 bytes >{0}< >{1}< >{2}< >{3}< (prefetch: {2} {0} {3}) [entry] [rendered]
chunk {5} inner.js (inner) 0 bytes <{0}> [rendered]
chunk {6} inner2.js (inner2) 0 bytes <{0}> [rendered]
3 changes: 2 additions & 1 deletion test/statsCases/prefetch/webpack.config.js
Expand Up @@ -4,6 +4,7 @@ module.exports = {
stats: {
all: false,
assets: true,
entrypoints: true
entrypoints: true,
chunks: true
}
};
9 changes: 8 additions & 1 deletion test/statsCases/preload/expected.txt
Expand Up @@ -6,4 +6,11 @@ preloaded3.js 130 bytes 3 [emitted] preloaded3
main.js 9.81 KiB 4 [emitted] main
inner.js 136 bytes 5 [emitted] inner
inner2.js 201 bytes 6 [emitted] inner2
Entrypoint main = main.js (preload: preloaded2.js preloaded.js preloaded3.js)
Entrypoint main = main.js (preload: preloaded2.js preloaded.js preloaded3.js)
chunk {0} preloaded.js (preloaded) 226 bytes <{4}> >{5}< >{6}< (preload: {6} {5}) [rendered]
chunk {1} normal.js (normal) 0 bytes <{4}> [rendered]
chunk {2} preloaded2.js (preloaded2) 0 bytes <{4}> [rendered]
chunk {3} preloaded3.js (preloaded3) 0 bytes <{4}> [rendered]
chunk {4} main.js (main) 424 bytes >{0}< >{1}< >{2}< >{3}< (preload: {2} {0} {3}) [entry] [rendered]
chunk {5} inner.js (inner) 0 bytes <{0}> [rendered]
chunk {6} inner2.js (inner2) 0 bytes <{0}> [rendered]
3 changes: 2 additions & 1 deletion test/statsCases/preload/webpack.config.js
Expand Up @@ -4,6 +4,7 @@ module.exports = {
stats: {
all: false,
assets: true,
entrypoints: true
entrypoints: true,
chunks: true
}
};

0 comments on commit 873d7d4

Please sign in to comment.