Skip to content
Closed
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"babel-plugin-syntax-hermes-parser": "0.25.1",
"babel-plugin-transform-define": "^2.1.4",
"babel-plugin-transform-flow-enums": "^0.0.2",
"chalk": "^4.0.0",
"chalk": "^4.1.2",
"clang-format": "^1.8.0",
"connect": "^3.6.5",
"deep-equal": "1.1.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/community-cli-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
"dependencies": {
"@react-native/dev-middleware": "workspace:*",
"@react-native/metro-babel-transformer": "workspace:*",
"chalk": "^4.0.0",
"chalk": "^4.1.2",
"debug": "^2.2.0",
"invariant": "^2.2.4",
"metro": "^0.81.0",
"metro-config": "^0.81.0",
"metro-core": "^0.81.0",
"readline": "^1.3.0",
"semver": "^7.1.3"
"semver": "^7.7.2"
},
"devDependencies": {
"metro-resolver": "^0.81.0"
Expand Down
8 changes: 4 additions & 4 deletions packages/helloworld/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
"@babel/core": "^7.25.2",
"@babel/preset-env": "^7.25.3",
"@babel/runtime": "^7.25.0",
"@react-native/babel-preset": "0.77.0-main",
"@react-native/core-cli-utils": "0.77.0-main",
"@react-native/eslint-config": "0.77.0-main",
"@react-native/metro-config": "0.77.0-main",
"@react-native/babel-preset": "workspace:*",
"@react-native/core-cli-utils": "workspace:*",
"@react-native/eslint-config": "workspace:*",
"@react-native/metro-config": "workspace:*",
"chalk": "^4.1.2",
"commander": "^12.0.0",
"eslint": "^8.19.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-codegen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@babel/plugin-transform-object-rest-spread": "^7.24.7",
"@babel/plugin-transform-optional-chaining": "^7.24.8",
"@babel/preset-env": "^7.25.3",
"chalk": "^4.0.0",
"chalk": "^4.1.2",
"hermes-estree": "0.25.1",
"micromatch": "^4.0.4",
"prettier": "2.8.8",
Expand Down
6 changes: 3 additions & 3 deletions packages/react-native-macos-init/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
},
"bin": "./bin.js",
"dependencies": {
"chalk": "^3",
"chalk": "^4.1.2",
"find-up": "^4.1.0",
"npm-registry-fetch": "^14.0.0",
"prompts": "^2.3.0",
"semver": "^7.5.2",
"yargs": "^15.1.0"
"semver": "^7.7.2",
"yargs": "^17.6.2"
},
"devDependencies": {
"@rnx-kit/tsconfig": "^2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native-popup-menu-android/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@react-native/popup-menu-android",
"name": "@react-native-macos/popup-menu-android",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Undo

"version": "0.77.0-main",
"private": true,
"description": "PopupMenu for the Android platform",
Expand All @@ -23,7 +23,7 @@
"peerDependencies": {
"@types/react": "^19.0.0",
"react": "*",
"react-native": "*"
"react-native-macos": "workspace:*"
},
"peerDependenciesMeta": {
"@types/react": {
Expand Down
3 changes: 2 additions & 1 deletion packages/react-native-test-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@
"devDependencies": {
"@babel/core": "^7.25.2",
"@react-native/babel-preset": "workspace:*",
"react": "19.0.0",
"react-native-macos": "workspace:*"
},
"peerDependencies": {
"react": "*",
"react-native-macos": "*"
"react-native-macos": "workspace:*"
},
"codegenConfig": {
"name": "OSSLibraryExampleSpec",
Expand Down
8 changes: 6 additions & 2 deletions packages/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
}
},
"dependencies": {
"@babel/core": "^7.25.2",
"@jest/create-cache-key-function": "^29.6.3",
"@react-native-macos/virtualized-lists": "workspace:*",
"@react-native/assets-registry": "workspace:*",
Expand All @@ -124,7 +125,7 @@
"babel-jest": "^29.7.0",
"babel-plugin-syntax-hermes-parser": "0.25.1",
"base64-js": "^1.5.1",
"chalk": "^4.0.0",
"chalk": "^4.1.2",
"commander": "^12.0.0",
"event-target-shim": "^5.0.1",
"flow-enums-runtime": "^0.0.6",
Expand All @@ -141,7 +142,7 @@
"react-refresh": "^0.14.0",
"regenerator-runtime": "^0.13.2",
"scheduler": "0.25.0",
"semver": "^7.1.3",
"semver": "^7.7.2",
"stacktrace-parser": "^0.1.10",
"whatwg-fetch": "^3.0.0",
"ws": "^6.2.3",
Expand All @@ -164,5 +165,8 @@
"jsSrcsDir": "src"
}
]
},
"devDependencies": {
"react": "19.0.0"
}
}
3 changes: 2 additions & 1 deletion packages/rn-tester/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"e2e-test-ios": "./scripts/maestro-test-ios.sh"
},
"dependencies": {
"@react-native-macos/popup-menu-android": "workspace:*",
"@react-native/oss-library-example": "workspace:*",
"@react-native/popup-menu-android": "workspace:*",
"flow-enums-runtime": "^0.0.6",
"invariant": "^2.2.4",
"nullthrows": "^1.1.1"
Expand All @@ -54,6 +54,7 @@
"@react-native-community/cli": "15.0.0-alpha.2",
"@react-native-community/cli-platform-android": "15.0.0-alpha.2",
"@react-native-community/cli-platform-ios": "15.0.0-alpha.2",
"react": "19.0.0",
"react-native-macos": "workspace:*"
}
}
7 changes: 6 additions & 1 deletion packages/virtualized-lists/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,21 @@
"nullthrows": "^1.1.1"
},
"devDependencies": {
"react": "19.0.0",
"react-test-renderer": "19.0.0"
},
"peerDependencies": {
"@types/react": "^19.0.0",
"react": "*",
"react-native": "*"
"react-native": "*",
"react-native-macos": "workspace:*"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
},
"react-native": {
"optional": true
}
}
}
2 changes: 1 addition & 1 deletion tools/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"license": "MIT",
"private": true,
"dependencies": {
"chalk": "^4.0.0",
"chalk": "^4.1.2",
"glob": "^7.1.1",
"ini": "^5.0.0"
}
Expand Down
171 changes: 170 additions & 1 deletion yarn.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,157 @@ const {defineConfig} = require('@yarnpkg/types');
* @typedef {import('@yarnpkg/types').Yarn.Constraints.Dependency} Dependency
*/

