rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

[rush] Design proposal: An improved alternative to "rush-pnpm link"

Open L-Qun opened this issue 10 months ago • 0 comments

Summary

From the description of pnpm link, its functionality is very straightforward—it simply links the target package to the node_modules directory.

Image

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.

Image

It seems that this issue has been resolved in pnpm@10. But it will automatically make some configuration changes for me.

Image

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.

Image

Details

  1. 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
  1. 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.

Image

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:

Image

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:

Image

I think both of these commands are essential. The first one is simple and intuitive, while the second may require additional configuration.

L-Qun avatar Jan 23 '25 07:01 L-Qun