Skip to content

Commit 529df9a

Browse files
committed
[rush] Fix performance in findOrphanedProjects
1 parent ba5ffaa commit 529df9a

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/rush",
5+
"comment": "Fix poor performance scaling during `rush install` when identifying projects in the lockfile that no longer exist.",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@microsoft/rush"
10+
}

libraries/rush-lib/src/logic/pnpm/PnpmShrinkwrapFile.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import type {
4242
ResolvedDependencies
4343
} from '@pnpm/lockfile.types';
4444
import { convertLockfileV9ToLockfileObject } from './PnpmShrinkWrapFileConverters';
45+
import type { IReadonlyLookupByPath } from '@rushstack/lookup-by-path';
4546

4647
const yamlModule: typeof import('js-yaml') = Import.lazy('js-yaml', require);
4748

@@ -812,12 +813,15 @@ export class PnpmShrinkwrapFile extends BaseShrinkwrapFile {
812813
return super.findOrphanedProjects(rushConfiguration, subspace);
813814
}
814815

816+
const subspaceTempFolder: string = subspace.getSubspaceTempFolderPath();
817+
const lookup: IReadonlyLookupByPath<RushConfigurationProject> =
818+
rushConfiguration.getProjectLookupForRoot(subspaceTempFolder);
819+
815820
const orphanedProjectPaths: string[] = [];
816821
for (const importerKey of this.getImporterKeys()) {
817-
// PNPM importer keys are relative paths from the workspace root, which is the common temp folder
818-
const rushProjectPath: string = path.resolve(subspace.getSubspaceTempFolderPath(), importerKey);
819-
if (!rushConfiguration.tryGetProjectForPath(rushProjectPath)) {
820-
orphanedProjectPaths.push(rushProjectPath);
822+
if (!lookup.findChildPath(importerKey)) {
823+
// PNPM importer keys are relative paths from the workspace root, which is the common temp folder
824+
orphanedProjectPaths.push(path.resolve(subspaceTempFolder, importerKey));
821825
}
822826
}
823827
return orphanedProjectPaths;

0 commit comments

Comments
 (0)