Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure Webpack config shows a warning when using Turbopack #63822

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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