-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
feat(bun): support bun.lock
#9783
base: main
Are you sure you want to change the base?
feat(bun): support bun.lock
#9783
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
7400701
to
f50149a
Compare
This is a great step toward support |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple notes. The biome -> serde setup could potentially be cleaner, but otherwise looks good!
// npm -> [ | ||
// "name@version", | ||
// registry (TODO: remove if default), | ||
// INFO, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify, this is the structure of a package entry? Bun stores it in an array? And what is the .bun-tag
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify, this is the structure of a package entry? Bun stores it in an array?
Yes these are the various variants of a package entry according to this comment
And what is the .bun-tag?
It seems to be a special string, I haven't found where it is generated.
} | ||
|
||
fn less_specific_key(key: &str) -> Option<&str> { | ||
let slash_idx = key.find('/')?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tiny nit: split_once
might work better here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one of those cases where might need a str
that includes the /
I split on so I feel like find
is a little easier to work with here.
// TODO | ||
} | ||
let syntax_tree = parsed_json.syntax(); | ||
let format = biome_json_formatter::format_node( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you want a slightly shorter trip, I think you can use biome_deserialize
to get a serde_json::Value
, then use serde to deserialize that into BunLockfile
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not seeing serde_json::Value
as being supported by biome_deserialize
.
Big thanks to @chris-olszewski for working on this!!! Can't wait to have this in a release |
Hey, is there anything that could be done to help move this along? We use Bun with Turbo and the conversion to a Yarn lockfile has some issues (whether it's on Bun's side or Turbo's, I'm not sure - #9628), which means we can't use Turbo reliably in our Dockerfiles. |
d3a0b51
to
aa4deff
Compare
Description
Closes #9628
Switch over from our usage of
yarn.lock
and directly supportbun.lock
parsing.We use
biome
to strip out the trailing commas that appear in theworkspaces
andpackages
objects to leverageserde
which I am more competent in. We can switch tobiome
in the future and avoid a second pass, but I do not know how to do correct deserialization logic forPackageEntry
(seede.rs
for examples of what this looks like) inbiome
.I will call out is the fact that the lockfile keys in
bun.lock
aren't used directly unlike other lockfile implementation. Instead we use resolved package identifiers e.g.package@(protocol:)?version
. The keys themselves can shift when the underlying package does not change resulting in incorrect behavior.A quick example to illustrate:
a
depends on[email protected]
b
depends on[email protected]
[email protected]
will get they key ofshared
sincea
is beforeb
[email protected]
will get a key ofb/shared
a
updates to[email protected]
, then theshared
key will now point to[email protected]
b
since it's key changed fromb/shared
toshared
and not rebuilda
since it's key remainedshared
This PR does not add support for
turbo prune
.Reviewing each commit on it's own would probably be helpful.
Testing Instructions
Unit tests. Manual testing on a
create-turbo
repository.