diff --git a/common/changes/@microsoft/rush/chao-improve-getPackageJsonInjectedDependenciesHash_2024-06-26-04-40.json b/common/changes/@microsoft/rush/chao-improve-getPackageJsonInjectedDependenciesHash_2024-06-26-04-40.json new file mode 100644 index 00000000000..7e622d89389 --- /dev/null +++ b/common/changes/@microsoft/rush/chao-improve-getPackageJsonInjectedDependenciesHash_2024-06-26-04-40.json @@ -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" +} \ No newline at end of file diff --git a/common/config/subspaces/build-tests-subspace/repo-state.json b/common/config/subspaces/build-tests-subspace/repo-state.json index 43d9919959f..da55ddba3fa 100644 --- a/common/config/subspaces/build-tests-subspace/repo-state.json +++ b/common/config/subspaces/build-tests-subspace/repo-state.json @@ -2,5 +2,5 @@ { "pnpmShrinkwrapHash": "c040a0d59aada7e1f9bdf0916df7079547de3a85", "preferredVersionsHash": "ce857ea0536b894ec8f346aaea08cfd85a5af648", - "packageJsonInjectedDependenciesHash": "f3a12861197ad52c4c30bdaceed213a8dfe77a23" + "packageJsonInjectedDependenciesHash": "5ae59c4febdaa2b4d21f7e19b0d7a8a5b56f4e60" } diff --git a/libraries/rush-lib/src/api/Subspace.ts b/libraries/rush-lib/src/api/Subspace.ts index e28268fb775..8b9248143b6 100644 --- a/libraries/rush-lib/src/api/Subspace.ts +++ b/libraries/rush-lib/src/api/Subspace.ts @@ -379,6 +379,10 @@ export class Subspace { return undefined; } + const allWorkspaceProjectSet: Set = new Set( + this._rushConfiguration.projects.map((rushProject) => rushProject.packageName) + ); + // get all related package.json while (relatedProjects.length > 0) { const rushProject: RushConfigurationProject = relatedProjects.pop()!; @@ -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, diff --git a/rush.json b/rush.json index 5d01e0a3693..95e74696044 100644 --- a/rush.json +++ b/rush.json @@ -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.