Skip to content

chore: Default to React 19 #8296

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

Merged
merged 3 commits into from
May 23, 2025
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
3 changes: 0 additions & 3 deletions .circleci/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ async function run() {
body: `Build successful! 🎉

* [View the storybook](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/storybook/index.html)
* [View the storybook-19](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/storybook-19/index.html)
* [View the storybook-17](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/storybook-17/index.html)
* [View the storybook-16](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/storybook-16/index.html)
* [View the S2 storybook](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/storybook-s2/index.html)
* [View the documentation](https://reactspectrum.blob.core.windows.net/reactspectrum/${process.env.CIRCLE_SHA1}/docs/index.html)`
});
Expand Down
151 changes: 80 additions & 71 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
- ~/react-spectrum
key: react-spectrum17-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}

install-19:
install-18:
executor: rsp-large
steps:
- checkout
Expand All @@ -119,12 +119,34 @@ jobs:
- run:
name: build
command: |
yarn install --immutable && yarn install-19
yarn install --immutable && yarn install-18

- save_cache:
paths:
- ~/react-spectrum
key: react-spectrum-19-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}
key: react-spectrum-18-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}

install-canary:
executor: rsp-large
steps:
- checkout

- run:
name: Write npmrc
command: |
if [ $NPM_PASSWORD ]; then
cp .circleci/.npmrc .npmrc
fi

- run:
name: build
command: |
yarn install --immutable && yarn install-canary

- save_cache:
paths:
- ~/react-spectrum
key: react-spectrum-canary-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}

test-ssr:
executor: rsp-xlarge
Expand Down Expand Up @@ -184,11 +206,22 @@ jobs:
command: |
yarn test:ssr

test-ssr-19:
test-ssr-18:
executor: rsp-xlarge
steps:
- restore_cache:
key: react-spectrum-18-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}

- run:
name: test ssr
command: |
yarn test:ssr

test-ssr-canary:
executor: rsp-xlarge
steps:
- restore_cache:
key: react-spectrum-19-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}
key: react-spectrum-canary-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}

- run:
name: test ssr
Expand Down Expand Up @@ -243,12 +276,12 @@ jobs:
- store_artifacts:
path: ~/junit

test-19:
test-18:
parallelism: 3
executor: rsp-xlarge
steps:
- restore_cache:
key: react-spectrum-19-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}
key: react-spectrum-18-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}

- run: mkdir ~/junit

Expand All @@ -257,10 +290,34 @@ jobs:
command: |
shopt -s globstar
TESTFILES=$(circleci tests glob "packages/**/*.test.[tj]{s,sx}" | circleci tests split --split-by=timings)
JEST_JUNIT_OUTPUT_NAME="junit-19.xml" yarn test ${TESTFILES}
JEST_JUNIT_OUTPUT_NAME="junit-18.xml" yarn test ${TESTFILES}

- run:
command: cp junit-19.xml ~/junit/
command: cp junit-18.xml ~/junit/
when: always
- store_test_results:
path: ~/junit
- store_artifacts:
path: ~/junit

test-canary:
parallelism: 3
executor: rsp-xlarge
steps:
- restore_cache:
key: react-spectrum-canary-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}

- run: mkdir ~/junit

- run:
name: test
command: |
shopt -s globstar
TESTFILES=$(circleci tests glob "packages/**/*.test.[tj]{s,sx}" | circleci tests split --split-by=timings)
JEST_JUNIT_OUTPUT_NAME="junit-canary.xml" yarn test ${TESTFILES}

- run:
command: cp junit-canary.xml ~/junit/
when: always
- store_test_results:
path: ~/junit
Expand Down Expand Up @@ -368,51 +425,6 @@ jobs:
paths:
- '*/storybook/'

storybook-16:
executor: rsp-large
steps:
- restore_cache:
key: react-spectrum16-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}

- run:
name: build storybook-16
command: make storybook-16

- persist_to_workspace:
root: dist
paths:
- '*/storybook-16/'

storybook-17:
executor: rsp-large
steps:
- restore_cache:
key: react-spectrum17-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}

- run:
name: build storybook-17
command: make storybook-17

- persist_to_workspace:
root: dist
paths:
- '*/storybook-17/'

storybook-19:
executor: rsp-large
steps:
- restore_cache:
key: react-spectrum-19-{{ .Environment.CACHE_VERSION }}-{{ .Environment.CIRCLE_SHA1 }}

