prjct-cli 0.35.2 → 0.35.4

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.
Files changed (406) hide show
  1. package/core/commands/analysis.ts +58 -32
  2. package/core/commands/command-data.ts +11 -50
  3. package/core/commands/commands.ts +18 -21
  4. package/core/commands/context.ts +238 -0
  5. package/core/commands/register.ts +7 -5
  6. package/core/commands/setup.ts +1 -17
  7. package/core/commands/workflow.ts +3 -2
  8. package/core/index.ts +2 -4
  9. package/core/services/index.ts +2 -0
  10. package/core/services/sync-service.ts +1080 -0
  11. package/core/types/commands.ts +0 -12
  12. package/core/types/index.ts +0 -1
  13. package/dist/bin/prjct.mjs +1219 -310
  14. package/package.json +2 -8
  15. package/templates/_bases/tracker-base.md +309 -0
  16. package/templates/agentic/agent-routing.md +22 -88
  17. package/templates/agentic/agents/uxui.md +42 -197
  18. package/templates/agentic/context-filtering.md +14 -56
  19. package/templates/agentic/orchestrator.md +31 -365
  20. package/templates/agentic/skill-integration.md +37 -289
  21. package/templates/agentic/subagent-generation.md +31 -104
  22. package/templates/agentic/task-fragmentation.md +39 -273
  23. package/templates/agents/AGENTS.md +32 -188
  24. package/templates/commands/bug.md +22 -520
  25. package/templates/commands/dash.md +26 -161
  26. package/templates/commands/done.md +19 -250
  27. package/templates/commands/enrich.md +21 -732
  28. package/templates/commands/github.md +9 -0
  29. package/templates/commands/history.md +296 -83
  30. package/templates/commands/idea.md +18 -160
  31. package/templates/commands/init.md +20 -209
  32. package/templates/commands/jira.md +9 -0
  33. package/templates/commands/linear.md +9 -0
  34. package/templates/commands/merge.md +21 -185
  35. package/templates/commands/monday.md +9 -0
  36. package/templates/commands/next.md +21 -103
  37. package/templates/commands/p.md +198 -63
  38. package/templates/commands/pause.md +21 -272
  39. package/templates/commands/resume.md +19 -348
  40. package/templates/commands/setup.md +0 -1
  41. package/templates/commands/ship.md +30 -627
  42. package/templates/commands/sync.md +11 -1345
  43. package/templates/commands/task.md +17 -439
  44. package/templates/commands/test.md +30 -259
  45. package/CLAUDE.md +0 -211
  46. package/packages/shared/node_modules/@types/bun/LICENSE +0 -21
  47. package/packages/shared/node_modules/@types/bun/README.md +0 -20
  48. package/packages/shared/node_modules/@types/bun/index.d.ts +0 -1
  49. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/CLAUDE.md +0 -105
  50. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/README.md +0 -33
  51. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/bun.d.ts +0 -7032
  52. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/bun.ns.d.ts +0 -5
  53. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/bundle.d.ts +0 -74
  54. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/deprecated.d.ts +0 -184
  55. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/devserver.d.ts +0 -187
  56. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/README.md +0 -28
  57. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/bundler/bytecode.mdx +0 -465
  58. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/bundler/css.mdx +0 -1024
  59. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/bundler/esbuild.mdx +0 -298
  60. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/bundler/executables.mdx +0 -1277
  61. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/bundler/fullstack.mdx +0 -1086
  62. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/bundler/hot-reloading.mdx +0 -229
  63. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/bundler/html-static.mdx +0 -488
  64. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/bundler/index.mdx +0 -1604
  65. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/bundler/loaders.mdx +0 -451
  66. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/bundler/macros.mdx +0 -328
  67. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/bundler/minifier.mdx +0 -1286
  68. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/bundler/plugins.mdx +0 -425
  69. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/feedback.mdx +0 -75
  70. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/arraybuffer-to-array.mdx +0 -29
  71. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/arraybuffer-to-blob.mdx +0 -26
  72. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/arraybuffer-to-buffer.mdx +0 -27
  73. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/arraybuffer-to-string.mdx +0 -17
  74. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/arraybuffer-to-typedarray.mdx +0 -41
  75. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/blob-to-arraybuffer.mdx +0 -16
  76. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/blob-to-dataview.mdx +0 -16
  77. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/blob-to-stream.mdx +0 -16
  78. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/blob-to-string.mdx +0 -17
  79. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/blob-to-typedarray.mdx +0 -16
  80. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/buffer-to-arraybuffer.mdx +0 -16
  81. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/buffer-to-blob.mdx +0 -16
  82. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/buffer-to-readablestream.mdx +0 -43
  83. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/buffer-to-string.mdx +0 -27
  84. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/buffer-to-typedarray.mdx +0 -16
  85. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/dataview-to-string.mdx +0 -17
  86. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/typedarray-to-arraybuffer.mdx +0 -27
  87. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/typedarray-to-blob.mdx +0 -18
  88. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/typedarray-to-buffer.mdx +0 -16
  89. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/typedarray-to-dataview.mdx +0 -16
  90. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/typedarray-to-readablestream.mdx +0 -43
  91. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/binary/typedarray-to-string.mdx +0 -18
  92. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/deployment/aws-lambda.mdx +0 -204
  93. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/deployment/digital-ocean.mdx +0 -161
  94. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/deployment/google-cloud-run.mdx +0 -194
  95. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/deployment/railway.mdx +0 -145
  96. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/deployment/render.mdx +0 -82
  97. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/deployment/vercel.mdx +0 -97
  98. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/astro.mdx +0 -82
  99. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/discordjs.mdx +0 -80
  100. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/docker.mdx +0 -151
  101. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/drizzle.mdx +0 -195
  102. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/elysia.mdx +0 -31
  103. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/express.mdx +0 -43
  104. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/gel.mdx +0 -261
  105. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/hono.mdx +0 -47
  106. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/mongoose.mdx +0 -92
  107. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/neon-drizzle.mdx +0 -234
  108. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/neon-serverless-postgres.mdx +0 -60
  109. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/nextjs.mdx +0 -103
  110. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/nuxt.mdx +0 -96
  111. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/pm2.mdx +0 -55
  112. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/prisma-postgres.mdx +0 -169
  113. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/prisma.mdx +0 -164
  114. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/qwik.mdx +0 -114
  115. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/react.mdx +0 -52
  116. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/remix.mdx +0 -97
  117. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/sentry.mdx +0 -54
  118. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/solidstart.mdx +0 -62
  119. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/ssr-react.mdx +0 -49
  120. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/stric.mdx +0 -54
  121. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/sveltekit.mdx +0 -138
  122. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/systemd.mdx +0 -114
  123. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/tanstack-start.mdx +0 -791
  124. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/upstash.mdx +0 -87
  125. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/ecosystem/vite.mdx +0 -77
  126. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/html-rewriter/extract-links.mdx +0 -71
  127. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/html-rewriter/extract-social-meta.mdx +0 -97
  128. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/http/cluster.mdx +0 -69
  129. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/http/fetch-unix.mdx +0 -35
  130. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/http/fetch.mdx +0 -26
  131. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/http/file-uploads.mdx +0 -97
  132. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/http/hot.mdx +0 -28
  133. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/http/proxy.mdx +0 -50
  134. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/http/server.mdx +0 -48
  135. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/http/simple.mdx +0 -20
  136. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/http/stream-file.mdx +0 -50
  137. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/http/stream-iterator.mdx +0 -49
  138. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/http/stream-node-streams-in-bun.mdx +0 -22
  139. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/http/tls.mdx +0 -32
  140. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/index.mdx +0 -10
  141. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/add-dev.mdx +0 -28
  142. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/add-git.mdx +0 -40
  143. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/add-optional.mdx +0 -27
  144. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/add-peer.mdx +0 -45
  145. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/add-tarball.mdx +0 -35
  146. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/add.mdx +0 -44
  147. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/azure-artifacts.mdx +0 -76
  148. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/cicd.mdx +0 -43
  149. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/custom-registry.mdx +0 -32
  150. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/from-npm-install-to-bun-install.mdx +0 -230
  151. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/git-diff-bun-lockfile.mdx +0 -48
  152. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/jfrog-artifactory.mdx +0 -28
  153. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/npm-alias.mdx +0 -25
  154. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/registry-scope.mdx +0 -40
  155. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/trusted.mdx +0 -52
  156. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/workspaces.mdx +0 -70
  157. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/install/yarnlock.mdx +0 -51
  158. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/process/argv.mdx +0 -66
  159. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/process/ctrl-c.mdx +0 -18
  160. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/process/ipc.mdx +0 -69
  161. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/process/nanoseconds.mdx +0 -15
  162. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/process/os-signals.mdx +0 -31
  163. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/process/spawn-stderr.mdx +0 -34
  164. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/process/spawn-stdout.mdx +0 -28
  165. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/process/spawn.mdx +0 -43
  166. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/process/stdin.mdx +0 -62
  167. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/read-file/arraybuffer.mdx +0 -30
  168. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/read-file/buffer.mdx +0 -21
  169. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/read-file/exists.mdx +0 -18
  170. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/read-file/json.mdx +0 -19
  171. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/read-file/mime.mdx +0 -22
  172. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/read-file/stream.mdx +0 -28
  173. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/read-file/string.mdx +0 -24
  174. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/read-file/uint8array.mdx +0 -23
  175. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/read-file/watch.mdx +0 -66
  176. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/build-time-constants.mdx +0 -295
  177. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/cicd.mdx +0 -45
  178. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/codesign-macos-executable.mdx +0 -61
  179. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/define-constant.mdx +0 -149
  180. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/delete-directory.mdx +0 -39
  181. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/delete-file.mdx +0 -21
  182. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/heap-snapshot.mdx +0 -28
  183. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/import-html.mdx +0 -15
  184. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/import-json.mdx +0 -46
  185. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/import-toml.mdx +0 -32
  186. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/import-yaml.mdx +0 -104
  187. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/read-env.mdx +0 -37
  188. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/set-env.mdx +0 -51
  189. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/shell.mdx +0 -42
  190. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/timezone.mdx +0 -38
  191. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/tsconfig-paths.mdx +0 -31
  192. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/typescript.mdx +0 -51
  193. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/vscode-debugger.mdx +0 -47
  194. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/runtime/web-debugger.mdx +0 -103
  195. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/streams/node-readable-to-arraybuffer.mdx +0 -13
  196. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/streams/node-readable-to-blob.mdx +0 -13
  197. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/streams/node-readable-to-json.mdx +0 -14
  198. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/streams/node-readable-to-string.mdx +0 -14
  199. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/streams/node-readable-to-uint8array.mdx +0 -13
  200. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/streams/to-array.mdx +0 -16
  201. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/streams/to-arraybuffer.mdx +0 -16
  202. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/streams/to-blob.mdx +0 -16
  203. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/streams/to-buffer.mdx +0 -17
  204. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/streams/to-json.mdx +0 -16
  205. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/streams/to-string.mdx +0 -16
  206. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/streams/to-typedarray.mdx +0 -24
  207. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/bail.mdx +0 -24
  208. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/concurrent-test-glob.mdx +0 -146
  209. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/coverage-threshold.mdx +0 -67
  210. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/coverage.mdx +0 -49
  211. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/happy-dom.mdx +0 -73
  212. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/migrate-from-jest.mdx +0 -125
  213. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/mock-clock.mdx +0 -50
  214. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/mock-functions.mdx +0 -70
  215. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/rerun-each.mdx +0 -16
  216. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/run-tests.mdx +0 -116
  217. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/skip-tests.mdx +0 -43
  218. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/snapshot.mdx +0 -102
  219. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/spy-on.mdx +0 -49
  220. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/svelte-test.mdx +0 -113
  221. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/testing-library.mdx +0 -93
  222. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/timeout.mdx +0 -17
  223. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/todo-tests.mdx +0 -74
  224. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/update-snapshots.mdx +0 -49
  225. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/test/watch-mode.mdx +0 -24
  226. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/base64.mdx +0 -17
  227. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/deep-equals.mdx +0 -41
  228. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/deflate.mdx +0 -20
  229. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/detect-bun.mdx +0 -28
  230. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/entrypoint.mdx +0 -19
  231. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/escape-html.mdx +0 -24
  232. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/file-url-to-path.mdx +0 -16
  233. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/gzip.mdx +0 -20
  234. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/hash-a-password.mdx +0 -56
  235. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/import-meta-dir.mdx +0 -15
  236. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/import-meta-file.mdx +0 -15
  237. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/import-meta-path.mdx +0 -15
  238. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/javascript-uuid.mdx +0 -25
  239. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/main.mdx +0 -43
  240. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/path-to-file-url.mdx +0 -16
  241. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/sleep.mdx +0 -24
  242. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/upgrade.mdx +0 -93
  243. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/version.mdx +0 -23
  244. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/util/which-path-to-executable-bin.mdx +0 -17
  245. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/websocket/compression.mdx +0 -33
  246. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/websocket/context.mdx +0 -79
  247. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/websocket/pubsub.mdx +0 -43
  248. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/websocket/simple.mdx +0 -38
  249. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/write-file/append.mdx +0 -54
  250. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/write-file/basic.mdx +0 -46
  251. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/write-file/blob.mdx +0 -30
  252. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/write-file/cat.mdx +0 -19
  253. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/write-file/file-cp.mdx +0 -18
  254. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/write-file/filesink.mdx +0 -54
  255. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/write-file/response.mdx +0 -19
  256. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/write-file/stdout.mdx +0 -23
  257. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/write-file/stream.mdx +0 -19
  258. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/guides/write-file/unlink.mdx +0 -18
  259. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/index.mdx +0 -133
  260. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/installation.mdx +0 -365
  261. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/bunx.mdx +0 -91
  262. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/catalogs.mdx +0 -292
  263. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/cli/add.mdx +0 -179
  264. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/cli/audit.mdx +0 -60
  265. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/cli/info.mdx +0 -70
  266. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/cli/install.mdx +0 -606
  267. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/cli/link.mdx +0 -61
  268. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/cli/outdated.mdx +0 -197
  269. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/cli/patch.mdx +0 -69
  270. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/cli/pm.mdx +0 -323
  271. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/cli/publish.mdx +0 -131
  272. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/cli/remove.mdx +0 -16
  273. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/cli/update.mdx +0 -140
  274. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/cli/why.mdx +0 -84
  275. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/filter.mdx +0 -102
  276. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/global-cache.mdx +0 -72
  277. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/isolated-installs.mdx +0 -220
  278. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/lifecycle.mdx +0 -64
  279. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/lockfile.mdx +0 -64
  280. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/npmrc.mdx +0 -111
  281. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/overrides.mdx +0 -83
  282. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/scopes-registries.mdx +0 -35
  283. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/security-scanner-api.mdx +0 -95
  284. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/pm/workspaces.mdx +0 -115
  285. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/project/benchmarking.mdx +0 -241
  286. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/project/bindgen.mdx +0 -223
  287. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/project/building-windows.mdx +0 -133
  288. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/project/contributing.mdx +0 -388
  289. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/project/feedback.mdx +0 -20
  290. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/project/license.mdx +0 -78
  291. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/project/roadmap.mdx +0 -8
  292. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/quickstart.mdx +0 -251
  293. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/auto-install.mdx +0 -97
  294. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/binary-data.mdx +0 -846
  295. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/bun-apis.mdx +0 -59
  296. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/bunfig.mdx +0 -723
  297. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/c-compiler.mdx +0 -204
  298. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/child-process.mdx +0 -659
  299. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/color.mdx +0 -267
  300. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/console.mdx +0 -67
  301. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/cookies.mdx +0 -454
  302. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/debugger.mdx +0 -335
  303. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/environment-variables.mdx +0 -231
  304. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/ffi.mdx +0 -565
  305. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/file-io.mdx +0 -306
  306. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/file-system-router.mdx +0 -118
  307. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/file-types.mdx +0 -435
  308. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/glob.mdx +0 -181
  309. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/globals.mdx +0 -72
  310. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/hashing.mdx +0 -315
  311. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/html-rewriter.mdx +0 -333
  312. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/http/cookies.mdx +0 -79
  313. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/http/error-handling.mdx +0 -40
  314. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/http/metrics.mdx +0 -36
  315. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/http/routing.mdx +0 -289
  316. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/http/server.mdx +0 -645
  317. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/http/tls.mdx +0 -101
  318. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/http/websockets.mdx +0 -414
  319. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/index.mdx +0 -223
  320. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/jsx.mdx +0 -115
  321. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/module-resolution.mdx +0 -374
  322. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/networking/dns.mdx +0 -111
  323. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/networking/fetch.mdx +0 -484
  324. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/networking/tcp.mdx +0 -239
  325. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/networking/udp.mdx +0 -129
  326. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/node-api.mdx +0 -19
  327. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/nodejs-compat.mdx +0 -468
  328. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/plugins.mdx +0 -419
  329. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/redis.mdx +0 -583
  330. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/s3.mdx +0 -863
  331. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/secrets.mdx +0 -340
  332. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/semver.mdx +0 -57
  333. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/shell.mdx +0 -637
  334. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/sql.mdx +0 -1404
  335. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/sqlite.mdx +0 -721
  336. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/streams.mdx +0 -232
  337. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/templating/create.mdx +0 -269
  338. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/templating/init.mdx +0 -58
  339. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/transpiler.mdx +0 -288
  340. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/typescript.mdx +0 -58
  341. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/utils.mdx +0 -922
  342. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/watch-mode.mdx +0 -161
  343. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/web-apis.mdx +0 -29
  344. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/workers.mdx +0 -314
  345. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/runtime/yaml.mdx +0 -469
  346. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/snippets/cli/add.mdx +0 -166
  347. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/snippets/cli/build.mdx +0 -196
  348. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/snippets/cli/bunx.mdx +0 -49
  349. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/snippets/cli/feedback.mdx +0 -17
  350. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/snippets/cli/init.mdx +0 -84
  351. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/snippets/cli/install.mdx +0 -173
  352. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/snippets/cli/link.mdx +0 -163
  353. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/snippets/cli/outdated.mdx +0 -140
  354. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/snippets/cli/patch.mdx +0 -171
  355. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/snippets/cli/publish.mdx +0 -198
  356. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/snippets/cli/remove.mdx +0 -146
  357. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/snippets/cli/run.mdx +0 -293
  358. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/snippets/cli/test.mdx +0 -100
  359. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/snippets/cli/update.mdx +0 -144
  360. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/test/code-coverage.mdx +0 -409
  361. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/test/configuration.mdx +0 -514
  362. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/test/dates-times.mdx +0 -129
  363. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/test/discovery.mdx +0 -90
  364. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/test/dom.mdx +0 -226
  365. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/test/index.mdx +0 -380
  366. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/test/lifecycle.mdx +0 -366
  367. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/test/mocks.mdx +0 -637
  368. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/test/reporters.mdx +0 -126
  369. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/test/runtime-behavior.mdx +0 -342
  370. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/test/snapshots.mdx +0 -434
  371. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/test/writing-tests.mdx +0 -672
  372. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/docs/typescript.mdx +0 -54
  373. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/extensions.d.ts +0 -35
  374. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/fetch.d.ts +0 -79
  375. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/ffi.d.ts +0 -1154
  376. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/globals.d.ts +0 -2067
  377. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/html-rewriter.d.ts +0 -186
  378. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/index.d.ts +0 -32
  379. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/jsc.d.ts +0 -233
  380. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/overrides.d.ts +0 -376
  381. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/package.json +0 -37
  382. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/redis.d.ts +0 -3352
  383. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/s3.d.ts +0 -1299
  384. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/security.d.ts +0 -101
  385. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/serve.d.ts +0 -1296
  386. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/shell.d.ts +0 -380
  387. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/sql.d.ts +0 -887
  388. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/sqlite.d.ts +0 -1321
  389. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/test-globals.d.ts +0 -22
  390. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/test.d.ts +0 -2391
  391. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/vendor/expect-type/branding.d.ts +0 -283
  392. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/vendor/expect-type/index.d.ts +0 -1207
  393. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/vendor/expect-type/messages.d.ts +0 -395
  394. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/vendor/expect-type/overloads.d.ts +0 -669
  395. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/vendor/expect-type/utils.d.ts +0 -431
  396. package/packages/shared/node_modules/@types/bun/node_modules/bun-types/wasm.d.ts +0 -193
  397. package/packages/shared/node_modules/@types/bun/package.json +0 -53
  398. package/packages/shared/package.json +0 -29
  399. package/packages/shared/src/index.ts +0 -10
  400. package/packages/shared/src/schemas.ts +0 -124
  401. package/packages/shared/src/types.ts +0 -187
  402. package/packages/shared/src/unified.ts +0 -174
  403. package/packages/shared/src/utils.ts +0 -148
  404. package/packages/shared/tsconfig.json +0 -18
  405. package/templates/commands/redo.md +0 -144
  406. package/templates/commands/undo.md +0 -154
