Skip to content

Commit

Permalink
Merge rsc queries handling
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Mar 23, 2022
1 parent 72478c5 commit 9f4eeac
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 28 deletions.
Expand Up @@ -25,7 +25,7 @@ export function getRender({
buildManifest,
reactLoadableManifest,
serverComponentManifest,
isServerComponent,
// isServerComponent,
config,
buildId,
}: {
Expand All @@ -39,7 +39,7 @@ export function getRender({
buildManifest: BuildManifest
reactLoadableManifest: ReactLoadableManifest
serverComponentManifest: any | null
isServerComponent: boolean
// isServerComponent: boolean
config: NextConfig
buildId: string
}) {
Expand Down Expand Up @@ -123,21 +123,6 @@ export function getRender({
})
}

const renderServerComponentData = isServerComponent
? query.__flight__ !== undefined
: false

const serverComponentProps =
isServerComponent && query.__props__
? JSON.parse(query.__props__)
: undefined

// Extend the render options.
server.updateRenderOpts({
renderServerComponentData,
serverComponentProps,
})

const extendedReq = new WebNextRequest(request)
const extendedRes = new WebNextResponse()
requestHandler(extendedReq, extendedRes)
Expand Down
17 changes: 9 additions & 8 deletions packages/next/server/render.tsx
Expand Up @@ -231,8 +231,6 @@ export type RenderOptsPartial = {
resolvedUrl?: string
resolvedAsPath?: string
serverComponentManifest?: any
renderServerComponentData?: boolean
serverComponentProps?: any
distDir?: string
locale?: string
locales?: string[]
Expand Down Expand Up @@ -451,7 +449,7 @@ export async function renderToHTML(
getStaticPaths,
getServerSideProps,
serverComponentManifest,
serverComponentProps,
// serverComponentProps,
isDataReq,
params,
previewProps,
Expand Down Expand Up @@ -505,11 +503,14 @@ export async function renderToHTML(
return ''
}

let { renderServerComponentData } = renderOpts
if (isServerComponent && query.__flight__) {
renderServerComponentData = true
delete query.__flight__
}
let renderServerComponentData = isServerComponent
? query.__flight__ !== undefined
: false

const serverComponentProps =
isServerComponent && query.__props__
? JSON.parse(query.__props__ as string)
: undefined

const callMiddleware = async (method: string, args: any[], props = false) => {
let results: any = props ? {} : []
Expand Down
6 changes: 3 additions & 3 deletions packages/next/server/web-server.ts
Expand Up @@ -204,7 +204,7 @@ export default class NextWebServer extends BaseServer {
}
}

public updateRenderOpts(renderOpts: Partial<BaseServer['renderOpts']>) {
Object.assign(this.renderOpts, renderOpts)
}
// public updateRenderOpts(renderOpts: Partial<BaseServer['renderOpts']>) {
// Object.assign(this.renderOpts, renderOpts)
// }
}

0 comments on commit 9f4eeac

Please sign in to comment.