Unverified Commit 14f33dd5 authored by Joe Haddad's avatar Joe Haddad Committed by GitHub

Make Missing Prerender Manifest Fatal (#10485)

* Fail on Invalid Prerender Manifest

* Make Missing Prerender Manifest Fatal

* fix test
parent a33e365c
......@@ -801,6 +801,17 @@ export default async function build(dir: string, conf = null): Promise<void> {
dynamicRoutes: finalDynamicRoutes,
}
await fsWriteFile(
path.join(distDir, PRERENDER_MANIFEST),
JSON.stringify(prerenderManifest),
'utf8'
)
} else {
const prerenderManifest: PrerenderManifest = {
version: 1,
routes: {},
dynamicRoutes: {},
}
await fsWriteFile(
path.join(distDir, PRERENDER_MANIFEST),
JSON.stringify(prerenderManifest),
......
import fs from 'fs'
import path from 'path'
import LRUCache from 'lru-cache'
import mkdirpOrig from 'mkdirp'
import path from 'path'
import { promisify } from 'util'
import { PrerenderManifest } from '../../build'
import { PRERENDER_MANIFEST } from '../lib/constants'
import { normalizePagePath } from './normalize-page-path'
import mkdirpOrig from 'mkdirp'
const mkdirp = promisify(mkdirpOrig)
const readFile = promisify(fs.readFile)
......@@ -72,14 +72,12 @@ export function initializeSprCache({
!dev && (typeof flushToDisk !== 'undefined' ? flushToDisk : true),
}
try {
prerenderManifest = dev
? { routes: {}, dynamicRoutes: [] }
: JSON.parse(
fs.readFileSync(path.join(distDir, PRERENDER_MANIFEST), 'utf8')
)
} catch (_) {
prerenderManifest = { version: 1, routes: {}, dynamicRoutes: {} }
if (dev) {
prerenderManifest = { version: -1, routes: {}, dynamicRoutes: {} }
} else {
prerenderManifest = JSON.parse(
fs.readFileSync(path.join(distDir, PRERENDER_MANIFEST), 'utf8')
)
}
cache = new LRUCache({
......
import Link from 'next/link'
export default () => (
<>
<h3>Hi 👋</h3>
<Link href="/a-non-existing-page">
<a>a lnik to no-where</a>
</Link>
</>
)
function Index() {
return (
<>
<h3>Hi 👋</h3>
<Link href="/a-non-existing-page">
<a>a link to no-where</a>
</Link>
</>
)
}
Index.getInitialProps = () => ({})
export default Index
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