Unverified Commit 80843e1a authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Fix turbo custom config detection (#42022)

Fixes: https://github.com/vercel/next.js/issues/41920

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`
parent e2a98cdf
...@@ -11,6 +11,7 @@ import { getProjectDir } from '../lib/get-project-dir' ...@@ -11,6 +11,7 @@ import { getProjectDir } from '../lib/get-project-dir'
import { CONFIG_FILES } from '../shared/lib/constants' import { CONFIG_FILES } from '../shared/lib/constants'
import path from 'path' import path from 'path'
import type { NextConfig } from '../types' import type { NextConfig } from '../types'
import { interopDefault } from '../lib/interop-default'
const nextDev: cliCommand = (argv) => { const nextDev: cliCommand = (argv) => {
const validArgs: arg.Spec = { const validArgs: arg.Spec = {
...@@ -137,25 +138,40 @@ const nextDev: cliCommand = (argv) => { ...@@ -137,25 +138,40 @@ const nextDev: cliCommand = (argv) => {
let babelrc = await getBabelConfigFile(dir) let babelrc = await getBabelConfigFile(dir)
if (babelrc) babelrc = path.basename(babelrc) if (babelrc) babelrc = path.basename(babelrc)
const rawNextConfig = (await loadConfig( const rawNextConfig = interopDefault(
PHASE_DEVELOPMENT_SERVER, await loadConfig(PHASE_DEVELOPMENT_SERVER, dir, undefined, true)
dir, ) as NextConfig
undefined,
true const checkUnsupportedCustomConfig = (
)) as NextConfig configKey = '',
parentUserConfig: any,
const hasNonDefaultConfig = Object.keys(rawNextConfig).some( parentDefaultConfig: any
(configKey) => { ): boolean => {
if (!(configKey in defaultConfig)) return false // these should not error
if (typeof defaultConfig[configKey] !== 'object') { if (
return defaultConfig[configKey] !== rawNextConfig[configKey] configKey === 'serverComponentsExternalPackages' ||
} configKey === 'appDir' ||
return ( configKey === 'transpilePackages' ||
JSON.stringify(rawNextConfig[configKey]) !== configKey === 'reactStrictMode' ||
JSON.stringify(defaultConfig[configKey]) configKey === 'swcMinify'
) ) {
return false
}
let userValue = parentUserConfig[configKey]
let defaultValue = parentDefaultConfig[configKey]
if (typeof defaultValue !== 'object') {
return defaultValue !== userValue
} }
return Object.keys(userValue).some((key: string) => {
return checkUnsupportedCustomConfig(key, userValue, defaultValue)
})
}
const hasNonDefaultConfig = Object.keys(rawNextConfig).some((key) =>
checkUnsupportedCustomConfig(key, rawNextConfig, defaultConfig)
) )
const findUp = const findUp =
require('next/dist/compiled/find-up') as typeof import('next/dist/compiled/find-up') require('next/dist/compiled/find-up') as typeof import('next/dist/compiled/find-up')
const packagePath = findUp.sync('package.json', { cwd: dir }) const packagePath = findUp.sync('package.json', { cwd: dir })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment