Unverified Commit 96338c31 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Revert "refactor: write pages router export files directly to server/pages/" (#92733)

Reverts vercel/next.js#90018
parent a1cb5654
This diff is collapsed.
...@@ -345,10 +345,8 @@ async function exportAppImpl( ...@@ -345,10 +345,8 @@ async function exportAppImpl(
) )
} }
if (!options.buildExport) { await fs.rm(outDir, { recursive: true, force: true })
await fs.rm(outDir, { recursive: true, force: true }) await fs.mkdir(join(outDir, '_next', buildId), { recursive: true })
await fs.mkdir(join(outDir, '_next', buildId), { recursive: true })
}
await fs.writeFile( await fs.writeFile(
join(distDir, EXPORT_DETAIL), join(distDir, EXPORT_DETAIL),
...@@ -652,7 +650,7 @@ async function exportAppImpl( ...@@ -652,7 +650,7 @@ async function exportAppImpl(
} }
const pagesDataDir = options.buildExport const pagesDataDir = options.buildExport
? join(distDir, 'server', 'pages') ? outDir
: join(outDir, '_next/data', buildId) : join(outDir, '_next/data', buildId)
const publicDir = join(dir, CLIENT_PUBLIC_FILES_PATH) const publicDir = join(dir, CLIENT_PUBLIC_FILES_PATH)
...@@ -719,9 +717,7 @@ async function exportAppImpl( ...@@ -719,9 +717,7 @@ async function exportAppImpl(
options, options,
dir, dir,
distDir, distDir,
outDir: options.buildExport outDir,
? join(distDir, 'server', 'pages')
: outDir,
nextConfig, nextConfig,
cacheHandler: nextConfig.cacheHandler, cacheHandler: nextConfig.cacheHandler,
cacheMaxMemorySize: nextConfig.cacheMaxMemorySize, cacheMaxMemorySize: nextConfig.cacheMaxMemorySize,
...@@ -934,25 +930,19 @@ async function exportAppImpl( ...@@ -934,25 +930,19 @@ async function exportAppImpl(
// realizing the implications. // realizing the implications.
const route = normalizePagePath(unnormalizedRoute) const route = normalizePagePath(unnormalizedRoute)
let orig: string const pagePath = getPagePath(pageName, distDir, undefined, isAppPath)
if (isAppPath) { const distPagesDir = join(
const pagePath = getPagePath(pageName, distDir, undefined, isAppPath) pagePath,
const distPagesDir = join( // strip leading / and then recurse number of nested dirs
pagePath, // to place from base folder
// strip leading / and then recurse number of nested dirs pageName
// to place from base folder .slice(1)
pageName .split('/')
.slice(1) .map(() => '..')
.split('/') .join('/')
.map(() => '..') )
.join('/')
) const orig = join(distPagesDir, route)
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 handlerSrc = `${orig}.body`
const handlerDest = join(outDir, route) const handlerDest = join(outDir, route)
......
...@@ -113,7 +113,7 @@ export async function exportPagesPage( ...@@ -113,7 +113,7 @@ export async function exportPagesPage(
renderResult && !renderResult.isNull ? renderResult.toUnchunkedString() : '' renderResult && !renderResult.isNull ? renderResult.toUnchunkedString() : ''
const metadata = renderResult?.metadata || {} const metadata = renderResult?.metadata || {}
if (metadata.pageData && !ssgNotFound) { if (metadata.pageData) {
const dataFile = join( const dataFile = join(
pagesDataDir, pagesDataDir,
htmlFilename.replace(/\.html$/, NEXT_DATA_SUFFIX) htmlFilename.replace(/\.html$/, NEXT_DATA_SUFFIX)
......
...@@ -1543,7 +1543,7 @@ function runTests({ dev }) { ...@@ -1543,7 +1543,7 @@ function runTests({ dev }) {
"/catchall-dash/[...hello-world]": "pages/catchall-dash/[...hello-world].html", "/catchall-dash/[...hello-world]": "pages/catchall-dash/[...hello-world].html",
"/d/[id]": "pages/d/[id].html", "/d/[id]": "pages/d/[id].html",
"/dash/[hello-world]": "pages/dash/[hello-world].html", "/dash/[hello-world]": "pages/dash/[hello-world].html",
"/index/[...slug]": "pages/index/[...slug].html", "/index/[...slug]": "pages/index/index/[...slug].html",
"/on-mount/[post]": "pages/on-mount/[post].html", "/on-mount/[post]": "pages/on-mount/[post].html",
"/p1/p2/all-ssg/[...rest]": "pages/p1/p2/all-ssg/[...rest].js", "/p1/p2/all-ssg/[...rest]": "pages/p1/p2/all-ssg/[...rest].js",
"/p1/p2/all-ssr/[...rest]": "pages/p1/p2/all-ssr/[...rest].js", "/p1/p2/all-ssr/[...rest]": "pages/p1/p2/all-ssr/[...rest].js",
......
...@@ -88,15 +88,6 @@ describe('i18n Support', () => { ...@@ -88,15 +88,6 @@ describe('i18n Support', () => {
expect(content).toMatch(/Internal Server Error/i) 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`)
}
})
} }
) )
......
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