@@ -81,6 +81,7 @@ import type { BuildManifest } from '../server/get-page-files'
8181import { normalizePagePath } from '../shared/lib/page-path/normalize-page-path'
8282import { getPagePath } from '../server/require'
8383import * as ciEnvironment from '../telemetry/ci-info'
84+
8485import {
8586 eventBuildOptimize ,
8687 eventCliSession ,
@@ -155,6 +156,7 @@ import { collectBuildTraces } from './collect-build-traces'
155156import type { BuildTraceContext } from './webpack/plugins/next-trace-entrypoints-plugin'
156157import { formatManifest } from './manifests/formatter/format-manifest'
157158import { getStartServerInfo , logStartInfo } from '../server/lib/app-info-log'
159+ import type { NextEnabledDirectories } from '../server/base-server'
158160
159161interface ExperimentalBypassForInfo {
160162 experimentalBypassFor ?: RouteHas [ ]
@@ -347,7 +349,6 @@ export default async function build(
347349 const isCompile = buildMode === 'experimental-compile'
348350 const isGenerate = buildMode === 'experimental-generate'
349351
350- let hasAppDir = false
351352 try {
352353 const nextBuildSpan = trace ( 'next-build' , undefined , {
353354 buildMode : buildMode ,
@@ -432,11 +433,14 @@ export default async function build(
432433 setGlobal ( 'telemetry' , telemetry )
433434
434435 const publicDir = path . join ( dir , 'public' )
435- const isAppDirEnabled = true
436436 const { pagesDir, appDir } = findPagesDir ( dir )
437437 NextBuildContext . pagesDir = pagesDir
438438 NextBuildContext . appDir = appDir
439- hasAppDir = Boolean ( appDir )
439+
440+ const enabledDirectories : NextEnabledDirectories = {
441+ app : typeof appDir === 'string' ,
442+ pages : typeof pagesDir === 'string' ,
443+ }
440444
441445 const isSrcDir = path
442446 . relative ( dir , pagesDir || appDir || '' )
@@ -1292,8 +1296,9 @@ export default async function build(
12921296 } = await initializeIncrementalCache ( {
12931297 fs : nodeFs ,
12941298 dev : false ,
1295- appDir : isAppDirEnabled ,
1296- fetchCache : isAppDirEnabled ,
1299+ pagesDir : true ,
1300+ appDir : true ,
1301+ fetchCache : true ,
12971302 flushToDisk : config . experimental . isrFlushToDisk ,
12981303 serverDistDir : path . join ( distDir , 'server' ) ,
12991304 fetchCacheKeyPrefix : config . experimental . fetchCacheKeyPrefix ,
@@ -1317,7 +1322,7 @@ export default async function build(
13171322 incrementalCacheIpcPort ,
13181323 incrementalCacheIpcValidationKey
13191324 )
1320- const appStaticWorkers = isAppDirEnabled
1325+ const appStaticWorkers = appDir
13211326 ? createStaticWorker (
13221327 incrementalCacheIpcPort ,
13231328 incrementalCacheIpcValidationKey
@@ -2032,7 +2037,7 @@ export default async function build(
20322037 ( combinedPages . length > 0 ||
20332038 useStaticPages404 ||
20342039 useDefaultStatic500 ||
2035- isAppDirEnabled )
2040+ appDir )
20362041 ) {
20372042 const staticGenerationSpan =
20382043 nextBuildSpan . traceChild ( 'static-generation' )
@@ -2172,7 +2177,7 @@ export default async function build(
21722177
21732178 const exportOptions : ExportAppOptions = {
21742179 nextConfig : exportConfig ,
2175- hasAppDir ,
2180+ enabledDirectories ,
21762181 silent : false ,
21772182 buildExport : true ,
21782183 debugOutput,
@@ -2870,7 +2875,7 @@ export default async function build(
28702875 const options : ExportAppOptions = {
28712876 buildExport : false ,
28722877 nextConfig : config ,
2873- hasAppDir ,
2878+ enabledDirectories ,
28742879 silent : true ,
28752880 threads : config . experimental . cpus ,
28762881 outdir : path . join ( dir , configOutDir ) ,
0 commit comments