const IGNORE_CONSISTENT_DEPENDENCIES_FOR = new Set([
`.`,
`packages/docusaurus`,
]);

/**
* This rule will enforce that a workspace MUST depend on the same version of a dependency as the one used by the other workspaces
* We allow Docusaurus to have different dependencies for now; will be addressed later (when we remove Gatsby)
* @param {Context} context
*/
function enforceConsistentDependenciesAcrossTheProject({Yarn}) {
for (const dependency of Yarn.dependencies()) {
if (IGNORE_CONSISTENT_DEPENDENCIES_FOR.has(dependency.workspace.cwd))
continue;

if (dependency.type === `peerDependencies`)
continue;

for (const otherDependency of Yarn.dependencies({ident: dependency.ident})) {
if (IGNORE_CONSISTENT_DEPENDENCIES_FOR.has(otherDependency.workspace.cwd))
continue;

if (otherDependency.type === `peerDependencies`)
continue;

if ((dependency.type === `devDependencies` || otherDependency.type === `devDependencies`) && Yarn.workspace({ident: otherDependency.ident}))
continue;

dependency.update(otherDependency.range);
}
}
}

/**
* This rule will enforce that a workspace MUST depend on the same version of a dependency as the one used by the other workspaces
* We allow Docusaurus to have different dependencies for now; will be addressed later (when we remove Gatsby)
* @param {Context} context
*/
function enforceWorkspaceDependenciesWhenPossible({Yarn}) {
for (const dependency of Yarn.dependencies()) {
if (!Yarn.workspace({ident: dependency.ident}))
continue;

dependency.update(`workspace:*`);
}
}

/**
* @param {Context} context
* @param {string} ident
* @param {string} explanation
*/
function forbidDependency({Yarn}, ident, explanation) {
for (const dependency of Yarn.dependencies({ident})) {
dependency.error(explanation);
}
}

