Skip to content

Commit

Permalink
Fix included flight manifest on node runtime (#34113)
Browse files Browse the repository at this point in the history
We need to switch to json flight manifest on node deployment for RSC
  • Loading branch information
huozhi authored Feb 9, 2022
1 parent e2d6c31 commit 0f5d9dc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packages/next/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,12 @@ export default async function build(
PRERENDER_MANIFEST,
path.join(SERVER_DIRECTORY, MIDDLEWARE_MANIFEST),
hasServerComponents
? path.join(SERVER_DIRECTORY, MIDDLEWARE_FLIGHT_MANIFEST + '.js')
? path.join(
SERVER_DIRECTORY,
MIDDLEWARE_FLIGHT_MANIFEST + runtime === 'edge'
? '.js'
: '.json'
)
: null,
REACT_LOADABLE_MANIFEST,
config.optimizeFonts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ describe('Edge runtime - prod', () => {
await killApp(context.server)
})

it('should generate rsc middleware manifests', async () => {
it('should generate middleware SSR manifests for edge runtime', async () => {
const distServerDir = join(distDir, 'server')
const hasFile = (filename) => fs.existsSync(join(distServerDir, filename))

Expand Down Expand Up @@ -246,6 +246,24 @@ const nodejsRuntimeBasicSuite = {
runTests: (context, env) => {
basic(context, env)
streaming(context)

if (env === 'prod') {
it('should generate middleware SSR manifests for Node.js', async () => {
const distServerDir = join(distDir, 'server')
const hasFile = (filename) =>
fs.existsSync(join(distServerDir, filename))

const files = [
'middleware-build-manifest.js',
'middleware-flight-manifest.json',
'middleware-manifest.json',
]
files.forEach((file) => {
if (!hasFile(file)) console.log(file)
expect(hasFile(file)).toBe(true)
})
})
}
},
beforeAll: () => nextConfig.replace("runtime: 'edge'", "runtime: 'nodejs'"),
afterAll: () => nextConfig.restore(),
Expand Down

0 comments on commit 0f5d9dc

Please sign in to comment.