bun-types 1.3.2-canary.20251104T140728 → 1.3.2-canary.20251106T140813

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 (312) hide show
  1. package/bun.d.ts +4 -4
  2. package/docs/README.md +28 -0
  3. package/globals.d.ts +0 -1
  4. package/overrides.d.ts +45 -15
  5. package/package.json +1 -1
  6. package/test.d.ts +1 -1
  7. package/docs/api/binary-data.md +0 -1038
  8. package/docs/api/cc.md +0 -197
  9. package/docs/api/color.md +0 -262
  10. package/docs/api/console.md +0 -57
  11. package/docs/api/cookie.md +0 -449
  12. package/docs/api/dns.md +0 -110
  13. package/docs/api/fetch.md +0 -463
  14. package/docs/api/ffi.md +0 -557
  15. package/docs/api/file-io.md +0 -366
  16. package/docs/api/file-system-router.md +0 -112
  17. package/docs/api/file.md +0 -19
  18. package/docs/api/glob.md +0 -178
  19. package/docs/api/globals.md +0 -387
  20. package/docs/api/hashing.md +0 -319
  21. package/docs/api/html-rewriter.md +0 -334
  22. package/docs/api/http.md +0 -1408
  23. package/docs/api/import-meta.md +0 -69
  24. package/docs/api/node-api.md +0 -14
  25. package/docs/api/redis.md +0 -597
  26. package/docs/api/s3.md +0 -850
  27. package/docs/api/secrets.md +0 -319
  28. package/docs/api/semver.md +0 -52
  29. package/docs/api/spawn.md +0 -582
  30. package/docs/api/sql.md +0 -1374
  31. package/docs/api/sqlite.md +0 -694
  32. package/docs/api/streams.md +0 -230
  33. package/docs/api/tcp.md +0 -221
  34. package/docs/api/transpiler.md +0 -276
  35. package/docs/api/udp.md +0 -123
  36. package/docs/api/utils.md +0 -891
  37. package/docs/api/websockets.md +0 -573
  38. package/docs/api/workers.md +0 -322
  39. package/docs/api/yaml.md +0 -668
  40. package/docs/benchmarks.md +0 -120
  41. package/docs/bun-flavored-toml.md +0 -42
  42. package/docs/bundler/css.md +0 -1028
  43. package/docs/bundler/css_modules.md +0 -145
  44. package/docs/bundler/executables.md +0 -626
  45. package/docs/bundler/fullstack.md +0 -418
  46. package/docs/bundler/hmr.md +0 -234
  47. package/docs/bundler/html.md +0 -349
  48. package/docs/bundler/index.md +0 -1735
  49. package/docs/bundler/intro.md +0 -75
  50. package/docs/bundler/loaders.md +0 -410
  51. package/docs/bundler/macros.md +0 -329
  52. package/docs/bundler/plugins.md +0 -449
  53. package/docs/bundler/vs-esbuild.md +0 -1127
  54. package/docs/cli/add.md +0 -173
  55. package/docs/cli/bun-completions.md +0 -3
  56. package/docs/cli/bun-create.md +0 -338
  57. package/docs/cli/bun-install.md +0 -349
  58. package/docs/cli/bun-upgrade.md +0 -39
  59. package/docs/cli/bunx.md +0 -89
  60. package/docs/cli/filter.md +0 -90
  61. package/docs/cli/info.md +0 -65
  62. package/docs/cli/init.md +0 -85
  63. package/docs/cli/install.md +0 -344
  64. package/docs/cli/link.md +0 -40
  65. package/docs/cli/outdated.md +0 -90
  66. package/docs/cli/patch-commit.md +0 -11
  67. package/docs/cli/pm.md +0 -285
  68. package/docs/cli/publish.md +0 -120
  69. package/docs/cli/remove.md +0 -7
  70. package/docs/cli/run.md +0 -261
  71. package/docs/cli/test.md +0 -397
  72. package/docs/cli/unlink.md +0 -9
  73. package/docs/cli/update.md +0 -129
  74. package/docs/cli/why.md +0 -67
  75. package/docs/contributing/upgrading-webkit.md +0 -57
  76. package/docs/ecosystem/elysia.md +0 -24
  77. package/docs/ecosystem/express.md +0 -37
  78. package/docs/ecosystem/hono.md +0 -18
  79. package/docs/ecosystem/react.md +0 -65
  80. package/docs/ecosystem/stric.md +0 -38
  81. package/docs/guides/binary/arraybuffer-to-array.md +0 -27
  82. package/docs/guides/binary/arraybuffer-to-blob.md +0 -24
  83. package/docs/guides/binary/arraybuffer-to-buffer.md +0 -25
  84. package/docs/guides/binary/arraybuffer-to-string.md +0 -15
  85. package/docs/guides/binary/arraybuffer-to-typedarray.md +0 -39
  86. package/docs/guides/binary/blob-to-arraybuffer.md +0 -14
  87. package/docs/guides/binary/blob-to-dataview.md +0 -14
  88. package/docs/guides/binary/blob-to-stream.md +0 -14
  89. package/docs/guides/binary/blob-to-string.md +0 -15
  90. package/docs/guides/binary/blob-to-typedarray.md +0 -14
  91. package/docs/guides/binary/buffer-to-arraybuffer.md +0 -14
  92. package/docs/guides/binary/buffer-to-blob.md +0 -14
  93. package/docs/guides/binary/buffer-to-readablestream.md +0 -41
  94. package/docs/guides/binary/buffer-to-string.md +0 -25
  95. package/docs/guides/binary/buffer-to-typedarray.md +0 -14
  96. package/docs/guides/binary/dataview-to-string.md +0 -15
  97. package/docs/guides/binary/typedarray-to-arraybuffer.md +0 -25
  98. package/docs/guides/binary/typedarray-to-blob.md +0 -16
  99. package/docs/guides/binary/typedarray-to-buffer.md +0 -14
  100. package/docs/guides/binary/typedarray-to-dataview.md +0 -14
  101. package/docs/guides/binary/typedarray-to-readablestream.md +0 -41
  102. package/docs/guides/binary/typedarray-to-string.md +0 -16
  103. package/docs/guides/deployment/railway.md +0 -157
  104. package/docs/guides/ecosystem/astro.md +0 -72
  105. package/docs/guides/ecosystem/discordjs.md +0 -77
  106. package/docs/guides/ecosystem/docker.md +0 -140
  107. package/docs/guides/ecosystem/drizzle.md +0 -185
  108. package/docs/guides/ecosystem/edgedb.md +0 -228
  109. package/docs/guides/ecosystem/elysia.md +0 -31
  110. package/docs/guides/ecosystem/express.md +0 -40
  111. package/docs/guides/ecosystem/hono.md +0 -39
  112. package/docs/guides/ecosystem/mongoose.md +0 -87
  113. package/docs/guides/ecosystem/neon-drizzle.md +0 -220
  114. package/docs/guides/ecosystem/neon-serverless-postgres.md +0 -55
  115. package/docs/guides/ecosystem/nextjs.md +0 -49
  116. package/docs/guides/ecosystem/nuxt.md +0 -56
  117. package/docs/guides/ecosystem/pm2.md +0 -57
  118. package/docs/guides/ecosystem/prisma.md +0 -141
  119. package/docs/guides/ecosystem/qwik.md +0 -107
  120. package/docs/guides/ecosystem/react.md +0 -50
  121. package/docs/guides/ecosystem/remix.md +0 -78
  122. package/docs/guides/ecosystem/render.md +0 -79
  123. package/docs/guides/ecosystem/sentry.md +0 -52
  124. package/docs/guides/ecosystem/solidstart.md +0 -58
  125. package/docs/guides/ecosystem/ssr-react.md +0 -51
  126. package/docs/guides/ecosystem/stric.md +0 -55
  127. package/docs/guides/ecosystem/sveltekit.md +0 -125
  128. package/docs/guides/ecosystem/systemd.md +0 -113
  129. package/docs/guides/ecosystem/vite.md +0 -71
  130. package/docs/guides/html-rewriter/extract-links.md +0 -68
  131. package/docs/guides/html-rewriter/extract-social-meta.md +0 -93
  132. package/docs/guides/http/cluster.md +0 -66
  133. package/docs/guides/http/fetch-unix.md +0 -33
  134. package/docs/guides/http/fetch.md +0 -24
  135. package/docs/guides/http/file-uploads.md +0 -94
  136. package/docs/guides/http/hot.md +0 -26
  137. package/docs/guides/http/proxy.md +0 -24
  138. package/docs/guides/http/server.md +0 -46
  139. package/docs/guides/http/simple.md +0 -18
  140. package/docs/guides/http/stream-file.md +0 -48
  141. package/docs/guides/http/stream-iterator.md +0 -47
  142. package/docs/guides/http/stream-node-streams-in-bun.md +0 -20
  143. package/docs/guides/http/tls.md +0 -30
  144. package/docs/guides/install/add-dev.md +0 -26
  145. package/docs/guides/install/add-git.md +0 -36
  146. package/docs/guides/install/add-optional.md +0 -25
  147. package/docs/guides/install/add-peer.md +0 -43
  148. package/docs/guides/install/add-tarball.md +0 -33
  149. package/docs/guides/install/add.md +0 -42
  150. package/docs/guides/install/azure-artifacts.md +0 -73
  151. package/docs/guides/install/cicd.md +0 -41
  152. package/docs/guides/install/custom-registry.md +0 -30
  153. package/docs/guides/install/from-npm-install-to-bun-install.md +0 -214
  154. package/docs/guides/install/git-diff-bun-lockfile.md +0 -44
  155. package/docs/guides/install/jfrog-artifactory.md +0 -28
  156. package/docs/guides/install/npm-alias.md +0 -23
  157. package/docs/guides/install/registry-scope.md +0 -38
  158. package/docs/guides/install/trusted.md +0 -46
  159. package/docs/guides/install/workspaces.md +0 -70
  160. package/docs/guides/install/yarnlock.md +0 -44
  161. package/docs/guides/process/argv.md +0 -58
  162. package/docs/guides/process/ctrl-c.md +0 -16
  163. package/docs/guides/process/ipc.md +0 -66
  164. package/docs/guides/process/nanoseconds.md +0 -13
  165. package/docs/guides/process/os-signals.md +0 -39
  166. package/docs/guides/process/spawn-stderr.md +0 -31
  167. package/docs/guides/process/spawn-stdout.md +0 -26
  168. package/docs/guides/process/spawn.md +0 -41
  169. package/docs/guides/process/stdin.md +0 -54
  170. package/docs/guides/read-file/arraybuffer.md +0 -28
  171. package/docs/guides/read-file/buffer.md +0 -19
  172. package/docs/guides/read-file/exists.md +0 -16
  173. package/docs/guides/read-file/json.md +0 -17
  174. package/docs/guides/read-file/mime.md +0 -20
  175. package/docs/guides/read-file/stream.md +0 -26
  176. package/docs/guides/read-file/string.md +0 -22
  177. package/docs/guides/read-file/uint8array.md +0 -21
  178. package/docs/guides/read-file/watch.md +0 -68
  179. package/docs/guides/runtime/build-time-constants.md +0 -293
  180. package/docs/guides/runtime/cicd.md +0 -43
  181. package/docs/guides/runtime/codesign-macos-executable.md +0 -56
  182. package/docs/guides/runtime/define-constant.md +0 -145
  183. package/docs/guides/runtime/delete-directory.md +0 -37
  184. package/docs/guides/runtime/delete-file.md +0 -19
  185. package/docs/guides/runtime/heap-snapshot.md +0 -26
  186. package/docs/guides/runtime/import-html.md +0 -15
  187. package/docs/guides/runtime/import-json.md +0 -44
  188. package/docs/guides/runtime/import-toml.md +0 -30
  189. package/docs/guides/runtime/import-yaml.md +0 -102
  190. package/docs/guides/runtime/read-env.md +0 -32
  191. package/docs/guides/runtime/set-env.md +0 -47
  192. package/docs/guides/runtime/shell.md +0 -40
  193. package/docs/guides/runtime/timezone.md +0 -35
  194. package/docs/guides/runtime/tsconfig-paths.md +0 -29
  195. package/docs/guides/runtime/typescript.md +0 -49
  196. package/docs/guides/runtime/vscode-debugger.md +0 -47
  197. package/docs/guides/runtime/web-debugger.md +0 -82
  198. package/docs/guides/streams/node-readable-to-arraybuffer.md +0 -11
  199. package/docs/guides/streams/node-readable-to-blob.md +0 -11
  200. package/docs/guides/streams/node-readable-to-json.md +0 -12
  201. package/docs/guides/streams/node-readable-to-string.md +0 -12
  202. package/docs/guides/streams/node-readable-to-uint8array.md +0 -11
  203. package/docs/guides/streams/to-array.md +0 -14
  204. package/docs/guides/streams/to-arraybuffer.md +0 -14
  205. package/docs/guides/streams/to-blob.md +0 -14
  206. package/docs/guides/streams/to-buffer.md +0 -15
  207. package/docs/guides/streams/to-json.md +0 -14
  208. package/docs/guides/streams/to-string.md +0 -14
  209. package/docs/guides/streams/to-typedarray.md +0 -22
  210. package/docs/guides/test/bail.md +0 -22
  211. package/docs/guides/test/coverage-threshold.md +0 -60
  212. package/docs/guides/test/coverage.md +0 -44
  213. package/docs/guides/test/happy-dom.md +0 -68
  214. package/docs/guides/test/migrate-from-jest.md +0 -143
  215. package/docs/guides/test/mock-clock.md +0 -48
  216. package/docs/guides/test/mock-functions.md +0 -68
  217. package/docs/guides/test/rerun-each.md +0 -14
  218. package/docs/guides/test/run-tests.md +0 -111
  219. package/docs/guides/test/skip-tests.md +0 -39
  220. package/docs/guides/test/snapshot.md +0 -95
  221. package/docs/guides/test/spy-on.md +0 -46
  222. package/docs/guides/test/svelte-test.md +0 -120
  223. package/docs/guides/test/testing-library.md +0 -92
  224. package/docs/guides/test/timeout.md +0 -15
  225. package/docs/guides/test/todo-tests.md +0 -67
  226. package/docs/guides/test/update-snapshots.md +0 -46
  227. package/docs/guides/test/watch-mode.md +0 -19
  228. package/docs/guides/util/base64.md +0 -15
  229. package/docs/guides/util/deep-equals.md +0 -39
  230. package/docs/guides/util/deflate.md +0 -18
  231. package/docs/guides/util/detect-bun.md +0 -23
  232. package/docs/guides/util/entrypoint.md +0 -17
  233. package/docs/guides/util/escape-html.md +0 -22
  234. package/docs/guides/util/file-url-to-path.md +0 -14
  235. package/docs/guides/util/gzip.md +0 -18
  236. package/docs/guides/util/hash-a-password.md +0 -54
  237. package/docs/guides/util/import-meta-dir.md +0 -13
  238. package/docs/guides/util/import-meta-file.md +0 -13
  239. package/docs/guides/util/import-meta-path.md +0 -13
  240. package/docs/guides/util/javascript-uuid.md +0 -23
  241. package/docs/guides/util/main.md +0 -32
  242. package/docs/guides/util/path-to-file-url.md +0 -14
  243. package/docs/guides/util/sleep.md +0 -22
  244. package/docs/guides/util/version.md +0 -21
  245. package/docs/guides/util/which-path-to-executable-bin.md +0 -15
  246. package/docs/guides/websocket/compression.md +0 -31
  247. package/docs/guides/websocket/context.md +0 -77
  248. package/docs/guides/websocket/pubsub.md +0 -41
  249. package/docs/guides/websocket/simple.md +0 -33
  250. package/docs/guides/write-file/append.md +0 -52
  251. package/docs/guides/write-file/basic.md +0 -44
  252. package/docs/guides/write-file/blob.md +0 -28
  253. package/docs/guides/write-file/cat.md +0 -17
  254. package/docs/guides/write-file/file-cp.md +0 -16
  255. package/docs/guides/write-file/filesink.md +0 -52
  256. package/docs/guides/write-file/response.md +0 -17
  257. package/docs/guides/write-file/stdout.md +0 -21
  258. package/docs/guides/write-file/stream.md +0 -17
  259. package/docs/guides/write-file/unlink.md +0 -16
  260. package/docs/index.md +0 -77
  261. package/docs/install/audit.md +0 -57
  262. package/docs/install/cache.md +0 -59
  263. package/docs/install/catalogs.md +0 -298
  264. package/docs/install/index.md +0 -248
  265. package/docs/install/isolated.md +0 -197
  266. package/docs/install/lifecycle.md +0 -46
  267. package/docs/install/lockfile.md +0 -58
  268. package/docs/install/npmrc.md +0 -105
  269. package/docs/install/overrides.md +0 -73
  270. package/docs/install/patch.md +0 -59
  271. package/docs/install/registries.md +0 -30
  272. package/docs/install/security-scanner-api.md +0 -81
  273. package/docs/install/workspaces.md +0 -114
  274. package/docs/installation.md +0 -327
  275. package/docs/project/asan.md +0 -124
  276. package/docs/project/benchmarking.md +0 -203
  277. package/docs/project/bindgen.md +0 -225
  278. package/docs/project/building-windows.md +0 -162
  279. package/docs/project/contributing.md +0 -347
  280. package/docs/project/internals/build-process-for-ci.md +0 -75
  281. package/docs/project/licensing.md +0 -73
  282. package/docs/project/roadmap.md +0 -87
  283. package/docs/quickstart.md +0 -157
  284. package/docs/runtime/autoimport.md +0 -94
  285. package/docs/runtime/bun-apis.md +0 -207
  286. package/docs/runtime/bunfig.md +0 -772
  287. package/docs/runtime/debugger.md +0 -325
  288. package/docs/runtime/env.md +0 -253
  289. package/docs/runtime/hot.md +0 -145
  290. package/docs/runtime/index.md +0 -312
  291. package/docs/runtime/jsx.md +0 -385
  292. package/docs/runtime/loaders.md +0 -130
  293. package/docs/runtime/modules.md +0 -320
  294. package/docs/runtime/nodejs-apis.md +0 -463
  295. package/docs/runtime/plugins.md +0 -561
  296. package/docs/runtime/shell.md +0 -605
  297. package/docs/runtime/typescript.md +0 -139
  298. package/docs/runtime/web-apis.md +0 -128
  299. package/docs/test/configuration.md +0 -154
  300. package/docs/test/coverage.md +0 -142
  301. package/docs/test/discovery.md +0 -85
  302. package/docs/test/dom.md +0 -75
  303. package/docs/test/examples/concurrent-test-glob.md +0 -132
  304. package/docs/test/hot.md +0 -15
  305. package/docs/test/lifecycle.md +0 -81
  306. package/docs/test/mocks.md +0 -313
  307. package/docs/test/reporters.md +0 -117
  308. package/docs/test/runtime-behavior.md +0 -95
  309. package/docs/test/snapshots.md +0 -68
  310. package/docs/test/time.md +0 -126
  311. package/docs/test/writing.md +0 -825
  312. package/docs/typescript.md +0 -53