/**
* @param {Context} context
* @param {Record<string, ((workspace: Workspace) => any) | string>} fields
*/
function enforceFieldsOnAllWorkspaces({Yarn}, fields) {
for (const workspace of Yarn.workspaces()) {
for (const [field, value] of Object.entries(fields)) {
workspace.set(field, typeof value === `function` ? value(workspace) : value);
}
}
}

/**
* @param {Context} context
* @param {string} ident
* @param {string} otherIdent
* @param {boolean} mustExist
*/
function enforceDependencyRelationship({Yarn}, ident, otherIdent, mustExist) {
for (const dependency of Yarn.dependencies({ident})) {
if (dependency.type === `peerDependencies`)
continue;

const hasOtherDependency = Yarn.dependency({
workspace: dependency.workspace,
ident: otherIdent,
});

if (mustExist) {
if (hasOtherDependency)
continue;

dependency.error(`The presence of ${ident} in ${dependency.type} mandates the presence of ${otherIdent}`);
} else {
if (!hasOtherDependency)
continue;

dependency.error(`The presence of ${ident} in ${dependency.type} forbids the presence of ${otherIdent}`);
}
}
}


/**
* Validate that all peer dependencies are provided. If one isn't, the
* constraint will try to fix it by looking at what's used in the other
* workspaces of the project. If it doesn't find any way to satisfy the
* dependency, it will generate an error.
*
* @param {Context} context
*/
function enforcePeerDependencyPresence({Yarn}) {
for (const workspace of Yarn.workspaces()) {
// The Gatsby website is pretty much deprecated anyway
if (workspace.cwd === `packages/gatsby`)
continue;

for (const dependency of Yarn.dependencies({workspace})) {
if (dependency.type === `peerDependencies`)
continue;

if (!dependency.resolution)
continue;

for (const peerName of dependency.resolution.peerDependencies.keys()) {
// Webpack plugins have peer dependencies but don't often need it; weird
if (peerName === `webpack`)
continue;

if (dependency.resolution.dependencies.has(peerName))
continue;

const otherDeps = Yarn.dependencies({ident: peerName})
.filter(otherDep => otherDep.type !== `peerDependencies`);

if (otherDeps.length === 0)
workspace.error(`Missing dependency on ${peerName} (required by ${dependency.ident})`);

// If the workspace has itself a peer dependency of the same name, then
// we assume that it'll be fulfilled by its ancestors in the dependency
// tree, so we only need to add the dependency to devDependencies.
const autofixTarget = Yarn.dependency({workspace, ident: peerName, type: `peerDependencies`})
? `devDependencies`
: `dependencies`;

for (const otherDep of otherDeps) {
workspace.set([autofixTarget, peerName], otherDep.range);
}
}
}
}
}

/**
* Enforce that react-native-macos declares a peer dependency on react-native on release branches,
* except on the main branch, where there is no published version of React Native to align to.
Expand Down Expand Up @@ -109,8 +260,26 @@ function enforceReactNativeMacosVersionConsistency({Yarn}) {

module.exports = defineConfig({
constraints: async ctx => {
// Constraints copied from the Yarn monorepo
enforceConsistentDependenciesAcrossTheProject(ctx);
enforceWorkspaceDependenciesWhenPossible(ctx);
enforcePeerDependencyPresence(ctx);
// enforceFieldsOnAllWorkspaces(ctx, {
// license: `MIT`,
// // When changing the engines.node value check https://node.green/ for
// // which ECMAScript version is fully supported and update the following files as needed:
// // - tsconfig.json
// // - packages/eslint-config/index.js
// // - packages/yarnpkg-builder/sources/commands/new/plugin.ts
// [`engines.node`]: `>=18.12.0`,
// [`repository.type`]: `git`,
// [`repository.url`]: `git+https://github.com/yarnpkg/berry.git`,
// [`repository.directory`]: workspace => workspace.cwd,
// });

// React Native macOS specific constraints
expectReactNativePeerDependency(ctx);
enforceReactNativeVersionConsistency(ctx);
enforceReactNativeMacosVersionConsistency(ctx);
},
});
});
Loading
Loading