bun-types 1.3.2-canary.20251106T140813 → 1.3.2
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 +102 -6
- package/docs/bundler/bytecode.mdx +465 -0
- package/docs/bundler/css.mdx +1024 -0
- package/docs/bundler/esbuild.mdx +253 -0
- package/docs/bundler/executables.mdx +535 -0
- package/docs/bundler/fullstack.mdx +1064 -0
- package/docs/bundler/hot-reloading.mdx +229 -0
- package/docs/bundler/html-static.mdx +386 -0
- package/docs/bundler/index.mdx +1499 -0
- package/docs/bundler/loaders.mdx +356 -0
- package/docs/bundler/macros.mdx +328 -0
- package/docs/bundler/minifier.mdx +1306 -0
- package/docs/bundler/plugins.mdx +411 -0
- package/docs/feedback.mdx +85 -0
- package/docs/guides/binary/arraybuffer-to-array.mdx +29 -0
- package/docs/guides/binary/arraybuffer-to-blob.mdx +26 -0
- package/docs/guides/binary/arraybuffer-to-buffer.mdx +27 -0
- package/docs/guides/binary/arraybuffer-to-string.mdx +17 -0
- package/docs/guides/binary/arraybuffer-to-typedarray.mdx +41 -0
- package/docs/guides/binary/blob-to-arraybuffer.mdx +16 -0
- package/docs/guides/binary/blob-to-dataview.mdx +16 -0
- package/docs/guides/binary/blob-to-stream.mdx +16 -0
- package/docs/guides/binary/blob-to-string.mdx +17 -0
- package/docs/guides/binary/blob-to-typedarray.mdx +16 -0
- package/docs/guides/binary/buffer-to-arraybuffer.mdx +16 -0
- package/docs/guides/binary/buffer-to-blob.mdx +16 -0
- package/docs/guides/binary/buffer-to-readablestream.mdx +43 -0
- package/docs/guides/binary/buffer-to-string.mdx +27 -0
- package/docs/guides/binary/buffer-to-typedarray.mdx +16 -0
- package/docs/guides/binary/dataview-to-string.mdx +17 -0
- package/docs/guides/binary/typedarray-to-arraybuffer.mdx +27 -0
- package/docs/guides/binary/typedarray-to-blob.mdx +18 -0
- package/docs/guides/binary/typedarray-to-buffer.mdx +16 -0
- package/docs/guides/binary/typedarray-to-dataview.mdx +16 -0
- package/docs/guides/binary/typedarray-to-readablestream.mdx +43 -0
- package/docs/guides/binary/typedarray-to-string.mdx +18 -0
- package/docs/guides/deployment/aws-lambda.mdx +204 -0
- package/docs/guides/deployment/digital-ocean.mdx +161 -0
- package/docs/guides/deployment/google-cloud-run.mdx +197 -0
- package/docs/guides/deployment/railway.mdx +145 -0
- package/docs/guides/deployment/render.mdx +82 -0
- package/docs/guides/deployment/vercel.mdx +99 -0
- package/docs/guides/ecosystem/astro.mdx +82 -0
- package/docs/guides/ecosystem/discordjs.mdx +80 -0
- package/docs/guides/ecosystem/docker.mdx +151 -0
- package/docs/guides/ecosystem/drizzle.mdx +195 -0
- package/docs/guides/ecosystem/edgedb.mdx +257 -0
- package/docs/guides/ecosystem/elysia.mdx +31 -0
- package/docs/guides/ecosystem/express.mdx +43 -0
- package/docs/guides/ecosystem/hono.mdx +47 -0
- package/docs/guides/ecosystem/mongoose.mdx +92 -0
- package/docs/guides/ecosystem/neon-drizzle.mdx +234 -0
- package/docs/guides/ecosystem/neon-serverless-postgres.mdx +60 -0
- package/docs/guides/ecosystem/nextjs.mdx +57 -0
- package/docs/guides/ecosystem/nuxt.mdx +90 -0
- package/docs/guides/ecosystem/pm2.mdx +55 -0
- package/docs/guides/ecosystem/prisma-postgres.mdx +169 -0
- package/docs/guides/ecosystem/prisma.mdx +164 -0
- package/docs/guides/ecosystem/qwik.mdx +114 -0
- package/docs/guides/ecosystem/react.mdx +52 -0
- package/docs/guides/ecosystem/remix.mdx +97 -0
- package/docs/guides/ecosystem/sentry.mdx +54 -0
- package/docs/guides/ecosystem/solidstart.mdx +66 -0
- package/docs/guides/ecosystem/ssr-react.mdx +49 -0
- package/docs/guides/ecosystem/stric.mdx +54 -0
- package/docs/guides/ecosystem/sveltekit.mdx +138 -0
- package/docs/guides/ecosystem/systemd.mdx +114 -0
- package/docs/guides/ecosystem/upstash.mdx +87 -0
- package/docs/guides/ecosystem/vite.mdx +77 -0
- package/docs/guides/html-rewriter/extract-links.mdx +72 -0
- package/docs/guides/html-rewriter/extract-social-meta.mdx +97 -0
- package/docs/guides/http/cluster.mdx +69 -0
- package/docs/guides/http/fetch-unix.mdx +35 -0
- package/docs/guides/http/fetch.mdx +26 -0
- package/docs/guides/http/file-uploads.mdx +97 -0
- package/docs/guides/http/hot.mdx +28 -0
- package/docs/guides/http/proxy.mdx +26 -0
- package/docs/guides/http/server.mdx +48 -0
- package/docs/guides/http/simple.mdx +20 -0
- package/docs/guides/http/stream-file.mdx +50 -0
- package/docs/guides/http/stream-iterator.mdx +49 -0
- package/docs/guides/http/stream-node-streams-in-bun.mdx +22 -0
- package/docs/guides/http/tls.mdx +32 -0
- package/docs/guides/index.mdx +10 -0
- package/docs/guides/install/add-dev.mdx +28 -0
- package/docs/guides/install/add-git.mdx +38 -0
- package/docs/guides/install/add-optional.mdx +27 -0
- package/docs/guides/install/add-peer.mdx +45 -0
- package/docs/guides/install/add-tarball.mdx +35 -0
- package/docs/guides/install/add.mdx +44 -0
- package/docs/guides/install/azure-artifacts.mdx +76 -0
- package/docs/guides/install/cicd.mdx +43 -0
- package/docs/guides/install/custom-registry.mdx +32 -0
- package/docs/guides/install/from-npm-install-to-bun-install.mdx +230 -0
- package/docs/guides/install/git-diff-bun-lockfile.mdx +47 -0
- package/docs/guides/install/jfrog-artifactory.mdx +28 -0
- package/docs/guides/install/npm-alias.mdx +25 -0
- package/docs/guides/install/registry-scope.mdx +40 -0
- package/docs/guides/install/trusted.mdx +50 -0
- package/docs/guides/install/workspaces.mdx +70 -0
- package/docs/guides/install/yarnlock.mdx +50 -0
- package/docs/guides/process/argv.mdx +66 -0
- package/docs/guides/process/ctrl-c.mdx +18 -0
- package/docs/guides/process/ipc.mdx +69 -0
- package/docs/guides/process/nanoseconds.mdx +15 -0
- package/docs/guides/process/os-signals.mdx +41 -0
- package/docs/guides/process/spawn-stderr.mdx +34 -0
- package/docs/guides/process/spawn-stdout.mdx +28 -0
- package/docs/guides/process/spawn.mdx +43 -0
- package/docs/guides/process/stdin.mdx +62 -0
- package/docs/guides/read-file/arraybuffer.mdx +30 -0
- package/docs/guides/read-file/buffer.mdx +21 -0
- package/docs/guides/read-file/exists.mdx +18 -0
- package/docs/guides/read-file/json.mdx +19 -0
- package/docs/guides/read-file/mime.mdx +22 -0
- package/docs/guides/read-file/stream.mdx +28 -0
- package/docs/guides/read-file/string.mdx +24 -0
- package/docs/guides/read-file/uint8array.mdx +23 -0
- package/docs/guides/read-file/watch.mdx +66 -0
- package/docs/guides/runtime/build-time-constants.mdx +295 -0
- package/docs/guides/runtime/cicd.mdx +45 -0
- package/docs/guides/runtime/codesign-macos-executable.mdx +61 -0
- package/docs/guides/runtime/define-constant.mdx +149 -0
- package/docs/guides/runtime/delete-directory.mdx +39 -0
- package/docs/guides/runtime/delete-file.mdx +21 -0
- package/docs/guides/runtime/heap-snapshot.mdx +28 -0
- package/docs/guides/runtime/import-html.mdx +17 -0
- package/docs/guides/runtime/import-json.mdx +46 -0
- package/docs/guides/runtime/import-toml.mdx +32 -0
- package/docs/guides/runtime/import-yaml.mdx +104 -0
- package/docs/guides/runtime/read-env.mdx +37 -0
- package/docs/guides/runtime/set-env.mdx +51 -0
- package/docs/guides/runtime/shell.mdx +42 -0
- package/docs/guides/runtime/timezone.mdx +38 -0
- package/docs/guides/runtime/tsconfig-paths.mdx +31 -0
- package/docs/guides/runtime/typescript.mdx +51 -0
- package/docs/guides/runtime/vscode-debugger.mdx +48 -0
- package/docs/guides/runtime/web-debugger.mdx +103 -0
- package/docs/guides/streams/node-readable-to-arraybuffer.mdx +13 -0
- package/docs/guides/streams/node-readable-to-blob.mdx +13 -0
- package/docs/guides/streams/node-readable-to-json.mdx +14 -0
- package/docs/guides/streams/node-readable-to-string.mdx +14 -0
- package/docs/guides/streams/node-readable-to-uint8array.mdx +13 -0
- package/docs/guides/streams/to-array.mdx +16 -0
- package/docs/guides/streams/to-arraybuffer.mdx +16 -0
- package/docs/guides/streams/to-blob.mdx +16 -0
- package/docs/guides/streams/to-buffer.mdx +17 -0
- package/docs/guides/streams/to-json.mdx +16 -0
- package/docs/guides/streams/to-string.mdx +16 -0
- package/docs/guides/streams/to-typedarray.mdx +24 -0
- package/docs/guides/test/bail.mdx +24 -0
- package/docs/guides/test/coverage-threshold.mdx +67 -0
- package/docs/guides/test/coverage.mdx +49 -0
- package/docs/guides/test/happy-dom.mdx +73 -0
- package/docs/guides/test/migrate-from-jest.mdx +125 -0
- package/docs/guides/test/mock-clock.mdx +50 -0
- package/docs/guides/test/mock-functions.mdx +70 -0
- package/docs/guides/test/rerun-each.mdx +16 -0
- package/docs/guides/test/run-tests.mdx +116 -0
- package/docs/guides/test/skip-tests.mdx +43 -0
- package/docs/guides/test/snapshot.mdx +102 -0
- package/docs/guides/test/spy-on.mdx +49 -0
- package/docs/guides/test/svelte-test.mdx +113 -0
- package/docs/guides/test/testing-library.mdx +93 -0
- package/docs/guides/test/timeout.mdx +17 -0
- package/docs/guides/test/todo-tests.mdx +74 -0
- package/docs/guides/test/update-snapshots.mdx +49 -0
- package/docs/guides/test/watch-mode.mdx +24 -0
- package/docs/guides/util/base64.mdx +17 -0
- package/docs/guides/util/deep-equals.mdx +41 -0
- package/docs/guides/util/deflate.mdx +20 -0
- package/docs/guides/util/detect-bun.mdx +25 -0
- package/docs/guides/util/entrypoint.mdx +19 -0
- package/docs/guides/util/escape-html.mdx +24 -0
- package/docs/guides/util/file-url-to-path.mdx +16 -0
- package/docs/guides/util/gzip.mdx +20 -0
- package/docs/guides/util/hash-a-password.mdx +56 -0
- package/docs/guides/util/import-meta-dir.mdx +15 -0
- package/docs/guides/util/import-meta-file.mdx +15 -0
- package/docs/guides/util/import-meta-path.mdx +15 -0
- package/docs/guides/util/javascript-uuid.mdx +25 -0
- package/docs/guides/util/main.mdx +43 -0
- package/docs/guides/util/path-to-file-url.mdx +16 -0
- package/docs/guides/util/sleep.mdx +24 -0
- package/docs/guides/util/version.mdx +23 -0
- package/docs/guides/util/which-path-to-executable-bin.mdx +17 -0
- package/docs/guides/websocket/compression.mdx +33 -0
- package/docs/guides/websocket/context.mdx +74 -0
- package/docs/guides/websocket/pubsub.mdx +40 -0
- package/docs/guides/websocket/simple.mdx +35 -0
- package/docs/guides/write-file/append.mdx +54 -0
- package/docs/guides/write-file/basic.mdx +46 -0
- package/docs/guides/write-file/blob.mdx +30 -0
- package/docs/guides/write-file/cat.mdx +19 -0
- package/docs/guides/write-file/file-cp.mdx +18 -0
- package/docs/guides/write-file/filesink.mdx +54 -0
- package/docs/guides/write-file/response.mdx +19 -0
- package/docs/guides/write-file/stdout.mdx +23 -0
- package/docs/guides/write-file/stream.mdx +19 -0
- package/docs/guides/write-file/unlink.mdx +18 -0
- package/docs/index.mdx +133 -0
- package/docs/installation.mdx +365 -0
- package/docs/pm/bunx.mdx +83 -0
- package/docs/pm/catalogs.mdx +292 -0
- package/docs/pm/cli/add.mdx +179 -0
- package/docs/pm/cli/audit.mdx +60 -0
- package/docs/pm/cli/install.mdx +471 -0
- package/docs/pm/cli/link.mdx +48 -0
- package/docs/pm/cli/outdated.mdx +197 -0
- package/docs/pm/cli/patch.mdx +69 -0
- package/docs/pm/cli/pm.mdx +319 -0
- package/docs/pm/cli/publish.mdx +123 -0
- package/docs/pm/cli/remove.mdx +16 -0
- package/docs/pm/cli/update.mdx +140 -0
- package/docs/pm/cli/why.mdx +84 -0
- package/docs/pm/filter.mdx +102 -0
- package/docs/pm/global-cache.mdx +72 -0
- package/docs/pm/isolated-installs.mdx +205 -0
- package/docs/pm/lifecycle.mdx +57 -0
- package/docs/pm/lockfile.mdx +64 -0
- package/docs/pm/npmrc.mdx +111 -0
- package/docs/pm/overrides.mdx +83 -0
- package/docs/pm/scopes-registries.mdx +35 -0
- package/docs/pm/security-scanner-api.mdx +95 -0
- package/docs/pm/workspaces.mdx +109 -0
- package/docs/project/benchmarking.mdx +218 -0
- package/docs/project/bindgen.mdx +223 -0
- package/docs/project/building-windows.mdx +133 -0
- package/docs/project/contributing.mdx +343 -0
- package/docs/project/feedback.mdx +20 -0
- package/docs/project/license.mdx +78 -0
- package/docs/project/roadmap.mdx +8 -0
- package/docs/quickstart.mdx +240 -0
- package/docs/runtime/auto-install.mdx +97 -0
- package/docs/runtime/binary-data.mdx +846 -0
- package/docs/runtime/bun-apis.mdx +59 -0
- package/docs/runtime/bunfig.mdx +642 -0
- package/docs/runtime/c-compiler.mdx +204 -0
- package/docs/runtime/child-process.mdx +532 -0
- package/docs/runtime/color.mdx +267 -0
- package/docs/runtime/console.mdx +67 -0
- package/docs/runtime/cookies.mdx +454 -0
- package/docs/runtime/debugger.mdx +335 -0
- package/docs/runtime/environment-variables.mdx +214 -0
- package/docs/runtime/ffi.mdx +565 -0
- package/docs/runtime/file-io.mdx +306 -0
- package/docs/runtime/file-system-router.mdx +118 -0
- package/docs/runtime/file-types.mdx +354 -0
- package/docs/runtime/glob.mdx +181 -0
- package/docs/runtime/globals.mdx +72 -0
- package/docs/runtime/hashing.mdx +315 -0
- package/docs/runtime/html-rewriter.mdx +340 -0
- package/docs/runtime/http/cookies.mdx +79 -0
- package/docs/runtime/http/error-handling.mdx +40 -0
- package/docs/runtime/http/metrics.mdx +36 -0
- package/docs/runtime/http/routing.mdx +289 -0
- package/docs/runtime/http/server.mdx +647 -0
- package/docs/runtime/http/tls.mdx +101 -0
- package/docs/runtime/http/websockets.mdx +404 -0
- package/docs/runtime/index.mdx +223 -0
- package/docs/runtime/jsx.mdx +115 -0
- package/docs/runtime/module-resolution.mdx +342 -0
- package/docs/runtime/networking/dns.mdx +111 -0
- package/docs/runtime/networking/fetch.mdx +468 -0
- package/docs/runtime/networking/tcp.mdx +239 -0
- package/docs/runtime/networking/udp.mdx +129 -0
- package/docs/runtime/node-api.mdx +19 -0
- package/docs/runtime/nodejs-compat.mdx +468 -0
- package/docs/runtime/plugins.mdx +405 -0
- package/docs/runtime/redis.mdx +582 -0
- package/docs/runtime/s3.mdx +863 -0
- package/docs/runtime/secrets.mdx +336 -0
- package/docs/runtime/semver.mdx +57 -0
- package/docs/runtime/shell.mdx +637 -0
- package/docs/runtime/sql.mdx +1404 -0
- package/docs/runtime/sqlite.mdx +699 -0
- package/docs/runtime/streams.mdx +232 -0
- package/docs/runtime/templating/create.mdx +269 -0
- package/docs/runtime/templating/init.mdx +58 -0
- package/docs/runtime/transpiler.mdx +288 -0
- package/docs/runtime/typescript.mdx +58 -0
- package/docs/runtime/utils.mdx +922 -0
- package/docs/runtime/watch-mode.mdx +161 -0
- package/docs/runtime/web-apis.mdx +29 -0
- package/docs/runtime/workers.mdx +328 -0
- package/docs/runtime/yaml.mdx +469 -0
- package/docs/snippets/cli/add.mdx +166 -0
- package/docs/snippets/cli/build.mdx +196 -0
- package/docs/snippets/cli/feedback.mdx +17 -0
- package/docs/snippets/cli/init.mdx +84 -0
- package/docs/snippets/cli/install.mdx +173 -0
- package/docs/snippets/cli/link.mdx +163 -0
- package/docs/snippets/cli/outdated.mdx +140 -0
- package/docs/snippets/cli/patch.mdx +171 -0
- package/docs/snippets/cli/publish.mdx +198 -0
- package/docs/snippets/cli/remove.mdx +146 -0
- package/docs/snippets/cli/run.mdx +293 -0
- package/docs/snippets/cli/test.mdx +100 -0
- package/docs/snippets/cli/update.mdx +144 -0
- package/docs/snippets/product-card.mdx +32 -0
- package/docs/snippets/product-tiles.mdx +94 -0
- package/docs/test/code-coverage.mdx +409 -0
- package/docs/test/configuration.mdx +467 -0
- package/docs/test/dates-times.mdx +129 -0
- package/docs/test/discovery.mdx +90 -0
- package/docs/test/dom.mdx +226 -0
- package/docs/test/index.mdx +380 -0
- package/docs/test/lifecycle.mdx +348 -0
- package/docs/test/mocks.mdx +637 -0
- package/docs/test/reporters.mdx +117 -0
- package/docs/test/runtime-behavior.mdx +342 -0
- package/docs/test/snapshots.mdx +434 -0
- package/docs/test/writing-tests.mdx +635 -0
- package/docs/typescript.mdx +54 -0
- package/package.json +8 -6
- package/test.d.ts +2 -2
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Catalogs"
|
|
3
|
+
description: "Share common dependency versions across multiple packages in a monorepo"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
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.
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Unlike traditional dependency management where each workspace package needs to independently specify versions, catalogs let you:
|
|
11
|
+
|
|
12
|
+
1. Define version catalogs in the root package.json
|
|
13
|
+
2. Reference these versions with a simple `catalog:` protocol
|
|
14
|
+
3. Update all packages simultaneously by changing the version in just one place
|
|
15
|
+
|
|
16
|
+
This is especially useful in large monorepos where dozens of packages need to use the same version of key dependencies.
|
|
17
|
+
|
|
18
|
+
## How to Use Catalogs
|
|
19
|
+
|
|
20
|
+
### Directory Structure Example
|
|
21
|
+
|
|
22
|
+
Consider a monorepo with the following structure:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
my-monorepo/
|
|
26
|
+
├── package.json
|
|
27
|
+
├── bun.lock
|
|
28
|
+
└── packages/
|
|
29
|
+
├── app/
|
|
30
|
+
│ └── package.json
|
|
31
|
+
├── ui/
|
|
32
|
+
│ └── package.json
|
|
33
|
+
└── utils/
|
|
34
|
+
└── package.json
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 1. Define Catalogs in Root package.json
|
|
38
|
+
|
|
39
|
+
In your root-level `package.json`, add a `catalog` or `catalogs` field within the `workspaces` object:
|
|
40
|
+
|
|
41
|
+
```json package.json icon="file-json"
|
|
42
|
+
{
|
|
43
|
+
"name": "my-monorepo",
|
|
44
|
+
"workspaces": {
|
|
45
|
+
"packages": ["packages/*"],
|
|
46
|
+
"catalog": {
|
|
47
|
+
"react": "^19.0.0",
|
|
48
|
+
"react-dom": "^19.0.0"
|
|
49
|
+
},
|
|
50
|
+
"catalogs": {
|
|
51
|
+
"testing": {
|
|
52
|
+
"jest": "30.0.0",
|
|
53
|
+
"testing-library": "14.0.0"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
If you put `catalog` or `catalogs` at the top level of the `package.json` file, that will work too.
|
|
61
|
+
|
|
62
|
+
### 2. Reference Catalog Versions in Workspace Packages
|
|
63
|
+
|
|
64
|
+
In your workspace packages, use the `catalog:` protocol to reference versions:
|
|
65
|
+
|
|
66
|
+
```json packages/app/package.json icon="file-json"
|
|
67
|
+
{
|
|
68
|
+
"name": "app",
|
|
69
|
+
"dependencies": {
|
|
70
|
+
"react": "catalog:",
|
|
71
|
+
"react-dom": "catalog:",
|
|
72
|
+
"jest": "catalog:testing"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
```json packages/ui/package.json icon="file-json"
|
|
78
|
+
{
|
|
79
|
+
"name": "ui",
|
|
80
|
+
"dependencies": {
|
|
81
|
+
"react": "catalog:",
|
|
82
|
+
"react-dom": "catalog:"
|
|
83
|
+
},
|
|
84
|
+
"devDependencies": {
|
|
85
|
+
"jest": "catalog:testing",
|
|
86
|
+
"testing-library": "catalog:testing"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### 3. Run Bun Install
|
|
92
|
+
|
|
93
|
+
Run `bun install` to install all dependencies according to the catalog versions.
|
|
94
|
+
|
|
95
|
+
## Catalog vs Catalogs
|
|
96
|
+
|
|
97
|
+
Bun supports two ways to define catalogs:
|
|
98
|
+
|
|
99
|
+
1. **`catalog`** (singular): A single default catalog for commonly used dependencies
|
|
100
|
+
|
|
101
|
+
```json package.json icon="file-json"
|
|
102
|
+
"catalog": {
|
|
103
|
+
"react": "^19.0.0",
|
|
104
|
+
"react-dom": "^19.0.0"
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Reference with simply `catalog:`:
|
|
109
|
+
|
|
110
|
+
```json packages/app/package.json icon="file-json"
|
|
111
|
+
"dependencies": {
|
|
112
|
+
"react": "catalog:"
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
2. **`catalogs`** (plural): Multiple named catalogs for grouping dependencies
|
|
117
|
+
|
|
118
|
+
```json package.json icon="file-json"
|
|
119
|
+
"catalogs": {
|
|
120
|
+
"testing": {
|
|
121
|
+
"jest": "30.0.0"
|
|
122
|
+
},
|
|
123
|
+
"ui": {
|
|
124
|
+
"tailwind": "4.0.0"
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Reference with `catalog:<name>`:
|
|
130
|
+
|
|
131
|
+
```json packages/app/package.json icon="file-json"
|
|
132
|
+
"dependencies": {
|
|
133
|
+
"jest": "catalog:testing",
|
|
134
|
+
"tailwind": "catalog:ui"
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Benefits of Using Catalogs
|
|
139
|
+
|
|
140
|
+
- **Consistency**: Ensures all packages use the same version of critical dependencies
|
|
141
|
+
- **Maintenance**: Update a dependency version in one place instead of across multiple package.json files
|
|
142
|
+
- **Clarity**: Makes it obvious which dependencies are standardized across your monorepo
|
|
143
|
+
- **Simplicity**: No need for complex version resolution strategies or external tools
|
|
144
|
+
|
|
145
|
+
## Real-World Example
|
|
146
|
+
|
|
147
|
+
Here's a more comprehensive example for a React application:
|
|
148
|
+
|
|
149
|
+
**Root package.json**
|
|
150
|
+
|
|
151
|
+
```json package.json icon="file-json"
|
|
152
|
+
{
|
|
153
|
+
"name": "react-monorepo",
|
|
154
|
+
"workspaces": {
|
|
155
|
+
"packages": ["packages/*"],
|
|
156
|
+
"catalog": {
|
|
157
|
+
"react": "^19.0.0",
|
|
158
|
+
"react-dom": "^19.0.0",
|
|
159
|
+
"react-router-dom": "^6.15.0"
|
|
160
|
+
},
|
|
161
|
+
"catalogs": {
|
|
162
|
+
"build": {
|
|
163
|
+
"webpack": "5.88.2",
|
|
164
|
+
"babel": "7.22.10"
|
|
165
|
+
},
|
|
166
|
+
"testing": {
|
|
167
|
+
"jest": "29.6.2",
|
|
168
|
+
"react-testing-library": "14.0.0"
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
"devDependencies": {
|
|
173
|
+
"typescript": "5.1.6"
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
```json packages/app/package.json icon="file-json"
|
|
179
|
+
{
|
|
180
|
+
"name": "app",
|
|
181
|
+
"dependencies": {
|
|
182
|
+
"react": "catalog:",
|
|
183
|
+
"react-dom": "catalog:",
|
|
184
|
+
"react-router-dom": "catalog:",
|
|
185
|
+
"@monorepo/ui": "workspace:*",
|
|
186
|
+
"@monorepo/utils": "workspace:*"
|
|
187
|
+
},
|
|
188
|
+
"devDependencies": {
|
|
189
|
+
"webpack": "catalog:build",
|
|
190
|
+
"babel": "catalog:build",
|
|
191
|
+
"jest": "catalog:testing",
|
|
192
|
+
"react-testing-library": "catalog:testing"
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
```json packages/ui/package.json icon="file-json"
|
|
198
|
+
{
|
|
199
|
+
"name": "@monorepo/ui",
|
|
200
|
+
"dependencies": {
|
|
201
|
+
"react": "catalog:",
|
|
202
|
+
"react-dom": "catalog:"
|
|
203
|
+
},
|
|
204
|
+
"devDependencies": {
|
|
205
|
+
"jest": "catalog:testing",
|
|
206
|
+
"react-testing-library": "catalog:testing"
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
```json packages/utils/package.json icon="file-json"
|
|
212
|
+
{
|
|
213
|
+
"name": "@monorepo/utils",
|
|
214
|
+
"dependencies": {
|
|
215
|
+
"react": "catalog:"
|
|
216
|
+
},
|
|
217
|
+
"devDependencies": {
|
|
218
|
+
"jest": "catalog:testing"
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## Updating Versions
|
|
224
|
+
|
|
225
|
+
To update versions across all packages, simply change the version in the root package.json:
|
|
226
|
+
|
|
227
|
+
```json package.json icon="file-json"
|
|
228
|
+
"catalog": {
|
|
229
|
+
"react": "^19.1.0", // Updated from ^19.0.0
|
|
230
|
+
"react-dom": "^19.1.0" // Updated from ^19.0.0
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Then run `bun install` to update all packages.
|
|
235
|
+
|
|
236
|
+
## Lockfile Integration
|
|
237
|
+
|
|
238
|
+
Bun's lockfile tracks catalog versions, making it easy to ensure consistent installations across different environments. The lockfile includes:
|
|
239
|
+
|
|
240
|
+
- The catalog definitions from your package.json
|
|
241
|
+
- The resolution of each cataloged dependency
|
|
242
|
+
|
|
243
|
+
```json bun.lock(excerpt) icon="file-json"
|
|
244
|
+
{
|
|
245
|
+
"lockfileVersion": 1,
|
|
246
|
+
"workspaces": {
|
|
247
|
+
"": {
|
|
248
|
+
"name": "react-monorepo",
|
|
249
|
+
},
|
|
250
|
+
"packages/app": {
|
|
251
|
+
"name": "app",
|
|
252
|
+
"dependencies": {
|
|
253
|
+
"react": "catalog:",
|
|
254
|
+
"react-dom": "catalog:",
|
|
255
|
+
...
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
...
|
|
259
|
+
},
|
|
260
|
+
"catalog": {
|
|
261
|
+
"react": "^19.0.0",
|
|
262
|
+
"react-dom": "^19.0.0",
|
|
263
|
+
...
|
|
264
|
+
},
|
|
265
|
+
"catalogs": {
|
|
266
|
+
"build": {
|
|
267
|
+
"webpack": "5.88.2",
|
|
268
|
+
...
|
|
269
|
+
},
|
|
270
|
+
...
|
|
271
|
+
},
|
|
272
|
+
"packages": {
|
|
273
|
+
...
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
## Limitations and Edge Cases
|
|
279
|
+
|
|
280
|
+
- Catalog references must match a dependency defined in either `catalog` or one of the named `catalogs`
|
|
281
|
+
- Empty strings and whitespace in catalog names are ignored (treated as default catalog)
|
|
282
|
+
- Invalid dependency versions in catalogs will fail to resolve during `bun install`
|
|
283
|
+
- Catalogs are only available within workspaces; they cannot be used outside the monorepo
|
|
284
|
+
|
|
285
|
+
Bun's catalog system provides a powerful yet simple way to maintain consistency across your monorepo without introducing additional complexity to your workflow.
|
|
286
|
+
|
|
287
|
+
## Publishing
|
|
288
|
+
|
|
289
|
+
When you run `bun publish` or `bun pm pack`, Bun automatically replaces
|
|
290
|
+
`catalog:` references in your `package.json` with the resolved version numbers.
|
|
291
|
+
The published package includes regular semver strings and no longer depends on
|
|
292
|
+
your catalog definitions.
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "bun add"
|
|
3
|
+
description: "Add packages to your project with Bun's fast package manager"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import Add from "/snippets/cli/add.mdx";
|
|
7
|
+
|
|
8
|
+
To add a particular package:
|
|
9
|
+
|
|
10
|
+
```bash terminal icon="terminal"
|
|
11
|
+
bun add preact
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
To specify a version, version range, or tag:
|
|
15
|
+
|
|
16
|
+
```bash terminal icon="terminal"
|
|
17
|
+
bun add zod@3.20.0
|
|
18
|
+
bun add zod@^3.0.0
|
|
19
|
+
bun add zod@latest
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## `--dev`
|
|
23
|
+
|
|
24
|
+
<Note>**Alias** — `--development`, `-d`, `-D`</Note>
|
|
25
|
+
|
|
26
|
+
To add a package as a dev dependency (`"devDependencies"`):
|
|
27
|
+
|
|
28
|
+
```bash terminal icon="terminal"
|
|
29
|
+
bun add --dev @types/react
|
|
30
|
+
bun add -d @types/react
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## `--optional`
|
|
34
|
+
|
|
35
|
+
To add a package as an optional dependency (`"optionalDependencies"`):
|
|
36
|
+
|
|
37
|
+
```bash terminal icon="terminal"
|
|
38
|
+
bun add --optional lodash
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## `--peer`
|
|
42
|
+
|
|
43
|
+
To add a package as a peer dependency (`"peerDependencies"`):
|
|
44
|
+
|
|
45
|
+
```bash terminal icon="terminal"
|
|
46
|
+
bun add --peer @types/bun
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## `--exact`
|
|
50
|
+
|
|
51
|
+
<Note>**Alias** — `-E`</Note>
|
|
52
|
+
|
|
53
|
+
To add a package and pin to the resolved version, use `--exact`. This will resolve the version of the package and add it to your `package.json` with an exact version number instead of a version range.
|
|
54
|
+
|
|
55
|
+
```bash terminal icon="terminal"
|
|
56
|
+
bun add react --exact
|
|
57
|
+
bun add react -E
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
This will add the following to your `package.json`:
|
|
61
|
+
|
|
62
|
+
```json package.json icon="file-json"
|
|
63
|
+
{
|
|
64
|
+
"dependencies": {
|
|
65
|
+
// without --exact
|
|
66
|
+
"react": "^18.2.0", // this matches >= 18.2.0 < 19.0.0
|
|
67
|
+
|
|
68
|
+
// with --exact
|
|
69
|
+
"react": "18.2.0" // this matches only 18.2.0 exactly
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
To view a complete list of options for this command:
|
|
75
|
+
|
|
76
|
+
```bash terminal icon="terminal"
|
|
77
|
+
bun add --help
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## `--global`
|
|
81
|
+
|
|
82
|
+
<Note>
|
|
83
|
+
**Note** — This would not modify package.json of your current project folder. **Alias** - `bun add --global`, `bun add
|
|
84
|
+
-g`, `bun install --global` and `bun install -g`
|
|
85
|
+
</Note>
|
|
86
|
+
|
|
87
|
+
To install a package globally, use the `-g`/`--global` flag. This will not modify the `package.json` of your current project. Typically this is used for installing command-line tools.
|
|
88
|
+
|
|
89
|
+
```bash terminal icon="terminal"
|
|
90
|
+
bun add --global cowsay # or `bun add -g cowsay`
|
|
91
|
+
cowsay "Bun!"
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
```txt
|
|
95
|
+
______
|
|
96
|
+
< Bun! >
|
|
97
|
+
------
|
|
98
|
+
\ ^__^
|
|
99
|
+
\ (oo)\_______
|
|
100
|
+
(__)\ )\/\
|
|
101
|
+
||----w |
|
|
102
|
+
|| ||
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
<Accordion title="Configuring global installation behavior">
|
|
106
|
+
|
|
107
|
+
```toml bunfig.toml icon="settings"
|
|
108
|
+
[install]
|
|
109
|
+
# where `bun add --global` installs packages
|
|
110
|
+
globalDir = "~/.bun/install/global"
|
|
111
|
+
|
|
112
|
+
# where globally-installed package bins are linked
|
|
113
|
+
globalBinDir = "~/.bun/bin"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
</Accordion>
|
|
117
|
+
|
|
118
|
+
## Trusted dependencies
|
|
119
|
+
|
|
120
|
+
Unlike other npm clients, Bun does not execute arbitrary lifecycle scripts for installed dependencies, such as `postinstall`. These scripts represent a potential security risk, as they can execute arbitrary code on your machine.
|
|
121
|
+
|
|
122
|
+
To tell Bun to allow lifecycle scripts for a particular package, add the package to `trustedDependencies` in your package.json.
|
|
123
|
+
|
|
124
|
+
```json package.json icon="file-json"
|
|
125
|
+
{
|
|
126
|
+
"name": "my-app",
|
|
127
|
+
"version": "1.0.0",
|
|
128
|
+
"trustedDependencies": ["my-trusted-package"] // [!code ++]
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Bun reads this field and will run lifecycle scripts for `my-trusted-package`.
|
|
133
|
+
|
|
134
|
+
## Git dependencies
|
|
135
|
+
|
|
136
|
+
To add a dependency from a public or private git repository:
|
|
137
|
+
|
|
138
|
+
```bash terminal icon="terminal"
|
|
139
|
+
bun add git@github.com:moment/moment.git
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
<Note>
|
|
143
|
+
To install private repositories, your system needs the appropriate SSH credentials to access the repository.
|
|
144
|
+
</Note>
|
|
145
|
+
|
|
146
|
+
Bun supports a variety of protocols, including [`github`](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#github-urls), [`git`](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#git-urls-as-dependencies), `git+ssh`, `git+https`, and many more.
|
|
147
|
+
|
|
148
|
+
```json package.json icon="file-json"
|
|
149
|
+
{
|
|
150
|
+
"dependencies": {
|
|
151
|
+
"dayjs": "git+https://github.com/iamkun/dayjs.git",
|
|
152
|
+
"lodash": "git+ssh://github.com/lodash/lodash.git#4.17.21",
|
|
153
|
+
"moment": "git@github.com:moment/moment.git",
|
|
154
|
+
"zod": "github:colinhacks/zod"
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Tarball dependencies
|
|
160
|
+
|
|
161
|
+
A package name can correspond to a publicly hosted `.tgz` file. During installation, Bun will download and install the package from the specified tarball URL, rather than from the package registry.
|
|
162
|
+
|
|
163
|
+
```sh terminal icon="terminal"
|
|
164
|
+
bun add zod@https://registry.npmjs.org/zod/-/zod-3.21.4.tgz
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
This will add the following line to your `package.json`:
|
|
168
|
+
|
|
169
|
+
```json package.json icon="file-json"
|
|
170
|
+
{
|
|
171
|
+
"dependencies": {
|
|
172
|
+
"zod": "https://registry.npmjs.org/zod/-/zod-3.21.4.tgz"
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
<Add />
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "bun audit"
|
|
3
|
+
description: "Check your installed packages for known security vulnerabilities"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Run the command in a project with a `bun.lock` file:
|
|
7
|
+
|
|
8
|
+
```bash terminal icon="terminal"
|
|
9
|
+
bun audit
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
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.
|
|
13
|
+
|
|
14
|
+
If no vulnerabilities are found, the command prints:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
No vulnerabilities found
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
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:
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
3 vulnerabilities (1 high, 2 moderate)
|
|
24
|
+
To update all dependencies to the latest compatible versions:
|
|
25
|
+
bun update
|
|
26
|
+
To update all dependencies to the latest versions (including breaking changes):
|
|
27
|
+
bun update --latest
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Filtering options
|
|
31
|
+
|
|
32
|
+
**`--audit-level=<low|moderate|high|critical>`** - Only show vulnerabilities at this severity level or higher:
|
|
33
|
+
|
|
34
|
+
```bash terminal icon="terminal"
|
|
35
|
+
bun audit --audit-level=high
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**`--prod`** - Audit only production dependencies (excludes devDependencies):
|
|
39
|
+
|
|
40
|
+
```bash terminal icon="terminal"
|
|
41
|
+
bun audit --prod
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**`--ignore <CVE>`** - Ignore specific CVEs (can be used multiple times):
|
|
45
|
+
|
|
46
|
+
```bash terminal icon="terminal"
|
|
47
|
+
bun audit --ignore CVE-2022-25883 --ignore CVE-2023-26136
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### `--json`
|
|
51
|
+
|
|
52
|
+
Use the `--json` flag to print the raw JSON response from the registry instead of the formatted report:
|
|
53
|
+
|
|
54
|
+
```bash terminal icon="terminal"
|
|
55
|
+
bun audit --json
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Exit code
|
|
59
|
+
|
|
60
|
+
`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.
|