Skip to content

Commit e0c34cb

Browse files
committed
fix: ensure all @react-native scoped packaged are marked private
1 parent 38e9c69 commit e0c34cb

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

yarn.config.cjs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function expectReactNativePeerDependency({Yarn}) {
3535
/**
3636
* Enforce that all @react-native/ scoped packages use the same version
3737
* as the react-native peer dependency declared in react-native-macos.
38-
* On the main branch, enforce that we use workspace:* for @react-native/ packages.
38+
* Enforce that we use workspace:* for @react-native/ packages.
3939
* @param {Context} context
4040
*/
4141
function enforceReactNativeVersionConsistency({Yarn}) {
@@ -60,18 +60,16 @@ function enforceReactNativeVersionConsistency({Yarn}) {
6060
return;
6161
}
6262
targetVersion = rnPeerDependency;
63-
} // Enforce this version on all @react-native/ scoped packages across all workspaces
63+
}
64+
// Enforce this version on all @react-native/ scoped packages across all workspaces
6465
for (const dependency of Yarn.dependencies()) {
6566
if (dependency.ident.startsWith('@react-native/')) {
66-
// Check if the target package is private (not published)
67-
const targetWorkspace = Yarn.workspace({ident: dependency.ident});
68-
const isPrivatePackage = targetWorkspace && targetWorkspace.manifest.private;
69-
70-
if (isPrivatePackage) {
71-
// Private packages should always use workspace:* since they're not published
67+
Yarn.workspace({ident: dependency.ident})?.set('private', true);
68+
69+
// Don't use `workspace:*` for `react-native-macos` or `@react-native-macos/` scoped packages (AKA, packages we have forked
70+
// until nx release with Yarn 4 supports it.
71+
if (dependency.workspace.ident !== 'react-native-macos' || dependency.workspace.ident.startsWith('@react-native-macos/')) {
7272
dependency.update('workspace:*');
73-
} else {
74-
dependency.update(targetVersion);
7573
}
7674
}
7775
}

0 commit comments

Comments
 (0)