Skip to content

Commit

Permalink
Enable dynamic HTML in minimal mode (#34222)
Browse files Browse the repository at this point in the history
Follow up for #34068

Let minimalMode render HTML by streaming facilities
  • Loading branch information
huozhi committed Feb 11, 2022
1 parent 516e113 commit 477134d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
3 changes: 1 addition & 2 deletions packages/next/server/base-server.ts
Expand Up @@ -289,7 +289,7 @@ export default abstract class Server {
} = this.nextConfig

this.buildId = this.getBuildId()
this.minimalMode = minimalMode
this.minimalMode = minimalMode || !!process.env.NEXT_PRIVATE_MINIMAL_MODE

const serverComponents = this.nextConfig.experimental.serverComponents
this.serverComponentManifest = serverComponents
Expand Down Expand Up @@ -1162,7 +1162,6 @@ export default abstract class Server {
!isSSG &&
!isLikeServerless &&
!query.amp &&
!this.minimalMode &&
typeof components.Document?.getInitialProps !== 'function'
}

Expand Down
44 changes: 44 additions & 0 deletions test/production/react-18-streaming-ssr/index.test.ts
@@ -0,0 +1,44 @@
import { createNext } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import { renderViaHTTP } from 'next-test-utils'

describe('react-18-streaming-ssr in minimal mode', () => {
let next: NextInstance

beforeAll(async () => {
process.env.NEXT_PRIVATE_MINIMAL_MODE = '1'

next = await createNext({
files: {
'pages/index.server.js': `
export default function Page() {
return <p>static streaming</p>
}
`,
},
nextConfig: {
experimental: {
reactRoot: true,
serverComponents: true,
runtime: 'nodejs',
},
},
dependencies: {
react: '18.0.0-rc.0',
'react-dom': '18.0.0-rc.0',
},
skipStart: true,
})

await next.start()
})
afterAll(() => {
delete process.env.NEXT_PRIVATE_MINIMAL_MODE
next.destroy()
})

it('should generate html response by streaming correctly', async () => {
const html = await renderViaHTTP(next.url, '/')
expect(html).toContain('static streaming')
})
})

0 comments on commit 477134d

Please sign in to comment.