Bun is a fast all-in-one JavaScript runtime
Bundle, transpile, install and run JavaScript & TypeScript projects — all in Bun. Bun is a new JavaScript runtime with a native bundler, transpiler, task runner and npm client built-in.
diff --git a/packages/bun-landing/index.css b/packages/bun-landing/index.css index bd1b41e961df2c..9bc802de0d9bdf 100644 --- a/packages/bun-landing/index.css +++ b/packages/bun-landing/index.css @@ -302,7 +302,6 @@ header { align-items: center; width: min-content; white-space: nowrap; - gap: 2rem; } .Tab { @@ -312,6 +311,7 @@ header { padding-bottom: 8px; border-bottom: 1px solid #ccc; cursor: pointer; + padding: 16px 16px; } .Tab[data-tab="react"]:hover, @@ -321,6 +321,7 @@ header { .Tab[data-tab="ffi"]:hover, .Graphs--active-ffi .Tab[data-tab="ffi"] { border-bottom-color: aquamarine; + background-color: rgba(130, 216, 247, 0.1); border-right-color: aquamarine; border-left-color: aquamarine; } @@ -630,6 +631,11 @@ li { } } +#explain { + max-width: 650px; + margin: 0 auto; +} + @media (max-width: 930px) { header { padding: 24px 16px; @@ -872,3 +878,47 @@ li { border-top: 1px solid rgba(200, 200, 200, 0.1); } } + +#explain p > code { + white-space: pre; + padding: 1px 2px; +} + +.Group { + display: block; +} + +.Tag--Command { + display: block; + width: fit-content; + margin-bottom: 0.5rem; + padding: 8px 12px; +} + +.Label-replace { + font-weight: 500; +} + +.Label-text { + margin-top: 0.5rem; + margin-bottom: 1rem; +} + +#batteries { + padding-left: 0; +} + +.Group { + margin-bottom: 2rem; +} + +.Group strong { + display: block; +} + +.Built { + text-align: center; + margin-top: 4rem; + margin-bottom: 2rem; + color: #333; +} diff --git a/packages/bun-landing/page.tsx b/packages/bun-landing/page.tsx index dba64517e0961a..66590de7974cf6 100644 --- a/packages/bun-landing/page.tsx +++ b/packages/bun-landing/page.tsx @@ -48,6 +48,18 @@ const Bun = ({ children, href, Tag = href ? "a" : "span" }) => ( const fmt = new Intl.NumberFormat(); +const Label = ({ children, replace }) => { + if (replace) { + return ( +
+ Bun is a modern JavaScript runtime like Node or Deno. It was built + from scratch to focus on three main things: +
package.json "scripts"
{" "}
- npm run
- + Bun is designed as a drop-in replacement for your current JavaScript + & TypeScript apps or scripts — on your local computer, server or + on the edge. Bun natively implements hundreds of Node.js and Web + APIs, including 90% of Node-API functions (native modules), fs, + path, Buffer and more. The goal of Bun is to run most of the worlds + JavaScript outside of browsers, bringing performance and complexity + enhancements to your future infrastructure, as well as developer + productivity through better, simpler tooling. +
++ The goal of Bun is to run most of the worlds JavaScript outside of + browsers, bringing performance and complexity enhancements to your + future infrastructure, as well as developer productivity through + better, simpler tooling. +
+"paths"
, "jsxImportSource"
- and more from tsconfig.json
+ bun supports "paths"
,{" "}
+ "jsxImportSource"
+ and more from require("dotenv").load()
+ Bun.js uses the{" "}
+
+ JavaScriptCore
+ {" "}
+ engine, which tends{" "}
+
+ to start
+ {" "}
+ and perform a little faster than more traditional choices like V8.
+ Bun is written in{" "}
+
+
+
+ Most of Bun is written from scratch including the JSX/TypeScript
+ transpiler, npm client, bundler, SQLite client, HTTP client,
+ WebSocket client and more.
+
+ An enourmous amount of time spent profiling, benchmarking and
+ optimizing things. The answer is different for every part of Bun,
+ but one general theme:{" "}
+
+
To install bun, run this{" "} @@ -520,11 +583,9 @@ export default () => ( {" "} in your terminal. It downloads Bun from GitHub.
-{" "} Bun's HTTP server is built on web standards like{" "} @@ -542,7 +603,6 @@ curl https://bun.sh/install | bash Response
-Run it with bun:
-Then open{" "} @@ -574,53 +631,61 @@ export default { Bun's Discord
-
- Bun.js uses the{" "}
-
- JavaScriptCore
- {" "}
- engine, which tends{" "}
-
- to start
- {" "}
- and perform a little faster than more traditional choices like V8.
- Bun is written in{" "}
-
-
+ The same command for running JavaScript & TypeScript files
+ with bun's JavaScript runtime also runs package.json{" "}
+ "scripts"
.
+
npm run
with{" "}
+ bun run
and save 160ms on every run.
+
npm run
+ + bun install is an npm-compatible package manager. You probably + will be surprised by how much faster copying files can get. +
+ + Replaceyarn
with{" "}
+ bun install
and get 20x faster
+ package installs.
+
- An enourmous amount of time spent profiling, benchmarking and
- optimizing things. The answer is different for every part of Bun,
- but one general theme:{" "}
-
-
+ A Jest-like test runner for JavaScript & TypeScript projects + builtin to bun +
+ +MIT License, excluding dependencies which have various licenses.
-Bun is on GitHub @@ -646,6 +711,7 @@ document.querySelector("#code-box-copy").addEventListener("click", async e => { `, }} /> +
Bundle, transpile, install and run JavaScript & TypeScript projects — all in Bun. Bun is a new JavaScript runtime with a native bundler, transpiler, task runner and npm client built-in.
package.json "scripts"
30x faster than npm run
"paths"
, "jsxImportSource"
and more from tsconfig.jsonrequire("dotenv").load()
To install bun, run this install script in your terminal. It downloads Bun from GitHub.
curl https://bun.sh/install | bash
Bun's HTTP server is built on web standards like Request and Response
// http.js
+Bun is a fast all-in-one JavaScript runtime
Bundle, transpile, install and run JavaScript & TypeScript projects — all in Bun. Bun is a new JavaScript runtime with a native bundler, transpiler, task runner and npm client built-in.
Install Bun CLI v0.1.0 (beta)macOS x64 & Silicon, Linux x64, Windows Subsystem for Linuxcurl https://bun.sh/install | bashcopyShow script sourceBun.servebun:sqlitebun:ffiServer-side rendering ReactHTTP requests per second (Linux AMD64)48,93616,28812,289Average queries per second SELECT * from "Orders" (Northwind Traders)60.2423.289.55Operations per secondCall add(1,2,3) from JavaScript115,473,44143,478,2612,891,761Install Bun CLI v0.1.0 (beta)macOS x64 & Silicon, Linux x64, Windows Subsystem for Linuxcurl https://bun.sh/install | bashcopyShow script sourceTell me more about Bun
Bun is a modern JavaScript runtime like Node or Deno. It was built from scratch to focus on three main things:
- Extremely lightweight (it has the edge in mind).
- New levels of performance (extending JavaScriptCore, the engine).
- Being a great and complete tool (bundler, transpiler, package manager).
Bun is designed as a drop-in replacement for your current JavaScript & TypeScript apps or scripts — on your local computer, server or on the edge. Bun natively implements hundreds of Node.js and Web APIs, including 90% of Node-API functions (native modules), fs, path, Buffer and more. The goal of Bun is to run most of the worlds JavaScript outside of browsers, bringing performance and complexity enhancements to your future infrastructure, as well as developer productivity through better, simpler tooling.
The goal of Bun is to run most of the worlds JavaScript outside of browsers, bringing performance and complexity enhancements to your future infrastructure, as well as developer productivity through better, simpler tooling.
Batteries included
- Web APIs like fetch, WebSocket, and ReadableStream are builtin
- node_modules bun implements Node.js' module resolution algorithm, so you can use npm packages in bun.js. ESM and CommonJS are supported, but Bun internally uses ESM.
- In bun.js, every file is transpiled. TypeScript & JSX just work.
- bun supports
"paths"
, "jsxImportSource"
and more from tsconfig.json files - Bun.Transpiler bun's JSX & TypeScript transpiler is available as an API in Bun.js
- use the fastest system calls available with Bun.write to write, copy, pipe, send and clone files.
- bun.js automatically loads environment variables from .env files. No more
require("dotenv").load()
- bun ships with a fast SQLite3 client builtin bun:sqlite
- Node-API bun.js implements most of Node.jÀ' native addons API, Node-API (NAPI). Many Node.js native modules just work.
- bun:ffi call native code from JavaScript with bun's low-overhead foreign function interface
- node:fs node:path bun.js natively supports a growing list of Node.js core modules along with globals like Buffer and process.
How does Bun work?
Bun.js uses the JavaScriptCore engine, which tends to start and perform a little faster than more traditional choices like V8. Bun is written in , a low-level programming language with manual memory management.
Most of Bun is written from scratch including the JSX/TypeScript transpiler, npm client, bundler, SQLite client, HTTP client, WebSocket client and more.
Why is Bun fast?
An enourmous amount of time spent profiling, benchmarking and optimizing things. The answer is different for every part of Bun, but one general theme: 's low-level control over memory and lack of hidden control flow makes it much simpler to write fast software. Sponsor the Zig Software Foundation
Getting started
To install bun, run this install script in your terminal. It downloads Bun from GitHub.
curl https://bun.sh/install | bash
Bun's HTTP server is built on web standards like Request and Response
// http.js
export default {
port: 3000,
fetch(request) {
return new Response("Welcome to Bun!");
},
-};
Run it with bun:
bun run http.js
Then open http://localhost:3000 in your browser
See more examples and check out the docs. If you have any questions or want help, join Bun's Discord
How does Bun work?
Bun.js uses the JavaScriptCore engine, which tends to start and perform a little faster than more traditional choices like V8. Bun is written in , a low-level programming language with manual memory management.
Most of Bun is written from scratch including the JSX/TypeScript transpiler, npm client, bundler, SQLite client, HTTP client, WebSocket client and more.
Why is Bun fast?
An enourmous amount of time spent profiling, benchmarking and optimizing things. The answer is different for every part of Bun, but one general theme: 's low-level control over memory and lack of hidden control flow makes it much simpler to write fast software. Sponsor the Zig Software Foundation
What is the license?
MIT License, excluding dependencies which have various licenses.
How do I see the source code?
Bun is on GitHub
\ No newline at end of file
+
+document.querySelector("#code-box-copy").addEventListener("click", async e => {
+ var el = document.querySelector("#code-box");
+ await navigator.clipboard.writeText("curl https://bun.sh/install | bash");
+});
+ Built with Bun v0.1.0
\ No newline at end of file
diff --git a/packages/bun-landing/ssr.tsx b/packages/bun-landing/ssr.tsx
index a608f968e86609..3ff8adac981109 100644
--- a/packages/bun-landing/ssr.tsx
+++ b/packages/bun-landing/ssr.tsx
@@ -10,6 +10,10 @@ async function fetch(req: Request) {
return new Response("", { status: 404 });
}
+ if (req.url.endsWith(".css")) {
+ return new Response(file(join(import.meta.dir + "/", "index.css")));
+ }
+
if (!req.url.includes(".")) {
const { default: Page } = await import("./page.tsx");
return new Response(await renderToReadableStream( ), {