Unverified Commit 34dd8d42 authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

[turbopack] fix build of empty entries of pages (#84873)

parent 62bc243b
...@@ -552,6 +552,12 @@ export async function createPagesMapping({ ...@@ -552,6 +552,12 @@ export async function createPagesMapping({
// added or removed. // added or removed.
const root = isDev && pagesDir ? PAGES_DIR_ALIAS : 'next/dist/pages' const root = isDev && pagesDir ? PAGES_DIR_ALIAS : 'next/dist/pages'
// If there are no user pages routes, treat this as app-dir-only mode.
// The pages/ folder could be present and the initial appDirOnly is treated as false, but no valid routes are found.
if (Object.keys(pages).length === 0 && !appDirOnly) {
appDirOnly = true
}
return { return {
// Don't add default pages entries if this is an app-router-only build // Don't add default pages entries if this is an app-router-only build
...((isDev || !appDirOnly) && { ...((isDev || !appDirOnly) && {
......
...@@ -1276,6 +1276,11 @@ export default async function build( ...@@ -1276,6 +1276,11 @@ export default async function build(
) )
NextBuildContext.mappedPages = mappedPages NextBuildContext.mappedPages = mappedPages
// Update appDirOnly if no user pages routes are found
if (Object.keys(mappedPages).length === 0 && !appDirOnly) {
NextBuildContext.appDirOnly = appDirOnly = true
}
let mappedAppPages: MappedPages | undefined let mappedAppPages: MappedPages | undefined
let mappedAppLayouts: MappedPages | undefined let mappedAppLayouts: MappedPages | undefined
let denormalizedAppPages: string[] | undefined let denormalizedAppPages: string[] | undefined
......
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