bun-types 1.3.3 → 1.3.4-canary.20251125T140733

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 (220) hide show
  1. package/CLAUDE.md +3 -3
  2. package/docs/bundler/css.mdx +1 -1
  3. package/docs/bundler/executables.mdx +33 -4
  4. package/docs/bundler/fullstack.mdx +3 -3
  5. package/docs/bundler/hot-reloading.mdx +2 -2
  6. package/docs/bundler/html-static.mdx +10 -9
  7. package/docs/bundler/index.mdx +27 -18
  8. package/docs/bundler/loaders.mdx +2 -2
  9. package/docs/bundler/macros.mdx +1 -1
  10. package/docs/feedback.mdx +2 -12
  11. package/docs/guides/binary/arraybuffer-to-array.mdx +1 -1
  12. package/docs/guides/binary/arraybuffer-to-blob.mdx +1 -1
  13. package/docs/guides/binary/arraybuffer-to-buffer.mdx +1 -1
  14. package/docs/guides/binary/arraybuffer-to-string.mdx +1 -1
  15. package/docs/guides/binary/arraybuffer-to-typedarray.mdx +1 -1
  16. package/docs/guides/binary/blob-to-arraybuffer.mdx +1 -1
  17. package/docs/guides/binary/blob-to-dataview.mdx +1 -1
  18. package/docs/guides/binary/blob-to-stream.mdx +1 -1
  19. package/docs/guides/binary/blob-to-string.mdx +1 -1
  20. package/docs/guides/binary/blob-to-typedarray.mdx +1 -1
  21. package/docs/guides/binary/buffer-to-arraybuffer.mdx +1 -1
  22. package/docs/guides/binary/buffer-to-blob.mdx +1 -1
  23. package/docs/guides/binary/buffer-to-readablestream.mdx +1 -1
  24. package/docs/guides/binary/buffer-to-string.mdx +1 -1
  25. package/docs/guides/binary/buffer-to-typedarray.mdx +1 -1
  26. package/docs/guides/binary/dataview-to-string.mdx +1 -1
  27. package/docs/guides/binary/typedarray-to-arraybuffer.mdx +1 -1
  28. package/docs/guides/binary/typedarray-to-blob.mdx +1 -1
  29. package/docs/guides/binary/typedarray-to-buffer.mdx +1 -1
  30. package/docs/guides/binary/typedarray-to-dataview.mdx +1 -1
  31. package/docs/guides/binary/typedarray-to-readablestream.mdx +1 -1
  32. package/docs/guides/binary/typedarray-to-string.mdx +1 -1
  33. package/docs/guides/deployment/aws-lambda.mdx +6 -6
  34. package/docs/guides/deployment/digital-ocean.mdx +7 -7
  35. package/docs/guides/deployment/vercel.mdx +1 -3
  36. package/docs/guides/ecosystem/discordjs.mdx +2 -2
  37. package/docs/guides/ecosystem/express.mdx +2 -2
  38. package/docs/guides/ecosystem/mongoose.mdx +1 -1
  39. package/docs/guides/ecosystem/neon-drizzle.mdx +2 -2
  40. package/docs/guides/ecosystem/neon-serverless-postgres.mdx +2 -2
  41. package/docs/guides/ecosystem/nuxt.mdx +1 -1
  42. package/docs/guides/ecosystem/prisma-postgres.mdx +1 -1
  43. package/docs/guides/ecosystem/prisma.mdx +1 -1
  44. package/docs/guides/ecosystem/qwik.mdx +4 -4
  45. package/docs/guides/ecosystem/sentry.mdx +2 -2
  46. package/docs/guides/ecosystem/sveltekit.mdx +1 -1
  47. package/docs/guides/ecosystem/tanstack-start.mdx +0 -1
  48. package/docs/guides/ecosystem/upstash.mdx +2 -2
  49. package/docs/guides/ecosystem/vite.mdx +2 -2
  50. package/docs/guides/html-rewriter/extract-links.mdx +2 -2
  51. package/docs/guides/html-rewriter/extract-social-meta.mdx +1 -1
  52. package/docs/guides/http/file-uploads.mdx +1 -1
  53. package/docs/guides/http/hot.mdx +1 -1
  54. package/docs/guides/http/server.mdx +1 -1
  55. package/docs/guides/http/simple.mdx +1 -1
  56. package/docs/guides/http/stream-file.mdx +3 -3
  57. package/docs/guides/http/tls.mdx +1 -1
  58. package/docs/guides/install/add-dev.mdx +1 -1
  59. package/docs/guides/install/add-git.mdx +1 -1
  60. package/docs/guides/install/add-optional.mdx +1 -1
  61. package/docs/guides/install/add-peer.mdx +3 -3
  62. package/docs/guides/install/add-tarball.mdx +1 -1
  63. package/docs/guides/install/add.mdx +1 -1
  64. package/docs/guides/install/azure-artifacts.mdx +3 -3
  65. package/docs/guides/install/custom-registry.mdx +2 -2
  66. package/docs/guides/install/from-npm-install-to-bun-install.mdx +1 -1
  67. package/docs/guides/install/git-diff-bun-lockfile.mdx +2 -1
  68. package/docs/guides/install/npm-alias.mdx +1 -1
  69. package/docs/guides/install/registry-scope.mdx +3 -3
  70. package/docs/guides/install/trusted.mdx +1 -1
  71. package/docs/guides/install/workspaces.mdx +1 -1
  72. package/docs/guides/install/yarnlock.mdx +4 -3
  73. package/docs/guides/process/ctrl-c.mdx +1 -1
  74. package/docs/guides/process/ipc.mdx +2 -2
  75. package/docs/guides/process/nanoseconds.mdx +1 -1
  76. package/docs/guides/process/os-signals.mdx +1 -1
  77. package/docs/guides/process/spawn-stderr.mdx +2 -2
  78. package/docs/guides/process/spawn-stdout.mdx +2 -2
  79. package/docs/guides/process/spawn.mdx +2 -2
  80. package/docs/guides/process/stdin.mdx +1 -1
  81. package/docs/guides/read-file/arraybuffer.mdx +2 -2
  82. package/docs/guides/read-file/buffer.mdx +1 -1
  83. package/docs/guides/read-file/exists.mdx +1 -1
  84. package/docs/guides/read-file/mime.mdx +1 -1
  85. package/docs/guides/read-file/stream.mdx +1 -1
  86. package/docs/guides/read-file/uint8array.mdx +1 -1
  87. package/docs/guides/read-file/watch.mdx +1 -1
  88. package/docs/guides/runtime/build-time-constants.mdx +3 -3
  89. package/docs/guides/runtime/cicd.mdx +1 -1
  90. package/docs/guides/runtime/codesign-macos-executable.mdx +1 -1
  91. package/docs/guides/runtime/delete-directory.mdx +1 -1
  92. package/docs/guides/runtime/delete-file.mdx +1 -1
  93. package/docs/guides/runtime/heap-snapshot.mdx +1 -1
  94. package/docs/guides/runtime/import-json.mdx +1 -1
  95. package/docs/guides/runtime/import-toml.mdx +1 -1
  96. package/docs/guides/runtime/import-yaml.mdx +1 -1
  97. package/docs/guides/runtime/read-env.mdx +1 -1
  98. package/docs/guides/runtime/set-env.mdx +2 -2
  99. package/docs/guides/runtime/shell.mdx +1 -1
  100. package/docs/guides/runtime/tsconfig-paths.mdx +1 -1
  101. package/docs/guides/runtime/typescript.mdx +1 -1
  102. package/docs/guides/runtime/vscode-debugger.mdx +1 -2
  103. package/docs/guides/runtime/web-debugger.mdx +1 -1
  104. package/docs/guides/streams/to-array.mdx +1 -1
  105. package/docs/guides/streams/to-arraybuffer.mdx +1 -1
  106. package/docs/guides/streams/to-blob.mdx +1 -1
  107. package/docs/guides/streams/to-buffer.mdx +1 -1
  108. package/docs/guides/streams/to-json.mdx +1 -1
  109. package/docs/guides/streams/to-string.mdx +1 -1
  110. package/docs/guides/streams/to-typedarray.mdx +1 -1
  111. package/docs/guides/test/bail.mdx +1 -1
  112. package/docs/guides/test/concurrent-test-glob.mdx +5 -2
  113. package/docs/guides/test/coverage-threshold.mdx +1 -1
  114. package/docs/guides/test/coverage.mdx +1 -1
  115. package/docs/guides/test/happy-dom.mdx +1 -1
  116. package/docs/guides/test/migrate-from-jest.mdx +7 -7
  117. package/docs/guides/test/mock-clock.mdx +2 -2
  118. package/docs/guides/test/mock-functions.mdx +1 -1
  119. package/docs/guides/test/rerun-each.mdx +1 -1
  120. package/docs/guides/test/run-tests.mdx +2 -2
  121. package/docs/guides/test/skip-tests.mdx +2 -2
  122. package/docs/guides/test/snapshot.mdx +4 -4
  123. package/docs/guides/test/spy-on.mdx +1 -1
  124. package/docs/guides/test/svelte-test.mdx +4 -4
  125. package/docs/guides/test/testing-library.mdx +3 -3
  126. package/docs/guides/test/timeout.mdx +1 -1
  127. package/docs/guides/test/todo-tests.mdx +2 -2
  128. package/docs/guides/test/update-snapshots.mdx +1 -1
  129. package/docs/guides/test/watch-mode.mdx +1 -1
  130. package/docs/guides/util/base64.mdx +1 -1
  131. package/docs/guides/util/deep-equals.mdx +3 -3
  132. package/docs/guides/util/deflate.mdx +1 -1
  133. package/docs/guides/util/entrypoint.mdx +2 -2
  134. package/docs/guides/util/escape-html.mdx +1 -1
  135. package/docs/guides/util/file-url-to-path.mdx +1 -1
  136. package/docs/guides/util/gzip.mdx +1 -1
  137. package/docs/guides/util/hash-a-password.mdx +1 -1
  138. package/docs/guides/util/import-meta-dir.mdx +2 -2
  139. package/docs/guides/util/import-meta-file.mdx +2 -2
  140. package/docs/guides/util/import-meta-path.mdx +2 -2
  141. package/docs/guides/util/javascript-uuid.mdx +2 -2
  142. package/docs/guides/util/main.mdx +1 -1
  143. package/docs/guides/util/path-to-file-url.mdx +1 -1
  144. package/docs/guides/util/sleep.mdx +1 -1
  145. package/docs/guides/util/version.mdx +2 -2
  146. package/docs/guides/util/which-path-to-executable-bin.mdx +1 -1
  147. package/docs/guides/websocket/context.mdx +1 -1
  148. package/docs/guides/websocket/simple.mdx +1 -1
  149. package/docs/guides/write-file/basic.mdx +2 -2
  150. package/docs/guides/write-file/blob.mdx +2 -2
  151. package/docs/guides/write-file/cat.mdx +2 -2
  152. package/docs/guides/write-file/file-cp.mdx +2 -2
  153. package/docs/guides/write-file/filesink.mdx +1 -1
  154. package/docs/guides/write-file/response.mdx +2 -2
  155. package/docs/guides/write-file/stdout.mdx +2 -2
  156. package/docs/guides/write-file/stream.mdx +2 -2
  157. package/docs/guides/write-file/unlink.mdx +1 -1
  158. package/docs/index.mdx +2 -2
  159. package/docs/installation.mdx +3 -3
  160. package/docs/pm/bunx.mdx +2 -2
  161. package/docs/pm/cli/install.mdx +8 -8
  162. package/docs/pm/cli/link.mdx +2 -2
  163. package/docs/pm/cli/outdated.mdx +3 -3
  164. package/docs/pm/cli/patch.mdx +2 -2
  165. package/docs/pm/cli/pm.mdx +1 -1
  166. package/docs/pm/cli/publish.mdx +1 -1
  167. package/docs/pm/filter.mdx +2 -2
  168. package/docs/pm/isolated-installs.mdx +3 -3
  169. package/docs/pm/npmrc.mdx +6 -6
  170. package/docs/pm/scopes-registries.mdx +1 -1
  171. package/docs/pm/security-scanner-api.mdx +2 -2
  172. package/docs/pm/workspaces.mdx +3 -4
  173. package/docs/project/benchmarking.mdx +1 -1
  174. package/docs/project/building-windows.mdx +1 -1
  175. package/docs/project/contributing.mdx +1 -1
  176. package/docs/project/license.mdx +1 -1
  177. package/docs/quickstart.mdx +3 -3
  178. package/docs/runtime/auto-install.mdx +1 -1
  179. package/docs/runtime/binary-data.mdx +1 -1
  180. package/docs/runtime/bun-apis.mdx +35 -35
  181. package/docs/runtime/bunfig.mdx +29 -3
  182. package/docs/runtime/c-compiler.mdx +3 -3
  183. package/docs/runtime/child-process.mdx +2 -2
  184. package/docs/runtime/cookies.mdx +19 -19
  185. package/docs/runtime/debugger.mdx +4 -4
  186. package/docs/runtime/environment-variables.mdx +24 -7
  187. package/docs/runtime/ffi.mdx +2 -2
  188. package/docs/runtime/file-io.mdx +2 -2
  189. package/docs/runtime/file-types.mdx +5 -5
  190. package/docs/runtime/globals.mdx +4 -4
  191. package/docs/runtime/http/error-handling.mdx +2 -2
  192. package/docs/runtime/http/routing.mdx +1 -1
  193. package/docs/runtime/http/server.mdx +5 -9
  194. package/docs/runtime/http/websockets.mdx +1 -1
  195. package/docs/runtime/index.mdx +2 -2
  196. package/docs/runtime/jsx.mdx +1 -1
  197. package/docs/runtime/module-resolution.mdx +2 -2
  198. package/docs/runtime/networking/fetch.mdx +4 -4
  199. package/docs/runtime/nodejs-compat.mdx +3 -3
  200. package/docs/runtime/plugins.mdx +1 -1
  201. package/docs/runtime/s3.mdx +4 -4
  202. package/docs/runtime/secrets.mdx +10 -7
  203. package/docs/runtime/sql.mdx +10 -10
  204. package/docs/runtime/sqlite.mdx +15 -4
  205. package/docs/runtime/templating/create.mdx +4 -4
  206. package/docs/runtime/transpiler.mdx +1 -1
  207. package/docs/runtime/utils.mdx +3 -3
  208. package/docs/runtime/watch-mode.mdx +1 -1
  209. package/docs/runtime/workers.mdx +5 -17
  210. package/docs/snippets/cli/publish.mdx +2 -2
  211. package/docs/test/configuration.mdx +1 -1
  212. package/docs/test/dom.mdx +1 -1
  213. package/docs/test/index.mdx +8 -8
  214. package/docs/test/reporters.mdx +1 -1
  215. package/docs/test/snapshots.mdx +3 -3
  216. package/docs/test/writing-tests.mdx +37 -0
  217. package/docs/typescript.mdx +2 -2
  218. package/package.json +3 -4
  219. package/docs/snippets/product-card.mdx +0 -32
  220. package/docs/snippets/product-tiles.mdx +0 -94
