bun-types 1.1.44-canary.20250115T140647 → 1.1.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/api/fetch.md +1 -1
- package/docs/api/s3.md +8 -0
- package/docs/api/spawn.md +1 -1
- package/docs/bundler/fullstack.md +247 -0
- package/docs/bundler/plugins.md +1 -1
- package/docs/cli/install.md +1 -1
- package/docs/cli/publish.md +1 -1
- package/docs/index.md +1 -1
- package/docs/install/npmrc.md +1 -1
- package/docs/runtime/debugger.md +3 -3
- package/docs/runtime/nodejs-apis.md +89 -83
- package/docs/test/dom.md +1 -1
- package/package.json +1 -1
package/docs/api/fetch.md
CHANGED
|
@@ -195,7 +195,7 @@ This will print the request and response headers to your terminal:
|
|
|
195
195
|
```sh
|
|
196
196
|
[fetch] > HTTP/1.1 GET http://example.com/
|
|
197
197
|
[fetch] > Connection: keep-alive
|
|
198
|
-
[fetch] > User-Agent: Bun/
|
|
198
|
+
[fetch] > User-Agent: Bun/bun-v1.1.44
|
|
199
199
|
[fetch] > Accept: */*
|
|
200
200
|
[fetch] > Host: example.com
|
|
201
201
|
[fetch] > Accept-Encoding: gzip, deflate, br
|
package/docs/api/s3.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
Production servers often read, upload, and write files to S3-compatible object storage services instead of the local filesystem. Historically, that means local filesystem APIs you use in development can't be used in production. When you use Bun, things are different.
|
|
2
2
|
|
|
3
|
+
{% callout %}
|
|
4
|
+
|
|
5
|
+
### Bun's S3 API is fast
|
|
6
|
+
|
|
7
|
+
{% image src="https://bun.sh/bun-s3-node.gif" alt="Bun's S3 API is fast" caption="Left: Bun v1.1.44. Right: Node.js v23.6.0" /%}
|
|
8
|
+
|
|
9
|
+
{% /callout %}
|
|
10
|
+
|
|
3
11
|
Bun provides fast, native bindings for interacting with S3-compatible object storage services. Bun's S3 API is designed to be simple and feel similar to fetch's `Response` and `Blob` APIs (like Bun's local filesystem APIs).
|
|
4
12
|
|
|
5
13
|
```ts
|
package/docs/api/spawn.md
CHANGED
|
@@ -110,7 +110,7 @@ You can read results from the subprocess via the `stdout` and `stderr` propertie
|
|
|
110
110
|
```ts
|
|
111
111
|
const proc = Bun.spawn(["bun", "--version"]);
|
|
112
112
|
const text = await new Response(proc.stdout).text();
|
|
113
|
-
console.log(text); // => "
|
|
113
|
+
console.log(text); // => "bun-v1.1.44"
|
|
114
114
|
```
|
|
115
115
|
|
|
116
116
|
Configure the output stream by passing one of the following values to `stdout/stderr`:
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
As of Bun v1.1.44, we've added initial support for bundling frontend apps directly in Bun's HTTP server: `Bun.serve()`. Run your frontend and backend in the same app with no extra steps.
|
|
2
|
+
|
|
3
|
+
To get started, import your HTML files and pass them to the `static` option in `Bun.serve()`.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import dashboard from "./dashboard.html";
|
|
7
|
+
import homepage from "./index.html";
|
|
8
|
+
|
|
9
|
+
Bun.serve({
|
|
10
|
+
// Add HTML imports to `static`
|
|
11
|
+
static: {
|
|
12
|
+
// Bundle & route index.html to "/"
|
|
13
|
+
"/": homepage,
|
|
14
|
+
// Bundle & route dashboard.html to "/dashboard"
|
|
15
|
+
"/dashboard": dashboard,
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
// Enable development mode for:
|
|
19
|
+
// - Detailed error messages
|
|
20
|
+
// - Rebuild on request
|
|
21
|
+
development: true,
|
|
22
|
+
|
|
23
|
+
// Handle API requests
|
|
24
|
+
async fetch(req) {
|
|
25
|
+
// ...your API code
|
|
26
|
+
if (req.url.endsWith("/api/users")) {
|
|
27
|
+
const users = await Bun.sql`SELECT * FROM users`;
|
|
28
|
+
return Response.json(users);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Return 404 for unmatched routes
|
|
32
|
+
return new Response("Not Found", { status: 404 });
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
You'll need to run your app with `bun --experimental-html` to enable this feature:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
$ bun --experimental-html run app.ts
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## HTML imports are routes
|
|
44
|
+
|
|
45
|
+
The web starts with HTML, and so does Bun's fullstack dev server.
|
|
46
|
+
|
|
47
|
+
To specify entrypoints to your frontend, import HTML files into your JavaScript/TypeScript/TSX/JSX files.
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import dashboard from "./dashboard.html";
|
|
51
|
+
import homepage from "./index.html";
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
These HTML files are used as routes in Bun's dev server you can pass to `Bun.serve()`.
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
Bun.serve({
|
|
58
|
+
static: {
|
|
59
|
+
"/": homepage,
|
|
60
|
+
"/dashboard": dashboard,
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
fetch(req) {
|
|
64
|
+
// ... api requests
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
When you make a request to `/dashboard` or `/`, Bun automatically bundles the `<script>` and `<link>` tags in the HTML files, exposes them as static routes, and serves the result.
|
|
70
|
+
|
|
71
|
+
An index.html file like this:
|
|
72
|
+
|
|
73
|
+
```html#index.html
|
|
74
|
+
<!DOCTYPE html>
|
|
75
|
+
<html>
|
|
76
|
+
<head>
|
|
77
|
+
<title>Home</title>
|
|
78
|
+
<link rel="stylesheet" href="./reset.css" />
|
|
79
|
+
<link rel="stylesheet" href="./styles.css" />
|
|
80
|
+
</head>
|
|
81
|
+
<body>
|
|
82
|
+
<div id="root"></div>
|
|
83
|
+
<script type="module" src="./sentry-and-preloads.ts"></script>
|
|
84
|
+
<script type="module" src="./my-app.tsx"></script>
|
|
85
|
+
</body>
|
|
86
|
+
</html>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Becomes something like this:
|
|
90
|
+
|
|
91
|
+
```html#index.html
|
|
92
|
+
<!DOCTYPE html>
|
|
93
|
+
<html>
|
|
94
|
+
<head>
|
|
95
|
+
<title>Home</title>
|
|
96
|
+
<link rel="stylesheet" href="/index-[hash].css" />
|
|
97
|
+
</head>
|
|
98
|
+
<body>
|
|
99
|
+
<div id="root"></div>
|
|
100
|
+
<script type="module" src="/index-[hash].js"></script>
|
|
101
|
+
</body>
|
|
102
|
+
</html>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### How to use with React
|
|
106
|
+
|
|
107
|
+
To use React in your client-side code, import `react-dom/client` and render your app.
|
|
108
|
+
|
|
109
|
+
{% codetabs %}
|
|
110
|
+
|
|
111
|
+
```ts#src/backend.ts
|
|
112
|
+
import dashboard from "./public/dashboard.html";
|
|
113
|
+
import { serve } from "bun";
|
|
114
|
+
|
|
115
|
+
serve({
|
|
116
|
+
static: {
|
|
117
|
+
"/": dashboard,
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
async fetch(req) {
|
|
121
|
+
// ...api requests
|
|
122
|
+
return new Response("hello world");
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
```ts#src/frontend.tsx
|
|
128
|
+
import "./styles.css";
|
|
129
|
+
import { createRoot } from "react-dom/client";
|
|
130
|
+
import { App } from "./app.tsx";
|
|
131
|
+
|
|
132
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
133
|
+
const root = createRoot(document.getElementById("root"));
|
|
134
|
+
root.render(<App />);
|
|
135
|
+
});
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
```html#public/dashboard.html
|
|
139
|
+
<!DOCTYPE html>
|
|
140
|
+
<html>
|
|
141
|
+
<head>
|
|
142
|
+
<title>Dashboard</title>
|
|
143
|
+
</head>
|
|
144
|
+
<body>
|
|
145
|
+
<div id="root"></div>
|
|
146
|
+
<script type="module" src="../src/frontend.tsx"></script>
|
|
147
|
+
</body>
|
|
148
|
+
</html>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
```css#src/styles.css
|
|
152
|
+
body {
|
|
153
|
+
background-color: red;
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
```tsx#src/app.tsx
|
|
158
|
+
export function App() {
|
|
159
|
+
return <div>Hello World</div>;
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
{% /codetabs %}
|
|
164
|
+
|
|
165
|
+
### Development mode
|
|
166
|
+
|
|
167
|
+
When building locally, enable development mode by setting `development: true` in `Bun.serve()`.
|
|
168
|
+
|
|
169
|
+
```js-diff
|
|
170
|
+
import homepage from "./index.html";
|
|
171
|
+
import dashboard from "./dashboard.html";
|
|
172
|
+
|
|
173
|
+
Bun.serve({
|
|
174
|
+
static: {
|
|
175
|
+
"/": homepage,
|
|
176
|
+
"/dashboard": dashboard,
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
+ development: true,
|
|
180
|
+
|
|
181
|
+
fetch(req) {
|
|
182
|
+
// ... api requests
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
When `development` is `true`, Bun will:
|
|
188
|
+
|
|
189
|
+
- Include the `SourceMap` header in the response so that devtools can show the original source code
|
|
190
|
+
- Disable minification
|
|
191
|
+
- Re-bundle assets on each request to a .html file
|
|
192
|
+
|
|
193
|
+
#### Production mode
|
|
194
|
+
|
|
195
|
+
When serving your app in production, set `development: false` in `Bun.serve()`.
|
|
196
|
+
|
|
197
|
+
- Enable in-memory caching of bundled assets. Bun will bundle assets lazily on the first request to an `.html` file, and cache the result in memory until the server restarts.
|
|
198
|
+
- Enables `Cache-Control` headers and `ETag` headers
|
|
199
|
+
- Minifies JavaScript/TypeScript/TSX/JSX files
|
|
200
|
+
|
|
201
|
+
## How this works
|
|
202
|
+
|
|
203
|
+
Bun uses [`HTMLRewriter`](/docs/api/html-rewriter) to scan for `<script>` and `<link>` tags in HTML files, uses them as entrypoints for [Bun's bundler](/docs/bundler), generates an optimized bundle for the JavaScript/TypeScript/TSX/JSX and CSS files, and serves the result.
|
|
204
|
+
|
|
205
|
+
1. **`<script>` processing**
|
|
206
|
+
|
|
207
|
+
- Transpiles TypeScript, JSX, and TSX in `<script>` tags
|
|
208
|
+
- Bundles imported dependencies
|
|
209
|
+
- Generates sourcemaps for debugging
|
|
210
|
+
- Minifies when `development` is not `true` in `Bun.serve()`
|
|
211
|
+
|
|
212
|
+
```html
|
|
213
|
+
<script type="module" src="./counter.tsx"></script>
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
2. **`<link>` processing**
|
|
217
|
+
|
|
218
|
+
- Processes CSS imports and `<link>` tags
|
|
219
|
+
- Concatenates CSS files
|
|
220
|
+
- Rewrites `url` and asset paths to include content-addressable hashes in URLs
|
|
221
|
+
|
|
222
|
+
```html
|
|
223
|
+
<link rel="stylesheet" href="./styles.css" />
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
3. **`<img>` & asset processing**
|
|
227
|
+
|
|
228
|
+
- Links to assets are rewritten to include content-addressable hashes in URLs
|
|
229
|
+
- Small assets in CSS files are inlined into `data:` URLs, reducing the total number of HTTP requests sent over the wire
|
|
230
|
+
|
|
231
|
+
4. **Rewrite HTML**
|
|
232
|
+
|
|
233
|
+
- Combines all `<script>` tags into a single `<script>` tag with a content-addressable hash in the URL
|
|
234
|
+
- Combines all `<link>` tags into a single `<link>` tag with a content-addressable hash in the URL
|
|
235
|
+
- Outputs a new HTML file
|
|
236
|
+
|
|
237
|
+
5. **Serve**
|
|
238
|
+
|
|
239
|
+
- All the output files from the bundler are exposed as static routes, using the same mechanism internally as when you pass a `Response` object to [`static` in `Bun.serve()`](/docs/api/http#static-routes).
|
|
240
|
+
|
|
241
|
+
This works similarly to how [`Bun.build` processes HTML files](/docs/bundler/html).
|
|
242
|
+
|
|
243
|
+
## This is a work in progress
|
|
244
|
+
|
|
245
|
+
- Client-side hot reloading isn't wired up yet. It will be in the future.
|
|
246
|
+
- This doesn't support `bun build` yet. It also will in the future.
|
|
247
|
+
- We haven't figured out plugins yet. This probably will live in `bunfig.toml` with the same API as in `Bun.build` otherwise.
|
package/docs/bundler/plugins.md
CHANGED
|
@@ -291,7 +291,7 @@ One of the reasons why Bun's bundler is so fast is that it is written in native
|
|
|
291
291
|
|
|
292
292
|
However, one limitation of plugins written in JavaScript is that JavaScript itself is single-threaded.
|
|
293
293
|
|
|
294
|
-
Native plugins are written as [NAPI](/docs/node-api) modules and can be run on multiple threads. This allows native plugins to run much faster than JavaScript plugins.
|
|
294
|
+
Native plugins are written as [NAPI](https://bun.sh/docs/api/node-api) modules and can be run on multiple threads. This allows native plugins to run much faster than JavaScript plugins.
|
|
295
295
|
|
|
296
296
|
In addition, native plugins can skip unnecessary work such as the UTF-8 -> UTF-16 conversion needed to pass strings to JavaScript.
|
|
297
297
|
|
package/docs/cli/install.md
CHANGED
|
@@ -93,7 +93,7 @@ $ bun install --filter '!pkg-c'
|
|
|
93
93
|
$ bun install --filter './packages/pkg-a'
|
|
94
94
|
```
|
|
95
95
|
|
|
96
|
-
For more information on filtering with `bun install`, refer to [Package Manager > Filtering](https://bun.sh/docs/cli/
|
|
96
|
+
For more information on filtering with `bun install`, refer to [Package Manager > Filtering](https://bun.sh/docs/cli/filter#bun-install-and-bun-outdated)
|
|
97
97
|
|
|
98
98
|
## Overrides and resolutions
|
|
99
99
|
|
package/docs/cli/publish.md
CHANGED
package/docs/index.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Bun is an all-in-one toolkit for JavaScript and TypeScript apps. It ships as a single executable called `bun`.
|
|
2
2
|
|
|
3
|
-
At its core is the _Bun runtime_, a fast JavaScript runtime designed as a drop-in replacement for Node.js
|
|
3
|
+
At its core is the _Bun runtime_, a fast JavaScript runtime designed as **a drop-in replacement for Node.js**. It's written in Zig and powered by JavaScriptCore under the hood, dramatically reducing startup times and memory usage.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
6
|
$ bun run index.tsx # TS and JSX supported out of the box
|
package/docs/install/npmrc.md
CHANGED
|
@@ -10,7 +10,7 @@ Bun supports loading configuration options from [`.npmrc`](https://docs.npmjs.co
|
|
|
10
10
|
|
|
11
11
|
### `registry`: Set the default registry
|
|
12
12
|
|
|
13
|
-
The default registry is used to resolve packages,
|
|
13
|
+
The default registry is used to resolve packages, its default value is `npm`'s official registry (`https://registry.npmjs.org/`).
|
|
14
14
|
|
|
15
15
|
To change it, you can set the `registry` option in `.npmrc`:
|
|
16
16
|
|
package/docs/runtime/debugger.md
CHANGED
|
@@ -124,11 +124,11 @@ await fetch("https://example.com", {
|
|
|
124
124
|
This prints the `fetch` request as a single-line `curl` command to let you copy-paste into your terminal to replicate the request.
|
|
125
125
|
|
|
126
126
|
```sh
|
|
127
|
-
[fetch] $ curl --http1.1 "https://example.com/" -X POST -H "content-type: application/json" -H "Connection: keep-alive" -H "User-Agent: Bun/
|
|
127
|
+
[fetch] $ curl --http1.1 "https://example.com/" -X POST -H "content-type: application/json" -H "Connection: keep-alive" -H "User-Agent: Bun/bun-v1.1.44" -H "Accept: */*" -H "Host: example.com" -H "Accept-Encoding: gzip, deflate, br" --compressed -H "Content-Length: 13" --data-raw "{\"foo\":\"bar\"}"
|
|
128
128
|
[fetch] > HTTP/1.1 POST https://example.com/
|
|
129
129
|
[fetch] > content-type: application/json
|
|
130
130
|
[fetch] > Connection: keep-alive
|
|
131
|
-
[fetch] > User-Agent: Bun/
|
|
131
|
+
[fetch] > User-Agent: Bun/bun-v1.1.44
|
|
132
132
|
[fetch] > Accept: */*
|
|
133
133
|
[fetch] > Host: example.com
|
|
134
134
|
[fetch] > Accept-Encoding: gzip, deflate, br
|
|
@@ -170,7 +170,7 @@ This prints the following to the console:
|
|
|
170
170
|
[fetch] > HTTP/1.1 POST https://example.com/
|
|
171
171
|
[fetch] > content-type: application/json
|
|
172
172
|
[fetch] > Connection: keep-alive
|
|
173
|
-
[fetch] > User-Agent: Bun/
|
|
173
|
+
[fetch] > User-Agent: Bun/bun-v1.1.44
|
|
174
174
|
[fetch] > Accept: */*
|
|
175
175
|
[fetch] > Host: example.com
|
|
176
176
|
[fetch] > Accept-Encoding: gzip, deflate, br
|
|
@@ -1,155 +1,145 @@
|
|
|
1
|
-
Bun
|
|
1
|
+
Every day, Bun gets closer to 100% Node.js API compatibility. Today, popular frameworks like Next.js, Express, and millions of `npm` packages intended for Node just work with Bun. To ensure compatibility, we run thousands of tests from Node.js' test suite before every release of Bun.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**If a package works in Node.js but doesn't work in Bun, we consider it a bug in Bun.** Please [open an issue](https://bun.sh/issues) and we'll fix it.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This page is updated regularly to reflect compatibility status of the latest version of Bun. The information below reflects Bun's compatibility with _Node.js v23_.
|
|
6
|
+
|
|
7
|
+
## Built-in Node.js modules
|
|
6
8
|
|
|
7
9
|
### [`node:assert`](https://nodejs.org/api/assert.html)
|
|
8
10
|
|
|
9
11
|
🟢 Fully implemented.
|
|
10
12
|
|
|
11
|
-
### [`node:async_hooks`](https://nodejs.org/api/async_hooks.html)
|
|
12
|
-
|
|
13
|
-
🟡 Only `AsyncLocalStorage`, and `AsyncResource` are implemented. `AsyncResource` is missing `bind`.
|
|
14
|
-
|
|
15
13
|
### [`node:buffer`](https://nodejs.org/api/buffer.html)
|
|
16
14
|
|
|
17
15
|
🟢 Fully implemented.
|
|
18
16
|
|
|
19
|
-
### [`node:child_process`](https://nodejs.org/api/child_process.html)
|
|
20
|
-
|
|
21
|
-
🟡 Missing `proc.gid` `proc.uid`. `Stream` class not exported. IPC cannot send socket handles. Node.js <> Bun IPC can be used with JSON serialization.
|
|
22
|
-
|
|
23
|
-
### [`node:cluster`](https://nodejs.org/api/cluster.html)
|
|
24
|
-
|
|
25
|
-
🟡 Handles and file descriptors cannot be passed between workers, which means load-balancing HTTP requests across processes is only supported on Linux at this time (via `SO_REUSEPORT`). Otherwise, implemented but not battle-tested.
|
|
26
|
-
|
|
27
17
|
### [`node:console`](https://nodejs.org/api/console.html)
|
|
28
18
|
|
|
29
19
|
🟢 Fully implemented.
|
|
30
20
|
|
|
31
|
-
### [`node:crypto`](https://nodejs.org/api/crypto.html)
|
|
32
|
-
|
|
33
|
-
🟡 Missing `Certificate` `ECDH` `X509Certificate` `checkPrime` `checkPrimeSync` `diffieHellman` `generatePrime` `generatePrimeSync` `getCipherInfo` `getFips` `hkdf` `hkdfSync` `secureHeapUsed` `setEngine` `setFips`
|
|
34
|
-
|
|
35
|
-
Some methods are not optimized yet.
|
|
36
|
-
|
|
37
|
-
### [`node:dgram`](https://nodejs.org/api/dgram.html)
|
|
38
|
-
|
|
39
|
-
🟡 Missing `setBroadcast` `setTTL` `setMulticastTTL` `setMulticastLoopback` `setMulticastInterface` `addMembership` `dropMembership`
|
|
40
|
-
`addSourceSpecificMembership` `dropSourceSpecificMembership`
|
|
41
|
-
|
|
42
21
|
### [`node:diagnostics_channel`](https://nodejs.org/api/diagnostics_channel.html)
|
|
43
22
|
|
|
44
23
|
🟢 Fully implemented.
|
|
45
24
|
|
|
46
25
|
### [`node:dns`](https://nodejs.org/api/dns.html)
|
|
47
26
|
|
|
48
|
-
|
|
27
|
+
🟢 Fully implemented. > 90% of Node.js's test suite passes.
|
|
49
28
|
|
|
50
|
-
### [`node:
|
|
29
|
+
### [`node:events`](https://nodejs.org/api/events.html)
|
|
51
30
|
|
|
52
|
-
|
|
31
|
+
🟢 Fully implemented. `EventEmitterAsyncResource` uses `AsyncResource` underneath. 100% of Node.js's test suite for EventEmitter passes.
|
|
53
32
|
|
|
54
|
-
### [`node:
|
|
33
|
+
### [`node:http`](https://nodejs.org/api/http.html)
|
|
55
34
|
|
|
56
|
-
🟢 Fully implemented.
|
|
35
|
+
🟢 Fully implemented. Outgoing client request body is currently buffered instead of streamed.
|
|
57
36
|
|
|
58
|
-
### [`node:
|
|
37
|
+
### [`node:https`](https://nodejs.org/api/https.html)
|
|
59
38
|
|
|
60
|
-
|
|
39
|
+
🟢 APIs are implemented, but `Agent` is not always used yet.
|
|
61
40
|
|
|
62
|
-
### [`node:
|
|
41
|
+
### [`node:os`](https://nodejs.org/api/os.html)
|
|
63
42
|
|
|
64
|
-
🟢 Fully implemented.
|
|
43
|
+
🟢 Fully implemented. 100% of Node.js's test suite passes.
|
|
65
44
|
|
|
66
|
-
### [`node:
|
|
45
|
+
### [`node:path`](https://nodejs.org/api/path.html)
|
|
67
46
|
|
|
68
|
-
|
|
47
|
+
🟢 Fully implemented. 100% of Node.js's test suite passes.
|
|
69
48
|
|
|
70
|
-
### [`node:
|
|
49
|
+
### [`node:punycode`](https://nodejs.org/api/punycode.html)
|
|
71
50
|
|
|
72
|
-
🟢
|
|
51
|
+
🟢 Fully implemented. 100% of Node.js's test suite passes, _deprecated by Node.js_.
|
|
73
52
|
|
|
74
|
-
### [`node:
|
|
53
|
+
### [`node:querystring`](https://nodejs.org/api/querystring.html)
|
|
75
54
|
|
|
76
|
-
|
|
55
|
+
🟢 Fully implemented. 100% of Node.js's test suite passes.
|
|
77
56
|
|
|
78
|
-
### [`node:
|
|
57
|
+
### [`node:readline`](https://nodejs.org/api/readline.html)
|
|
79
58
|
|
|
80
|
-
|
|
59
|
+
🟢 Fully implemented.
|
|
81
60
|
|
|
82
|
-
### [`node:
|
|
61
|
+
### [`node:string_decoder`](https://nodejs.org/api/string_decoder.html)
|
|
83
62
|
|
|
84
|
-
|
|
63
|
+
🟢 Fully implemented. 100% of Node.js's test suite passes.
|
|
85
64
|
|
|
86
|
-
### [`node:
|
|
65
|
+
### [`node:timers`](https://nodejs.org/api/timers.html)
|
|
66
|
+
|
|
67
|
+
🟢 Recommended to use global `setTimeout`, et. al. instead.
|
|
68
|
+
|
|
69
|
+
### [`node:tty`](https://nodejs.org/api/tty.html)
|
|
87
70
|
|
|
88
71
|
🟢 Fully implemented.
|
|
89
72
|
|
|
90
|
-
### [`node:
|
|
73
|
+
### [`node:url`](https://nodejs.org/api/url.html)
|
|
91
74
|
|
|
92
75
|
🟢 Fully implemented.
|
|
93
76
|
|
|
94
|
-
### [`node:
|
|
77
|
+
### [`node:zlib`](https://nodejs.org/api/zlib.html)
|
|
95
78
|
|
|
96
|
-
|
|
79
|
+
🟢 Fully implemented. 98% of Node.js's test suite passes.
|
|
97
80
|
|
|
98
|
-
### [`node:
|
|
81
|
+
### [`node:async_hooks`](https://nodejs.org/api/async_hooks.html)
|
|
99
82
|
|
|
100
|
-
🟡
|
|
83
|
+
🟡 `AsyncLocalStorage`, and `AsyncResource` are implemented. `AsyncResource` is missing `bind`. v8 hooks are stubbed.
|
|
101
84
|
|
|
102
|
-
### [`node:
|
|
85
|
+
### [`node:child_process`](https://nodejs.org/api/child_process.html)
|
|
103
86
|
|
|
104
|
-
|
|
87
|
+
🟡 Missing `proc.gid` `proc.uid`. `Stream` class not exported. IPC cannot send socket handles. Node.js <> Bun IPC can be used with JSON serialization.
|
|
105
88
|
|
|
106
|
-
### [`node:
|
|
89
|
+
### [`node:cluster`](https://nodejs.org/api/cluster.html)
|
|
107
90
|
|
|
108
|
-
|
|
91
|
+
🟡 Handles and file descriptors cannot be passed between workers, which means load-balancing HTTP requests across processes is only supported on Linux at this time (via `SO_REUSEPORT`). Otherwise, implemented but not battle-tested.
|
|
109
92
|
|
|
110
|
-
### [`node:
|
|
93
|
+
### [`node:crypto`](https://nodejs.org/api/crypto.html)
|
|
111
94
|
|
|
112
|
-
|
|
95
|
+
🟡 Missing `Certificate` `ECDH` `X509Certificate` `checkPrime` `checkPrimeSync` `diffieHellman` `generatePrime` `generatePrimeSync` `getCipherInfo` `getFips` `hkdf` `hkdfSync` `secureHeapUsed` `setEngine` `setFips`
|
|
113
96
|
|
|
114
|
-
|
|
97
|
+
Some methods are not optimized yet.
|
|
115
98
|
|
|
116
|
-
|
|
99
|
+
### [`node:dgram`](https://nodejs.org/api/dgram.html)
|
|
117
100
|
|
|
118
|
-
|
|
101
|
+
🟡 Missing `setBroadcast` `setTTL` `setMulticastTTL` `setMulticastLoopback` `setMulticastInterface` `addMembership` `dropMembership`
|
|
102
|
+
`addSourceSpecificMembership` `dropSourceSpecificMembership`
|
|
119
103
|
|
|
120
|
-
|
|
104
|
+
### [`node:domain`](https://nodejs.org/api/domain.html)
|
|
121
105
|
|
|
122
|
-
|
|
106
|
+
🟡 Missing `Domain` `active`
|
|
123
107
|
|
|
124
|
-
|
|
108
|
+
### [`node:fs`](https://nodejs.org/api/fs.html)
|
|
125
109
|
|
|
126
|
-
|
|
110
|
+
🟡 Missing `statfs` `statfsSync`, `opendirSync`. `Dir` is partially implemented.
|
|
127
111
|
|
|
128
|
-
|
|
112
|
+
### [`node:http2`](https://nodejs.org/api/http2.html)
|
|
129
113
|
|
|
130
|
-
|
|
114
|
+
🟡 Client & server are implemented (95.25% of gRPC's test suite passes). Missing `options.allowHTTP1`, `options.enableConnectProtocol`, ALTSVC extension, and `http2stream.pushStream`.
|
|
131
115
|
|
|
132
|
-
|
|
116
|
+
### [`node:module`](https://nodejs.org/api/module.html)
|
|
133
117
|
|
|
134
|
-
|
|
118
|
+
🟡 Missing `runMain` `syncBuiltinESMExports`, `Module#load()`. Overriding `require.cache` is supported for ESM & CJS modules. `module._extensions`, `module._pathCache`, `module._cache` are no-ops. `module.register` is not implemented and we recommend using a [`Bun.plugin`](https://bun.sh/docs/runtime/plugins) in the meantime.
|
|
135
119
|
|
|
136
|
-
|
|
120
|
+
### [`node:net`](https://nodejs.org/api/net.html)
|
|
137
121
|
|
|
138
|
-
|
|
122
|
+
🟡 `SocketAddress` class not exposed (but implemented). `BlockList` exists but is a no-op.
|
|
139
123
|
|
|
140
|
-
|
|
124
|
+
### [`node:perf_hooks`](https://nodejs.org/api/perf_hooks.html)
|
|
141
125
|
|
|
142
|
-
|
|
126
|
+
🟡 Missing `createHistogram` `monitorEventLoopDelay`. It's recommended to use `performance` global instead of `perf_hooks.performance`.
|
|
143
127
|
|
|
144
|
-
|
|
128
|
+
### [`node:process`](https://nodejs.org/api/process.html)
|
|
145
129
|
|
|
146
|
-
|
|
130
|
+
🟡 See [`process`](#process) Global.
|
|
147
131
|
|
|
148
|
-
|
|
132
|
+
### [`node:stream`](https://nodejs.org/api/stream.html)
|
|
149
133
|
|
|
150
|
-
|
|
134
|
+
🟡 Missing `toWeb`
|
|
151
135
|
|
|
152
|
-
|
|
136
|
+
### [`node:sys`](https://nodejs.org/api/util.html)
|
|
137
|
+
|
|
138
|
+
🟡 See [`node:util`](#node-util).
|
|
139
|
+
|
|
140
|
+
### [`node:tls`](https://nodejs.org/api/tls.html)
|
|
141
|
+
|
|
142
|
+
🟡 Missing `tls.createSecurePair`.
|
|
153
143
|
|
|
154
144
|
### [`node:util`](https://nodejs.org/api/util.html)
|
|
155
145
|
|
|
@@ -171,11 +161,27 @@ Some methods are not optimized yet.
|
|
|
171
161
|
|
|
172
162
|
🟡 `Worker` doesn't support the following options: `stdin` `stdout` `stderr` `trackedUnmanagedFds` `resourceLimits`. Missing `markAsUntransferable` `moveMessagePortToContext` `getHeapSnapshot`.
|
|
173
163
|
|
|
174
|
-
### [`node:
|
|
164
|
+
### [`node:inspector`](https://nodejs.org/api/inspector.html)
|
|
175
165
|
|
|
176
|
-
|
|
166
|
+
🔴 Not implemented.
|
|
177
167
|
|
|
178
|
-
|
|
168
|
+
### [`node:repl`](https://nodejs.org/api/repl.html)
|
|
169
|
+
|
|
170
|
+
🔴 Not implemented.
|
|
171
|
+
|
|
172
|
+
### [`node:sqlite`](https://nodejs.org/api/sqlite.html)
|
|
173
|
+
|
|
174
|
+
🔴 Not implemented.
|
|
175
|
+
|
|
176
|
+
### [`node:test`](https://nodejs.org/api/test.html)
|
|
177
|
+
|
|
178
|
+
🔴 Not implemented. Use [`bun:test`](https://bun.sh/docs/cli/test) instead.
|
|
179
|
+
|
|
180
|
+
### [`node:trace_events`](https://nodejs.org/api/tracing.html)
|
|
181
|
+
|
|
182
|
+
🔴 Not implemented.
|
|
183
|
+
|
|
184
|
+
## Node.js globals
|
|
179
185
|
|
|
180
186
|
The table below lists all globals implemented by Node.js and Bun's current compatibility status.
|
|
181
187
|
|
|
@@ -333,7 +339,7 @@ The table below lists all globals implemented by Node.js and Bun's current compa
|
|
|
333
339
|
|
|
334
340
|
### [`PerformanceResourceTiming`](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming)
|
|
335
341
|
|
|
336
|
-
|
|
342
|
+
🟢 Fully implemented.
|
|
337
343
|
|
|
338
344
|
### [`performance`](https://developer.mozilla.org/en-US/docs/Web/API/performance)
|
|
339
345
|
|
|
@@ -341,7 +347,7 @@ The table below lists all globals implemented by Node.js and Bun's current compa
|
|
|
341
347
|
|
|
342
348
|
### [`process`](https://nodejs.org/api/process.html)
|
|
343
349
|
|
|
344
|
-
🟡
|
|
350
|
+
🟡 Mostly implemented. `process.binding` (internal Node.js bindings some packages rely on) is partially implemented. `process.title` is a currently a no-op on macOS & Linux. `getActiveResourcesInfo` `setActiveResourcesInfo`, `getActiveResources` and `setSourceMapsEnabled` are stubs. Newer APIs like `process.loadEnvFile` and `process.getBuiltinModule` are not implemented yet.
|
|
345
351
|
|
|
346
352
|
### [`queueMicrotask()`](https://developer.mozilla.org/en-US/docs/Web/API/queueMicrotask)
|
|
347
353
|
|
|
@@ -373,7 +379,7 @@ The table below lists all globals implemented by Node.js and Bun's current compa
|
|
|
373
379
|
|
|
374
380
|
### [`require()`](https://nodejs.org/api/globals.html#require)
|
|
375
381
|
|
|
376
|
-
🟢 Fully implemented, including [`require.main`](https://nodejs.org/api/modules.html#requiremain), [`require.cache`](https://nodejs.org/api/modules.html#requirecache), [`require.resolve`](https://nodejs.org/api/modules.html#requireresolverequest-options)
|
|
382
|
+
🟢 Fully implemented, including [`require.main`](https://nodejs.org/api/modules.html#requiremain), [`require.cache`](https://nodejs.org/api/modules.html#requirecache), [`require.resolve`](https://nodejs.org/api/modules.html#requireresolverequest-options). `require.extensions` is a stub.
|
|
377
383
|
|
|
378
384
|
### [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
|
379
385
|
|
package/docs/test/dom.md
CHANGED
package/package.json
CHANGED