Skip to content

Commit

Permalink
isPrerender -> prerendered
Browse files Browse the repository at this point in the history
  • Loading branch information
ztanner committed Oct 1, 2024
1 parent 052a8bc commit 9ca1772
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/next/src/client/app-index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const pendingActionQueue: Promise<AppRouterActionQueue> = new Promise(
location: window.location,
couldBeIntercepted: initialRSCPayload.i,
postponed: initialRSCPayload.s,
isPrerender: initialRSCPayload.S,
prerendered: initialRSCPayload.S,
})
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('createInitialRouterState', () => {
location: new URL('/linking', 'https://localhost') as any,
couldBeIntercepted: false,
postponed: false,
isPrerender: false,
prerendered: false,
})

const state2 = createInitialRouterState({
Expand All @@ -56,7 +56,7 @@ describe('createInitialRouterState', () => {
location: new URL('/linking', 'https://localhost') as any,
couldBeIntercepted: false,
postponed: false,
isPrerender: false,
prerendered: false,
})

const expectedCache: CacheNode = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface InitialRouterStateParameters {
location: Location | null
couldBeIntercepted: boolean
postponed: boolean
isPrerender: boolean
prerendered: boolean
}

export function createInitialRouterState({
Expand All @@ -28,7 +28,7 @@ export function createInitialRouterState({
location,
couldBeIntercepted,
postponed,
isPrerender,
prerendered,
}: InitialRouterStateParameters) {
// When initialized on the server, the canonical URL is provided as an array of parts.
// This is to ensure that when the RSC payload streamed to the client, crawlers don't interpret it
Expand Down Expand Up @@ -120,13 +120,13 @@ export function createInitialRouterState({
flightData: [normalizedFlightData],
canonicalUrl: undefined,
couldBeIntercepted: !!couldBeIntercepted,
isPrerender,
prerendered,
postponed,
},
tree: initialState.tree,
prefetchCache: initialState.prefetchCache,
nextUrl: initialState.nextUrl,
kind: isPrerender ? PrefetchKind.FULL : PrefetchKind.AUTO,
kind: prerendered ? PrefetchKind.FULL : PrefetchKind.AUTO,
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export type FetchServerResponseResult = {
flightData: NormalizedFlightData[] | string
canonicalUrl: URL | undefined
couldBeIntercepted: boolean
isPrerender: boolean
prerendered: boolean
postponed: boolean
}

Expand All @@ -71,7 +71,7 @@ function doMpaNavigation(url: string): FetchServerResponseResult {
flightData: urlToUrlWithoutFlightMarker(url).toString(),
canonicalUrl: undefined,
couldBeIntercepted: false,
isPrerender: false,
prerendered: false,
postponed: false,
}
}
Expand Down Expand Up @@ -221,7 +221,7 @@ export async function fetchServerResponse(
flightData: normalizeFlightData(response.f),
canonicalUrl: canonicalUrl,
couldBeIntercepted: interception,
isPrerender: response.S,
prerendered: response.S,
postponed,
}
} catch (err) {
Expand All @@ -236,7 +236,7 @@ export async function fetchServerResponse(
flightData: url.toString(),
canonicalUrl: undefined,
couldBeIntercepted: false,
isPrerender: false,
prerendered: false,
postponed: false,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ function createLazyPrefetchEntry({
// If the prefetch was a cache hit, we want to update the existing cache entry to reflect that it was a full prefetch.
// This is because we know that a static response will contain the full RSC payload, and can be updated to respect the `static`
// staleTime.
if (prefetchResponse.isPrerender) {
if (prefetchResponse.prerendered) {
const existingCacheEntry = prefetchCache.get(
// if we prefixed the cache key due to route interception, we want to use the new key. Otherwise we use the original key
newCacheKey ?? prefetchCacheKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export function serverActionReducer(
flightData,
canonicalUrl: undefined,
couldBeIntercepted: false,
isPrerender: false,
prerendered: false,
postponed: false,
},
tree: state.tree,
Expand Down
4 changes: 2 additions & 2 deletions packages/next/src/server/app-render/app-render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ function App<T>({
location: null,
couldBeIntercepted: response.i,
postponed: response.s,
isPrerender: response.S,
prerendered: response.S,
})

const actionQueue = createMutableActionQueue(initialState)
Expand Down Expand Up @@ -829,7 +829,7 @@ function AppWithoutContext<T>({
location: null,
couldBeIntercepted: response.i,
postponed: response.s,
isPrerender: response.S,
prerendered: response.S,
})

const actionQueue = createMutableActionQueue(initialState)
Expand Down
9 changes: 9 additions & 0 deletions test/e2e/app-dir/app-prefetch/prefetching.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,18 @@ describe('app dir - prefetching', () => {
)
})

// navigate to index
await browser.elementByCss('[href="/"]').click()

// we should be on the index page
await browser.waitForElementByCss('#to-dashboard')

// navigate to the static page
await browser.elementByCss('[href="/static-page"]').click()

// we should be on the static page
await browser.waitForElementByCss('#static-page')

// We still shouldn't see any requests
await retry(async () => {
expect(rscRequests.filter((req) => req === '/static-page').length).toBe(
Expand Down

0 comments on commit 9ca1772

Please sign in to comment.