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

Allow webpack config, but warn if no turbo config #49170

Merged
merged 1 commit into from May 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 22 additions & 0 deletions packages/next/src/lib/turbopack-warning.ts
Expand Up @@ -25,6 +25,7 @@ const supportedTurbopackNextConfigOptions = [
'experimental.swcFileReading',
'experimental.forceSwcTransforms',
// options below are not really supported, but ignored
'webpack',
'devIndicators',
'onDemandEntries',
'experimental.cpus',
Expand Down Expand Up @@ -98,6 +99,9 @@ export async function validateTurboNextConfig({
let babelrc = await getBabelConfigFile(dir)
if (babelrc) babelrc = path.basename(babelrc)

let hasWebpack = false
let hasTurbo = false

let unsupportedConfig: string[] = []
let rawNextConfig: NextConfig = {}

Expand Down Expand Up @@ -156,6 +160,13 @@ export async function validateTurboNextConfig({
: supportedTurbopackNextConfigOptions

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

let isSupported =
supportedKeys.some((supportedKey) => key.startsWith(supportedKey)) ||
getDeepValue(rawNextConfig, key) === getDeepValue(defaultConfig, key)
Expand Down Expand Up @@ -185,6 +196,17 @@ export async function validateTurboNextConfig({
feedbackMessage = chalk.dim(feedbackMessage)
}

if (hasWebpack && !hasTurbo) {
console.warn(
`\n${chalk.yellow(
'Warning:'
)} Webpack is configured while Turbopack is not, which may cause problems.\n
${chalk.dim(
`See instructions if you need to configure Turbopack:\n https://turbo.build/pack/docs/features/customizing-turbopack\n`
)}`
)
}

if (babelrc) {
unsupportedParts += `\n- Babel detected (${chalk.cyan(
babelrc
Expand Down