package/CLAUDE.md CHANGED
@@ -5,6 +5,7 @@ Default to using Bun instead of Node.js.
5
5
  - Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild`
6
6
  - Use `bun install` instead of `npm install` or `yarn install` or `pnpm install`
7
7
  - Use `bun run <script>` instead of `npm run <script>` or `yarn run <script>` or `pnpm run <script>`
8
+ - Use `bunx <package> <command>` instead of `npx <package> <command>`
8
9
  - Bun automatically loads .env, so don't use dotenv.
9
10
 
10
11
  ## APIs
@@ -81,12 +82,11 @@ With the following `frontend.tsx`:
81
82
 
82
83
  ```tsx#frontend.tsx
83
84
  import React from "react";
85
+ import { createRoot } from "react-dom/client";
84
86
 
85
87
  // import .css files directly and it works
86
88
  import './index.css';
87
89
 
88
- import { createRoot } from "react-dom/client";
89
-
90
90
  const root = createRoot(document.body);
91
91
 
92
92
  export default function Frontend() {
@@ -102,4 +102,4 @@ Then, run index.ts
102
102
  bun --hot ./index.ts
103
103
  ```
104
104
 
105
- For more information, read the Bun API docs in `docs/**.md`.
105
+ For more information, read the Bun API docs in `docs/**.mdx`.
@@ -72,7 +72,7 @@ Bun's CSS bundler automatically converts this nested syntax into traditional fla
72
72
 
73
73
  You can also nest media queries and other at-rules inside selectors, eliminating the need to repeat selector patterns:
74
74
 
75
- ```css title="styles.css" icon="file-code"
75
+ ```scss title="styles.css" icon="file-code"
76
76
  .responsive-element {
77
77
  display: block;
78
78
 
@@ -118,7 +118,7 @@ These constants are embedded directly into your compiled binary at build time, p
118
118
 
119
119
  <Note>
120
120
  For comprehensive examples and advanced patterns, see the [Build-time constants
121
- guide](https://bun.com/guides/runtime/build-time-constants).
121
+ guide](/docs/guides/runtime/build-time-constants).
122
122
  </Note>
123
123
 
124
124
  ---
@@ -183,6 +183,35 @@ console.log(process.execArgv); // ["--smol", "--user-agent=MyBot"]
183
183
 
184
184
  ---
185
185
 
186
+ ## Disabling automatic config loading
187
+
188
+ By default, standalone executables look for `.env` and `bunfig.toml` files in the directory where the executable is run. You can disable this behavior at build time for deterministic execution regardless of the user's working directory.
189
+
190
+ ```bash icon="terminal" terminal
191
+ # Disable .env loading
192
+ bun build --compile --no-compile-autoload-dotenv ./app.ts --outfile myapp
193
+
194
+ # Disable bunfig.toml loading
195
+ bun build --compile --no-compile-autoload-bunfig ./app.ts --outfile myapp
196
+
197
+ # Disable both
198
+ bun build --compile --no-compile-autoload-dotenv --no-compile-autoload-bunfig ./app.ts --outfile myapp
199
+ ```
200
+
201
+ You can also configure this via the JavaScript API:
202
+
203
+ ```ts
204
+ await Bun.build({
205
+ entrypoints: ["./app.ts"],
206
+ compile: {
207
+ autoloadDotenv: false, // Disable .env loading
208
+ autoloadBunfig: false, // Disable bunfig.toml loading
209
+ },
210
+ });
211
+ ```
212
+
213
+ ---
214
+
186
215
  ## Act as the Bun CLI
187
216
 
188
217
  <Note>New in Bun v1.2.16</Note>
@@ -259,12 +288,12 @@ console.log(`Server running at http://localhost:${server.port}`);
259
288
  </head>
260
289
  <body>
261
290
  <h1>Hello World</h1>
262
- <script src="./app.js"></script>
291
+ <script src="./app.ts"></script>
263
292
  </body>
264
293
  </html>
265
294
  ```
266
295
 
267
- ```ts app.js icon="file-code"
296
+ ```ts app.ts icon="file-code"
268
297
  console.log("Hello from the client!");
269
298
  ```
270
299
 
@@ -297,7 +326,7 @@ The result is a single file that can be deployed anywhere without needing Node.j
297
326
 
298
327
  Bun automatically handles serving the frontend assets with proper MIME types and cache headers. The HTML import is replaced with a manifest object that `Bun.serve` uses to efficiently serve pre-bundled assets.
299
328
 
300
- For more details on building full-stack applications with Bun, see the [full-stack guide](/bundler/fullstack).
329
+ For more details on building full-stack applications with Bun, see the [full-stack guide](/docs/bundler/fullstack).
301
330
 
302
331
  ---
303
332
 
@@ -632,7 +632,7 @@ const server = serve({
632
632
  console.log(`🚀 Server running on ${server.url}`);
633
633
  ```
634
634
 
635
- ```html title="public/index.html"
635
+ ```html title="public/index.html" icon="file-code"
636
636
  <!DOCTYPE html>
637
637
  <html>
638
638
  <head>
@@ -757,7 +757,7 @@ export function App() {
757
757
  }
758
758
  ```
759
759
 
760
- ```css title="src/styles.css"
760
+ ```css title="src/styles.css" icon="file-code"
761
761
  * {
762
762
  margin: 0;
763
763
  padding: 0;
@@ -999,7 +999,7 @@ CMD ["bun", "index.js"]
999
999
 
1000
1000
  ### Environment Variables
1001
1001
 
1002
- ```bash title=".env.production" icon="file-code"
1002
+ ```ini title=".env.production" icon="file-code"
1003
1003
  NODE_ENV=production
1004
1004
  PORT=3000
1005
1005
  DATABASE_URL=postgresql://user:pass@localhost:5432/myapp
@@ -9,7 +9,7 @@ Hot Module Replacement (HMR) allows you to update modules in a running applicati
9
9
 
10
10
  ## `import.meta.hot` API Reference
11
11
 
12
- Bun implements a client-side HMR API modeled after [Vite's `import.meta.hot` API](https://vitejs.dev/guide/api-hmr.html). It can be checked for with `if (import.meta.hot)`, tree-shaking it in production.
12
+ Bun implements a client-side HMR API modeled after [Vite's `import.meta.hot` API](https://vite.dev/guide/api-hmr). It can be checked for with `if (import.meta.hot)`, tree-shaking it in production.
13
13
 
14
14
  ```ts title="index.ts" icon="/icons/typescript.svg"
15
15
  if (import.meta.hot) {
@@ -144,7 +144,7 @@ Indicates that multiple dependencies' modules can be accepted. This variant acce
144
144
 
145
145
  `import.meta.hot.data` maintains state between module instances during hot replacement, enabling data transfer from previous to new versions. When `import.meta.hot.data` is written into, Bun will also mark this module as capable of self-accepting (equivalent of calling `import.meta.hot.accept()`).
146
146
 
147
- ```jsx title="index.ts" icon="/icons/typescript.svg"
147
+ ```tsx title="index.tsx" icon="/icons/typescript.svg"
148
148
  import { createRoot } from "react-dom/client";
149
149
  import { App } from "./app";
150
150
 
@@ -25,7 +25,7 @@ bun ./index.html
25
25
  ```
26
26
 
27
27
  ```
28
- Bun v1.3.2
28
+ Bun v1.3.3
29
29
  ready in 6.62ms
30
30
  → http://localhost:3000/
31
31
  Press h + Enter to show shortcuts
@@ -51,7 +51,7 @@ bun index.html
51
51
  ```
52
52
 
53
53
  ```
54
- Bun v1.3.2
54
+ Bun v1.3.3
55
55
  ready in 6.62ms
56
56
  → http://localhost:3000/
57
57
  Press h + Enter to show shortcuts
@@ -81,7 +81,7 @@ bun ./index.html ./about.html
81
81
  ```
82
82
 
83
83
  ```txt
84
- Bun v1.3.2
84
+ Bun v1.3.3
85
85
  ready in 6.62ms
86
86
  → http://localhost:3000/
87
87
  Routes:
@@ -104,7 +104,7 @@ bun ./**/*.html
104
104
  ```
105
105
 
106
106
  ```
107
- Bun v1.3.2
107
+ Bun v1.3.3
108
108
  ready in 6.62ms
109
109
  → http://localhost:3000/
110
110
  Routes:
@@ -122,7 +122,7 @@ bun ./index.html ./about/index.html ./about/foo/index.html
122
122
  ```
123
123
 
124
124
  ```
125
- Bun v1.3.2
125
+ Bun v1.3.3
126
126
  ready in 6.62ms
127
127
  → http://localhost:3000/
128
128
  Routes:
@@ -164,7 +164,7 @@ For example:
164
164
  }
