|
9 | 9 | normalizeConfig,
|
10 | 10 | ExperimentalConfig,
|
11 | 11 | NextConfigComplete,
|
12 |
| - validateConfig, |
13 | 12 | NextConfig,
|
14 | 13 | TurboLoaderItem,
|
15 | 14 | } from './config-shared'
|
@@ -955,31 +954,36 @@ export default async function loadConfig(
|
955 | 954 | userConfigModule.default || userConfigModule
|
956 | 955 | )
|
957 | 956 |
|
958 |
| - const validateError = validateConfig(userConfig) |
| 957 | + if (!process.env.NEXT_MINIMAL) { |
| 958 | + // We only validate the config against schema in non minimal mode |
| 959 | + const { configSchema } = |
| 960 | + require('./config-schema') as typeof import('./config-schema') |
| 961 | + const state = configSchema.safeParse(userConfig) |
959 | 962 |
|
960 |
| - if (validateError) { |
961 |
| - // error message header |
962 |
| - const messages = [`Invalid ${configFileName} options detected: `] |
| 963 | + if (!state.success) { |
| 964 | + // error message header |
| 965 | + const messages = [`Invalid ${configFileName} options detected: `] |
963 | 966 |
|
964 |
| - const [errorMessages, shouldExit] = normalizeZodErrors(validateError) |
965 |
| - // ident list item |
966 |
| - for (const error of errorMessages) { |
967 |
| - messages.push(` ${error}`) |
968 |
| - } |
| 967 | + const [errorMessages, shouldExit] = normalizeZodErrors(state.error) |
| 968 | + // ident list item |
| 969 | + for (const error of errorMessages) { |
| 970 | + messages.push(` ${error}`) |
| 971 | + } |
969 | 972 |
|
970 |
| - // error message footer |
971 |
| - messages.push( |
972 |
| - 'See more info here: https://nextjs.org/docs/messages/invalid-next-config' |
973 |
| - ) |
| 973 | + // error message footer |
| 974 | + messages.push( |
| 975 | + 'See more info here: https://nextjs.org/docs/messages/invalid-next-config' |
| 976 | + ) |
974 | 977 |
|
975 |
| - if (shouldExit) { |
976 |
| - for (const message of messages) { |
977 |
| - console.error(message) |
978 |
| - } |
979 |
| - await flushAndExit(1) |
980 |
| - } else { |
981 |
| - for (const message of messages) { |
982 |
| - curLog.warn(message) |
| 978 | + if (shouldExit) { |
| 979 | + for (const message of messages) { |
| 980 | + console.error(message) |
| 981 | + } |
| 982 | + await flushAndExit(1) |
| 983 | + } else { |
| 984 | + for (const message of messages) { |
| 985 | + curLog.warn(message) |
| 986 | + } |
983 | 987 | }
|
984 | 988 | }
|
985 | 989 | }
|
|
0 commit comments