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

Add flight render starting point #36760

Merged
merged 8 commits into from May 8, 2022
16 changes: 14 additions & 2 deletions packages/next/server/view-render.tsx
Expand Up @@ -219,13 +219,25 @@ export async function renderToHTML(
const hasConcurrentFeatures = !!runtime
const pageIsDynamic = isDynamicRoute(pathname)
const components = Object.keys(ComponentMod.components)
.filter((path) => {
const { __flight__, __flight_router_path__: routerPath } = query
// Rendering part of the page is only allowed for flight data
if (__flight__ !== undefined && routerPath) {
// TODO: check the actual path
const pathLength = path.length
return pathLength >= routerPath.length
}
return true
})
.sort()
.map((key) => {
const mod = ComponentMod.components[key]()
.map((path) => {
const mod = ComponentMod.components[path]()
mod.Component = mod.default || mod
return mod
})

console.log({ components })
timneutkens marked this conversation as resolved.
Show resolved Hide resolved

// Reads of this are cached on the `req` object, so this should resolve
// instantly. There's no need to pass this data down from a previous
// invoke, where we'd have to consider server & serverless.
Expand Down