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

Enable dynamic HTML in minimal mode #34222

Merged
merged 5 commits into from Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/next/server/base-server.ts
Expand Up @@ -1162,7 +1162,6 @@ export default abstract class Server {
!isSSG &&
!isLikeServerless &&
!query.amp &&
!this.minimalMode &&
typeof components.Document?.getInitialProps !== 'function'
}

Expand Down
51 changes: 51 additions & 0 deletions test/production/react-18-streaming-ssr/index.test.ts
@@ -0,0 +1,51 @@
import fs from 'fs-extra'
import { join } from 'path'
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 () => {
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,
})

// Enable minimal mode
const baseServerPath = join(
next.testDir,
'node_modules/next/dist/server/base-server.js'
)
const minimalModeBaseServerCode = fs
.readFileSync(baseServerPath, { encoding: 'utf-8' })
.replace(/this.minimalMode = minimalMode/, 'this.minimalMode = true')
fs.writeFileSync(baseServerPath, minimalModeBaseServerCode)
huozhi marked this conversation as resolved.
Show resolved Hide resolved

await next.start()
})
afterAll(() => next.destroy())

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