Skip to content

Commit

Permalink
fix PPR build output logs (#58149)
Browse files Browse the repository at this point in the history
Fixes two build output logs:

- A page that uses `generateStaticParams` & postpones should be marked as partially prerendered
- Assume pages that contain dynamic segments will postpone when PPR is enabled even though it won't be determined until request time
  • Loading branch information
ztanner authored Nov 7, 2023
1 parent d3756fa commit 9aefe52
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
10 changes: 10 additions & 0 deletions packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2301,6 +2301,13 @@ export default async function build(
hasEmptyPrelude,
})

// update the page (eg /blog/[slug]) to also have the postpone metadata
pageInfos.set(page, {
...(pageInfos.get(page) as PageInfo),
hasPostponed,
hasEmptyPrelude,
})

if (revalidate !== 0) {
const normalizedRoute = normalizePagePath(route)

Expand Down Expand Up @@ -2386,6 +2393,9 @@ export default async function build(
pageInfos.set(page, {
...(pageInfos.get(page) as PageInfo),
isDynamicAppRoute: true,
// if PPR is turned on and the route contains a dynamic segment,
// we assume it'll be partially prerendered
hasPostponed: experimentalPPR,
})

// TODO: create a separate manifest to allow enforcing
Expand Down
9 changes: 7 additions & 2 deletions packages/next/src/build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,13 @@ export async function printTreeView(
} else if (isEdgeRuntime(pageInfo?.runtime)) {
symbol = 'ℇ'
} else if (pageInfo?.isPPR) {
// If the page has an empty prelude, then it's equivalent to a static page.
if (pageInfo?.hasEmptyPrelude || pageInfo.isDynamicAppRoute) {
if (
// If the page has an empty prelude, then it's equivalent to a dynamic page
pageInfo?.hasEmptyPrelude ||
// ensure we don't mark dynamic paths that postponed as being dynamic
// since in this case we're able to partially prerender it
(pageInfo.isDynamicAppRoute && !pageInfo.hasPostponed)
) {
symbol = 'λ'
} else if (!pageInfo?.hasPostponed) {
symbol = '○'
Expand Down
12 changes: 11 additions & 1 deletion test/e2e/app-dir/ppr/ppr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,17 @@ createNextDescribe(
files: __dirname,
skipDeployment: true,
},
({ next, isNextDev }) => {
({ next, isNextDev, isNextStart }) => {
if (isNextStart) {
describe('build output', () => {
it('correctly marks pages as being partially prerendered in the build output', () => {
expect(next.cliOutput).toContain('◐ /loading/nested/[slug]')
expect(next.cliOutput).toContain('◐ /suspense/node')
expect(next.cliOutput).toContain('◐ /suspense/node/gsp/[slug]')
expect(next.cliOutput).toContain('◐ /suspense/node/nested/[slug]')
})
})
}
describe.each([
{ pathname: '/suspense/node' },
{ pathname: '/suspense/node/nested/1' },
Expand Down

0 comments on commit 9aefe52

Please sign in to comment.