From 873d7d442a56574e2b262f2f5fbd8aa315b34785 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 17 Apr 2018 08:56:40 +0200 Subject: [PATCH] show preload and prefetch in stats --- lib/Stats.js | 17 ++++++++++++++++- test/statsCases/prefetch/expected.txt | 9 ++++++++- test/statsCases/prefetch/webpack.config.js | 3 ++- test/statsCases/preload/expected.txt | 9 ++++++++- test/statsCases/preload/webpack.config.js | 3 ++- 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/lib/Stats.js b/lib/Stats.js index 46945bdb8a3..485080fef26 100644 --- a/lib/Stats.js +++ b/lib/Stats.js @@ -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) { @@ -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 @@ -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) { diff --git a/test/statsCases/prefetch/expected.txt b/test/statsCases/prefetch/expected.txt index 79540b8d6b9..1c4aa09a03e 100644 --- a/test/statsCases/prefetch/expected.txt +++ b/test/statsCases/prefetch/expected.txt @@ -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) \ No newline at end of file +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] \ No newline at end of file diff --git a/test/statsCases/prefetch/webpack.config.js b/test/statsCases/prefetch/webpack.config.js index cfa206e3c0c..17dba56dbc3 100644 --- a/test/statsCases/prefetch/webpack.config.js +++ b/test/statsCases/prefetch/webpack.config.js @@ -4,6 +4,7 @@ module.exports = { stats: { all: false, assets: true, - entrypoints: true + entrypoints: true, + chunks: true } }; diff --git a/test/statsCases/preload/expected.txt b/test/statsCases/preload/expected.txt index 85ac239883b..75bf0ae9fa8 100644 --- a/test/statsCases/preload/expected.txt +++ b/test/statsCases/preload/expected.txt @@ -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) \ No newline at end of file +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] \ No newline at end of file diff --git a/test/statsCases/preload/webpack.config.js b/test/statsCases/preload/webpack.config.js index cfa206e3c0c..17dba56dbc3 100644 --- a/test/statsCases/preload/webpack.config.js +++ b/test/statsCases/preload/webpack.config.js @@ -4,6 +4,7 @@ module.exports = { stats: { all: false, assets: true, - entrypoints: true + entrypoints: true, + chunks: true } };