-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Reland static prefetches & fix prefetch bailout behavior #56228
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
86f6a76
Revert "Revert: "Generate prefetch RSC payload during build for SSR p…
ztanner 55f8af4
Revert "app router: ensure static prefetch renders loading.js (#55950)"
ztanner e7fb362
add prefetch-auto test case and fix prefetch bailout logic
ztanner 6ea3f69
don't generate prefetches if layout opts into dynamic rendering
ztanner 233e9d7
Merge branch 'canary' into fix/reland-static-prefetches
ztanner b1bf5e7
fix test
ztanner 46cc885
Merge branch 'canary' into fix/reland-static-prefetches
ztanner e8e5f8a
fix static prefetches when running next start & add a failing test
ztanner c50657f
ensure cache key is cased consistently
ztanner 3c8d500
Merge branch 'canary' into fix/reland-static-prefetches
ztanner 917e6d1
use a separate flag to determine if we can statically prefetch
ztanner ac69094
remove unneeded property
ztanner 4463bd0
test rename
ztanner 5726766
Merge branch 'canary' into fix/reland-static-prefetches
ztanner e11ba4d
tweak test import
ztanner 9b3091f
Merge branch 'canary' into fix/reland-static-prefetches
kodiakhq[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
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
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
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
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
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
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
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
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
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
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
39 changes: 39 additions & 0 deletions
39
test/e2e/app-dir/app-prefetch-static/app-prefetch-static.test.ts
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { createNextDescribe } from 'e2e-utils' | ||
import { waitFor } from 'next-test-utils' | ||
|
||
createNextDescribe( | ||
'app-prefetch-static', | ||
{ | ||
files: __dirname, | ||
}, | ||
({ next, isNextDev }) => { | ||
if (isNextDev) { | ||
it('should skip next dev', () => {}) | ||
return | ||
} | ||
|
||
it('should correctly navigate between static & dynamic pages', async () => { | ||
const browser = await next.browser('/') | ||
// Ensure the page is prefetched | ||
await waitFor(1000) | ||
|
||
await browser.elementByCss('#static-prefetch').click() | ||
|
||
expect(await browser.elementByCss('#static-prefetch-page').text()).toBe( | ||
'Hello from Static Prefetch Page' | ||
) | ||
|
||
await browser.elementByCss('#dynamic-prefetch').click() | ||
|
||
expect(await browser.elementByCss('#dynamic-prefetch-page').text()).toBe( | ||
'Hello from Dynamic Prefetch Page' | ||
) | ||
|
||
await browser.elementByCss('#static-prefetch').click() | ||
|
||
expect(await browser.elementByCss('#static-prefetch-page').text()).toBe( | ||
'Hello from Static Prefetch Page' | ||
) | ||
}) | ||
} | ||
) |
3 changes: 3 additions & 0 deletions
3
test/e2e/app-dir/app-prefetch-static/app/[region]/(default)/dynamic-area/[slug]/page.js
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default async function DynamicPage({ params, searchParams }) { | ||
return <div id="dynamic-prefetch-page">Hello from Dynamic Prefetch Page</div> | ||
} |
13 changes: 13 additions & 0 deletions
13
test/e2e/app-dir/app-prefetch-static/app/[region]/(default)/layout.js
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export const regions = ['SE', 'DE'] | ||
|
||
export default async function Layout({ children, params }) { | ||
return children | ||
} | ||
|
||
export function generateStaticParams() { | ||
return regions.map((region) => ({ | ||
region, | ||
})) | ||
} | ||
|
||
export const dynamicParams = false |
9 changes: 9 additions & 0 deletions
9
test/e2e/app-dir/app-prefetch-static/app/[region]/(default)/static-prefetch/page.js
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const dynamic = 'force-dynamic' | ||
|
||
export default async function StaticPrefetchPage({ params }) { | ||
return ( | ||
<div id="static-prefetch-page"> | ||
<h1>Hello from Static Prefetch Page</h1> | ||
</div> | ||
) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Link from 'next/link' | ||
export default function RootLayout({ children }) { | ||
return ( | ||
<html> | ||
<body> | ||
{children} | ||
|
||
<Link href="/se/static-prefetch" id="static-prefetch"> | ||
Static Prefetch | ||
</Link> | ||
<Link href="/se/dynamic-area/slug" id="dynamic-prefetch"> | ||
Dynamic Prefetch | ||
</Link> | ||
</body> | ||
</html> | ||
) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Main() { | ||
return <div>Main Page</div> | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
should we not enforce the segments on the server to always be lowercased instead?
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.
will follow up to see where the casing diff was coming from and if there’s a better spot to address the differences here 👍