berry icon indicating copy to clipboard operation
berry copied to clipboard

[Feature] Expected `yarn link ...` does not change package.json and lockfile

Open WhiteMinds opened this issue 3 years ago • 8 comments

  • [ ] I'd be willing to implement this feature (contributing guide)
  • [ ] This feature is important to have in this repository; a contrib plugin wouldn't do

Describe the user story

Developing multiple packages in the case of local non -Monorepo, I will last long to perform Yarn Link, but this configuration should not be uploaded to Git. The current version of yarn will change the package.json and lockfile during yarn link, which will affect my git operation.

Describe the solution you'd like

Can you provide a file like yarn.linked to indicate linked Instead of changing package.json? So I can add the file(yarn.linked) in ignore.

Describe the drawbacks of your solution

No thought, just trying to suggest.

Describe alternatives you've considered

Like yarn v1, global effect?

WhiteMinds avatar Sep 19 '22 09:09 WhiteMinds

There was an attempt made already 2019, see #90

benjaminr-ps avatar Sep 26 '22 14:09 benjaminr-ps

There was an attempt made already 2019, see #90

Oh, thanks.

I looked at it, it still didn't seem to be resolved, so sad 😢.

WhiteMinds avatar Sep 27 '22 13:09 WhiteMinds

Yeah this surprised me as well. I looked into a solution because "yarn link" v1 doesn't work correctly if you want to link a scoped package from a link dir. I thought the v3 version would solve this, however it changes package.json which isn't really a good solution if you intend to push the result.

Blackclaws avatar Sep 30 '22 12:09 Blackclaws

Until this problem is resolved, it seems that we will have to continue using yarn v1 😢.

WhiteMinds avatar Oct 13 '22 07:10 WhiteMinds

@WhiteMinds I think, you can still upgrade to latest berry version 3.x with the following workaround, doing no harm to package.json nor tsconfig.json:

  1. cd <project-a>
  2. YARN_IGNORE_PATH=1 yarn link
  3. cd <project-b>
  4. YARN_IGNORE_PATH=1 yarn link project-a

benjaminr-ps avatar Oct 18 '22 07:10 benjaminr-ps

@WhiteMinds I think, you can still upgrade to latest berry version 3.x with the following workaround, doing no harm to package.json nor tsconfig.json:

Thank you. It works great! Now I can go from classic link to berry and go from berry link to classic.

WhiteMinds avatar Oct 18 '22 07:10 WhiteMinds

I tried a solution like the one from @Venryx mentioned in #90 (yarn-vtools), but was disappointed to learn that this still changes your yarn.lock file.

robintown avatar Mar 14 '25 16:03 robintown

It'll take some time, but it's definitely something I'd like to address in the next major or the one after. Generally I'd like to extend the concept of workspaces to external repositories, although I'm not fully sure yet how this would materialize.

arcanis avatar Mar 14 '25 16:03 arcanis