NewsCrawler.org

Bun v1.4.4 tested: bun fmt formats 2,025 files in 2.6 seconds

Bun v1.4.4 packs the bun fmt formatter, bun check, bun install changes and Bun.SQL improvements into a single patch release, and the author tested the first three on their own machine. On Bun's official benchmark run on Prettier's own repository (2,616 files), bun fmt is 234 to 425 times faster than Prettier 3.9.9 on vitest, date-fns, monkeytype and h3; against oxfmt 0.74.0 it is 31 times faster on fumadocs (2,452 files), 6.2 times on vite and 3.0 times on RSSHub. The author's own run on Windows, on the date-fns main branch (2,025 TS/JS files, 20 threads), took 2,643 ms on the first pass and 916 ms on the second.

Compatibility: 9,648 of 9,731 Prettier test cases pass (99.1%), and the output matches oxfmt on 94.6% of 330 open-source repositories, with four intentional differences — for example, in the CSS value Font\ Awesome, Prettier 3.9.9 treats \A as a hex escape, while bun fmt keeps the text unchanged. Migration starts with bun fmt --doctor, which reports the config it read (.prettierrc) and the packages that can be removed, then bun fmt --check with exit code 1 goes into CI and bun fmt --staged replaces pre-commit hooks. bun check -b takes a monorepo[1] with 4,000 independent projects from 13.65 s to 0.87 s (15.7x) and cuts peak memory from 1,987 MB to 872 MB; on the author's two-file project it caught a TS2345 error in 31.41 ms. bun install gains exponential backoff[2] retries (up to 5, at 50/100/200/400/800 ms with ±20% jitter) that survive even a second of registry 503 errors, direct Yarn Berry lockfile[3] migration in 59.59 ms, peer dependency[4] resolution similar to pnpm and a minimumReleaseAge option against freshly published poisoned versions, among 133 install fixes.

Bun.SQL reduces CPU per query by 48% on point SELECT, 30% on a 100-row SELECT, 21% on INSERT and 38% on a batch insert of 1,000 rows × 10 columns, and adds query.cancel() to stop runaway queries. The author notes that all the official benchmarks ran on Linux/macOS, and that bun fmt is a port of oxc_formatter, itself a port of the Biome formatter, so the remaining 0.9% becomes the user's own problem. The author's advice: switch to bun fmt right away, try bun check after comparing its output with tsc (the TypeScript compiler), and hold off on the new Bun.SQL features until a real slow-query scenario appears.

Read the original juejin.cn

Sources

  • CNJuejin ZH

    Bun v1.4.4 实测:2,025 个文件,bun fmt 2.6 秒跑完

    2 likes287 views0 comments2 saves

Published: First seen: Читать по-русски

Open as a page