Skip to content

Commit

Permalink
Avoid bundling appDir rendering into pages edge SSR bundle (#43184)
Browse files Browse the repository at this point in the history
Do not directly import app-render into base-server since base-server is
shared module for both nodejs SSR and edge SSR.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people committed Nov 21, 2022
1 parent c1370c9 commit 2763f60
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
6 changes: 6 additions & 0 deletions packages/next/client/components/app-router-headers.ts
Expand Up @@ -3,3 +3,9 @@ export const NEXT_ROUTER_STATE_TREE = 'Next-Router-State-Tree' as const
export const NEXT_ROUTER_PREFETCH = 'Next-Router-Prefetch' as const
export const RSC_VARY_HEADER =
`${RSC}, ${NEXT_ROUTER_STATE_TREE}, ${NEXT_ROUTER_PREFETCH}` as const

export const FLIGHT_PARAMETERS = [
[RSC],
[NEXT_ROUTER_STATE_TREE],
[NEXT_ROUTER_PREFETCH],
] as const
7 changes: 1 addition & 6 deletions packages/next/server/app-render.tsx
Expand Up @@ -42,6 +42,7 @@ import {
NEXT_ROUTER_PREFETCH,
NEXT_ROUTER_STATE_TREE,
RSC,
FLIGHT_PARAMETERS,
} from '../client/components/app-router-headers'
import type { StaticGenerationStore } from '../client/components/static-generation-async-storage'

Expand Down Expand Up @@ -704,12 +705,6 @@ function getScriptNonceFromHeader(cspHeaderValue: string): string | undefined {
return nonce
}

export const FLIGHT_PARAMETERS = [
[RSC],
[NEXT_ROUTER_STATE_TREE],
[NEXT_ROUTER_PREFETCH],
] as const

function headersWithoutFlight(headers: IncomingHttpHeaders) {
const newHeaders = { ...headers }
for (const param of FLIGHT_PARAMETERS) {
Expand Down
7 changes: 5 additions & 2 deletions packages/next/server/base-server.ts
Expand Up @@ -74,8 +74,11 @@ import { getHostname } from '../shared/lib/get-hostname'
import { parseUrl as parseUrlUtil } from '../shared/lib/router/utils/parse-url'
import { getNextPathnameInfo } from '../shared/lib/router/utils/get-next-pathname-info'
import { MiddlewareMatcher } from '../build/analysis/get-page-static-info'
import { RSC, RSC_VARY_HEADER } from '../client/components/app-router-headers'
import { FLIGHT_PARAMETERS } from './app-render'
import {
RSC,
RSC_VARY_HEADER,
FLIGHT_PARAMETERS,
} from '../client/components/app-router-headers'

export type FindComponentsResult = {
components: LoadComponentsReturnType
Expand Down

0 comments on commit 2763f60

Please sign in to comment.