diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7819ca11b48..356022c096e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,6 +53,10 @@ jobs: test: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + react-version: [react-18, react-19] steps: - name: Checkout repository uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 @@ -61,6 +65,8 @@ jobs: with: node-version: 22 cache: 'npm' + - if: ${{ matrix.react-version == 'react-19' }} + run: node --experimental-strip-types script/setup-react-19.mts - name: Install dependencies run: npm ci - name: Build @@ -74,6 +80,10 @@ jobs: type-check: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + react-version: [react-18, react-19] steps: - name: Checkout repository uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 @@ -82,6 +92,8 @@ jobs: with: node-version: 22 cache: 'npm' + - if: ${{ matrix.react-version == 'react-19' }} + run: node --experimental-strip-types script/setup-react-19.mts - name: Install dependencies run: npm ci - name: Build project diff --git a/script/setup-react-19.mts b/script/setup-react-19.mts new file mode 100644 index 00000000000..75c8ca67baf --- /dev/null +++ b/script/setup-react-19.mts @@ -0,0 +1,49 @@ +import fs from 'node:fs' +import {spawn as spawnCallback} from 'node:child_process' +import path from 'node:path' +import {promisify} from 'node:util' + +const spawn = promisify(spawnCallback) +const ROOT_DIRECTORY = path.resolve(import.meta.dirname, '../') +const workspaces = ['examples/codesandbox', 'examples/nextjs', 'examples/theming', 'packages/react'] + +async function main() { + const overrides = { + react: '19.1.0', + 'react-dom': '19.1.0', + 'react-test-renderer': '19.1.0', + '@types/react': '19.1.4', + '@types/react-dom': '19.1.5', + } as const + + for (const workspace of workspaces) { + const packageJsonPath = path.join(ROOT_DIRECTORY, workspace, 'package.json') + const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')) + + for (const [key, value] of Object.entries(overrides)) { + if (packageJson.devDependencies?.[key]) { + packageJson.devDependencies[key] = value + } + + if (packageJson.dependencies?.[key]) { + packageJson.dependencies[key] = value + } + + if (packageJson.peerDependencies?.[key]) { + packageJson.peerDependencies[key] = value + } + } + + fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n') + } + + await spawn('npm', ['install'], { + cwd: ROOT_DIRECTORY, + stdio: 'inherit', + }) +} + +main().catch(error => { + console.error(error) + process.exit(1) +})