@@ -42,9 +42,6 @@ const unsupportedTurbopackNextConfigOptions = [
4242 'experimental.slowModuleDetection' ,
4343]
4444
45- // The following will need to be supported by `next build --turbopack`
46- const unsupportedProductionSpecificTurbopackNextConfigOptions : string [ ] = [ ]
47-
4845/** */
4946export async function validateTurboNextConfig ( {
5047 dir,
@@ -81,23 +78,26 @@ export async function validateTurboNextConfig({
8178 defaultConfig,
8279 } )
8380 }
81+ hasWebpackConfig = Boolean ( rawNextConfig . webpack )
82+ hasTurboConfig = Boolean ( rawNextConfig . turbopack )
8483
8584 const flattenKeys = ( obj : any , prefix : string = '' ) : string [ ] => {
8685 let keys : string [ ] = [ ]
8786
8887 for ( const key in obj ) {
89- if ( typeof obj ?. [ key ] === 'undefined' ) {
88+ const value = obj ?. [ key ]
89+ if ( typeof value === 'undefined' ) {
9090 continue
9191 }
9292
9393 const pre = prefix . length ? `${ prefix } .` : ''
9494
9595 if (
96- typeof obj [ key ] === 'object' &&
97- ! Array . isArray ( obj [ key ] ) &&
98- obj [ key ] !== null
96+ typeof value === 'object' &&
97+ ! Array . isArray ( value ) &&
98+ value !== null
9999 ) {
100- keys = keys . concat ( flattenKeys ( obj [ key ] , pre + key ) )
100+ keys = keys . concat ( flattenKeys ( value , pre + key ) )
101101 } else {
102102 keys . push ( pre + key )
103103 }
@@ -118,23 +118,13 @@ export async function validateTurboNextConfig({
118118
119119 const customKeys = flattenKeys ( rawNextConfig )
120120
121- const unsupportedKeys = isDev
122- ? unsupportedTurbopackNextConfigOptions
123- : [
124- ...unsupportedTurbopackNextConfigOptions ,
125- ...unsupportedProductionSpecificTurbopackNextConfigOptions ,
126- ]
127-
128121 for ( const key of customKeys ) {
129- if ( key . startsWith ( 'webpack' ) && rawNextConfig . webpack ) {
130- hasWebpackConfig = true
131- }
132- if ( key . startsWith ( 'turbopack' ) || key . startsWith ( 'experimental.turbo' ) ) {
122+ if ( key . startsWith ( 'experimental.turbo' ) ) {
133123 hasTurboConfig = true
134124 }
135125
136126 const isUnsupported =
137- unsupportedKeys . some (
127+ unsupportedTurbopackNextConfigOptions . some (
138128 ( unsupportedKey ) =>
139129 // Either the key matches (or is a more specific subkey) of
140130 // unsupportedKey, or the key is the path to a specific subkey.
0 commit comments