Skip to content

Commit

Permalink
Merge branch 'canary' into opt-in-swc
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] committed May 10, 2022
2 parents 53d1feb + 7d52589 commit 6d7daec
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/next/server/base-server.ts
Expand Up @@ -1629,7 +1629,7 @@ export default abstract class Server<ServerOptions extends Options = Options> {
return null
}

if (isSSG) {
if (isSSG && !this.minimalMode) {
// set x-nextjs-cache header to match the header
// we set for the image-optimizer
res.setHeader(
Expand Down
13 changes: 7 additions & 6 deletions packages/next/server/view-render.tsx
Expand Up @@ -216,16 +216,18 @@ export async function renderToHTML(
ComponentMod,
} = renderOpts

const isFlight = query.__flight__ !== undefined
const flightRouterPath = isFlight ? query.__flight_router_path__ : undefined

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) {
if (flightRouterPath) {
// TODO: check the actual path
const pathLength = path.length
return pathLength >= routerPath.length
return pathLength >= flightRouterPath.length
}
return true
})
Expand Down Expand Up @@ -343,9 +345,8 @@ export async function renderToHTML(
// }
}

// Fall back to default root layout that renders <html> / <head> / <body>
if (!RootLayout) {
// TODO: fallback to our own root layout?
// throw new Error('invariant RootLayout not loaded')
RootLayout = DefaultRootLayout
}

Expand Down Expand Up @@ -412,7 +413,7 @@ export async function renderToHTML(
</FlushEffectContainer>
)

const renderServerComponentData = query.__flight__ !== undefined
const renderServerComponentData = isFlight
if (renderServerComponentData) {
return new RenderResult(
renderToReadableStream(
Expand Down
2 changes: 2 additions & 0 deletions test/production/required-server-files.test.ts
Expand Up @@ -188,6 +188,7 @@ describe('should set-up next', () => {
redirect: 'manual',
})
expect(res.status).toBe(200)
expect(res.headers.get('x-nextjs-cache')).toBeFalsy()
const $ = cheerio.load(await res.text())
const props = JSON.parse($('#props').text())
expect(props.gspCalls).toBeDefined()
Expand All @@ -201,6 +202,7 @@ describe('should set-up next', () => {
}
)
expect(res2.status).toBe(200)
expect(res2.headers.get('x-nextjs-cache')).toBeFalsy()
const { pageProps: props2 } = await res2.json()
expect(props2.gspCalls).toBe(props.gspCalls)

Expand Down

0 comments on commit 6d7daec

Please sign in to comment.