( prerenderManifest: NextPrerenderedRoutes, canUsePreviewMode: boolean, entryDirectory: string, nonLambdaSsgPages: Set<string>, routeKey: string, hasPages404: boolean, routesManifest?: RoutesManifest, appDir?: string | null )
| 2411 | |
| 2412 | // checks if prerender files are all static or not before creating lambdas |
| 2413 | export const onPrerenderRouteInitial = ( |
| 2414 | prerenderManifest: NextPrerenderedRoutes, |
| 2415 | canUsePreviewMode: boolean, |
| 2416 | entryDirectory: string, |
| 2417 | nonLambdaSsgPages: Set<string>, |
| 2418 | routeKey: string, |
| 2419 | hasPages404: boolean, |
| 2420 | routesManifest?: RoutesManifest, |
| 2421 | appDir?: string | null |
| 2422 | ) => { |
| 2423 | let static404Page: string | undefined; |
| 2424 | let static500Page: string | undefined; |
| 2425 | |
| 2426 | // Get the route file as it'd be mounted in the builder output |
| 2427 | const pr = prerenderManifest.staticRoutes[routeKey]; |
| 2428 | const { initialRevalidate, srcRoute, dataRoute } = pr; |
| 2429 | const route = srcRoute || routeKey; |
| 2430 | |
| 2431 | const isAppPathRoute = appDir && (!dataRoute || dataRoute?.endsWith('.rsc')); |
| 2432 | |
| 2433 | const routeNoLocale = routesManifest?.i18n |
| 2434 | ? normalizeLocalePath(routeKey, routesManifest.i18n.locales).pathname |
| 2435 | : routeKey; |
| 2436 | |
| 2437 | // if the 404 page used getStaticProps we need to update static404Page |
| 2438 | // since it wasn't populated from the staticPages group |
| 2439 | if (routeNoLocale === '/404') { |
| 2440 | static404Page = path.posix.join(entryDirectory, routeKey); |
| 2441 | } |
| 2442 | |
| 2443 | if (routeNoLocale === '/500') { |
| 2444 | static500Page = path.posix.join(entryDirectory, routeKey); |
| 2445 | } |
| 2446 | |
| 2447 | if ( |
| 2448 | // App paths must be Prerenders to ensure Vary header is |
| 2449 | // correctly added |
| 2450 | !isAppPathRoute && |
| 2451 | initialRevalidate === false && |
| 2452 | (!canUsePreviewMode || (hasPages404 && routeNoLocale === '/404')) && |
| 2453 | !prerenderManifest.fallbackRoutes[route] && |
| 2454 | !prerenderManifest.blockingFallbackRoutes[route] |
| 2455 | ) { |
| 2456 | if ( |
| 2457 | routesManifest?.i18n && |
| 2458 | Object.keys(prerenderManifest.staticRoutes).some(route => { |
| 2459 | const staticRoute = prerenderManifest.staticRoutes[route]; |
| 2460 | |
| 2461 | return ( |
| 2462 | staticRoute.srcRoute === srcRoute && |
| 2463 | staticRoute.initialRevalidate !== false |
| 2464 | ); |
| 2465 | }) |
| 2466 | ) { |
| 2467 | // if any locale static routes are using revalidate the page |
| 2468 | // requires a lambda |
| 2469 | return { |
| 2470 | static404Page, |
no test coverage detected