- run:
name: build storybook-19
command: make storybook-19

- persist_to_workspace:
root: dist
paths:
- '*/storybook-19/'

storybook-s2:
executor: rsp-large
steps:
Expand Down Expand Up @@ -788,7 +800,8 @@ workflows:
- install
- install-16
- install-17
- install-19
- install-18
- install-canary
- test-ssr:
requires:
- install
Expand All @@ -807,12 +820,18 @@ workflows:
- test-17:
requires:
- install-17
- test-19:
- test-18:
requires:
- install-18
- test-ssr-18:
requires:
- install-18
- test-canary:
requires:
- install-19
- test-ssr-19:
- install-canary
- test-ssr-canary:
requires:
- install-19
- install-canary
- test-esm:
requires:
- install
Expand Down Expand Up @@ -844,15 +863,6 @@ workflows:
- storybook:
requires:
- install
- storybook-16:
requires:
- install-16
- storybook-17:
requires:
- install-17
- storybook-19:
requires:
- install-19
- storybook-s2:
requires:
- install
Expand Down Expand Up @@ -907,11 +917,10 @@ workflows:
- test-16
- test-ssr-17
- test-17
- test-ssr-18
- test-18
- test-esm
- storybook
- storybook-16
- storybook-17
- storybook-19
- storybook-s2
- docs
- deploy-verdaccio:
Expand Down
9 changes: 0 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,6 @@ icons: packages/@spectrum-icons/workflow/src packages/@spectrum-icons/color/src
storybook:
NODE_ENV=production yarn build:storybook

storybook-16:
yarn build:storybook-16

storybook-17:
yarn build:storybook-17

storybook-19:
yarn build:storybook-19

# for now doesn't have deploy since v3 doesn't have a place for docs and stuff yet
ci:
$(MAKE) publish
Expand Down
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
"check-types": "tsc",
"install-16": "node scripts/react-16-install-prep.mjs && yarn add react@^16.8.0 react-dom@^16.8.0 @testing-library/react@^12 @testing-library/react-hooks@^8 @testing-library/dom@^8 react-test-renderer@^16.9.0 && node scripts/oldReactSupport.mjs",
"install-17": "node scripts/react-17-install-prep.mjs && yarn add react@^17 react-dom@^17 @testing-library/react@^12 @testing-library/react-hooks@^8 @testing-library/dom@^8 react-test-renderer@^16.9.0 && node scripts/oldReactSupport.mjs",
"install-19": "node scripts/react-19-install-prep.mjs && yarn add react@next react-dom@next",
"install-18": "node scripts/react-18-install-prep.mjs && yarn add react@^18 react-dom@^18",
"install-canary": "node scripts/react-canary-install-prep.mjs && yarn add react@canary react-dom@canary",
"start": "cross-env NODE_ENV=storybook storybook dev -p 9003 --ci -c '.storybook'",
"build:storybook": "storybook build -c .storybook -o dist/$(git rev-parse HEAD)/storybook",
"build:storybook-16": "storybook build -c .storybook -o dist/$(git rev-parse HEAD)/storybook-16",
"build:storybook-17": "storybook build -c .storybook -o dist/$(git rev-parse HEAD)/storybook-17",
"build:storybook-19": "storybook build -c .storybook -o dist/$(git rev-parse HEAD)/storybook-19",
"start:chromatic": "CHROMATIC=1 NODE_ENV=storybook storybook dev -p 9004 --ci -c '.chromatic'",
"build:chromatic": "CHROMATIC=1 storybook build -c .chromatic -o dist/$(git rev-parse HEAD)/chromatic",
"start:chromatic-fc": "CHROMATIC=1 NODE_ENV=storybook storybook dev -p 9005 --ci -c '.chromatic-fc'",
Expand Down Expand Up @@ -189,9 +187,9 @@
"postcss-import": "^15.1.0",
"prop-types": "^15.6.0",
"raf": "^3.4.0",
"react": "^18.2.0",
"react": "^19.1.0",
"react-axe": "^3.0.2",
"react-dom": "^18.2.0",
"react-dom": "^19.1.0",
"react-frame-component": "^5.0.0",
"react-test-renderer": "^18.3.1",
"recast": "^0.23",
Expand Down
12 changes: 12 additions & 0 deletions scripts/react-18-install-prep.mjs
Copy link
Contributor

