rushstack
rushstack copied to clipboard
[rush] Design proposal: An improved alternative to "rush-pnpm link"
Summary
From the description of pnpm link, its functionality is very straightforward—it simply links the target package to the node_modules directory.
However, pnpm performs more complex checks. For example, if a package's package.json includes workspace dependencies, pnpm will sequentially check whether the current workspace contains that package. If it doesn't, pnpm will throw an error.
It seems that this issue has been resolved in pnpm@10. But it will automatically make some configuration changes for me.
But we don't need these, right? Because the target path is uncertain, if we accidentally commit the changes, it will cause problems. At the same time, it creates symbolic links in the root node_modules directory, which means that the rush-pnpm link command will no longer work in pnpm@10.
We need two additional Rush commands to address this issue.
Details
rush link-package
cd my-project && rush link-package /path/to/repo/the-library
rush link-package /path/to/repo/the-library --project my-project --project framework
rush bridge-package
rush bridge-package /path/to/repo/the-library
The first one works similarly to pnpm link, but it prevents issues arising from version differences in pnpm. However, it still cannot address problems with peerDependencies.
The second approach is similar to installing a package normally, but with symbolic links, changes are automatically synchronized. The current dependency relationships are as follows:
The dependencies of this package should also be synchronized. For example, when both the dependent package and the dependency package rely on React, it can be correctly resolved. The current dependency relationships are as follows:
I think both of these commands are essential. The first one is simple and intuitive, while the second may require additional configuration.