-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Implement a text-based lockfile format #11863
Comments
Feels like json5 could also be a good choice, that has a real spec at least. I realise there is no parser currently but surely it's better than having jsons that are not valid with most parsers |
Regarding json5 vs jsonc, there is a related issue with some discussion about tsconfig.json from a few years ago: |
This is following the Bun [guide][1]/[docs][2] for enabling git diffs for `bun.lockb` This won't work on GitHub, and this file isn't currently checked into git. It is supported by Renovate, so we could check it in, but there are various issues with this including [increased merge conflicts with dependency management][3] and [potential security threats][4]. This issue should be resolved and this change revertible when [Bun moves to a by-default text-based lockfile][5] and Renovate adds support [1]: https://bun.sh/guides/install/git-diff-bun-lockfile [2]: https://bun.sh/docs/install/lockfile#how-do-i-git-diff-bun-s-lockfile [3]: oven-sh/bun#5486 [4]: oven-sh/bun#5486 (comment) [5]: oven-sh/bun#11863
Good design goals from yarn:
To achieve 3 it is useful to have a dedicated format and parser. Diffability at yarn.lock is simply top notch. Yes, commas in JSON fixes the situation from catastrophic to acceptable, but yarn.locks are always more compact and win in readability over JSON files. The downside of a custom format is that if it is not compatible or is not a subset of some other, more common format, it will be harder to work with it at the user or infrastructure code level. In any case, this undertaking cannot but rejoice. |
This would really unblock bun for being usable in storybooks as parseable outputs are important for it to adopt as a supported package manager. storybookjs/storybook#28164 |
I'm not as familiar with the technical implications, but as a user I have to say that YAML makes a lot of sense in a long, auto-generated file like the lock file. |
Wondering why just re-using |
I think it's a good idea to keep a way to support a backwards compatible (package-lock.json) in addition to the current (binary) one. Then people could choose in the bunfig.toml if they are willing to pay the performance penalty in order to be more compatible with the node ecosystem. |
Two same lockfile content This is super annoying with Git. |
Re-using package-lock.json or yarn.lock will cause tooling problems. Lots of things rely on those to detect the package manager (for better or for worse). You'd end up with scripts installing things with yarn or npm if bun were to use the same name and/or format. |
If anyone thinks YAML is a good idea, read this: https://noyaml.com/ Sure, the basic concept of syntax is great, but there are too many pitfalls. That's why there are some simpler configuration languages with similar syntax which retain the same level of readability and diffability, while being simpler and way less error-prone. |
Maybe not as relevant for a lockfile, but there is some great innovation in better configuration files: https://nickel-lang.org/ |
I totally agree with you. YAML and other counterparts like TOML, are totally harmful and bad. Either go JSON or .js if you want full power. |
If you decide to move to jsonc, does this mean the current binary lock file going to change from yarn lock to the new jsonc. Also is bun going to provide a parser for the new lock file like yarn does or at least the types like pnpm? |
Is there any progress on the matter? It could be a game changer💪🏻 |
One additional benefit from a text-based format is the ability for a tool like Nix to parse it and pull dependencies for reproducible builds. Bun's largest pain point for me is the lack of a way to easily provide package lock information to Nix so that packages can be fetched for use in the sandbox. An awkward conversion of |
@Jarred-Sumner, text-based format is crucial for security, as dependency scanners cannot scan or read binary files. Please prioritize this feature. |
Another advantage of a text-based approach would be fewer merge conflicts. Tools like renovate can update buns binary lock files, but merge conflicts arise immediately. Effectively only one update can be merged |
We can disregard it and just rely on the package.json. Also, it's being replaced in the future: oven-sh/bun#11863.
This is a tracking issue for implementing a text-based lockfile format for
bun install
and making it the default format going forward. There will be a smooth migration path frombun.lockb
→bun.lock
.Why?
When first working on the package manager, the flamegraph showed parsing JSON was the biggest number. So instead of a JSON lockfile, we designed two efficient binary formats: one for the registry manifest cache and one for the lockfile.
The binary lockfile format has served us well, but it isn't worth the cost in developer experience, particularly for larger teams working together. We suggest workarounds today for various things, but none of them are great.
bun.lockb.1
orbun.lockb.2
? What about both?bun install
and the lockfile has changes due to hashes changing, package.jsonscripts
changing, or other reasons and this is hard to understand right now because it's hard to read in a text editor.bun.lockb
to the.gitignore
fileWill bun install still be fast?
Yes.
Will it make bun install slower?
Based on what we've seen, about 1-20 milliseconds.
What will the new format be?
Probably JSON with Trailing Commas, like
tsconfig.json
.Bun already supports this schema format for the runtime (and package.json). TOML is another option and it's what we use for
bunfig.toml
, though I kind of think that was a mistake and it should've been JSON with Trailing Commas. TOML's editor tooling support is not as mature as JSON with Trailing Commas.Why JSON with Trailing Commas instead of JSON?
Too many collective human lifetimes have been spent fixing merge conflicts from diffs caused by adding or removing trailing commas at the end of lists in JSON
Why JSON with Trailing Commas instead of YAML?
YAML is fine. We don't have a YAML parser in Bun yet, and the indentation gets really confusing sometimes. Also, YAML parsers tend to be slower than JSON parsers (and YAML parsers are also JSON parsers). My favorite YAML fact is that the two-digit country code for Norway in YAML is parsed as
false
, though this isn't relevant to a lockfileWhy JSON with Trailing Commas instead of JSON5?
We don't have a JSON5 parser in Bun, and would like to avoid formats that're slower to parse than JSON
When will
bun.lock
be released?Q3.
What will the migration plan be?
bun install
will support bothbun.lockb
andbun.lock
for awhile, but once released, new features will only be supported viabun.lock
.Do people really edit lockfiles manually?
Yes, for small tweaks it can be important
Why not fix merge conflicts via
bun install
instead?We will support that as well. But, it shouldn't be impossible to do manually.
The text was updated successfully, but these errors were encountered: