Skip to content

Commit 8049c31

Browse files
committed
fix: request analyzer stats fields
1 parent a2ae1ef commit 8049c31

2 files changed

Lines changed: 40 additions & 3 deletions

File tree

.changeset/fair-forks-tap.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"webpack-bundle-analyzer": patch
3+
---
4+
5+
Ensure analyzer modes request the stats fields needed for bundle analysis.

src/BundleAnalyzerPlugin.js

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,32 @@ const viewer = require("./viewer");
3030
/** @typedef {string | (() => string)} ReportTitle */
3131
/** @typedef {(options: { listenHost: string, listenPort: number, boundAddress: string | AddressInfo | null }) => string} AnalyzerUrl */
3232

33+
/** @type {StatsOptions} */
34+
const analyzerStatsOptions = {
35+
all: false,
36+
assets: true,
37+
cachedAssets: true,
38+
cachedModules: true,
39+
cached: true,
40+
children: true,
41+
chunks: true,
42+
chunkModules: true,
43+
chunkModulesSpace: Number.POSITIVE_INFINITY,
44+
depth: true,
45+
entrypoints: true,
46+
errors: false,
47+
errorsCount: false,
48+
ids: true,
49+
modules: true,
50+
modulesSpace: Number.POSITIVE_INFINITY,
51+
nestedModules: true,
52+
nestedModulesSpace: Number.POSITIVE_INFINITY,
53+
runtimeModules: false,
54+
source: false,
55+
warnings: false,
56+
warningsCount: false,
57+
};
58+
3359
/**
3460
* @typedef {object} Options
3561
* @property {Mode=} analyzerMode analyzer mode
@@ -111,11 +137,17 @@ class BundleAnalyzerPlugin {
111137
}
112138

113139
if (this.opts.analyzerMode === "server") {
114-
actions.push(() => this.startAnalyzerServer(stats.toJson()));
140+
actions.push(() =>
141+
this.startAnalyzerServer(stats.toJson(analyzerStatsOptions)),
142+
);
115143
} else if (this.opts.analyzerMode === "static") {
116-
actions.push(() => this.generateStaticReport(stats.toJson()));
144+
actions.push(() =>
145+
this.generateStaticReport(stats.toJson(analyzerStatsOptions)),
146+
);
117147
} else if (this.opts.analyzerMode === "json") {
118-
actions.push(() => this.generateJSONReport(stats.toJson()));
148+
actions.push(() =>
149+
this.generateJSONReport(stats.toJson(analyzerStatsOptions)),
150+
);
119151
}
120152

121153
if (actions.length) {

0 commit comments

Comments
 (0)