-
Notifications
You must be signed in to change notification settings - Fork 26.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix react root env missing in NextServer (#37562)
* Fix react root env missing in NextServer * switch to useId instead of using process.env var * add production test * extend timeout * fix test * fix lint * use version to detect if enable react root
- Loading branch information
Showing
12 changed files
with
179 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
test/production/react-18-streaming-ssr/custom-server/next.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
experimental: { | ||
serverComponents: true, | ||
}, | ||
} |
7 changes: 7 additions & 0 deletions
7
test/production/react-18-streaming-ssr/custom-server/pages/index.server.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function Page() { | ||
return <p>streaming</p> | ||
} | ||
|
||
export async function getServerSideProps() { | ||
return { props: {} } | ||
} |
44 changes: 44 additions & 0 deletions
44
test/production/react-18-streaming-ssr/custom-server/server.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const NextServer = require('next/dist/server/next-server').default | ||
const defaultNextConfig = | ||
require('next/dist/server/config-shared').defaultConfig | ||
const http = require('http') | ||
|
||
process.on('SIGTERM', () => process.exit(0)) | ||
process.on('SIGINT', () => process.exit(0)) | ||
|
||
let handler | ||
|
||
const server = http.createServer(async (req, res) => { | ||
try { | ||
await handler(req, res) | ||
} catch (err) { | ||
console.error(err) | ||
res.statusCode = 500 | ||
res.end('internal server error') | ||
} | ||
}) | ||
const currentPort = parseInt(process.env.PORT, 10) || 3000 | ||
|
||
server.listen(currentPort, (err) => { | ||
if (err) { | ||
console.error('Failed to start server', err) | ||
process.exit(1) | ||
} | ||
const nextServer = new NextServer({ | ||
hostname: 'localhost', | ||
port: currentPort, | ||
customServer: true, | ||
dev: false, | ||
conf: { | ||
...defaultNextConfig, | ||
distDir: '.next', | ||
experimental: { | ||
...defaultNextConfig.experimental, | ||
serverComponents: true, | ||
}, | ||
}, | ||
}) | ||
handler = nextServer.getRequestHandler() | ||
|
||
console.log('Listening on port', currentPort) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
test/production/react-18-streaming-ssr/streaming-ssr/next.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
trailingSlash: true, | ||
experimental: { | ||
runtime: 'edge', | ||
}, | ||
} |
14 changes: 14 additions & 0 deletions
14
test/production/react-18-streaming-ssr/streaming-ssr/pages/hello.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Link from 'next/link' | ||
|
||
export default function Page() { | ||
return ( | ||
<div> | ||
<p>hello nextjs</p> | ||
<Link href="/"> | ||
<a>home</a> | ||
</Link> | ||
</div> | ||
) | ||
} | ||
|
||
export const config = { runtime: 'edge' } |
14 changes: 14 additions & 0 deletions
14
test/production/react-18-streaming-ssr/streaming-ssr/pages/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export default function Page() { | ||
return ( | ||
<div> | ||
<style jsx>{` | ||
p { | ||
color: blue; | ||
} | ||
`}</style> | ||
<p>index</p> | ||
</div> | ||
) | ||
} | ||
|
||
export const config = { runtime: 'edge' } |
9 changes: 9 additions & 0 deletions
9
test/production/react-18-streaming-ssr/streaming-ssr/pages/multi-byte.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export default function Page() { | ||
return ( | ||
<div> | ||
<p>{'マルチバイト'.repeat(28)}</p> | ||
</div> | ||
) | ||
} | ||
|
||
export const config = { runtime: 'edge' } |