rsnext/bench/minimal-server/start.js
Tim Neutkens 14c9376899
BREAKING CHANGE: Remove React 17 (#41629)
Next.js 13 will require React 18.

In this PR I've only updated the peerDependency and removed the test runs in GH actions. Further cleanup will follow later, this allows us to remove the code supporting it later.



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)


Co-authored-by: Jiachi Liu <4800338+huozhi@users.noreply.github.com>
2022-10-21 22:20:36 +00:00

39 lines
866 B
JavaScript

process.env.NODE_ENV = 'production'
require('../../test/lib/react-channel-require-hook')
console.time('next-cold-start')
const NextServer = require('next/dist/server/next-server').default
const path = require('path')
const appDir = path.join(__dirname, 'benchmark-app')
const distDir = '.next'
const compiledConfig = require(path.join(
appDir,
distDir,
'required-server-files.json'
)).config
process.chdir(appDir)
const nextServer = new NextServer({
conf: compiledConfig,
dir: appDir,
distDir,
minimalMode: true,
customServer: false,
})
const requestHandler = nextServer.getRequestHandler()
require('http')
.createServer((req, res) => {
console.time('next-request')
return requestHandler(req, res).finally(() => {
console.timeEnd('next-request')
})
})
.listen(3000, () => {
console.timeEnd('next-cold-start')
})