-
Notifications
You must be signed in to change notification settings - Fork 26.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
layout: add build status for app routes #41627
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1365,148 +1365,152 @@ export default async function build( | |
|
||
if (pageType === 'app' && originalAppPath) { | ||
appNormalizedPaths.set(originalAppPath, page) | ||
|
||
// TODO-APP: handle prerendering with edge | ||
// runtime | ||
if (pageRuntime === 'experimental-edge') { | ||
return | ||
} | ||
|
||
if ( | ||
workerResult.encodedPrerenderRoutes && | ||
workerResult.prerenderRoutes | ||
) { | ||
appStaticPaths.set( | ||
originalAppPath, | ||
isStatic = false | ||
isSsg = false | ||
} else { | ||
if ( | ||
workerResult.encodedPrerenderRoutes && | ||
workerResult.prerenderRoutes | ||
) | ||
appStaticPathsEncoded.set( | ||
) { | ||
appStaticPaths.set( | ||
originalAppPath, | ||
workerResult.prerenderRoutes | ||
) | ||
appStaticPathsEncoded.set( | ||
originalAppPath, | ||
workerResult.encodedPrerenderRoutes | ||
) | ||
ssgPageRoutes = workerResult.prerenderRoutes | ||
isSsg = true | ||
} | ||
if ( | ||
!isDynamicRoute(page) && | ||
workerResult.appConfig?.revalidate !== 0 | ||
) { | ||
appStaticPaths.set(originalAppPath, [page]) | ||
appStaticPathsEncoded.set(originalAppPath, [page]) | ||
isStatic = true | ||
} | ||
if (workerResult.prerenderFallback) { | ||
// whether or not to allow requests for paths not | ||
// returned from generateStaticParams | ||
appDynamicParamPaths.add(originalAppPath) | ||
} | ||
appDefaultConfigs.set( | ||
originalAppPath, | ||
workerResult.encodedPrerenderRoutes | ||
workerResult.appConfig || {} | ||
) | ||
} | ||
if (!isDynamicRoute(page)) { | ||
appStaticPaths.set(originalAppPath, [page]) | ||
appStaticPathsEncoded.set(originalAppPath, [page]) | ||
} | ||
if (workerResult.prerenderFallback) { | ||
// whether or not to allow requests for paths not | ||
// returned from generateStaticParams | ||
appDynamicParamPaths.add(originalAppPath) | ||
} else { | ||
if (pageRuntime === SERVER_RUNTIME.edge) { | ||
if (workerResult.hasStaticProps) { | ||
console.warn( | ||
`"getStaticProps" is not yet supported fully with "experimental-edge", detected on ${page}` | ||
) | ||
} | ||
// TODO: add handling for statically rendering edge | ||
// pages and allow edge with Prerender outputs | ||
workerResult.isStatic = false | ||
workerResult.hasStaticProps = false | ||
} | ||
appDefaultConfigs.set( | ||
originalAppPath, | ||
workerResult.appConfig || {} | ||
) | ||
return | ||
} | ||
|
||
if (pageRuntime === SERVER_RUNTIME.edge) { | ||
if (workerResult.hasStaticProps) { | ||
console.warn( | ||
`"getStaticProps" is not yet supported fully with "experimental-edge", detected on ${page}` | ||
if (config.outputFileTracing) { | ||
pageTraceIncludes.set( | ||
page, | ||
workerResult.traceIncludes || [] | ||
) | ||
pageTraceExcludes.set( | ||
page, | ||
workerResult.traceExcludes || [] | ||
) | ||
} | ||
// TODO: add handling for statically rendering edge | ||
// pages and allow edge with Prerender outputs | ||
workerResult.isStatic = false | ||
workerResult.hasStaticProps = false | ||
} | ||
|
||
if (config.outputFileTracing) { | ||
pageTraceIncludes.set( | ||
page, | ||
workerResult.traceIncludes || [] | ||
) | ||
pageTraceExcludes.set( | ||
page, | ||
workerResult.traceExcludes || [] | ||
) | ||
} | ||
|
||
if ( | ||
workerResult.isStatic === false && | ||
(workerResult.isHybridAmp || workerResult.isAmpOnly) | ||
) { | ||
hasSsrAmpPages = true | ||
} | ||
if ( | ||
workerResult.isStatic === false && | ||
(workerResult.isHybridAmp || workerResult.isAmpOnly) | ||
) { | ||
hasSsrAmpPages = true | ||
} | ||
|
||
if (workerResult.isHybridAmp) { | ||
isHybridAmp = true | ||
hybridAmpPages.add(page) | ||
} | ||
if (workerResult.isHybridAmp) { | ||
isHybridAmp = true | ||
hybridAmpPages.add(page) | ||
} | ||
|
||
if (workerResult.isNextImageImported) { | ||
isNextImageImported = true | ||
} | ||
if (workerResult.isNextImageImported) { | ||
isNextImageImported = true | ||
} | ||
|
||
if (workerResult.hasStaticProps) { | ||
ssgPages.add(page) | ||
isSsg = true | ||
if (workerResult.hasStaticProps) { | ||
ssgPages.add(page) | ||
isSsg = true | ||
|
||
if ( | ||
workerResult.prerenderRoutes && | ||
workerResult.encodedPrerenderRoutes | ||
) { | ||
additionalSsgPaths.set( | ||
page, | ||
workerResult.prerenderRoutes | ||
) | ||
additionalSsgPathsEncoded.set( | ||
page, | ||
if ( | ||
workerResult.prerenderRoutes && | ||
workerResult.encodedPrerenderRoutes | ||
) | ||
ssgPageRoutes = workerResult.prerenderRoutes | ||
) { | ||
additionalSsgPaths.set( | ||
page, | ||
workerResult.prerenderRoutes | ||
) | ||
additionalSsgPathsEncoded.set( | ||
page, | ||
workerResult.encodedPrerenderRoutes | ||
) | ||
ssgPageRoutes = workerResult.prerenderRoutes | ||
} | ||
|
||
if (workerResult.prerenderFallback === 'blocking') { | ||
ssgBlockingFallbackPages.add(page) | ||
} else if (workerResult.prerenderFallback === true) { | ||
ssgStaticFallbackPages.add(page) | ||
} | ||
} else if (workerResult.hasServerProps) { | ||
serverPropsPages.add(page) | ||
} else if ( | ||
workerResult.isStatic && | ||
!isServerComponent && | ||
(await customAppGetInitialPropsPromise) === false | ||
) { | ||
staticPages.add(page) | ||
isStatic = true | ||
} else if (isServerComponent) { | ||
// This is a static server component page that doesn't have | ||
// gSP or gSSP. We still treat it as a SSG page. | ||
ssgPages.add(page) | ||
isSsg = true | ||
} | ||
|
||
if (workerResult.prerenderFallback === 'blocking') { | ||
ssgBlockingFallbackPages.add(page) | ||
} else if (workerResult.prerenderFallback === true) { | ||
ssgStaticFallbackPages.add(page) | ||
if (hasPages404 && page === '/404') { | ||
if ( | ||
!workerResult.isStatic && | ||
!workerResult.hasStaticProps | ||
) { | ||
throw new Error( | ||
`\`pages/404\` ${STATIC_STATUS_PAGE_GET_INITIAL_PROPS_ERROR}` | ||
) | ||
} | ||
// we need to ensure the 404 lambda is present since we use | ||
// it when _app has getInitialProps | ||
if ( | ||
(await customAppGetInitialPropsPromise) && | ||
!workerResult.hasStaticProps | ||
) { | ||
staticPages.delete(page) | ||
} | ||
} | ||
} else if (workerResult.hasServerProps) { | ||
serverPropsPages.add(page) | ||
} else if ( | ||
workerResult.isStatic && | ||
!isServerComponent && | ||
(await customAppGetInitialPropsPromise) === false | ||
) { | ||
staticPages.add(page) | ||
isStatic = true | ||
} else if (isServerComponent) { | ||
// This is a static server component page that doesn't have | ||
// gSP or gSSP. We still treat it as a SSG page. | ||
ssgPages.add(page) | ||
isSsg = true | ||
} | ||
|
||
if (hasPages404 && page === '/404') { | ||
if ( | ||
STATIC_STATUS_PAGES.includes(page) && | ||
!workerResult.isStatic && | ||
!workerResult.hasStaticProps | ||
) { | ||
throw new Error( | ||
`\`pages/404\` ${STATIC_STATUS_PAGE_GET_INITIAL_PROPS_ERROR}` | ||
`\`pages${page}\` ${STATIC_STATUS_PAGE_GET_INITIAL_PROPS_ERROR}` | ||
) | ||
} | ||
// we need to ensure the 404 lambda is present since we use | ||
// it when _app has getInitialProps | ||
if ( | ||
(await customAppGetInitialPropsPromise) && | ||
!workerResult.hasStaticProps | ||
) { | ||
staticPages.delete(page) | ||
} | ||
} | ||
|
||
if ( | ||
STATIC_STATUS_PAGES.includes(page) && | ||
!workerResult.isStatic && | ||
!workerResult.hasStaticProps | ||
) { | ||
throw new Error( | ||
`\`pages${page}\` ${STATIC_STATUS_PAGE_GET_INITIAL_PROPS_ERROR}` | ||
) | ||
} | ||
} catch (err) { | ||
if ( | ||
|
@@ -2151,6 +2155,13 @@ export default async function build( | |
} | ||
} else { | ||
hasDynamicData = true | ||
// we might have determined during prerendering that this page | ||
// used dynamic data | ||
pageInfos.set(route, { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is necessary because we can only if a route is dynamic after trying to render it now |
||
...(pageInfos.get(route) as PageInfo), | ||
isSsg: false, | ||
static: false, | ||
}) | ||
} | ||
}) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not deleted, just moved between brackets