Table of contents
Open Table of contents
π Whatβs New in Bun v1.2
Bun continues to innovate with v1.2, bringing enhancements that focus on performance, reliability, and usability for developers. Whether youβre building modern web apps or optimizing workflows, Bun v1.2 is designed to make your development process faster and easier.
Key Features and Updates
π Performance Boosts
-
5x Faster Object Spread (
{ ...obj }
) The spread operator performance has been significantly improved, offering lightning-fast execution.const obj = { a: 1, b: 2, c: 3 }; const clone = { ...obj }; console.log(clone); // Output: { a: 1, b: 2, c: 3 }
Microbenchmarks show this runs 5x faster, particularly in scenarios involving empty object literals and single spreads.
π Improved Windows Support
-
Rewritten
fs.watch
:- Enhances speed and reliability.
- Deduplicates watched paths to reduce memory usage.
import { watch } from "bun"; watch("src", (event, filePath) => { console.log(`${event}: ${filePath}`); });
-
Error Fixes:
- EBUSY: Resolved for
vite dev
andnext dev
. - ENOENT/EEXIST: Improved handling of tarball extraction for npm packages.
- EBUSY: Resolved for
π Bun Shell Enhancements
Bun Shell now supports popular GNU Coreutils commands:
seq
: Generates a sequence of numbers.yes
: Repeats input until interrupted.basename
&dirname
: Extracts file and directory names.
Example:
import { $ } from "bun";
await $`seq 1 5`;
// Output:
// 1
// 2
// 3
// 4
// 5
await $`basename /path/to/file.js`;
// Output: file.js
await $`dirname /path/to/file.js`;
// Output: /path/to
π¦ Enhanced Package Management
-
bun install --production
Without Lockfile: Perfect for CI environments.bun install --production
-
Fixed Crashes in Tarball Downloads: Improved error handling ensures smoother installs for edge cases.
π TypeScript Parsing Fixes
Complex TypeScript edge cases are now parsed correctly:
type Example = Bar extends string | (infer Baz extends string) ? Baz : never;
These fixes provide seamless compatibility for advanced TypeScript patterns.
Upgrade to Bun v1.2
To get started or upgrade to the latest version:
bun upgrade
For fresh installs:
curl -fsSL https://bun.sh/install | bash
Conclusion
Bun v1.2 is a game-changer for developers seeking speed, reliability, and simplicity. With improved performance, enhanced Windows support, and new features, itβs the ultimate toolkit for JavaScript development.