@@ -1,58 +0,0 @@
1
- ---
2
- name: Build an app with SolidStart and Bun
3
- ---
4
-
5
- {% callout %}
6
- SolidStart currently relies on Node.js APIs that Bun does not yet implement. The guide below uses Bun to initialize a project and install dependencies, but it uses Node.js to run the dev server.
7
- {% /callout %}
8
-
9
- ---
10
-
11
- Initialize a SolidStart app with `create-solid`.
12
-
13
- ```sh
14
- $ bun create solid my-app
15
- create-solid version 0.2.31
16
-
17
- Welcome to the SolidStart setup wizard!
18
-
19
- There are definitely bugs and some feature might not work yet.
20
- If you encounter an issue, have a look at
21
- https://github.com/solidjs/solid-start/issues and open a new one,
22
- if it is not already tracked.
23
-
24
- ✔ Which template do you want to use? › todomvc
25
- ✔ Server Side Rendering? … yes
26
- ✔ Use TypeScript? … yes
27
- cloned solidjs/solid-start#main to /path/to/my-app/.solid-start
28
- ✔ Copied project files
29
- ```
30
-
31
- ---
32
-
33
- As instructed by the `create-solid` CLI, let's install our dependencies.
34
-
35
- ```sh
36
- $ cd my-app
37
- $ bun install
38
- ```
39
-
40
- ---
41
-
42
- Then run the development server.
43
-
44
- ```sh
45
- $ bun run dev
46
- # or, equivalently
47
- $ bunx solid-start dev
48
- ```
49
-
50
- ---
51
-
52
- Open [localhost:3000](http://localhost:3000). Any changes you make to `src/routes/index.tsx` will be hot-reloaded automatically.
53
-
54
- {% image src="https://github.com/oven-sh/bun/assets/3084745/1e8043c4-49d1-498c-9add-c1eaab6c7167" alt="SolidStart demo app" /%}
55
-
56
- ---
57
-
58
- Refer to the [SolidStart website](https://start.solidjs.com/getting-started/what-is-solidstart) for complete framework documentation.
@@ -1,51 +0,0 @@
1
- ---
2
- name: Server-side render (SSR) a React component
3
- ---
4
-
5
- To get started, install `react` & `react-dom`:
6
-
7
- ```sh
8
- # Any package manager can be used
9
- $ bun add react react-dom
10
- ```
11
-
12
- ---
13
-
14
- To render a React component to an HTML stream server-side (SSR):
15
-
16
- ```tsx
17
- import { renderToReadableStream } from "react-dom/server";
18
-
19
- function Component(props: { message: string }) {
20
- return (
21
- <body>
22
- <h1>{props.message}</h1>
23
- </body>
24
- );
25
- }
26
-
27
- const stream = await renderToReadableStream(
28
- <Component message="Hello from server!" />,
29
- );
30
- ```
31
-
32
- ---
33
-
34
- Combining this with `Bun.serve()`, we get a simple SSR HTTP server:
35
-
36
- ```tsx
37
- Bun.serve({
38
- async fetch() {
39
- const stream = await renderToReadableStream(
40
- <Component message="Hello from server!" />,
41
- );
42
- return new Response(stream, {
43
- headers: { "Content-Type": "text/html" },
44
- });
45
- },
46
- });
47
- ```
48
-
49
- ---
50
-
51
- React `19` and later includes an [SSR optimization](https://github.com/facebook/react/pull/25597) that takes advantage of Bun's "direct" `ReadableStream` implementation. If you run into an error like `export named 'renderToReadableStream' not found`, please make sure to install version `19` of `react` & `react-dom`, or import from `react-dom/server.browser` instead of `react-dom/server`. See [facebook/react#28941](https://github.com/facebook/react/issues/28941) for more information.
@@ -1,55 +0,0 @@
1
- ---
2
- name: Build an HTTP server using StricJS and Bun
3
- ---
4
-
5
- [StricJS](https://github.com/bunsvr) is a Bun framework for building high-performance web applications and APIs.
6
-
7
- - **Fast** — Stric is one of the fastest Bun frameworks. See [benchmark](https://github.com/bunsvr/benchmark) for more details.
8
- - **Minimal** — The basic components like `@stricjs/router` and `@stricjs/utils` are under 50kB and require no external dependencies.
9
- - **Extensible** — Stric includes with a plugin system, dependency injection, and optional optimizations for handling requests.
10
-
11
- ---
12
-
13
- Use `bun init` to create an empty project.
14
-
15
- ```bash
16
- $ mkdir myapp
17
- $ cd myapp
18
- $ bun init
19
- $ bun add @stricjs/router @stricjs/utils
20
- ```
21
-
22
- ---
23
-
24
- To implement a simple HTTP server with StricJS:
25
-
26
- ```ts#index.ts
27
- import { Router } from '@stricjs/router';
28
-
29
- export default new Router()
30
- .get('/', () => new Response('Hi'));
31
- ```
32
-
33
- ---
34
-
35
- To serve static files from `/public`:
36
-
37
- ```ts#index.ts
38
- import { dir } from '@stricjs/utils';
39
-
40
- export default new Router()
41
- .get('/', () => new Response('Hi'))
42
- .get('/*', dir('./public'));
43
- ```
44
-
45
- ---
46
-
47
- Run the file in watch mode to start the development server.
48
-
49
- ```bash
50
- $ bun --watch run index.ts
51
- ```
52
-
53
- ---
54
-
55
- For more info, see Stric's [documentation](https://stricjs.netlify.app).
@@ -1,125 +0,0 @@
1
- ---
2
- name: Build an app with SvelteKit and Bun
3
- ---
4
-
5
- Use `sv create my-app` to create a SvelteKit project with SvelteKit CLI. Answer the prompts to select a template and set up your development environment.
6
-
7
- ```sh
8
- $ bunx sv create my-app
9
- ┌ Welcome to the Svelte CLI! (v0.5.7)
10
-
11
- ◇ Which template would you like?
12
- │ SvelteKit demo
13
-
14
- ◇ Add type checking with Typescript?
15
- │ Yes, using Typescript syntax
16
-
17
- ◆ Project created
18
-
19
- ◇ What would you like to add to your project?
20
- │ none
21
-
22
- ◇ Which package manager do you want to install dependencies with?
23
- │ bun
24
-
25
- ◇ Successfully installed dependencies
26
-
27
- ◇ Project next steps ─────────────────────────────────────────────────────╮
28
- │ │
29
- │ 1: cd my-app │
30
- │ 2: git init && git add -A && git commit -m "Initial commit" (optional) │
31
- │ 3: bun run dev -- --open │
32
- │ │
33
- │ To close the dev server, hit Ctrl-C │
34
- │ │
35
- │ Stuck? Visit us at https://svelte.dev/chat │
36
- │ │
37
- ├──────────────────────────────────────────────────────────────────────────╯
38
-
39
- └ You're all set!
40
- ```
41
-
42
- ---
43
-
44
- Once the project is initialized, `cd` into the new project. You don't need to run 'bun install' since the dependencies are already installed.
45
-
46
- Then start the development server with `bun --bun run dev`.
47
-
48
- To run the dev server with Node.js instead of Bun, you can omit the `--bun` flag.
49
-
50
- ```sh
51
- $ cd my-app
52
- $ bun --bun run dev
53
- $ vite dev
54
- Forced re-optimization of dependencies
55
-
56
- VITE v5.4.10 ready in 424 ms
57
-
58
- ➜ Local: http://localhost:5173/
59
- ➜ Network: use --host to expose
60
- ➜ press h + enter to show help
61
- ```
62
-
63
- ---
64
-
65
- Visit [http://localhost:5173](http://localhost:5173/) in a browser to see the template app.
66
-
67
- {% image src="https://github.com/oven-sh/bun/assets/3084745/7c76eae8-78f9-44fa-9f15-1bd3ca1a47c0" /%}
68
-
69
- ---
70
-
71
- If you edit and save `src/routes/+page.svelte`, you should see your changes hot-reloaded in the browser.
72
-
73
- ---
74
-
75
- To build for production, you'll need to add the right SvelteKit adapter. Currently we recommend the
76
-
77
- `bun add -D svelte-adapter-bun`.
78
-
79
- Now, make the following changes to your `svelte.config.js`.
80
-
81
- ```ts-diff
82
- - import adapter from "@sveltejs/adapter-auto";
83
- + import adapter from "svelte-adapter-bun";
84
- import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
85
-
86
- /** @type {import('@sveltejs/kit').Config} */
87
- const config = {
88
- // Consult https://svelte.dev/docs/kit/integrations#preprocessors
89
- // for more information about preprocessors
90
- preprocess: vitePreprocess(),
91
-
92
- kit: {
93
- // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
94
- // If your environment is not supported, or you settled on a specific environment, switch out the adapter.
95
- // See https://svelte.dev/docs/kit/adapters for more information about adapters.
96
- adapter: adapter()
97
- }
98
- };
99
-
100
- export default config;
101
- ```
102
-
103
- ---
104
-
105
- To build a production bundle:
106
-
107
- ```sh
108
- $ bun --bun run build
109
- $ vite build
110
- vite v5.4.10 building SSR bundle for production...
111
- "confetti" is imported from external module "@neoconfetti/svelte" but never used in "src/routes/sverdle/+page.svelte".
112
- ✓ 130 modules transformed.
113
- vite v5.4.10 building for production...
114
- ✓ 148 modules transformed.
115
- ...
116
- ✓ built in 231ms
117
- ...
118
- ✓ built in 899ms
119
-
120
- Run npm run preview to preview your production build locally.
121
-
122
- > Using svelte-adapter-bun
123
- ✔ Start server with: bun ./build/index.js
124
- ✔ done
125
- ```
@@ -1,113 +0,0 @@
1
- ---
2
- name: Run Bun as a daemon with systemd
3
- ---
4
-
5
- [systemd](https://systemd.io) is an init system and service manager for Linux operating systems that manages the startup and control of system processes and services.
6
-
7
- <!-- systemd provides aggressive parallelization capabilities, uses socket and D-Bus activation for starting services, offers on-demand starting of daemons, keeps track of processes using Linux control groups, maintains mount and auto mount points, and implements an elaborate transactional dependency-based service control logic. systemd supports SysV and LSB init scripts and works as a replacement for sysvinit. -->
8
-
9
- <!-- Other parts include a logging daemon, utilities to control basic system configuration like the hostname, date, locale, maintain a list of logged-in users and running containers and virtual machines, system accounts, runtime directories and settings, and daemons to manage simple network configuration, network time synchronization, log forwarding, and name resolution. -->
10
-
11
- ---
12
-
13
- To run a Bun application as a daemon using **systemd** you'll need to create a _service file_ in `/lib/systemd/system/`.
14
-
15
- ```sh
16
- $ cd /lib/systemd/system
17
- $ touch my-app.service
18
- ```
19
-
20
- ---
21
-
22
- Here is a typical service file that runs an application on system start. You can use this as a template for your own service. Replace `YOUR_USER` with the name of the user you want to run the application as. To run as `root`, replace `YOUR_USER` with `root`, though this is generally not recommended for security reasons.
23
-
24
- Refer to the [systemd documentation](https://www.freedesktop.org/software/systemd/man/systemd.service.html) for more information on each setting.
25
-
26
- ```ini#my-app.service
27
- [Unit]
28
- # describe the app
29
- Description=My App
30
- # start the app after the network is available
31
- After=network.target
32
-
33
- [Service]
34
- # usually you'll use 'simple'
35
- # one of https://www.freedesktop.org/software/systemd/man/systemd.service.html#Type=
36
- Type=simple
37
- # which user to use when starting the app
38
- User=YOUR_USER
39
- # path to your application's root directory
40
- WorkingDirectory=/home/YOUR_USER/path/to/my-app
41
- # the command to start the app
42
- # requires absolute paths
43
- ExecStart=/home/YOUR_USER/.bun/bin/bun run index.ts
44
- # restart policy
45
- # one of {no|on-success|on-failure|on-abnormal|on-watchdog|on-abort|always}
46
- Restart=always
47
-
48
- [Install]
49
- # start the app automatically
50
- WantedBy=multi-user.target
51
- ```
52
-
53
- ---
54
-
55
- If your application starts a webserver, note that non-`root` users are not able to listen on ports 80 or 443 by default. To permanently allow Bun to listen on these ports when executed by a non-`root` user, use the following command. This step isn't necessary when running as `root`.
56
-
57
- ```bash
58
- $ sudo setcap CAP_NET_BIND_SERVICE=+eip ~/.bun/bin/bun
59
- ```
60
-
61
- ---
62
-
63
- With the service file configured, you can now _enable_ the service. Once enabled, it will start automatically on reboot. This requires `sudo` permissions.
64
-
65
- ```bash
66
- $ sudo systemctl enable my-app
67
- ```
68
-
69
- ---
70
-
71
- To start the service without rebooting, you can manually _start_ it.
72
-
73
- ```bash
74
- $ sudo systemctl start my-app
75
- ```
76
-
77
- ---
78
-
79
- Check the status of your application with `systemctl status`. If you've started your app successfully, you should see something like this:
80
-
81
- ```bash
82
- $ sudo systemctl status my-app
83
- ● my-app.service - My App
84
- Loaded: loaded (/lib/systemd/system/my-app.service; enabled; preset: enabled)
85
- Active: active (running) since Thu 2023-10-12 11:34:08 UTC; 1h 8min ago
86
- Main PID: 309641 (bun)
87
- Tasks: 3 (limit: 503)
88
- Memory: 40.9M
89
- CPU: 1.093s
90
- CGroup: /system.slice/my-app.service
91
- └─309641 /home/YOUR_USER/.bun/bin/bun run /home/YOUR_USER/application/index.ts
92
- ```
93
-
94
- ---
95
-
96
- To update the service, edit the contents of the service file, then reload the daemon.
97
-
98
- ```bash
99
- $ sudo systemctl daemon-reload
100
- ```
101
-
102
- ---
103
-
104
- For a complete guide on the service unit configuration, you can check [this page](https://www.freedesktop.org/software/systemd/man/systemd.service.html). Or refer to this cheatsheet of common commands:
105
-
106
- ```bash
107
- $ sudo systemctl daemon-reload # tell systemd that some files got changed
108
- $ sudo systemctl enable my-app # enable the app (to allow auto-start)
109
- $ sudo systemctl disable my-app # disable the app (turns off auto-start)
110
- $ sudo systemctl start my-app # start the app if is stopped
111
- $ sudo systemctl stop my-app # stop the app
112
- $ sudo systemctl restart my-app # restart the app
113
- ```
@@ -1,71 +0,0 @@
1
- ---
2
- name: Build a frontend using Vite and Bun
3
- ---
4
-
5
- {% callout %}
6
- You can use Vite with Bun, but many projects get faster builds & drop hundreds of dependencies by switching to [HTML imports](/docs/bundler/html).
7
- {% /callout %}
8
-
9
- ---
10
-
11
- Vite works out of the box with Bun. Get started with one of Vite's templates.
12
-
13
- ```bash
14
- $ bun create vite my-app
15
- ✔ Select a framework: › React
16
- ✔ Select a variant: › TypeScript + SWC
17
- Scaffolding project in /path/to/my-app...
18
- ```
19
-
20
- ---
21
-
22
- Then `cd` into the project directory and install dependencies.
23
-
24
- ```bash
25
- cd my-app
26
- bun install
27
- ```
28
-
29
- ---
30
-
31
- Start the development server with the `vite` CLI using `bunx`.
32
-
33
- The `--bun` flag tells Bun to run Vite's CLI using `bun` instead of `node`; by default Bun respects Vite's `#!/usr/bin/env node` [shebang line](<https://en.wikipedia.org/wiki/Shebang_(Unix)>).
34
-
35
- ```bash
36
- bunx --bun vite
37
- ```
38
-
39
- ---
40
-
41
- To simplify this command, update the `"dev"` script in `package.json` to the following.
42
-
43
- ```json-diff#package.json
44
- "scripts": {
45
- - "dev": "vite",
46
- + "dev": "bunx --bun vite",
47
- "build": "vite build",
48
- "serve": "vite preview"
49
- },
50
- // ...
51
- ```
52
-
53
- ---
54
-
55
- Now you can start the development server with `bun run dev`.
56
-
57
- ```bash
58
- bun run dev
59
- ```
60
-
61
- ---
62
-
63
- The following command will build your app for production.
64
-
65
- ```sh
66
- $ bunx --bun vite build
67
- ```
68
-
69
- ---
70
-
71
- This is a stripped down guide to get you started with Vite + Bun. For more information, see the [Vite documentation](https://vitejs.dev/guide/).
@@ -1,68 +0,0 @@
1
- ---
2
- name: Extract links from a webpage using HTMLRewriter
3
- ---
4
-
5
- ## Extract links from a webpage
6
-
7
- Bun's [HTMLRewriter](https://bun.com/docs/api/html-rewriter) API can be used to efficiently extract links from HTML content. It works by chaining together CSS selectors to match the elements, text, and attributes you want to process. This is a simple example of how to extract links from a webpage. You can pass `.transform` a `Response`, `Blob`, or `string`.
8
-
9
- ```ts
10
- async function extractLinks(url: string) {
11
- const links = new Set<string>();
12
- const response = await fetch(url);
13
-
14
- const rewriter = new HTMLRewriter().on("a[href]", {
15
- element(el) {
16
- const href = el.getAttribute("href");
17
- if (href) {
18
- links.add(href);
19
- }
20
- },
21
- });
22
-
23
- // Wait for the response to be processed
24
- await rewriter.transform(response).blob();
25
- console.log([...links]); // ["https://bun.com", "/docs", ...]
26
- }
27
-
28
- // Extract all links from the Bun website
29
- await extractLinks("https://bun.com");
30
- ```
31
-
32
- ---
33
-
34
- ## Convert relative URLs to absolute
35
-
36
- When scraping websites, you often want to convert relative URLs (like `/docs`) to absolute URLs. Here's how to handle URL resolution:
37
-
38
- ```ts
39
- async function extractLinksFromURL(url: string) {
40
- const response = await fetch(url);
41
- const links = new Set<string>();
42
-
43
- const rewriter = new HTMLRewriter().on("a[href]", {
44
- element(el) {
45
- const href = el.getAttribute("href");
46
- if (href) {
47
- // Convert relative URLs to absolute
48
- try {
49
- const absoluteURL = new URL(href, url).href;
50
- links.add(absoluteURL);
51
- } catch {
52
- links.add(href);
53
- }
54
- }
55
- },
56
- });
57
-
58
- // Wait for the response to be processed
59
- await rewriter.transform(response).blob();
60
- return [...links];
61
- }
62
-
63
- const websiteLinks = await extractLinksFromURL("https://example.com");
64
- ```
65
-
66
- ---
67
-
68
- See [Docs > API > HTMLRewriter](https://bun.com/docs/api/html-rewriter) for complete documentation on HTML transformation with Bun.
@@ -1,93 +0,0 @@
1
- ---
2
- name: Extract social share images and Open Graph tags
3
- ---
4
-
5
- ## Extract social share images and Open Graph tags
6
-
7
- Bun's [HTMLRewriter](https://bun.com/docs/api/html-rewriter) API can be used to efficiently extract social share images and Open Graph metadata from HTML content. This is particularly useful for building link preview features, social media cards, or web scrapers. We can use HTMLRewriter to match CSS selectors to HTML elements, text, and attributes we want to process.
8
-
9
- ```ts
10
- interface SocialMetadata {
11
- title?: string;
12
- description?: string;
13
- image?: string;
14
- url?: string;
15
- siteName?: string;
16
- type?: string;
17
- }
18
-
19
- async function extractSocialMetadata(url: string): Promise<SocialMetadata> {
20
- const metadata: SocialMetadata = {};
21
- const response = await fetch(url);
22
-
23
- const rewriter = new HTMLRewriter()
24
- // Extract Open Graph meta tags
25
- .on('meta[property^="og:"]', {
26
- element(el) {
27
- const property = el.getAttribute("property");
28
- const content = el.getAttribute("content");
29
- if (property && content) {
30
- // Convert "og:image" to "image" etc.
31
- const key = property.replace("og:", "") as keyof SocialMetadata;
32
- metadata[key] = content;
33
- }
34
- },
35
- })
36
- // Extract Twitter Card meta tags as fallback
37
- .on('meta[name^="twitter:"]', {
38
- element(el) {
39
- const name = el.getAttribute("name");
40
- const content = el.getAttribute("content");
41
- if (name && content) {
42
- const key = name.replace("twitter:", "") as keyof SocialMetadata;
43
- // Only use Twitter Card data if we don't have OG data
44
- if (!metadata[key]) {
45
- metadata[key] = content;
46
- }
47
- }
48
- },
49
- })
50
- // Fallback to regular meta tags
51
- .on('meta[name="description"]', {
52
- element(el) {
53
- const content = el.getAttribute("content");
54
- if (content && !metadata.description) {
55
- metadata.description = content;
56
- }
57
- },
58
- })
59
- // Fallback to title tag
60
- .on("title", {
61
- text(text) {
62
- if (!metadata.title) {
63
- metadata.title = text.text;
64
- }
65
- },
66
- });
67
-
68
- // Process the response
69
- await rewriter.transform(response).blob();
70
-
71
- // Convert relative image URLs to absolute
72
- if (metadata.image && !metadata.image.startsWith("http")) {
73
- try {
74
- metadata.image = new URL(metadata.image, url).href;
75
- } catch {
76
- // Keep the original URL if parsing fails
77
- }
78
- }
79
-
80
- return metadata;
81
- }
82
-
83
- // Example usage
84
- const metadata = await extractSocialMetadata("https://bun.com");
85
- console.log(metadata);
86
- // {
87
- // title: "Bun — A fast all-in-one JavaScript runtime",
88
- // description: "Bundle, transpile, install and run JavaScript & TypeScript projects — all in Bun. Bun is a fast all-in-one JavaScript runtime & toolkit designed for speed, complete with a bundler, test runner, and Node.js-compatible package manager.",
89
- // image: "https://bun.com/share.jpg",
90
- // type: "website",
91
- // ...
92
- // }
93
- ```