Skip to content

Commit

Permalink
Ensure Webpack config shows a warning when using Turbopack
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens committed Mar 28, 2024
1 parent fe9ce66 commit c09862b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/next/src/lib/turbopack-warning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ export async function validateTurboNextConfig({
let babelrc = await getBabelConfigFile(dir)
if (babelrc) babelrc = path.basename(babelrc)

let hasWebpack = false
let hasTurbo = !!process.env.TURBOPACK
let hasWebpackConfig = false
let hasTurboConfig = false

let unsupportedConfig: string[] = []
let rawNextConfig: NextConfig = {}
Expand Down Expand Up @@ -154,10 +154,10 @@ export async function validateTurboNextConfig({

for (const key of customKeys) {
if (key.startsWith('webpack')) {
hasWebpack = true
hasWebpackConfig = true
}
if (key.startsWith('experimental.turbo')) {
hasTurbo = true
hasTurboConfig = true
}

let isUnsupported =
Expand Down Expand Up @@ -187,12 +187,12 @@ export async function validateTurboNextConfig({
'https://nextjs.link/with-turbopack'
)}\n`

if (hasWebpack && !hasTurbo) {
if (hasWebpackConfig && !hasTurboConfig) {
Log.warn(
`Webpack is configured while Turbopack is not, which may cause problems.`
)
Log.warn(
`See instructions if you need to configure Turbopack:\n https://turbo.build/pack/docs/features/customizing-turbopack\n`
`See instructions if you need to configure Turbopack:\n https://nextjs.org/docs/app/api-reference/next-config-js/turbo\n`
)
}

Expand Down

0 comments on commit c09862b

Please sign in to comment.