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 = module.exports =
({ enabled = true, logLevel, openAnalyzer, analyzerMode } = {}) => ({ enabled = true, logLevel, openAnalyzer, analyzerMode } = {}) =>
(nextConfig = {}) => { (nextConfig = {}) => {
if (!enabled) {
return nextConfig
}
return Object.assign({}, nextConfig, { return Object.assign({}, nextConfig, {
webpack(config, options) { webpack(config, options) {
if (enabled) { const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer') config.plugins.push(
config.plugins.push( new BundleAnalyzerPlugin({
new BundleAnalyzerPlugin({ analyzerMode: analyzerMode || 'static',
analyzerMode: analyzerMode || 'static', logLevel,
logLevel, openAnalyzer,
openAnalyzer, reportFilename: !options.nextRuntime
reportFilename: !options.nextRuntime ? `./analyze/client.html`
? `./analyze/client.html` : `../${options.nextRuntime === 'nodejs' ? '../' : ''}analyze/${
: `../${options.nextRuntime === 'nodejs' ? '../' : ''}analyze/${ options.nextRuntime
options.nextRuntime }.html`,
}.html`, })
}) )
)
}
if (typeof nextConfig.webpack === 'function') { if (typeof nextConfig.webpack === 'function') {
return nextConfig.webpack(config, options) 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