Description
Summary
Rush treats npm alias as link when subspace is enabled.
Repro steps
This repository can reproduce this issue:https://github.com/fzxen/rushstack_reproduce
My project has two subspaces, one is default subspace, and the other is named test-library.
There is a package existing under the default space, which uses npm alias to declare its dependencies.
{
"devDependencies": {
"@testing-library/dom": "workspace:*",
"@testing-library/dom-npm": "npm:@testing-library/dom@^10.4.0"
}
}
@testing-library/dom is a package in test-library subspace. I expect @testing-library/dom-npm can be downloaded from npm instead of directly creating a local symbol link.
Expected result:
pnpm will download @testing-library/dom from npm.
../../../projects/project1:
devDependencies:
'@testing-library/dom':
specifier: link:../test-library-dom
version: link:../test-library-dom
'@testing-library/dom-npm':
specifier: npm:@testing-library/dom@^10.4.0
version: 10.4.0
Actual result:
pnpm directly links to a package named @testing-library/dom in another sub-space.
I also tried adding @testing-library/dom-npm
to decoupledLocalDependencies, but got the same result.
../../../projects/project1:
devDependencies:
'@testing-library/dom':
specifier: link:../test-library-dom
version: link:../test-library-dom
'@testing-library/dom-npm':
specifier: link:../test-library-dom
version: link:../test-library-dom
Details
I located the code causing this problem.
rushstack/libraries/rush-lib/src/logic/pnpm/SubspaceGlobalPnpmfileShim.ts
Lines 127 to 148 in 66196ff
The rush
pnpmfile script will resolve npm aliases. As long as there is a dependency with the same name in the workspace, it will directly change to link:
.
I think that the original specifier should be maintained and should not be changed to link:
When this dependency is added to decoupledLocalDependencies
.
Standard questions
Please answer these questions to help us investigate your issue more quickly:
Question | Answer |
---|---|
@microsoft/rush globally installed version? |
5.153.1 |
rushVersion from rush.json? |
5.153.1 |
useWorkspaces from rush.json? |
Yes |
Operating system? | Mac |
Would you consider contributing a PR? | Yes |
Node.js version (node -v )? |
20.16.0 |
Metadata
Metadata
Assignees
Labels
Type
Projects
Status