@depup/bun-types 1.3.11-depup.0
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/CLAUDE.md +105 -0
- package/README.md +25 -0
- package/bun.d.ts +8712 -0
- package/bun.ns.d.ts +5 -0
- package/bundle.d.ts +74 -0
- package/changes.json +5 -0
- package/deprecated.d.ts +184 -0
- package/devserver.d.ts +187 -0
- package/docs/README.md +28 -0
- package/docs/bundler/bytecode.mdx +447 -0
- package/docs/bundler/css.mdx +1024 -0
- package/docs/bundler/esbuild.mdx +304 -0
- package/docs/bundler/executables.mdx +1318 -0
- package/docs/bundler/fullstack.mdx +1086 -0
- package/docs/bundler/hot-reloading.mdx +229 -0
- package/docs/bundler/html-static.mdx +498 -0
- package/docs/bundler/index.mdx +1840 -0
- package/docs/bundler/loaders.mdx +451 -0
- package/docs/bundler/macros.mdx +328 -0
- package/docs/bundler/minifier.mdx +1286 -0
- package/docs/bundler/plugins.mdx +477 -0
- package/docs/bundler/standalone-html.mdx +314 -0
- package/docs/feedback.mdx +75 -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 +194 -0
- package/docs/guides/deployment/railway.mdx +145 -0
- package/docs/guides/deployment/render.mdx +82 -0
- package/docs/guides/deployment/vercel.mdx +97 -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/elysia.mdx +31 -0
- package/docs/guides/ecosystem/express.mdx +43 -0
- package/docs/guides/ecosystem/gel.mdx +261 -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 +103 -0
- package/docs/guides/ecosystem/nuxt.mdx +96 -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 +62 -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/tanstack-start.mdx +791 -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 +71 -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 +50 -0
- package/docs/guides/http/server.mdx +48 -0
- package/docs/guides/http/simple.mdx +20 -0
- package/docs/guides/http/sse.mdx +91 -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 +40 -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 +48 -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 +52 -0
- package/docs/guides/install/workspaces.mdx +70 -0
- package/docs/guides/install/yarnlock.mdx +51 -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 +31 -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 +15 -0
- package/docs/guides/runtime/import-json.mdx +46 -0
- package/docs/guides/runtime/import-json5.mdx +74 -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 +47 -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/concurrent-test-glob.mdx +146 -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 +28 -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/upgrade.mdx +93 -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 +79 -0
- package/docs/guides/websocket/pubsub.mdx +43 -0
- package/docs/guides/websocket/simple.mdx +38 -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 +372 -0
- package/docs/pm/bunx.mdx +91 -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/info.mdx +70 -0
- package/docs/pm/cli/install.mdx +591 -0
- package/docs/pm/cli/link.mdx +61 -0
- package/docs/pm/cli/outdated.mdx +197 -0
- package/docs/pm/cli/patch.mdx +69 -0
- package/docs/pm/cli/pm.mdx +323 -0
- package/docs/pm/cli/publish.mdx +131 -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 +127 -0
- package/docs/pm/global-cache.mdx +72 -0
- package/docs/pm/isolated-installs.mdx +220 -0
- package/docs/pm/lifecycle.mdx +64 -0
- package/docs/pm/lockfile.mdx +64 -0
- package/docs/pm/npmrc.mdx +245 -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 +115 -0
- package/docs/project/benchmarking.mdx +296 -0
- package/docs/project/bindgen.mdx +223 -0
- package/docs/project/building-windows.mdx +143 -0
- package/docs/project/contributing.mdx +366 -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 +251 -0
- package/docs/runtime/archive.mdx +452 -0
- package/docs/runtime/auto-install.mdx +97 -0
- package/docs/runtime/binary-data.mdx +846 -0
- package/docs/runtime/bun-apis.mdx +60 -0
- package/docs/runtime/bunfig.mdx +765 -0
- package/docs/runtime/c-compiler.mdx +204 -0
- package/docs/runtime/child-process.mdx +659 -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/cron.mdx +358 -0
- package/docs/runtime/csrf.mdx +171 -0
- package/docs/runtime/debugger.mdx +335 -0
- package/docs/runtime/environment-variables.mdx +231 -0
- package/docs/runtime/ffi.mdx +567 -0
- package/docs/runtime/file-io.mdx +306 -0
- package/docs/runtime/file-system-router.mdx +118 -0
- package/docs/runtime/file-types.mdx +482 -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 +333 -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 +672 -0
- package/docs/runtime/http/tls.mdx +101 -0
- package/docs/runtime/http/websockets.mdx +414 -0
- package/docs/runtime/index.mdx +223 -0
- package/docs/runtime/json5.mdx +271 -0
- package/docs/runtime/jsonl.mdx +188 -0
- package/docs/runtime/jsx.mdx +115 -0
- package/docs/runtime/markdown.mdx +381 -0
- package/docs/runtime/module-resolution.mdx +374 -0
- package/docs/runtime/networking/dns.mdx +111 -0
- package/docs/runtime/networking/fetch.mdx +484 -0
- package/docs/runtime/networking/tcp.mdx +239 -0
- package/docs/runtime/networking/udp.mdx +180 -0
- package/docs/runtime/node-api.mdx +19 -0
- package/docs/runtime/nodejs-compat.mdx +468 -0
- package/docs/runtime/plugins.mdx +419 -0
- package/docs/runtime/redis.mdx +583 -0
- package/docs/runtime/repl.mdx +176 -0
- package/docs/runtime/s3.mdx +881 -0
- package/docs/runtime/secrets.mdx +340 -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 +721 -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/toml.mdx +238 -0
- package/docs/runtime/transpiler.mdx +288 -0
- package/docs/runtime/typescript.mdx +58 -0
- package/docs/runtime/utils.mdx +1010 -0
- package/docs/runtime/watch-mode.mdx +161 -0
- package/docs/runtime/web-apis.mdx +29 -0
- package/docs/runtime/workers.mdx +314 -0
- package/docs/runtime/yaml.mdx +470 -0
- package/docs/snippets/cli/add.mdx +166 -0
- package/docs/snippets/cli/build.mdx +197 -0
- package/docs/snippets/cli/bunx.mdx +49 -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 +305 -0
- package/docs/snippets/cli/test.mdx +105 -0
- package/docs/snippets/cli/update.mdx +144 -0
- package/docs/test/code-coverage.mdx +409 -0
- package/docs/test/configuration.mdx +574 -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 +409 -0
- package/docs/test/lifecycle.mdx +366 -0
- package/docs/test/mocks.mdx +637 -0
- package/docs/test/reporters.mdx +126 -0
- package/docs/test/runtime-behavior.mdx +342 -0
- package/docs/test/snapshots.mdx +434 -0
- package/docs/test/writing-tests.mdx +672 -0
- package/docs/typescript.mdx +54 -0
- package/extensions.d.ts +40 -0
- package/fetch.d.ts +79 -0
- package/ffi.d.ts +1154 -0
- package/globals.d.ts +2067 -0
- package/html-rewriter.d.ts +186 -0
- package/index.d.ts +32 -0
- package/jsc.d.ts +233 -0
- package/jsx.d.ts +11 -0
- package/overrides.d.ts +376 -0
- package/package.json +53 -0
- package/redis.d.ts +3352 -0
- package/s3.d.ts +1354 -0
- package/security.d.ts +101 -0
- package/serve.d.ts +1296 -0
- package/shell.d.ts +380 -0
- package/sql.d.ts +887 -0
- package/sqlite.d.ts +1322 -0
- package/test-globals.d.ts +22 -0
- package/test.d.ts +2392 -0
- package/vendor/expect-type/branding.d.ts +283 -0
- package/vendor/expect-type/index.d.ts +1207 -0
- package/vendor/expect-type/messages.d.ts +395 -0
- package/vendor/expect-type/overloads.d.ts +669 -0
- package/vendor/expect-type/utils.d.ts +431 -0
- package/wasm.d.ts +193 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Scopes and registries"
|
|
3
|
+
description: "Configure private registries and scoped packages"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
The default registry is `registry.npmjs.org`. This can be globally configured in `bunfig.toml`:
|
|
7
|
+
|
|
8
|
+
```toml bunfig.toml icon="settings"
|
|
9
|
+
[install]
|
|
10
|
+
# set default registry as a string
|
|
11
|
+
registry = "https://registry.npmjs.org"
|
|
12
|
+
# set a token
|
|
13
|
+
registry = { url = "https://registry.npmjs.org", token = "123456" }
|
|
14
|
+
# set a username/password
|
|
15
|
+
registry = "https://username:password@registry.npmjs.org"
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
To configure a private registry scoped to a particular organization:
|
|
19
|
+
|
|
20
|
+
```toml bunfig.toml icon="settings"
|
|
21
|
+
[install.scopes]
|
|
22
|
+
# registry as string
|
|
23
|
+
"@myorg1" = "https://username:password@registry.myorg.com/"
|
|
24
|
+
|
|
25
|
+
# registry with username/password
|
|
26
|
+
# you can reference environment variables
|
|
27
|
+
"@myorg2" = { username = "myusername", password = "$NPM_PASS", url = "https://registry.myorg.com/" }
|
|
28
|
+
|
|
29
|
+
# registry with token
|
|
30
|
+
"@myorg3" = { token = "$npm_token", url = "https://registry.myorg.com/" }
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### `.npmrc`
|
|
34
|
+
|
|
35
|
+
Bun also reads `.npmrc` files, [learn more](/docs/pm/npmrc).
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Security Scanner API
|
|
3
|
+
description:
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Bun's package manager can scan packages for security vulnerabilities before installation, helping protect your applications from supply chain attacks and known vulnerabilities.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Quick Start
|
|
11
|
+
|
|
12
|
+
Configure a security scanner in your `bunfig.toml`:
|
|
13
|
+
|
|
14
|
+
```toml bunfig.toml icon="settings"
|
|
15
|
+
[install.security]
|
|
16
|
+
scanner = "@acme/bun-security-scanner"
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
When configured, Bun will:
|
|
20
|
+
|
|
21
|
+
- Scan all packages before installation
|
|
22
|
+
- Display security warnings and advisories
|
|
23
|
+
- Cancel installation if critical vulnerabilities are found
|
|
24
|
+
- Automatically disable auto-install for security
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## How It Works
|
|
29
|
+
|
|
30
|
+
Security scanners analyze packages during `bun install`, `bun add`, and other package operations. They can detect:
|
|
31
|
+
|
|
32
|
+
- Known security vulnerabilities (CVEs)
|
|
33
|
+
- Malicious packages
|
|
34
|
+
- License compliance issues
|
|
35
|
+
- ...and more!
|
|
36
|
+
|
|
37
|
+
### Security Levels
|
|
38
|
+
|
|
39
|
+
Scanners report issues at two severity levels:
|
|
40
|
+
|
|
41
|
+
- **`fatal`** - Installation stops immediately, exits with non-zero code
|
|
42
|
+
- **`warn`** - In interactive terminals, prompts to continue; in CI, exits immediately
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Using Pre-built Scanners
|
|
47
|
+
|
|
48
|
+
Many security companies publish Bun security scanners as npm packages that you can install and use immediately.
|
|
49
|
+
|
|
50
|
+
### Installing a Scanner
|
|
51
|
+
|
|
52
|
+
Install a security scanner from npm:
|
|
53
|
+
|
|
54
|
+
```bash terminal icon="terminal"
|
|
55
|
+
bun add -d @acme/bun-security-scanner
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
<Note>
|
|
59
|
+
Consult your security scanner's documentation for their specific package name and installation instructions. Most
|
|
60
|
+
scanners will be installed with `bun add`.
|
|
61
|
+
</Note>
|
|
62
|
+
|
|
63
|
+
### Configuring the Scanner
|
|
64
|
+
|
|
65
|
+
After installation, configure it in your `bunfig.toml`:
|
|
66
|
+
|
|
67
|
+
```toml bunfig.toml icon="settings"
|
|
68
|
+
[install.security]
|
|
69
|
+
scanner = "@acme/bun-security-scanner"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Enterprise Configuration
|
|
73
|
+
|
|
74
|
+
Some enterprise scanners might support authentication and/or configuration through environment variables:
|
|
75
|
+
|
|
76
|
+
```bash terminal icon="terminal"
|
|
77
|
+
# This might go in ~/.bashrc, for example
|
|
78
|
+
export SECURITY_API_KEY="your-api-key"
|
|
79
|
+
|
|
80
|
+
# The scanner will now use these credentials automatically
|
|
81
|
+
bun install
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Consult your security scanner's documentation to learn which environment variables to set and if any additional configuration is required.
|
|
85
|
+
|
|
86
|
+
### Authoring your own scanner
|
|
87
|
+
|
|
88
|
+
For a complete example with tests and CI setup, see the official template:
|
|
89
|
+
[github.com/oven-sh/security-scanner-template](https://github.com/oven-sh/security-scanner-template)
|
|
90
|
+
|
|
91
|
+
## Related
|
|
92
|
+
|
|
93
|
+
- [Configuration (bunfig.toml)](/docs/runtime/bunfig#install-security-scanner)
|
|
94
|
+
- [Package Manager](/docs/installation)
|
|
95
|
+
- [Security Scanner Template](https://github.com/oven-sh/security-scanner-template)
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Workspaces"
|
|
3
|
+
description: "Develop complex monorepos with multiple independent packages"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Bun supports [`workspaces`](https://docs.npmjs.com/cli/v9/using-npm/workspaces?v=true#description) in `package.json`. Workspaces make it easy to develop complex software as a _monorepo_ consisting of several independent packages.
|
|
7
|
+
|
|
8
|
+
It's common for a monorepo to have the following structure:
|
|
9
|
+
|
|
10
|
+
```txt File Tree icon="folder-tree"
|
|
11
|
+
<root>
|
|
12
|
+
├── README.md
|
|
13
|
+
├── bun.lock
|
|
14
|
+
├── package.json
|
|
15
|
+
├── tsconfig.json
|
|
16
|
+
└── packages
|
|
17
|
+
├── pkg-a
|
|
18
|
+
│ ├── index.ts
|
|
19
|
+
│ ├── package.json
|
|
20
|
+
│ └── tsconfig.json
|
|
21
|
+
├── pkg-b
|
|
22
|
+
│ ├── index.ts
|
|
23
|
+
│ ├── package.json
|
|
24
|
+
│ └── tsconfig.json
|
|
25
|
+
└── pkg-c
|
|
26
|
+
├── index.ts
|
|
27
|
+
├── package.json
|
|
28
|
+
└── tsconfig.json
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
In the root `package.json`, the `"workspaces"` key is used to indicate which subdirectories should be considered packages/workspaces within the monorepo. It's conventional to place all the workspace in a directory called `packages`.
|
|
32
|
+
|
|
33
|
+
```json package.json icon="file-json"
|
|
34
|
+
{
|
|
35
|
+
"name": "my-project",
|
|
36
|
+
"version": "1.0.0",
|
|
37
|
+
"workspaces": ["packages/*"],
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"example-package-in-monorepo": "workspace:*"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
<Note>
|
|
45
|
+
**Glob support** — Bun supports full glob syntax in `"workspaces"`, including negative patterns (e.g.
|
|
46
|
+
`!**/excluded/**`). See [here](/docs/runtime/glob#supported-glob-patterns) for a comprehensive list of supported syntax.
|
|
47
|
+
</Note>
|
|
48
|
+
|
|
49
|
+
```json package.json icon="file-json"
|
|
50
|
+
{
|
|
51
|
+
"name": "my-project",
|
|
52
|
+
"version": "1.0.0",
|
|
53
|
+
"workspaces": ["packages/**", "!packages/**/test/**", "!packages/**/template/**"]
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Each workspace has it's own `package.json`. When referencing other packages in the monorepo, semver or workspace protocols (e.g. `workspace:*`) can be used as the version field in your `package.json`.
|
|
58
|
+
|
|
59
|
+
```json packages/pkg-a/package.json icon="file-json"
|
|
60
|
+
{
|
|
61
|
+
"name": "pkg-a",
|
|
62
|
+
"version": "1.0.0",
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"pkg-b": "workspace:*"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`bun install` will install dependencies for all workspaces in the monorepo, de-duplicating packages if possible. If you only want to install dependencies for specific workspaces, you can use the `--filter` flag.
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Install dependencies for all workspaces starting with `pkg-` except for `pkg-c`
|
|
73
|
+
bun install --filter "pkg-*" --filter "!pkg-c"
|
|
74
|
+
|
|
75
|
+
# Paths can also be used. This is equivalent to the command above.
|
|
76
|
+
bun install --filter "./packages/pkg-*" --filter "!pkg-c" # or --filter "!./packages/pkg-c"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
When publishing, `workspace:` versions are replaced by the package's `package.json` version,
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
"workspace:*" -> "1.0.1"
|
|
83
|
+
"workspace:^" -> "^1.0.1"
|
|
84
|
+
"workspace:~" -> "~1.0.1"
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Setting a specific version takes precedence over the package's `package.json` version,
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
"workspace:1.0.2" -> "1.0.2" // Even if current version is 1.0.1
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Workspaces have a couple major benefits.
|
|
94
|
+
|
|
95
|
+
- **Code can be split into logical parts.** If one package relies on another, you can simply add it as a dependency in `package.json`. If package `b` depends on `a`, `bun install` will install your local `packages/a` directory into `node_modules` instead of downloading it from the npm registry.
|
|
96
|
+
- **Dependencies can be de-duplicated.** If `a` and `b` share a common dependency, it will be _hoisted_ to the root `node_modules` directory. This reduces redundant disk usage and minimizes "dependency hell" issues associated with having multiple versions of a package installed simultaneously.
|
|
97
|
+
- **Run scripts in multiple packages.** You can use the [`--filter` flag](/docs/pm/filter) to easily run `package.json` scripts in multiple packages in your workspace, , or `--workspaces` to run scripts across all workspaces.
|
|
98
|
+
|
|
99
|
+
## Share versions with Catalogs
|
|
100
|
+
|
|
101
|
+
When many packages need the same dependency versions, catalogs let you define
|
|
102
|
+
those versions once in the root `package.json` and reference them from your
|
|
103
|
+
workspaces using the `catalog:` protocol. Updating the catalog automatically
|
|
104
|
+
updates every package that references it. See
|
|
105
|
+
[Catalogs](/docs/pm/catalogs) for details.
|
|
106
|
+
|
|
107
|
+
<Note>
|
|
108
|
+
⚡️ **Speed** — Installs are fast, even for big monorepos. Bun installs the [Remix](https://github.com/remix-run/remix) monorepo in about `500ms` on Linux.
|
|
109
|
+
|
|
110
|
+
- 28x faster than `npm install`
|
|
111
|
+
- 12x faster than `yarn install` (v1)
|
|
112
|
+
- 8x faster than `pnpm install`
|
|
113
|
+
|
|
114
|
+
<Image src="https://user-images.githubusercontent.com/709451/212829600-77df9544-7c9f-4d8d-a984-b2cd0fd2aa52.png" />
|
|
115
|
+
</Note>
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Benchmarking
|
|
3
|
+
description: How to benchmark Bun
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Bun is designed for speed. Hot paths are extensively profiled and benchmarked. The source code for all of Bun's public benchmarks can be found in the [`/bench`](https://github.com/oven-sh/bun/tree/main/bench) directory of the Bun repo.
|
|
7
|
+
|
|
8
|
+
## Measuring time
|
|
9
|
+
|
|
10
|
+
To precisely measure time, Bun offers two runtime APIs functions:
|
|
11
|
+
|
|
12
|
+
1. The Web-standard [`performance.now()`](https://developer.mozilla.org/en-US/docs/Web/API/Performance/now) function
|
|
13
|
+
2. `Bun.nanoseconds()` which is similar to `performance.now()` except it returns the current time since the application started in nanoseconds. You can use `performance.timeOrigin` to convert this to a Unix timestamp.
|
|
14
|
+
|
|
15
|
+
## Benchmarking tools
|
|
16
|
+
|
|
17
|
+
When writing your own benchmarks, it's important to choose the right tool.
|
|
18
|
+
|
|
19
|
+
- For microbenchmarks, a great general-purpose tool is [`mitata`](https://github.com/evanwashere/mitata).
|
|
20
|
+
- For load testing, you _must use_ an HTTP benchmarking tool that is at least as fast as `Bun.serve()`, or your results will be skewed. Some popular Node.js-based benchmarking tools like [`autocannon`](https://github.com/mcollina/autocannon) are not fast enough. We recommend one of the following:
|
|
21
|
+
- [`bombardier`](https://github.com/codesenberg/bombardier)
|
|
22
|
+
- [`oha`](https://github.com/hatoo/oha)
|
|
23
|
+
- [`http_load_test`](https://github.com/uNetworking/uSockets/blob/master/examples/http_load_test.c)
|
|
24
|
+
- For benchmarking scripts or CLI commands, we recommend [`hyperfine`](https://github.com/sharkdp/hyperfine).
|
|
25
|
+
|
|
26
|
+
## Measuring memory usage
|
|
27
|
+
|
|
28
|
+
Bun has two heaps. One heap is for the JavaScript runtime and the other heap is for everything else.
|
|
29
|
+
|
|
30
|
+
### JavaScript heap stats
|
|
31
|
+
|
|
32
|
+
The `bun:jsc` module exposes a few functions for measuring memory usage:
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { heapStats } from "bun:jsc";
|
|
36
|
+
console.log(heapStats());
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
<Accordion title="View example statistics">
|
|
40
|
+
|
|
41
|
+
```ts expandable icon="/icons/typescript.svg"
|
|
42
|
+
{
|
|
43
|
+
heapSize: 1657575,
|
|
44
|
+
heapCapacity: 2872775,
|
|
45
|
+
extraMemorySize: 598199,
|
|
46
|
+
objectCount: 13790,
|
|
47
|
+
protectedObjectCount: 62,
|
|
48
|
+
globalObjectCount: 1,
|
|
49
|
+
protectedGlobalObjectCount: 1,
|
|
50
|
+
// A count of every object type in the heap
|
|
51
|
+
objectTypeCounts: {
|
|
52
|
+
CallbackObject: 25,
|
|
53
|
+
FunctionExecutable: 2078,
|
|
54
|
+
AsyncGeneratorFunction: 2,
|
|
55
|
+
'RegExp String Iterator': 1,
|
|
56
|
+
FunctionCodeBlock: 188,
|
|
57
|
+
ModuleProgramExecutable: 13,
|
|
58
|
+
String: 1,
|
|
59
|
+
UnlinkedModuleProgramCodeBlock: 13,
|
|
60
|
+
JSON: 1,
|
|
61
|
+
AsyncGenerator: 1,
|
|
62
|
+
Symbol: 1,
|
|
63
|
+
GetterSetter: 68,
|
|
64
|
+
ImportMeta: 10,
|
|
65
|
+
DOMAttributeGetterSetter: 1,
|
|
66
|
+
UnlinkedFunctionCodeBlock: 174,
|
|
67
|
+
RegExp: 52,
|
|
68
|
+
ModuleLoader: 1,
|
|
69
|
+
Intl: 1,
|
|
70
|
+
WeakMap: 4,
|
|
71
|
+
Generator: 2,
|
|
72
|
+
PropertyTable: 95,
|
|
73
|
+
'Array Iterator': 1,
|
|
74
|
+
JSLexicalEnvironment: 75,
|
|
75
|
+
UnlinkedFunctionExecutable: 2067,
|
|
76
|
+
WeakSet: 1,
|
|
77
|
+
console: 1,
|
|
78
|
+
Map: 23,
|
|
79
|
+
SparseArrayValueMap: 14,
|
|
80
|
+
StructureChain: 19,
|
|
81
|
+
Set: 18,
|
|
82
|
+
'String Iterator': 1,
|
|
83
|
+
FunctionRareData: 3,
|
|
84
|
+
JSGlobalLexicalEnvironment: 1,
|
|
85
|
+
Object: 481,
|
|
86
|
+
BigInt: 2,
|
|
87
|
+
StructureRareData: 55,
|
|
88
|
+
Array: 179,
|
|
89
|
+
AbortController: 2,
|
|
90
|
+
ModuleNamespaceObject: 11,
|
|
91
|
+
ShadowRealm: 1,
|
|
92
|
+
'Immutable Butterfly': 103,
|
|
93
|
+
Primordials: 1,
|
|
94
|
+
'Set Iterator': 1,
|
|
95
|
+
JSGlobalProxy: 1,
|
|
96
|
+
AsyncFromSyncIterator: 1,
|
|
97
|
+
ModuleRecord: 13,
|
|
98
|
+
FinalizationRegistry: 1,
|
|
99
|
+
AsyncIterator: 1,
|
|
100
|
+
InternalPromise: 22,
|
|
101
|
+
Iterator: 1,
|
|
102
|
+
CustomGetterSetter: 65,
|
|
103
|
+
Promise: 19,
|
|
104
|
+
WeakRef: 1,
|
|
105
|
+
InternalPromisePrototype: 1,
|
|
106
|
+
Function: 2381,
|
|
107
|
+
AsyncFunction: 2,
|
|
108
|
+
GlobalObject: 1,
|
|
109
|
+
ArrayBuffer: 2,
|
|
110
|
+
Boolean: 1,
|
|
111
|
+
Math: 1,
|
|
112
|
+
CallbackConstructor: 1,
|
|
113
|
+
Error: 2,
|
|
114
|
+
JSModuleEnvironment: 13,
|
|
115
|
+
WebAssembly: 1,
|
|
116
|
+
HashMapBucket: 300,
|
|
117
|
+
Callee: 3,
|
|
118
|
+
symbol: 37,
|
|
119
|
+
string: 2484,
|
|
120
|
+
Performance: 1,
|
|
121
|
+
ModuleProgramCodeBlock: 12,
|
|
122
|
+
JSSourceCode: 13,
|
|
123
|
+
JSPropertyNameEnumerator: 3,
|
|
124
|
+
NativeExecutable: 290,
|
|
125
|
+
Number: 1,
|
|
126
|
+
Structure: 1550,
|
|
127
|
+
SymbolTable: 108,
|
|
128
|
+
GeneratorFunction: 2,
|
|
129
|
+
'Map Iterator': 1
|
|
130
|
+
},
|
|
131
|
+
protectedObjectTypeCounts: {
|
|
132
|
+
CallbackConstructor: 1,
|
|
133
|
+
BigInt: 1,
|
|
134
|
+
RegExp: 2,
|
|
135
|
+
GlobalObject: 1,
|
|
136
|
+
UnlinkedModuleProgramCodeBlock: 13,
|
|
137
|
+
HashMapBucket: 2,
|
|
138
|
+
Structure: 41,
|
|
139
|
+
JSPropertyNameEnumerator: 1
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
</Accordion>
|
|
145
|
+
|
|
146
|
+
JavaScript is a garbage-collected language, not reference counted. It's normal and correct for objects to not be freed immediately in all cases, though it's not normal for objects to never be freed.
|
|
147
|
+
|
|
148
|
+
To force garbage collection to run manually:
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
Bun.gc(true); // synchronous
|
|
152
|
+
Bun.gc(false); // asynchronous
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Heap snapshots let you inspect what objects are not being freed. You can use the `bun:jsc` module to take a heap snapshot and then view it with Safari or WebKit GTK developer tools. To generate a heap snapshot:
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
import { generateHeapSnapshot } from "bun";
|
|
159
|
+
|
|
160
|
+
const snapshot = generateHeapSnapshot();
|
|
161
|
+
await Bun.write("heap.json", JSON.stringify(snapshot, null, 2));
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
To view the snapshot, open the `heap.json` file in Safari's Developer Tools (or WebKit GTK)
|
|
165
|
+
|
|
166
|
+
1. Open the Developer Tools
|
|
167
|
+
2. Click "Timeline"
|
|
168
|
+
3. Click "JavaScript Allocations" in the menu on the left. It might not be visible until you click the pencil icon to show all the timelines
|
|
169
|
+
4. Click "Import" and select your heap snapshot JSON
|
|
170
|
+
|
|
171
|
+
<Frame>
|
|
172
|
+
<img
|
|
173
|
+
src="https://user-images.githubusercontent.com/709451/204428943-ba999e8f-8984-4f23-97cb-b4e3e280363e.png"
|
|
174
|
+
alt="Importing a heap snapshot"
|
|
175
|
+
/>
|
|
176
|
+
</Frame>
|
|
177
|
+
|
|
178
|
+
Once imported, you should see something like this:
|
|
179
|
+
|
|
180
|
+
<Frame>
|
|
181
|
+
<img
|
|
182
|
+
alt="Viewing heap snapshot in Safari"
|
|
183
|
+
src="https://user-images.githubusercontent.com/709451/204429337-b0d8935f-3509-4071-b991-217794d1fb27.png"
|
|
184
|
+
caption="Viewing heap snapshot in Safari Dev Tools"
|
|
185
|
+
/>
|
|
186
|
+
</Frame>
|
|
187
|
+
|
|
188
|
+
> The [web debugger](/docs/runtime/debugger#inspect) also offers the timeline feature which allows you to track and examine the memory usage of the running debug session.
|
|
189
|
+
|
|
190
|
+
### Native heap stats
|
|
191
|
+
|
|
192
|
+
Bun uses mimalloc for the other heap. To report a summary of non-JavaScript memory usage, set the `MIMALLOC_SHOW_STATS=1` environment variable. and stats will print on exit.
|
|
193
|
+
|
|
194
|
+
```sh terminal icon="terminal"
|
|
195
|
+
MIMALLOC_SHOW_STATS=1 bun script.js
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
```txt
|
|
199
|
+
heap stats: peak total freed current unit count
|
|
200
|
+
reserved: 64.0 MiB 64.0 MiB 0 64.0 MiB not all freed!
|
|
201
|
+
committed: 64.0 MiB 64.0 MiB 0 64.0 MiB not all freed!
|
|
202
|
+
reset: 0 0 0 0 ok
|
|
203
|
+
touched: 128.5 KiB 128.5 KiB 5.4 MiB -5.3 MiB ok
|
|
204
|
+
segments: 1 1 0 1 not all freed!
|
|
205
|
+
-abandoned: 0 0 0 0 ok
|
|
206
|
+
-cached: 0 0 0 0 ok
|
|
207
|
+
pages: 0 0 53 -53 ok
|
|
208
|
+
-abandoned: 0 0 0 0 ok
|
|
209
|
+
-extended: 0
|
|
210
|
+
-noretire: 0
|
|
211
|
+
mmaps: 0
|
|
212
|
+
commits: 0
|
|
213
|
+
threads: 0 0 0 0 ok
|
|
214
|
+
searches: 0.0 avg
|
|
215
|
+
numa nodes: 1
|
|
216
|
+
elapsed: 0.068 s
|
|
217
|
+
process: user: 0.061 s, system: 0.014 s, faults: 0, rss: 57.4 MiB, commit: 64.0 MiB
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## CPU profiling
|
|
221
|
+
|
|
222
|
+
Profile JavaScript execution to identify performance bottlenecks with the `--cpu-prof` flag.
|
|
223
|
+
|
|
224
|
+
```sh terminal icon="terminal"
|
|
225
|
+
bun --cpu-prof script.js
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
This generates a `.cpuprofile` file you can open in Chrome DevTools (Performance tab → Load profile) or VS Code's CPU profiler.
|
|
229
|
+
|
|
230
|
+
### Markdown output
|
|
231
|
+
|
|
232
|
+
Use `--cpu-prof-md` to generate a markdown CPU profile, which is grep-friendly and designed for LLM analysis:
|
|
233
|
+
|
|
234
|
+
```sh terminal icon="terminal"
|
|
235
|
+
bun --cpu-prof-md script.js
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
Both `--cpu-prof` and `--cpu-prof-md` can be used together to generate both formats at once:
|
|
239
|
+
|
|
240
|
+
```sh terminal icon="terminal"
|
|
241
|
+
bun --cpu-prof --cpu-prof-md script.js
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
You can also trigger profiling via the `BUN_OPTIONS` environment variable:
|
|
245
|
+
|
|
246
|
+
```sh terminal icon="terminal"
|
|
247
|
+
BUN_OPTIONS="--cpu-prof-md" bun script.js
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Options
|
|
251
|
+
|
|
252
|
+
```sh terminal icon="terminal"
|
|
253
|
+
bun --cpu-prof --cpu-prof-name my-profile.cpuprofile script.js
|
|
254
|
+
bun --cpu-prof --cpu-prof-dir ./profiles script.js
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
| Flag | Description |
|
|
258
|
+
| ---------------------------- | ----------------------------------------------------------- |
|
|
259
|
+
| `--cpu-prof` | Generate a `.cpuprofile` JSON file (Chrome DevTools format) |
|
|
260
|
+
| `--cpu-prof-md` | Generate a markdown CPU profile (grep/LLM-friendly) |
|
|
261
|
+
| `--cpu-prof-name <filename>` | Set output filename |
|
|
262
|
+
| `--cpu-prof-dir <dir>` | Set output directory |
|
|
263
|
+
|
|
264
|
+
## Heap profiling
|
|
265
|
+
|
|
266
|
+
Generate heap snapshots on exit to analyze memory usage and find memory leaks.
|
|
267
|
+
|
|
268
|
+
```sh terminal icon="terminal"
|
|
269
|
+
bun --heap-prof script.js
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
This generates a V8 `.heapsnapshot` file that can be loaded in Chrome DevTools (Memory tab → Load).
|
|
273
|
+
|
|
274
|
+
### Markdown output
|
|
275
|
+
|
|
276
|
+
Use `--heap-prof-md` to generate a markdown heap profile for CLI analysis:
|
|
277
|
+
|
|
278
|
+
```sh terminal icon="terminal"
|
|
279
|
+
bun --heap-prof-md script.js
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
<Note>If both `--heap-prof` and `--heap-prof-md` are specified, the markdown format is used.</Note>
|
|
283
|
+
|
|
284
|
+
### Options
|
|
285
|
+
|
|
286
|
+
```sh terminal icon="terminal"
|
|
287
|
+
bun --heap-prof --heap-prof-name my-snapshot.heapsnapshot script.js
|
|
288
|
+
bun --heap-prof --heap-prof-dir ./profiles script.js
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
| Flag | Description |
|
|
292
|
+
| ----------------------------- | ------------------------------------------ |
|
|
293
|
+
| `--heap-prof` | Generate a V8 `.heapsnapshot` file on exit |
|
|
294
|
+
| `--heap-prof-md` | Generate a markdown heap profile on exit |
|
|
295
|
+
| `--heap-prof-name <filename>` | Set output filename |
|
|
296
|
+
| `--heap-prof-dir <dir>` | Set output directory |
|