Skip to content

[rush] Fix an edge case for workspace peer dependencies when calculating packageJsonInjectedDependenciesHash to improve its accuracy #4809

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

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/rush",
"comment": "Fix an edge case for workspace peer dependencies when calculating packageJsonInjectedDependenciesHash to improve its accuracy ",
"type": "none"
}
],
"packageName": "@microsoft/rush"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
{
"pnpmShrinkwrapHash": "c040a0d59aada7e1f9bdf0916df7079547de3a85",
"preferredVersionsHash": "ce857ea0536b894ec8f346aaea08cfd85a5af648",
"packageJsonInjectedDependenciesHash": "f3a12861197ad52c4c30bdaceed213a8dfe77a23"
"packageJsonInjectedDependenciesHash": "5ae59c4febdaa2b4d21f7e19b0d7a8a5b56f4e60"
}
14 changes: 14 additions & 0 deletions libraries/rush-lib/src/api/Subspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,10 @@ export class Subspace {
return undefined;
}

const allWorkspaceProjectSet: Set<string> = new Set(
this._rushConfiguration.projects.map((rushProject) => rushProject.packageName)
);

// get all related package.json
while (relatedProjects.length > 0) {
const rushProject: RushConfigurationProject = relatedProjects.pop()!;
Expand All @@ -395,6 +399,16 @@ export class Subspace {
resolutions
} = rushProject.packageJson;

// special handing for peerDependencies
// for workspace packages, the version range is meaningless here.
if (peerDependencies) {
for (const packageName of Object.keys(peerDependencies)) {
if (allWorkspaceProjectSet.has(packageName)) {
peerDependencies[packageName] = 'workspace:*';
}
}
}

allPackageJson.push({
name,
bin,
Expand Down
2 changes: 1 addition & 1 deletion rush.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* path segment in the "$schema" field for all your Rush config files. This will ensure
* correct error-underlining and tab-completion for editors such as VS Code.
*/
"rushVersion": "5.129.3",
"rushVersion": "5.129.5",

/**
* The next field selects which package manager should be installed and determines its version.
Expand Down
Loading