aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-07-01 19:19:42 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-07-02 01:36:04 -0700
commit65672241254941d401054ac7424154d30494ee99 (patch)
tree87a556617fc3a4c6047e1a4f744f3b773d80bd2b
parent7907de58beac678cfdaa5aff89fb4f589697395a (diff)
downloadbun-65672241254941d401054ac7424154d30494ee99.tar.gz
bun-65672241254941d401054ac7424154d30494ee99.tar.zst
bun-65672241254941d401054ac7424154d30494ee99.zip
wip
-rw-r--r--README.md96
1 files changed, 61 insertions, 35 deletions
diff --git a/README.md b/README.md
index 4f7739df5..a25157eb4 100644
--- a/README.md
+++ b/README.md
@@ -2,10 +2,9 @@
bun is a new:
+- JavaScript runtime with [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/fetch), [`WebSocket`](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket), and several Web APIs builtin. bun embeds JavaScriptCore, which tends to be faster and more memory efficient than more popular engines like V8 (though harder to embed)
- JavaScript/TypeScript/JSX transpiler
- JavaScript & CSS bundler
-- Development server with 60fps Hot Module Reloading (& WIP support for React Fast Refresh)
-- JavaScript Runtime Environment (powered by JavaScriptCore, what WebKit/Safari uses)
- Task runner for package.json scripts
- npm-compatible package manager
@@ -13,6 +12,8 @@ All in one fast &amp; easy-to-use tool. Instead of 1,000 node_modules for develo
**bun is experimental software**. Join [bun’s Discord](https://bun.sh/discord) for help and have a look at [things that don’t work yet](#not-implemented-yet).
+Today, bun's primary focus is bun.js: bun's JavaScript runtime.
+
## Install
Native: (macOS x64 & Silicon, Linux x64, Windows Subsystem for Linux)
@@ -170,7 +171,7 @@ export default {
</details>
-bun.js prefers Web API compatibility or node API compatibility instead of designing new APIs when possible.
+bun.js prefers Web API compatibility instead of designing new APIs when possible. bun.js also implements some Node.js APIs.
- TypeScript & JSX support is builtin, powered by Bun's JavaScript transpiler
- ESM & CommonJS modules are supported (internally, bun.js uses ESM)
@@ -190,16 +191,49 @@ The runtime uses JavaScriptCore, the JavaScript engine powering WebKit and Safar
```js
// cat.js
import { resolve } from "path";
-const { write, stdout, file } = Bun;
-const { argv } = process;
+import { write, stdout, file, argv } from "bun";
const path = resolve(argv.at(-1));
-// file(path) returns a Blob - https://developer.mozilla.org/en-US/docs/Web/API/Blob
-await write(stdout, file(path));
+
+await write(
+ // stdout is a Blob
+ stdout,
+ // file(path) returns a Blob - https://developer.mozilla.org/en-US/docs/Web/API/Blob
+ file(path)
+);
// bun ./cat.js ./path-to-file
```
+Server-side render React:
+
+```js
+// requires Bun v0.1.0 or later
+// react-ssr.tsx
+import { renderToReadableStream } from "react-dom/server";
+
+export default {
+ port: 3000,
+ async fetch(request: Request) {
+ return new Response(
+ await renderToReadableStream(
+ <html>
+ <head>
+ <title>Hello World</title>
+ </head>
+ <body>
+ <h1>Hello from React!</h1>
+ <p>The date is {new Intl.DateTimeFormat().format(new Date())}</p>
+ </body>
+ </html>
+ )
+ );
+ },
+};
+
+// bun react-ssr.tsx
+```
+
There are some more examples in the [examples](./examples) folder.
PRs adding more examples are very welcome!
@@ -437,26 +471,26 @@ From there, make sure to import the `dist/tailwind.css` file (or what you chose
bun is a project with incredibly large scope, and it’s early days.
-| Feature | In |
-| ------------------------------------------------------------------------------------- | --------------- |
-| [Hash components for Fast Refresh](https://github.com/Jarred-Sumner/bun/issues/18) | JSX Transpiler |
-| Source Maps | JavaScript |
-| Source Maps | CSS |
-| JavaScript Minifier | JS Transpiler |
-| CSS Minifier | CSS |
-| CSS Parser (it only bundles) | CSS |
-| Tree-shaking | JavaScript |
-| Tree-shaking | CSS |
-| [`extends`](https://www.typescriptlang.org/tsconfig#extends) in tsconfig.json | TS Transpiler |
-| [TypeScript Decorators](https://www.typescriptlang.org/docs/handbook/decorators.html) | TS Transpiler |
-| `@jsxPragma` comments | JS Transpiler |
-| JSX source file name | JS Transpiler |
-| Sharing `.bun` files | bun |
-| [workspace: dependencies](https://github.com/Jarred-Sumner/bun/issues/83) | Package manager |
-| [git: dependencies](https://github.com/Jarred-Sumner/bun/issues/82) | Package manager |
-| [github: dependencies](https://github.com/Jarred-Sumner/bun/issues/81) | Package manager |
-| [link: dependencies](https://github.com/Jarred-Sumner/bun/issues/81) | Package manager |
-| Dates & timestamps | TOML parser |
+You can see [Bun's Roadmap](https://github.com/Jarred-Sumner/bun/issues/159), but here are some additional things that are planned:
+
+| Feature | In |
+| ------------------------------------------------------------------------------------- | -------------- |
+| Web Streams with Fetch API | Bun.js |
+| Web Streams with HTMLRewriter | Bun.js |
+| WebSocket Server | Bun.js |
+| [Hash components for Fast Refresh](https://github.com/Jarred-Sumner/bun/issues/18) | JSX Transpiler |
+| Source Maps | JS Bundler |
+| Source Maps | CSS |
+| JavaScript Minifier | JS Transpiler |
+| CSS Minifier | CSS |
+| CSS Parser (it only bundles) | CSS |
+| Tree-shaking | JavaScript |
+| Tree-shaking | CSS |
+| [`extends`](https://www.typescriptlang.org/tsconfig#extends) in tsconfig.json | TS Transpiler |
+| [TypeScript Decorators](https://www.typescriptlang.org/docs/handbook/decorators.html) | TS Transpiler |
+| `@jsxPragma` comments | JS Transpiler |
+| Sharing `.bun` files | bun |
+| Dates & timestamps | TOML parser |
<small>
JS Transpiler == JavaScript Transpiler
@@ -478,14 +512,6 @@ Ideally, most projects can use bun with their existing tooling while making few
Longer-term, bun intends to replace Node.js, Webpack, Babel, and PostCSS (in production).
-## Benchmarks
-
-TODO: update this section with runtime benchmarks
-
-**CSS**: [bun is 14x faster](./bench/hot-module-reloading/css-stress-test) than Next.js at hot reloading CSS. TODO: compare Vite
-
-**JavaScript**: TODO
-
## Configuration
### bunfig.toml