-
Notifications
You must be signed in to change notification settings - Fork 98
fix: handle cacheComponents case not producing prerendered .rsc files #3275
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
Conversation
📊 Package size report 0.01%↑
Unchanged files
🤖 This report was automatically generated by pkg-size-action |
| // app router 404 pages are not in the prerender manifest for some next.js versions | ||
| // so we need to check for them manually if prerender manifest does not include it | ||
| if ( | ||
| !appRouterNotFoundDefinedInPrerenderManifest && | ||
| existsSync(join(ctx.publishDir, `server/app/_not-found.html`)) | ||
| ) { | ||
| const lastModified = Date.now() | ||
| const key = '/404' | ||
| const value = await buildAppCacheValue( | ||
| join(ctx.publishDir, 'server/app/_not-found'), | ||
| shouldUseAppPageKind, | ||
| ) | ||
| await writeCacheEntry(key, value, lastModified, ctx) | ||
| } |
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.
We don't have meta.renderingMode here, but this case will only be hit on Next.js versions before vercel/next.js#82199 which happened earlier than removal of unneeded .prefetch.rsc so this case can assume that Next.js version would generate .prefetch.rsc files if we hit it
| "test": { | ||
| "dependencies": { | ||
| "next": "canary" | ||
| "next": "canary || >=16.0.0" |
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.
We were not running those tests on latest even tho cacheComponents can be used on stable releases.
|
|
||
| if (versionConstraints) { | ||
| // We need to be able to define constraint such as "canary or >=16.0.0" for testing features that might have | ||
| // canary-only support (you can only even try them on canary releases) that later on get promoted to be usable in stable |
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.
Some additional context about "canary-only" support - Next.js tends to have checks like so https://github.com/vercel/next.js/blob/f54479b9dfea3cb9b092a1e11020db0d438454cc/packages/next/src/server/config.ts#L401-L408 or https://github.com/vercel/next.js/blob/v15.5.6/packages/next/src/server/config.ts#L371-L382 (depending on version)
So for features like this we kind of need a way to check if it's canary, but there is not a good way to check this with some kind of semver range, so we kind of need a special case for it. We already did have one, but it didn't support alternatives, which is what this change is adding, so we could continue to be able to run tests on previous canaries + newer stable versions
Description
In recent Next.js canaries there was a cleanup of
.prefetch.rscfiles for thecacheComponentscase ( vercel/next.js#86100 ). We currently are expecting all app router pages to have either.rscor.prefetch.rscfile generated, but with the change this is no longer true. This makes .rsc optional for PPR pages (note that we will still use them if they exist to continue to behave same way with Next.js versions prior to that change).Documentation
Tests
Tests were slightly updated to not expect
/404prerendered cache entries blobs for Next.js newer than vercel/next.js#82199 . Existing tests for 404 cases continue to pass.Relevant links (GitHub issues, etc.) or a picture of cute animal