Skip to content

Commit 96ee79d

Browse files
authored
chore: add Yarn constraints to enforce dependency alignment (#2582)
## Summary: Introduce [Yarn Constraints](https://yarnpkg.com/features/constraints) to the repository, that check a few things: 1. Enforce that on release branches, we have a peer dependency on React Native (used for Hermes version lookup, and aligning other dependencies) 2. Enforce that all `@react-native` scoped dependencies use that version. 3. Enforce that all public `@react-native-macos` packages align with our react-native-macos version. Some notes.. - This is effectively only `@react-native-macos/virtualized-lists` - `public`, because `@react-native-macos/nx-release-version` is private ## Test Plan: Earlier version of this PR without fixes from `yarn constraints --fix` properly failed CI: <img width="1185" height="514" alt="image" src="https://github.com/user-attachments/assets/0021c531-d57f-4b4a-80f9-ac42d57abef1" />
1 parent 370a5e1 commit 96ee79d

File tree

17 files changed

+200
-55
lines changed

17 files changed

+200
-55
lines changed

.github/workflows/microsoft-pr.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,20 @@ jobs:
6969
run: |
7070
echo "Target branch: ${{ github.base_ref }}"
7171
yarn nx release --dry-run --verbose
72+
73+
yarn-constraints:
74+
name: "Check Yarn Constraints"
75+
permissions: {}
76+
runs-on: ubuntu-latest
77+
steps:
78+
- uses: actions/checkout@v4
79+
with:
80+
filter: blob:none
81+
fetch-depth: 0
82+
- uses: actions/setup-node@v4
83+
with:
84+
node-version: '22'
85+
- name: Install dependencies
86+
run: yarn
87+
- name: Check constraints
88+
run: yarn constraints

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,12 @@
5252
"@definitelytyped/dtslint": "^0.0.127",
5353
"@jest/create-cache-key-function": "^29.6.3",
5454
"@nx/js": "^21.2.4",
55-
"@react-native/metro-babel-transformer": "0.77.0-main",
56-
"@react-native/metro-config": "0.77.0-main",
55+
"@react-native/metro-babel-transformer": "workspace:*",
56+
"@react-native/metro-config": "workspace:*",
5757
"@tsconfig/node18": "1.0.1",
5858
"@types/react": "^19.0.0",
5959
"@typescript-eslint/parser": "^7.1.1",
60+
"@yarnpkg/types": "^4.0.1",
6061
"ansi-styles": "^4.2.1",
6162
"babel-plugin-minify-dead-code-elimination": "^0.5.2",
6263
"babel-plugin-syntax-hermes-parser": "0.25.1",

packages/babel-plugin-codegen/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
],
2828
"dependencies": {
2929
"@babel/traverse": "^7.25.3",
30-
"@react-native/codegen": "0.77.0-main"
30+
"@react-native/codegen": "workspace:*"
3131
},
3232
"devDependencies": {
3333
"@babel/core": "^7.25.2"

packages/community-cli-plugin/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"dist"
2424
],
2525
"dependencies": {
26-
"@react-native/dev-middleware": "0.77.0-main",
27-
"@react-native/metro-babel-transformer": "0.77.0-main",
26+
"@react-native/dev-middleware": "workspace:*",
27+
"@react-native/metro-babel-transformer": "workspace:*",
2828
"chalk": "^4.0.0",
2929
"debug": "^2.2.0",
3030
"invariant": "^2.2.4",

packages/dev-middleware/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
],
2525
"dependencies": {
2626
"@isaacs/ttlcache": "^1.4.1",
27-
"@react-native/debugger-frontend": "0.77.0-main",
27+
"@react-native/debugger-frontend": "workspace:*",
2828
"chrome-launcher": "^0.15.2",
2929
"chromium-edge-launcher": "^0.2.0",
3030
"connect": "^3.6.5",

packages/eslint-config-react-native/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"dependencies": {
2424
"@babel/core": "^7.25.2",
2525
"@babel/eslint-parser": "^7.25.1",
26-
"@react-native/eslint-plugin": "0.77.0-main",
26+
"@react-native/eslint-plugin": "workspace:*",
2727
"@typescript-eslint/eslint-plugin": "^7.1.1",
2828
"@typescript-eslint/parser": "^7.1.1",
2929
"eslint-config-prettier": "^8.5.0",

packages/eslint-plugin-specs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"dependencies": {
2828
"@babel/core": "^7.25.2",
2929
"@babel/plugin-transform-flow-strip-types": "^7.25.2",
30-
"@react-native/codegen": "0.77.0-main",
30+
"@react-native/codegen": "workspace:*",
3131
"make-dir": "^2.1.0",
3232
"pirates": "^4.0.1",
3333
"source-map-support": "0.5.0"

packages/metro-config/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
"dist"
2828
],
2929
"dependencies": {
30-
"@react-native/js-polyfills": "0.77.0-main",
31-
"@react-native/metro-babel-transformer": "0.77.0-main",
30+
"@react-native/js-polyfills": "workspace:*",
31+
"@react-native/metro-babel-transformer": "workspace:*",
3232
"metro-config": "^0.81.0",
3333
"metro-runtime": "^0.81.0"
3434
}

packages/nx-release-version/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@react-native-macos/nx-release-version",
33
"version": "0.0.1-dev",
4+
"private": true,
45
"description": "Nx Release Version Actions for React Native macOS",
56
"homepage": "https://github.com/microsoft/react-native-macos/tree/HEAD/packages/nx-release-version#readme",
67
"license": "MIT",

packages/react-native-babel-preset/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"@babel/plugin-transform-typescript": "^7.25.2",
5757
"@babel/plugin-transform-unicode-regex": "^7.24.7",
5858
"@babel/template": "^7.25.0",
59-
"@react-native/babel-plugin-codegen": "0.77.0-main",
59+
"@react-native/babel-plugin-codegen": "workspace:*",
6060
"babel-plugin-syntax-hermes-parser": "0.25.1",
6161
"babel-plugin-transform-flow-enums": "^0.0.2",
6262
"react-refresh": "^0.14.0"

0 commit comments

Comments
 (0)