From ea0f5163b03d56134ebf121d5acf72b20abee30c Mon Sep 17 00:00:00 2001 From: Sean O'Neil <59893658+sean-rallycry@users.noreply.github.com> Date: Fri, 19 Apr 2024 15:43:26 -0500 Subject: [PATCH] Update 06-bundle-analyzer.mdx (#64740) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The[ existing code example](https://nextjs.org/docs/app/building-your-application/optimizing/bundle-analyzer) generates the following warning when using `--turbo` in the current latest version of NextJS (14.2.2): ⚠ Webpack is configured while Turbopack is not, which may cause problems. ⚠ See instructions if you need to configure Turbopack: https://nextjs.org/docs/app/api-reference/next-config-js/turbo This modification ensures that the bundle analyzer is only applied when the user intends to generate a report. Fixes # https://github.com/vercel/next.js/issues/64739 --------- Co-authored-by: Lee Robinson Co-authored-by: Maxim Svetlakov Co-authored-by: JJ Kasper --- .../06-optimizing/06-bundle-analyzer.mdx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/02-app/01-building-your-application/06-optimizing/06-bundle-analyzer.mdx b/docs/02-app/01-building-your-application/06-optimizing/06-bundle-analyzer.mdx index 3a71bb1a8ce46..cb46ac5470fbe 100644 --- a/docs/02-app/01-building-your-application/06-optimizing/06-bundle-analyzer.mdx +++ b/docs/02-app/01-building-your-application/06-optimizing/06-bundle-analyzer.mdx @@ -24,14 +24,13 @@ pnpm add @next/bundle-analyzer Then, add the bundle analyzer's settings to your `next.config.js`. ```js filename="next.config.js" -const withBundleAnalyzer = require('@next/bundle-analyzer')({ - enabled: process.env.ANALYZE === 'true', -}) - /** @type {import('next').NextConfig} */ const nextConfig = {} -module.exports = withBundleAnalyzer(nextConfig) +const withBundleAnalyzer = require('@next/bundle-analyzer')() + +module.exports = + process.env.ANALYZE === 'true' ? withBundleAnalyzer(nextConfig) : nextConfig ``` ## Analyzing your bundles