rushstack
rushstack copied to clipboard
[rush] [discussion] how to work with outside projects that need to be linked?
Not all projects that need to be npm link
ed may always be in the rush-managed monorepo.
Suppose there's a package from the outside that we need to temporarily npm link
for development and testing while we submit a patch.
What's the recommended way to do this? Will running npm link external-package
inside a rush monorepo project cause problems with how rush tracks dependencies?
Currently npm link doesn't work consistently with Rush. This is can be valuable during testing an external dependency and we should design this feature further. The current way to do it is to add the project to your monorepo and test it that way. Please feel free to propose a design and work on this feature if you want.
:thinking: Hmmmm, maybe after the sub-module issues get worked out, then we could make a command that could accept a remote project URL and clone it into the specified path and add it to rush.json. F.e.:
rush add-project [email protected]:foo/bar.git packages/bar
The downside to this approach would be that it causes git modifications in the umbrella-repo.
What about a command like
rush add-project [email protected]:foo/bar.git --ignored
which adds the project to common/temp/project.json
which is similar to rush.json
's projects
array, and then clones the repo into common/temp/projects
. Rush would look both in rush.json
for projects, as well as in the new place.
Or something.
This is a very serious problem. It's a common practice to link some external library from GitHub in order to fix something in it and then to submit a PR. I think Rush should provide a utility to do so. Ideally, it should be temporary and shouldn't generate any changes in the monorepo itself.
Related issues:
- https://github.com/microsoft/rushstack/issues/2378 asks for
pnpm link
to work in a Rush repo - https://github.com/microsoft/rushstack/issues/2347 agreed on a general design for enabling PNPM workspace commands in a Rush repo, and is likely the solution for that
- https://github.com/microsoft/rushstack/issues/876 discusses how to link two entire monorepos together
The https://github.com/domclick/super-rush tool may also be related to this.
I wrote here the way that I use work locally, maybe it could help you.
I wrote here the way that I use work locally, maybe it could help you.
@hyanmandian I think it doesn't work in case rush monorepo need to link a external library, it works in external library needs link to rush's repo
Currently npm link doesn't work consistently with Rush. This is can be valuable during testing an external dependency and we should design this feature further. The current way to do it is to add the project to your monorepo and test it that way. Please feel free to propose a design and work on this feature if you want.
Would you please tell me what the new progress now
The rush-pnpm
command was introduced in Rush 5.74.0 which allows access to the pnpm link
command. It's a partial solution, but I still think Rush should have a built-in solution for this common scenario. Let's keep this issue open to track that.
@octogonz I'm not clear on how to use rush-pnpm link
to link to an outside project.
I run rush-pnpm link -g
from the outside project that I want to others to link to. This works fine. It creates a link in the global pnpm directory.
I then run rush-pnpm link -g @scope/mypackage
from the project that I want to use the link from. However, it ends up just deleting the link in the global pnpm directory instead of creating a link from node_modules/@scope/my-package
to the global pnpm directory.