Unverified Commit 0e457e95 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Keep pages/404.js to be able to dynamically render it anyway (#89263)

Needed for https://github.com/vercel/vercel/pull/14795

Keep the file so that we can instead dynamically render it as opposed to having to bundle the prerender into the function
parent f17694d6
...@@ -3179,6 +3179,11 @@ export default async function build( ...@@ -3179,6 +3179,11 @@ export default async function build(
// remove server bundles that were exported // remove server bundles that were exported
for (const page of staticPages) { for (const page of staticPages) {
if (page === '/404') {
// keep the pages 404 chunk as we might need it if we do want to runtime-render the
// 404 in the function later
continue
}
const serverBundle = getPagePath(page, distDir, undefined, false) const serverBundle = getPagePath(page, distDir, undefined, false)
await fs.unlink(serverBundle) await fs.unlink(serverBundle)
} }
......
...@@ -60,6 +60,12 @@ const runTests = (mode = 'server') => { ...@@ -60,6 +60,12 @@ const runTests = (mode = 'server') => {
expect(page.endsWith('.html')).toBe(true) expect(page.endsWith('.html')).toBe(true)
}) })
it('should still output 404.js anyway', async () => {
expect(
await fs.pathExists(join(appDir, '.next/server/pages/404.js'))
).toBeTrue()
})
it('should add /404 to pages-manifest correctly', async () => { it('should add /404 to pages-manifest correctly', async () => {
const manifest = await fs.readJSON( const manifest = await fs.readJSON(
join(appDir, '.next', mode, 'pages-manifest.json') join(appDir, '.next', mode, 'pages-manifest.json')
......
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