DEV Community

Ushieru Kokoran
Ushieru Kokoran

Posted on

3 3

Bun - Ya esta aqui.

Bun es el nuevo runtime de JavaScript, escrito en Zig. Bundler nativo, transpilador, task runner y cliente npm. Todo en uno.

Benchmark

Baterías incluidas

  • APIs Web como fetch, WebSocket y ReadableStream.
  • node_modules bun implementa un algoritmo de resolución de módulos de Node.js, por lo que puedes usar paquetes npm en bun.js. ESM y CommonJS son compatibles, pero Bun utiliza internamente ESM.
  • Transpilador de Typescript y JSX.
  • Soporta paths, jsxImportSource y más desde los archivos tsconfig.json.
  • Utiliza las llamadas al sistema más rápidas disponibles con Bun.write para write, copy, pipe, send y clone files.
  • Cargado automatico de .env sin require("dotenv").load()
  • Cliente SQLite3 integrado con bun:sqlite
  • bun:ffi Para codigo iteroperable con JavaScript
  • node:fs node:path Bun soporta de manera nativa la mayoria de modulos del core de Node.js
  • wiptest para test de JavaScript y TypeScript

Que tal si vemos un poco de codigo? 👨‍💻

Levantemos un servidor HTTP sencillito.

// http.js
export default {
  port: 3000,
  fetch(request) {
    return new Response("Welcome to Bun!");
  },
};

Enter fullscreen mode Exit fullscreen mode

Echémoslo a volar con:

bun run http.js
Enter fullscreen mode Exit fullscreen mode

Y ya lo tenemos.

server

Pero que tal si hacemos un app de Next.js?
bun create next ./app

Que tal algo con React?
bun create react ./app

Bun CLI

  • Bun ejecuta package.json scripts hasta x30 más rápido que NPM.
  • Bun instala paquetes NPM hasta x20 más rápido que yarn.

Ve, echale un ojo a su repositorio. Si puedes pruébalo y cuéntame en los comentarios como te fue.

Y Happy Hacking 🎉👨‍💻.

Top comments (0)

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay