Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
f710bb50
Unverified
Commit
f710bb50
authored
Sep 24, 2025
by
Jiachi Liu
Committed by
GitHub
Sep 24, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[turbopack] set app dir only to true when no pages entries detected (#84144)
parent
dabf1f66
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
19 deletions
+31
-19
project.rs
crates/next-api/src/project.rs
+13
-6
impl.ts
packages/next/src/build/turbopack-build/impl.ts
+14
-1
app-router-only.test.ts
...oduction/500-page/app-router-only/app-router-only.test.ts
+4
-12
No files found.
crates/next-api/src/project.rs
View file @
f710bb50
...
@@ -848,12 +848,7 @@ impl Project {
...
@@ -848,12 +848,7 @@ impl Project {
let
mut
endpoints
=
Vec
::
new
();
let
mut
endpoints
=
Vec
::
new
();
let
entrypoints
=
self
.entrypoints
()
.await
?
;
let
entrypoints
=
self
.entrypoints
()
.await
?
;
let
mut
is_pages_entries_added
=
false
;
// Always include these basic pages endpoints regardless of `app_dir_only`. The user's
// page routes themselves are excluded below.
endpoints
.push
(
entrypoints
.pages_error_endpoint
);
endpoints
.push
(
entrypoints
.pages_app_endpoint
);
endpoints
.push
(
entrypoints
.pages_document_endpoint
);
if
let
Some
(
middleware
)
=
&
entrypoints
.middleware
{
if
let
Some
(
middleware
)
=
&
entrypoints
.middleware
{
endpoints
.push
(
middleware
.endpoint
);
endpoints
.push
(
middleware
.endpoint
);
...
@@ -872,11 +867,23 @@ impl Project {
...
@@ -872,11 +867,23 @@ impl Project {
}
=>
{
}
=>
{
if
!
app_dir_only
{
if
!
app_dir_only
{
endpoints
.push
(
*
html_endpoint
);
endpoints
.push
(
*
html_endpoint
);
if
!
is_pages_entries_added
{
endpoints
.push
(
entrypoints
.pages_error_endpoint
);
endpoints
.push
(
entrypoints
.pages_app_endpoint
);
endpoints
.push
(
entrypoints
.pages_document_endpoint
);
is_pages_entries_added
=
true
;
}
}
}
}
}
Route
::
PageApi
{
endpoint
}
=>
{
Route
::
PageApi
{
endpoint
}
=>
{
if
!
app_dir_only
{
if
!
app_dir_only
{
endpoints
.push
(
*
endpoint
);
endpoints
.push
(
*
endpoint
);
if
!
is_pages_entries_added
{
endpoints
.push
(
entrypoints
.pages_error_endpoint
);
endpoints
.push
(
entrypoints
.pages_app_endpoint
);
endpoints
.push
(
entrypoints
.pages_document_endpoint
);
is_pages_entries_added
=
true
;
}
}
}
}
}
Route
::
AppPage
(
page_routes
)
=>
{
Route
::
AppPage
(
page_routes
)
=>
{
...
...
packages/next/src/build/turbopack-build/impl.ts
View file @
f710bb50
...
@@ -41,7 +41,6 @@ export async function turbopackBuild(): Promise<{
...
@@ -41,7 +41,6 @@ export async function turbopackBuild(): Promise<{
const
previewProps
=
NextBuildContext
.
previewProps
!
const
previewProps
=
NextBuildContext
.
previewProps
!
const
hasRewrites
=
NextBuildContext
.
hasRewrites
!
const
hasRewrites
=
NextBuildContext
.
hasRewrites
!
const
rewrites
=
NextBuildContext
.
rewrites
!
const
rewrites
=
NextBuildContext
.
rewrites
!
const
appDirOnly
=
NextBuildContext
.
appDirOnly
!
const
noMangling
=
NextBuildContext
.
noMangling
!
const
noMangling
=
NextBuildContext
.
noMangling
!
const
currentNodeJsVersion
=
process
.
versions
.
node
const
currentNodeJsVersion
=
process
.
versions
.
node
...
@@ -107,9 +106,23 @@ export async function turbopackBuild(): Promise<{
...
@@ -107,9 +106,23 @@ export async function turbopackBuild(): Promise<{
'{"type": "commonjs"}'
'{"type": "commonjs"}'
)
)
let
appDirOnly
=
NextBuildContext
.
appDirOnly
!
// eslint-disable-next-line @typescript-eslint/no-unused-vars
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const
entrypoints
=
await
project
.
writeAllEntrypointsToDisk
(
appDirOnly
)
const
entrypoints
=
await
project
.
writeAllEntrypointsToDisk
(
appDirOnly
)
const
hasPagesEntries
=
Array
.
from
(
entrypoints
.
routes
.
values
()).
some
(
(
route
)
=>
{
if
(
route
.
type
===
'page'
||
route
.
type
===
'page-api'
)
{
return
true
}
return
false
}
)
// If there's no pages entries, then we are in app-dir-only mode
if
(
!
hasPagesEntries
)
{
appDirOnly
=
true
}
const
manifestLoader
=
new
TurbopackManifestLoader
({
const
manifestLoader
=
new
TurbopackManifestLoader
({
buildId
,
buildId
,
distDir
,
distDir
,
...
...
test/production/500-page/app-router-only/app-router-only.test.ts
View file @
f710bb50
...
@@ -3,7 +3,7 @@ import fsp from 'fs/promises'
...
@@ -3,7 +3,7 @@ import fsp from 'fs/promises'
import
path
from
'path'
import
path
from
'path'
describe
(
'500-page app-router-only'
,
()
=>
{
describe
(
'500-page app-router-only'
,
()
=>
{
const
{
next
,
isNextStart
,
is
Turbopack
,
is
NextDeploy
}
=
nextTestSetup
({
const
{
next
,
isNextStart
,
isNextDeploy
}
=
nextTestSetup
({
files
:
__dirname
,
files
:
__dirname
,
})
})
...
@@ -48,17 +48,9 @@ describe('500-page app-router-only', () => {
...
@@ -48,17 +48,9 @@ describe('500-page app-router-only', () => {
const
pagesDir
=
path
.
join
(
next
.
testDir
,
'.next'
,
'server'
,
'pages'
)
const
pagesDir
=
path
.
join
(
next
.
testDir
,
'.next'
,
'server'
,
'pages'
)
const
files
=
await
fsp
.
readdir
(
pagesDir
)
const
files
=
await
fsp
.
readdir
(
pagesDir
)
expect
(
files
).
not
.
toContain
(
'500'
)
expect
(
files
).
not
.
toContain
(
'500'
)
if
(
isTurbopack
)
{
expect
(
files
).
not
.
toContain
(
'_app'
)
// In turbopack, _app, _document, _error are still generated with manifest, but no javascript files.
expect
(
files
).
not
.
toContain
(
'_document'
)
// The manifest are under the folder, they're still needed for static generation.
expect
(
files
).
not
.
toContain
(
'_error'
)
expect
(
files
).
not
.
toContain
(
'_app.js'
)
expect
(
files
).
not
.
toContain
(
'_document.js'
)
expect
(
files
).
not
.
toContain
(
'_error.js'
)
}
else
{
expect
(
files
).
not
.
toContain
(
'_app'
)
expect
(
files
).
not
.
toContain
(
'_document'
)
expect
(
files
).
not
.
toContain
(
'_error'
)
}
})
})
}
}
})
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment