bun-types 1.3.2-canary.20251105T140650 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bun.d.ts +102 -6
- package/docs/README.md +28 -0
- package/docs/bundler/bytecode.mdx +465 -0
- package/docs/bundler/{css.md → css.mdx} +97 -101
- package/docs/bundler/esbuild.mdx +253 -0
- package/docs/bundler/{executables.md → executables.mdx} +130 -221
- package/docs/bundler/fullstack.mdx +1064 -0
- package/docs/bundler/{hmr.md → hot-reloading.mdx} +74 -79
- package/docs/bundler/{html.md → html-static.mdx} +148 -111
- package/docs/bundler/index.mdx +1499 -0
- package/docs/bundler/loaders.mdx +356 -0
- package/docs/bundler/{macros.md → macros.mdx} +83 -84
- package/docs/bundler/minifier.mdx +1306 -0
- package/docs/bundler/plugins.mdx +411 -0
- package/docs/feedback.mdx +85 -0
- package/docs/guides/binary/{arraybuffer-to-array.md → arraybuffer-to-array.mdx} +3 -1
- package/docs/guides/binary/{arraybuffer-to-blob.md → arraybuffer-to-blob.mdx} +3 -1
- package/docs/guides/binary/{arraybuffer-to-buffer.md → arraybuffer-to-buffer.mdx} +3 -1
- package/docs/guides/binary/{arraybuffer-to-string.md → arraybuffer-to-string.mdx} +3 -1
- package/docs/guides/binary/{arraybuffer-to-typedarray.md → arraybuffer-to-typedarray.mdx} +3 -1
- package/docs/guides/binary/{blob-to-arraybuffer.md → blob-to-arraybuffer.mdx} +3 -1
- package/docs/guides/binary/{blob-to-dataview.md → blob-to-dataview.mdx} +3 -1
- package/docs/guides/binary/{blob-to-stream.md → blob-to-stream.mdx} +3 -1
- package/docs/guides/binary/{blob-to-string.md → blob-to-string.mdx} +3 -1
- package/docs/guides/binary/{blob-to-typedarray.md → blob-to-typedarray.mdx} +3 -1
- package/docs/guides/binary/{buffer-to-arraybuffer.md → buffer-to-arraybuffer.mdx} +3 -1
- package/docs/guides/binary/{buffer-to-blob.md → buffer-to-blob.mdx} +3 -1
- package/docs/guides/binary/{buffer-to-readablestream.md → buffer-to-readablestream.mdx} +3 -1
- package/docs/guides/binary/{buffer-to-string.md → buffer-to-string.mdx} +3 -1
- package/docs/guides/binary/{buffer-to-typedarray.md → buffer-to-typedarray.mdx} +3 -1
- package/docs/guides/binary/{dataview-to-string.md → dataview-to-string.mdx} +3 -1
- package/docs/guides/binary/{typedarray-to-arraybuffer.md → typedarray-to-arraybuffer.mdx} +3 -1
- package/docs/guides/binary/{typedarray-to-blob.md → typedarray-to-blob.mdx} +3 -1
- package/docs/guides/binary/{typedarray-to-buffer.md → typedarray-to-buffer.mdx} +3 -1
- package/docs/guides/binary/{typedarray-to-dataview.md → typedarray-to-dataview.mdx} +3 -1
- package/docs/guides/binary/{typedarray-to-readablestream.md → typedarray-to-readablestream.mdx} +3 -1
- package/docs/guides/binary/{typedarray-to-string.md → typedarray-to-string.mdx} +3 -1
- package/docs/guides/deployment/aws-lambda.mdx +204 -0
- package/docs/guides/deployment/digital-ocean.mdx +161 -0
- package/docs/guides/deployment/google-cloud-run.mdx +197 -0
- package/docs/guides/deployment/{railway.md → railway.mdx} +42 -54
- package/docs/guides/deployment/render.mdx +82 -0
- package/docs/guides/deployment/vercel.mdx +99 -0
- package/docs/guides/ecosystem/{astro.md → astro.mdx} +16 -6
- package/docs/guides/ecosystem/{discordjs.md → discordjs.mdx} +21 -18
- package/docs/guides/ecosystem/{docker.md → docker.mdx} +25 -14
- package/docs/guides/ecosystem/{drizzle.md → drizzle.mdx} +32 -22
- package/docs/guides/ecosystem/{edgedb.md → edgedb.mdx} +63 -34
- package/docs/guides/ecosystem/{elysia.md → elysia.mdx} +11 -11
- package/docs/guides/ecosystem/{express.md → express.mdx} +12 -9
- package/docs/guides/ecosystem/{hono.md → hono.mdx} +16 -8
- package/docs/guides/ecosystem/{mongoose.md → mongoose.mdx} +26 -21
- package/docs/guides/ecosystem/{neon-drizzle.md → neon-drizzle.mdx} +49 -35
- package/docs/guides/ecosystem/{neon-serverless-postgres.md → neon-serverless-postgres.mdx} +16 -11
- package/docs/guides/ecosystem/{nextjs.md → nextjs.mdx} +18 -10
- package/docs/guides/ecosystem/{nuxt.md → nuxt.mdx} +45 -11
- package/docs/guides/ecosystem/{pm2.md → pm2.mdx} +7 -9
- package/docs/guides/ecosystem/prisma-postgres.mdx +169 -0
- package/docs/guides/ecosystem/prisma.mdx +164 -0
- package/docs/guides/ecosystem/{qwik.md → qwik.mdx} +18 -11
- package/docs/guides/ecosystem/{react.md → react.mdx} +9 -7
- package/docs/guides/ecosystem/{remix.md → remix.mdx} +45 -26
- package/docs/guides/ecosystem/{sentry.md → sentry.mdx} +7 -5
- package/docs/guides/ecosystem/{solidstart.md → solidstart.mdx} +21 -13
- package/docs/guides/ecosystem/{ssr-react.md → ssr-react.mdx} +9 -11
- package/docs/guides/ecosystem/{stric.md → stric.mdx} +16 -17
- package/docs/guides/ecosystem/{sveltekit.md → sveltekit.mdx} +42 -29
- package/docs/guides/ecosystem/{systemd.md → systemd.mdx} +27 -26
- package/docs/guides/ecosystem/upstash.mdx +87 -0
- package/docs/guides/ecosystem/{vite.md → vite.mdx} +20 -14
- package/docs/guides/html-rewriter/{extract-links.md → extract-links.mdx} +11 -7
- package/docs/guides/html-rewriter/{extract-social-meta.md → extract-social-meta.mdx} +6 -2
- package/docs/guides/http/{cluster.md → cluster.mdx} +10 -7
- package/docs/guides/http/{fetch-unix.md → fetch-unix.mdx} +5 -3
- package/docs/guides/http/{fetch.md → fetch.mdx} +5 -3
- package/docs/guides/http/{file-uploads.md → file-uploads.mdx} +18 -15
- package/docs/guides/http/{hot.md → hot.mdx} +9 -7
- package/docs/guides/http/{proxy.md → proxy.mdx} +7 -5
- package/docs/guides/http/{server.md → server.mdx} +4 -2
- package/docs/guides/http/{simple.md → simple.mdx} +4 -2
- package/docs/guides/http/{stream-file.md → stream-file.mdx} +6 -4
- package/docs/guides/http/{stream-iterator.md → stream-iterator.mdx} +5 -3
- package/docs/guides/http/{stream-node-streams-in-bun.md → stream-node-streams-in-bun.mdx} +4 -2
- package/docs/guides/http/{tls.md → tls.mdx} +5 -3
- package/docs/guides/index.mdx +10 -0
- package/docs/guides/install/{add-dev.md → add-dev.mdx} +8 -6
- package/docs/guides/install/add-git.mdx +38 -0
- package/docs/guides/install/{add-optional.md → add-optional.mdx} +7 -5
- package/docs/guides/install/{add-peer.md → add-peer.mdx} +13 -11
- package/docs/guides/install/{add-tarball.md → add-tarball.mdx} +7 -5
- package/docs/guides/install/{add.md → add.mdx} +12 -10
- package/docs/guides/install/{azure-artifacts.md → azure-artifacts.mdx} +15 -12
- package/docs/guides/{runtime/cicd.md → install/cicd.mdx} +13 -13
- package/docs/guides/install/{custom-registry.md → custom-registry.mdx} +6 -4
- package/docs/guides/install/{from-npm-install-to-bun-install.md → from-npm-install-to-bun-install.mdx} +50 -34
- package/docs/guides/install/{git-diff-bun-lockfile.md → git-diff-bun-lockfile.mdx} +14 -11
- package/docs/guides/install/{jfrog-artifactory.md → jfrog-artifactory.mdx} +4 -4
- package/docs/guides/install/{npm-alias.md → npm-alias.mdx} +6 -4
- package/docs/guides/install/{registry-scope.md → registry-scope.mdx} +6 -4
- package/docs/guides/install/{trusted.md → trusted.mdx} +22 -18
- package/docs/guides/install/{workspaces.md → workspaces.mdx} +13 -13
- package/docs/guides/install/{yarnlock.md → yarnlock.mdx} +15 -9
- package/docs/guides/process/{argv.md → argv.mdx} +17 -9
- package/docs/guides/process/{ctrl-c.md → ctrl-c.mdx} +4 -2
- package/docs/guides/process/{ipc.md → ipc.mdx} +13 -10
- package/docs/guides/process/{nanoseconds.md → nanoseconds.mdx} +3 -1
- package/docs/guides/process/{os-signals.md → os-signals.mdx} +3 -1
- package/docs/guides/process/{spawn-stderr.md → spawn-stderr.mdx} +4 -1
- package/docs/guides/process/{spawn-stdout.md → spawn-stdout.mdx} +3 -1
- package/docs/guides/process/{spawn.md → spawn.mdx} +3 -1
- package/docs/guides/process/{stdin.md → stdin.mdx} +15 -7
- package/docs/guides/read-file/{arraybuffer.md → arraybuffer.mdx} +5 -3
- package/docs/guides/read-file/{buffer.md → buffer.mdx} +4 -2
- package/docs/guides/read-file/{exists.md → exists.mdx} +4 -2
- package/docs/guides/read-file/{json.md → json.mdx} +4 -2
- package/docs/guides/read-file/{mime.md → mime.mdx} +3 -1
- package/docs/guides/read-file/{stream.md → stream.mdx} +3 -1
- package/docs/guides/read-file/{string.md → string.mdx} +3 -1
- package/docs/guides/read-file/{uint8array.md → uint8array.mdx} +3 -1
- package/docs/guides/read-file/{watch.md → watch.mdx} +6 -8
- package/docs/guides/runtime/{build-time-constants.md → build-time-constants.mdx} +24 -22
- package/docs/guides/{install/cicd.md → runtime/cicd.mdx} +11 -7
- package/docs/guides/runtime/{codesign-macos-executable.md → codesign-macos-executable.mdx} +14 -9
- package/docs/guides/runtime/{define-constant.md → define-constant.mdx} +20 -16
- package/docs/guides/runtime/{delete-directory.md → delete-directory.mdx} +5 -3
- package/docs/guides/runtime/{delete-file.md → delete-file.mdx} +4 -2
- package/docs/guides/runtime/{heap-snapshot.md → heap-snapshot.mdx} +5 -3
- package/docs/guides/runtime/{import-html.md → import-html.mdx} +4 -2
- package/docs/guides/runtime/{import-json.md → import-json.mdx} +6 -4
- package/docs/guides/runtime/{import-toml.md → import-toml.mdx} +5 -3
- package/docs/guides/runtime/{import-yaml.md → import-yaml.mdx} +9 -7
- package/docs/guides/runtime/{read-env.md → read-env.mdx} +10 -5
- package/docs/guides/runtime/{set-env.md → set-env.mdx} +14 -10
- package/docs/guides/runtime/{shell.md → shell.mdx} +6 -4
- package/docs/guides/runtime/{timezone.md → timezone.mdx} +10 -7
- package/docs/guides/runtime/{tsconfig-paths.md → tsconfig-paths.mdx} +5 -3
- package/docs/guides/runtime/{typescript.md → typescript.mdx} +8 -6
- package/docs/guides/runtime/{vscode-debugger.md → vscode-debugger.mdx} +12 -11
- package/docs/guides/runtime/{web-debugger.md → web-debugger.mdx} +39 -18
- package/docs/guides/streams/{node-readable-to-arraybuffer.md → node-readable-to-arraybuffer.mdx} +3 -1
- package/docs/guides/streams/{node-readable-to-blob.md → node-readable-to-blob.mdx} +3 -1
- package/docs/guides/streams/{node-readable-to-json.md → node-readable-to-json.mdx} +3 -1
- package/docs/guides/streams/{node-readable-to-string.md → node-readable-to-string.mdx} +3 -1
- package/docs/guides/streams/{node-readable-to-uint8array.md → node-readable-to-uint8array.mdx} +3 -1
- package/docs/guides/streams/{to-array.md → to-array.mdx} +3 -1
- package/docs/guides/streams/{to-arraybuffer.md → to-arraybuffer.mdx} +3 -1
- package/docs/guides/streams/{to-blob.md → to-blob.mdx} +3 -1
- package/docs/guides/streams/{to-buffer.md → to-buffer.mdx} +3 -1
- package/docs/guides/streams/{to-json.md → to-json.mdx} +4 -2
- package/docs/guides/streams/{to-string.md → to-string.mdx} +3 -1
- package/docs/guides/streams/{to-typedarray.md → to-typedarray.mdx} +3 -1
- package/docs/guides/test/{bail.md → bail.mdx} +7 -5
- package/docs/guides/test/{coverage-threshold.md → coverage-threshold.mdx} +14 -7
- package/docs/guides/test/{coverage.md → coverage.mdx} +9 -4
- package/docs/guides/test/{happy-dom.md → happy-dom.mdx} +13 -8
- package/docs/guides/test/{migrate-from-jest.md → migrate-from-jest.mdx} +19 -37
- package/docs/guides/test/{mock-clock.md → mock-clock.mdx} +3 -1
- package/docs/guides/test/{mock-functions.md → mock-functions.mdx} +7 -5
- package/docs/guides/test/{rerun-each.md → rerun-each.mdx} +5 -3
- package/docs/guides/test/{run-tests.md → run-tests.mdx} +16 -11
- package/docs/guides/test/{skip-tests.md → skip-tests.mdx} +8 -4
- package/docs/guides/test/{snapshot.md → snapshot.mdx} +20 -13
- package/docs/guides/test/spy-on.mdx +49 -0
- package/docs/guides/test/{svelte-test.md → svelte-test.mdx} +16 -23
- package/docs/guides/test/{testing-library.md → testing-library.mdx} +18 -17
- package/docs/guides/test/{timeout.md → timeout.mdx} +5 -3
- package/docs/guides/test/{todo-tests.md → todo-tests.mdx} +13 -6
- package/docs/guides/test/{update-snapshots.md → update-snapshots.mdx} +9 -6
- package/docs/guides/test/{watch-mode.md → watch-mode.mdx} +9 -4
- package/docs/guides/util/{base64.md → base64.mdx} +3 -1
- package/docs/guides/util/{deep-equals.md → deep-equals.mdx} +5 -3
- package/docs/guides/util/{deflate.md → deflate.mdx} +3 -1
- package/docs/guides/util/{detect-bun.md → detect-bun.mdx} +3 -1
- package/docs/guides/util/{entrypoint.md → entrypoint.mdx} +4 -2
- package/docs/guides/util/{escape-html.md → escape-html.mdx} +3 -1
- package/docs/guides/util/{file-url-to-path.md → file-url-to-path.mdx} +3 -1
- package/docs/guides/util/{gzip.md → gzip.mdx} +3 -1
- package/docs/guides/util/{hash-a-password.md → hash-a-password.mdx} +3 -1
- package/docs/guides/util/{import-meta-dir.md → import-meta-dir.mdx} +4 -2
- package/docs/guides/util/{import-meta-file.md → import-meta-file.mdx} +4 -2
- package/docs/guides/util/{import-meta-path.md → import-meta-path.mdx} +4 -2
- package/docs/guides/util/{javascript-uuid.md → javascript-uuid.mdx} +3 -1
- package/docs/guides/util/{main.md → main.mdx} +19 -8
- package/docs/guides/util/{path-to-file-url.md → path-to-file-url.mdx} +3 -1
- package/docs/guides/util/{sleep.md → sleep.mdx} +3 -1
- package/docs/guides/util/{version.md → version.mdx} +6 -4
- package/docs/guides/util/{which-path-to-executable-bin.md → which-path-to-executable-bin.mdx} +4 -2
- package/docs/guides/websocket/{compression.md → compression.mdx} +5 -3
- package/docs/guides/websocket/{context.md → context.mdx} +9 -12
- package/docs/guides/websocket/{pubsub.md → pubsub.mdx} +5 -6
- package/docs/guides/websocket/{simple.md → simple.mdx} +5 -3
- package/docs/guides/write-file/{append.md → append.mdx} +3 -1
- package/docs/guides/write-file/{basic.md → basic.mdx} +3 -1
- package/docs/guides/write-file/{blob.md → blob.mdx} +3 -1
- package/docs/guides/write-file/{cat.md → cat.mdx} +4 -2
- package/docs/guides/write-file/{file-cp.md → file-cp.mdx} +3 -1
- package/docs/guides/write-file/{filesink.md → filesink.mdx} +3 -1
- package/docs/guides/write-file/{response.md → response.mdx} +3 -1
- package/docs/guides/write-file/{stdout.md → stdout.mdx} +3 -1
- package/docs/guides/write-file/{stream.md → stream.mdx} +3 -1
- package/docs/guides/write-file/{unlink.md → unlink.mdx} +3 -1
- package/docs/{index.md → index.mdx} +97 -41
- package/docs/installation.mdx +365 -0
- package/docs/{cli/bunx.md → pm/bunx.mdx} +25 -31
- package/docs/{install/catalogs.md → pm/catalogs.mdx} +18 -24
- package/docs/{cli/add.md → pm/cli/add.mdx} +61 -55
- package/docs/{install/audit.md → pm/cli/audit.mdx} +11 -8
- package/docs/{cli/install.md → pm/cli/install.mdx} +208 -81
- package/docs/{cli/link.md → pm/cli/link.mdx} +27 -19
- package/docs/{cli/outdated.md → pm/cli/outdated.mdx} +119 -12
- package/docs/{install/patch.md → pm/cli/patch.mdx} +25 -15
- package/docs/{cli/pm.md → pm/cli/pm.mdx} +96 -62
- package/docs/{cli/publish.md → pm/cli/publish.mdx} +38 -35
- package/docs/pm/cli/remove.mdx +16 -0
- package/docs/{cli/update.md → pm/cli/update.mdx} +26 -15
- package/docs/{cli/why.md → pm/cli/why.mdx} +27 -10
- package/docs/{cli/filter.md → pm/filter.mdx} +26 -14
- package/docs/{install/cache.md → pm/global-cache.mdx} +25 -12
- package/docs/{install/isolated.md → pm/isolated-installs.mdx} +32 -24
- package/docs/{install/lifecycle.md → pm/lifecycle.mdx} +20 -9
- package/docs/{install/lockfile.md → pm/lockfile.mdx} +18 -12
- package/docs/{install/npmrc.md → pm/npmrc.mdx} +30 -24
- package/docs/{install/overrides.md → pm/overrides.mdx} +47 -37
- package/docs/{install/registries.md → pm/scopes-registries.mdx} +8 -3
- package/docs/{install/security-scanner-api.md → pm/security-scanner-api.mdx} +22 -8
- package/docs/{install/workspaces.md → pm/workspaces.mdx} +17 -22
- package/docs/project/{benchmarking.md → benchmarking.mdx} +26 -11
- package/docs/project/{bindgen.md → bindgen.mdx} +12 -14
- package/docs/project/{building-windows.md → building-windows.mdx} +18 -47
- package/docs/project/{contributing.md → contributing.mdx} +56 -60
- package/docs/project/feedback.mdx +20 -0
- package/docs/project/license.mdx +78 -0
- package/docs/project/roadmap.mdx +8 -0
- package/docs/quickstart.mdx +240 -0
- package/docs/runtime/{autoimport.md → auto-install.mdx} +34 -31
- package/docs/{api/binary-data.md → runtime/binary-data.mdx} +77 -269
- package/docs/runtime/bun-apis.mdx +59 -0
- package/docs/runtime/{bunfig.md → bunfig.mdx} +95 -225
- package/docs/{api/cc.md → runtime/c-compiler.mdx} +16 -9
- package/docs/{api/spawn.md → runtime/child-process.mdx} +69 -119
- package/docs/{api/color.md → runtime/color.mdx} +6 -1
- package/docs/{api/console.md → runtime/console.mdx} +17 -7
- package/docs/{api/cookie.md → runtime/cookies.mdx} +24 -19
- package/docs/runtime/{debugger.md → debugger.mdx} +61 -51
- package/docs/runtime/environment-variables.mdx +214 -0
- package/docs/{api/ffi.md → runtime/ffi.mdx} +53 -45
- package/docs/{api/file-io.md → runtime/file-io.mdx} +41 -101
- package/docs/{api/file-system-router.md → runtime/file-system-router.mdx} +8 -2
- package/docs/{bundler/loaders.md → runtime/file-types.mdx} +56 -112
- package/docs/{api/glob.md → runtime/glob.mdx} +4 -1
- package/docs/runtime/globals.mdx +72 -0
- package/docs/{api/hashing.md → runtime/hashing.mdx} +18 -22
- package/docs/{api/html-rewriter.md → runtime/html-rewriter.mdx} +36 -30
- package/docs/runtime/http/cookies.mdx +79 -0
- package/docs/runtime/http/error-handling.mdx +40 -0
- package/docs/runtime/http/metrics.mdx +36 -0
- package/docs/runtime/http/routing.mdx +289 -0
- package/docs/runtime/http/server.mdx +647 -0
- package/docs/runtime/http/tls.mdx +101 -0
- package/docs/{api/websockets.md → runtime/http/websockets.mdx} +62 -231
- package/docs/{cli/run.md → runtime/index.mdx} +70 -108
- package/docs/runtime/jsx.mdx +115 -0
- package/docs/runtime/{modules.md → module-resolution.mdx} +83 -61
- package/docs/{api/dns.md → runtime/networking/dns.mdx} +23 -22
- package/docs/{api/fetch.md → runtime/networking/fetch.mdx} +10 -5
- package/docs/{api/tcp.md → runtime/networking/tcp.mdx} +59 -41
- package/docs/{api/udp.md → runtime/networking/udp.mdx} +14 -8
- package/docs/{api/node-api.md → runtime/node-api.mdx} +5 -0
- package/docs/runtime/{nodejs-apis.md → nodejs-compat.mdx} +9 -4
- package/docs/{bundler/plugins.md → runtime/plugins.mdx} +17 -61
- package/docs/{api/redis.md → runtime/redis.mdx} +65 -80
- package/docs/{api/s3.md → runtime/s3.mdx} +79 -66
- package/docs/{api/secrets.md → runtime/secrets.mdx} +27 -10
- package/docs/{api/semver.md → runtime/semver.mdx} +9 -4
- package/docs/runtime/{shell.md → shell.mdx} +52 -20
- package/docs/{api/sql.md → runtime/sql.mdx} +129 -99
- package/docs/{api/sqlite.md → runtime/sqlite.mdx} +162 -157
- package/docs/{api/streams.md → runtime/streams.mdx} +33 -31
- package/docs/{cli/bun-create.md → runtime/templating/create.mdx} +74 -143
- package/docs/{cli/init.md → runtime/templating/init.mdx} +24 -51
- package/docs/{api/transpiler.md → runtime/transpiler.mdx} +50 -38
- package/docs/{typescript.md → runtime/typescript.mdx} +7 -2
- package/docs/{api/utils.md → runtime/utils.mdx} +81 -50
- package/docs/runtime/{hot.md → watch-mode.mdx} +53 -37
- package/docs/runtime/web-apis.mdx +29 -0
- package/docs/{api/workers.md → runtime/workers.mdx} +28 -22
- package/docs/{api/yaml.md → runtime/yaml.mdx} +33 -232
- package/docs/snippets/cli/add.mdx +166 -0
- package/docs/snippets/cli/build.mdx +196 -0
- package/docs/snippets/cli/feedback.mdx +17 -0
- package/docs/snippets/cli/init.mdx +84 -0
- package/docs/snippets/cli/install.mdx +173 -0
- package/docs/snippets/cli/link.mdx +163 -0
- package/docs/snippets/cli/outdated.mdx +140 -0
- package/docs/snippets/cli/patch.mdx +171 -0
- package/docs/snippets/cli/publish.mdx +198 -0
- package/docs/snippets/cli/remove.mdx +146 -0
- package/docs/snippets/cli/run.mdx +293 -0
- package/docs/snippets/cli/test.mdx +100 -0
- package/docs/snippets/cli/update.mdx +144 -0
- package/docs/snippets/product-card.mdx +32 -0
- package/docs/snippets/product-tiles.mdx +94 -0
- package/docs/test/code-coverage.mdx +409 -0
- package/docs/test/configuration.mdx +467 -0
- package/docs/test/{time.md → dates-times.mdx} +23 -20
- package/docs/test/{discovery.md → discovery.mdx} +15 -10
- package/docs/test/dom.mdx +226 -0
- package/docs/{cli/test.md → test/index.mdx} +77 -94
- package/docs/test/lifecycle.mdx +348 -0
- package/docs/test/mocks.mdx +637 -0
- package/docs/test/{reporters.md → reporters.mdx} +15 -15
- package/docs/test/runtime-behavior.mdx +342 -0
- package/docs/test/snapshots.mdx +434 -0
- package/docs/test/writing-tests.mdx +635 -0
- package/docs/typescript.mdx +54 -0
- package/package.json +8 -6
- package/test.d.ts +2 -2
- package/docs/api/file.md +0 -19
- package/docs/api/globals.md +0 -387
- package/docs/api/http.md +0 -1408
- package/docs/api/import-meta.md +0 -69
- package/docs/benchmarks.md +0 -120
- package/docs/bun-flavored-toml.md +0 -42
- package/docs/bundler/css_modules.md +0 -145
- package/docs/bundler/fullstack.md +0 -418
- package/docs/bundler/index.md +0 -1735
- package/docs/bundler/intro.md +0 -75
- package/docs/bundler/vs-esbuild.md +0 -1127
- package/docs/cli/bun-completions.md +0 -3
- package/docs/cli/bun-install.md +0 -349
- package/docs/cli/bun-upgrade.md +0 -39
- package/docs/cli/info.md +0 -65
- package/docs/cli/patch-commit.md +0 -11
- package/docs/cli/remove.md +0 -7
- package/docs/cli/unlink.md +0 -9
- package/docs/contributing/upgrading-webkit.md +0 -57
- package/docs/ecosystem/elysia.md +0 -24
- package/docs/ecosystem/express.md +0 -37
- package/docs/ecosystem/hono.md +0 -18
- package/docs/ecosystem/react.md +0 -65
- package/docs/ecosystem/stric.md +0 -38
- package/docs/guides/ecosystem/prisma.md +0 -141
- package/docs/guides/ecosystem/render.md +0 -79
- package/docs/guides/install/add-git.md +0 -36
- package/docs/guides/test/spy-on.md +0 -46
- package/docs/install/index.md +0 -248
- package/docs/installation.md +0 -327
- package/docs/project/asan.md +0 -124
- package/docs/project/internals/build-process-for-ci.md +0 -75
- package/docs/project/licensing.md +0 -73
- package/docs/project/roadmap.md +0 -87
- package/docs/quickstart.md +0 -157
- package/docs/runtime/bun-apis.md +0 -207
- package/docs/runtime/env.md +0 -253
- package/docs/runtime/index.md +0 -312
- package/docs/runtime/jsx.md +0 -385
- package/docs/runtime/loaders.md +0 -130
- package/docs/runtime/plugins.md +0 -561
- package/docs/runtime/typescript.md +0 -139
- package/docs/runtime/web-apis.md +0 -128
- package/docs/test/configuration.md +0 -154
- package/docs/test/coverage.md +0 -142
- package/docs/test/dom.md +0 -75
- package/docs/test/examples/concurrent-test-glob.md +0 -132
- package/docs/test/hot.md +0 -15
- package/docs/test/lifecycle.md +0 -81
- package/docs/test/mocks.md +0 -313
- package/docs/test/runtime-behavior.md +0 -95
- package/docs/test/snapshots.md +0 -68
- package/docs/test/writing.md +0 -825
|
@@ -1,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
|
|
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
|
|
19
|
+
<Note>A huge thanks goes to the amazing work from the authors of LightningCSS and esbuild.</Note>
|
|
15
20
|
|
|
16
|
-
|
|
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
|
-
|
|
31
|
+
## Syntax Lowering
|
|
27
32
|
|
|
28
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
989
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1028
|
-
|
|
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>
|