[rush] New commands "rush link-package" and "rush bridge-package" #5123
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Since the relevant background has already been introduced in the Design Proposal, this section will mainly focus on some implementation details.
Details
rush link-package
rush link-package
will create a symbolic link of the target package to thenode_modules
directory of the current package.Usage:
rush bridge-package
Since
rush link-package
cannot resolve issues caused bypeerDependencies
, we providerush bridge-package
to address this problem, which is based on hard links and symbolic links.It is based on pnpm-sync behind the scenes, which means it will automatically help me with synchronization during the build.
At the same time, we should have the concept that we cannot fully equate this with installing third-party dependencies, nor should we attempt to implement this capability.
Let's say the target-package includes
react
as apeerDependency
, the current dependency model is:Usage:
We also offer a way to directly replace the artifacts, backed by pnpm-sync behind the scenes.
Usage:
rush-link-state.json
rush-link-state.json
used to store information about packages connected viarush link-package
andrush bridge-package
commands.Thus, it can be avoided from being skipped when running
rush install
.How it was tested
The target package can be correctly accessed under the current package.