bun-types 1.3.2-canary.20251104T140728 → 1.3.2-canary.20251106T140813
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/bun.d.ts +4 -4
- package/docs/README.md +28 -0
- package/globals.d.ts +0 -1
- package/overrides.d.ts +45 -15
- package/package.json +1 -1
- package/test.d.ts +1 -1
- package/docs/api/binary-data.md +0 -1038
- package/docs/api/cc.md +0 -197
- package/docs/api/color.md +0 -262
- package/docs/api/console.md +0 -57
- package/docs/api/cookie.md +0 -449
- package/docs/api/dns.md +0 -110
- package/docs/api/fetch.md +0 -463
- package/docs/api/ffi.md +0 -557
- package/docs/api/file-io.md +0 -366
- package/docs/api/file-system-router.md +0 -112
- package/docs/api/file.md +0 -19
- package/docs/api/glob.md +0 -178
- package/docs/api/globals.md +0 -387
- package/docs/api/hashing.md +0 -319
- package/docs/api/html-rewriter.md +0 -334
- package/docs/api/http.md +0 -1408
- package/docs/api/import-meta.md +0 -69
- package/docs/api/node-api.md +0 -14
- package/docs/api/redis.md +0 -597
- package/docs/api/s3.md +0 -850
- package/docs/api/secrets.md +0 -319
- package/docs/api/semver.md +0 -52
- package/docs/api/spawn.md +0 -582
- package/docs/api/sql.md +0 -1374
- package/docs/api/sqlite.md +0 -694
- package/docs/api/streams.md +0 -230
- package/docs/api/tcp.md +0 -221
- package/docs/api/transpiler.md +0 -276
- package/docs/api/udp.md +0 -123
- package/docs/api/utils.md +0 -891
- package/docs/api/websockets.md +0 -573
- package/docs/api/workers.md +0 -322
- package/docs/api/yaml.md +0 -668
- package/docs/benchmarks.md +0 -120
- package/docs/bun-flavored-toml.md +0 -42
- package/docs/bundler/css.md +0 -1028
- package/docs/bundler/css_modules.md +0 -145
- package/docs/bundler/executables.md +0 -626
- package/docs/bundler/fullstack.md +0 -418
- package/docs/bundler/hmr.md +0 -234
- package/docs/bundler/html.md +0 -349
- package/docs/bundler/index.md +0 -1735
- package/docs/bundler/intro.md +0 -75
- package/docs/bundler/loaders.md +0 -410
- package/docs/bundler/macros.md +0 -329
- package/docs/bundler/plugins.md +0 -449
- package/docs/bundler/vs-esbuild.md +0 -1127
- package/docs/cli/add.md +0 -173
- package/docs/cli/bun-completions.md +0 -3
- package/docs/cli/bun-create.md +0 -338
- package/docs/cli/bun-install.md +0 -349
- package/docs/cli/bun-upgrade.md +0 -39
- package/docs/cli/bunx.md +0 -89
- package/docs/cli/filter.md +0 -90
- package/docs/cli/info.md +0 -65
- package/docs/cli/init.md +0 -85
- package/docs/cli/install.md +0 -344
- package/docs/cli/link.md +0 -40
- package/docs/cli/outdated.md +0 -90
- package/docs/cli/patch-commit.md +0 -11
- package/docs/cli/pm.md +0 -285
- package/docs/cli/publish.md +0 -120
- package/docs/cli/remove.md +0 -7
- package/docs/cli/run.md +0 -261
- package/docs/cli/test.md +0 -397
- package/docs/cli/unlink.md +0 -9
- package/docs/cli/update.md +0 -129
- package/docs/cli/why.md +0 -67
- package/docs/contributing/upgrading-webkit.md +0 -57
- package/docs/ecosystem/elysia.md +0 -24
- package/docs/ecosystem/express.md +0 -37
- package/docs/ecosystem/hono.md +0 -18
- package/docs/ecosystem/react.md +0 -65
- package/docs/ecosystem/stric.md +0 -38
- package/docs/guides/binary/arraybuffer-to-array.md +0 -27
- package/docs/guides/binary/arraybuffer-to-blob.md +0 -24
- package/docs/guides/binary/arraybuffer-to-buffer.md +0 -25
- package/docs/guides/binary/arraybuffer-to-string.md +0 -15
- package/docs/guides/binary/arraybuffer-to-typedarray.md +0 -39
- package/docs/guides/binary/blob-to-arraybuffer.md +0 -14
- package/docs/guides/binary/blob-to-dataview.md +0 -14
- package/docs/guides/binary/blob-to-stream.md +0 -14
- package/docs/guides/binary/blob-to-string.md +0 -15
- package/docs/guides/binary/blob-to-typedarray.md +0 -14
- package/docs/guides/binary/buffer-to-arraybuffer.md +0 -14
- package/docs/guides/binary/buffer-to-blob.md +0 -14
- package/docs/guides/binary/buffer-to-readablestream.md +0 -41
- package/docs/guides/binary/buffer-to-string.md +0 -25
- package/docs/guides/binary/buffer-to-typedarray.md +0 -14
- package/docs/guides/binary/dataview-to-string.md +0 -15
- package/docs/guides/binary/typedarray-to-arraybuffer.md +0 -25
- package/docs/guides/binary/typedarray-to-blob.md +0 -16
- package/docs/guides/binary/typedarray-to-buffer.md +0 -14
- package/docs/guides/binary/typedarray-to-dataview.md +0 -14
- package/docs/guides/binary/typedarray-to-readablestream.md +0 -41
- package/docs/guides/binary/typedarray-to-string.md +0 -16
- package/docs/guides/deployment/railway.md +0 -157
- package/docs/guides/ecosystem/astro.md +0 -72
- package/docs/guides/ecosystem/discordjs.md +0 -77
- package/docs/guides/ecosystem/docker.md +0 -140
- package/docs/guides/ecosystem/drizzle.md +0 -185
- package/docs/guides/ecosystem/edgedb.md +0 -228
- package/docs/guides/ecosystem/elysia.md +0 -31
- package/docs/guides/ecosystem/express.md +0 -40
- package/docs/guides/ecosystem/hono.md +0 -39
- package/docs/guides/ecosystem/mongoose.md +0 -87
- package/docs/guides/ecosystem/neon-drizzle.md +0 -220
- package/docs/guides/ecosystem/neon-serverless-postgres.md +0 -55
- package/docs/guides/ecosystem/nextjs.md +0 -49
- package/docs/guides/ecosystem/nuxt.md +0 -56
- package/docs/guides/ecosystem/pm2.md +0 -57
- package/docs/guides/ecosystem/prisma.md +0 -141
- package/docs/guides/ecosystem/qwik.md +0 -107
- package/docs/guides/ecosystem/react.md +0 -50
- package/docs/guides/ecosystem/remix.md +0 -78
- package/docs/guides/ecosystem/render.md +0 -79
- package/docs/guides/ecosystem/sentry.md +0 -52
- package/docs/guides/ecosystem/solidstart.md +0 -58
- package/docs/guides/ecosystem/ssr-react.md +0 -51
- package/docs/guides/ecosystem/stric.md +0 -55
- package/docs/guides/ecosystem/sveltekit.md +0 -125
- package/docs/guides/ecosystem/systemd.md +0 -113
- package/docs/guides/ecosystem/vite.md +0 -71
- package/docs/guides/html-rewriter/extract-links.md +0 -68
- package/docs/guides/html-rewriter/extract-social-meta.md +0 -93
- package/docs/guides/http/cluster.md +0 -66
- package/docs/guides/http/fetch-unix.md +0 -33
- package/docs/guides/http/fetch.md +0 -24
- package/docs/guides/http/file-uploads.md +0 -94
- package/docs/guides/http/hot.md +0 -26
- package/docs/guides/http/proxy.md +0 -24
- package/docs/guides/http/server.md +0 -46
- package/docs/guides/http/simple.md +0 -18
- package/docs/guides/http/stream-file.md +0 -48
- package/docs/guides/http/stream-iterator.md +0 -47
- package/docs/guides/http/stream-node-streams-in-bun.md +0 -20
- package/docs/guides/http/tls.md +0 -30
- package/docs/guides/install/add-dev.md +0 -26
- package/docs/guides/install/add-git.md +0 -36
- package/docs/guides/install/add-optional.md +0 -25
- package/docs/guides/install/add-peer.md +0 -43
- package/docs/guides/install/add-tarball.md +0 -33
- package/docs/guides/install/add.md +0 -42
- package/docs/guides/install/azure-artifacts.md +0 -73
- package/docs/guides/install/cicd.md +0 -41
- package/docs/guides/install/custom-registry.md +0 -30
- package/docs/guides/install/from-npm-install-to-bun-install.md +0 -214
- package/docs/guides/install/git-diff-bun-lockfile.md +0 -44
- package/docs/guides/install/jfrog-artifactory.md +0 -28
- package/docs/guides/install/npm-alias.md +0 -23
- package/docs/guides/install/registry-scope.md +0 -38
- package/docs/guides/install/trusted.md +0 -46
- package/docs/guides/install/workspaces.md +0 -70
- package/docs/guides/install/yarnlock.md +0 -44
- package/docs/guides/process/argv.md +0 -58
- package/docs/guides/process/ctrl-c.md +0 -16
- package/docs/guides/process/ipc.md +0 -66
- package/docs/guides/process/nanoseconds.md +0 -13
- package/docs/guides/process/os-signals.md +0 -39
- package/docs/guides/process/spawn-stderr.md +0 -31
- package/docs/guides/process/spawn-stdout.md +0 -26
- package/docs/guides/process/spawn.md +0 -41
- package/docs/guides/process/stdin.md +0 -54
- package/docs/guides/read-file/arraybuffer.md +0 -28
- package/docs/guides/read-file/buffer.md +0 -19
- package/docs/guides/read-file/exists.md +0 -16
- package/docs/guides/read-file/json.md +0 -17
- package/docs/guides/read-file/mime.md +0 -20
- package/docs/guides/read-file/stream.md +0 -26
- package/docs/guides/read-file/string.md +0 -22
- package/docs/guides/read-file/uint8array.md +0 -21
- package/docs/guides/read-file/watch.md +0 -68
- package/docs/guides/runtime/build-time-constants.md +0 -293
- package/docs/guides/runtime/cicd.md +0 -43
- package/docs/guides/runtime/codesign-macos-executable.md +0 -56
- package/docs/guides/runtime/define-constant.md +0 -145
- package/docs/guides/runtime/delete-directory.md +0 -37
- package/docs/guides/runtime/delete-file.md +0 -19
- package/docs/guides/runtime/heap-snapshot.md +0 -26
- package/docs/guides/runtime/import-html.md +0 -15
- package/docs/guides/runtime/import-json.md +0 -44
- package/docs/guides/runtime/import-toml.md +0 -30
- package/docs/guides/runtime/import-yaml.md +0 -102
- package/docs/guides/runtime/read-env.md +0 -32
- package/docs/guides/runtime/set-env.md +0 -47
- package/docs/guides/runtime/shell.md +0 -40
- package/docs/guides/runtime/timezone.md +0 -35
- package/docs/guides/runtime/tsconfig-paths.md +0 -29
- package/docs/guides/runtime/typescript.md +0 -49
- package/docs/guides/runtime/vscode-debugger.md +0 -47
- package/docs/guides/runtime/web-debugger.md +0 -82
- package/docs/guides/streams/node-readable-to-arraybuffer.md +0 -11
- package/docs/guides/streams/node-readable-to-blob.md +0 -11
- package/docs/guides/streams/node-readable-to-json.md +0 -12
- package/docs/guides/streams/node-readable-to-string.md +0 -12
- package/docs/guides/streams/node-readable-to-uint8array.md +0 -11
- package/docs/guides/streams/to-array.md +0 -14
- package/docs/guides/streams/to-arraybuffer.md +0 -14
- package/docs/guides/streams/to-blob.md +0 -14
- package/docs/guides/streams/to-buffer.md +0 -15
- package/docs/guides/streams/to-json.md +0 -14
- package/docs/guides/streams/to-string.md +0 -14
- package/docs/guides/streams/to-typedarray.md +0 -22
- package/docs/guides/test/bail.md +0 -22
- package/docs/guides/test/coverage-threshold.md +0 -60
- package/docs/guides/test/coverage.md +0 -44
- package/docs/guides/test/happy-dom.md +0 -68
- package/docs/guides/test/migrate-from-jest.md +0 -143
- package/docs/guides/test/mock-clock.md +0 -48
- package/docs/guides/test/mock-functions.md +0 -68
- package/docs/guides/test/rerun-each.md +0 -14
- package/docs/guides/test/run-tests.md +0 -111
- package/docs/guides/test/skip-tests.md +0 -39
- package/docs/guides/test/snapshot.md +0 -95
- package/docs/guides/test/spy-on.md +0 -46
- package/docs/guides/test/svelte-test.md +0 -120
- package/docs/guides/test/testing-library.md +0 -92
- package/docs/guides/test/timeout.md +0 -15
- package/docs/guides/test/todo-tests.md +0 -67
- package/docs/guides/test/update-snapshots.md +0 -46
- package/docs/guides/test/watch-mode.md +0 -19
- package/docs/guides/util/base64.md +0 -15
- package/docs/guides/util/deep-equals.md +0 -39
- package/docs/guides/util/deflate.md +0 -18
- package/docs/guides/util/detect-bun.md +0 -23
- package/docs/guides/util/entrypoint.md +0 -17
- package/docs/guides/util/escape-html.md +0 -22
- package/docs/guides/util/file-url-to-path.md +0 -14
- package/docs/guides/util/gzip.md +0 -18
- package/docs/guides/util/hash-a-password.md +0 -54
- package/docs/guides/util/import-meta-dir.md +0 -13
- package/docs/guides/util/import-meta-file.md +0 -13
- package/docs/guides/util/import-meta-path.md +0 -13
- package/docs/guides/util/javascript-uuid.md +0 -23
- package/docs/guides/util/main.md +0 -32
- package/docs/guides/util/path-to-file-url.md +0 -14
- package/docs/guides/util/sleep.md +0 -22
- package/docs/guides/util/version.md +0 -21
- package/docs/guides/util/which-path-to-executable-bin.md +0 -15
- package/docs/guides/websocket/compression.md +0 -31
- package/docs/guides/websocket/context.md +0 -77
- package/docs/guides/websocket/pubsub.md +0 -41
- package/docs/guides/websocket/simple.md +0 -33
- package/docs/guides/write-file/append.md +0 -52
- package/docs/guides/write-file/basic.md +0 -44
- package/docs/guides/write-file/blob.md +0 -28
- package/docs/guides/write-file/cat.md +0 -17
- package/docs/guides/write-file/file-cp.md +0 -16
- package/docs/guides/write-file/filesink.md +0 -52
- package/docs/guides/write-file/response.md +0 -17
- package/docs/guides/write-file/stdout.md +0 -21
- package/docs/guides/write-file/stream.md +0 -17
- package/docs/guides/write-file/unlink.md +0 -16
- package/docs/index.md +0 -77
- package/docs/install/audit.md +0 -57
- package/docs/install/cache.md +0 -59
- package/docs/install/catalogs.md +0 -298
- package/docs/install/index.md +0 -248
- package/docs/install/isolated.md +0 -197
- package/docs/install/lifecycle.md +0 -46
- package/docs/install/lockfile.md +0 -58
- package/docs/install/npmrc.md +0 -105
- package/docs/install/overrides.md +0 -73
- package/docs/install/patch.md +0 -59
- package/docs/install/registries.md +0 -30
- package/docs/install/security-scanner-api.md +0 -81
- package/docs/install/workspaces.md +0 -114
- package/docs/installation.md +0 -327
- package/docs/project/asan.md +0 -124
- package/docs/project/benchmarking.md +0 -203
- package/docs/project/bindgen.md +0 -225
- package/docs/project/building-windows.md +0 -162
- package/docs/project/contributing.md +0 -347
- package/docs/project/internals/build-process-for-ci.md +0 -75
- package/docs/project/licensing.md +0 -73
- package/docs/project/roadmap.md +0 -87
- package/docs/quickstart.md +0 -157
- package/docs/runtime/autoimport.md +0 -94
- package/docs/runtime/bun-apis.md +0 -207
- package/docs/runtime/bunfig.md +0 -772
- package/docs/runtime/debugger.md +0 -325
- package/docs/runtime/env.md +0 -253
- package/docs/runtime/hot.md +0 -145
- package/docs/runtime/index.md +0 -312
- package/docs/runtime/jsx.md +0 -385
- package/docs/runtime/loaders.md +0 -130
- package/docs/runtime/modules.md +0 -320
- package/docs/runtime/nodejs-apis.md +0 -463
- package/docs/runtime/plugins.md +0 -561
- package/docs/runtime/shell.md +0 -605
- package/docs/runtime/typescript.md +0 -139
- package/docs/runtime/web-apis.md +0 -128
- package/docs/test/configuration.md +0 -154
- package/docs/test/coverage.md +0 -142
- package/docs/test/discovery.md +0 -85
- package/docs/test/dom.md +0 -75
- package/docs/test/examples/concurrent-test-glob.md +0 -132
- package/docs/test/hot.md +0 -15
- package/docs/test/lifecycle.md +0 -81
- package/docs/test/mocks.md +0 -313
- package/docs/test/reporters.md +0 -117
- package/docs/test/runtime-behavior.md +0 -95
- package/docs/test/snapshots.md +0 -68
- package/docs/test/time.md +0 -126
- package/docs/test/writing.md +0 -825
- package/docs/typescript.md +0 -53
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Write a ReadableStream to a file
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
To write a `ReadableStream` to disk, first create a `Response` instance from the stream. This `Response` can then be written to disk using [`Bun.write()`](https://bun.com/docs/api/file-io#writing-files-bun-write).
|
|
6
|
-
|
|
7
|
-
```ts
|
|
8
|
-
const stream: ReadableStream = ...;
|
|
9
|
-
const path = "./file.txt";
|
|
10
|
-
const response = new Response(stream);
|
|
11
|
-
|
|
12
|
-
await Bun.write(path, response);
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
See [Docs > API > File I/O](https://bun.com/docs/api/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`.
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Delete a file
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
The `Bun.file()` function accepts a path and returns a `BunFile` instance. Use the `.delete()` method to delete the file.
|
|
6
|
-
|
|
7
|
-
```ts
|
|
8
|
-
const path = "/path/to/file.txt";
|
|
9
|
-
const file = Bun.file(path);
|
|
10
|
-
|
|
11
|
-
await file.delete();
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
---
|
|
15
|
-
|
|
16
|
-
See [Docs > API > File I/O](https://bun.com/docs/api/file-io#reading-files-bun-file) for complete documentation of `Bun.file()`.
|
package/docs/index.md
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
Bun is an all-in-one toolkit for JavaScript and TypeScript apps. It ships as a single executable called `bun`.
|
|
2
|
-
|
|
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
|
-
|
|
5
|
-
```bash
|
|
6
|
-
$ bun run index.tsx # TS and JSX supported out of the box
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
The `bun` command-line tool also implements a test runner, script runner, and Node.js-compatible package manager, all significantly faster than existing tools and usable in existing Node.js projects with little to no changes necessary.
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
$ bun run start # run the `start` script
|
|
13
|
-
$ bun install <pkg> # install a package
|
|
14
|
-
$ bun build ./index.tsx # bundle a project for browsers
|
|
15
|
-
$ bun test # run tests
|
|
16
|
-
$ bunx cowsay 'Hello, world!' # execute a package
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
Get started with one of the quick links below, or read on to learn more about Bun.
|
|
20
|
-
|
|
21
|
-
{% block className="gap-2 grid grid-flow-row grid-cols-1 md:grid-cols-2" %}
|
|
22
|
-
{% arrowbutton href="/docs/installation" text="Install Bun" /%}
|
|
23
|
-
{% arrowbutton href="/docs/quickstart" text="Do the quickstart" /%}
|
|
24
|
-
{% arrowbutton href="/docs/cli/install" text="Install a package" /%}
|
|
25
|
-
{% arrowbutton href="/docs/cli/bun-create" text="Use a project template" /%}
|
|
26
|
-
{% arrowbutton href="/docs/bundler" text="Bundle code for production" /%}
|
|
27
|
-
{% arrowbutton href="/docs/api/http" text="Build an HTTP server" /%}
|
|
28
|
-
{% arrowbutton href="/docs/api/websockets" text="Build a Websocket server" /%}
|
|
29
|
-
{% arrowbutton href="/docs/api/file-io" text="Read and write files" /%}
|
|
30
|
-
{% arrowbutton href="/docs/api/sqlite" text="Run SQLite queries" /%}
|
|
31
|
-
{% arrowbutton href="/docs/cli/test" text="Write and run tests" /%}
|
|
32
|
-
{% /block %}
|
|
33
|
-
|
|
34
|
-
## What is a runtime?
|
|
35
|
-
|
|
36
|
-
JavaScript (or, more formally, ECMAScript) is just a _specification_ for a programming language. Anyone can write a JavaScript _engine_ that ingests a valid JavaScript program and executes it. The two most popular engines in use today are V8 (developed by Google)
|
|
37
|
-
and JavaScriptCore (developed by Apple). Both are open source.
|
|
38
|
-
|
|
39
|
-
But most JavaScript programs don't run in a vacuum. They need a way to access the outside world to perform useful tasks. This is where _runtimes_ come in. They implement additional APIs that are then made available to the JavaScript programs they execute.
|
|
40
|
-
|
|
41
|
-
### Browsers
|
|
42
|
-
|
|
43
|
-
Notably, browsers ship with JavaScript runtimes that implement a set of Web-specific APIs that are exposed via the global `window` object. Any JavaScript code executed by the browser can use these APIs to implement interactive or dynamic behavior in the context of the current webpage.
|
|
44
|
-
|
|
45
|
-
<!-- JavaScript runtime that exposes JavaScript engines are designed to run "vanilla" JavaScript programs, but it's often JavaScript _runtimes_ use an engine internally to execute the code and implement additional APIs that are then made available to executed programs.
|
|
46
|
-
JavaScript was [initially designed](https://en.wikipedia.org/wiki/JavaScript) as a language to run in web browsers to implement interactivity and dynamic behavior in web pages. Browsers are the first JavaScript runtimes. JavaScript programs that are executed in browsers have access to a set of Web-specific global APIs on the `window` object. -->
|
|
47
|
-
|
|
48
|
-
### Node.js
|
|
49
|
-
|
|
50
|
-
Similarly, Node.js is a JavaScript runtime that can be used in non-browser environments, like servers. JavaScript programs executed by Node.js have access to a set of Node.js-specific [globals](https://nodejs.org/api/globals.html) like `Buffer`, `process`, and `__dirname` in addition to built-in modules for performing OS-level tasks like reading/writing files (`node:fs`) and networking (`node:net`, `node:http`). Node.js also implements a CommonJS-based module system and resolution algorithm that pre-dates JavaScript's native module system.
|
|
51
|
-
|
|
52
|
-
<!-- Bun.js prefers Web API compatibility instead of designing new APIs when possible. Bun.js also implements some Node.js APIs. -->
|
|
53
|
-
|
|
54
|
-
Bun is designed as a faster, leaner, more modern replacement for Node.js.
|
|
55
|
-
|
|
56
|
-
<!-- ## Why a new runtime?
|
|
57
|
-
|
|
58
|
-
Bun is designed as a faster, leaner, more modern replacement for Node.js. Node.js is burdened by ingrained performance issues, backwards compatibility concerns, and slow development velocity—inevitable issues for a project of its age and magnitude. -->
|
|
59
|
-
|
|
60
|
-
## Design goals
|
|
61
|
-
|
|
62
|
-
Bun is designed from the ground-up with today's JavaScript ecosystem in mind.
|
|
63
|
-
|
|
64
|
-
- **Speed**. Bun processes start [4x faster than Node.js](https://twitter.com/jarredsumner/status/1499225725492076544) currently (try it yourself!)
|
|
65
|
-
- **TypeScript & JSX support**. You can directly execute `.jsx`, `.ts`, and `.tsx` files; Bun's transpiler converts these to vanilla JavaScript before execution.
|
|
66
|
-
- **ESM & CommonJS compatibility**. The world is moving towards ES modules (ESM), but millions of packages on npm still require CommonJS. Bun recommends ES modules, but supports CommonJS.
|
|
67
|
-
- **Web-standard APIs**. Bun implements standard Web APIs like `fetch`, `WebSocket`, and `ReadableStream`. Bun is powered by the JavaScriptCore engine, which is developed by Apple for Safari, so some APIs like [`Headers`](https://developer.mozilla.org/en-US/docs/Web/API/Headers) and [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL) directly use [Safari's implementation](https://github.com/oven-sh/bun/blob/HEAD/src/bun.js/bindings/webcore/JSFetchHeaders.cpp).
|
|
68
|
-
- **Node.js compatibility**. In addition to supporting Node-style module resolution, Bun aims for full compatibility with built-in Node.js globals (`process`, `Buffer`) and modules (`path`, `fs`, `http`, etc.) _This is an ongoing effort that is not complete._ Refer to the [compatibility page](https://bun.com/docs/runtime/nodejs-apis) for the current status.
|
|
69
|
-
|
|
70
|
-
Bun is more than a runtime. The long-term goal is to be a cohesive, infrastructural toolkit for building apps with JavaScript/TypeScript, including a package manager, transpiler, bundler, script runner, test runner, and more.
|
|
71
|
-
|
|
72
|
-
<!-- - tsconfig.json `"paths"` is natively supported, along with `"exports"` in package.json
|
|
73
|
-
- `fs`, `path`, and `process` from Node.js are partially implemented
|
|
74
|
-
- Web APIs like [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/fetch), [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response), [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL) and more are built-in
|
|
75
|
-
- [`HTMLRewriter`](https://developers.cloudflare.com/workers/runtime-apis/html-rewriter/) makes it easy to transform HTML in Bun.js
|
|
76
|
-
- `.env` files automatically load into `process.env` and `Bun.env`
|
|
77
|
-
- top level await -->
|
package/docs/install/audit.md
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
`bun audit` checks your installed packages for known security vulnerabilities.
|
|
2
|
-
|
|
3
|
-
Run the command in a project with a `bun.lock` file:
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
$ bun audit
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
Bun sends the list of installed packages and versions to NPM, and prints a report of any vulnerabilities that were found. Packages installed from registries other than the default registry are skipped.
|
|
10
|
-
|
|
11
|
-
If no vulnerabilities are found, the command prints:
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
No vulnerabilities found
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
When vulnerabilities are detected, each affected package is listed along with the severity, a short description and a link to the advisory. At the end of the report Bun prints a summary and hints for updating:
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
3 vulnerabilities (1 high, 2 moderate)
|
|
21
|
-
To update all dependencies to the latest compatible versions:
|
|
22
|
-
bun update
|
|
23
|
-
To update all dependencies to the latest versions (including breaking changes):
|
|
24
|
-
bun update --latest
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### Filtering options
|
|
28
|
-
|
|
29
|
-
**`--audit-level=<low|moderate|high|critical>`** - Only show vulnerabilities at this severity level or higher:
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
bun audit --audit-level=high
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
**`--prod`** - Audit only production dependencies (excludes devDependencies):
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
bun audit --prod
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
**`--ignore <CVE>`** - Ignore specific CVEs (can be used multiple times):
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
bun audit --ignore CVE-2022-25883 --ignore CVE-2023-26136
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
### `--json`
|
|
48
|
-
|
|
49
|
-
Use the `--json` flag to print the raw JSON response from the registry instead of the formatted report:
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
$ bun audit --json
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### Exit code
|
|
56
|
-
|
|
57
|
-
`bun audit` will exit with code `0` if no vulnerabilities are found and `1` if the report lists any vulnerabilities. This will still happen even if `--json` is passed.
|
package/docs/install/cache.md
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
All packages downloaded from the registry are stored in a global cache at `~/.bun/install/cache`, or the path defined by the environment variable `BUN_INSTALL_CACHE_DIR`. They are stored in subdirectories named like `${name}@${version}`, so multiple versions of a package can be cached.
|
|
2
|
-
|
|
3
|
-
{% details summary="Configuring cache behavior (bunfig.toml)" %}
|
|
4
|
-
|
|
5
|
-
```toml
|
|
6
|
-
[install.cache]
|
|
7
|
-
# the directory to use for the cache
|
|
8
|
-
dir = "~/.bun/install/cache"
|
|
9
|
-
|
|
10
|
-
# when true, don't load from the global cache.
|
|
11
|
-
# Bun may still write to node_modules/.cache
|
|
12
|
-
disable = false
|
|
13
|
-
|
|
14
|
-
# when true, always resolve the latest versions from the registry
|
|
15
|
-
disableManifest = false
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
{% /details %}
|
|
19
|
-
|
|
20
|
-
## Minimizing re-downloads
|
|
21
|
-
|
|
22
|
-
Bun strives to avoid re-downloading packages multiple times. When installing a package, if the cache already contains a version in the range specified by `package.json`, Bun will use the cached package instead of downloading it again.
|
|
23
|
-
|
|
24
|
-
{% details summary="Installation details" %}
|
|
25
|
-
If the semver version has pre-release suffix (`1.0.0-beta.0`) or a build suffix (`1.0.0+20220101`), it is replaced with a hash of that value instead, to reduce the chances of errors associated with long file paths.
|
|
26
|
-
|
|
27
|
-
When the `node_modules` folder exists, before installing, Bun checks that `node_modules` contains all expected packages with appropriate versions. If so `bun install` completes. Bun uses a custom JSON parser which stops parsing as soon as it finds `"name"` and `"version"`.
|
|
28
|
-
|
|
29
|
-
If a package is missing or has a version incompatible with the `package.json`, Bun checks for a compatible module in the cache. If found, it is installed into `node_modules`. Otherwise, the package will be downloaded from the registry then installed.
|
|
30
|
-
{% /details %}
|
|
31
|
-
|
|
32
|
-
## Fast copying
|
|
33
|
-
|
|
34
|
-
Once a package is downloaded into the cache, Bun still needs to copy those files into `node_modules`. Bun uses the fastest syscalls available to perform this task. On Linux, it uses hardlinks; on macOS, it uses `clonefile`.
|
|
35
|
-
|
|
36
|
-
## Saving disk space
|
|
37
|
-
|
|
38
|
-
Since Bun uses hardlinks to "copy" a module into a project's `node_modules` directory on Linux and Windows, the contents of the package only exist in a single location on disk, greatly reducing the amount of disk space dedicated to `node_modules`.
|
|
39
|
-
|
|
40
|
-
This benefit also applies to macOS, but there are exceptions. It uses `clonefile` which is copy-on-write, meaning it will not occupy disk space, but it will count towards drive's limit. This behavior is useful if something attempts to patch `node_modules/*`, so it's impossible to affect other installations.
|
|
41
|
-
|
|
42
|
-
{% details summary="Installation strategies" %}
|
|
43
|
-
This behavior is configurable with the `--backend` flag, which is respected by all of Bun's package management commands.
|
|
44
|
-
|
|
45
|
-
- **`hardlink`**: Default on Linux and Windows.
|
|
46
|
-
- **`clonefile`** Default on macOS.
|
|
47
|
-
- **`clonefile_each_dir`**: Similar to `clonefile`, except it clones each file individually per directory. It is only available on macOS and tends to perform slower than `clonefile`.
|
|
48
|
-
- **`copyfile`**: The fallback used when any of the above fail. It is the slowest option. On macOS, it uses `fcopyfile()`; on Linux it uses `copy_file_range()`.
|
|
49
|
-
- **`symlink`**: Currently used only `file:` (and eventually `link:`) dependencies. To prevent infinite loops, it skips symlinking the `node_modules` folder.
|
|
50
|
-
|
|
51
|
-
If you install with `--backend=symlink`, Node.js won't resolve node_modules of dependencies unless each dependency has its own `node_modules` folder or you pass `--preserve-symlinks` to `node` or `bun`. See [Node.js documentation on `--preserve-symlinks`](https://nodejs.org/api/cli.html#--preserve-symlinks).
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
$ bun install --backend symlink
|
|
55
|
-
$ node --preserve-symlinks ./foo.js
|
|
56
|
-
$ bun --preserve-symlinks ./foo.js
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
{% /details %}
|
package/docs/install/catalogs.md
DELETED
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
Catalogs in Bun provide a straightforward way to share common dependency versions across multiple packages in a monorepo. Rather than specifying the same versions repeatedly in each workspace package, you define them once in the root package.json and reference them consistently throughout your project.
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
Unlike traditional dependency management where each workspace package needs to independently specify versions, catalogs let you:
|
|
6
|
-
|
|
7
|
-
1. Define version catalogs in the root package.json
|
|
8
|
-
2. Reference these versions with a simple `catalog:` protocol
|
|
9
|
-
3. Update all packages simultaneously by changing the version in just one place
|
|
10
|
-
|
|
11
|
-
This is especially useful in large monorepos where dozens of packages need to use the same version of key dependencies.
|
|
12
|
-
|
|
13
|
-
## How to Use Catalogs
|
|
14
|
-
|
|
15
|
-
### Directory Structure Example
|
|
16
|
-
|
|
17
|
-
Consider a monorepo with the following structure:
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
my-monorepo/
|
|
21
|
-
├── package.json
|
|
22
|
-
├── bun.lock
|
|
23
|
-
└── packages/
|
|
24
|
-
├── app/
|
|
25
|
-
│ └── package.json
|
|
26
|
-
├── ui/
|
|
27
|
-
│ └── package.json
|
|
28
|
-
└── utils/
|
|
29
|
-
└── package.json
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
### 1. Define Catalogs in Root package.json
|
|
33
|
-
|
|
34
|
-
In your root-level `package.json`, add a `catalog` or `catalogs` field within the `workspaces` object:
|
|
35
|
-
|
|
36
|
-
```json
|
|
37
|
-
{
|
|
38
|
-
"name": "my-monorepo",
|
|
39
|
-
"workspaces": {
|
|
40
|
-
"packages": ["packages/*"],
|
|
41
|
-
"catalog": {
|
|
42
|
-
"react": "^19.0.0",
|
|
43
|
-
"react-dom": "^19.0.0"
|
|
44
|
-
},
|
|
45
|
-
"catalogs": {
|
|
46
|
-
"testing": {
|
|
47
|
-
"jest": "30.0.0",
|
|
48
|
-
"testing-library": "14.0.0"
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
If you put `catalog` or `catalogs` at the top level of the `package.json` file, that will work too.
|
|
56
|
-
|
|
57
|
-
### 2. Reference Catalog Versions in Workspace Packages
|
|
58
|
-
|
|
59
|
-
In your workspace packages, use the `catalog:` protocol to reference versions:
|
|
60
|
-
|
|
61
|
-
**packages/app/package.json**
|
|
62
|
-
|
|
63
|
-
```json
|
|
64
|
-
{
|
|
65
|
-
"name": "app",
|
|
66
|
-
"dependencies": {
|
|
67
|
-
"react": "catalog:",
|
|
68
|
-
"react-dom": "catalog:",
|
|
69
|
-
"jest": "catalog:testing"
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
**packages/ui/package.json**
|
|
75
|
-
|
|
76
|
-
```json
|
|
77
|
-
{
|
|
78
|
-
"name": "ui",
|
|
79
|
-
"dependencies": {
|
|
80
|
-
"react": "catalog:",
|
|
81
|
-
"react-dom": "catalog:"
|
|
82
|
-
},
|
|
83
|
-
"devDependencies": {
|
|
84
|
-
"jest": "catalog:testing",
|
|
85
|
-
"testing-library": "catalog:testing"
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### 3. Run Bun Install
|
|
91
|
-
|
|
92
|
-
Run `bun install` to install all dependencies according to the catalog versions.
|
|
93
|
-
|
|
94
|
-
## Catalog vs Catalogs
|
|
95
|
-
|
|
96
|
-
Bun supports two ways to define catalogs:
|
|
97
|
-
|
|
98
|
-
1. **`catalog`** (singular): A single default catalog for commonly used dependencies
|
|
99
|
-
|
|
100
|
-
```json
|
|
101
|
-
"catalog": {
|
|
102
|
-
"react": "^19.0.0",
|
|
103
|
-
"react-dom": "^19.0.0"
|
|
104
|
-
}
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
Reference with simply `catalog:`:
|
|
108
|
-
|
|
109
|
-
```json
|
|
110
|
-
"dependencies": {
|
|
111
|
-
"react": "catalog:"
|
|
112
|
-
}
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
2. **`catalogs`** (plural): Multiple named catalogs for grouping dependencies
|
|
116
|
-
|
|
117
|
-
```json
|
|
118
|
-
"catalogs": {
|
|
119
|
-
"testing": {
|
|
120
|
-
"jest": "30.0.0"
|
|
121
|
-
},
|
|
122
|
-
"ui": {
|
|
123
|
-
"tailwind": "4.0.0"
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
Reference with `catalog:<name>`:
|
|
129
|
-
|
|
130
|
-
```json
|
|
131
|
-
"dependencies": {
|
|
132
|
-
"jest": "catalog:testing",
|
|
133
|
-
"tailwind": "catalog:ui"
|
|
134
|
-
}
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
## Benefits of Using Catalogs
|
|
138
|
-
|
|
139
|
-
- **Consistency**: Ensures all packages use the same version of critical dependencies
|
|
140
|
-
- **Maintenance**: Update a dependency version in one place instead of across multiple package.json files
|
|
141
|
-
- **Clarity**: Makes it obvious which dependencies are standardized across your monorepo
|
|
142
|
-
- **Simplicity**: No need for complex version resolution strategies or external tools
|
|
143
|
-
|
|
144
|
-
## Real-World Example
|
|
145
|
-
|
|
146
|
-
Here's a more comprehensive example for a React application:
|
|
147
|
-
|
|
148
|
-
**Root package.json**
|
|
149
|
-
|
|
150
|
-
```json
|
|
151
|
-
{
|
|
152
|
-
"name": "react-monorepo",
|
|
153
|
-
"workspaces": {
|
|
154
|
-
"packages": ["packages/*"],
|
|
155
|
-
"catalog": {
|
|
156
|
-
"react": "^19.0.0",
|
|
157
|
-
"react-dom": "^19.0.0",
|
|
158
|
-
"react-router-dom": "^6.15.0"
|
|
159
|
-
},
|
|
160
|
-
"catalogs": {
|
|
161
|
-
"build": {
|
|
162
|
-
"webpack": "5.88.2",
|
|
163
|
-
"babel": "7.22.10"
|
|
164
|
-
},
|
|
165
|
-
"testing": {
|
|
166
|
-
"jest": "29.6.2",
|
|
167
|
-
"react-testing-library": "14.0.0"
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
"devDependencies": {
|
|
172
|
-
"typescript": "5.1.6"
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
**packages/app/package.json**
|
|
178
|
-
|
|
179
|
-
```json
|
|
180
|
-
{
|
|
181
|
-
"name": "app",
|
|
182
|
-
"dependencies": {
|
|
183
|
-
"react": "catalog:",
|
|
184
|
-
"react-dom": "catalog:",
|
|
185
|
-
"react-router-dom": "catalog:",
|
|
186
|
-
"@monorepo/ui": "workspace:*",
|
|
187
|
-
"@monorepo/utils": "workspace:*"
|
|
188
|
-
},
|
|
189
|
-
"devDependencies": {
|
|
190
|
-
"webpack": "catalog:build",
|
|
191
|
-
"babel": "catalog:build",
|
|
192
|
-
"jest": "catalog:testing",
|
|
193
|
-
"react-testing-library": "catalog:testing"
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
**packages/ui/package.json**
|
|
199
|
-
|
|
200
|
-
```json
|
|
201
|
-
{
|
|
202
|
-
"name": "@monorepo/ui",
|
|
203
|
-
"dependencies": {
|
|
204
|
-
"react": "catalog:",
|
|
205
|
-
"react-dom": "catalog:"
|
|
206
|
-
},
|
|
207
|
-
"devDependencies": {
|
|
208
|
-
"jest": "catalog:testing",
|
|
209
|
-
"react-testing-library": "catalog:testing"
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
**packages/utils/package.json**
|
|
215
|
-
|
|
216
|
-
```json
|
|
217
|
-
{
|
|
218
|
-
"name": "@monorepo/utils",
|
|
219
|
-
"dependencies": {
|
|
220
|
-
"react": "catalog:"
|
|
221
|
-
},
|
|
222
|
-
"devDependencies": {
|
|
223
|
-
"jest": "catalog:testing"
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
## Updating Versions
|
|
229
|
-
|
|
230
|
-
To update versions across all packages, simply change the version in the root package.json:
|
|
231
|
-
|
|
232
|
-
```json
|
|
233
|
-
"catalog": {
|
|
234
|
-
"react": "^19.1.0", // Updated from ^19.0.0
|
|
235
|
-
"react-dom": "^19.1.0" // Updated from ^19.0.0
|
|
236
|
-
}
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
Then run `bun install` to update all packages.
|
|
240
|
-
|
|
241
|
-
## Lockfile Integration
|
|
242
|
-
|
|
243
|
-
Bun's lockfile tracks catalog versions, making it easy to ensure consistent installations across different environments. The lockfile includes:
|
|
244
|
-
|
|
245
|
-
- The catalog definitions from your package.json
|
|
246
|
-
- The resolution of each cataloged dependency
|
|
247
|
-
|
|
248
|
-
```
|
|
249
|
-
// bun.lock (excerpt)
|
|
250
|
-
{
|
|
251
|
-
"lockfileVersion": 1,
|
|
252
|
-
"workspaces": {
|
|
253
|
-
"": {
|
|
254
|
-
"name": "react-monorepo",
|
|
255
|
-
},
|
|
256
|
-
"packages/app": {
|
|
257
|
-
"name": "app",
|
|
258
|
-
"dependencies": {
|
|
259
|
-
"react": "catalog:",
|
|
260
|
-
"react-dom": "catalog:",
|
|
261
|
-
...
|
|
262
|
-
},
|
|
263
|
-
},
|
|
264
|
-
...
|
|
265
|
-
},
|
|
266
|
-
"catalog": {
|
|
267
|
-
"react": "^19.0.0",
|
|
268
|
-
"react-dom": "^19.0.0",
|
|
269
|
-
...
|
|
270
|
-
},
|
|
271
|
-
"catalogs": {
|
|
272
|
-
"build": {
|
|
273
|
-
"webpack": "5.88.2",
|
|
274
|
-
...
|
|
275
|
-
},
|
|
276
|
-
...
|
|
277
|
-
},
|
|
278
|
-
"packages": {
|
|
279
|
-
...
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
## Limitations and Edge Cases
|
|
285
|
-
|
|
286
|
-
- Catalog references must match a dependency defined in either `catalog` or one of the named `catalogs`
|
|
287
|
-
- Empty strings and whitespace in catalog names are ignored (treated as default catalog)
|
|
288
|
-
- Invalid dependency versions in catalogs will fail to resolve during `bun install`
|
|
289
|
-
- Catalogs are only available within workspaces; they cannot be used outside the monorepo
|
|
290
|
-
|
|
291
|
-
Bun's catalog system provides a powerful yet simple way to maintain consistency across your monorepo without introducing additional complexity to your workflow.
|
|
292
|
-
|
|
293
|
-
## Publishing
|
|
294
|
-
|
|
295
|
-
When you run `bun publish` or `bun pm pack`, Bun automatically replaces
|
|
296
|
-
`catalog:` references in your `package.json` with the resolved version numbers.
|
|
297
|
-
The published package includes regular semver strings and no longer depends on
|
|
298
|
-
your catalog definitions.
|