bun-types 1.3.2-canary.20251105T140650 → 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/README.md +28 -0
- package/docs/bundler/bytecode.mdx +465 -0
- package/docs/bundler/{css.md → css.mdx} +97 -101
- package/docs/bundler/esbuild.mdx +253 -0
- package/docs/bundler/{executables.md → executables.mdx} +130 -221
- package/docs/bundler/fullstack.mdx +1064 -0
- package/docs/bundler/{hmr.md → hot-reloading.mdx} +74 -79
- package/docs/bundler/{html.md → html-static.mdx} +148 -111
- package/docs/bundler/index.mdx +1499 -0
- package/docs/bundler/loaders.mdx +356 -0
- package/docs/bundler/{macros.md → macros.mdx} +83 -84
- 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.md → arraybuffer-to-array.mdx} +3 -1
- package/docs/guides/binary/{arraybuffer-to-blob.md → arraybuffer-to-blob.mdx} +3 -1
- package/docs/guides/binary/{arraybuffer-to-buffer.md → arraybuffer-to-buffer.mdx} +3 -1
- package/docs/guides/binary/{arraybuffer-to-string.md → arraybuffer-to-string.mdx} +3 -1
- package/docs/guides/binary/{arraybuffer-to-typedarray.md → arraybuffer-to-typedarray.mdx} +3 -1
- package/docs/guides/binary/{blob-to-arraybuffer.md → blob-to-arraybuffer.mdx} +3 -1
- package/docs/guides/binary/{blob-to-dataview.md → blob-to-dataview.mdx} +3 -1
- package/docs/guides/binary/{blob-to-stream.md → blob-to-stream.mdx} +3 -1
- package/docs/guides/binary/{blob-to-string.md → blob-to-string.mdx} +3 -1
- package/docs/guides/binary/{blob-to-typedarray.md → blob-to-typedarray.mdx} +3 -1
- package/docs/guides/binary/{buffer-to-arraybuffer.md → buffer-to-arraybuffer.mdx} +3 -1
- package/docs/guides/binary/{buffer-to-blob.md → buffer-to-blob.mdx} +3 -1
- package/docs/guides/binary/{buffer-to-readablestream.md → buffer-to-readablestream.mdx} +3 -1
- package/docs/guides/binary/{buffer-to-string.md → buffer-to-string.mdx} +3 -1
- package/docs/guides/binary/{buffer-to-typedarray.md → buffer-to-typedarray.mdx} +3 -1
- package/docs/guides/binary/{dataview-to-string.md → dataview-to-string.mdx} +3 -1
- package/docs/guides/binary/{typedarray-to-arraybuffer.md → typedarray-to-arraybuffer.mdx} +3 -1
- package/docs/guides/binary/{typedarray-to-blob.md → typedarray-to-blob.mdx} +3 -1
- package/docs/guides/binary/{typedarray-to-buffer.md → typedarray-to-buffer.mdx} +3 -1
- package/docs/guides/binary/{typedarray-to-dataview.md → typedarray-to-dataview.mdx} +3 -1
- package/docs/guides/binary/{typedarray-to-readablestream.md → typedarray-to-readablestream.mdx} +3 -1
- package/docs/guides/binary/{typedarray-to-string.md → typedarray-to-string.mdx} +3 -1
- 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.md → railway.mdx} +42 -54
- package/docs/guides/deployment/render.mdx +82 -0
- package/docs/guides/deployment/vercel.mdx +99 -0
- package/docs/guides/ecosystem/{astro.md → astro.mdx} +16 -6
- package/docs/guides/ecosystem/{discordjs.md → discordjs.mdx} +21 -18
- package/docs/guides/ecosystem/{docker.md → docker.mdx} +25 -14
- package/docs/guides/ecosystem/{drizzle.md → drizzle.mdx} +32 -22
- package/docs/guides/ecosystem/{edgedb.md → edgedb.mdx} +63 -34
- package/docs/guides/ecosystem/{elysia.md → elysia.mdx} +11 -11
- package/docs/guides/ecosystem/{express.md → express.mdx} +12 -9
- package/docs/guides/ecosystem/{hono.md → hono.mdx} +16 -8
- package/docs/guides/ecosystem/{mongoose.md → mongoose.mdx} +26 -21
- package/docs/guides/ecosystem/{neon-drizzle.md → neon-drizzle.mdx} +49 -35
- package/docs/guides/ecosystem/{neon-serverless-postgres.md → neon-serverless-postgres.mdx} +16 -11
- package/docs/guides/ecosystem/{nextjs.md → nextjs.mdx} +18 -10
- package/docs/guides/ecosystem/{nuxt.md → nuxt.mdx} +45 -11
- package/docs/guides/ecosystem/{pm2.md → pm2.mdx} +7 -9
- package/docs/guides/ecosystem/prisma-postgres.mdx +169 -0
- package/docs/guides/ecosystem/prisma.mdx +164 -0
- package/docs/guides/ecosystem/{qwik.md → qwik.mdx} +18 -11
- package/docs/guides/ecosystem/{react.md → react.mdx} +9 -7
- package/docs/guides/ecosystem/{remix.md → remix.mdx} +45 -26
- package/docs/guides/ecosystem/{sentry.md → sentry.mdx} +7 -5
- package/docs/guides/ecosystem/{solidstart.md → solidstart.mdx} +21 -13
- package/docs/guides/ecosystem/{ssr-react.md → ssr-react.mdx} +9 -11
- package/docs/guides/ecosystem/{stric.md → stric.mdx} +16 -17
- package/docs/guides/ecosystem/{sveltekit.md → sveltekit.mdx} +42 -29
- package/docs/guides/ecosystem/{systemd.md → systemd.mdx} +27 -26
- package/docs/guides/ecosystem/upstash.mdx +87 -0
- package/docs/guides/ecosystem/{vite.md → vite.mdx} +20 -14
- package/docs/guides/html-rewriter/{extract-links.md → extract-links.mdx} +11 -7
- package/docs/guides/html-rewriter/{extract-social-meta.md → extract-social-meta.mdx} +6 -2
- package/docs/guides/http/{cluster.md → cluster.mdx} +10 -7
- package/docs/guides/http/{fetch-unix.md → fetch-unix.mdx} +5 -3
- package/docs/guides/http/{fetch.md → fetch.mdx} +5 -3
- package/docs/guides/http/{file-uploads.md → file-uploads.mdx} +18 -15
- package/docs/guides/http/{hot.md → hot.mdx} +9 -7
- package/docs/guides/http/{proxy.md → proxy.mdx} +7 -5
- package/docs/guides/http/{server.md → server.mdx} +4 -2
- package/docs/guides/http/{simple.md → simple.mdx} +4 -2
- package/docs/guides/http/{stream-file.md → stream-file.mdx} +6 -4
- package/docs/guides/http/{stream-iterator.md → stream-iterator.mdx} +5 -3
- package/docs/guides/http/{stream-node-streams-in-bun.md → stream-node-streams-in-bun.mdx} +4 -2
- package/docs/guides/http/{tls.md → tls.mdx} +5 -3
- package/docs/guides/index.mdx +10 -0
- package/docs/guides/install/{add-dev.md → add-dev.mdx} +8 -6
- package/docs/guides/install/add-git.mdx +38 -0
- package/docs/guides/install/{add-optional.md → add-optional.mdx} +7 -5
- package/docs/guides/install/{add-peer.md → add-peer.mdx} +13 -11
- package/docs/guides/install/{add-tarball.md → add-tarball.mdx} +7 -5
- package/docs/guides/install/{add.md → add.mdx} +12 -10
- package/docs/guides/install/{azure-artifacts.md → azure-artifacts.mdx} +15 -12
- package/docs/guides/{runtime/cicd.md → install/cicd.mdx} +13 -13
- package/docs/guides/install/{custom-registry.md → custom-registry.mdx} +6 -4
- package/docs/guides/install/{from-npm-install-to-bun-install.md → from-npm-install-to-bun-install.mdx} +50 -34
- package/docs/guides/install/{git-diff-bun-lockfile.md → git-diff-bun-lockfile.mdx} +14 -11
- package/docs/guides/install/{jfrog-artifactory.md → jfrog-artifactory.mdx} +4 -4
- package/docs/guides/install/{npm-alias.md → npm-alias.mdx} +6 -4
- package/docs/guides/install/{registry-scope.md → registry-scope.mdx} +6 -4
- package/docs/guides/install/{trusted.md → trusted.mdx} +22 -18
- package/docs/guides/install/{workspaces.md → workspaces.mdx} +13 -13
- package/docs/guides/install/{yarnlock.md → yarnlock.mdx} +15 -9
- package/docs/guides/process/{argv.md → argv.mdx} +17 -9
- package/docs/guides/process/{ctrl-c.md → ctrl-c.mdx} +4 -2
- package/docs/guides/process/{ipc.md → ipc.mdx} +13 -10
- package/docs/guides/process/{nanoseconds.md → nanoseconds.mdx} +3 -1
- package/docs/guides/process/{os-signals.md → os-signals.mdx} +3 -1
- package/docs/guides/process/{spawn-stderr.md → spawn-stderr.mdx} +4 -1
- package/docs/guides/process/{spawn-stdout.md → spawn-stdout.mdx} +3 -1
- package/docs/guides/process/{spawn.md → spawn.mdx} +3 -1
- package/docs/guides/process/{stdin.md → stdin.mdx} +15 -7
- package/docs/guides/read-file/{arraybuffer.md → arraybuffer.mdx} +5 -3
- package/docs/guides/read-file/{buffer.md → buffer.mdx} +4 -2
- package/docs/guides/read-file/{exists.md → exists.mdx} +4 -2
- package/docs/guides/read-file/{json.md → json.mdx} +4 -2
- package/docs/guides/read-file/{mime.md → mime.mdx} +3 -1
- package/docs/guides/read-file/{stream.md → stream.mdx} +3 -1
- package/docs/guides/read-file/{string.md → string.mdx} +3 -1
- package/docs/guides/read-file/{uint8array.md → uint8array.mdx} +3 -1
- package/docs/guides/read-file/{watch.md → watch.mdx} +6 -8
- package/docs/guides/runtime/{build-time-constants.md → build-time-constants.mdx} +24 -22
- package/docs/guides/{install/cicd.md → runtime/cicd.mdx} +11 -7
- package/docs/guides/runtime/{codesign-macos-executable.md → codesign-macos-executable.mdx} +14 -9
- package/docs/guides/runtime/{define-constant.md → define-constant.mdx} +20 -16
- package/docs/guides/runtime/{delete-directory.md → delete-directory.mdx} +5 -3
- package/docs/guides/runtime/{delete-file.md → delete-file.mdx} +4 -2
- package/docs/guides/runtime/{heap-snapshot.md → heap-snapshot.mdx} +5 -3
- package/docs/guides/runtime/{import-html.md → import-html.mdx} +4 -2
- package/docs/guides/runtime/{import-json.md → import-json.mdx} +6 -4
- package/docs/guides/runtime/{import-toml.md → import-toml.mdx} +5 -3
- package/docs/guides/runtime/{import-yaml.md → import-yaml.mdx} +9 -7
- package/docs/guides/runtime/{read-env.md → read-env.mdx} +10 -5
- package/docs/guides/runtime/{set-env.md → set-env.mdx} +14 -10
- package/docs/guides/runtime/{shell.md → shell.mdx} +6 -4
- package/docs/guides/runtime/{timezone.md → timezone.mdx} +10 -7
- package/docs/guides/runtime/{tsconfig-paths.md → tsconfig-paths.mdx} +5 -3
- package/docs/guides/runtime/{typescript.md → typescript.mdx} +8 -6
- package/docs/guides/runtime/{vscode-debugger.md → vscode-debugger.mdx} +12 -11
- package/docs/guides/runtime/{web-debugger.md → web-debugger.mdx} +39 -18
- package/docs/guides/streams/{node-readable-to-arraybuffer.md → node-readable-to-arraybuffer.mdx} +3 -1
- package/docs/guides/streams/{node-readable-to-blob.md → node-readable-to-blob.mdx} +3 -1
- package/docs/guides/streams/{node-readable-to-json.md → node-readable-to-json.mdx} +3 -1
- package/docs/guides/streams/{node-readable-to-string.md → node-readable-to-string.mdx} +3 -1
- package/docs/guides/streams/{node-readable-to-uint8array.md → node-readable-to-uint8array.mdx} +3 -1
- package/docs/guides/streams/{to-array.md → to-array.mdx} +3 -1
- package/docs/guides/streams/{to-arraybuffer.md → to-arraybuffer.mdx} +3 -1
- package/docs/guides/streams/{to-blob.md → to-blob.mdx} +3 -1
- package/docs/guides/streams/{to-buffer.md → to-buffer.mdx} +3 -1
- package/docs/guides/streams/{to-json.md → to-json.mdx} +4 -2
- package/docs/guides/streams/{to-string.md → to-string.mdx} +3 -1
- package/docs/guides/streams/{to-typedarray.md → to-typedarray.mdx} +3 -1
- package/docs/guides/test/{bail.md → bail.mdx} +7 -5
- package/docs/guides/test/{coverage-threshold.md → coverage-threshold.mdx} +14 -7
- package/docs/guides/test/{coverage.md → coverage.mdx} +9 -4
- package/docs/guides/test/{happy-dom.md → happy-dom.mdx} +13 -8
- package/docs/guides/test/{migrate-from-jest.md → migrate-from-jest.mdx} +19 -37
- package/docs/guides/test/{mock-clock.md → mock-clock.mdx} +3 -1
- package/docs/guides/test/{mock-functions.md → mock-functions.mdx} +7 -5
- package/docs/guides/test/{rerun-each.md → rerun-each.mdx} +5 -3
- package/docs/guides/test/{run-tests.md → run-tests.mdx} +16 -11
- package/docs/guides/test/{skip-tests.md → skip-tests.mdx} +8 -4
- package/docs/guides/test/{snapshot.md → snapshot.mdx} +20 -13
- package/docs/guides/test/spy-on.mdx +49 -0
- package/docs/guides/test/{svelte-test.md → svelte-test.mdx} +16 -23
- package/docs/guides/test/{testing-library.md → testing-library.mdx} +18 -17
- package/docs/guides/test/{timeout.md → timeout.mdx} +5 -3
- package/docs/guides/test/{todo-tests.md → todo-tests.mdx} +13 -6
- package/docs/guides/test/{update-snapshots.md → update-snapshots.mdx} +9 -6
- package/docs/guides/test/{watch-mode.md → watch-mode.mdx} +9 -4
- package/docs/guides/util/{base64.md → base64.mdx} +3 -1
- package/docs/guides/util/{deep-equals.md → deep-equals.mdx} +5 -3
- package/docs/guides/util/{deflate.md → deflate.mdx} +3 -1
- package/docs/guides/util/{detect-bun.md → detect-bun.mdx} +3 -1
- package/docs/guides/util/{entrypoint.md → entrypoint.mdx} +4 -2
- package/docs/guides/util/{escape-html.md → escape-html.mdx} +3 -1
- package/docs/guides/util/{file-url-to-path.md → file-url-to-path.mdx} +3 -1
- package/docs/guides/util/{gzip.md → gzip.mdx} +3 -1
- package/docs/guides/util/{hash-a-password.md → hash-a-password.mdx} +3 -1
- package/docs/guides/util/{import-meta-dir.md → import-meta-dir.mdx} +4 -2
- package/docs/guides/util/{import-meta-file.md → import-meta-file.mdx} +4 -2
- package/docs/guides/util/{import-meta-path.md → import-meta-path.mdx} +4 -2
- package/docs/guides/util/{javascript-uuid.md → javascript-uuid.mdx} +3 -1
- package/docs/guides/util/{main.md → main.mdx} +19 -8
- package/docs/guides/util/{path-to-file-url.md → path-to-file-url.mdx} +3 -1
- package/docs/guides/util/{sleep.md → sleep.mdx} +3 -1
- package/docs/guides/util/{version.md → version.mdx} +6 -4
- package/docs/guides/util/{which-path-to-executable-bin.md → which-path-to-executable-bin.mdx} +4 -2
- package/docs/guides/websocket/{compression.md → compression.mdx} +5 -3
- package/docs/guides/websocket/{context.md → context.mdx} +9 -12
- package/docs/guides/websocket/{pubsub.md → pubsub.mdx} +5 -6
- package/docs/guides/websocket/{simple.md → simple.mdx} +5 -3
- package/docs/guides/write-file/{append.md → append.mdx} +3 -1
- package/docs/guides/write-file/{basic.md → basic.mdx} +3 -1
- package/docs/guides/write-file/{blob.md → blob.mdx} +3 -1
- package/docs/guides/write-file/{cat.md → cat.mdx} +4 -2
- package/docs/guides/write-file/{file-cp.md → file-cp.mdx} +3 -1
- package/docs/guides/write-file/{filesink.md → filesink.mdx} +3 -1
- package/docs/guides/write-file/{response.md → response.mdx} +3 -1
- package/docs/guides/write-file/{stdout.md → stdout.mdx} +3 -1
- package/docs/guides/write-file/{stream.md → stream.mdx} +3 -1
- package/docs/guides/write-file/{unlink.md → unlink.mdx} +3 -1
- package/docs/{index.md → index.mdx} +97 -41
- package/docs/installation.mdx +365 -0
- package/docs/{cli/bunx.md → pm/bunx.mdx} +25 -31
- package/docs/{install/catalogs.md → pm/catalogs.mdx} +18 -24
- package/docs/{cli/add.md → pm/cli/add.mdx} +61 -55
- package/docs/{install/audit.md → pm/cli/audit.mdx} +11 -8
- package/docs/{cli/install.md → pm/cli/install.mdx} +208 -81
- package/docs/{cli/link.md → pm/cli/link.mdx} +27 -19
- package/docs/{cli/outdated.md → pm/cli/outdated.mdx} +119 -12
- package/docs/{install/patch.md → pm/cli/patch.mdx} +25 -15
- package/docs/{cli/pm.md → pm/cli/pm.mdx} +96 -62
- package/docs/{cli/publish.md → pm/cli/publish.mdx} +38 -35
- package/docs/pm/cli/remove.mdx +16 -0
- package/docs/{cli/update.md → pm/cli/update.mdx} +26 -15
- package/docs/{cli/why.md → pm/cli/why.mdx} +27 -10
- package/docs/{cli/filter.md → pm/filter.mdx} +26 -14
- package/docs/{install/cache.md → pm/global-cache.mdx} +25 -12
- package/docs/{install/isolated.md → pm/isolated-installs.mdx} +32 -24
- package/docs/{install/lifecycle.md → pm/lifecycle.mdx} +20 -9
- package/docs/{install/lockfile.md → pm/lockfile.mdx} +18 -12
- package/docs/{install/npmrc.md → pm/npmrc.mdx} +30 -24
- package/docs/{install/overrides.md → pm/overrides.mdx} +47 -37
- package/docs/{install/registries.md → pm/scopes-registries.mdx} +8 -3
- package/docs/{install/security-scanner-api.md → pm/security-scanner-api.mdx} +22 -8
- package/docs/{install/workspaces.md → pm/workspaces.mdx} +17 -22
- package/docs/project/{benchmarking.md → benchmarking.mdx} +26 -11
- package/docs/project/{bindgen.md → bindgen.mdx} +12 -14
- package/docs/project/{building-windows.md → building-windows.mdx} +18 -47
- package/docs/project/{contributing.md → contributing.mdx} +56 -60
- 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/{autoimport.md → auto-install.mdx} +34 -31
- package/docs/{api/binary-data.md → runtime/binary-data.mdx} +77 -269
- package/docs/runtime/bun-apis.mdx +59 -0
- package/docs/runtime/{bunfig.md → bunfig.mdx} +95 -225
- package/docs/{api/cc.md → runtime/c-compiler.mdx} +16 -9
- package/docs/{api/spawn.md → runtime/child-process.mdx} +69 -119
- package/docs/{api/color.md → runtime/color.mdx} +6 -1
- package/docs/{api/console.md → runtime/console.mdx} +17 -7
- package/docs/{api/cookie.md → runtime/cookies.mdx} +24 -19
- package/docs/runtime/{debugger.md → debugger.mdx} +61 -51
- package/docs/runtime/environment-variables.mdx +214 -0
- package/docs/{api/ffi.md → runtime/ffi.mdx} +53 -45
- package/docs/{api/file-io.md → runtime/file-io.mdx} +41 -101
- package/docs/{api/file-system-router.md → runtime/file-system-router.mdx} +8 -2
- package/docs/{bundler/loaders.md → runtime/file-types.mdx} +56 -112
- package/docs/{api/glob.md → runtime/glob.mdx} +4 -1
- package/docs/runtime/globals.mdx +72 -0
- package/docs/{api/hashing.md → runtime/hashing.mdx} +18 -22
- package/docs/{api/html-rewriter.md → runtime/html-rewriter.mdx} +36 -30
- 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/{api/websockets.md → runtime/http/websockets.mdx} +62 -231
- package/docs/{cli/run.md → runtime/index.mdx} +70 -108
- package/docs/runtime/jsx.mdx +115 -0
- package/docs/runtime/{modules.md → module-resolution.mdx} +83 -61
- package/docs/{api/dns.md → runtime/networking/dns.mdx} +23 -22
- package/docs/{api/fetch.md → runtime/networking/fetch.mdx} +10 -5
- package/docs/{api/tcp.md → runtime/networking/tcp.mdx} +59 -41
- package/docs/{api/udp.md → runtime/networking/udp.mdx} +14 -8
- package/docs/{api/node-api.md → runtime/node-api.mdx} +5 -0
- package/docs/runtime/{nodejs-apis.md → nodejs-compat.mdx} +9 -4
- package/docs/{bundler/plugins.md → runtime/plugins.mdx} +17 -61
- package/docs/{api/redis.md → runtime/redis.mdx} +65 -80
- package/docs/{api/s3.md → runtime/s3.mdx} +79 -66
- package/docs/{api/secrets.md → runtime/secrets.mdx} +27 -10
- package/docs/{api/semver.md → runtime/semver.mdx} +9 -4
- package/docs/runtime/{shell.md → shell.mdx} +52 -20
- package/docs/{api/sql.md → runtime/sql.mdx} +129 -99
- package/docs/{api/sqlite.md → runtime/sqlite.mdx} +162 -157
- package/docs/{api/streams.md → runtime/streams.mdx} +33 -31
- package/docs/{cli/bun-create.md → runtime/templating/create.mdx} +74 -143
- package/docs/{cli/init.md → runtime/templating/init.mdx} +24 -51
- package/docs/{api/transpiler.md → runtime/transpiler.mdx} +50 -38
- package/docs/{typescript.md → runtime/typescript.mdx} +7 -2
- package/docs/{api/utils.md → runtime/utils.mdx} +81 -50
- package/docs/runtime/{hot.md → watch-mode.mdx} +53 -37
- package/docs/runtime/web-apis.mdx +29 -0
- package/docs/{api/workers.md → runtime/workers.mdx} +28 -22
- package/docs/{api/yaml.md → runtime/yaml.mdx} +33 -232
- 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/{time.md → dates-times.mdx} +23 -20
- package/docs/test/{discovery.md → discovery.mdx} +15 -10
- package/docs/test/dom.mdx +226 -0
- package/docs/{cli/test.md → test/index.mdx} +77 -94
- package/docs/test/lifecycle.mdx +348 -0
- package/docs/test/mocks.mdx +637 -0
- package/docs/test/{reporters.md → reporters.mdx} +15 -15
- 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
- package/docs/api/file.md +0 -19
- package/docs/api/globals.md +0 -387
- package/docs/api/http.md +0 -1408
- package/docs/api/import-meta.md +0 -69
- package/docs/benchmarks.md +0 -120
- package/docs/bun-flavored-toml.md +0 -42
- package/docs/bundler/css_modules.md +0 -145
- package/docs/bundler/fullstack.md +0 -418
- package/docs/bundler/index.md +0 -1735
- package/docs/bundler/intro.md +0 -75
- package/docs/bundler/vs-esbuild.md +0 -1127
- package/docs/cli/bun-completions.md +0 -3
- package/docs/cli/bun-install.md +0 -349
- package/docs/cli/bun-upgrade.md +0 -39
- package/docs/cli/info.md +0 -65
- package/docs/cli/patch-commit.md +0 -11
- package/docs/cli/remove.md +0 -7
- package/docs/cli/unlink.md +0 -9
- 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/ecosystem/prisma.md +0 -141
- package/docs/guides/ecosystem/render.md +0 -79
- package/docs/guides/install/add-git.md +0 -36
- package/docs/guides/test/spy-on.md +0 -46
- package/docs/install/index.md +0 -248
- package/docs/installation.md +0 -327
- package/docs/project/asan.md +0 -124
- 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/bun-apis.md +0 -207
- package/docs/runtime/env.md +0 -253
- package/docs/runtime/index.md +0 -312
- package/docs/runtime/jsx.md +0 -385
- package/docs/runtime/loaders.md +0 -130
- package/docs/runtime/plugins.md +0 -561
- 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/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/runtime-behavior.md +0 -95
- package/docs/test/snapshots.md +0 -68
- package/docs/test/writing.md +0 -825
|
@@ -1,33 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Single-file executable"
|
|
3
|
+
description: "Generate standalone executables from TypeScript or JavaScript files with Bun"
|
|
4
|
+
---
|
|
5
|
+
|
|
1
6
|
Bun's bundler implements a `--compile` flag for generating a standalone binary from a TypeScript or JavaScript file.
|
|
2
7
|
|
|
3
|
-
|
|
8
|
+
<CodeGroup>
|
|
4
9
|
|
|
5
|
-
```bash
|
|
6
|
-
|
|
10
|
+
```bash terminal icon="terminal"
|
|
11
|
+
bun build ./cli.ts --compile --outfile mycli
|
|
7
12
|
```
|
|
8
13
|
|
|
9
|
-
```ts
|
|
14
|
+
```ts cli.ts icon="/icons/typescript.svg"
|
|
10
15
|
console.log("Hello world!");
|
|
11
16
|
```
|
|
12
17
|
|
|
13
|
-
|
|
18
|
+
</CodeGroup>
|
|
14
19
|
|
|
15
20
|
This bundles `cli.ts` into an executable that can be executed directly:
|
|
16
21
|
|
|
22
|
+
```bash terminal icon="terminal"
|
|
23
|
+
./mycli
|
|
17
24
|
```
|
|
18
|
-
|
|
25
|
+
|
|
26
|
+
```txt
|
|
19
27
|
Hello world!
|
|
20
28
|
```
|
|
21
29
|
|
|
22
30
|
All imported files and packages are bundled into the executable, along with a copy of the Bun runtime. All built-in Bun and Node.js APIs are supported.
|
|
23
31
|
|
|
32
|
+
---
|
|
33
|
+
|
|
24
34
|
## Cross-compile to other platforms
|
|
25
35
|
|
|
26
36
|
The `--target` flag lets you compile your standalone executable for a different operating system, architecture, or version of Bun than the machine you're running `bun build` on.
|
|
27
37
|
|
|
28
38
|
To build for Linux x64 (most servers):
|
|
29
39
|
|
|
30
|
-
```
|
|
40
|
+
```bash icon="terminal" terminal
|
|
31
41
|
bun build --compile --target=bun-linux-x64 ./index.ts --outfile myapp
|
|
32
42
|
|
|
33
43
|
# To support CPUs from before 2013, use the baseline version (nehalem)
|
|
@@ -40,14 +50,14 @@ bun build --compile --target=bun-linux-x64-modern ./index.ts --outfile myapp
|
|
|
40
50
|
|
|
41
51
|
To build for Linux ARM64 (e.g. Graviton or Raspberry Pi):
|
|
42
52
|
|
|
43
|
-
```
|
|
53
|
+
```bash icon="terminal" terminal
|
|
44
54
|
# Note: the default architecture is x64 if no architecture is specified.
|
|
45
55
|
bun build --compile --target=bun-linux-arm64 ./index.ts --outfile myapp
|
|
46
56
|
```
|
|
47
57
|
|
|
48
58
|
To build for Windows x64:
|
|
49
59
|
|
|
50
|
-
```
|
|
60
|
+
```bash icon="terminal" terminal
|
|
51
61
|
bun build --compile --target=bun-windows-x64 ./path/to/my/app.ts --outfile myapp
|
|
52
62
|
|
|
53
63
|
# To support CPUs from before 2013, use the baseline version (nehalem)
|
|
@@ -61,17 +71,17 @@ bun build --compile --target=bun-windows-x64-modern ./path/to/my/app.ts --outfil
|
|
|
61
71
|
|
|
62
72
|
To build for macOS arm64:
|
|
63
73
|
|
|
64
|
-
```
|
|
74
|
+
```bash icon="terminal" terminal
|
|
65
75
|
bun build --compile --target=bun-darwin-arm64 ./path/to/my/app.ts --outfile myapp
|
|
66
76
|
```
|
|
67
77
|
|
|
68
78
|
To build for macOS x64:
|
|
69
79
|
|
|
70
|
-
```
|
|
80
|
+
```bash icon="terminal" terminal
|
|
71
81
|
bun build --compile --target=bun-darwin-x64 ./path/to/my/app.ts --outfile myapp
|
|
72
82
|
```
|
|
73
83
|
|
|
74
|
-
|
|
84
|
+
### Supported targets
|
|
75
85
|
|
|
76
86
|
The order of the `--target` flag does not matter, as long as they're delimited by a `-`.
|
|
77
87
|
|
|
@@ -86,21 +96,32 @@ The order of the `--target` flag does not matter, as long as they're delimited b
|
|
|
86
96
|
| bun-linux-x64-musl | Linux | x64 | ✅ | ✅ | musl |
|
|
87
97
|
| bun-linux-arm64-musl | Linux | arm64 | ✅ | N/A | musl |
|
|
88
98
|
|
|
89
|
-
|
|
99
|
+
<Warning>
|
|
100
|
+
On x64 platforms, Bun uses SIMD optimizations which require a modern CPU supporting AVX2 instructions. The `-baseline`
|
|
101
|
+
build of Bun is for older CPUs that don't support these optimizations. Normally, when you install Bun we automatically
|
|
102
|
+
detect which version to use but this can be harder to do when cross-compiling since you might not know the target CPU.
|
|
103
|
+
You usually don't need to worry about it on Darwin x64, but it is relevant for Windows x64 and Linux x64. If you or
|
|
104
|
+
your users see `"Illegal instruction"` errors, you might need to use the baseline version.
|
|
105
|
+
</Warning>
|
|
106
|
+
|
|
107
|
+
---
|
|
90
108
|
|
|
91
109
|
## Build-time constants
|
|
92
110
|
|
|
93
111
|
Use the `--define` flag to inject build-time constants into your executable, such as version numbers, build timestamps, or configuration values:
|
|
94
112
|
|
|
95
|
-
```bash
|
|
96
|
-
|
|
113
|
+
```bash icon="terminal" terminal
|
|
114
|
+
bun build --compile --define BUILD_VERSION='"1.2.3"' --define BUILD_TIME='"2024-01-15T10:30:00Z"' src/cli.ts --outfile mycli
|
|
97
115
|
```
|
|
98
116
|
|
|
99
117
|
These constants are embedded directly into your compiled binary at build time, providing zero runtime overhead and enabling dead code elimination optimizations.
|
|
100
118
|
|
|
101
|
-
|
|
102
|
-
For comprehensive examples and advanced patterns, see the [Build-time constants
|
|
103
|
-
|
|
119
|
+
<Note>
|
|
120
|
+
For comprehensive examples and advanced patterns, see the [Build-time constants
|
|
121
|
+
guide](https://bun.com/guides/runtime/build-time-constants).
|
|
122
|
+
</Note>
|
|
123
|
+
|
|
124
|
+
---
|
|
104
125
|
|
|
105
126
|
## Deploying to production
|
|
106
127
|
|
|
@@ -112,7 +133,7 @@ With compiled executables, you can move that cost from runtime to build-time.
|
|
|
112
133
|
|
|
113
134
|
When deploying to production, we recommend the following:
|
|
114
135
|
|
|
115
|
-
```
|
|
136
|
+
```bash icon="terminal" terminal
|
|
116
137
|
bun build --compile --minify --sourcemap ./path/to/my/app.ts --outfile myapp
|
|
117
138
|
```
|
|
118
139
|
|
|
@@ -120,17 +141,22 @@ bun build --compile --minify --sourcemap ./path/to/my/app.ts --outfile myapp
|
|
|
120
141
|
|
|
121
142
|
To improve startup time, enable bytecode compilation:
|
|
122
143
|
|
|
123
|
-
```
|
|
144
|
+
```bash icon="terminal" terminal
|
|
124
145
|
bun build --compile --minify --sourcemap --bytecode ./path/to/my/app.ts --outfile myapp
|
|
125
146
|
```
|
|
126
147
|
|
|
127
148
|
Using bytecode compilation, `tsc` starts 2x faster:
|
|
128
149
|
|
|
129
|
-
|
|
150
|
+
<Frame>
|
|
151
|
+

|
|
152
|
+
</Frame>
|
|
130
153
|
|
|
131
154
|
Bytecode compilation moves parsing overhead for large input files from runtime to bundle time. Your app starts faster, in exchange for making the `bun build` command a little slower. It doesn't obscure source code.
|
|
132
155
|
|
|
133
|
-
|
|
156
|
+
<Warning>
|
|
157
|
+
**Experimental:** Bytecode compilation is an experimental feature introduced in Bun v1.1.30. Only `cjs` format is
|
|
158
|
+
supported (which means no top-level-await). Let us know if you run into any issues!
|
|
159
|
+
</Warning>
|
|
134
160
|
|
|
135
161
|
### What do these flags do?
|
|
136
162
|
|
|
@@ -140,68 +166,77 @@ The `--sourcemap` argument embeds a sourcemap compressed with zstd, so that erro
|
|
|
140
166
|
|
|
141
167
|
The `--bytecode` argument enables bytecode compilation. Every time you run JavaScript code in Bun, JavaScriptCore (the engine) will compile your source code into bytecode. We can move this parsing work from runtime to bundle time, saving you startup time.
|
|
142
168
|
|
|
169
|
+
---
|
|
170
|
+
|
|
143
171
|
## Embedding runtime arguments
|
|
144
172
|
|
|
145
173
|
**`--compile-exec-argv="args"`** - Embed runtime arguments that are available via `process.execArgv`:
|
|
146
174
|
|
|
147
|
-
```bash
|
|
175
|
+
```bash icon="terminal" terminal
|
|
148
176
|
bun build --compile --compile-exec-argv="--smol --user-agent=MyBot" ./app.ts --outfile myapp
|
|
149
177
|
```
|
|
150
178
|
|
|
151
|
-
```
|
|
179
|
+
```ts app.ts icon="/icons/typescript.svg"
|
|
152
180
|
// In the compiled app
|
|
153
181
|
console.log(process.execArgv); // ["--smol", "--user-agent=MyBot"]
|
|
154
182
|
```
|
|
155
183
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
{% note %}
|
|
184
|
+
---
|
|
159
185
|
|
|
160
|
-
|
|
186
|
+
## Act as the Bun CLI
|
|
161
187
|
|
|
162
|
-
|
|
188
|
+
<Note>New in Bun v1.2.16</Note>
|
|
163
189
|
|
|
164
190
|
You can run a standalone executable as if it were the `bun` CLI itself by setting the `BUN_BE_BUN=1` environment variable. When this variable is set, the executable will ignore its bundled entrypoint and instead expose all the features of Bun's CLI.
|
|
165
191
|
|
|
166
192
|
For example, consider an executable compiled from a simple script:
|
|
167
193
|
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
|
|
194
|
+
```bash icon="terminal" terminal
|
|
195
|
+
echo "console.log(\"you shouldn't see this\");" > such-bun.js
|
|
196
|
+
bun build --compile ./such-bun.js
|
|
197
|
+
```
|
|
171
198
|
|
|
172
|
-
|
|
173
|
-
|
|
199
|
+
```txt
|
|
200
|
+
[3ms] bundle 1 modules
|
|
174
201
|
[89ms] compile such-bun
|
|
175
202
|
```
|
|
176
203
|
|
|
177
|
-
Normally, running `./such-bun` with arguments would execute the script.
|
|
204
|
+
Normally, running `./such-bun` with arguments would execute the script.
|
|
178
205
|
|
|
179
|
-
```
|
|
206
|
+
```bash icon="terminal" terminal
|
|
180
207
|
# Executable runs its own entrypoint by default
|
|
181
|
-
|
|
208
|
+
./such-bun install
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
```txt
|
|
182
212
|
you shouldn't see this
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
However, with the `BUN_BE_BUN=1` environment variable, it acts just like the `bun` binary:
|
|
183
216
|
|
|
217
|
+
```bash icon="terminal" terminal
|
|
184
218
|
# With the env var, the executable acts like the `bun` CLI
|
|
185
|
-
|
|
219
|
+
bun_BE_BUN=1 ./such-bun install
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
```txt
|
|
186
223
|
bun install v1.2.16-canary.1 (1d1db811)
|
|
187
224
|
Checked 63 installs across 64 packages (no changes) [5.00ms]
|
|
188
225
|
```
|
|
189
226
|
|
|
190
227
|
This is useful for building CLI tools on top of Bun that may need to install packages, bundle dependencies, run different or local files and more without needing to download a separate binary or install bun.
|
|
191
228
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
{% note %}
|
|
229
|
+
---
|
|
195
230
|
|
|
196
|
-
|
|
231
|
+
## Full-stack executables
|
|
197
232
|
|
|
198
|
-
|
|
233
|
+
<Note>New in Bun v1.2.17</Note>
|
|
199
234
|
|
|
200
235
|
Bun's `--compile` flag can create standalone executables that contain both server and client code, making it ideal for full-stack applications. When you import an HTML file in your server code, Bun automatically bundles all frontend assets (JavaScript, CSS, etc.) and embeds them into the executable. When Bun sees the HTML import on the server, it kicks off a frontend build process to bundle JavaScript, CSS, and other assets.
|
|
201
236
|
|
|
202
|
-
|
|
237
|
+
<CodeGroup>
|
|
203
238
|
|
|
204
|
-
```ts
|
|
239
|
+
```ts server.ts icon="/icons/typescript.svg"
|
|
205
240
|
import { serve } from "bun";
|
|
206
241
|
import index from "./index.html";
|
|
207
242
|
|
|
@@ -215,12 +250,12 @@ const server = serve({
|
|
|
215
250
|
console.log(`Server running at http://localhost:${server.port}`);
|
|
216
251
|
```
|
|
217
252
|
|
|
218
|
-
```html
|
|
253
|
+
```html index.html icon="file-code"
|
|
219
254
|
<!DOCTYPE html>
|
|
220
255
|
<html>
|
|
221
256
|
<head>
|
|
222
257
|
<title>My App</title>
|
|
223
|
-
<link rel="stylesheet" href="./styles.css"
|
|
258
|
+
<link rel="stylesheet" href="./styles.css" />
|
|
224
259
|
</head>
|
|
225
260
|
<body>
|
|
226
261
|
<h1>Hello World</h1>
|
|
@@ -229,21 +264,21 @@ console.log(`Server running at http://localhost:${server.port}`);
|
|
|
229
264
|
</html>
|
|
230
265
|
```
|
|
231
266
|
|
|
232
|
-
```
|
|
267
|
+
```ts app.js icon="file-code"
|
|
233
268
|
console.log("Hello from the client!");
|
|
234
269
|
```
|
|
235
270
|
|
|
236
|
-
```css
|
|
271
|
+
```css styles.css icon="file-code"
|
|
237
272
|
body {
|
|
238
273
|
background-color: #f0f0f0;
|
|
239
274
|
}
|
|
240
275
|
```
|
|
241
276
|
|
|
242
|
-
|
|
277
|
+
</CodeGroup>
|
|
243
278
|
|
|
244
279
|
To build this into a single executable:
|
|
245
280
|
|
|
246
|
-
```
|
|
281
|
+
```bash terminal icon="terminal"
|
|
247
282
|
bun build --compile ./server.ts --outfile myapp
|
|
248
283
|
```
|
|
249
284
|
|
|
@@ -256,25 +291,27 @@ This creates a self-contained binary that includes:
|
|
|
256
291
|
|
|
257
292
|
The result is a single file that can be deployed anywhere without needing Node.js, Bun, or any dependencies installed. Just run:
|
|
258
293
|
|
|
259
|
-
```
|
|
294
|
+
```bash terminal icon="terminal"
|
|
260
295
|
./myapp
|
|
261
296
|
```
|
|
262
297
|
|
|
263
298
|
Bun automatically handles serving the frontend assets with proper MIME types and cache headers. The HTML import is replaced with a manifest object that `Bun.serve` uses to efficiently serve pre-bundled assets.
|
|
264
299
|
|
|
265
|
-
For more details on building full-stack applications with Bun, see the [full-stack guide](/
|
|
300
|
+
For more details on building full-stack applications with Bun, see the [full-stack guide](/bundler/fullstack).
|
|
301
|
+
|
|
302
|
+
---
|
|
266
303
|
|
|
267
304
|
## Worker
|
|
268
305
|
|
|
269
306
|
To use workers in a standalone executable, add the worker's entrypoint to the CLI arguments:
|
|
270
307
|
|
|
271
|
-
```
|
|
272
|
-
|
|
308
|
+
```bash terminal icon="terminal"
|
|
309
|
+
bun build --compile ./index.ts ./my-worker.ts --outfile myapp
|
|
273
310
|
```
|
|
274
311
|
|
|
275
312
|
Then, reference the worker in your code:
|
|
276
313
|
|
|
277
|
-
```ts
|
|
314
|
+
```ts index.ts icon="/icons/typescript.svg"
|
|
278
315
|
console.log("Hello from Bun!");
|
|
279
316
|
|
|
280
317
|
// Any of these will work:
|
|
@@ -289,13 +326,15 @@ In the future, we may automatically detect usages of statically-known paths in `
|
|
|
289
326
|
|
|
290
327
|
If you use a relative path to a file not included in the standalone executable, it will attempt to load that path from disk relative to the current working directory of the process (and then error if it doesn't exist).
|
|
291
328
|
|
|
329
|
+
---
|
|
330
|
+
|
|
292
331
|
## SQLite
|
|
293
332
|
|
|
294
333
|
You can use `bun:sqlite` imports with `bun build --compile`.
|
|
295
334
|
|
|
296
335
|
By default, the database is resolved relative to the current working directory of the process.
|
|
297
336
|
|
|
298
|
-
```
|
|
337
|
+
```ts index.ts icon="/icons/typescript.svg"
|
|
299
338
|
import db from "./my.db" with { type: "sqlite" };
|
|
300
339
|
|
|
301
340
|
console.log(db.query("select * from users LIMIT 1").get());
|
|
@@ -303,18 +342,20 @@ console.log(db.query("select * from users LIMIT 1").get());
|
|
|
303
342
|
|
|
304
343
|
That means if the executable is located at `/usr/bin/hello`, the user's terminal is located at `/home/me/Desktop`, it will look for `/home/me/Desktop/my.db`.
|
|
305
344
|
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
|
|
345
|
+
```bash terminal icon="terminal"
|
|
346
|
+
cd /home/me/Desktop
|
|
347
|
+
./hello
|
|
309
348
|
```
|
|
310
349
|
|
|
350
|
+
---
|
|
351
|
+
|
|
311
352
|
## Embed assets & files
|
|
312
353
|
|
|
313
354
|
Standalone executables support embedding files.
|
|
314
355
|
|
|
315
356
|
To embed files into an executable with `bun build --compile`, import the file in your code.
|
|
316
357
|
|
|
317
|
-
```ts
|
|
358
|
+
```ts index.ts icon="/icons/typescript.svg"
|
|
318
359
|
// this becomes an internal file path
|
|
319
360
|
import icon from "./icon.png" with { type: "file" };
|
|
320
361
|
import { file } from "bun";
|
|
@@ -331,7 +372,7 @@ Embedded files can be read using `Bun.file`'s functions or the Node.js `fs.readF
|
|
|
331
372
|
|
|
332
373
|
For example, to read the contents of the embedded file:
|
|
333
374
|
|
|
334
|
-
```
|
|
375
|
+
```ts index.ts icon="/icons/typescript.svg"
|
|
335
376
|
import icon from "./icon.png" with { type: "file" };
|
|
336
377
|
import { file } from "bun";
|
|
337
378
|
|
|
@@ -344,7 +385,7 @@ const bytes = await file(icon).arrayBuffer();
|
|
|
344
385
|
|
|
345
386
|
If your application wants to embed a SQLite database, set `type: "sqlite"` in the import attribute and the `embed` attribute to `"true"`.
|
|
346
387
|
|
|
347
|
-
```
|
|
388
|
+
```ts index.ts icon="/icons/typescript.svg"
|
|
348
389
|
import myEmbeddedDb from "./my.db" with { type: "sqlite", embed: "true" };
|
|
349
390
|
|
|
350
391
|
console.log(myEmbeddedDb.query("select * from users LIMIT 1").get());
|
|
@@ -356,7 +397,7 @@ This database is read-write, but all changes are lost when the executable exits
|
|
|
356
397
|
|
|
357
398
|
As of Bun v1.0.23, you can embed `.node` files into executables.
|
|
358
399
|
|
|
359
|
-
```
|
|
400
|
+
```ts index.ts icon="/icons/typescript.svg"
|
|
360
401
|
const addon = require("./addon.node");
|
|
361
402
|
|
|
362
403
|
console.log(addon.hello());
|
|
@@ -368,13 +409,13 @@ Unfortunately, if you're using `@mapbox/node-pre-gyp` or other similar tools, yo
|
|
|
368
409
|
|
|
369
410
|
To embed a directory with `bun build --compile`, use a shell glob in your `bun build` command:
|
|
370
411
|
|
|
371
|
-
```
|
|
372
|
-
|
|
412
|
+
```bash terminal icon="terminal"
|
|
413
|
+
bun build --compile ./index.ts ./public/**/*.png
|
|
373
414
|
```
|
|
374
415
|
|
|
375
416
|
Then, you can reference the files in your code:
|
|
376
417
|
|
|
377
|
-
```ts
|
|
418
|
+
```ts index.ts icon="/icons/typescript.svg"
|
|
378
419
|
import icon from "./public/assets/icon.png" with { type: "file" };
|
|
379
420
|
import { file } from "bun";
|
|
380
421
|
|
|
@@ -392,7 +433,7 @@ This is honestly a workaround, and we expect to improve this in the future with
|
|
|
392
433
|
|
|
393
434
|
To get a list of all embedded files, use `Bun.embeddedFiles`:
|
|
394
435
|
|
|
395
|
-
```
|
|
436
|
+
```ts index.ts icon="/icons/typescript.svg"
|
|
396
437
|
import "./icon.png" with { type: "file" };
|
|
397
438
|
import { embeddedFiles } from "bun";
|
|
398
439
|
|
|
@@ -413,141 +454,40 @@ By default, embedded files have a content hash appended to their name. This is u
|
|
|
413
454
|
|
|
414
455
|
To disable the content hash, pass `--asset-naming` to `bun build --compile` like this:
|
|
415
456
|
|
|
416
|
-
```
|
|
417
|
-
|
|
457
|
+
```bash terminal icon="terminal"
|
|
458
|
+
bun build --compile --asset-naming="[name].[ext]" ./index.ts
|
|
418
459
|
```
|
|
419
460
|
|
|
461
|
+
---
|
|
462
|
+
|
|
420
463
|
## Minification
|
|
421
464
|
|
|
422
465
|
To trim down the size of the executable a little, pass `--minify` to `bun build --compile`. This uses Bun's minifier to reduce the code size. Overall though, Bun's binary is still way too big and we need to make it smaller.
|
|
423
466
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
You can also generate standalone executables using the `Bun.build()` JavaScript API. This is useful when you need programmatic control over the build process.
|
|
427
|
-
|
|
428
|
-
### Basic usage
|
|
429
|
-
|
|
430
|
-
```js
|
|
431
|
-
await Bun.build({
|
|
432
|
-
entrypoints: ["./app.ts"],
|
|
433
|
-
outdir: "./dist",
|
|
434
|
-
compile: {
|
|
435
|
-
target: "bun-windows-x64",
|
|
436
|
-
outfile: "myapp.exe",
|
|
437
|
-
},
|
|
438
|
-
});
|
|
439
|
-
```
|
|
440
|
-
|
|
441
|
-
### Windows metadata with Bun.build()
|
|
442
|
-
|
|
443
|
-
When targeting Windows, you can specify metadata through the `windows` object:
|
|
444
|
-
|
|
445
|
-
```js
|
|
446
|
-
await Bun.build({
|
|
447
|
-
entrypoints: ["./app.ts"],
|
|
448
|
-
outdir: "./dist",
|
|
449
|
-
compile: {
|
|
450
|
-
target: "bun-windows-x64",
|
|
451
|
-
outfile: "myapp.exe",
|
|
452
|
-
windows: {
|
|
453
|
-
title: "My Application",
|
|
454
|
-
publisher: "My Company Inc",
|
|
455
|
-
version: "1.2.3.4",
|
|
456
|
-
description: "A powerful application built with Bun",
|
|
457
|
-
copyright: "© 2024 My Company Inc",
|
|
458
|
-
hideConsole: false, // Set to true for GUI applications
|
|
459
|
-
icon: "./icon.ico", // Path to icon file
|
|
460
|
-
},
|
|
461
|
-
},
|
|
462
|
-
});
|
|
463
|
-
```
|
|
464
|
-
|
|
465
|
-
### Cross-compilation with Bun.build()
|
|
466
|
-
|
|
467
|
-
You can cross-compile for different platforms:
|
|
468
|
-
|
|
469
|
-
```js
|
|
470
|
-
// Build for multiple platforms
|
|
471
|
-
const platforms = [
|
|
472
|
-
{ target: "bun-windows-x64", outfile: "app-windows.exe" },
|
|
473
|
-
{ target: "bun-linux-x64", outfile: "app-linux" },
|
|
474
|
-
{ target: "bun-darwin-arm64", outfile: "app-macos" },
|
|
475
|
-
];
|
|
476
|
-
|
|
477
|
-
for (const platform of platforms) {
|
|
478
|
-
await Bun.build({
|
|
479
|
-
entrypoints: ["./app.ts"],
|
|
480
|
-
outdir: "./dist",
|
|
481
|
-
compile: platform,
|
|
482
|
-
});
|
|
483
|
-
}
|
|
484
|
-
```
|
|
467
|
+
---
|
|
485
468
|
|
|
486
469
|
## Windows-specific flags
|
|
487
470
|
|
|
488
|
-
When compiling a standalone executable
|
|
489
|
-
|
|
490
|
-
### Visual customization
|
|
491
|
-
|
|
492
|
-
- `--windows-icon=path/to/icon.ico` - Set the executable file icon
|
|
493
|
-
- `--windows-hide-console` - Disable the background terminal window (useful for GUI applications)
|
|
494
|
-
|
|
495
|
-
### Metadata customization
|
|
496
|
-
|
|
497
|
-
You can embed version information and other metadata into your Windows executable:
|
|
498
|
-
|
|
499
|
-
- `--windows-title <STR>` - Set the product name (appears in file properties)
|
|
500
|
-
- `--windows-publisher <STR>` - Set the company name
|
|
501
|
-
- `--windows-version <STR>` - Set the version number (e.g. "1.2.3.4")
|
|
502
|
-
- `--windows-description <STR>` - Set the file description
|
|
503
|
-
- `--windows-copyright <STR>` - Set the copyright information
|
|
504
|
-
|
|
505
|
-
#### Example with all metadata flags:
|
|
506
|
-
|
|
507
|
-
```sh
|
|
508
|
-
bun build --compile ./app.ts \
|
|
509
|
-
--outfile myapp.exe \
|
|
510
|
-
--windows-title "My Application" \
|
|
511
|
-
--windows-publisher "My Company Inc" \
|
|
512
|
-
--windows-version "1.2.3.4" \
|
|
513
|
-
--windows-description "A powerful application built with Bun" \
|
|
514
|
-
--windows-copyright "© 2024 My Company Inc"
|
|
515
|
-
```
|
|
516
|
-
|
|
517
|
-
This metadata will be visible in Windows Explorer when viewing the file properties:
|
|
518
|
-
|
|
519
|
-
1. Right-click the executable in Windows Explorer
|
|
520
|
-
2. Select "Properties"
|
|
521
|
-
3. Go to the "Details" tab
|
|
522
|
-
|
|
523
|
-
#### Version string format
|
|
471
|
+
When compiling a standalone executable on Windows, there are two platform-specific options that can be used to customize metadata on the generated `.exe` file:
|
|
524
472
|
|
|
525
|
-
|
|
473
|
+
- `--windows-icon=path/to/icon.ico` to customize the executable file icon.
|
|
474
|
+
- `--windows-hide-console` to disable the background terminal, which can be used for applications that do not need a TTY.
|
|
526
475
|
|
|
527
|
-
|
|
528
|
-
- `"1.2"` - Will be normalized to "1.2.0.0"
|
|
529
|
-
- `"1.2.3"` - Will be normalized to "1.2.3.0"
|
|
530
|
-
- `"1.2.3.4"` - Full version format
|
|
476
|
+
<Warning>These flags currently cannot be used when cross-compiling because they depend on Windows APIs.</Warning>
|
|
531
477
|
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
{% callout %}
|
|
535
|
-
|
|
536
|
-
These flags currently cannot be used when cross-compiling because they depend on Windows APIs. They are only available when building on Windows itself.
|
|
537
|
-
|
|
538
|
-
{% /callout %}
|
|
478
|
+
---
|
|
539
479
|
|
|
540
480
|
## Code signing on macOS
|
|
541
481
|
|
|
542
482
|
To codesign a standalone executable on macOS (which fixes Gatekeeper warnings), use the `codesign` command.
|
|
543
483
|
|
|
544
|
-
```
|
|
545
|
-
|
|
484
|
+
```bash terminal icon="terminal"
|
|
485
|
+
codesign --deep --force -vvvv --sign "XXXXXXXXXX" ./myapp
|
|
546
486
|
```
|
|
547
487
|
|
|
548
488
|
We recommend including an `entitlements.plist` file with JIT permissions.
|
|
549
489
|
|
|
550
|
-
```xml
|
|
490
|
+
```xml icon="xml" title="info.plist"
|
|
551
491
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
552
492
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
553
493
|
<plist version="1.0">
|
|
@@ -568,59 +508,28 @@ We recommend including an `entitlements.plist` file with JIT permissions.
|
|
|
568
508
|
|
|
569
509
|
To codesign with JIT support, pass the `--entitlements` flag to `codesign`.
|
|
570
510
|
|
|
571
|
-
```
|
|
572
|
-
|
|
511
|
+
```bash terminal icon="terminal"
|
|
512
|
+
codesign --deep --force -vvvv --sign "XXXXXXXXXX" --entitlements entitlements.plist ./myapp
|
|
573
513
|
```
|
|
574
514
|
|
|
575
515
|
After codesigning, verify the executable:
|
|
576
516
|
|
|
577
|
-
```
|
|
578
|
-
|
|
517
|
+
```bash terminal icon="terminal"
|
|
518
|
+
codesign -vvv --verify ./myapp
|
|
579
519
|
./myapp: valid on disk
|
|
580
520
|
./myapp: satisfies its Designated Requirement
|
|
581
521
|
```
|
|
582
522
|
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
Codesign support requires Bun v1.2.4 or newer.
|
|
586
|
-
|
|
587
|
-
{% /callout %}
|
|
588
|
-
|
|
589
|
-
## Code splitting
|
|
590
|
-
|
|
591
|
-
Standalone executables support code splitting. Use `--compile` with `--splitting` to create an executable that loads code-split chunks at runtime.
|
|
592
|
-
|
|
593
|
-
```bash
|
|
594
|
-
$ bun build --compile --splitting ./src/entry.ts --outdir ./build
|
|
595
|
-
```
|
|
523
|
+
<Warning>Codesign support requires Bun v1.2.4 or newer.</Warning>
|
|
596
524
|
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
```ts#src/entry.ts
|
|
600
|
-
console.log("Entrypoint loaded");
|
|
601
|
-
const lazy = await import("./lazy.ts");
|
|
602
|
-
lazy.hello();
|
|
603
|
-
```
|
|
604
|
-
|
|
605
|
-
```ts#src/lazy.ts
|
|
606
|
-
export function hello() {
|
|
607
|
-
console.log("Lazy module loaded");
|
|
608
|
-
}
|
|
609
|
-
```
|
|
610
|
-
|
|
611
|
-
{% /codetabs %}
|
|
612
|
-
|
|
613
|
-
```bash
|
|
614
|
-
$ ./build/entry
|
|
615
|
-
Entrypoint loaded
|
|
616
|
-
Lazy module loaded
|
|
617
|
-
```
|
|
525
|
+
---
|
|
618
526
|
|
|
619
527
|
## Unsupported CLI arguments
|
|
620
528
|
|
|
621
529
|
Currently, the `--compile` flag can only accept a single entrypoint at a time and does not support the following flags:
|
|
622
530
|
|
|
623
|
-
- `--outdir` — use `outfile` instead
|
|
531
|
+
- `--outdir` — use `outfile` instead.
|
|
532
|
+
- `--splitting`
|
|
624
533
|
- `--public-path`
|
|
625
534
|
- `--target=node` or `--target=browser`
|
|
626
535
|
- `--no-bundle` - we always bundle everything into the executable.
|