bun-types 1.3.2-canary.20251105T140650 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (370) hide show
  1. package/bun.d.ts +102 -6
  2. package/docs/README.md +28 -0
  3. package/docs/bundler/bytecode.mdx +465 -0
  4. package/docs/bundler/{css.md → css.mdx} +97 -101
  5. package/docs/bundler/esbuild.mdx +253 -0
  6. package/docs/bundler/{executables.md → executables.mdx} +130 -221
  7. package/docs/bundler/fullstack.mdx +1064 -0
  8. package/docs/bundler/{hmr.md → hot-reloading.mdx} +74 -79
  9. package/docs/bundler/{html.md → html-static.mdx} +148 -111
  10. package/docs/bundler/index.mdx +1499 -0
  11. package/docs/bundler/loaders.mdx +356 -0
  12. package/docs/bundler/{macros.md → macros.mdx} +83 -84
  13. package/docs/bundler/minifier.mdx +1306 -0
  14. package/docs/bundler/plugins.mdx +411 -0
  15. package/docs/feedback.mdx +85 -0
  16. package/docs/guides/binary/{arraybuffer-to-array.md → arraybuffer-to-array.mdx} +3 -1
  17. package/docs/guides/binary/{arraybuffer-to-blob.md → arraybuffer-to-blob.mdx} +3 -1
  18. package/docs/guides/binary/{arraybuffer-to-buffer.md → arraybuffer-to-buffer.mdx} +3 -1
  19. package/docs/guides/binary/{arraybuffer-to-string.md → arraybuffer-to-string.mdx} +3 -1
  20. package/docs/guides/binary/{arraybuffer-to-typedarray.md → arraybuffer-to-typedarray.mdx} +3 -1
  21. package/docs/guides/binary/{blob-to-arraybuffer.md → blob-to-arraybuffer.mdx} +3 -1
  22. package/docs/guides/binary/{blob-to-dataview.md → blob-to-dataview.mdx} +3 -1
  23. package/docs/guides/binary/{blob-to-stream.md → blob-to-stream.mdx} +3 -1
  24. package/docs/guides/binary/{blob-to-string.md → blob-to-string.mdx} +3 -1
  25. package/docs/guides/binary/{blob-to-typedarray.md → blob-to-typedarray.mdx} +3 -1
  26. package/docs/guides/binary/{buffer-to-arraybuffer.md → buffer-to-arraybuffer.mdx} +3 -1
  27. package/docs/guides/binary/{buffer-to-blob.md → buffer-to-blob.mdx} +3 -1
  28. package/docs/guides/binary/{buffer-to-readablestream.md → buffer-to-readablestream.mdx} +3 -1
  29. package/docs/guides/binary/{buffer-to-string.md → buffer-to-string.mdx} +3 -1
  30. package/docs/guides/binary/{buffer-to-typedarray.md → buffer-to-typedarray.mdx} +3 -1
  31. package/docs/guides/binary/{dataview-to-string.md → dataview-to-string.mdx} +3 -1
  32. package/docs/guides/binary/{typedarray-to-arraybuffer.md → typedarray-to-arraybuffer.mdx} +3 -1
  33. package/docs/guides/binary/{typedarray-to-blob.md → typedarray-to-blob.mdx} +3 -1
  34. package/docs/guides/binary/{typedarray-to-buffer.md → typedarray-to-buffer.mdx} +3 -1
  35. package/docs/guides/binary/{typedarray-to-dataview.md → typedarray-to-dataview.mdx} +3 -1
  36. package/docs/guides/binary/{typedarray-to-readablestream.md → typedarray-to-readablestream.mdx} +3 -1
  37. package/docs/guides/binary/{typedarray-to-string.md → typedarray-to-string.mdx} +3 -1
  38. package/docs/guides/deployment/aws-lambda.mdx +204 -0
  39. package/docs/guides/deployment/digital-ocean.mdx +161 -0
  40. package/docs/guides/deployment/google-cloud-run.mdx +197 -0
  41. package/docs/guides/deployment/{railway.md → railway.mdx} +42 -54
  42. package/docs/guides/deployment/render.mdx +82 -0
  43. package/docs/guides/deployment/vercel.mdx +99 -0
  44. package/docs/guides/ecosystem/{astro.md → astro.mdx} +16 -6
  45. package/docs/guides/ecosystem/{discordjs.md → discordjs.mdx} +21 -18
  46. package/docs/guides/ecosystem/{docker.md → docker.mdx} +25 -14
  47. package/docs/guides/ecosystem/{drizzle.md → drizzle.mdx} +32 -22
  48. package/docs/guides/ecosystem/{edgedb.md → edgedb.mdx} +63 -34
  49. package/docs/guides/ecosystem/{elysia.md → elysia.mdx} +11 -11
  50. package/docs/guides/ecosystem/{express.md → express.mdx} +12 -9
  51. package/docs/guides/ecosystem/{hono.md → hono.mdx} +16 -8
  52. package/docs/guides/ecosystem/{mongoose.md → mongoose.mdx} +26 -21
  53. package/docs/guides/ecosystem/{neon-drizzle.md → neon-drizzle.mdx} +49 -35
  54. package/docs/guides/ecosystem/{neon-serverless-postgres.md → neon-serverless-postgres.mdx} +16 -11
  55. package/docs/guides/ecosystem/{nextjs.md → nextjs.mdx} +18 -10
  56. package/docs/guides/ecosystem/{nuxt.md → nuxt.mdx} +45 -11
  57. package/docs/guides/ecosystem/{pm2.md → pm2.mdx} +7 -9
  58. package/docs/guides/ecosystem/prisma-postgres.mdx +169 -0
  59. package/docs/guides/ecosystem/prisma.mdx +164 -0
  60. package/docs/guides/ecosystem/{qwik.md → qwik.mdx} +18 -11
  61. package/docs/guides/ecosystem/{react.md → react.mdx} +9 -7
  62. package/docs/guides/ecosystem/{remix.md → remix.mdx} +45 -26
  63. package/docs/guides/ecosystem/{sentry.md → sentry.mdx} +7 -5
  64. package/docs/guides/ecosystem/{solidstart.md → solidstart.mdx} +21 -13
  65. package/docs/guides/ecosystem/{ssr-react.md → ssr-react.mdx} +9 -11
  66. package/docs/guides/ecosystem/{stric.md → stric.mdx} +16 -17
  67. package/docs/guides/ecosystem/{sveltekit.md → sveltekit.mdx} +42 -29
  68. package/docs/guides/ecosystem/{systemd.md → systemd.mdx} +27 -26
  69. package/docs/guides/ecosystem/upstash.mdx +87 -0
  70. package/docs/guides/ecosystem/{vite.md → vite.mdx} +20 -14
  71. package/docs/guides/html-rewriter/{extract-links.md → extract-links.mdx} +11 -7
  72. package/docs/guides/html-rewriter/{extract-social-meta.md → extract-social-meta.mdx} +6 -2
  73. package/docs/guides/http/{cluster.md → cluster.mdx} +10 -7
  74. package/docs/guides/http/{fetch-unix.md → fetch-unix.mdx} +5 -3
  75. package/docs/guides/http/{fetch.md → fetch.mdx} +5 -3
  76. package/docs/guides/http/{file-uploads.md → file-uploads.mdx} +18 -15
  77. package/docs/guides/http/{hot.md → hot.mdx} +9 -7
  78. package/docs/guides/http/{proxy.md → proxy.mdx} +7 -5
  79. package/docs/guides/http/{server.md → server.mdx} +4 -2
  80. package/docs/guides/http/{simple.md → simple.mdx} +4 -2
  81. package/docs/guides/http/{stream-file.md → stream-file.mdx} +6 -4
  82. package/docs/guides/http/{stream-iterator.md → stream-iterator.mdx} +5 -3
  83. package/docs/guides/http/{stream-node-streams-in-bun.md → stream-node-streams-in-bun.mdx} +4 -2
  84. package/docs/guides/http/{tls.md → tls.mdx} +5 -3
  85. package/docs/guides/index.mdx +10 -0
  86. package/docs/guides/install/{add-dev.md → add-dev.mdx} +8 -6
  87. package/docs/guides/install/add-git.mdx +38 -0
  88. package/docs/guides/install/{add-optional.md → add-optional.mdx} +7 -5
  89. package/docs/guides/install/{add-peer.md → add-peer.mdx} +13 -11
  90. package/docs/guides/install/{add-tarball.md → add-tarball.mdx} +7 -5
  91. package/docs/guides/install/{add.md → add.mdx} +12 -10
  92. package/docs/guides/install/{azure-artifacts.md → azure-artifacts.mdx} +15 -12
  93. package/docs/guides/{runtime/cicd.md → install/cicd.mdx} +13 -13
  94. package/docs/guides/install/{custom-registry.md → custom-registry.mdx} +6 -4
  95. package/docs/guides/install/{from-npm-install-to-bun-install.md → from-npm-install-to-bun-install.mdx} +50 -34
  96. package/docs/guides/install/{git-diff-bun-lockfile.md → git-diff-bun-lockfile.mdx} +14 -11
  97. package/docs/guides/install/{jfrog-artifactory.md → jfrog-artifactory.mdx} +4 -4
  98. package/docs/guides/install/{npm-alias.md → npm-alias.mdx} +6 -4
  99. package/docs/guides/install/{registry-scope.md → registry-scope.mdx} +6 -4
  100. package/docs/guides/install/{trusted.md → trusted.mdx} +22 -18
  101. package/docs/guides/install/{workspaces.md → workspaces.mdx} +13 -13
  102. package/docs/guides/install/{yarnlock.md → yarnlock.mdx} +15 -9
  103. package/docs/guides/process/{argv.md → argv.mdx} +17 -9
  104. package/docs/guides/process/{ctrl-c.md → ctrl-c.mdx} +4 -2
  105. package/docs/guides/process/{ipc.md → ipc.mdx} +13 -10
  106. package/docs/guides/process/{nanoseconds.md → nanoseconds.mdx} +3 -1
  107. package/docs/guides/process/{os-signals.md → os-signals.mdx} +3 -1
  108. package/docs/guides/process/{spawn-stderr.md → spawn-stderr.mdx} +4 -1
  109. package/docs/guides/process/{spawn-stdout.md → spawn-stdout.mdx} +3 -1
  110. package/docs/guides/process/{spawn.md → spawn.mdx} +3 -1
  111. package/docs/guides/process/{stdin.md → stdin.mdx} +15 -7
  112. package/docs/guides/read-file/{arraybuffer.md → arraybuffer.mdx} +5 -3
  113. package/docs/guides/read-file/{buffer.md → buffer.mdx} +4 -2
  114. package/docs/guides/read-file/{exists.md → exists.mdx} +4 -2
  115. package/docs/guides/read-file/{json.md → json.mdx} +4 -2
  116. package/docs/guides/read-file/{mime.md → mime.mdx} +3 -1
  117. package/docs/guides/read-file/{stream.md → stream.mdx} +3 -1
  118. package/docs/guides/read-file/{string.md → string.mdx} +3 -1
  119. package/docs/guides/read-file/{uint8array.md → uint8array.mdx} +3 -1
  120. package/docs/guides/read-file/{watch.md → watch.mdx} +6 -8
  121. package/docs/guides/runtime/{build-time-constants.md → build-time-constants.mdx} +24 -22
  122. package/docs/guides/{install/cicd.md → runtime/cicd.mdx} +11 -7
  123. package/docs/guides/runtime/{codesign-macos-executable.md → codesign-macos-executable.mdx} +14 -9
  124. package/docs/guides/runtime/{define-constant.md → define-constant.mdx} +20 -16
  125. package/docs/guides/runtime/{delete-directory.md → delete-directory.mdx} +5 -3
  126. package/docs/guides/runtime/{delete-file.md → delete-file.mdx} +4 -2
  127. package/docs/guides/runtime/{heap-snapshot.md → heap-snapshot.mdx} +5 -3
  128. package/docs/guides/runtime/{import-html.md → import-html.mdx} +4 -2
  129. package/docs/guides/runtime/{import-json.md → import-json.mdx} +6 -4
  130. package/docs/guides/runtime/{import-toml.md → import-toml.mdx} +5 -3
  131. package/docs/guides/runtime/{import-yaml.md → import-yaml.mdx} +9 -7
  132. package/docs/guides/runtime/{read-env.md → read-env.mdx} +10 -5
  133. package/docs/guides/runtime/{set-env.md → set-env.mdx} +14 -10
  134. package/docs/guides/runtime/{shell.md → shell.mdx} +6 -4
  135. package/docs/guides/runtime/{timezone.md → timezone.mdx} +10 -7
  136. package/docs/guides/runtime/{tsconfig-paths.md → tsconfig-paths.mdx} +5 -3
  137. package/docs/guides/runtime/{typescript.md → typescript.mdx} +8 -6
  138. package/docs/guides/runtime/{vscode-debugger.md → vscode-debugger.mdx} +12 -11
  139. package/docs/guides/runtime/{web-debugger.md → web-debugger.mdx} +39 -18
  140. package/docs/guides/streams/{node-readable-to-arraybuffer.md → node-readable-to-arraybuffer.mdx} +3 -1
  141. package/docs/guides/streams/{node-readable-to-blob.md → node-readable-to-blob.mdx} +3 -1
  142. package/docs/guides/streams/{node-readable-to-json.md → node-readable-to-json.mdx} +3 -1
  143. package/docs/guides/streams/{node-readable-to-string.md → node-readable-to-string.mdx} +3 -1
  144. package/docs/guides/streams/{node-readable-to-uint8array.md → node-readable-to-uint8array.mdx} +3 -1
  145. package/docs/guides/streams/{to-array.md → to-array.mdx} +3 -1
  146. package/docs/guides/streams/{to-arraybuffer.md → to-arraybuffer.mdx} +3 -1
  147. package/docs/guides/streams/{to-blob.md → to-blob.mdx} +3 -1
  148. package/docs/guides/streams/{to-buffer.md → to-buffer.mdx} +3 -1
  149. package/docs/guides/streams/{to-json.md → to-json.mdx} +4 -2
  150. package/docs/guides/streams/{to-string.md → to-string.mdx} +3 -1
  151. package/docs/guides/streams/{to-typedarray.md → to-typedarray.mdx} +3 -1
  152. package/docs/guides/test/{bail.md → bail.mdx} +7 -5
  153. package/docs/guides/test/{coverage-threshold.md → coverage-threshold.mdx} +14 -7
  154. package/docs/guides/test/{coverage.md → coverage.mdx} +9 -4
  155. package/docs/guides/test/{happy-dom.md → happy-dom.mdx} +13 -8
  156. package/docs/guides/test/{migrate-from-jest.md → migrate-from-jest.mdx} +19 -37
  157. package/docs/guides/test/{mock-clock.md → mock-clock.mdx} +3 -1
  158. package/docs/guides/test/{mock-functions.md → mock-functions.mdx} +7 -5
  159. package/docs/guides/test/{rerun-each.md → rerun-each.mdx} +5 -3
  160. package/docs/guides/test/{run-tests.md → run-tests.mdx} +16 -11
  161. package/docs/guides/test/{skip-tests.md → skip-tests.mdx} +8 -4
  162. package/docs/guides/test/{snapshot.md → snapshot.mdx} +20 -13
  163. package/docs/guides/test/spy-on.mdx +49 -0
  164. package/docs/guides/test/{svelte-test.md → svelte-test.mdx} +16 -23
  165. package/docs/guides/test/{testing-library.md → testing-library.mdx} +18 -17
  166. package/docs/guides/test/{timeout.md → timeout.mdx} +5 -3
  167. package/docs/guides/test/{todo-tests.md → todo-tests.mdx} +13 -6
  168. package/docs/guides/test/{update-snapshots.md → update-snapshots.mdx} +9 -6
  169. package/docs/guides/test/{watch-mode.md → watch-mode.mdx} +9 -4
  170. package/docs/guides/util/{base64.md → base64.mdx} +3 -1
  171. package/docs/guides/util/{deep-equals.md → deep-equals.mdx} +5 -3
  172. package/docs/guides/util/{deflate.md → deflate.mdx} +3 -1
  173. package/docs/guides/util/{detect-bun.md → detect-bun.mdx} +3 -1
  174. package/docs/guides/util/{entrypoint.md → entrypoint.mdx} +4 -2
  175. package/docs/guides/util/{escape-html.md → escape-html.mdx} +3 -1
  176. package/docs/guides/util/{file-url-to-path.md → file-url-to-path.mdx} +3 -1
  177. package/docs/guides/util/{gzip.md → gzip.mdx} +3 -1
  178. package/docs/guides/util/{hash-a-password.md → hash-a-password.mdx} +3 -1
  179. package/docs/guides/util/{import-meta-dir.md → import-meta-dir.mdx} +4 -2
  180. package/docs/guides/util/{import-meta-file.md → import-meta-file.mdx} +4 -2
  181. package/docs/guides/util/{import-meta-path.md → import-meta-path.mdx} +4 -2
  182. package/docs/guides/util/{javascript-uuid.md → javascript-uuid.mdx} +3 -1
  183. package/docs/guides/util/{main.md → main.mdx} +19 -8
  184. package/docs/guides/util/{path-to-file-url.md → path-to-file-url.mdx} +3 -1
  185. package/docs/guides/util/{sleep.md → sleep.mdx} +3 -1
  186. package/docs/guides/util/{version.md → version.mdx} +6 -4
  187. package/docs/guides/util/{which-path-to-executable-bin.md → which-path-to-executable-bin.mdx} +4 -2
  188. package/docs/guides/websocket/{compression.md → compression.mdx} +5 -3
  189. package/docs/guides/websocket/{context.md → context.mdx} +9 -12
  190. package/docs/guides/websocket/{pubsub.md → pubsub.mdx} +5 -6
  191. package/docs/guides/websocket/{simple.md → simple.mdx} +5 -3
  192. package/docs/guides/write-file/{append.md → append.mdx} +3 -1
  193. package/docs/guides/write-file/{basic.md → basic.mdx} +3 -1
  194. package/docs/guides/write-file/{blob.md → blob.mdx} +3 -1
  195. package/docs/guides/write-file/{cat.md → cat.mdx} +4 -2
  196. package/docs/guides/write-file/{file-cp.md → file-cp.mdx} +3 -1
  197. package/docs/guides/write-file/{filesink.md → filesink.mdx} +3 -1
  198. package/docs/guides/write-file/{response.md → response.mdx} +3 -1
  199. package/docs/guides/write-file/{stdout.md → stdout.mdx} +3 -1
  200. package/docs/guides/write-file/{stream.md → stream.mdx} +3 -1
  201. package/docs/guides/write-file/{unlink.md → unlink.mdx} +3 -1
  202. package/docs/{index.md → index.mdx} +97 -41
  203. package/docs/installation.mdx +365 -0
  204. package/docs/{cli/bunx.md → pm/bunx.mdx} +25 -31
  205. package/docs/{install/catalogs.md → pm/catalogs.mdx} +18 -24
  206. package/docs/{cli/add.md → pm/cli/add.mdx} +61 -55
  207. package/docs/{install/audit.md → pm/cli/audit.mdx} +11 -8
  208. package/docs/{cli/install.md → pm/cli/install.mdx} +208 -81
  209. package/docs/{cli/link.md → pm/cli/link.mdx} +27 -19
  210. package/docs/{cli/outdated.md → pm/cli/outdated.mdx} +119 -12
  211. package/docs/{install/patch.md → pm/cli/patch.mdx} +25 -15
  212. package/docs/{cli/pm.md → pm/cli/pm.mdx} +96 -62
  213. package/docs/{cli/publish.md → pm/cli/publish.mdx} +38 -35
  214. package/docs/pm/cli/remove.mdx +16 -0
  215. package/docs/{cli/update.md → pm/cli/update.mdx} +26 -15
  216. package/docs/{cli/why.md → pm/cli/why.mdx} +27 -10
  217. package/docs/{cli/filter.md → pm/filter.mdx} +26 -14
  218. package/docs/{install/cache.md → pm/global-cache.mdx} +25 -12
  219. package/docs/{install/isolated.md → pm/isolated-installs.mdx} +32 -24
  220. package/docs/{install/lifecycle.md → pm/lifecycle.mdx} +20 -9
  221. package/docs/{install/lockfile.md → pm/lockfile.mdx} +18 -12
  222. package/docs/{install/npmrc.md → pm/npmrc.mdx} +30 -24
  223. package/docs/{install/overrides.md → pm/overrides.mdx} +47 -37
  224. package/docs/{install/registries.md → pm/scopes-registries.mdx} +8 -3
  225. package/docs/{install/security-scanner-api.md → pm/security-scanner-api.mdx} +22 -8
  226. package/docs/{install/workspaces.md → pm/workspaces.mdx} +17 -22
  227. package/docs/project/{benchmarking.md → benchmarking.mdx} +26 -11
  228. package/docs/project/{bindgen.md → bindgen.mdx} +12 -14
  229. package/docs/project/{building-windows.md → building-windows.mdx} +18 -47
  230. package/docs/project/{contributing.md → contributing.mdx} +56 -60
  231. package/docs/project/feedback.mdx +20 -0
  232. package/docs/project/license.mdx +78 -0
  233. package/docs/project/roadmap.mdx +8 -0
  234. package/docs/quickstart.mdx +240 -0
  235. package/docs/runtime/{autoimport.md → auto-install.mdx} +34 -31
  236. package/docs/{api/binary-data.md → runtime/binary-data.mdx} +77 -269
  237. package/docs/runtime/bun-apis.mdx +59 -0
  238. package/docs/runtime/{bunfig.md → bunfig.mdx} +95 -225
  239. package/docs/{api/cc.md → runtime/c-compiler.mdx} +16 -9
  240. package/docs/{api/spawn.md → runtime/child-process.mdx} +69 -119
  241. package/docs/{api/color.md → runtime/color.mdx} +6 -1
  242. package/docs/{api/console.md → runtime/console.mdx} +17 -7
  243. package/docs/{api/cookie.md → runtime/cookies.mdx} +24 -19
  244. package/docs/runtime/{debugger.md → debugger.mdx} +61 -51
  245. package/docs/runtime/environment-variables.mdx +214 -0
  246. package/docs/{api/ffi.md → runtime/ffi.mdx} +53 -45
  247. package/docs/{api/file-io.md → runtime/file-io.mdx} +41 -101
  248. package/docs/{api/file-system-router.md → runtime/file-system-router.mdx} +8 -2
  249. package/docs/{bundler/loaders.md → runtime/file-types.mdx} +56 -112
  250. package/docs/{api/glob.md → runtime/glob.mdx} +4 -1
  251. package/docs/runtime/globals.mdx +72 -0
  252. package/docs/{api/hashing.md → runtime/hashing.mdx} +18 -22
  253. package/docs/{api/html-rewriter.md → runtime/html-rewriter.mdx} +36 -30
  254. package/docs/runtime/http/cookies.mdx +79 -0
  255. package/docs/runtime/http/error-handling.mdx +40 -0
  256. package/docs/runtime/http/metrics.mdx +36 -0
  257. package/docs/runtime/http/routing.mdx +289 -0
  258. package/docs/runtime/http/server.mdx +647 -0
  259. package/docs/runtime/http/tls.mdx +101 -0
  260. package/docs/{api/websockets.md → runtime/http/websockets.mdx} +62 -231
  261. package/docs/{cli/run.md → runtime/index.mdx} +70 -108
  262. package/docs/runtime/jsx.mdx +115 -0
  263. package/docs/runtime/{modules.md → module-resolution.mdx} +83 -61
  264. package/docs/{api/dns.md → runtime/networking/dns.mdx} +23 -22
  265. package/docs/{api/fetch.md → runtime/networking/fetch.mdx} +10 -5
  266. package/docs/{api/tcp.md → runtime/networking/tcp.mdx} +59 -41
  267. package/docs/{api/udp.md → runtime/networking/udp.mdx} +14 -8
  268. package/docs/{api/node-api.md → runtime/node-api.mdx} +5 -0
  269. package/docs/runtime/{nodejs-apis.md → nodejs-compat.mdx} +9 -4
  270. package/docs/{bundler/plugins.md → runtime/plugins.mdx} +17 -61
  271. package/docs/{api/redis.md → runtime/redis.mdx} +65 -80
  272. package/docs/{api/s3.md → runtime/s3.mdx} +79 -66
  273. package/docs/{api/secrets.md → runtime/secrets.mdx} +27 -10
  274. package/docs/{api/semver.md → runtime/semver.mdx} +9 -4
  275. package/docs/runtime/{shell.md → shell.mdx} +52 -20
  276. package/docs/{api/sql.md → runtime/sql.mdx} +129 -99
  277. package/docs/{api/sqlite.md → runtime/sqlite.mdx} +162 -157
  278. package/docs/{api/streams.md → runtime/streams.mdx} +33 -31
  279. package/docs/{cli/bun-create.md → runtime/templating/create.mdx} +74 -143
  280. package/docs/{cli/init.md → runtime/templating/init.mdx} +24 -51
  281. package/docs/{api/transpiler.md → runtime/transpiler.mdx} +50 -38
  282. package/docs/{typescript.md → runtime/typescript.mdx} +7 -2
  283. package/docs/{api/utils.md → runtime/utils.mdx} +81 -50
  284. package/docs/runtime/{hot.md → watch-mode.mdx} +53 -37
  285. package/docs/runtime/web-apis.mdx +29 -0
  286. package/docs/{api/workers.md → runtime/workers.mdx} +28 -22
  287. package/docs/{api/yaml.md → runtime/yaml.mdx} +33 -232
  288. package/docs/snippets/cli/add.mdx +166 -0
  289. package/docs/snippets/cli/build.mdx +196 -0
  290. package/docs/snippets/cli/feedback.mdx +17 -0
  291. package/docs/snippets/cli/init.mdx +84 -0
  292. package/docs/snippets/cli/install.mdx +173 -0
  293. package/docs/snippets/cli/link.mdx +163 -0
  294. package/docs/snippets/cli/outdated.mdx +140 -0
  295. package/docs/snippets/cli/patch.mdx +171 -0
  296. package/docs/snippets/cli/publish.mdx +198 -0
  297. package/docs/snippets/cli/remove.mdx +146 -0
  298. package/docs/snippets/cli/run.mdx +293 -0
  299. package/docs/snippets/cli/test.mdx +100 -0
  300. package/docs/snippets/cli/update.mdx +144 -0
  301. package/docs/snippets/product-card.mdx +32 -0
  302. package/docs/snippets/product-tiles.mdx +94 -0
  303. package/docs/test/code-coverage.mdx +409 -0
  304. package/docs/test/configuration.mdx +467 -0
  305. package/docs/test/{time.md → dates-times.mdx} +23 -20
  306. package/docs/test/{discovery.md → discovery.mdx} +15 -10
  307. package/docs/test/dom.mdx +226 -0
  308. package/docs/{cli/test.md → test/index.mdx} +77 -94
  309. package/docs/test/lifecycle.mdx +348 -0
  310. package/docs/test/mocks.mdx +637 -0
  311. package/docs/test/{reporters.md → reporters.mdx} +15 -15
  312. package/docs/test/runtime-behavior.mdx +342 -0
  313. package/docs/test/snapshots.mdx +434 -0
  314. package/docs/test/writing-tests.mdx +635 -0
  315. package/docs/typescript.mdx +54 -0
  316. package/package.json +8 -6
  317. package/test.d.ts +2 -2
  318. package/docs/api/file.md +0 -19
  319. package/docs/api/globals.md +0 -387
  320. package/docs/api/http.md +0 -1408
  321. package/docs/api/import-meta.md +0 -69
  322. package/docs/benchmarks.md +0 -120
  323. package/docs/bun-flavored-toml.md +0 -42
  324. package/docs/bundler/css_modules.md +0 -145
  325. package/docs/bundler/fullstack.md +0 -418
  326. package/docs/bundler/index.md +0 -1735
  327. package/docs/bundler/intro.md +0 -75
  328. package/docs/bundler/vs-esbuild.md +0 -1127
  329. package/docs/cli/bun-completions.md +0 -3
  330. package/docs/cli/bun-install.md +0 -349
  331. package/docs/cli/bun-upgrade.md +0 -39
  332. package/docs/cli/info.md +0 -65
  333. package/docs/cli/patch-commit.md +0 -11
  334. package/docs/cli/remove.md +0 -7
  335. package/docs/cli/unlink.md +0 -9
  336. package/docs/contributing/upgrading-webkit.md +0 -57
  337. package/docs/ecosystem/elysia.md +0 -24
  338. package/docs/ecosystem/express.md +0 -37
  339. package/docs/ecosystem/hono.md +0 -18
  340. package/docs/ecosystem/react.md +0 -65
  341. package/docs/ecosystem/stric.md +0 -38
  342. package/docs/guides/ecosystem/prisma.md +0 -141
  343. package/docs/guides/ecosystem/render.md +0 -79
  344. package/docs/guides/install/add-git.md +0 -36
  345. package/docs/guides/test/spy-on.md +0 -46
  346. package/docs/install/index.md +0 -248
  347. package/docs/installation.md +0 -327
  348. package/docs/project/asan.md +0 -124
  349. package/docs/project/internals/build-process-for-ci.md +0 -75
  350. package/docs/project/licensing.md +0 -73
  351. package/docs/project/roadmap.md +0 -87
  352. package/docs/quickstart.md +0 -157
  353. package/docs/runtime/bun-apis.md +0 -207
  354. package/docs/runtime/env.md +0 -253
  355. package/docs/runtime/index.md +0 -312
  356. package/docs/runtime/jsx.md +0 -385
  357. package/docs/runtime/loaders.md +0 -130
  358. package/docs/runtime/plugins.md +0 -561
  359. package/docs/runtime/typescript.md +0 -139
  360. package/docs/runtime/web-apis.md +0 -128
  361. package/docs/test/configuration.md +0 -154
  362. package/docs/test/coverage.md +0 -142
  363. package/docs/test/dom.md +0 -75
  364. package/docs/test/examples/concurrent-test-glob.md +0 -132
  365. package/docs/test/hot.md +0 -15
  366. package/docs/test/lifecycle.md +0 -81
  367. package/docs/test/mocks.md +0 -313
  368. package/docs/test/runtime-behavior.md +0 -95
  369. package/docs/test/snapshots.md +0 -68
  370. package/docs/test/writing.md +0 -825
