Skip to content

Commit

Permalink
List unsupported Turbopack config keys (#46582)
Browse files Browse the repository at this point in the history
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">
  • Loading branch information
jridgewell authored Mar 1, 2023
1 parent 725fbc2 commit 494943c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/next/src/cli/next-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ const nextDev: CliCommand = async (argv) => {
let babelrc = await getBabelConfigFile(dir)
if (babelrc) babelrc = path.basename(babelrc)

let hasNonDefaultConfig
let nonSupportedConfig: string[] = []
let rawNextConfig: NextConfig = {}

try {
Expand Down Expand Up @@ -317,14 +317,14 @@ const nextDev: CliCommand = async (argv) => {
}
}

hasNonDefaultConfig = Object.keys(rawNextConfig).some((key) =>
nonSupportedConfig = Object.keys(rawNextConfig).filter((key) =>
checkUnsupportedCustomConfig(key, rawNextConfig, defaultConfig)
)
} catch (e) {
console.error('Unexpected error occurred while checking config', e)
}

const hasWarningOrError = babelrc || hasNonDefaultConfig
const hasWarningOrError = babelrc || nonSupportedConfig.length
if (!hasWarningOrError) {
thankYouMsg = chalk.dim(thankYouMsg)
}
Expand All @@ -349,13 +349,17 @@ const nextDev: CliCommand = async (argv) => {
`Babel is not yet supported. To use Turbopack at the moment,\n you'll need to remove your usage of Babel.`
)}`
}
if (hasNonDefaultConfig) {
if (nonSupportedConfig.length) {
unsupportedParts += `\n\n- Unsupported Next.js configuration option(s) (${chalk.cyan(
'next.config.js'
)})\n ${chalk.dim(
`The only configurations options supported are:\n${supportedTurbopackNextConfigOptions
.map((name) => ` - ${chalk.cyan(name)}\n`)
.join('')} To use Turbopack, remove other configuration options.`
.join(
''
)} To use Turbopack, remove the following configuration options:\n${nonSupportedConfig.map(
(name) => ` - ${chalk.red(name)}\n`
)}`
)} `
}

Expand Down

0 comments on commit 494943c

Please sign in to comment.