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

Use React 19 stable in Pages Router #73562

Merged
merged 2 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/reproduction-template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
},
"dependencies": {
"next": "canary",
"react": "19.0.0-rc-de68d2f4-20241204",
"react-dom": "19.0.0-rc-de68d2f4-20241204"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"devDependencies": {
"@types/node": "20.12.12",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@
"pretty-bytes": "5.3.0",
"pretty-ms": "7.0.0",
"random-seed": "0.3.0",
"react": "19.0.0-rc-de68d2f4-20241204",
"react": "19.0.0",
"react-builtin": "npm:react@19.0.0-rc-de68d2f4-20241204",
"react-dom": "19.0.0-rc-de68d2f4-20241204",
"react-dom": "19.0.0",
"react-dom-builtin": "npm:react-dom@19.0.0-rc-de68d2f4-20241204",
"react-dom-experimental-builtin": "npm:react-dom@0.0.0-experimental-de68d2f4-20241204",
"react-experimental-builtin": "npm:react@0.0.0-experimental-de68d2f4-20241204",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-next-app/templates/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { GetTemplateFileArgs, InstallTemplateArgs } from "./types";

// Do not rename or format. sync-react script relies on this line.
// prettier-ignore
const nextjsReactPeerVersion = "19.0.0-rc-de68d2f4-20241204";
const nextjsReactPeerVersion = "^19.0.0";

/**
* Get the file path for a given file in a template, e.g. "next.config.js".
Expand Down
4 changes: 2 additions & 2 deletions packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@
"@opentelemetry/api": "^1.1.0",
"@playwright/test": "^1.41.2",
"babel-plugin-react-compiler": "*",
"react": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204",
"react-dom": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204",
"react": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0",
"react-dom": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0",
"sass": "^1.3.0"
},
"peerDependenciesMeta": {
Expand Down
2 changes: 1 addition & 1 deletion packages/third-parties/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
},
"peerDependencies": {
"next": "^13.0.0 || ^14.0.0 || ^15.0.0",
"react": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204"
"react": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0"
}
}
2 changes: 1 addition & 1 deletion run-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const { getTestFilter } = require('./test/get-test-filter')

// Do not rename or format. sync-react script relies on this line.
// prettier-ignore
const nextjsReactPeerVersion = "19.0.0-rc-de68d2f4-20241204";
const nextjsReactPeerVersion = "^19.0.0";

let argv = require('yargs/yargs')(process.argv.slice(2))
.string('type')
Expand Down
7 changes: 4 additions & 3 deletions scripts/sync-react.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const pullRequestReviewers = ['eps1lon']
* Set to a specific version to override the Pages Router React version e.g. `^19.0.0`.
* @type {string | null}
*/
const pagesRouterReact = null
const pagesRouterReact = '^19.0.0'

const filesReferencingReactPeerDependencyVersion = [
'run-tests.js',
Expand Down Expand Up @@ -371,13 +371,14 @@ Or, run this command with no arguments to use the most recently published versio
const packageJsonPath = path.join(cwd, fileName)
const packageJson = await fsp.readFile(packageJsonPath, 'utf-8')
const manifest = JSON.parse(packageJson)
// Need to specify last supported RC version to avoid breaking changes.
if (manifest.peerDependencies['react']) {
manifest.peerDependencies['react'] =
`^18.2.0 || ${pagesRouterReactVersion}`
`^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ${pagesRouterReactVersion}`
}
if (manifest.peerDependencies['react-dom']) {
manifest.peerDependencies['react-dom'] =
`^18.2.0 || ${pagesRouterReactVersion}`
`^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ${pagesRouterReactVersion}`
}
await fsp.writeFile(
packageJsonPath,
Expand Down
4 changes: 2 additions & 2 deletions test/.stats-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"license": "MIT",
"dependencies": {
"next": "latest",
"react": "19.0.0-rc-de68d2f4-20241204",
"react-dom": "19.0.0-rc-de68d2f4-20241204"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"engines": {
"node": ">=18.18.0"
Expand Down
28 changes: 3 additions & 25 deletions test/e2e/app-dir/rsc-basic/rsc-basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import cheerio from 'cheerio'
// on experimental flags. For example, as a first step we could all the common
// gates like this one into a single module.
const isPPREnabledByDefault = process.env.__NEXT_EXPERIMENTAL_PPR === 'true'
const isReact18 = parseInt(process.env.NEXT_TEST_REACT_VERSION) === 18

async function resolveStreamResponse(response: any, onData?: any) {
let result = ''
Expand Down Expand Up @@ -515,14 +514,7 @@ describe('app dir - rsc basics', () => {
]

ssrPagesReactVersions.forEach((version) => {
if (isReact18 || isPPREnabledByDefault) {
expect(version).not.toMatch(bundledReactVersionPattern)
} else {
// TODO: Pages router only supports React 19 that is bundled
// Once we run with React 19 stable, this branch should be removed in
// favor of unconditional `not.toMatch`
expect(version).toMatch(bundledReactVersionPattern)
}
expect(version).not.toMatch(bundledReactVersionPattern)
})
})
await Promise.all(promises)
Expand Down Expand Up @@ -556,24 +548,10 @@ describe('app dir - rsc basics', () => {
`)

browserPagesReactVersions.forEach((version) => {
if (isReact18 || isPPREnabledByDefault) {
expect(version).not.toMatch(bundledReactVersionPattern)
} else {
// TODO: Pages router only supports React 19 that is bundled
// Once we run with React 19 stable, this branch should be removed in
// favor of unconditional `not.toMatch`
expect(version).toMatch(bundledReactVersionPattern)
}
expect(version).not.toMatch(bundledReactVersionPattern)
})
browserEdgePagesReactVersions.forEach((version) => {
if (isReact18 || isPPREnabledByDefault) {
expect(version).not.toMatch(bundledReactVersionPattern)
} else {
// TODO: Pages router only supports React 19 that is bundled
// Once we run with React 19 stable, this branch should be removed in
// favor of unconditional `not.toMatch`
expect(version).toMatch(bundledReactVersionPattern)
}
expect(version).not.toMatch(bundledReactVersionPattern)
})
})

Expand Down
4 changes: 2 additions & 2 deletions test/e2e/next-test/first-time-setup-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"dependencies": {
"next": "canary",
"react": "19.0.0-rc-de68d2f4-20241204",
"react-dom": "19.0.0-rc-de68d2f4-20241204"
"react": "^19.0.0",
"react-dom": "^19.0.0"
}
}
4 changes: 2 additions & 2 deletions test/e2e/next-test/first-time-setup-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
},
"dependencies": {
"next": "canary",
"react": "19.0.0-rc-de68d2f4-20241204",
"react-dom": "19.0.0-rc-de68d2f4-20241204"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"devDependencies": {
"@types/react": "^18",
Expand Down
2 changes: 1 addition & 1 deletion test/lib/next-modes/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type OmitFirstArgument<F> = F extends (

// Do not rename or format. sync-react script relies on this line.
// prettier-ignore
const nextjsReactPeerVersion = "19.0.0-rc-de68d2f4-20241204";
const nextjsReactPeerVersion = "^19.0.0";

export class NextInstance {
protected files: FileRef | { [filename: string]: string | FileRef }
Expand Down
Loading