A new stable version was quietly and unobtrusively released. Bun – 1.1.30.
Bun is an ECMAScript / JavaScript runtime environment, similar in many aspects to nodejs. At its core, Bun uses JavaScriptCore from Apple, but Bun itself, like many of its modules, is written in zig. Bun aims to be highly compatible with nodejs in terms of command-line options, supports ECMAScript (ESM) and CommonJS modules. npm package management and support for typescript are built directly into the application as native code, allowing TypeScript programs to be executed directly by the interpreter without prior configuration.
However, Bun is not just a 'copy' of nodejs in terms of its capabilities. In addition to being faster in various scenarios (starting right from application launch) and almost fully supporting the available nodejs API, Bun provides extensive features for server-side applications – from file handling to HTML tree transformation (HTMLRewriter), a TypeScript transpilation module (Bun.Transpiler), built-in database work sqlite, modules for interacting with native platform libraries through C APIs – ffi, integrated testing tools , and many other features.
Additionally, in experimental mode, Bun supports integration with C code through transparent calls to tcc:
hello.c: int hello() { return 42; } hello.js: import { cc } from "bun:ffi"; import source from ".\/hello.c" with { type: "file" }; const { symbols: { hello }, } = cc({ source, symbols: { hello: { args: [], returns: "int", }, }, }); console.log("What is the answer to the universe?", hello()); $ bun hello.js What is the answer to the universe? 42
In this release, among other things, a CSS parser based on LightningCSS was specially rewritten from legacy technologies such as rust to zig, which allowed seamless integration of CSS and TypeScript, now making it possible to directly import a CSS file into a TypeScript module:
index.ts: import ".\/style.css"; import Component from ".\/MyComponent.tsx"; // … rest of your app style.css: /* build output: */ /* style.css */ .hello { background: red; } /* MyComponent.css */ .MyComponent { color: green; }
Bun allows you collect to package the entire application with all resources into a single executable file.
Source: linux.org.ru
