How to symlink a package in workspace without updating yarn.lock?

1.9k views Asked by At

package.json -

"workspaces": [
  "packages/*",
  "samples/*"
],
"packageManager": "[email protected]"

I want to install and symlink the dependencies in samples but I don't want the yarn install to update the yarn.lock file. Is there a setting in workspaces or yarn to achieve this?

1

There are 1 answers

0
mycroes On

I think you want to use yarn add your-package@"workspace:^" (or other workspace: ranges). This does end up in your yarn.lock, but when publishing your package yarn will actually replace the dependency with a versioned dependency (depending on the range specifier). Also, it doesn't include any hash or anything in the yarn.lock, so you don't need to reinstall when changes are made to the package.