Skip to content

Commit

Permalink
Vendor react@experimental (#48697)
Browse files Browse the repository at this point in the history
Part of #47759 (which had been reverted twice so here we only land a part of the change), relates to NEXT-926. Thanks to #48506 we can soon switch between these two channels during runtime.

Also fixes a problem of `renderKind` (only revealed after upgrading React), it should be also based on the `match` kind.
  • Loading branch information
shuding committed Apr 25, 2023
1 parent f08cab3 commit 287e379
Show file tree
Hide file tree
Showing 99 changed files with 174,792 additions and 2,256 deletions.
8 changes: 6 additions & 2 deletions package.json
Expand Up @@ -196,10 +196,12 @@
"random-seed": "0.3.0",
"react": "18.2.0",
"react-17": "npm:react@17.0.2",
"react-builtin": "npm:react@18.3.0-next-1f248bdd7-20230419",
"react-builtin": "npm:react@18.3.0-next-c8369527e-20230420",
"react-experimental-builtin": "npm:react@0.0.0-experimental-c8369527e-20230420",
"react-dom": "18.2.0",
"react-dom-17": "npm:react-dom@17.0.2",
"react-dom-builtin": "npm:react-dom@18.3.0-next-1f248bdd7-20230419",
"react-dom-builtin": "npm:react-dom@18.3.0-next-c8369527e-20230420",
"react-dom-experimental-builtin": "npm:react-dom@0.0.0-experimental-c8369527e-20230420",
"react-server-dom-webpack": "18.3.0-next-1f248bdd7-20230419",
"react-ssr-prepass": "1.0.8",
"react-virtualized": "9.22.3",
Expand All @@ -211,6 +213,8 @@
"rimraf": "3.0.2",
"sass": "1.54.0",
"satori": "0.4.4",
"scheduler-builtin": "npm:scheduler@0.24.0-next-c8369527e-20230420",
"scheduler-experimental-builtin": "npm:scheduler@0.0.0-experimental-c8369527e-20230420",
"seedrandom": "3.0.5",
"selenium-webdriver": "4.0.0-beta.4",
"semver": "7.3.7",
Expand Down
27 changes: 20 additions & 7 deletions packages/next/src/build/utils.ts
Expand Up @@ -1943,6 +1943,25 @@ if (!process.env.NEXT_MANUAL_SIG_HANDLE) {
let handler
const currentPort = parseInt(process.env.PORT, 10) || 3000
const hostname = process.env.HOSTNAME || 'localhost'
const keepAliveTimeout = parseInt(process.env.KEEP_ALIVE_TIMEOUT, 10);
const nextConfig = ${JSON.stringify({
...serverConfig,
distDir: `./${path.relative(dir, distDir)}`,
})}
${
// In standalone mode, we don't have separated render workers so if both
// app and pages are used, we need to resolve to the prebundled React
// to ensure the correctness of the version for app.
`\
if (nextConfig && nextConfig.experimental && nextConfig.experimental.appDir) {
process.env.__NEXT_PRIVATE_PREBUNDLED_REACT = '1'
}
`
}
const server = http.createServer(async (req, res) => {
try {
await handler(req, res)
Expand All @@ -1952,9 +1971,6 @@ const server = http.createServer(async (req, res) => {
res.end('internal server error')
}
})
const currentPort = parseInt(process.env.PORT, 10) || 3000
const hostname = process.env.HOSTNAME || 'localhost'
const keepAliveTimeout = parseInt(process.env.KEEP_ALIVE_TIMEOUT, 10);
if (
!Number.isNaN(keepAliveTimeout) &&
Expand All @@ -1974,10 +1990,7 @@ server.listen(currentPort, (err) => {
dir: path.join(__dirname),
dev: false,
customServer: false,
conf: ${JSON.stringify({
...serverConfig,
distDir: `./${path.relative(dir, distDir)}`,
})},
conf: nextConfig,
})
handler = nextServer.getRequestHandler()
Expand Down
21 changes: 21 additions & 0 deletions packages/next/src/compiled/react-dom-experimental/LICENSE
@@ -0,0 +1,21 @@
MIT License

Copyright (c) Meta Platforms, Inc. and affiliates.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

0 comments on commit 287e379

Please sign in to comment.