Skip to content

Commit

Permalink
Only await Webpack Runtime update outside of prefetches
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Jul 12, 2024
1 parent da4c84a commit bc9e932
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,14 @@ export async function fetchServerResponse(
}

/**
* Three cases:
* Four cases:
* - `prefetchKind` is `undefined`, it means it's a normal navigation, so we want to prefetch the page data fully
* - `prefetchKind` is `temporary` - it means it's a normal navigation, so we want to prefetch the page data fully
* - `prefetchKind` is `full` - we want to prefetch the whole page so same as above
* - `prefetchKind` is `auto` - if the page is dynamic, prefetch the page data partially, if static prefetch the page data fully
*/
const isNavigation =
prefetchKind === undefined || prefetchKind === PrefetchKind.TEMPORARY
if (prefetchKind === PrefetchKind.AUTO) {
headers[NEXT_ROUTER_PREFETCH_HEADER] = '1'
}
Expand Down Expand Up @@ -157,7 +160,7 @@ export async function fetchServerResponse(
// In prod, every page will have the same Webpack runtime.
// In dev, the Webpack runtime is minimal for each page.
// We need to ensure the Webpack runtime is updated before executing client-side JS of the new page.
if (process.env.NODE_ENV !== 'production') {
if (process.env.NODE_ENV !== 'production' && isNavigation) {
await waitForWebpackRuntimeHotUpdate()
}

Expand Down

0 comments on commit bc9e932

Please sign in to comment.