Skip to content

Pass through prerender classification metadata to prerender-config.json#80

Open
agadzik wants to merge 1 commit into
nextjs:mainfrom
agadzik:gadzik/add-ppr-metadata-prerender
Open

Pass through prerender classification metadata to prerender-config.json#80
agadzik wants to merge 1 commit into
nextjs:mainfrom
agadzik:gadzik/add-ppr-metadata-prerender

Conversation

@agadzik

@agadzik agadzik commented Jul 7, 2026

Copy link
Copy Markdown

What

Forwards four per-route classification fields from AdapterOutput['PRERENDER'] into the Build Output API prerender-config.json:

  • hasPostponed — whether the build-time PPR prerender postponed
  • hasFallback — whether a dynamic route template has a static fallback shell
  • htmlSize — byte size of the prerendered HTML shell (0 = fully postponed empty shell)
  • isDynamicRoute — dynamic route template vs. concrete prerendered path

Why

Vercel's deployment summary classifies PPR and Cache Components routes from these signals. The legacy @vercel/next builder emits them (vercel/vercel#16554, vercel/vercel#16584); this adapter did not, so newer Next versions regressed the summary.

How

Pure pass-through — all four values are computed in Next core by vercel/next.js#95534 and written raw: they are tri-state, so false/0 must be preserved and only undefined keys dropped by JSON.stringify. Deliberately not using the || undefined idiom used elsewhere in this file, which would collapse false to undefined.

Since no published next canary includes vercel/next.js#95534 yet, the fields are typed via a local PrerenderClassificationFields type intersected at the read site. Remove it once the next devDependency is bumped past that PR's merge. Until then (and on older Next versions at runtime) the fields simply read undefined and are omitted — this PR is safe to merge independently.

Tests

Adds the repo's first vitest setup (vitest run, wired into the Lint workflow) with a pass-through test for handlePrerenderOutputs: asserts hasFallback: false and htmlSize: 0 survive un-mangled, and that absent fields produce no keys.

Rollout

A release of this package does nothing in production until @vercel/next bumps its pinned version and re-bundles. After merge, cut a new beta from the version-packages PR so that follow-up can pin it.

Known fast-follow (separate PR, different mechanism, tracked in #79): .vc-config.json reports operationType: PAGE where the legacy builder emits ISR (e.g. pages/index.js with getStaticProps + revalidate), which corrupts the same deployment-summary classification these fields feed.

Supersedes #78 (same commit, branch renamed).

🤖 Generated with Claude Code

Forward hasPostponed, hasFallback, htmlSize, and isDynamicRoute from
AdapterOutput['PRERENDER'] (added in vercel/next.js#95534) so deployment
summaries can classify PPR and Cache Components routes, matching the
@vercel/next builder. The values are tri-state, so they are written raw:
false/0 are preserved and only undefined keys are dropped.

Adds the repo's first vitest setup with a pass-through test, wired into
the Lint workflow.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jul 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e86b9d3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@next-community/adapter-vercel Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Jul 7, 2026

Copy link
Copy Markdown

@agadzik is attempting to deploy a commit to the vtest314-next-adapter-e2e-tests Team on Vercel.

A member of the Team first needs to authorize it.

Comment on lines +618 to +651
/**
* Prerender classification metadata added to `AdapterOutput['PRERENDER']`
* by https://github.com/vercel/next.js/pull/95534. Remove this type (and
* the cast below) once the `next` devDependency includes those fields.
*/
type PrerenderClassificationFields = {
/**
* hasPostponed signals whether the build-time prerender of a PPR app
* page postponed (React suspended on dynamic data). `false` means it
* prerendered without postponing; `undefined` means the signal does
* not apply (pages router, route handlers, blocking templates).
*/
hasPostponed?: boolean;
/**
* hasFallback signals whether a dynamic route template has a static
* fallback shell generated during build. `false` means the template
* is blocking or omitted; `undefined` means the concept does not
* apply (concrete prerenders).
*/
hasFallback?: boolean;
/**
* htmlSize is the byte size of the prerendered HTML shell for app
* pages. `0` means an empty shell (everything postponed). It is only
* set on the HTML prerender output; RSC/data/segment outputs leave it
* `undefined`, as do pages router and route handler outputs.
*/
htmlSize?: number;
/**
* isDynamicRoute signals whether this prerender originates from a
* dynamic route template (`dynamicRoutes` in the prerender manifest)
* rather than a concrete prerendered path (`routes`).
*/
isDynamicRoute?: boolean;
};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to remove this once the Nextjs side is merged. then bumping the next canary version dependency here will give you the true types.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, wont merge this until the next changes are merged and I make this change!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants