Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Append yarn-plugin-pin-deps to Contrib plugins #4552

Merged
merged 1 commit into from
Jun 15, 2022

Conversation

milesrichardson
Copy link
Contributor

@milesrichardson milesrichardson commented Jun 15, 2022

What's the problem this PR addresses?
This PR adds a new plugin to the list of "contrib plugins". The plugin is yarn-plugin-pin-deps, which adds a command yarn pin-deps. This command will find any dependencies referenced with a semver identifier, and will update package.json to replace that identifier with the exact version of the package currently resolved in the lockfile for that reference.

We've been using it "in production" for 1+ year and I recently migrated it to support Yarn 3, so I decided to also take the opportunity to package it as a plugin. It's worked well for our purposes, where the original goal was to migrate a mono-repo to use pinned dependencies. By it's nature it isn't something we use often, but we do occasionally use it to pin some dependency we accidentally installed without -E a few commits prior (granted, if I didn't have this plugin, I'd just remove the package and install it again - but it does help for migrating many dependencies all at once).

It's possible this plugin is not even necessary, or there is a way to accomplish this dependency pinning with basic yarn commands, but I'm not aware of it (at least, it was certainly not possible when I originally wrote this plugin). It's also possible that is has some oversight in how it pins dependencies that will cause weird bugs, but if so, I have not encountered it yet.

Please do let me know if there is better-supported way to pin dependencies to their currently resolved versions, so that I can delete the plugin 😄

How did you fix it?
I followed the "open a PR" link and used the wonderful GitHub editor to append a link to the plugin 😄 I hope I did not break any formatting.

Checklist

  • I have read the Contributing Guide.
  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

@milesrichardson milesrichardson changed the title Append yarn-plugin-pin-deps to community plugins docs: Append yarn-plugin-pin-deps to Contrib plugins Jun 15, 2022
@arcanis
Copy link
Member

arcanis commented Jun 15, 2022

Please do let me know if there is better-supported way to pin dependencies to their currently resolved versions, so that I can delete the plugin 😄

Something I wanted to allow was to have resolutions available within the constraints runtime. This way you could just have a constraint define that all dependencies must have their resolutions as range, and it'd auto-fix everything 🤔

@arcanis arcanis merged commit 82376c1 into yarnpkg:master Jun 15, 2022
@merceyz
Copy link
Member

merceyz commented Jun 15, 2022

but we do occasionally use it to pin some dependency we accidentally installed without -E a few commits prior

You can use defaultSemverRangePrefix to make yarn add always pin the dependency.

defaultSemverRangePrefix: ''

merceyz pushed a commit that referenced this pull request Oct 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants