Unverified Commit 6f6b8336 authored by Marcus Wood's avatar Marcus Wood Committed by GitHub

Make sure bundle analyzer does not trigger warning with turbopack (#79399)

### What?

Add a guard to return earlier to prevent `webpack` assignment to the
config.

### Why?

Next produces the warning if running with `--turbopack` and config has
`webpack` configuration.
Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
parent dd7fed07
module.exports =
({ enabled = true, logLevel, openAnalyzer, analyzerMode } = {}) =>
(nextConfig = {}) => {
if (!enabled) {
return nextConfig
}
return Object.assign({}, nextConfig, {
webpack(config, options) {
if (enabled) {
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
config.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: analyzerMode || 'static',
logLevel,
openAnalyzer,
reportFilename: !options.nextRuntime
? `./analyze/client.html`
: `../${options.nextRuntime === 'nodejs' ? '../' : ''}analyze/${
options.nextRuntime
}.html`,
})
)
}
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
config.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: analyzerMode || 'static',
logLevel,
openAnalyzer,
reportFilename: !options.nextRuntime
? `./analyze/client.html`
: `../${options.nextRuntime === 'nodejs' ? '../' : ''}analyze/${
options.nextRuntime
}.html`,
})
)
if (typeof nextConfig.webpack === 'function') {
return nextConfig.webpack(config, options)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment