Hvad er LOCKB-filformatet?
En .lockb-fil er den binære lockfile oprettet af Bun, JavaScript- og TypeScript-pakkehåndteringen og runtime fra Oven. Den hedder næsten altid bun.lockb og ligger i roden af et projekt. Bun skriver den, når du kører bun install, og registrerer den komplette løste afhængighedsgraf: hver pakke, dens præcise version, dens metadata, dens underafhængigheder og integritetshashes. Fastlåsning af alt dette lader alle teammedlemmer og CI-jobs installere det samme træ.
Oven byggede formatet som binært for hastighedens skyld. Det gemmer data i lineære arrays, refererer til pakker via indeks eller via et hash af pakkenavnet og fjerner dubletter af lange strenge. Filen åbner med ASCII-headeren bun-lockfile-format-v0. Ulempen er, at en binær lockfile er svær at gennemse og ikke vises i Git-diffs, hvilket er grunden til, at Bun v1.1.39 tilføjede en tekst-lockfile, og Bun v1.2 gjorde bun.lock til standard for nye projekter. Eksisterende bun.lockb-filer fungerer stadig.
Sikkerhed og tryghed
RISIKO: LOWA bun.lockb file is generated data, not an executable, so opening or committing it is safe. Bun can 'run' the file only in the sense that bun ./bun.lockb prints its contents; it does not execute arbitrary code from the file. The only real caution is supply-chain trust: the lockfile pins specific package versions and their sources, so review dependency changes as you would any lockfile update. Never edit it by hand, since a corrupted binary lockfile will fail to parse.
Formatdetaljer
kort fortaltProgrammer der åbner LOCKB-filer
bun bun.lockb in the project directory to print the lockfile as readable yarn.lock-style text, or bun install to use it. bun.lockb. bun.lockb and print its contents without installing Bun. bun bun.lockb to print the lockfile as readable text, or bun install to reinstall from it. bun.lockb as text inside the editor. bun.lockb contents in Node or the browser without Bun installed. bun bun.lockb for a readable text dump, or bun install to install dependencies from it. bun.lockb as readable text. git config diff.lockb.textconv bun so git diff shows bun.lockb changes as readable text. Tekniske detaljer
dyb specifikation| Encoding | Binary (serialized struct-of-arrays memory dump) |
| Byte order | Little-endian (native to the machine that wrote it) |
| Container | Flat custom binary format, not a standard container |
| Compression | None; long strings over 88 characters are deduplicated to save space |
| Typical size | A few KB to a few hundred KB depending on dependency count |
| Structure | A header/magic string followed by linear arrays: package list, string buffer, dependency slices, resolutions, and hoisting trees. Packages are referenced by an auto-incrementing index or a hash of the package name rather than by repeated name strings. |
| Integrity | Stores npm-style integrity hashes for each resolved package; the format itself is version-tagged via the header string |
| Platforms | Windows, macOS, Linux |
| Notes | Designed for fast reads and memory mapping. It is not human-readable and does not render in Git or GitHub diffs without a textconv helper. Superseded as the default by the text-based bun.lock (JSONC) in Bun v1.2, but still supported. |
| Human Readable | No |
| Udgivet | 2022 |
| Seneste version | bun-lockfile-format-v0 |
| Specifikation | github.com |
LOCKB-konverteringer
Fællesskabets Q&A
spurgt af brugereIngen spørgsmål endnu - vær den første til at spørge om LOCKB-filer.
Ofte stillede spørgsmål
Hvordan åbner jeg en bun.lockb-fil?
bun bun.lockb. Bun udskriver lockfilen som læsbar tekst i yarn.lock-stil. Du skal have Bun installeret for at gøre dette.Hvorfor er bun.lockb binær i stedet for tekst?
Bør jeg committe bun.lockb til Git?
Hvordan konverterer jeg bun.lockb til den nye bun.lock?
bun install --save-text-lockfile --frozen-lockfile --lockfile-only, og slet derefter den gamle bun.lockb. Bun v1.2 bruger den tekstbaserede bun.lock som standard for nye projekter.Kan jeg redigere en bun.lockb-fil manuelt?
package.json og kør bun install for at regenerere lockfilen. Redigering af den binære fil direkte vil ødelægge den.