@@ -1,1604 +0,0 @@
1
- ---
2
- title: Bundler
3
- description: Bun's fast native bundler for JavaScript, TypeScript, JSX, and more
4
- ---
5
-
6
- import Build from "/snippets/cli/build.mdx";
7
-
8
- Bun's fast native bundler can be used via the `bun build` CLI command or the `Bun.build()` JavaScript API.
9
-
10
- ### At a Glance
11
-
12
- - JS API: `await Bun.build({ entrypoints, outdir })`
13
- - CLI: `bun build <entry> --outdir ./out`
14
- - Watch: `--watch` for incremental rebuilds
15
- - Targets: `--target browser|bun|node`
16
- - Formats: `--format esm|cjs|iife` (experimental for cjs/iife)
17
-
18
- <Tabs>
19
- <Tab title="JavaScript">
20
- ```ts title="build.ts" icon="/icons/typescript.svg"
21
- await Bun.build({
22
- entrypoints: ['./index.tsx'],
23
- outdir: './build',
24
- });
25
- ```
26
- </Tab>
27
- <Tab title="CLI">
28
- ```bash terminal icon="terminal"
29
- bun build ./index.tsx --outdir ./build
30
- ```
31
- </Tab>
32
- </Tabs>
33
-
34
- It's fast. The numbers below represent performance on esbuild's [three.js benchmark](https://github.com/oven-sh/bun/tree/main/bench/bundle).
35
-
36
- <Frame>
37
- <img
38
- src="/images/bundler-speed.png"
39
- caption="Bundling 10 copies of three.js from scratch, with sourcemaps and minification"
40
- />
41
- </Frame>
42
-
43
- ## Why bundle?
44
-
45
- The bundler is a key piece of infrastructure in the JavaScript ecosystem. As a brief overview of why bundling is so important:
46
-
47
- - **Reducing HTTP requests.** A single package in `node_modules` may consist of hundreds of files, and large applications may have dozens of such dependencies. Loading each of these files with a separate HTTP request becomes untenable very quickly, so bundlers are used to convert our application source code into a smaller number of self-contained "bundles" that can be loaded with a single request.
48
- - **Code transforms.** Modern apps are commonly built with languages or tools like TypeScript, JSX, and CSS modules, all of which must be converted into plain JavaScript and CSS before they can be consumed by a browser. The bundler is the natural place to configure these transformations.
49
- - **Framework features.** Frameworks rely on bundler plugins & code transformations to implement common patterns like file-system routing, client-server code co-location (think `getServerSideProps` or Remix loaders), and server components.
50
- - **Full-stack Applications.** Bun's bundler can handle both server and client code in a single command, enabling optimized production builds and single-file executables. With build-time HTML imports, you can bundle your entire application — frontend assets and backend server — into a single deployable unit.
51
-
52
- Let's jump into the bundler API.
53
-
54
- <Note>The Bun bundler is not intended to replace `tsc` for typechecking or generating type declarations.</Note>
55
-
56
- ## Basic example
57
-
58
- Let's build our first bundle. You have the following two files, which implement a simple client-side rendered React app.
59
-
60
- <CodeGroup>
61
-
62
- ```tsx index.tsx icon="/icons/typescript.svg"
63
- import * as ReactDOM from "react-dom/client";
64
- import { Component } from "./Component";
65
-
66
- const root = ReactDOM.createRoot(document.getElementById("root")!);
67
- root.render(<Component message="Sup!" />);
68
- ```
69
-
70
- ```tsx Component.tsx icon="/icons/typescript.svg"
71
- export function Component(props: { message: string }) {
72
- return <h1>{props.message}</h1>;
73
- }
74
- ```
75
-
76
- </CodeGroup>
77
-
78
- Here, `index.tsx` is the "entrypoint" to our application. Commonly, this will be a script that performs some side effect, like starting a server or—in this case—initializing a React root. Because we're using TypeScript & JSX, we need to bundle our code before it can be sent to the browser.
79
-
80
- To create our bundle:
81
-
82
- <CodeGroup>
83
-
84
- ```ts build.ts icon="/icons/typescript.svg"
85
- await Bun.build({
86
- entrypoints: ["./index.tsx"],
87
- outdir: "./out",
88
- });
89
- ```
90
-
91
- ```bash terminal icon="terminal"
92
- bun build ./index.tsx --outdir ./out
93
- ```
94
-
95
- </CodeGroup>
96
-
97
- For each file specified in `entrypoints`, Bun will generate a new bundle. This bundle will be written to disk in the `./out` directory (as resolved from the current working directory). After running the build, the file system looks like this:
98
-
99
- ```text title="file system" icon="folder-tree"
100
- .
101
- ├── index.tsx
102
- ├── Component.tsx
103
- └── out
104
- └── index.js
105
- ```
106
-
107
- The contents of `out/index.js` will look something like this:
108
-
109
- ```js title="out/index.js" icon="/icons/javascript.svg"
110
- // out/index.js
111
- // ...
112
- // ~20k lines of code
113
- // including the contents of `react-dom/client` and all its dependencies
114
- // this is where the $jsxDEV and $createRoot functions are defined
115
-
116
- // Component.tsx
117
- function Component(props) {
118
- return $jsxDEV(
119
- "p",
120
- {
121
- children: props.message,
122
- },
123
- undefined,
124
- false,
125
- undefined,
126
- this,
127
- );
128
- }
129
-
130
- // index.tsx
131
- var rootNode = document.getElementById("root");
132
- var root = $createRoot(rootNode);
133
- root.render(
134
- $jsxDEV(
135
- Component,
136
- {
137
- message: "Sup!",
138
- },
139
- undefined,
140
- false,
141
- undefined,
142
- this,
143
- ),
144
- );
145
- ```
146
-
147
- ## Watch mode
148
-
149
- Like the runtime and test runner, the bundler supports watch mode natively.
150
-
151
- ```bash terminal icon="terminal"
152
- bun build ./index.tsx --outdir ./out --watch
153
- ```
154
-
155
- ## Content types
156
-
157
- Like the Bun runtime, the bundler supports an array of file types out of the box. The following table breaks down the bundler's set of standard "loaders". Refer to [Bundler > File types](/docs/bundler/loaders) for full documentation.
158
-
159
- | Extensions | Details |
160
- | ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
161
- | `.js` `.jsx` `.cjs` `.mjs` `.mts` `.cts` `.ts` `.tsx` | Uses Bun's built-in transpiler to parse the file and transpile TypeScript/JSX syntax to vanilla JavaScript. The bundler executes a set of default transforms including dead code elimination and tree shaking. At the moment Bun does not attempt to down-convert syntax; if you use recently ECMAScript syntax, that will be reflected in the bundled code. |
162
- | `.json` | JSON files are parsed and inlined into the bundle as a JavaScript object.<br/><br/>`js<br/>import pkg from "./package.json";<br/>pkg.name; // => "my-package"<br/>` |
163
- | `.jsonc` | JSON with comments. Files are parsed and inlined into the bundle as a JavaScript object.<br/><br/>`js<br/>import config from "./config.jsonc";<br/>config.name; // => "my-config"<br/>` |
164
- | `.toml` | TOML files are parsed and inlined into the bundle as a JavaScript object.<br/><br/>`js<br/>import config from "./bunfig.toml";<br/>config.logLevel; // => "debug"<br/>` |
165
- | `.yaml` `.yml` | YAML files are parsed and inlined into the bundle as a JavaScript object.<br/><br/>`js<br/>import config from "./config.yaml";<br/>config.name; // => "my-app"<br/>` |
166
- | `.txt` | The contents of the text file are read and inlined into the bundle as a string.<br/><br/>`js<br/>import contents from "./file.txt";<br/>console.log(contents); // => "Hello, world!"<br/>` |
167
- | `.html` | HTML files are processed and any referenced assets (scripts, stylesheets, images) are bundled. |
168
- | `.css` | CSS files are bundled together into a single `.css` file in the output directory. |
169
- | `.node` `.wasm` | These files are supported by the Bun runtime, but during bundling they are treated as assets. |
170
-
171
- ### Assets
172
-
173
- If the bundler encounters an import with an unrecognized extension, it treats the imported file as an external file. The referenced file is copied as-is into `outdir`, and the import is resolved as a path to the file.
174
-
175
- <CodeGroup>
176
-
177
- ```ts Input icon="/icons/typescript.svg"
178
- // bundle entrypoint
179
- import logo from "./logo.svg";
180
- console.log(logo);
181
- ```
182
-
183
- ```ts Output icon="/icons/javascript.svg"
184
- // bundled output
185
- var logo = "./logo-a7305bdef.svg";
186
- console.log(logo);
187
- ```
188
-
189
- </CodeGroup>
190
-
191
- The exact behavior of the file loader is also impacted by [`naming`](#naming) and [`publicPath`](#publicpath).
192
-
193
- <Info>Refer to the [Bundler > Loaders](/docs/bundler/loaders) page for more complete documentation on the file loader.</Info>
194
-
195
- ### Plugins
196
-
197
- The behavior described in this table can be overridden or extended with plugins. Refer to the [Bundler > Loaders](/docs/bundler/loaders) page for complete documentation.
198
-
199
- ## API
200
-
201
- ### entrypoints
202
-
203
- <Badge>Required</Badge>
204
-
205
- An array of paths corresponding to the entrypoints of our application. One bundle will be generated for each entrypoint.
206
-
207
- <Tabs>
208
- <Tab title="JavaScript">
209
- ```ts title="build.ts" icon="/icons/typescript.svg"
210
- const result = await Bun.build({
211
- entrypoints: ["./index.ts"],
212
- });
213
- // => { success: boolean, outputs: BuildArtifact[], logs: BuildMessage[] }
214
- ```
215
- </Tab>
216
- <Tab title="CLI">
217
- ```bash terminal icon="terminal"
218
- bun build ./index.ts
219
- ```
220
- </Tab>
221
- </Tabs>
222
-
223
- ### outdir
224
-
225
- The directory where output files will be written.
226
-
227
- <Tabs>
228
- <Tab title="JavaScript">
229
- ```ts title="build.ts" icon="/icons/typescript.svg"
230
- const result = await Bun.build({
231
- entrypoints: ['./index.ts'],
232
- outdir: './out'
233
- });
234
- // => { success: boolean, outputs: BuildArtifact[], logs: BuildMessage[] }
235
- ```
236
- </Tab>
237
- <Tab title="CLI">
238
- ```bash terminal icon="terminal"
239
- bun build ./index.ts --outdir ./out
240
- ```
241
- </Tab>
242
- </Tabs>
243
-
244
- If `outdir` is not passed to the JavaScript API, bundled code will not be written to disk. Bundled files are returned in an array of `BuildArtifact` objects. These objects are Blobs with extra properties; see [Outputs](#outputs) for complete documentation.
245
-
246
- ```ts title="build.ts" icon="/icons/typescript.svg"
247
- const result = await Bun.build({
248
- entrypoints: ["./index.ts"],
249
- });
250
-
251
- for (const res of result.outputs) {
252
- // Can be consumed as blobs
253
- await res.text();
254
-
255
- // Bun will set Content-Type and Etag headers
256
- new Response(res);
257
-
258
- // Can be written manually, but you should use `outdir` in this case.
259
- Bun.write(path.join("out", res.path), res);
260
- }
261
- ```
262
-
263
- When `outdir` is set, the `path` property on a `BuildArtifact` will be the absolute path to where it was written to.
264
-
265
- ### target
266
-
267
- The intended execution environment for the bundle.
268
-
269
- <Tabs>
270
- <Tab title="JavaScript">
271
- ```ts title="build.ts" icon="/icons/typescript.svg"
272
- await Bun.build({
273
- entrypoints: ['./index.ts'],
274
- outdir: './out',
275
- target: 'browser', // default
276
- })
277
- ```
278
- </Tab>
279
- <Tab title="CLI">
280
- ```bash terminal icon="terminal"
281
- bun build ./index.ts --outdir ./out --target browser
282
- ```
283
- </Tab>
284
- </Tabs>
285
-
286
- Depending on the target, Bun will apply different module resolution rules and optimizations.
287
-
288
- <Card title="browser" icon="globe">
289
- **Default.** For generating bundles that are intended for execution by a browser. Prioritizes the `"browser"` export
290
- condition when resolving imports. Importing any built-in modules, like `node:events` or `node:path` will work, but
291
- calling some functions, like `fs.readFile` will not work.
292
- </Card>
293
-
294
- <Card title="bun" icon="server">
295
- For generating bundles that are intended to be run by the Bun runtime. In many cases, it isn't necessary to bundle server-side code; you can directly execute the source code without modification. However, bundling your server code can reduce startup times and improve running performance. This is the target to use for building full-stack applications with build-time HTML imports, where both server and client code are bundled together.
296
-
297
- All bundles generated with `target: "bun"` are marked with a special `// @bun` pragma, which indicates to the Bun runtime that there's no need to re-transpile the file before execution.
298
-
299
- If any entrypoints contains a Bun shebang (`#!/usr/bin/env bun`) the bundler will default to `target: "bun"` instead of `"browser"`.
300
-
301
- When using `target: "bun"` and `format: "cjs"` together, the `// @bun @bun-cjs` pragma is added and the CommonJS wrapper function is not compatible with Node.js.
302
-
303
- </Card>
304
-
305
- <Card title="node" icon="node">
306
- For generating bundles that are intended to be run by Node.js. Prioritizes the `"node"` export condition when
307
- resolving imports, and outputs `.mjs`. In the future, this will automatically polyfill the Bun global and other
308
- built-in `bun:*` modules, though this is not yet implemented.
309
- </Card>
310
-
311
- ### format
312
-
313
- Specifies the module format to be used in the generated bundles.
314
-
315
- Bun defaults to `"esm"`, and provides experimental support for `"cjs"` and `"iife"`.
316
-
317
- #### format: "esm" - ES Module
318
-
319
- This is the default format, which supports ES Module syntax including top-level await, `import.meta`, and more.
320
-
321
- <Tabs>
322
- <Tab title="JavaScript">
323
- ```ts title="build.ts" icon="/icons/typescript.svg"
324
- await Bun.build({
325
- entrypoints: ['./index.tsx'],
326
- outdir: './out',
327
- format: "esm",
328
- })
329
- ```
330
- </Tab>
331
- <Tab title="CLI">
332
- ```bash terminal icon="terminal"
333
- bun build ./index.tsx --outdir ./out --format esm
334
- ```
335
- </Tab>
336
- </Tabs>
337
-
338
- To use ES Module syntax in browsers, set `format` to `"esm"` and make sure your `<script type="module">` tag has `type="module"` set.
339
-
340
- #### format: "cjs" - CommonJS
341
-
342
- To build a CommonJS module, set `format` to `"cjs"`. When choosing `"cjs"`, the default target changes from `"browser"` (esm) to `"node"` (cjs). CommonJS modules transpiled with `format: "cjs"`, `target: "node"` can be executed in both Bun and Node.js (assuming the APIs in use are supported by both).
343
-
344
- <Tabs>
345
- <Tab title="JavaScript">
346
- ```ts title="build.ts" icon="/icons/typescript.svg"
347
- await Bun.build({
348
- entrypoints: ['./index.tsx'],
349
- outdir: './out',
350
- format: "cjs",
351
- })
352
- ```
353
- </Tab>
354
- <Tab title="CLI">
355
- ```bash terminal icon="terminal"
356
- bun build ./index.tsx --outdir ./out --format cjs
357
- ```
358
- </Tab>
359
- </Tabs>
360
-
361
- #### format: "iife" - IIFE
362
-
363
- TODO: document IIFE once we support globalNames.
364
-
365
- ### `jsx`
366
-
367
- Configure JSX transform behavior. Allows fine-grained control over how JSX is compiled.
368
-
369
- **Classic runtime example** (uses `factory` and `fragment`):
370
-
371
- <CodeGroup>
372
-
373
- ```ts index.ts icon="/icons/typescript.svg"
374
- await Bun.build({
375
- entrypoints: ["./app.tsx"],
376
- outdir: "./out",
377
- jsx: {
378
- factory: "h",
379
- fragment: "Fragment",
380
- runtime: "classic",
381
- },
382
- });
383
- ```
384
-
385
- ```bash terminal icon="terminal"
386
- # JSX configuration is handled via bunfig.toml or tsconfig.json
387
- bun build ./app.tsx --outdir ./out
388
- ```
389
-
390
- </CodeGroup>
391
-
392
- **Automatic runtime example** (uses `importSource`):
393
-
394
- <CodeGroup>
395
-
396
- ```ts index.ts icon="/icons/typescript.svg"
397
- await Bun.build({
398
- entrypoints: ["./app.tsx"],
399
- outdir: "./out",
400
- jsx: {
401
- importSource: "preact",
402
- runtime: "automatic",
403
- },
404
- });
405
- ```
406
-
407
- ```bash terminal icon="terminal"
408
- # JSX configuration is handled via bunfig.toml or tsconfig.json
409
- bun build ./app.tsx --outdir ./out
410
- ```
411
-
412
- </CodeGroup>
413
-
414
- ### splitting
415
-
416
- Whether to enable code splitting.
417
-
418
- <Tabs>
419
- <Tab title="JavaScript">
420
- ```ts title="build.ts" icon="/icons/typescript.svg"
421
- await Bun.build({
422
- entrypoints: ['./index.tsx'],
423
- outdir: './out',
424
- splitting: false, // default
425
- })
426
- ```
427
- </Tab>
428
- <Tab title="CLI">
429
- ```bash terminal icon="terminal"
430
- bun build ./index.tsx --outdir ./out --splitting
431
- ```
432
- </Tab>
433
- </Tabs>
434
-
435
- When `true`, the bundler will enable code splitting. When multiple entrypoints both import the same file, module, or set of files/modules, it's often useful to split the shared code into a separate bundle. This shared bundle is known as a chunk. Consider the following files:
436
-
437
- <CodeGroup>
438
-
439
- ```ts entry-a.ts icon="/icons/typescript.svg"
440
- import { shared } from "./shared.ts";
441
- ```
442
-
443
- ```ts entry-b.ts icon="/icons/typescript.svg"
444
- import { shared } from "./shared.ts";
445
- ```
446
-
447
- ```ts shared.ts icon="/icons/typescript.svg"
448
- export const shared = "shared";
449
- ```
450
-
451
- </CodeGroup>
452
-
453
- To bundle `entry-a.ts` and `entry-b.ts` with code-splitting enabled:
454
-
455
- <Tabs>
456
- <Tab title="JavaScript">
457
- ```ts title="build.ts" icon="/icons/typescript.svg"
458
- await Bun.build({
459
- entrypoints: ['./entry-a.ts', './entry-b.ts'],
460
- outdir: './out',
461
- splitting: true,
462
- })
463
- ```
464
- </Tab>
465
- <Tab title="CLI">
466
- ```bash terminal icon="terminal"
467
- bun build ./entry-a.ts ./entry-b.ts --outdir ./out --splitting
468
- ```
469
- </Tab>
470
- </Tabs>
471
-
472
- Running this build will result in the following files:
473
-
474
- ```text title="file system" icon="folder-tree"
475
- .
476
- ├── entry-a.tsx
477
- ├── entry-b.tsx
478
- ├── shared.tsx
479
- └── out
480
- ├── entry-a.js
481
- ├── entry-b.js
482
- └── chunk-2fce6291bf86559d.js
483
- ```
484
-
485
- The generated `chunk-2fce6291bf86559d.js` file contains the shared code. To avoid collisions, the file name automatically includes a content hash by default. This can be customized with [`naming`](#naming).
486
-
487
- ### plugins
488
-
489
- A list of plugins to use during bundling.
490
-
491
- ```ts title="build.ts" icon="/icons/typescript.svg"
492
- await Bun.build({
493
- entrypoints: ["./index.tsx"],
494
- outdir: "./out",
495
- plugins: [
496
- /* ... */
497
- ],
498
- });
499
- ```
500
-
501
- Bun implements a universal plugin system for both Bun's runtime and bundler. Refer to the [plugin documentation](/docs/bundler/plugins) for complete documentation.
502
-
503
- ### env
504
-
505
- Controls how environment variables are handled during bundling. Internally, this uses `define` to inject environment variables into the bundle, but makes it easier to specify the environment variables to inject.
506
-
507
- #### env: "inline"
508
-
509
- Injects environment variables into the bundled output by converting `process.env.FOO` references to string literals containing the actual environment variable values.
510
-
511
- <Tabs>
512
- <Tab title="JavaScript">
513
- ```ts title="build.ts" icon="/icons/typescript.svg"
514
- await Bun.build({
515
- entrypoints: ['./index.tsx'],
516
- outdir: './out',
517
- env: "inline",
518
- })
519
- ```
520
- </Tab>
521
- <Tab title="CLI">
522
- ```bash terminal icon="terminal"
523
- bun build ./index.tsx --outdir ./out --env inline
524
- ```
525
- </Tab>
526
- </Tabs>
527
-
528
- For the input below:
529
-
530
- ```js title="input.js" icon="/icons/javascript.svg"
531
- // input.js
532
- console.log(process.env.FOO);
533
- console.log(process.env.BAZ);
534
- ```
535
-
536
- The generated bundle will contain the following code:
537
-
538
- ```js title="output.js" icon="/icons/javascript.svg"
539
- // output.js
540
- console.log("bar");
541
- console.log("123");
542
- ```
543
-
544
- #### env: "PUBLIC\_\*" (prefix)
545
-
546
- Inlines environment variables matching the given prefix (the part before the `*` character), replacing `process.env.FOO` with the actual environment variable value. This is useful for selectively inlining environment variables for things like public-facing URLs or client-side tokens, without worrying about injecting private credentials into output bundles.
547
-
548
- <Tabs>
549
- <Tab title="JavaScript">
550
- ```ts title="build.ts" icon="/icons/typescript.svg"
551
- await Bun.build({
552
- entrypoints: ['./index.tsx'],
553
- outdir: './out',
554
-
555
- // Inline all env vars that start with "ACME_PUBLIC_"
556
- env: "ACME_PUBLIC_*",
557
- })
558
- ```
559
- </Tab>
560
- <Tab title="CLI">
561
- ```bash terminal icon="terminal"
562
- bun build ./index.tsx --outdir ./out --env ACME_PUBLIC_*
563
- ```
564
- </Tab>
565
- </Tabs>
566
-
567
- For example, given the following environment variables:
568
-
569
- ```bash terminal icon="terminal"
570
- FOO=bar BAZ=123 ACME_PUBLIC_URL=https://acme.com
571
- ```
572
-
573
- And source code:
574
-
575
- ```tsx index.tsx icon="/icons/typescript.svg"
576
- console.log(process.env.FOO);
577
- console.log(process.env.ACME_PUBLIC_URL);
578
- console.log(process.env.BAZ);
579
- ```
580
-
581
- The generated bundle will contain the following code:
582
-
583
- ```js title="output.js" icon="/icons/javascript.svg"
584
- console.log(process.env.FOO);
585
- console.log("https://acme.com");
586
- console.log(process.env.BAZ);
587
- ```
588
-
589
- #### env: "disable"
590
-
591
- Disables environment variable injection entirely.
592
-
593
- ### sourcemap
594
-
595
- Specifies the type of sourcemap to generate.
596
-
597
- <Tabs>
598
- <Tab title="JavaScript">
599
- ```ts title="build.ts" icon="/icons/typescript.svg"
600
- await Bun.build({
601
- entrypoints: ['./index.tsx'],
602
- outdir: './out',
603
- sourcemap: 'linked', // default 'none'
604
- })
605
- ```
606
- </Tab>
607
- <Tab title="CLI">
608
- ```bash terminal icon="terminal"
609
- bun build ./index.tsx --outdir ./out --sourcemap linked
610
- ```
611
- </Tab>
612
- </Tabs>
613
-
614
- | Value | Description |
615
- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
616
- | `"none"` | Default. No sourcemap is generated. |
617
- | `"linked"` | A separate `*.js.map` file is created alongside each `*.js` bundle using a `//# sourceMappingURL` comment to link the two. Requires `--outdir` to be set. The base URL of this can be customized with `--public-path`.<br/><br/>`js<br/>// <bundled code here><br/><br/>//# sourceMappingURL=bundle.js.map<br/>` |
618
- | `"external"` | A separate `*.js.map` file is created alongside each `*.js` bundle without inserting a `//# sourceMappingURL` comment.<br/><br/>Generated bundles contain a debug id that can be used to associate a bundle with its corresponding sourcemap. This `debugId` is added as a comment at the bottom of the file.<br/><br/>`js<br/>// <generated bundle code><br/><br/>//# debugId=<DEBUG ID><br/>` |
619
- | `"inline"` | A sourcemap is generated and appended to the end of the generated bundle as a base64 payload.<br/><br/>`js<br/>// <bundled code here><br/><br/>//# sourceMappingURL=data:application/json;base64,<encoded sourcemap here><br/>` |
620
-
621
- The associated `*.js.map` sourcemap will be a JSON file containing an equivalent `debugId` property.
622
-
623
- ### minify
624
-
625
- Whether to enable minification. Default `false`.
626
-
627
- <Note>When targeting `bun`, identifiers will be minified by default.</Note>
628
-
629
- To enable all minification options:
630
-
631
- <Tabs>
632
- <Tab title="JavaScript">
633
- ```ts title="build.ts" icon="/icons/typescript.svg"
634
- await Bun.build({
635
- entrypoints: ['./index.tsx'],
636
- outdir: './out',
637
- minify: true, // default false
638
- })
639
- ```
640
- </Tab>
641
- <Tab title="CLI">
642
- ```bash terminal icon="terminal"
643
- bun build ./index.tsx --outdir ./out --minify
644
- ```
645
- </Tab>
646
- </Tabs>
647
-
648
- To granularly enable certain minifications:
649
-
650
- <Tabs>
651
- <Tab title="JavaScript">
652
- ```ts title="build.ts" icon="/icons/typescript.svg"
653
- await Bun.build({
654
- entrypoints: ['./index.tsx'],
655
- outdir: './out',
656
- minify: {
657
- whitespace: true,
658
- identifiers: true,
659
- syntax: true,
660
- },
661
- })
662
- ```
663
- </Tab>
664
- <Tab title="CLI">
665
- ```bash terminal icon="terminal"
666
- bun build ./index.tsx --outdir ./out --minify-whitespace --minify-identifiers --minify-syntax
667
- ```
668
- </Tab>
669
- </Tabs>
670
-
671
- ### external
672
-
673
- A list of import paths to consider external. Defaults to `[]`.
674
-
675
- <Tabs>
676
- <Tab title="JavaScript">
677
- ```ts title="build.ts" icon="/icons/typescript.svg"
678
- await Bun.build({
679
- entrypoints: ['./index.tsx'],
680
- outdir: './out',
681
- external: ["lodash", "react"], // default: []
682
- })
683
- ```
684
- </Tab>
685
- <Tab title="CLI">
686
- ```bash terminal icon="terminal"
687
- bun build ./index.tsx --outdir ./out --external lodash --external react
688
- ```
689
- </Tab>
690
- </Tabs>
691
-
692
- An external import is one that will not be included in the final bundle. Instead, the import statement will be left as-is, to be resolved at runtime.
693
-
694
- For instance, consider the following entrypoint file:
695
-
696
- ```tsx index.tsx icon="/icons/typescript.svg"
697
- import _ from "lodash";
698
- import { z } from "zod";
699
-
700
- const value = z.string().parse("Hello world!");
701
- console.log(_.upperCase(value));
702
- ```
703
-
704
- Normally, bundling `index.tsx` would generate a bundle containing the entire source code of the "zod" package. If instead, we want to leave the import statement as-is, we can mark it as external:
705
-
706
- <Tabs>
707
- <Tab title="JavaScript">
708
- ```ts title="build.ts" icon="/icons/typescript.svg"
709
- await Bun.build({
710
- entrypoints: ['./index.tsx'],
711
- outdir: './out',
712
- external: ['zod'],
713
- })
714
- ```
715
- </Tab>
716
- <Tab title="CLI">
717
- ```bash terminal icon="terminal"
718
- bun build ./index.tsx --outdir ./out --external zod
719
- ```
720
- </Tab>
721
- </Tabs>
722
-
723
- The generated bundle will look something like this:
724
-
725
- ```js title="out/index.js" icon="/icons/javascript.svg"
726
- import { z } from "zod";
727
-
728
- // ...
729
- // the contents of the "lodash" package
730
- // including the `_.upperCase` function
731
-
732
- var value = z.string().parse("Hello world!");
733
- console.log(_.upperCase(value));
734
- ```
735
-
736
- To mark all imports as external, use the wildcard `*`:
737
-
738
- <Tabs>
739
- <Tab title="JavaScript">
740
- ```ts title="build.ts" icon="/icons/typescript.svg"
741
- await Bun.build({
742
- entrypoints: ['./index.tsx'],
743
- outdir: './out',
744
- external: ['*'],
745
- })
746
- ```
747
- </Tab>
748
- <Tab title="CLI">
749
- ```bash terminal icon="terminal"
750
- bun build ./index.tsx --outdir ./out --external '*'
751
- ```
752
- </Tab>
753
- </Tabs>
754
-
755
- ### packages
756
-
757
- Control whether package dependencies are included to bundle or not. Possible values: `bundle` (default), `external`. Bun treats any import which path do not start with `.`, `..` or `/` as package.
758
-
759
- <Tabs>
760
- <Tab title="JavaScript">
761
- ```ts title="build.ts" icon="/icons/typescript.svg"
762
- await Bun.build({
763
- entrypoints: ['./index.ts'],
764
- packages: 'external',
765
- })
766
- ```
767
- </Tab>
768
- <Tab title="CLI">
769
- ```bash terminal icon="terminal"
770
- bun build ./index.ts --packages external
771
- ```
772
- </Tab>
773
- </Tabs>
774
-
775
- ### naming
776
-
777
- Customizes the generated file names. Defaults to `./[dir]/[name].[ext]`.
778
-
779
- <Tabs>
780
- <Tab title="JavaScript">
781
- ```ts title="build.ts" icon="/icons/typescript.svg"
782
- await Bun.build({
783
- entrypoints: ['./index.tsx'],
784
- outdir: './out',
785
- naming: "[dir]/[name].[ext]", // default
786
- })
787
- ```
788
- </Tab>
789
- <Tab title="CLI">
790
- ```bash terminal icon="terminal"
791
- bun build ./index.tsx --outdir ./out --entry-naming "[dir]/[name].[ext]"
792
- ```
793
- </Tab>
794
- </Tabs>
795
-
796
- By default, the names of the generated bundles are based on the name of the associated entrypoint.
797
-
798
- ```text title="file system" icon="folder-tree"
799
- .
800
- ├── index.tsx
801
- └── out
802
- └── index.js
803
- ```
804
-
805
- With multiple entrypoints, the generated file hierarchy will reflect the directory structure of the entrypoints.
806
-
807
- ```text title="file system" icon="folder-tree"
808
- .
809
- ├── index.tsx
810
- └── nested
811
- └── index.tsx
812
- └── out
813
- ├── index.js
814
- └── nested
815
- └── index.js
816
- ```
817
-
818
- The names and locations of the generated files can be customized with the `naming` field. This field accepts a template string that is used to generate the filenames for all bundles corresponding to entrypoints. where the following tokens are replaced with their corresponding values:
819
-
820
- - `[name]` - The name of the entrypoint file, without the extension.
821
- - `[ext]` - The extension of the generated bundle.
822
- - `[hash]` - A hash of the bundle contents.
823
- - `[dir]` - The relative path from the project root to the parent directory of the source file.
824
-
825
- For example:
826
-
827
- | Token | `[name]` | `[ext]` | `[hash]` | `[dir]` |
828
- | ------------------- | -------- | ------- | ---------- | ------------------- |
829
- | `./index.tsx` | `index` | `js` | `a1b2c3d4` | `""` (empty string) |
830
- | `./nested/entry.ts` | `entry` | `js` | `c3d4e5f6` | `"nested"` |
831
-
832
- We can combine these tokens to create a template string. For instance, to include the hash in the generated bundle names:
833
-
834
- <Tabs>
835
- <Tab title="JavaScript">
836
- ```ts title="build.ts" icon="/icons/typescript.svg"
837
- await Bun.build({
838
- entrypoints: ['./index.tsx'],
839
- outdir: './out',
840
- naming: 'files/[dir]/[name]-[hash].[ext]',
841
- })
842
- ```
843
- </Tab>
844
- <Tab title="CLI">
845
- ```bash terminal icon="terminal"
846
- bun build ./index.tsx --outdir ./out --entry-naming 'files/[dir]/[name]-[hash].[ext]'
847
- ```
848
- </Tab>
849
- </Tabs>
850
-
851
- This build would result in the following file structure:
852
-
853
- ```text title="file system" icon="folder-tree"
854
- .
855
- ├── index.tsx
856
- └── out
857
- └── files
858
- └── index-a1b2c3d4.js
859
- ```
860
-
861
- When a string is provided for the `naming` field, it is used only for bundles that correspond to entrypoints. The names of chunks and copied assets are not affected. Using the JavaScript API, separate template strings can be specified for each type of generated file.
862
-
863
- <Tabs>
864
- <Tab title="JavaScript">
865
- ```ts title="build.ts" icon="/icons/typescript.svg"
866
- await Bun.build({
867
- entrypoints: ['./index.tsx'],
868
- outdir: './out',
869
- naming: {
870
- // default values
871
- entry: '[dir]/[name].[ext]',
872
- chunk: '[name]-[hash].[ext]',
873
- asset: '[name]-[hash].[ext]',
874
- },
875
- })
876
- ```
877
- </Tab>
878
- <Tab title="CLI">
879
- ```bash terminal icon="terminal"
880
- bun build ./index.tsx --outdir ./out \
881
- --entry-naming '[dir]/[name].[ext]' \
882
- --chunk-naming '[name]-[hash].[ext]' \
883
- --asset-naming '[name]-[hash].[ext]'
884
- ```
885
- </Tab>
886
- </Tabs>
887
-
888
- ### root
889
-
890
- The root directory of the project.
891
-
892
- <Tabs>
893
- <Tab title="JavaScript">
894
- ```ts title="build.ts" icon="/icons/typescript.svg"
895
- await Bun.build({
896
- entrypoints: ['./pages/a.tsx', './pages/b.tsx'],
897
- outdir: './out',
898
- root: '.',
899
- })
900
- ```
901
- </Tab>
902
- <Tab title="CLI">
903
- ```bash terminal icon="terminal"
904
- bun build ./pages/a.tsx ./pages/b.tsx --outdir ./out --root .
905
- ```
906
- </Tab>
907
- </Tabs>
908
-
909
- If unspecified, it is computed to be the first common ancestor of all entrypoint files. Consider the following file structure:
910
-
911
- ```text title="file system" icon="folder-tree"
912
- .
913
- └── pages
914
- └── index.tsx
915
- └── settings.tsx
916
- ```
917
-
918
- We can build both entrypoints in the `pages` directory:
919
-
920
- <Tabs>
921
- <Tab title="JavaScript">
922
- ```js
923
- await Bun.build({
924
- entrypoints: ['./pages/index.tsx', './pages/settings.tsx'],
925
- outdir: './out',
926
- })
927
- ```
928
- </Tab>
929
- <Tab title="CLI">
930
- ```bash
931
- bun build ./pages/index.tsx ./pages/settings.tsx --outdir ./out
932
- ```
933
- </Tab>
934
- </Tabs>
935
-
936
- This would result in a file structure like this:
937
-
938
- ```text title="file system" icon="folder-tree"
939
- .
940
- └── pages
941
- └── index.tsx
942
- └── settings.tsx
943
- └── out
944
- └── index.js
945
- └── settings.js
946
- ```
947
-
948
- Since the `pages` directory is the first common ancestor of the entrypoint files, it is considered the project root. This means that the generated bundles live at the top level of the `out` directory; there is no `out/pages` directory.
949
-
950
- This behavior can be overridden by specifying the `root` option:
951
-
952
- <Tabs>
953
- <Tab title="JavaScript">
954
- ```js
955
- await Bun.build({
956
- entrypoints: ['./pages/index.tsx', './pages/settings.tsx'],
957
- outdir: './out',
958
- root: '.',
959
- })
960
- ```
961
- </Tab>
962
- <Tab title="CLI">
963
- ```bash
964
- bun build ./pages/index.tsx ./pages/settings.tsx --outdir ./out --root .
965
- ```
966
- </Tab>
967
- </Tabs>
968
-
969
- By specifying `.` as `root`, the generated file structure will look like this:
970
-
971
- ```
972
- .
973
- └── pages
974
- └── index.tsx
975
- └── settings.tsx
976
- └── out
977
- └── pages
978
- └── index.js
979
- └── settings.js
980
- ```
981
-
982
- ### publicPath
983
-
984
- A prefix to be appended to any import paths in bundled code.
985
-
986
- In many cases, generated bundles will contain no import statements. After all, the goal of bundling is to combine all of the code into a single file. However there are a number of cases with the generated bundles will contain import statements.
987
-
988
- - **Asset imports** — When importing an unrecognized file type like `*.svg`, the bundler defers to the file loader, which copies the file into `outdir` as is. The import is converted into a variable
989
- - **External modules** — Files and modules can be marked as external, in which case they will not be included in the bundle. Instead, the import statement will be left in the final bundle.
990
- - **Chunking.** When `splitting` is enabled, the bundler may generate separate "chunk" files that represent code that is shared among multiple entrypoints.
991
-
992
- In any of these cases, the final bundles may contain paths to other files. By default these imports are relative. Here is an example of a simple asset import:
993
-
994
- <CodeGroup>
995
-
996
- ```ts Input icon="/icons/typescript.svg"
997
- import logo from "./logo.svg";
998
- console.log(logo);
999
- ```
1000
-
1001
- ```ts Output icon="/icons/javascript.svg"
1002
- var logo = "./logo-a7305bdef.svg";
1003
- console.log(logo);
1004
- ```
1005
-
1006
- </CodeGroup>
1007
-
1008
- Setting `publicPath` will prefix all file paths with the specified value.
1009
-
1010
- <Tabs>
1011
- <Tab title="JavaScript">
1012
- ```ts title="build.ts" icon="/icons/typescript.svg"
1013
- await Bun.build({
1014
- entrypoints: ['./index.tsx'],
1015
- outdir: './out',
1016
- publicPath: 'https://cdn.example.com/', // default is undefined
1017
- })
1018
- ```
1019
- </Tab>
1020
- <Tab title="CLI">
1021
- ```bash terminal icon="terminal"
1022
- bun build ./index.tsx --outdir ./out --public-path 'https://cdn.example.com/'
1023
- ```
1024
- </Tab>
1025
- </Tabs>
1026
-
1027
- The output file would now look something like this.
1028
-
1029
- ```js title="out/index.js" icon="/icons/javascript.svg"
1030
- var logo = "https://cdn.example.com/logo-a7305bdef.svg";
1031
- ```
1032
-
1033
- ### define
1034
-
1035
- A map of global identifiers to be replaced at build time. Keys of this object are identifier names, and values are JSON strings that will be inlined.
1036
-
1037
- <Tabs>
1038
- <Tab title="JavaScript">
1039
- ```ts title="build.ts" icon="/icons/typescript.svg"
1040
- await Bun.build({
1041
- entrypoints: ['./index.tsx'],
1042
- outdir: './out',
1043
- define: {
1044
- STRING: JSON.stringify("value"),
1045
- "nested.boolean": "true",
1046
- },
1047
- })
1048
- ```
1049
- </Tab>
1050
- <Tab title="CLI">
1051
- ```bash terminal icon="terminal"
1052
- bun build ./index.tsx --outdir ./out --define STRING='"value"' --define nested.boolean=true
1053
- ```
1054
- </Tab>
1055
- </Tabs>
1056
-
1057
- ### loader
1058
-
1059
- A map of file extensions to built-in loader names. This can be used to quickly customize how certain files are loaded.
1060
-
1061
- <Tabs>
1062
- <Tab title="JavaScript">
1063
- ```ts title="build.ts" icon="/icons/typescript.svg"
1064
- await Bun.build({
1065
- entrypoints: ['./index.tsx'],
1066
- outdir: './out',
1067
- loader: {
1068
- ".png": "dataurl",
1069
- ".txt": "file",
1070
- },
1071
- })
1072
- ```
1073
- </Tab>
1074
- <Tab title="CLI">
1075
- ```bash terminal icon="terminal"
1076
- bun build ./index.tsx --outdir ./out --loader .png:dataurl --loader .txt:file
1077
- ```
1078
- </Tab>
1079
- </Tabs>
1080
-
1081
- ### banner
1082
-
1083
- A banner to be added to the final bundle, this can be a directive like `"use client"` for react or a comment block such as a license for the code.
1084
-
1085
- <Tabs>
1086
- <Tab title="JavaScript">
1087
- ```ts title="build.ts" icon="/icons/typescript.svg"
1088
- await Bun.build({
1089
- entrypoints: ['./index.tsx'],
1090
- outdir: './out',
1091
- banner: '"use client";'
1092
- })
1093
- ```
1094
- </Tab>
1095
- <Tab title="CLI">
1096
- ```bash terminal icon="terminal"
1097
- bun build ./index.tsx --outdir ./out --banner '"use client";'
1098
- ```
1099
- </Tab>
1100
- </Tabs>
1101
-
1102
- ### footer
1103
-
1104
- A footer to be added to the final bundle, this can be something like a comment block for a license or just a fun easter egg.
1105
-
1106
- <Tabs>
1107
- <Tab title="JavaScript">
1108
- ```ts title="build.ts" icon="/icons/typescript.svg"
1109
- await Bun.build({
1110
- entrypoints: ['./index.tsx'],
1111
- outdir: './out',
1112
- footer: '// built with love in SF'
1113
- })
1114
- ```
1115
- </Tab>
1116
- <Tab title="CLI">
1117
- ```bash terminal icon="terminal"
1118
- bun build ./index.tsx --outdir ./out --footer '// built with love in SF'
1119
- ```
1120
- </Tab>
1121
- </Tabs>
1122
-
1123
- ### drop
1124
-
1125
- Remove function calls from a bundle. For example, `--drop=console` will remove all calls to `console.log`. Arguments to calls will also be removed, regardless of if those arguments may have side effects. Dropping `debugger` will remove all `debugger` statements.
1126
-
1127
- <Tabs>
1128
- <Tab title="JavaScript">
1129
- ```ts title="build.ts" icon="/icons/typescript.svg"
1130
- await Bun.build({
1131
- entrypoints: ['./index.tsx'],
1132
- outdir: './out',
1133
- drop: ["console", "debugger", "anyIdentifier.or.propertyAccess"],
1134
- })
1135
- ```
1136
- </Tab>
1137
- <Tab title="CLI">
1138
- ```bash terminal icon="terminal"
1139
- bun build ./index.tsx --outdir ./out --drop console --drop debugger
1140
- ```
1141
- </Tab>
1142
- </Tabs>
1143
-
1144
- ### features
1145
-
1146
- Enable compile-time feature flags for dead-code elimination. This provides a way to conditionally include or exclude code paths at bundle time using `import { feature } from "bun:bundle"`.
1147
-
1148
- ```ts title="app.ts" icon="/icons/typescript.svg"
1149
- import { feature } from "bun:bundle";
1150
-
1151
- if (feature("PREMIUM")) {
1152
- // Only included when PREMIUM flag is enabled
1153
- initPremiumFeatures();
1154
- }
1155
-
1156
- if (feature("DEBUG")) {
1157
- // Only included when DEBUG flag is enabled
1158
- console.log("Debug mode");
1159
- }
1160
- ```
1161
-
1162
- <Tabs>
1163
- <Tab title="JavaScript">
1164
- ```ts title="build.ts" icon="/icons/typescript.svg"
1165
- await Bun.build({
1166
- entrypoints: ['./app.ts'],
1167
- outdir: './out',
1168
- features: ["PREMIUM"], // PREMIUM=true, DEBUG=false
1169
- })
1170
- ```
1171
- </Tab>
1172
- <Tab title="CLI">
1173
- ```bash terminal icon="terminal"
1174
- bun build ./app.ts --outdir ./out --feature PREMIUM
1175
- ```
1176
- </Tab>
1177
- </Tabs>
1178
-
1179
- The `feature()` function is replaced with `true` or `false` at bundle time. Combined with minification, unreachable code is eliminated:
1180
-
1181
- ```ts title="Input" icon="/icons/typescript.svg"
1182
- import { feature } from "bun:bundle";
1183
- const mode = feature("PREMIUM") ? "premium" : "free";
1184
- ```
1185
-
1186
- ```js title="Output (with --feature PREMIUM --minify)" icon="/icons/javascript.svg"
1187
- var mode = "premium";
1188
- ```
1189
-
1190
- ```js title="Output (without --feature PREMIUM, with --minify)" icon="/icons/javascript.svg"
1191
- var mode = "free";
1192
- ```
1193
-
1194
- **Key behaviors:**
1195
-
1196
- - `feature()` requires a string literal argument — dynamic values are not supported
1197
- - The `bun:bundle` import is completely removed from the output
1198
- - Works with `bun build`, `bun run`, and `bun test`
1199
- - Multiple flags can be enabled: `--feature FLAG_A --feature FLAG_B`
1200
- - For type safety, augment the `Registry` interface to restrict `feature()` to known flags (see below)
1201
-
1202
- **Use cases:**
1203
-
1204
- - Platform-specific code (`feature("SERVER")` vs `feature("CLIENT")`)
1205
- - Environment-based features (`feature("DEVELOPMENT")`)
1206
- - Gradual feature rollouts
1207
- - A/B testing variants
1208
- - Paid tier features
1209
-
1210
- **Type safety:** By default, `feature()` accepts any string. To get autocomplete and catch typos at compile time, create an `env.d.ts` file (or add to an existing `.d.ts`) and augment the `Registry` interface:
1211
-
1212
- ```ts title="env.d.ts" icon="/icons/typescript.svg"
1213
- declare module "bun:bundle" {
1214
- interface Registry {
1215
- features: "DEBUG" | "PREMIUM" | "BETA_FEATURES";
1216
- }
1217
- }
1218
- ```
1219
-
1220
- Ensure the file is included in your `tsconfig.json` (e.g., `"include": ["src", "env.d.ts"]`). Now `feature()` only accepts those flags, and invalid strings like `feature("TYPO")` become type errors.
1221
-
1222
- ## Outputs
1223
-
1224
- The `Bun.build` function returns a `Promise<BuildOutput>`, defined as:
1225
-
1226
- ```ts title="build.ts" icon="/icons/typescript.svg"
1227
- interface BuildOutput {
1228
- outputs: BuildArtifact[];
1229
- success: boolean;
1230
- logs: Array<object>; // see docs for details
1231
- }
1232
-
1233
- interface BuildArtifact extends Blob {
1234
- kind: "entry-point" | "chunk" | "asset" | "sourcemap";
1235
- path: string;
1236
- loader: Loader;
1237
- hash: string | null;
1238
- sourcemap: BuildArtifact | null;
1239
- }
1240
- ```
1241
-
1242
- The `outputs` array contains all the files that were generated by the build. Each artifact implements the Blob interface.
1243
-
1244
- ```ts title="build.ts" icon="/icons/typescript.svg"
1245
- const build = await Bun.build({
1246
- /* */
1247
- });
1248
-
1249
- for (const output of build.outputs) {
1250
- await output.arrayBuffer(); // => ArrayBuffer
1251
- await output.bytes(); // => Uint8Array
1252
- await output.text(); // string
1253
- }
1254
- ```
1255
-
1256
- Each artifact also contains the following properties:
1257
-
1258
- | Property | Description |
1259
- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
1260
- | `kind` | What kind of build output this file is. A build generates bundled entrypoints, code-split "chunks", sourcemaps, bytecode, and copied assets (like images). |
1261
- | `path` | Absolute path to the file on disk |
1262
- | `loader` | The loader was used to interpret the file. See [Bundler > Loaders](/docs/bundler/loaders) to see how Bun maps file extensions to the appropriate built-in loader. |
1263
- | `hash` | The hash of the file contents. Always defined for assets. |
1264
- | `sourcemap` | The sourcemap file corresponding to this file, if generated. Only defined for entrypoints and chunks. |
1265
-
1266
- Similar to `BunFile`, `BuildArtifact` objects can be passed directly into `new Response()`.
1267
-
1268
- ```ts title="build.ts" icon="/icons/typescript.svg"
1269
- const build = await Bun.build({
1270
- /* */
1271
- });
1272
-
1273
- const artifact = build.outputs[0];
1274
-
1275
- // Content-Type header is automatically set
1276
- return new Response(artifact);
1277
- ```
1278
-
1279
- The Bun runtime implements special pretty-printing of `BuildArtifact` object to make debugging easier.
1280
-
1281
- <CodeGroup>
1282
-
1283
- ```ts build.ts icon="/icons/typescript.svg"
1284
- // build.ts
1285
- const build = await Bun.build({
1286
- /* */
1287
- });
1288
-
1289
- const artifact = build.outputs[0];
1290
- console.log(artifact);
1291
- ```
1292
-
1293
- ```bash Shell output
1294
- bun run build.ts
1295
-
1296
- BuildArtifact (entry-point) {
1297
- path: "./index.js",
1298
- loader: "tsx",
1299
- kind: "entry-point",
1300
- hash: "824a039620219640",
1301
- Blob (74756 bytes) {
1302
- type: "text/javascript;charset=utf-8"
1303
- },
1304
- sourcemap: BuildArtifact (sourcemap) {
1305
- path: "./index.js.map",
1306
- loader: "file",
1307
- kind: "sourcemap",
1308
- hash: "e7178cda3e72e301",
1309
- Blob (24765 bytes) {
1310
- type: "application/json;charset=utf-8"
1311
- },
1312
- sourcemap: null
1313
- }
1314
- }
1315
- ```
1316
-
1317
- </CodeGroup>
1318
-
1319
- ## Bytecode
1320
-
1321
- The `bytecode: boolean` option can be used to generate bytecode for any JavaScript/TypeScript entrypoints. This can greatly improve startup times for large applications. Only supported for `"cjs"` format, only supports `"target": "bun"` and dependent on a matching version of Bun. This adds a corresponding `.jsc` file for each entrypoint.
1322
-
1323
- <Tabs>
1324
- <Tab title="JavaScript">
1325
- ```ts title="build.ts" icon="/icons/typescript.svg"
1326
- await Bun.build({
1327
- entrypoints: ["./index.tsx"],
1328
- outdir: "./out",
1329
- bytecode: true,
1330
- })
1331
- ```
1332
- </Tab>
1333
- <Tab title="CLI">
1334
- ```bash terminal icon="terminal"
1335
- bun build ./index.tsx --outdir ./out --bytecode
1336
- ```
1337
- </Tab>
1338
- </Tabs>
1339
-
1340
- ## Executables
1341
-
1342
- Bun supports "compiling" a JavaScript/TypeScript entrypoint into a standalone executable. This executable contains a copy of the Bun binary.
1343
-
1344
- ```bash terminal icon="terminal"
1345
- bun build ./cli.tsx --outfile mycli --compile
1346
- ./mycli
1347
- ```
1348
-
1349
- Refer to [Bundler > Executables](/docs/bundler/executables) for complete documentation.
1350
-
1351
- ## Logs and errors
1352
-
1353
- On failure, `Bun.build` returns a rejected promise with an `AggregateError`. This can be logged to the console for pretty printing of the error list, or programmatically read with a try/catch block.
1354
-
1355
- ```ts title="build.ts" icon="/icons/typescript.svg"
1356
- try {
1357
- const result = await Bun.build({
1358
- entrypoints: ["./index.tsx"],
1359
- outdir: "./out",
1360
- });
1361
- } catch (e) {
1362
- // TypeScript does not allow annotations on the catch clause
1363
- const error = e as AggregateError;
1364
- console.error("Build Failed");
1365
-
1366
- // Example: Using the built-in formatter
1367
- console.error(error);
1368
-
1369
- // Example: Serializing the failure as a JSON string.
1370
- console.error(JSON.stringify(error, null, 2));
1371
- }
1372
- ```
1373
-
1374
- Most of the time, an explicit try/catch is not needed, as Bun will neatly print uncaught exceptions. It is enough to just use a top-level await on the `Bun.build` call.
1375
-
1376
- Each item in `error.errors` is an instance of `BuildMessage` or `ResolveMessage` (subclasses of `Error`), containing detailed information for each error.
1377
-
1378
- ```ts title="build.ts" icon="/icons/typescript.svg"
1379
- class BuildMessage {
1380
- name: string;
1381
- position?: Position;
1382
- message: string;
1383
- level: "error" | "warning" | "info" | "debug" | "verbose";
1384
- }
1385
-
1386
- class ResolveMessage extends BuildMessage {
1387
- code: string;
1388
- referrer: string;
1389
- specifier: string;
1390
- importKind: ImportKind;
1391
- }
1392
- ```
1393
-
1394
- On build success, the returned object contains a `logs` property, which contains bundler warnings and info messages.
1395
-
1396
- ```ts title="build.ts" icon="/icons/typescript.svg"
1397
- const result = await Bun.build({
1398
- entrypoints: ["./index.tsx"],
1399
- outdir: "./out",
1400
- });
1401
-
1402
- if (result.logs.length > 0) {
1403
- console.warn("Build succeeded with warnings:");
1404
- for (const message of result.logs) {
1405
- // Bun will pretty print the message object
1406
- console.warn(message);
1407
- }
1408
- }
1409
- ```
1410
-
1411
- ## Reference
1412
-
1413
- ```ts Typescript Definitions icon="/icons/typescript.svg" expandable
1414
- interface Bun {
1415
- build(options: BuildOptions): Promise<BuildOutput>;
1416
- }
1417
-
1418
- interface BuildConfig {
1419
- entrypoints: string[]; // list of file path
1420
- outdir?: string; // output directory
1421
- target?: Target; // default: "browser"
1422
- /**
1423
- * Output module format. Top-level await is only supported for `"esm"`.
1424
- *
1425
- * Can be:
1426
- * - `"esm"`
1427
- * - `"cjs"` (**experimental**)
1428
- * - `"iife"` (**experimental**)
1429
- *
1430
- * @default "esm"
1431
- */
1432
- format?: "esm" | "cjs" | "iife";
1433
- /**
1434
- * JSX configuration object for controlling JSX transform behavior
1435
- */
1436
- jsx?: {
1437
- runtime?: "automatic" | "classic";
1438
- importSource?: string;
1439
- factory?: string;
1440
- fragment?: string;
1441
- sideEffects?: boolean;
1442
- development?: boolean;
1443
- };
1444
- naming?:
1445
- | string
1446
- | {
1447
- chunk?: string;
1448
- entry?: string;
1449
- asset?: string;
1450
- };
1451
- root?: string; // project root
1452
- splitting?: boolean; // default true, enable code splitting
1453
- plugins?: BunPlugin[];
1454
- external?: string[];
1455
- packages?: "bundle" | "external";
1456
- publicPath?: string;
1457
- define?: Record<string, string>;
1458
- loader?: { [k in string]: Loader };
1459
- sourcemap?: "none" | "linked" | "inline" | "external" | boolean; // default: "none", true -> "inline"
1460
- /**
1461
- * package.json `exports` conditions used when resolving imports
1462
- *
1463
- * Equivalent to `--conditions` in `bun build` or `bun run`.
1464
- *
1465
- * https://nodejs.org/api/packages.html#exports
1466
- */
1467
- conditions?: Array<string> | string;
1468
-
1469
- /**
1470
- * Controls how environment variables are handled during bundling.
1471
- *
1472
- * Can be one of:
1473
- * - `"inline"`: Injects environment variables into the bundled output by converting `process.env.FOO`
1474
- * references to string literals containing the actual environment variable values
1475
- * - `"disable"`: Disables environment variable injection entirely
1476
- * - A string ending in `*`: Inlines environment variables that match the given prefix.
1477
- * For example, `"MY_PUBLIC_*"` will only include env vars starting with "MY_PUBLIC_"
1478
- */
1479
- env?: "inline" | "disable" | `${string}*`;
1480
- minify?:
1481
- | boolean
1482
- | {
1483
- whitespace?: boolean;
1484
- syntax?: boolean;
1485
- identifiers?: boolean;
1486
- };
1487
- /**
1488
- * Ignore dead code elimination/tree-shaking annotations such as @__PURE__ and package.json
1489
- * "sideEffects" fields. This should only be used as a temporary workaround for incorrect
1490
- * annotations in libraries.
1491
- */
1492
- ignoreDCEAnnotations?: boolean;
1493
- /**
1494
- * Force emitting @__PURE__ annotations even if minify.whitespace is true.
1495
- */
1496
- emitDCEAnnotations?: boolean;
1497
-
1498
- /**
1499
- * Generate bytecode for the output. This can dramatically improve cold
1500
- * start times, but will make the final output larger and slightly increase
1501
- * memory usage.
1502
- *
1503
- * Bytecode is currently only supported for CommonJS (`format: "cjs"`).
1504
- *
1505
- * Must be `target: "bun"`
1506
- * @default false
1507
- */
1508
- bytecode?: boolean;
1509
- /**
1510
- * Add a banner to the bundled code such as "use client";
1511
- */
1512
- banner?: string;
1513
- /**
1514
- * Add a footer to the bundled code such as a comment block like
1515
- *
1516
- * `// made with bun!`
1517
- */
1518
- footer?: string;
1519
-
1520
- /**
1521
- * Drop function calls to matching property accesses.
1522
- */
1523
- drop?: string[];
1524
-
1525
- /**
1526
- * - When set to `true`, the returned promise rejects with an AggregateError when a build failure happens.
1527
- * - When set to `false`, returns a {@link BuildOutput} with `{success: false}`
1528
- *
1529
- * @default true
1530
- */
1531
- throw?: boolean;
1532
-
1533
- /**
1534
- * Custom tsconfig.json file path to use for path resolution.
1535
- * Equivalent to `--tsconfig-override` in the CLI.
1536
- */
1537
- tsconfig?: string;
1538
-
1539
- outdir?: string;
1540
- }
1541
-
1542
- interface BuildOutput {
1543
- outputs: BuildArtifact[];
1544
- success: boolean;
1545
- logs: Array<BuildMessage | ResolveMessage>;
1546
- }
1547
-
1548
- interface BuildArtifact extends Blob {
1549
- path: string;
1550
- loader: Loader;
1551
- hash: string | null;
1552
- kind: "entry-point" | "chunk" | "asset" | "sourcemap" | "bytecode";
1553
- sourcemap: BuildArtifact | null;
1554
- }
1555
-
1556
- type Loader =
1557
- | "js"
1558
- | "jsx"
1559
- | "ts"
1560
- | "tsx"
1561
- | "css"
1562
- | "json"
1563
- | "jsonc"
1564
- | "toml"
1565
- | "yaml"
1566
- | "text"
1567
- | "file"
1568
- | "napi"
1569
- | "wasm"
1570
- | "html";
1571
-
1572
- interface BuildOutput {
1573
- outputs: BuildArtifact[];
1574
- success: boolean;
1575
- logs: Array<BuildMessage | ResolveMessage>;
1576
- }
1577
-
1578
- declare class ResolveMessage {
1579
- readonly name: "ResolveMessage";
1580
- readonly position: Position | null;
1581
- readonly code: string;
1582
- readonly message: string;
1583
- readonly referrer: string;
1584
- readonly specifier: string;
1585
- readonly importKind:
1586
- | "entry_point"
1587
- | "stmt"
1588
- | "require"
1589
- | "import"
1590
- | "dynamic"
1591
- | "require_resolve"
1592
- | "at"
1593
- | "at_conditional"
1594
- | "url"
1595
- | "internal";
1596
- readonly level: "error" | "warning" | "info" | "debug" | "verbose";
1597
-
1598
- toString(): string;
1599
- }
1600
- ```
1601
-
1602
- ---
1603
-
1604
- <Build />