165
165
  ```
166
166
 
167
- ```css abc.css
167
+ ```css abc.css icon="file-code"
168
168
  body {
169
169
  background-color: red;
170
170
  }
@@ -174,7 +174,7 @@ body {
174
174
 
175
175
  This outputs:
176
176
 
177
- ```css
177
+ ```css styles.css icon="file-code"
178
178
  body {
179
179
  background-color: red;
180
180
  }
@@ -273,7 +273,7 @@ bun ./index.html --console
273
273
  ```
274
274
 
275
275
  ```
276
- Bun v1.3.2
276
+ Bun v1.3.3
277
277
  ready in 6.62ms
278
278
  → http://localhost:3000/
279
279
  Press h + Enter to show shortcuts
@@ -385,7 +385,8 @@ All paths are resolved relative to your HTML file, making it easy to organize yo
385
385
  - Need more configuration options for things like asset handling
386
386
  - Need a way to configure CORS, headers, etc.
387
387
 
388
- If you want to submit a PR, most of the code is [here](https://github.com/oven-sh/bun/blob/main/src/bun.js/api/bun/html-rewriter.ts). You could even copy paste that file into your project and use it as a starting point.
388
+ {/* todo: find the correct link to link to as this 404's and there isn't any similar files */}
389
+ {/* If you want to submit a PR, most of the code is [here](https://github.com/oven-sh/bun/blob/main/src/bun.js/api/bun/html-rewriter.ts). You could even copy paste that file into your project and use it as a starting point. */}
389
390
 
390
391
  </Warning>
391
392
 
@@ -106,7 +106,7 @@ For each file specified in `entrypoints`, Bun will generate a new bundle. This b
106
106
 
107
107
  The contents of `out/index.js` will look something like this:
108
108
 
109
- ```ts title="out/index.js" icon="/icons/javascript.svg"
109
+ ```js title="out/index.js" icon="/icons/javascript.svg"
110
110
  // out/index.js
111
111
  // ...
112
112
  // ~20k lines of code
@@ -154,7 +154,7 @@ bun build ./index.tsx --outdir ./out --watch
154
154
 
155
155
  ## Content types
156
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](/bundler/loaders) for full documentation.
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
158
 
159
159
  | Extensions | Details |
160
160
  | ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
@@ -190,11 +190,11 @@ console.log(logo);
190
190
 
191
191
  The exact behavior of the file loader is also impacted by [`naming`](#naming) and [`publicPath`](#publicpath).
192
192
 
193
- <Info>Refer to the [Bundler > Loaders](/bundler/loaders) page for more complete documentation on the file loader.</Info>
193
+ <Info>Refer to the [Bundler > Loaders](/docs/bundler/loaders) page for more complete documentation on the file loader.</Info>
194
194
 
195
195
  ### Plugins
196
196
 
197
- The behavior described in this table can be overridden or extended with plugins. Refer to the [Bundler > Loaders](/bundler/loaders) page for complete documentation.
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
198
 
199
199
  ## API
200
200
 
@@ -498,7 +498,7 @@ await Bun.build({
498
498
  });
499
499
  ```
