From 8049c3123a1fb3cebc2f408561aa4d6e2b8d74c3 Mon Sep 17 00:00:00 2001 From: Cong-Cong Pan Date: Fri, 12 Jun 2026 15:18:08 +0800 Subject: [PATCH 1/2] fix: request analyzer stats fields --- .changeset/fair-forks-tap.md | 5 +++++ src/BundleAnalyzerPlugin.js | 38 +++++++++++++++++++++++++++++++++--- 2 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 .changeset/fair-forks-tap.md diff --git a/.changeset/fair-forks-tap.md b/.changeset/fair-forks-tap.md new file mode 100644 index 00000000..2cc014fd --- /dev/null +++ b/.changeset/fair-forks-tap.md @@ -0,0 +1,5 @@ +--- +"webpack-bundle-analyzer": patch +--- + +Ensure analyzer modes request the stats fields needed for bundle analysis. diff --git a/src/BundleAnalyzerPlugin.js b/src/BundleAnalyzerPlugin.js index c682ad7e..3dada6fb 100644 --- a/src/BundleAnalyzerPlugin.js +++ b/src/BundleAnalyzerPlugin.js @@ -30,6 +30,32 @@ const viewer = require("./viewer"); /** @typedef {string | (() => string)} ReportTitle */ /** @typedef {(options: { listenHost: string, listenPort: number, boundAddress: string | AddressInfo | null }) => string} AnalyzerUrl */ +/** @type {StatsOptions} */ +const analyzerStatsOptions = { + all: false, + assets: true, + cachedAssets: true, + cachedModules: true, + cached: true, + children: true, + chunks: true, + chunkModules: true, + chunkModulesSpace: Number.POSITIVE_INFINITY, + depth: true, + entrypoints: true, + errors: false, + errorsCount: false, + ids: true, + modules: true, + modulesSpace: Number.POSITIVE_INFINITY, + nestedModules: true, + nestedModulesSpace: Number.POSITIVE_INFINITY, + runtimeModules: false, + source: false, + warnings: false, + warningsCount: false, +}; + /** * @typedef {object} Options * @property {Mode=} analyzerMode analyzer mode @@ -111,11 +137,17 @@ class BundleAnalyzerPlugin { } if (this.opts.analyzerMode === "server") { - actions.push(() => this.startAnalyzerServer(stats.toJson())); + actions.push(() => + this.startAnalyzerServer(stats.toJson(analyzerStatsOptions)), + ); } else if (this.opts.analyzerMode === "static") { - actions.push(() => this.generateStaticReport(stats.toJson())); + actions.push(() => + this.generateStaticReport(stats.toJson(analyzerStatsOptions)), + ); } else if (this.opts.analyzerMode === "json") { - actions.push(() => this.generateJSONReport(stats.toJson())); + actions.push(() => + this.generateJSONReport(stats.toJson(analyzerStatsOptions)), + ); } if (actions.length) { From 11af9228b3344ce5d28c56518bc1440f181723bc Mon Sep 17 00:00:00 2001 From: Vesa Laakso <482561+valscion@users.noreply.github.com> Date: Mon, 15 Jun 2026 10:52:58 +0300 Subject: [PATCH 2/2] Update stats options for bundle analysis in Rspack 2.0 Explicitly define `stats.toJson()` options for bundle analysis to support Rspack 2.0 with minimal code changes needed. --- .changeset/fair-forks-tap.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/fair-forks-tap.md b/.changeset/fair-forks-tap.md index 2cc014fd..9df8a8cb 100644 --- a/.changeset/fair-forks-tap.md +++ b/.changeset/fair-forks-tap.md @@ -2,4 +2,4 @@ "webpack-bundle-analyzer": patch --- -Ensure analyzer modes request the stats fields needed for bundle analysis. +Explicitly define `stats.toJson()` options for bundle analysis to support Rspack 2.0 with minimal code changes needed.