[rush-lib] Fix an bug when using pnpm 9, where a subspace is empty, the rush install fails
Summary
When using PNPM 9, if a subspace is empty. The rush install will throw follow error:
The shrinkwrap file has not been updated to support workspaces. Run "rush update --full" to update the shrinkwrap file.
However, after rush update --full, then rush install, the error still there.
This is due to, the isWorkspaceCompatible logic does not consider the empty lockfile case.
Here is the current logic:
this.isWorkspaceCompatible =
this.shrinkwrapFileMajorVersion >= ShrinkwrapFileMajorVersion.V9
? this.importers.size > 1
: this.importers.size > 0;
In a empty lockfile, the importers.size = 1, so I think we will need to change this logic to this.isWorkspaceCompatible = this.importers.size > 0
How it was tested
Manually tested with rush repo locally.
Impacted documentation
N/A
@fzxen Do you know what's intention to change this this.isWorkspaceCompatible for pnpm9? Right now, when I test it, I found out this logic could not support a empty subspace (which means a empty lockfile) when using pnpm9. So I revert the logic here.
@fzxen Do you know what's intention to change this
this.isWorkspaceCompatiblefor pnpm9? Right now, when I test it, I found out this logic could not support a empty subspace (which means a empty lockfile) when using pnpm9. So I revert the logic here.
@g-chao importers.size is always greater than 0 in pnpm lockfile v9
In non-workspace mode, the importers field of lockfilev9 is exists, but it does not in lockfilev6.
https://github.com/microsoft/rushstack/blob/724aa515c6c2d1a810dc8430576a7994c25ccb37/libraries/rush-lib/src/logic/test/shrinkwrapFile/non-workspace-pnpm-lock-v9.yaml#L7-L29