500
500
 
501
- Bun implements a universal plugin system for both Bun's runtime and bundler. Refer to the [plugin documentation](/bundler/plugins) for complete documentation.
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
502
 
503
503
  ### env
504
504
 
@@ -527,7 +527,7 @@ Injects environment variables into the bundled output by converting `process.env
527
527
 
528
528
  For the input below:
529
529
 
530
- ```ts title="input.js" icon="/icons/javascript.svg"
530
+ ```js title="input.js" icon="/icons/javascript.svg"
531
531
  // input.js
532
532
  console.log(process.env.FOO);
533
533
  console.log(process.env.BAZ);
@@ -535,7 +535,7 @@ console.log(process.env.BAZ);
535
535
 
536
536
  The generated bundle will contain the following code:
537
537
 
538
- ```ts title="output.js" icon="/icons/javascript.svg"
538
+ ```js title="output.js" icon="/icons/javascript.svg"
539
539
  // output.js
540
540
  console.log("bar");
541
541
  console.log("123");
@@ -580,7 +580,7 @@ console.log(process.env.BAZ);
580
580
 
581
581
  The generated bundle will contain the following code:
582
582
 
583
- ```ts title="output.js" icon="/icons/javascript.svg"
583
+ ```js title="output.js" icon="/icons/javascript.svg"
584
584
  console.log(process.env.FOO);
585
585
  console.log("https://acme.com");
586
586
  console.log(process.env.BAZ);
@@ -722,7 +722,7 @@ Normally, bundling `index.tsx` would generate a bundle containing the entire sou
722
722
 
723
723
  The generated bundle will look something like this:
724
724
 
725
- ```ts title="out/index.js" icon="/icons/javascript.svg"
725
+ ```js title="out/index.js" icon="/icons/javascript.svg"
726
726
  import { z } from "zod";
727
727
 
728
728
  // ...
@@ -1026,7 +1026,7 @@ Setting `publicPath` will prefix all file paths with the specified value.
1026
1026
 
1027
1027
  The output file would now look something like this.
1028
1028
 
1029
- ```ts title="out/index.js" icon="/icons/javascript.svg"
1029
+ ```js title="out/index.js" icon="/icons/javascript.svg"
1030
1030
  var logo = "https://cdn.example.com/logo-a7305bdef.svg";
1031
1031
  ```
