Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fair-forks-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"webpack-bundle-analyzer": patch
---

Explicitly define `stats.toJson()` options for bundle analysis to support Rspack 2.0 with minimal code changes needed.
38 changes: 35 additions & 3 deletions src/BundleAnalyzerPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Comment thread
SyMind marked this conversation as resolved.
depth: true,
entrypoints: true,
errors: false,
errorsCount: false,
ids: true,
modules: true,
modulesSpace: Number.POSITIVE_INFINITY,
nestedModules: true,
nestedModulesSpace: Number.POSITIVE_INFINITY,
Comment thread
SyMind marked this conversation as resolved.
runtimeModules: false,
source: false,
warnings: false,
warningsCount: false,
};
Comment thread
SyMind marked this conversation as resolved.

/**
* @typedef {object} Options
* @property {Mode=} analyzerMode analyzer mode
Expand Down Expand Up @@ -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)),
);
Comment thread
SyMind marked this conversation as resolved.
}

if (actions.length) {
Expand Down
Loading