New Fast JavaScript Runtime Bun 0.7 Released

guide 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 is mainly focused on improving compatibility with Node.js and supporting new features.

New Fast JavaScript Runtime Bun 0.7 Released New Fast JavaScript Runtime Bun 0.7 Released

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 between 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 modularity 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 to meet 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 clone 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 connections also have enhanced ping/pong listening support.

Memory leaks and performance issues caused by some nasty bugs 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.

Original text from: https://www.oschina.net/news/250429

 

Guess you like

Origin blog.csdn.net/weixin_56035688/article/details/132185288
Bun