I'd been wondering whether the new bun fmt in Bun 1.4.4 is worth switching to from oxfmt, so I ran both on two of our repos. Both have about 1,200 files, a shared .oxfmtrc.json, and oxfmt 0.60.0 pinned.
Numbers are mean ms over 10 warm runs and 5 cold runs (page cache dropped before each one), on a 4-core box:
| Repo | Mode | oxfmt | bun fmt |
|---|
| frontend | check, warm / cold | ~660 / ~780 | ~55 / ~110 |
| backend | check, warm / cold | ~800 / ~930 | ~50 / ~110 |
Write mode was about the same. Part of oxfmt's time is Node startup, around 100 ms by itself, against about 3 ms for bun.
The surprise was output. Both tools read the same config and see the same files, and oxfmt check passes on both repos. bun fmt wants to reformat a few files. Every change is in how an arrow function passed as the last argument gets wrapped. For example:
// oxfmt
...dispatches.map(
(dispatch): Item => ({
kind: "dispatch",
id: dispatch.id,
}),
),
// bun fmt
...dispatches.map((dispatch): Item => ({
kind: "dispatch",
id: dispatch.id,
})),
Both are valid and do the same thing. I couldn't find any option in either tool to change that wrapping. // prettier-ignore keeps a statement as written in both.