From 40e9891175d858e504c4f2fd2c42eb05ff22d9b0 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Sun, 8 May 2022 18:38:43 +0200 Subject: [PATCH] Add flight render starting point (#36760) ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint` --- packages/next/server/view-render.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/next/server/view-render.tsx b/packages/next/server/view-render.tsx index ad8f2b1f52ff..fbbac3d3151e 100644 --- a/packages/next/server/view-render.tsx +++ b/packages/next/server/view-render.tsx @@ -219,9 +219,19 @@ 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 })