New high-speed JavaScript runtime Bun 0.7 released

Recently, the new JavaScript runtime Bun officially released version 0.7, bringing a major upgrade. It is reported that Bun is a complete JavaScript solution, which integrates runtime, packager, translator and package manager, and pursues the ultimate running speed. This update mainly focuses on compatibility improvements with Node.js and new feature support.

First, Bun announced preliminary compatibility with Vite, a popular front-end packaging tool. Developers can now use Bun to directly run Vite projects and enjoy convenient functions such as hot updates without additional configuration. However, due to the different internal mechanisms of Bun and Vite, Vite still does not use Bun's packaging and translation advantages. But it sets the stage for deep integration in the future.

Then, Bun implements the Worker thread support in the browser environment. Developers can now create sub-threads through the newly added Worker class, and use multi-core CPUs to improve the execution efficiency of computing-intensive tasks. Bun's Worker naturally supports features such as modularization and TypeScript, which is easier to use than the browser's native Worker. It is worth mentioning that the popular comlink library can also be seamlessly applied to Bun's Worker, making inter-thread communication more convenient.

In addition, Bun restores native support for asynchronous context storage AsyncLocalStorage, which is the key for many frameworks to implement asynchronous operation tracking. Next, Bun is expected to be compatible with popular frameworks such as Next.js.

In terms of Node.js compatibility, Bun implements the timer callback in the event loop to ensure asynchronous execution, and the standard output stream, which is important for command-line applications, also enhances the window size query support. Especially in terms of TLS networks, Bun has improved the implementation of interfaces such as key derivation and session reuse, meeting the needs of popular encryption libraries.

Of course, this update also adds useful new features. For example, developers can now more easily pass data between the main thread and Worker, and can also use the structured cloning algorithm ( structuredClone()) to perform efficient deep copies. An API to convert a Readable stream into a FormData object is also possible. In terms of testing framework, the "--bail" mode that ends immediately after the first test fails has been added, which improves the efficiency in the CI/CD environment. WebSocket connection has also enhanced ping/pong listening support.

Some tricky bugs causing memory leaks and performance issues have also been fixed. Overall, the upgrades brought by Bun 0.7 bring it one step closer to competing with Node.js. As compatibility improves further, developers may see more and more projects move to using Bun. We will wait and see how Bun will perform in the future. After all, it is conceivable that a fast, efficient, and easy-to-use JavaScript solution is attractive to developers.

Guess you like

Origin www.oschina.net/news/250429/bun-0-7-released
Bun