@wojtekmaj wojtekmaj May 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fun fact: you could also do:

npm pkg set resolutions.react=^18 resolutions.react-dom=^18

No custom scripts needed :)

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

import fs from 'node:fs';

try {
let content = fs.readFileSync('./package.json', 'utf8');
let pkg = JSON.parse(content);
pkg.resolutions['react'] = '^18';
pkg.resolutions['react-dom'] = '^18';
fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2));
} catch (e) {
console.error('Error:', e);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import fs from 'node:fs';
import spawn from 'cross-spawn';

// setting the version to 'next' won't work due to a yarn 1 bug
let results = JSON.parse(await run('npm', ['view', 'react@next', '--json']));
let version = results['dist-tags']['next'];
// setting the version to 'canary' won't work due to a yarn 1 bug
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yarn 1 bug? Still relevant?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷 idk I didn't really want to change more than necessary

let results = JSON.parse(await run('npm', ['view', 'react@canary', '--json']));
let version = results['dist-tags']['canary'];
let data = fs.readFileSync('./packages/dev/docs/package.json');
let pkg = JSON.parse(data);
pkg.dependencies['react'] = version;
Expand Down
34 changes: 19 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -27567,15 +27567,14 @@ __metadata:
languageName: node
linkType: hard

"react-dom@npm:^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0, react-dom@npm:^18.2.0":
version: 18.3.1
resolution: "react-dom@npm:18.3.1"
"react-dom@npm:^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0, react-dom@npm:^19.1.0":
version: 19.1.0
resolution: "react-dom@npm:19.1.0"
dependencies:
loose-envify: "npm:^1.1.0"
scheduler: "npm:^0.23.2"
scheduler: "npm:^0.26.0"
peerDependencies:
react: ^18.3.1
checksum: 10c0/a752496c1941f958f2e8ac56239172296fcddce1365ce45222d04a1947e0cc5547df3e8447f855a81d6d39f008d7c32eab43db3712077f09e3f67c4874973e85
react: ^19.1.0
checksum: 10c0/3e26e89bb6c67c9a6aa86cb888c7a7f8258f2e347a6d2a15299c17eb16e04c19194e3452bc3255bd34000a61e45e2cb51e46292392340432f133e5a5d2dfb5fc
languageName: node
linkType: hard

Expand Down Expand Up @@ -27825,9 +27824,9 @@ __metadata:
postcss-import: "npm:^15.1.0"
prop-types: "npm:^15.6.0"
raf: "npm:^3.4.0"
react: "npm:^18.2.0"
react: "npm:^19.1.0"
react-axe: "npm:^3.0.2"
react-dom: "npm:^18.2.0"
react-dom: "npm:^19.1.0"
react-frame-component: "npm:^5.0.0"
react-test-renderer: "npm:^18.3.1"
recast: "npm:^0.23"
Expand Down Expand Up @@ -27935,12 +27934,10 @@ __metadata:
languageName: node
linkType: hard

"react@npm:^18.2.0":
version: 18.3.1
resolution: "react@npm:18.3.1"
dependencies:
loose-envify: "npm:^1.1.0"
checksum: 10c0/283e8c5efcf37802c9d1ce767f302dd569dd97a70d9bb8c7be79a789b9902451e0d16334b05d73299b20f048cbc3c7d288bbbde10b701fa194e2089c237dbea3
"react@npm:^19.1.0":
version: 19.1.0
resolution: "react@npm:19.1.0"
checksum: 10c0/530fb9a62237d54137a13d2cfb67a7db6a2156faed43eecc423f4713d9b20c6f2728b026b45e28fcd72e8eadb9e9ed4b089e99f5e295d2f0ad3134251bdd3698
languageName: node
linkType: hard

Expand Down Expand Up @@ -28977,6 +28974,13 @@ __metadata:
languageName: node
linkType: hard

"scheduler@npm:^0.26.0":
version: 0.26.0
resolution: "scheduler@npm:0.26.0"
checksum: 10c0/5b8d5bfddaae3513410eda54f2268e98a376a429931921a81b5c3a2873aab7ca4d775a8caac5498f8cbc7d0daeab947cf923dbd8e215d61671f9f4e392d34356
languageName: node
linkType: hard

"semver-diff@npm:^2.0.0":
version: 2.1.0
resolution: "semver-diff@npm:2.1.0"
Expand Down