Skip to content

Commit 494943c

Browse files
authored
List unsupported Turbopack config keys (vercel#46582)
A small DX improvement, this will list any unsupported keys when one is found: <img width="538" alt="Screen Shot 2023-02-28 at 5 23 58 PM" src="https://user-images.githubusercontent.com/112982/221995232-cb798084-4b6a-4733-99b7-0f599fdec315.png">
1 parent 725fbc2 commit 494943c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

packages/next/src/cli/next-dev.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ const nextDev: CliCommand = async (argv) => {
270270
let babelrc = await getBabelConfigFile(dir)
271271
if (babelrc) babelrc = path.basename(babelrc)
272272

273-
let hasNonDefaultConfig
273+
let nonSupportedConfig: string[] = []
274274
let rawNextConfig: NextConfig = {}
275275

276276
try {
@@ -317,14 +317,14 @@ const nextDev: CliCommand = async (argv) => {
317317
}
318318
}
319319

320-
hasNonDefaultConfig = Object.keys(rawNextConfig).some((key) =>
320+
nonSupportedConfig = Object.keys(rawNextConfig).filter((key) =>
321321
checkUnsupportedCustomConfig(key, rawNextConfig, defaultConfig)
322322
)
323323
} catch (e) {
324324
console.error('Unexpected error occurred while checking config', e)
325325
}
326326

327-
const hasWarningOrError = babelrc || hasNonDefaultConfig
327+
const hasWarningOrError = babelrc || nonSupportedConfig.length
328328
if (!hasWarningOrError) {
329329
thankYouMsg = chalk.dim(thankYouMsg)
330330
}
@@ -349,13 +349,17 @@ const nextDev: CliCommand = async (argv) => {
349349
`Babel is not yet supported. To use Turbopack at the moment,\n you'll need to remove your usage of Babel.`
350350
)}`
351351
}
352-
if (hasNonDefaultConfig) {
352+
if (nonSupportedConfig.length) {
353353
unsupportedParts += `\n\n- Unsupported Next.js configuration option(s) (${chalk.cyan(
354354
'next.config.js'
355355
)})\n ${chalk.dim(
356356
`The only configurations options supported are:\n${supportedTurbopackNextConfigOptions
357357
.map((name) => ` - ${chalk.cyan(name)}\n`)
358-
.join('')} To use Turbopack, remove other configuration options.`
358+
.join(
359+
''
360+
)} To use Turbopack, remove the following configuration options:\n${nonSupportedConfig.map(
361+
(name) => ` - ${chalk.red(name)}\n`
362+
)}`
359363
)} `
360364
}
361365

0 commit comments

Comments
 (0)