Bun v0.6.0 Released, JavaScript Runtime Written by Zig

Officially, Bun 0.6.0 is the biggest update to Bun so far.

The latest version of Bun now has a built-in JavaScript and TypeScript bundler and reducer that can be used to bundle front-end applications or to bundle your code into a single executable.

Bun 0.6.0 has also been busy with performance improvements and bug fixes: writeFile()20% faster on Linux, numerous bug fixes for Node.js compatibility and Web API compatibility, support for TypeScript 5.0 syntax, and support for bun installMade various fixes.

New JavaScript bundler & minifier

The focus of this release is Bun's new JavaScript Bundler (bundler), but the bundler is just the start of a much larger project. Over the next few months, Bun will release Bun.App- a "Super API" that stitches Bun's native-speed bundler, HTTP server, and filesystem router into a single package.

It can be used using bun buildCLI commands or the new JavaScript API.Bun.build()

JavaScript

Bun.build({
  entrypoints: ["./src/index.tsx"],
  outdir: "./build",
  minify: true,
  // ...
});

CLI

bun build ./src/index.tsx --outdir ./build --minify

standalone executable

Now you can bun builduse it to create standalone executables.

bun build --compile ./foo.ts

This lets you distribute your application as an executable without requiring users to install Bun.

You can also scale it down to improve startup performance for large applications:

bun build --minify --compile ./three.ts
  [32ms]  minify  -123 KB (estimate)
  [50ms]  bundle  456 modules
 [107ms] compile  three

This is provided by Bun's new JavaScript bundler and simplifier.

import.meta.main

Now you can import.meta.maincheck if the current file is the entry point for starting the bun with . This is useful for the CLI to determine if the current file is the one that started the application.

For example, if you have a index.tsfile called:

index.ts

console.log(import.meta.main);

Then you run it:

$ bun ./index.ts
true

But if you import it:

import "./index.ts";

and run it:

$ bun ./other.ts
false

right bun testimprovement

  • bun testNow reports time to run tests
  • describe.skiphas been achieved
  • achieved expect().toBeEven()andexpect().toBeOdd()

Faster on Linuxfs.writeFile

fs.writeFile is 20% faster for large files on Linux

Translator improvements

This release also introduces a number of improvements to the transpiler. Here are some of the highlights:

  • The parser supports TypeScript 5.0.
  • The parser supports importing attributes.
  • Some npm packages ReferenceError: Cannot access uninitialized variablehave errors due to a circular import bug in Bun's transpiler. This has been fixed.
  • support // @jsx, // @jsxImportSourceand // @jsxFragmentnotes
  • ……

More details can be viewed: https://bun.sh/blog/bun-v0.6.0

Guess you like

Origin www.oschina.net/news/241496/bun-0-6-0-released
Bun
Recommended