diff --git a/.changeset/fair-forks-tap.md b/.changeset/fair-forks-tap.md new file mode 100644 index 00000000..9df8a8cb --- /dev/null +++ b/.changeset/fair-forks-tap.md @@ -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. 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) {