diff --git a/packages/next-bundle-analyzer/index.d.ts b/packages/next-bundle-analyzer/index.d.ts index 5a97ee9b5be4b..d76b617c1f4fe 100644 --- a/packages/next-bundle-analyzer/index.d.ts +++ b/packages/next-bundle-analyzer/index.d.ts @@ -1,8 +1,9 @@ import type { NextConfig } from 'next' -declare const NextBundleAnalyzer = - (options?: { enabled?: boolean; openAnalyzer?: boolean }) => - (config?: NextConfig) => - NextConfig +declare function NextBundleAnalyzer(options?: { + enabled?: boolean + openAnalyzer?: boolean + analyzerMode?: 'json' | 'static' +}): (config?: NextConfig) => NextConfig export = NextBundleAnalyzer diff --git a/packages/next-bundle-analyzer/index.js b/packages/next-bundle-analyzer/index.js index ddcdbf1cff73c..e44e2ccf5c82a 100644 --- a/packages/next-bundle-analyzer/index.js +++ b/packages/next-bundle-analyzer/index.js @@ -1,5 +1,5 @@ module.exports = - ({ enabled = true, openAnalyzer = true } = {}) => + ({ enabled = true, openAnalyzer, analyzerMode } = {}) => (nextConfig = {}) => { return Object.assign({}, nextConfig, { webpack(config, options) { @@ -7,7 +7,7 @@ module.exports = const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer') config.plugins.push( new BundleAnalyzerPlugin({ - analyzerMode: 'static', + analyzerMode: analyzerMode || 'static', openAnalyzer, reportFilename: !options.nextRuntime ? `./analyze/client.html`