rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

[rush] [discussion] how to work with outside projects that need to be linked?

Open trusktr opened this issue 5 years ago • 11 comments

Not all projects that need to be npm linked 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?

trusktr avatar Jan 25 '20 07:01 trusktr

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.

apostolisms avatar Jan 27 '20 18:01 apostolisms

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

trusktr avatar Jan 28 '20 04:01 trusktr

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.

slavafomin avatar May 13 '21 11:05 slavafomin

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

octogonz avatar May 26 '21 20:05 octogonz

The https://github.com/domclick/super-rush tool may also be related to this.

octogonz avatar Jul 27 '21 05:07 octogonz

I wrote here the way that I use work locally, maybe it could help you.

hyanmandian avatar Aug 05 '21 18:08 hyanmandian

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

Measy avatar Aug 10 '21 07:08 Measy

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

VamKram avatar Apr 20 '22 03:04 VamKram

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 avatar Jun 10 '22 23:06 octogonz

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

bohnman avatar May 24 '23 12:05 bohnman