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
56e94bd2
Commit
56e94bd2
authored
Apr 13, 2026
by
Tim Neutkens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Revert "refactor: write pages router export files directly to server/…"
This reverts commit
96338c31
.
parent
901cb556
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
114 additions
and
166 deletions
+114
-166
index.ts
packages/next/src/build/index.ts
+76
-147
index.ts
packages/next/src/export/index.ts
+27
-17
pages.ts
packages/next/src/export/routes/pages.ts
+1
-1
index.test.ts
test/integration/dynamic-routing/test/index.test.ts
+1
-1
index.test.ts
test/integration/i18n-support/test/index.test.ts
+9
-0
No files found.
packages/next/src/build/index.ts
View file @
56e94bd2
This diff is collapsed.
Click to expand it.
packages/next/src/export/index.ts
View file @
56e94bd2
...
...
@@ -345,8 +345,10 @@ async function exportAppImpl(
)
}
await
fs
.
rm
(
outDir
,
{
recursive
:
true
,
force
:
true
})
await
fs
.
mkdir
(
join
(
outDir
,
'_next'
,
buildId
),
{
recursive
:
true
})
if
(
!
options
.
buildExport
)
{
await
fs
.
rm
(
outDir
,
{
recursive
:
true
,
force
:
true
})
await
fs
.
mkdir
(
join
(
outDir
,
'_next'
,
buildId
),
{
recursive
:
true
})
}
await
fs
.
writeFile
(
join
(
distDir
,
EXPORT_DETAIL
),
...
...
@@ -650,7 +652,7 @@ async function exportAppImpl(
}
const
pagesDataDir
=
options
.
buildExport
?
outDir
?
join
(
distDir
,
'server'
,
'pages'
)
:
join
(
outDir
,
'_next/data'
,
buildId
)
const
publicDir
=
join
(
dir
,
CLIENT_PUBLIC_FILES_PATH
)
...
...
@@ -717,7 +719,9 @@ async function exportAppImpl(
options
,
dir
,
distDir
,
outDir
,
outDir
:
options
.
buildExport
?
join
(
distDir
,
'server'
,
'pages'
)
:
outDir
,
nextConfig
,
cacheHandler
:
nextConfig
.
cacheHandler
,
cacheMaxMemorySize
:
nextConfig
.
cacheMaxMemorySize
,
...
...
@@ -930,19 +934,25 @@ async function exportAppImpl(
// realizing the implications.
const
route
=
normalizePagePath
(
unnormalizedRoute
)
const
pagePath
=
getPagePath
(
pageName
,
distDir
,
undefined
,
isAppPath
)
const
distPagesDir
=
join
(
pagePath
,
// strip leading / and then recurse number of nested dirs
// to place from base folder
pageName
.
slice
(
1
)
.
split
(
'/'
)
.
map
(()
=>
'..'
)
.
join
(
'/'
)
)
const
orig
=
join
(
distPagesDir
,
route
)
let
orig
:
string
if
(
isAppPath
)
{
const
pagePath
=
getPagePath
(
pageName
,
distDir
,
undefined
,
isAppPath
)
const
distPagesDir
=
join
(
pagePath
,
// strip leading / and then recurse number of nested dirs
// to place from base folder
pageName
.
slice
(
1
)
.
split
(
'/'
)
.
map
(()
=>
'..'
)
.
join
(
'/'
)
)
orig
=
join
(
distPagesDir
,
route
)
}
else
{
// Pages router files are written directly to server/pages/
// by the export worker during build, so read from there.
orig
=
join
(
distDir
,
'server'
,
'pages'
,
route
)
}
const
handlerSrc
=
`
${
orig
}
.body`
const
handlerDest
=
join
(
outDir
,
route
)
...
...
packages/next/src/export/routes/pages.ts
View file @
56e94bd2
...
...
@@ -113,7 +113,7 @@ export async function exportPagesPage(
renderResult
&&
!
renderResult
.
isNull
?
renderResult
.
toUnchunkedString
()
:
''
const
metadata
=
renderResult
?.
metadata
||
{}
if
(
metadata
.
pageData
)
{
if
(
metadata
.
pageData
&&
!
ssgNotFound
)
{
const
dataFile
=
join
(
pagesDataDir
,
htmlFilename
.
replace
(
/
\.
html$/
,
NEXT_DATA_SUFFIX
)
...
...
test/integration/dynamic-routing/test/index.test.ts
View file @
56e94bd2
...
...
@@ -1543,7 +1543,7 @@ function runTests({ dev }) {
"/catchall-dash/[...hello-world]": "pages/catchall-dash/[...hello-world].html",
"/d/[id]": "pages/d/[id].html",
"/dash/[hello-world]": "pages/dash/[hello-world].html",
"/index/[...slug]": "pages/index/
index/
[...slug].html",
"/index/[...slug]": "pages/index/[...slug].html",
"/on-mount/[post]": "pages/on-mount/[post].html",
"/p1/p2/all-ssg/[...rest]": "pages/p1/p2/all-ssg/[...rest].js",
"/p1/p2/all-ssr/[...rest]": "pages/p1/p2/all-ssr/[...rest].js",
...
...
test/integration/i18n-support/test/index.test.ts
View file @
56e94bd2
...
...
@@ -88,6 +88,15 @@ describe('i18n Support', () => {
expect
(
content
).
toMatch
(
/Internal Server Error/i
)
}
})
it
(
'should have locale-prefixed pages-manifest entries for default 500'
,
async
()
=>
{
const
manifest
=
await
fs
.
readJSON
(
join
(
appDir
,
'.next/server/pages-manifest.json'
)
)
for
(
const
locale
of
locales
)
{
expect
(
manifest
[
`/
${
locale
}
/500`
]).
toBe
(
`pages/
${
locale
}
/500.html`
)
}
})
}
)
...
...
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