Skip to content
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

app router: ensure static prefetch renders loading.js #55950

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/next/src/server/app-render/app-render.tsx
Expand Up @@ -1119,7 +1119,9 @@ export const renderToHTMLOrFlight: AppPageRender = (
getDynamicParamFromSegment,
query
),
isPrefetch && !Boolean(components.loading)
isPrefetch &&
!Boolean(components.loading) &&
!hasLoadingComponentInTree(loaderTree)
? null
: // Create component tree using the slice of the loaderTree
// @ts-expect-error TODO-APP: fix async component type
Expand All @@ -1142,7 +1144,9 @@ export const renderToHTMLOrFlight: AppPageRender = (

return <Component />
}),
isPrefetch && !Boolean(components.loading)
isPrefetch &&
!Boolean(components.loading) &&
!hasLoadingComponentInTree(loaderTree)
? null
: (() => {
const { layoutOrPagePath } =
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/app-dir/app/app/linking/about/loading.js
@@ -0,0 +1,4 @@
export default function AboutLoading() {
console.log('rendering linking about loading')
feedthejim marked this conversation as resolved.
Show resolved Hide resolved
return <p id="about-loading">About loading...</p>
}
2 changes: 1 addition & 1 deletion test/e2e/app-dir/app/index.test.ts
Expand Up @@ -19,7 +19,7 @@ createNextDescribe(
).toBeTruthy()
expect(
await next.readFile('.next/server/app/linking/about.prefetch.rsc')
).toBeTruthy()
).toContain('About loading...')
expect(
await next.readFile(
'.next/server/app/dashboard/deployments/breakdown.prefetch.rsc'
Expand Down