Skip to content
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

fix: yarn peers #7932

Merged
merged 2 commits into from
Mar 19, 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: 2 additions & 1 deletion packages/@react-spectrum/button/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
},
"peerDependencies": {
"@react-spectrum/provider": "^3.0.0",
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
},
"publishConfig": {
"access": "public"
Expand Down
3 changes: 2 additions & 1 deletion packages/@react-spectrum/checkbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
},
"peerDependencies": {
"@react-spectrum/provider": "^3.0.0",
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
},
"publishConfig": {
"access": "public"
Expand Down
3 changes: 2 additions & 1 deletion packages/@react-spectrum/divider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"@adobe/spectrum-css-temp": "3.0.0-alpha.1"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
},
"publishConfig": {
"access": "public"
Expand Down
3 changes: 2 additions & 1 deletion packages/@react-spectrum/dropzone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
},
"peerDependencies": {
"@react-spectrum/provider": "^3.0.0",
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
},
"publishConfig": {
"access": "public"
Expand Down
3 changes: 2 additions & 1 deletion packages/@react-spectrum/filetrigger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
},
"peerDependencies": {
"@react-spectrum/provider": "^3.0.0",
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
},
"publishConfig": {
"access": "public"
Expand Down
3 changes: 2 additions & 1 deletion packages/@react-spectrum/switch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
},
"peerDependencies": {
"@react-spectrum/provider": "^3.0.0",
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
},
"publishConfig": {
"access": "public"
Expand Down
3 changes: 2 additions & 1 deletion packages/@react-spectrum/text/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
},
"peerDependencies": {
"@react-spectrum/provider": "^3.0.0",
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
},
"publishConfig": {
"access": "public"
Expand Down
3 changes: 2 additions & 1 deletion packages/@react-types/card/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"@react-types/shared": "^3.28.0"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
},
"publishConfig": {
"access": "public"
Expand Down
3 changes: 2 additions & 1 deletion packages/@react-types/sidenav/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"@react-types/shared": "^3.1.0"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
},
"publishConfig": {
"access": "public"
Expand Down
3 changes: 2 additions & 1 deletion packages/@spectrum-icons/color/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
},
"peerDependencies": {
"@react-spectrum/provider": "^3.0.0",
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
},
"publishConfig": {
"access": "public"
Expand Down
3 changes: 2 additions & 1 deletion packages/@spectrum-icons/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
},
"peerDependencies": {
"@react-spectrum/provider": "^3.0.0",
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
},
"publishConfig": {
"access": "public"
Expand Down
3 changes: 2 additions & 1 deletion packages/@spectrum-icons/workflow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
},
"peerDependencies": {
"@react-spectrum/provider": "^3.0.0",
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
},
"publishConfig": {
"access": "public"
Expand Down
36 changes: 35 additions & 1 deletion yarn.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ function enforceWorkspaceDependencies({Yarn}) {
if (dependency.type === 'peerDependencies') {continue;}

for (const otherDependency of Yarn.dependencies({ident: dependency.ident})) {
if (otherDependency.type === 'peerDependencies') {continue;}
if (otherDependency.type === 'peerDependencies') {
continue;
}

if (isOurPackage(dependency)) {
// change back to workspaces:^ when we're ready for yarn to handle versioning
Expand All @@ -142,6 +144,38 @@ function enforceWorkspaceDependencies({Yarn}) {
}
}
}

// This finds all the peer dependencies and checks that everything up the
// workspace tree has the same peer dependency.
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't yarn itself check these? How did you find them in the first place?

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought yarn should catch these, but for some reason it didn't, I don't know why.

Found them through the issue that was opened against us and by running the command I listed in the description on their reproduction repo.

I'd like to get this fixed for the user and then spend some time figuring out if there is a bug in yarn, possibly upgrading to a newer version would fix it.

let seen = new Map();
for (const dependency of Yarn.dependencies()) {
if (dependency.type === 'peerDependencies') {
for (const workspace of Yarn.workspaces()) {
if (
// must check in manifest because yarn is reporting all peer in workspace.pkg.dependencies
// and doesn't differentiate between peer and dependencies
workspace.manifest.dependencies?.[dependency.workspace?.ident]
&& !workspace.manifest.peerDependencies?.[dependency.ident]
&& !workspace.manifest.dependencies?.[dependency.ident]
) {
// eslint-disable-next-line max-depth
if (seen.has(workspace.ident) && !seen.get(workspace.ident).includes(dependency.ident)) {
seen.get(workspace.ident).push(dependency.ident);
workspace.set('peerDependencies', {
...workspace.manifest.peerDependencies,
[dependency.ident]: dependency.range
});
} else if (!seen.has(workspace.ident)) {
seen.set(workspace.ident, [dependency.ident]);
workspace.set('peerDependencies', {
...workspace.manifest.peerDependencies,
[dependency.ident]: dependency.range
});
}
}
}
}
}
}

/** @param {Context} context */
Expand Down
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7052,6 +7052,7 @@ __metadata:
peerDependencies:
"@react-spectrum/provider": ^3.0.0
react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
react-dom: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -7153,6 +7154,7 @@ __metadata:
peerDependencies:
"@react-spectrum/provider": ^3.0.0
react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
react-dom: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -7353,6 +7355,7 @@ __metadata:
"@swc/helpers": "npm:^0.5.0"
peerDependencies:
react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
react-dom: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -7426,6 +7429,7 @@ __metadata:
peerDependencies:
"@react-spectrum/provider": ^3.0.0
react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
react-dom: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
languageName: unknown
linkType: soft

Expand All @@ -7440,6 +7444,7 @@ __metadata:
peerDependencies:
"@react-spectrum/provider": ^3.0.0
react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
react-dom: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -8079,6 +8084,7 @@ __metadata:
peerDependencies:
"@react-spectrum/provider": ^3.0.0
react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
react-dom: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -8228,6 +8234,7 @@ __metadata:
peerDependencies:
"@react-spectrum/provider": ^3.0.0
react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
react-dom: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -8963,6 +8970,7 @@ __metadata:
"@react-types/shared": "npm:^3.28.0"
peerDependencies:
react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
react-dom: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -9253,6 +9261,7 @@ __metadata:
"@react-types/shared": "npm:^3.1.0"
peerDependencies:
react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
react-dom: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -9515,6 +9524,7 @@ __metadata:
peerDependencies:
"@react-spectrum/provider": ^3.0.0
react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
react-dom: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -9561,6 +9571,7 @@ __metadata:
peerDependencies:
"@react-spectrum/provider": ^3.0.0
react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
react-dom: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
languageName: unknown
linkType: soft

Expand All @@ -9576,6 +9587,7 @@ __metadata:
peerDependencies:
"@react-spectrum/provider": ^3.0.0
react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
react-dom: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
languageName: unknown
linkType: soft

Expand Down