I’m reopening #2250 which was closed a bit too hastily. I just hit the use case of wanting to read yarn.lock from Python (as an introspection step), and although I thought yarn.lock was yaml, it’s actually not. It’s almost yaml.
Pipenv, which is heavily inspired by yarn, uses json for its lockfile which makes it very easy to parse.
I suggest either using json or yaml for the lockfile v2. If yaml’s large featureset is an issue, I know there’s “strict yaml” subsets (at least here for Python, I don’t know for JS). JSON would make the most sense but that does mean comments would no longer be available.
The initial design goals, iirc:
JSON didn’t meet 1 (which was an arbitrary choice in some extent, I don’t see the point of debating whether or not you agree with it), and YAML didn’t meet 3. The flat style of the file was required by 2 and some internal architectural choices.
Imo we should have used a stricter subset of yaml (one missing feature however is that our lockfile supports multi-keys properties, which are annoying to do in yaml without backreferences; so we would have had to reparse the keys to split on
,
anyway), but now the ecosystem is what it is, and we have to deal with it.Of course not…😒
I can’t tell for sure, but I think it just was called this way because a) it “locks” the dependencies and b) the shrinkwrap files produced by the NPM cli were riddled with bugs and I guess Yarn wanted to make the distinction super clear.
As a non anglophone speaker, I can also say that even after two years working on Yarn, I still had no idea what the literal meaning of the word😝
shrinkwrap
was until you brought the subject, so I guess calling it lockfile also helps international users@pgonzal I always assumed it was because Yehuda Katz had some initial input in the origin of the Yarn project. He was also one of the creators of Ruby Bundler, and Bundler uses the
.lock
convention https://bundler.io/v1.7/rationale.html#checking-your-code-into-version-controlYarn’s lock file serves basically the same purpose as Bundler’s, so I think that’s where the concept and name was taken from.