@@ -1,3 +1,8 @@
1
+ ---
2
+ title: CSS
3
+ description: Bun's bundler has built-in support for CSS with modern features
4
+ ---
5
+
1
6
  Bun's bundler has built-in support for CSS with the following features:
2
7
 
3
8
  - Transpiling modern/future features to work on all browsers (including vendor prefixing)
@@ -9,11 +14,11 @@ Bun's bundler has built-in support for CSS with the following features:
9
14
 
10
15
  Bun's CSS bundler lets you use modern/future CSS features without having to worry about browser compatibility — all thanks to its transpiling and vendor prefixing features which are enabled by default.
11
16
 
12
- Bun's CSS parser and bundler is a direct Rust → Zig port of [LightningCSS](https://lightningcss.dev/), with a bundling approach inspired by esbuild. The transpiler converts modern CSS syntax into backwards-compatible equivalents that work across browsers.
17
+ Bun's CSS parser and bundler is a direct Rust → Zig port of LightningCSS, with a bundling approach inspired by esbuild. The transpiler converts modern CSS syntax into backwards-compatible equivalents that work across browsers.
13
18
 
14
- A huge thanks goes to the amazing work from the authors of [LightningCSS](https://lightningcss.dev/) and [esbuild](https://esbuild.github.io/).
19
+ <Note>A huge thanks goes to the amazing work from the authors of LightningCSS and esbuild.</Note>
15
20
 
16
- ### Browser Compatibility
21
+ ## Browser Compatibility
17
22
 
18
23
  By default, Bun's CSS bundler targets the following browsers:
19
24
 
@@ -23,13 +28,13 @@ By default, Bun's CSS bundler targets the following browsers:
23
28
  - Chrome 87+
24
29
  - Safari 14+
25
30
 
26
- ### Syntax Lowering
31
+ ## Syntax Lowering
27
32
 
28
- #### Nesting
33
+ ### Nesting
29
34
 
30
35
  The CSS Nesting specification allows you to write more concise and intuitive stylesheets by nesting selectors inside one another. Instead of repeating parent selectors across your CSS file, you can write child styles directly within their parent blocks.
31
36
 
32
- ```css
37
+ ```css title="styles.css" icon="file-code"
33
38
  /* With nesting */
34
39
  .card {
35
40
  background: white;
@@ -48,7 +53,7 @@ The CSS Nesting specification allows you to write more concise and intuitive sty
48
53
 
49
54
  Bun's CSS bundler automatically converts this nested syntax into traditional flat CSS that works in all browsers:
50
55
 
51
- ```css
56
+ ```css title="styles.css" icon="file-code"
52
57
  /* Compiled output */
53
58
  .card {
54
59
  background: white;
@@ -67,7 +72,7 @@ Bun's CSS bundler automatically converts this nested syntax into traditional fla
67
72
 
68
73
  You can also nest media queries and other at-rules inside selectors, eliminating the need to repeat selector patterns:
69
74
 
70
- ```css
75
+ ```css title="styles.css" icon="file-code"
71
76
  .responsive-element {
72
77
  display: block;
73
78
 
@@ -79,7 +84,7 @@ You can also nest media queries and other at-rules inside selectors, eliminating
79
84
 
80
85
  This compiles to:
81
86
 
82
- ```css
87
+ ```css title="styles.css" icon="file-code"
83
88
  .responsive-element {
84
89
  display: block;
85
90
  }
@@ -91,11 +96,11 @@ This compiles to:
91
96
  }
92
97
  ```
93
98
 
94
- #### Color mix
99
+ ### Color mix
95
100
 
96
101
  The `color-mix()` function gives you an easy way to blend two colors together according to a specified ratio in a chosen color space. This powerful feature lets you create color variations without manually calculating the resulting values.
97
102
 
98
- ```css
103
+ ```css title="styles.css" icon="file-code"
99
104
  .button {
100
105
  /* Mix blue and red in the RGB color space with a 30/70 proportion */
101
106
  background-color: color-mix(in srgb, blue 30%, red);
@@ -109,7 +114,7 @@ The `color-mix()` function gives you an easy way to blend two colors together ac
109
114
 
110
115
  Bun's CSS bundler evaluates these color mixes at build time when all color values are known (not CSS variables), generating static color values that work in all browsers:
111
116
 
112
- ```css
117
+ ```css title="styles.css" icon="file-code"
113
118
  .button {
114
119
  /* Computed to the exact resulting color */
115
120
  background-color: #b31a1a;
@@ -122,11 +127,11 @@ Bun's CSS bundler evaluates these color mixes at build time when all color value
122
127
 
123
128
  This feature is particularly useful for creating color systems with programmatically derived shades, tints, and accents without needing preprocessors or custom tooling.
124
129
 
125
- #### Relative colors
130
+ ### Relative colors
126
131
 
127
132
  CSS now allows you to modify individual components of a color using relative color syntax. This powerful feature lets you create color variations by adjusting specific attributes like lightness, saturation, or individual channels without having to recalculate the entire color.
128
133
 
129
- ```css
134
+ ```css title="styles.css" icon="file-code"
130
135
  .theme-color {
131
136
  /* Start with a base color and increase lightness by 15% */
132
137
  --accent: lch(from purple calc(l + 15%) c h);
@@ -147,27 +152,23 @@ Bun's CSS bundler computes these relative color modifications at build time (whe
147
152
 
148
153
  This approach is extremely useful for theme generation, creating accessible color variants, or building color scales based on mathematical relationships instead of hard-coding each value.
149
154
 
150
- #### LAB colors
155
+ ### LAB colors
151
156
 
152
157
  Modern CSS supports perceptually uniform color spaces like LAB, LCH, OKLAB, and OKLCH that offer significant advantages over traditional RGB. These color spaces can represent colors outside the standard RGB gamut, resulting in more vibrant and visually consistent designs.
153
158
 
154
- ```css
159
+ ```css title="styles.css" icon="file-code"
155
160
  .vibrant-element {
156
161
  /* A vibrant red that exceeds sRGB gamut boundaries */
157
162
  color: lab(55% 78 35);
158
163
 
159
164
  /* A smooth gradient using perceptual color space */
160
- background: linear-gradient(
161
- to right,
162
- oklch(65% 0.25 10deg),
163
- oklch(65% 0.25 250deg)
164
- );
165
+ background: linear-gradient(to right, oklch(65% 0.25 10deg), oklch(65% 0.25 250deg));
165
166
  }
166
167
  ```
167
168
 
168
169
  Bun's CSS bundler automatically converts these advanced color formats to backwards-compatible alternatives for browsers that don't yet support them:
169
170
 
170
- ```css
171
+ ```css title="styles.css" icon="file-code"
171
172
  .vibrant-element {
172
173
  /* Fallback to closest RGB approximation */
173
174
  color: #ff0f52;
@@ -177,21 +178,17 @@ Bun's CSS bundler automatically converts these advanced color formats to backwar
177
178
  color: lab(55% 78 35);
178
179
 
179
180
  background: linear-gradient(to right, #cd4e15, #3887ab);
180
- background: linear-gradient(
181
- to right,
182
- oklch(65% 0.25 10deg),
183
- oklch(65% 0.25 250deg)
184
- );
181
+ background: linear-gradient(to right, oklch(65% 0.25 10deg), oklch(65% 0.25 250deg));
185
182
  }
186
183
  ```
187
184
 
188
185
  This layered approach ensures optimal color rendering across all browsers while allowing you to use the latest color technologies in your designs.
189
186
 
190
- #### Color function
187
+ ### Color function
191
188
 
192
189
  The `color()` function provides a standardized way to specify colors in various predefined color spaces, expanding your design options beyond the traditional RGB space. This allows you to access wider color gamuts and create more vibrant designs.
193
190
 
194
- ```css
191
+ ```css title="styles.css" icon="file-code"
195
192
  .vivid-element {
196
193
  /* Using the Display P3 color space for wider gamut colors */
197
194
  color: color(display-p3 1 0.1 0.3);
@@ -203,7 +200,7 @@ The `color()` function provides a standardized way to specify colors in various
203
200
 
204
201
  For browsers that don't support these advanced color functions yet, Bun's CSS bundler provides appropriate RGB fallbacks:
205
202
 
206
- ```css
203
+ ```css title="styles.css" icon="file-code"
207
204
  .vivid-element {
208
205
  /* RGB fallback first for maximum compatibility */
209
206
  color: #fa1a4c;
@@ -217,11 +214,11 @@ For browsers that don't support these advanced color functions yet, Bun's CSS bu
217
214
 
218
215
  This functionality lets you use modern color spaces immediately while ensuring your designs remain functional across all browsers, with optimal colors displayed in supporting browsers and reasonable approximations elsewhere.
219
216
 
220
- #### HWB colors
217
+ ### HWB colors
221
218
 
222
219
  The HWB (Hue, Whiteness, Blackness) color model provides an intuitive way to express colors based on how much white or black is mixed with a pure hue. Many designers find this approach more natural for creating color variations compared to manipulating RGB or HSL values.
223
220
 
224
- ```css
221
+ ```css title="styles.css" icon="file-code"
225
222
  .easy-theming {
226
223
  /* Pure cyan with no white or black added */
227
224
  --primary: hwb(180 0% 0%);
@@ -239,7 +236,7 @@ The HWB (Hue, Whiteness, Blackness) color model provides an intuitive way to exp
239
236
 
240
237
  Bun's CSS bundler automatically converts HWB colors to RGB for compatibility with all browsers:
241
238
 
242
- ```css
239
+ ```css title="styles.css" icon="file-code"
243
240
  .easy-theming {
244
241
  --primary: #00ffff;
245
242
  --primary-light: #33ffff;
@@ -250,11 +247,11 @@ Bun's CSS bundler automatically converts HWB colors to RGB for compatibility wit
250
247
 
251
248
  The HWB model makes it particularly easy to create systematic color variations for design systems, providing a more intuitive approach to creating consistent tints and shades than working directly with RGB or HSL values.
252
249
 
253
- #### Color notation
250
+ ### Color notation
254
251
 
255
252
  Modern CSS has introduced more intuitive and concise ways to express colors. Space-separated color syntax eliminates the need for commas in RGB and HSL values, while hex colors with alpha channels provide a compact way to specify transparency.
256
253
 
257
- ```css
254
+ ```css title="styles.css" icon="file-code"
258
255
  .modern-styling {
259
256
  /* Space-separated RGB notation (no commas) */
260
257
  color: rgb(50 100 200);
@@ -272,7 +269,7 @@ Modern CSS has introduced more intuitive and concise ways to express colors. Spa
272
269
 
273
270
  Bun's CSS bundler automatically converts these modern color formats to ensure compatibility with older browsers:
274
271
 
275
- ```css
272
+ ```css title="styles.css" icon="file-code"
276
273
  .modern-styling {
277
274
  /* Converted to comma format for older browsers */
278
275
  color: rgb(50, 100, 200);
@@ -289,11 +286,11 @@ Bun's CSS bundler automatically converts these modern color formats to ensure co
289
286
 
290
287
  This conversion process lets you write cleaner, more modern CSS while ensuring your styles work correctly across all browsers.
291
288
 
292
- #### light-dark() color function
289
+ ### light-dark() color function
293
290
 
294
291
  The `light-dark()` function provides an elegant solution for implementing color schemes that respect the user's system preference without requiring complex media queries. This function accepts two color values and automatically selects the appropriate one based on the current color scheme context.
295
292
 
296
- ```css
293
+ ```css title="styles.css" icon="file-code"
297
294
  :root {
298
295
  /* Define color scheme support */
299
296
  color-scheme: light dark;
@@ -318,7 +315,7 @@ The `light-dark()` function provides an elegant solution for implementing color
318
315
 
319
316
  For browsers that don't support this feature yet, Bun's CSS bundler converts it to use CSS variables with proper fallbacks:
320
317
 
321
- ```css
318
+ ```css title="styles.css" icon="file-code"
322
319
  :root {
323
320
  --lightningcss-light: initial;
324
321
  --lightningcss-dark: ;
@@ -345,21 +342,19 @@ For browsers that don't support this feature yet, Bun's CSS bundler converts it
345
342
  }
346
343
 
347
344
  .themed-component {
348
- background-color: var(--lightningcss-light, #ffffff)
349
- var(--lightningcss-dark, #121212);
345
+ background-color: var(--lightningcss-light, #ffffff) var(--lightningcss-dark, #121212);
350
346
  color: var(--lightningcss-light, #333333) var(--lightningcss-dark, #eeeeee);
351
- border-color: var(--lightningcss-light, #dddddd)
352
- var(--lightningcss-dark, #555555);
347
+ border-color: var(--lightningcss-light, #dddddd) var(--lightningcss-dark, #555555);
353
348
  }
354
349
  ```
355
350
 
356
351
  This approach gives you a clean way to handle light and dark themes without duplicating styles or writing complex media queries, while maintaining compatibility with browsers that don't yet support the feature natively.
357
352
 
358
- #### Logical properties
353
+ ### Logical properties
359
354
 
360
355
  CSS logical properties let you define layout, spacing, and sizing relative to the document's writing mode and text direction rather than physical screen directions. This is crucial for creating truly international layouts that automatically adapt to different writing systems.
361
356
 
362
- ```css
357
+ ```css title="styles.css" icon="file-code"
363
358
  .multilingual-component {
364
359
  /* Margin that adapts to writing direction */
365
360
  margin-inline-start: 1rem;
@@ -378,7 +373,7 @@ CSS logical properties let you define layout, spacing, and sizing relative to th
378
373
 
379
374
  For browsers that don't fully support logical properties, Bun's CSS bundler compiles them to physical properties with appropriate directional adjustments:
380
375
 
381
- ```css
376
+ ```css title="styles.css" icon="file-code"
382
377
  /* For left-to-right languages */
383
378
  .multilingual-component:dir(ltr) {
384
379
  margin-left: 1rem;
@@ -402,11 +397,11 @@ For browsers that don't fully support logical properties, Bun's CSS bundler comp
402
397
 
403
398
  If the `:dir()` selector isn't supported, additional fallbacks are automatically generated to ensure your layouts work properly across all browsers and writing systems. This makes creating internationalized designs much simpler while maintaining compatibility with older browsers.
404
399
 
405
- #### :dir() selector
400
+ ### :dir() selector
406
401
 
407
402
  The `:dir()` pseudo-class selector allows you to style elements based on their text direction (RTL or LTR), providing a powerful way to create direction-aware designs without JavaScript. This selector matches elements based on their directionality as determined by the document or explicit direction attributes.
408
403
 
409
- ```css
404
+ ```css title="styles.css" icon="file-code"
410
405
  /* Apply different styles based on text direction */
411
406
  .nav-arrow:dir(ltr) {
412
407
  transform: rotate(0deg);
@@ -428,7 +423,7 @@ The `:dir()` pseudo-class selector allows you to style elements based on their t
428
423
 
429
424
  For browsers that don't support the `:dir()` selector yet, Bun's CSS bundler converts it to the more widely supported `:lang()` selector with appropriate language mappings:
430
425
 
431
- ```css
426
+ ```css title="styles.css" icon="file-code"
432
427
  /* Converted to use language-based selectors as fallback */
433
428
  .nav-arrow:lang(en, fr, de, es, it, pt, nl) {
434
429
  transform: rotate(0deg);
@@ -449,11 +444,11 @@ For browsers that don't support the `:dir()` selector yet, Bun's CSS bundler con
449
444
 
450
445
  This conversion lets you write direction-aware CSS that works reliably across browsers, even those that don't yet support the `:dir()` selector natively. If multiple arguments to `:lang()` aren't supported, further fallbacks are automatically provided.
451
446
 
452
- #### :lang() selector
447
+ ### :lang() selector
453
448
 
454
449
  The `:lang()` pseudo-class selector allows you to target elements based on the language they're in, making it easy to apply language-specific styling. Modern CSS allows the `:lang()` selector to accept multiple language codes, letting you group language-specific rules more efficiently.
455
450
 
456
- ```css
451
+ ```css title="styles.css" icon="file-code"
457
452
  /* Typography adjustments for CJK languages */
458
453
  :lang(zh, ja, ko) {
459
454
  line-height: 1.8;
@@ -472,7 +467,7 @@ blockquote:lang(de, nl, da, sv) {
472
467
 
473
468
  For browsers that don't support multiple arguments in the `:lang()` selector, Bun's CSS bundler converts this syntax to use the `:is()` selector to maintain the same behavior:
474
469
 
475
- ```css
470
+ ```css title="styles.css" icon="file-code"
476
471
  /* Multiple languages grouped with :is() for better browser support */
477
472
  :is(:lang(zh), :lang(ja), :lang(ko)) {
478
473
  line-height: 1.8;
@@ -490,11 +485,11 @@ blockquote:is(:lang(de), :lang(nl), :lang(da), :lang(sv)) {
490
485
 
491
486
  If needed, Bun can provide additional fallbacks for `:is()` as well, ensuring your language-specific styles work across all browsers. This approach simplifies creating internationalized designs with distinct typographic and styling rules for different language groups.
492
487
 
493
- #### :is() selector
488
+ ### :is() selector
494
489
 
495
490
  The `:is()` pseudo-class function (formerly `:matches()`) allows you to create more concise and readable selectors by grouping multiple selectors together. It accepts a selector list as its argument and matches if any of the selectors in that list match, significantly reducing repetition in your CSS.
496
491
 
497
- ```css
492
+ ```css title="styles.css" icon="file-code"
498
493
  /* Instead of writing these separately */
499
494
  /*
500
495
  .article h1,
@@ -547,13 +542,17 @@ For browsers that don't support `:is()`, Bun's CSS bundler provides fallbacks us
547
542
  }
548
543
  ```
549
544
 
550
- It's worth noting that the vendor-prefixed versions have some limitations compared to the standardized `:is()` selector, particularly with complex selectors. Bun handles these limitations intelligently, only using prefixed versions when they'll work correctly.
545
+ <Warning>
546
+ The vendor-prefixed versions have some limitations compared to the standardized `:is()` selector, particularly with
547
+ complex selectors. Bun handles these limitations intelligently, only using prefixed versions when they'll work
548
+ correctly.
549
+ </Warning>
551
550
 
552
- #### :not() selector
551
+ ### :not() selector
553
552
 
554
553
  The `:not()` pseudo-class allows you to exclude elements that match a specific selector. The modern version of this selector accepts multiple arguments, letting you exclude multiple patterns with a single, concise selector.
555
554
 
556
- ```css
555
+ ```css title="styles.css" icon="file-code"
557
556
  /* Select all buttons except primary and secondary variants */
558
557
  button:not(.primary, .secondary) {
559
558
  background-color: #f5f5f5;
@@ -568,7 +567,7 @@ h2:not(.sidebar *, footer *) {
568
567
 
569
568
  For browsers that don't support multiple arguments in `:not()`, Bun's CSS bundler converts this syntax to a more compatible form while preserving the same behavior:
570
569
 
571
- ```css
570
+ ```css title="styles.css" icon="file-code"
572
571
  /* Converted to use :not with :is() for compatibility */
573
572
  button:not(:is(.primary, .secondary)) {
574
573
  background-color: #f5f5f5;
@@ -582,7 +581,7 @@ h2:not(:is(.sidebar *, footer *)) {
582
581
 
583
582
  And if `:is()` isn't supported, Bun can generate further fallbacks:
584
583
 
585
- ```css
584
+ ```css title="styles.css" icon="file-code"
586
585
  /* Even more fallbacks for maximum compatibility */
587
586
  button:not(:-webkit-any(.primary, .secondary)) {
588
587
  background-color: #f5f5f5;
@@ -602,11 +601,11 @@ button:not(:is(.primary, .secondary)) {
602
601
 
603
602
  This conversion ensures your negative selectors work correctly across all browsers while maintaining the correct specificity and behavior of the original selector.
604
603
 
605
- #### Math functions
604
+ ### Math functions
606
605
 
607
606
  CSS now includes a rich set of mathematical functions that let you perform complex calculations directly in your stylesheets. These include standard math functions (`round()`, `mod()`, `rem()`, `abs()`, `sign()`), trigonometric functions (`sin()`, `cos()`, `tan()`, `asin()`, `acos()`, `atan()`, `atan2()`), and exponential functions (`pow()`, `sqrt()`, `exp()`, `log()`, `hypot()`).
608
607
 
609
- ```css
608
+ ```css title="styles.css" icon="file-code"
610
609
  .dynamic-sizing {
611
610
  /* Clamp a value between minimum and maximum */
612
611
  width: clamp(200px, 50%, 800px);
@@ -625,7 +624,7 @@ CSS now includes a rich set of mathematical functions that let you perform compl
625
624
 
626
625
  Bun's CSS bundler evaluates these mathematical expressions at build time when all values are known constants (not variables), resulting in optimized output:
627
626
 
628
- ```css
627
+ ```css title="styles.css" icon="file-code"
629
628
  .dynamic-sizing {
630
629
  width: clamp(200px, 50%, 800px);
631
630
  padding: 15px;
@@ -637,11 +636,11 @@ Bun's CSS bundler evaluates these mathematical expressions at build time when al
637
636
 
638
637
  This approach lets you write more expressive and maintainable CSS with meaningful mathematical relationships, which then gets compiled to optimized values for maximum browser compatibility and performance.
639
638
 
640
- #### Media query ranges
639
+ ### Media query ranges
641
640
 
642
641
  Modern CSS supports intuitive range syntax for media queries, allowing you to specify breakpoints using comparison operators like `<`, `>`, `<=`, and `>=` instead of the more verbose `min-` and `max-` prefixes. This syntax is more readable and matches how we normally think about values and ranges.
643
642
 
644
- ```css
643
+ ```css title="styles.css" icon="file-code"
645
644
  /* Modern syntax with comparison operators */
646
645
  @media (width >= 768px) {
647
646
  .container {
@@ -666,7 +665,7 @@ Modern CSS supports intuitive range syntax for media queries, allowing you to sp
666
665
 
667
666
  Bun's CSS bundler converts these modern range queries to traditional media query syntax for compatibility with all browsers:
668
667
 
669
- ```css
668
+ ```css title="styles.css" icon="file-code"
670
669
  /* Converted to traditional min/max syntax */
671
670
  @media (min-width: 768px) {
672
671
  .container {
@@ -689,11 +688,11 @@ Bun's CSS bundler converts these modern range queries to traditional media query
689
688
 
690
689
  This lets you write more intuitive and mathematical media queries while ensuring your stylesheets work correctly across all browsers, including those that don't support the modern range syntax.
691
690
 
692
- #### Shorthands
691
+ ### Shorthands
693
692
 
694
693
  CSS has introduced several modern shorthand properties that improve code readability and maintainability. Bun's CSS bundler ensures these convenient shorthands work on all browsers by converting them to their longhand equivalents when needed.
695
694
 
696
- ```css
695
+ ```css title="styles.css" icon="file-code"
697
696
  /* Alignment shorthands */
698
697
  .flex-container {
699
698
  /* Shorthand for align-items and justify-items */
@@ -729,7 +728,7 @@ CSS has introduced several modern shorthand properties that improve code readabi
729
728
 
730
729
  For browsers that don't support these modern shorthands, Bun converts them to their component longhand properties:
731
730
 
732
- ```css
731
+ ```css title="styles.css" icon="file-code"
733
732
  .flex-container {
734
733
  /* Expanded alignment properties */
735
734
  align-items: center;
@@ -766,11 +765,11 @@ For browsers that don't support these modern shorthands, Bun converts them to th
766
765
 
767
766
  This conversion ensures your stylesheets remain clean and maintainable while providing the broadest possible browser compatibility.
768
767
 
769
- #### Double position gradients
768
+ ### Double position gradients
770
769
 
771
770
  The double position gradient syntax is a modern CSS feature that allows you to create hard color stops in gradients by specifying the same color at two adjacent positions. This creates a sharp transition rather than a smooth fade, which is useful for creating stripes, color bands, and other multi-color designs.
772
771
 
773
- ```css
772
+ ```css title="styles.css" icon="file-code"
774
773
  .striped-background {
775
774
  /* Creates a sharp transition from green to red at 30%-40% */
776
775
  background: linear-gradient(
@@ -799,7 +798,7 @@ The double position gradient syntax is a modern CSS feature that allows you to c
799
798
 
800
799
  For browsers that don't support this syntax, Bun's CSS bundler automatically converts it to the traditional format by duplicating color stops:
801
800
 
802
- ```css
801
+ ```css title="styles.css" icon="file-code"
803
802
  .striped-background {
804
803
  background: linear-gradient(
805
804
  to right,
@@ -830,11 +829,11 @@ For browsers that don't support this syntax, Bun's CSS bundler automatically con
830
829
 
831
830
  This conversion lets you use the cleaner double position syntax in your source code while ensuring gradients display correctly in all browsers.
832
831
 
833
- #### system-ui font
832
+ ### system-ui font
834
833
 
835
834
  The `system-ui` generic font family lets you use the device's native UI font, creating interfaces that feel more integrated with the operating system. This provides a more native look and feel without having to specify different font stacks for each platform.
836
835
 
837
- ```css
836
+ ```css title="styles.css" icon="file-code"
838
837
  .native-interface {
839
838
  /* Use the system's default UI font */
840
839
  font-family: system-ui;
@@ -848,7 +847,7 @@ The `system-ui` generic font family lets you use the device's native UI font, cr
848
847
 
849
848
  For browsers that don't support `system-ui`, Bun's CSS bundler automatically expands it to a comprehensive cross-platform font stack:
850
849
 
851
- ```css
850
+ ```css title="styles.css" icon="file-code"
852
851
  .native-interface {
853
852
  /* Expanded to support all major platforms */
854
853
  font-family:
@@ -883,7 +882,7 @@ This approach gives you the simplicity of writing just `system-ui` in your sourc
883
882
 
884
883
  ## CSS Modules
885
884
 
886
- Bun's bundler also supports bundling [CSS modules](https://css-tricks.com/css-modules-part-1-need/) in addition to [regular CSS](/docs/bundler/css) with support for the following features:
885
+ Bun's bundler also supports bundling CSS modules in addition to regular CSS with support for the following features:
887
886
 
888
887
  - Automatically detecting CSS module files (`.module.css`) with zero configuration
889
888
  - Composition (`composes` property)
@@ -894,17 +893,17 @@ A CSS module is a CSS file (with the `.module.css` extension) where are all clas
894
893
 
895
894
  Under the hood, Bun's bundler transforms locally scoped class names into unique identifiers.
896
895
 
897
- ## Getting started
896
+ ### Getting started
898
897
 
899
898
  Create a CSS file with the `.module.css` extension:
900
899
 
901
- ```css
902
- /* styles.module.css */
900
+ ```css title="styles.module.css" icon="file-code"
903
901
  .button {
904
902
  color: red;
905
903
  }
904
+ ```
906
905
 
907
- /* other-styles.module.css */
906
+ ```css title="other-styles.module.css" icon="file-code"
908
907
  .button {
909
908
  color: blue;
910
909
  }
@@ -912,7 +911,7 @@ Create a CSS file with the `.module.css` extension:
912
911
 
913
912
  You can then import this file, for example into a TSX file:
914
913
 
915
- ```tsx
914
+ ```tsx title="app.tsx" icon="/icons/typescript.svg"
916
915
  import styles from "./styles.module.css";
917
916
  import otherStyles from "./other-styles.module.css";
918
917
 
@@ -926,10 +925,9 @@ export default function App() {
926
925
  }
927
926
  ```
928
927
 
929
- The `styles` object from importing the CSS module file will be an object with all class names as keys and
930
- their unique identifiers as values:
928
+ The styles object from importing the CSS module file will be an object with all class names as keys and their unique identifiers as values:
931
929
 
932
- ```tsx
930
+ ```ts title="app.tsx" icon="/icons/typescript.svg"
933
931
  import styles from "./styles.module.css";
934
932
  import otherStyles from "./other-styles.module.css";
935
933
 
@@ -939,7 +937,7 @@ console.log(otherStyles);
939
937
 
940
938
  This will output:
941
939
 
942
- ```ts
940
+ ```ts title="app.tsx" icon="/icons/typescript.svg"
943
941
  {
944
942
  button: "button_123";
945
943
  }
@@ -953,12 +951,11 @@ As you can see, the class names are unique to each file, avoiding any collisions
953
951
 
954
952
  ### Composition
955
953
 
956
- CSS modules allow you to _compose_ class selectors together. This lets you reuse style rules across multiple classes.
954
+ CSS modules allow you to compose class selectors together. This lets you reuse style rules across multiple classes.
957
955
 
958
956
  For example:
959
957
 
960
- ```css
961
- /* styles.module.css */
958
+ ```css title="styles.module.css" icon="file-code"
962
959
  .button {
963
960
  composes: background;
964
961
  color: red;
@@ -971,7 +968,7 @@ For example:
971
968
 
972
969
  Would be the same as writing:
973
970
 
974
- ```css
971
+ ```css title="styles.module.css" icon="file-code"
975
972
  .button {
976
973
  background-color: blue;
977
974
  color: red;
@@ -982,13 +979,14 @@ Would be the same as writing:
982
979
  }
983
980
  ```
984
981
 
985
- {% callout %}
986
982
  There are a couple rules to keep in mind when using `composes`:
987
983
 
988
- - A `composes` property must come before any regular CSS properties or declarations
989
- - You can only use `composes` on a **simple selector with a single class name**:
984
+ <Info>
985
+ **Composition Rules:** - A `composes` property must come before any regular CSS properties or declarations - You can
986
+ only use `composes` on a simple selector with a single class name
987
+ </Info>
990
988
 
991
- ```css
989
+ ```css title="styles.module.css" icon="file-code"
992
990
  #button {
993
991
  /* Invalid! `#button` is not a class selector */
994
992
  composes: background;
@@ -1001,28 +999,26 @@ There are a couple rules to keep in mind when using `composes`:
1001
999
  }
1002
1000
  ```
1003
1001
 
1004
- {% /callout %}
1005
-
1006
1002
  ### Composing from a separate CSS module file
1007
1003
 
1008
1004
  You can also compose from a separate CSS module file:
1009
1005
 
1010
- ```css
1011
- /* background.module.css */
1006
+ ```css title="background.module.css" icon="file-code"
1012
1007
  .background {
1013
1008
  background-color: blue;
1014
1009
  }
1010
+ ```
1015
1011
 
1016
- /* styles.module.css */
1012
+ ```css title="styles.module.css" icon="file-code"
1017
1013
  .button {
1018
1014
  composes: background from "./background.module.css";
1019
1015
  color: red;
1020
1016
  }
1021
1017
  ```
1022
1018
 
1023
- {% callout %}
1019
+ <Warning>
1024
1020
  When composing classes from separate files, be sure that they do not contain the same properties.
1025
1021
 
1026
- The CSS module spec says that composing classes from separate files with conflicting properties is
1027
- undefined behavior, meaning that the output may differ and be unreliable.
1028
- {% /callout %}
1022
+ The CSS module spec says that composing classes from separate files with conflicting properties is undefined behavior, meaning that the output may differ and be unreliable.
1023
+
1024
+ </Warning>