1032
1032
 
@@ -1181,7 +1181,7 @@ Each artifact also contains the following properties:
1181
1181
  | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
1182
1182
  | `kind` | What kind of build output this file is. A build generates bundled entrypoints, code-split "chunks", sourcemaps, bytecode, and copied assets (like images). |
1183
1183
  | `path` | Absolute path to the file on disk |
1184
- | `loader` | The loader was used to interpret the file. See [Bundler > Loaders](/bundler/loaders) to see how Bun maps file extensions to the appropriate built-in loader. |
1184
+ | `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. |
1185
1185
  | `hash` | The hash of the file contents. Always defined for assets. |
1186
1186
  | `sourcemap` | The sourcemap file corresponding to this file, if generated. Only defined for entrypoints and chunks. |
1187
1187
 
@@ -1268,7 +1268,7 @@ bun build ./cli.tsx --outfile mycli --compile
1268
1268
  ./mycli
1269
1269
  ```
1270
1270
 
1271
- Refer to [Bundler > Executables](/bundler/executables) for complete documentation.
1271
+ Refer to [Bundler > Executables](/docs/bundler/executables) for complete documentation.
1272
1272
 
1273
1273
  ## Logs and errors
1274
1274
 
@@ -1356,10 +1356,12 @@ interface BuildConfig {
1356
1356
  * JSX configuration object for controlling JSX transform behavior
1357
1357
  */
1358
1358
  jsx?: {
1359
+ runtime?: "automatic" | "classic";
1360
+ importSource?: string;
1359
1361
  factory?: string;
1360
1362
  fragment?: string;
1361
- importSource?: string;
1362
- runtime?: "automatic" | "classic";
1363
+ sideEffects?: boolean;
1364
+ development?: boolean;
1363
1365
  };
1364
1366
  naming?:
1365
1367
  | string
@@ -1443,13 +1445,20 @@ interface BuildConfig {
1443
1445
  drop?: string[];
1444
1446
 
1445
1447
  /**
1446
- * When set to `true`, the returned promise rejects with an AggregateError when a build failure happens.
1447
- * When set to `false`, the `success` property of the returned object will be `false` when a build failure happens.
1448
+ * - When set to `true`, the returned promise rejects with an AggregateError when a build failure happens.
1449
+ * - When set to `false`, returns a {@link BuildOutput} with `{success: false}`
1448
1450
  *
1449
- * This defaults to `false` in Bun 1.1 and will change to `true` in Bun 1.2
1450
- * as most usage of `Bun.build` forgets to check for errors.
1451
+ * @default true
1451
1452
  */
1452
1453
  throw?: boolean;
1454
+
1455
+ /**
1456
+ * Custom tsconfig.json file path to use for path resolution.
1457
+ * Equivalent to `--tsconfig-override` in the CLI.
1458
+ */
1459
+ tsconfig?: string;
1460
+
1461
+ outdir?: string;
1453
1462
  }
1454
1463
 
1455
1464
  interface BuildOutput {
@@ -312,7 +312,7 @@ The `html` loader processes HTML files and bundles any referenced assets. It wil
312
312
 
313
313
  For example, given this HTML file:
314
314
 
315
- ```html title="src/index.html"
315
+ ```html title="src/index.html" icon="file-code"
316
316
  <!DOCTYPE html>
317
317
  <html>
318
318
  <body>
@@ -325,7 +325,7 @@ For example, given this HTML file:
325
325
 
326
326
  It will output a new HTML file with the bundled assets:
327
327
 
328
- ```html title="dist/index.html"
328
+ ```html title="dist/index.html" icon="file-code"
329
329
  <!DOCTYPE html>
330
330
  <html>
331
331
  <body>
@@ -87,7 +87,7 @@ macro();
87
87
 
88
88
  When shipping a library containing a macro to npm or another package registry, use the `"macro"` export condition to provide a special version of your package exclusively for the macro environment.
89
89
 
90
- ```json title="package.json" icon="file-code"
90
+ ```json title="package.json" icon="file-json"
91
91
  {
92
92
  "name": "my-package",
93
93
  "exports": {
package/docs/feedback.mdx CHANGED
@@ -4,13 +4,9 @@ description: Share feedback, bug reports, and feature requests
4
4
  mode: center
5
5
  ---
6
6
 
7
- import Feedback from "/snippets/cli/feedback.mdx";
8
-
9
7
  Whether you've found a bug, have a performance issue, or just want to suggest an improvement, here's how you can open a helpful issue:
10
8
 
11
- <Callout icon="discord">
12
- For general questions, please join our [Discord](https://discord.com/invite/CXdq2DP29u).
13
- </Callout>
9
+ <Callout icon="discord">For general questions, please join our [Discord](https://bun.com/discord).</Callout>
14
10
 
15
11
  ## Reporting Issues
16
12
 
@@ -56,9 +52,7 @@ Whether you've found a bug, have a performance issue, or just want to suggest an
56
52
  <Note>
57
53
  - For MacOS and Linux: copy the output of `uname -mprs`
58
54
  - For Windows: copy the output of this command in the powershell console:
59
- ```powershell
60
- "$([Environment]::OSVersion | ForEach-Object VersionString) $(if ([Environment]::Is64BitOperatingSystem) { "x64" } else { "x86" })"
61
- ```
55
+ `"$([Environment]::OSVersion | ForEach-Object VersionString) $(if ([Environment]::Is64BitOperatingSystem) { "x64" } else { "x86" })"`
62
56
  </Note>
63
57
  </Step>
64
58
 
@@ -79,7 +73,3 @@ echo "please document X" | bun feedback --email you@example.com
79
73
  ```
80
74
 
81
75
  You can provide feedback as text arguments, file paths, or piped input.
82
-
83
- ---
84
-
85
- <Feedback />
@@ -26,4 +26,4 @@ const regularArr = Array.from(uintArr);
26
26
 
27
27
  ---
28
28
 
29
- See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
29
+ See [Docs > API > Binary Data](/docs/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
@@ -23,4 +23,4 @@ blob.type; // => "application/octet-stream"
23
23
 
24
24
  ---
25
25
 
26
- See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
26
+ See [Docs > API > Binary Data](/docs/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
@@ -24,4 +24,4 @@ const nodeBuffer = Buffer.from(arrBuffer, 0, 16); // view first 16 bytes
24
24
 
25
25
  ---
26
26
 
27
- See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
27
+ See [Docs > API > Binary Data](/docs/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
@@ -14,4 +14,4 @@ const str = decoder.decode(buf);
14
14
 
15
15
  ---
16
16
 
17
- See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
17
+ See [Docs > API > Binary Data](/docs/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
@@ -38,4 +38,4 @@ const arr = new Uint8Array(buffer, 0, 16); // view first 16 bytes
38
38
 
39
39
  ---
40
40
 
41
- See [Docs > API > Utils](https://bun.com/docs/api/utils) for more useful utilities.
41
+ See [Docs > API > Utils](/docs/runtime/utils) for more useful utilities.
@@ -13,4 +13,4 @@ const buf = await blob.arrayBuffer();
13
13
 
14
14
  ---
15
15
 
16
- See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
16
+ See [Docs > API > Binary Data](/docs/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
@@ -13,4 +13,4 @@ const arr = new DataView(await blob.arrayBuffer());
13
13
 
14
14
  ---
15
15
 
16
- See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
16
+ See [Docs > API > Binary Data](/docs/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
@@ -13,4 +13,4 @@ const stream = await blob.stream();
13
13
 
14
14
  ---
15
15
 
16
- See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
16
+ See [Docs > API > Binary Data](/docs/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
@@ -14,4 +14,4 @@ const str = await blob.text();
14
14
 
15
15
  ---
16
16
 
17
- See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
17
+ See [Docs > API > Binary Data](/docs/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
@@ -13,4 +13,4 @@ const arr = new Uint8Array(await blob.arrayBuffer());
13
13
 
14
14
  ---
15
15
 
16
- See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
16
+ See [Docs > API > Binary Data](/docs/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
@@ -13,4 +13,4 @@ const arrBuf = nodeBuf.buffer;
13
13
 
14
14
  ---
15
15
 
16
- See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
16
+ See [Docs > API > Binary Data](/docs/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
@@ -13,4 +13,4 @@ const blob = new Blob([buf]);
13
13
 
14
14
  ---
15
15
 
16
- See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
16
+ See [Docs > API > Binary Data](/docs/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
@@ -40,4 +40,4 @@ const stream = blob.stream(1024);
40
40
 
41
41
  ---
42
42
 
43
- See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
43
+ See [Docs > API > Binary Data](/docs/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
@@ -24,4 +24,4 @@ const str = buf.toString("utf8", 0, 5);
24
24
 
25
25
  ---
26
26
 
27
- See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
27
+ See [Docs > API > Binary Data](/docs/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
@@ -13,4 +13,4 @@ buf instanceof Uint8Array; // => true
13
13
 
14
14
  ---
15
15
 
16
- See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
16
+ See [Docs > API > Binary Data](/docs/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
@@ -14,4 +14,4 @@ const str = decoder.decode(dv);
14
14
 
15
15
  ---
16
16
 
17
- See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
17
+ See [Docs > API > Binary Data](/docs/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
@@ -24,4 +24,4 @@ arr.byteLength; // => 32
24
24
 
25
25
  ---
26
26
 
27
- See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
27
+ See [Docs > API > Binary Data](/docs/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
@@ -15,4 +15,4 @@ console.log(await blob.text());
15
15
 
16
16
  ---
17
17
 
18
- See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
18
+ See [Docs > API > Binary Data](/docs/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
@@ -13,4 +13,4 @@ const buf = Buffer.from(arr);
13
13
 
14
14
  ---
15
15
 
16
- See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
16
+ See [Docs > API > Binary Data](/docs/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
@@ -13,4 +13,4 @@ const dv = new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
13
13
 
14
14
  ---
15
15
 
16
- See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
16
+ See [Docs > API > Binary Data](/docs/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
@@ -40,4 +40,4 @@ const stream = blob.stream(1024);
40
40
 
41
41
  ---
42
42
 
43
- See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
43
+ See [Docs > API > Binary Data](/docs/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
@@ -15,4 +15,4 @@ const str = decoder.decode(arr);
15
15
 
16
16
  ---
17
17
 
18
- See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
18
+ See [Docs > API > Binary Data](/docs/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.