mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
Compare commits
72 Commits
nektro-pat
...
nektro-pat
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb1997b394 | ||
|
|
5bdb8ec0cb | ||
|
|
4cf9b794c9 | ||
|
|
998ec54da9 | ||
|
|
0305f3d4d2 | ||
|
|
1006a4fac2 | ||
|
|
c7f7d9bb82 | ||
|
|
37bce389a0 | ||
|
|
bab583497c | ||
|
|
a83fceafc7 | ||
|
|
ef8eef3df8 | ||
|
|
69b571da41 | ||
|
|
908ab9ce30 | ||
|
|
43c46b1f77 | ||
|
|
a0c5f3dc69 | ||
|
|
5965ff18ea | ||
|
|
44f2328111 | ||
|
|
85e0a723f3 | ||
|
|
d50c5a385f | ||
|
|
bb7641b3b0 | ||
|
|
22f4dfae7c | ||
|
|
9fce97bac3 | ||
|
|
2fb3aa8991 | ||
|
|
dc25d66b00 | ||
|
|
ae29340708 | ||
|
|
123ac9dc2d | ||
|
|
48617563b5 | ||
|
|
cc393e43f2 | ||
|
|
3f0681996f | ||
|
|
e14d5593c5 | ||
|
|
7335cb747b | ||
|
|
9c8575f975 | ||
|
|
0da132ef6d | ||
|
|
0d863ba237 | ||
|
|
f31db64bd4 | ||
|
|
ddcec61f59 | ||
|
|
29051f9340 | ||
|
|
7076fbbe68 | ||
|
|
67be07fca4 | ||
|
|
25b91e5c86 | ||
|
|
3c60fcda33 | ||
|
|
8da699681e | ||
|
|
7a06dfcb89 | ||
|
|
9ed53283a4 | ||
|
|
4450d738fa | ||
|
|
7ec1aa8c95 | ||
|
|
abb1b0c4d7 | ||
|
|
274e01c737 | ||
|
|
a0c5edb15b | ||
|
|
5702b39ef1 | ||
|
|
b72ba31441 | ||
|
|
b92d2edcff | ||
|
|
a4af0aa4a8 | ||
|
|
28b950e2b0 | ||
|
|
595ad7de93 | ||
|
|
b38ba38a18 | ||
|
|
788f03454d | ||
|
|
0e23375d20 | ||
|
|
d584c86d5b | ||
|
|
0480d55a67 | ||
|
|
9189fc4fa1 | ||
|
|
b554626662 | ||
|
|
0054506538 | ||
|
|
1b36d35253 | ||
|
|
9a9473d4b9 | ||
|
|
2d954995cd | ||
|
|
11b20aa508 | ||
|
|
cac8e62635 | ||
|
|
f03957474e | ||
|
|
ab80bbe4c2 | ||
|
|
af498a0483 | ||
|
|
7c485177ee |
19
.aikido
Normal file
19
.aikido
Normal file
@@ -0,0 +1,19 @@
|
||||
exclude:
|
||||
paths:
|
||||
- test
|
||||
- scripts
|
||||
- bench
|
||||
- packages/bun-lambda
|
||||
- packages/bun-release
|
||||
- packages/bun-wasm
|
||||
- packages/bun-vscode
|
||||
- packages/bun-plugin-yaml
|
||||
- packages/bun-plugin-svelte
|
||||
- packages/bun-native-plugin-rs
|
||||
- packages/bun-native-bundler-plugin-api
|
||||
- packages/bun-inspector-protocol
|
||||
- packages/bun-inspector-frontend
|
||||
- packages/bun-error
|
||||
- packages/bun-debug-adapter-protocol
|
||||
- packages/bun-build-mdx-rs
|
||||
- packages/@types/bun
|
||||
@@ -31,7 +31,7 @@ import {
|
||||
} from "../scripts/utils.mjs";
|
||||
|
||||
/**
|
||||
* @typedef {"linux" | "darwin" | "windows"} Os
|
||||
* @typedef {"linux" | "darwin" | "windows" | "freebsd"} Os
|
||||
* @typedef {"aarch64" | "x64"} Arch
|
||||
* @typedef {"musl"} Abi
|
||||
* @typedef {"debian" | "ubuntu" | "alpine" | "amazonlinux"} Distro
|
||||
@@ -114,6 +114,7 @@ const buildPlatforms = [
|
||||
{ os: "linux", arch: "x64", abi: "musl", baseline: true, distro: "alpine", release: "3.22" },
|
||||
{ os: "windows", arch: "x64", release: "2019" },
|
||||
{ os: "windows", arch: "x64", baseline: true, release: "2019" },
|
||||
{ os: "freebsd", arch: "x64", release: "14.3" },
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -124,10 +125,10 @@ const testPlatforms = [
|
||||
{ os: "darwin", arch: "aarch64", release: "13", tier: "previous" },
|
||||
{ os: "darwin", arch: "x64", release: "14", tier: "latest" },
|
||||
{ os: "darwin", arch: "x64", release: "13", tier: "previous" },
|
||||
{ os: "linux", arch: "aarch64", distro: "debian", release: "12", tier: "latest" },
|
||||
{ os: "linux", arch: "x64", distro: "debian", release: "12", tier: "latest" },
|
||||
{ os: "linux", arch: "x64", baseline: true, distro: "debian", release: "12", tier: "latest" },
|
||||
{ os: "linux", arch: "x64", profile: "asan", distro: "debian", release: "12", tier: "latest" },
|
||||
{ os: "linux", arch: "aarch64", distro: "debian", release: "13", tier: "latest" },
|
||||
{ os: "linux", arch: "x64", distro: "debian", release: "13", tier: "latest" },
|
||||
{ os: "linux", arch: "x64", baseline: true, distro: "debian", release: "13", tier: "latest" },
|
||||
{ os: "linux", arch: "x64", profile: "asan", distro: "debian", release: "13", tier: "latest" },
|
||||
{ os: "linux", arch: "aarch64", distro: "ubuntu", release: "25.04", tier: "latest" },
|
||||
{ os: "linux", arch: "aarch64", distro: "ubuntu", release: "24.04", tier: "latest" },
|
||||
{ os: "linux", arch: "x64", distro: "ubuntu", release: "25.04", tier: "latest" },
|
||||
@@ -659,7 +660,7 @@ function getReleaseStep(buildPlatforms, options) {
|
||||
agents: {
|
||||
queue: "test-darwin",
|
||||
},
|
||||
depends_on: buildPlatforms.map(platform => `${getTargetKey(platform)}-build-bun`),
|
||||
depends_on: buildPlatforms.filter(p => p.os !== "freebsd").map(platform => `${getTargetKey(platform)}-build-bun`),
|
||||
env: {
|
||||
CANARY: revision,
|
||||
},
|
||||
@@ -1072,7 +1073,7 @@ async function getPipeline(options = {}) {
|
||||
const imagePlatforms = new Map(
|
||||
buildImages || publishImages
|
||||
? [...buildPlatforms, ...testPlatforms]
|
||||
.filter(({ os }) => os === "linux" || os === "windows")
|
||||
.filter(({ os }) => os !== "darwin")
|
||||
.map(platform => [getImageKey(platform), platform])
|
||||
: [],
|
||||
);
|
||||
@@ -1106,10 +1107,13 @@ async function getPipeline(options = {}) {
|
||||
const includeASAN = !isMainBranch();
|
||||
|
||||
if (!buildId) {
|
||||
const relevantBuildPlatforms = includeASAN
|
||||
let relevantBuildPlatforms = includeASAN
|
||||
? buildPlatforms
|
||||
: buildPlatforms.filter(({ profile }) => profile !== "asan");
|
||||
|
||||
// run build-image but no build-bun yet
|
||||
relevantBuildPlatforms = relevantBuildPlatforms.filter(({ os }) => os !== "freebsd");
|
||||
|
||||
steps.push(
|
||||
...relevantBuildPlatforms.map(target => {
|
||||
const imageKey = getImageKey(target);
|
||||
|
||||
66
.github/workflows/claude.yml
vendored
66
.github/workflows/claude.yml
vendored
@@ -1,66 +0,0 @@
|
||||
name: Claude Code
|
||||
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
pull_request_review_comment:
|
||||
types: [created]
|
||||
issues:
|
||||
types: [opened, assigned]
|
||||
pull_request_review:
|
||||
types: [submitted]
|
||||
|
||||
jobs:
|
||||
claude:
|
||||
if: |
|
||||
github.repository == 'oven-sh/bun' &&
|
||||
(
|
||||
(github.event_name == 'issue_comment' && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'COLLABORATOR')) ||
|
||||
(github.event_name == 'pull_request_review_comment' && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'COLLABORATOR')) ||
|
||||
(github.event_name == 'pull_request_review' && (github.event.review.author_association == 'MEMBER' || github.event.review.author_association == 'OWNER' || github.event.review.author_association == 'COLLABORATOR')) ||
|
||||
(github.event_name == 'issues' && (github.event.issue.author_association == 'MEMBER' || github.event.issue.author_association == 'OWNER' || github.event.issue.author_association == 'COLLABORATOR'))
|
||||
) &&
|
||||
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
|
||||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
|
||||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
|
||||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
|
||||
runs-on: claude
|
||||
env:
|
||||
IS_SANDBOX: 1
|
||||
container:
|
||||
image: localhost:5000/claude-bun:latest
|
||||
options: --privileged --user 1000:1000
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
working-directory: /workspace/bun
|
||||
run: |
|
||||
git config --global user.email "claude-bot@bun.sh" && \
|
||||
git config --global user.name "Claude Bot" && \
|
||||
git config --global url."git@github.com:".insteadOf "https://github.com/" && \
|
||||
git config --global url."git@github.com:".insteadOf "http://github.com/" && \
|
||||
git config --global --add safe.directory /workspace/bun && \
|
||||
git config --global push.default current && \
|
||||
git config --global pull.rebase true && \
|
||||
git config --global init.defaultBranch main && \
|
||||
git config --global core.editor "vim" && \
|
||||
git config --global color.ui auto && \
|
||||
git config --global fetch.prune true && \
|
||||
git config --global diff.colorMoved zebra && \
|
||||
git config --global merge.conflictStyle diff3 && \
|
||||
git config --global rerere.enabled true && \
|
||||
git config --global core.autocrlf input
|
||||
git fetch origin ${{ github.event.pull_request.head.sha }}
|
||||
git checkout ${{ github.event.pull_request.head.ref }}
|
||||
git reset --hard origin/${{ github.event.pull_request.head.ref }}
|
||||
- name: Run Claude Code
|
||||
id: claude
|
||||
uses: anthropics/claude-code-action@v1
|
||||
with:
|
||||
timeout_minutes: "180"
|
||||
claude_args: |
|
||||
--dangerously-skip-permissions
|
||||
--system-prompt "You are working on the Bun codebase"
|
||||
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
||||
16
.vscode/settings.json
vendored
16
.vscode/settings.json
vendored
@@ -27,18 +27,22 @@
|
||||
"git.ignoreLimitWarning": true,
|
||||
|
||||
// Zig
|
||||
"zig.initialSetupDone": true,
|
||||
"zig.buildOption": "build",
|
||||
// "zig.initialSetupDone": true,
|
||||
// "zig.buildOption": "build",
|
||||
"zig.zls.zigLibPath": "${workspaceFolder}/vendor/zig/lib",
|
||||
"zig.buildArgs": ["-Dgenerated-code=./build/debug/codegen", "--watch", "-fincremental"],
|
||||
"zig.zls.buildOnSaveStep": "check",
|
||||
"zig.buildOnSaveArgs": [
|
||||
"-Dgenerated-code=./build/debug/codegen",
|
||||
"--watch",
|
||||
"-fincremental"
|
||||
],
|
||||
// "zig.zls.buildOnSaveStep": "check",
|
||||
// "zig.zls.enableBuildOnSave": true,
|
||||
// "zig.buildOnSave": true,
|
||||
"zig.buildFilePath": "${workspaceFolder}/build.zig",
|
||||
// "zig.buildFilePath": "${workspaceFolder}/build.zig",
|
||||
"zig.path": "${workspaceFolder}/vendor/zig/zig.exe",
|
||||
"zig.zls.path": "${workspaceFolder}/vendor/zig/zls.exe",
|
||||
"zig.formattingProvider": "zls",
|
||||
"zig.zls.enableInlayHints": false,
|
||||
// "zig.zls.enableInlayHints": false,
|
||||
"[zig]": {
|
||||
"editor.tabSize": 4,
|
||||
"editor.useTabStops": false,
|
||||
|
||||
@@ -54,7 +54,7 @@ Bun supports Linux (x64 & arm64), macOS (x64 & Apple Silicon) and Windows (x64).
|
||||
curl -fsSL https://bun.com/install | bash
|
||||
|
||||
# on windows
|
||||
powershell -c "irm bun.com/install.ps1 | iex"
|
||||
powershell -c "irm bun.sh/install.ps1 | iex"
|
||||
|
||||
# with npm
|
||||
npm install -g bun
|
||||
@@ -104,13 +104,13 @@ bun upgrade --canary
|
||||
- [File types (Loaders)](https://bun.com/docs/runtime/loaders)
|
||||
- [TypeScript](https://bun.com/docs/runtime/typescript)
|
||||
- [JSX](https://bun.com/docs/runtime/jsx)
|
||||
- [Environment variables](https://bun.com/docs/runtime/env)
|
||||
- [Environment variables](https://bun.com/docs/runtime/environment-variables)
|
||||
- [Bun APIs](https://bun.com/docs/runtime/bun-apis)
|
||||
- [Web APIs](https://bun.com/docs/runtime/web-apis)
|
||||
- [Node.js compatibility](https://bun.com/docs/runtime/nodejs-apis)
|
||||
- [Node.js compatibility](https://bun.com/docs/runtime/nodejs-compat)
|
||||
- [Single-file executable](https://bun.com/docs/bundler/executables)
|
||||
- [Plugins](https://bun.com/docs/runtime/plugins)
|
||||
- [Watch mode / Hot Reloading](https://bun.com/docs/runtime/hot)
|
||||
- [Watch mode / Hot Reloading](https://bun.com/docs/runtime/watch-mode)
|
||||
- [Module resolution](https://bun.com/docs/runtime/modules)
|
||||
- [Auto-install](https://bun.com/docs/runtime/autoimport)
|
||||
- [bunfig.toml](https://bun.com/docs/runtime/bunfig)
|
||||
|
||||
@@ -13,7 +13,4 @@ export function run(opts = {}) {
|
||||
}
|
||||
|
||||
export const bench = Mitata.bench;
|
||||
|
||||
export function group(_name, fn) {
|
||||
return Mitata.group(fn);
|
||||
}
|
||||
export const group = Mitata.group;
|
||||
|
||||
156
bench/snippets/compression-streams.mjs
Normal file
156
bench/snippets/compression-streams.mjs
Normal file
@@ -0,0 +1,156 @@
|
||||
import { bench, group, run } from "../runner.mjs";
|
||||
|
||||
const runAll = !process.argv.includes("--simple");
|
||||
|
||||
const small = new Uint8Array(1024);
|
||||
const medium = new Uint8Array(1024 * 100);
|
||||
const large = new Uint8Array(1024 * 1024);
|
||||
|
||||
for (let i = 0; i < large.length; i++) {
|
||||
const value = Math.floor(Math.sin(i / 100) * 128 + 128);
|
||||
if (i < small.length) small[i] = value;
|
||||
if (i < medium.length) medium[i] = value;
|
||||
large[i] = value;
|
||||
}
|
||||
|
||||
const format = new Intl.NumberFormat("en-US", { notation: "compact", unit: "byte" });
|
||||
|
||||
async function compress(data, format) {
|
||||
const cs = new CompressionStream(format);
|
||||
const writer = cs.writable.getWriter();
|
||||
const reader = cs.readable.getReader();
|
||||
|
||||
writer.write(data);
|
||||
writer.close();
|
||||
|
||||
const chunks = [];
|
||||
while (true) {
|
||||
const { done, value } = await reader.read();
|
||||
if (done) break;
|
||||
chunks.push(value);
|
||||
}
|
||||
|
||||
const result = new Uint8Array(chunks.reduce((acc, chunk) => acc + chunk.length, 0));
|
||||
let offset = 0;
|
||||
for (const chunk of chunks) {
|
||||
result.set(chunk, offset);
|
||||
offset += chunk.length;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
async function decompress(data, format) {
|
||||
const ds = new DecompressionStream(format);
|
||||
const writer = ds.writable.getWriter();
|
||||
const reader = ds.readable.getReader();
|
||||
|
||||
writer.write(data);
|
||||
writer.close();
|
||||
|
||||
const chunks = [];
|
||||
while (true) {
|
||||
const { done, value } = await reader.read();
|
||||
if (done) break;
|
||||
chunks.push(value);
|
||||
}
|
||||
|
||||
const result = new Uint8Array(chunks.reduce((acc, chunk) => acc + chunk.length, 0));
|
||||
let offset = 0;
|
||||
for (const chunk of chunks) {
|
||||
result.set(chunk, offset);
|
||||
offset += chunk.length;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
async function roundTrip(data, format) {
|
||||
const compressed = await compress(data, format);
|
||||
return await decompress(compressed, format);
|
||||
}
|
||||
|
||||
const formats = ["deflate", "gzip", "deflate-raw"];
|
||||
if (runAll) formats.push("brotli", "zstd");
|
||||
|
||||
// Small data benchmarks (1KB)
|
||||
group(`CompressionStream ${format.format(small.length)}`, () => {
|
||||
for (const fmt of formats) {
|
||||
try {
|
||||
new CompressionStream(fmt);
|
||||
bench(fmt, async () => await compress(small, fmt));
|
||||
} catch (e) {
|
||||
// Skip unsupported formats
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Medium data benchmarks (100KB)
|
||||
group(`CompressionStream ${format.format(medium.length)}`, () => {
|
||||
for (const fmt of formats) {
|
||||
try {
|
||||
new CompressionStream(fmt);
|
||||
bench(fmt, async () => await compress(medium, fmt));
|
||||
} catch (e) {}
|
||||
}
|
||||
});
|
||||
|
||||
// Large data benchmarks (1MB)
|
||||
group(`CompressionStream ${format.format(large.length)}`, () => {
|
||||
for (const fmt of formats) {
|
||||
try {
|
||||
new CompressionStream(fmt);
|
||||
bench(fmt, async () => await compress(large, fmt));
|
||||
} catch (e) {
|
||||
// Skip unsupported formats
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const compressedData = {};
|
||||
for (const fmt of formats) {
|
||||
try {
|
||||
compressedData[fmt] = {
|
||||
small: await compress(small, fmt),
|
||||
medium: await compress(medium, fmt),
|
||||
large: await compress(large, fmt),
|
||||
};
|
||||
} catch (e) {
|
||||
// Skip unsupported formats
|
||||
}
|
||||
}
|
||||
|
||||
group(`DecompressionStream ${format.format(small.length)}`, () => {
|
||||
for (const fmt of formats) {
|
||||
if (compressedData[fmt]) {
|
||||
bench(fmt, async () => await decompress(compressedData[fmt].small, fmt));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
group(`DecompressionStream ${format.format(medium.length)}`, () => {
|
||||
for (const fmt of formats) {
|
||||
if (compressedData[fmt]) {
|
||||
bench(fmt, async () => await decompress(compressedData[fmt].medium, fmt));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
group(`DecompressionStream ${format.format(large.length)}`, () => {
|
||||
for (const fmt of formats) {
|
||||
if (compressedData[fmt]) {
|
||||
bench(fmt, async () => await decompress(compressedData[fmt].large, fmt));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
group(`roundtrip ${format.format(large.length)}`, () => {
|
||||
for (const fmt of formats) {
|
||||
try {
|
||||
new CompressionStream(fmt);
|
||||
bench(fmt, async () => await roundTrip(large, fmt));
|
||||
} catch (e) {
|
||||
// Skip unsupported formats
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
await run();
|
||||
48
bench/snippets/urlpattern.js
Normal file
48
bench/snippets/urlpattern.js
Normal file
@@ -0,0 +1,48 @@
|
||||
import { bench, group, run } from "../runner.mjs";
|
||||
|
||||
const patterns = [
|
||||
{ name: "string pattern", input: "https://(sub.)?example(.com/)foo" },
|
||||
{ name: "hostname IDN", input: { hostname: "xn--caf-dma.com" } },
|
||||
{
|
||||
name: "pathname + search + hash + baseURL",
|
||||
input: {
|
||||
pathname: "/foo",
|
||||
search: "bar",
|
||||
hash: "baz",
|
||||
baseURL: "https://example.com:8080",
|
||||
},
|
||||
},
|
||||
{ name: "pathname with regex", input: { pathname: "/([[a-z]--a])" } },
|
||||
{ name: "named groups", input: { pathname: "/users/:id/posts/:postId" } },
|
||||
{ name: "wildcard", input: { pathname: "/files/*" } },
|
||||
];
|
||||
|
||||
const testURL = "https://sub.example.com/foo";
|
||||
|
||||
group("URLPattern parse (constructor)", () => {
|
||||
for (const { name, input } of patterns) {
|
||||
bench(name, () => {
|
||||
return new URLPattern(input);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
group("URLPattern.test()", () => {
|
||||
for (const { name, input } of patterns) {
|
||||
const pattern = new URLPattern(input);
|
||||
bench(name, () => {
|
||||
return pattern.test(testURL);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
group("URLPattern.exec()", () => {
|
||||
for (const { name, input } of patterns) {
|
||||
const pattern = new URLPattern(input);
|
||||
bench(name, () => {
|
||||
return pattern.exec(testURL);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
await run();
|
||||
11
build.zig
11
build.zig
@@ -32,6 +32,7 @@ const BunBuildOptions = struct {
|
||||
/// enable debug logs in release builds
|
||||
enable_logs: bool = false,
|
||||
enable_asan: bool,
|
||||
enable_fuzzilli: bool,
|
||||
enable_valgrind: bool,
|
||||
use_mimalloc: bool,
|
||||
tracy_callstack_depth: u16,
|
||||
@@ -81,6 +82,7 @@ const BunBuildOptions = struct {
|
||||
opts.addOption(bool, "baseline", this.isBaseline());
|
||||
opts.addOption(bool, "enable_logs", this.enable_logs);
|
||||
opts.addOption(bool, "enable_asan", this.enable_asan);
|
||||
opts.addOption(bool, "enable_fuzzilli", this.enable_fuzzilli);
|
||||
opts.addOption(bool, "enable_valgrind", this.enable_valgrind);
|
||||
opts.addOption(bool, "use_mimalloc", this.use_mimalloc);
|
||||
opts.addOption([]const u8, "reported_nodejs_version", b.fmt("{f}", .{this.reported_nodejs_version}));
|
||||
@@ -255,6 +257,7 @@ pub fn build(b: *Build) !void {
|
||||
.tracy_callstack_depth = b.option(u16, "tracy_callstack_depth", "") orelse 10,
|
||||
.enable_logs = b.option(bool, "enable_logs", "Enable logs in release") orelse false,
|
||||
.enable_asan = b.option(bool, "enable_asan", "Enable asan") orelse false,
|
||||
.enable_fuzzilli = b.option(bool, "enable_fuzzilli", "Enable fuzzilli instrumentation") orelse false,
|
||||
.enable_valgrind = b.option(bool, "enable_valgrind", "Enable valgrind") orelse false,
|
||||
.use_mimalloc = b.option(bool, "use_mimalloc", "Use mimalloc as default allocator") orelse false,
|
||||
.llvm_codegen_threads = b.option(u32, "llvm_codegen_threads", "Number of threads to use for LLVM codegen") orelse 1,
|
||||
@@ -490,6 +493,7 @@ fn addMultiCheck(
|
||||
.no_llvm = root_build_options.no_llvm,
|
||||
.enable_asan = root_build_options.enable_asan,
|
||||
.enable_valgrind = root_build_options.enable_valgrind,
|
||||
.enable_fuzzilli = root_build_options.enable_fuzzilli,
|
||||
.use_mimalloc = root_build_options.use_mimalloc,
|
||||
.override_no_export_cpp_apis = root_build_options.override_no_export_cpp_apis,
|
||||
};
|
||||
@@ -605,13 +609,20 @@ fn configureObj(b: *Build, opts: *BunBuildOptions, obj: *Compile) void {
|
||||
|
||||
obj.no_link_obj = opts.os != .windows;
|
||||
|
||||
|
||||
if (opts.enable_asan and !enableFastBuild(b)) {
|
||||
if (@hasField(Build.Module, "sanitize_address")) {
|
||||
if (opts.enable_fuzzilli) {
|
||||
obj.sanitize_coverage_trace_pc_guard = true;
|
||||
}
|
||||
obj.root_module.sanitize_address = true;
|
||||
} else {
|
||||
const fail_step = b.addFail("asan is not supported on this platform");
|
||||
obj.step.dependOn(&fail_step.step);
|
||||
}
|
||||
} else if (opts.enable_fuzzilli) {
|
||||
const fail_step = b.addFail("fuzzilli requires asan");
|
||||
obj.step.dependOn(&fail_step.step);
|
||||
}
|
||||
obj.bundle_compiler_rt = false;
|
||||
obj.bundle_ubsan_rt = false;
|
||||
|
||||
42
bun.lock
42
bun.lock
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"lockfileVersion": 1,
|
||||
"configVersion": 0,
|
||||
"configVersion": 1,
|
||||
"workspaces": {
|
||||
"": {
|
||||
"name": "bun",
|
||||
@@ -85,13 +85,13 @@
|
||||
|
||||
"@esbuild/win32-x64": ["@esbuild/win32-x64@0.21.5", "", { "os": "win32", "cpu": "x64" }, "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw=="],
|
||||
|
||||
"@lezer/common": ["@lezer/common@1.2.3", "", {}, "sha512-w7ojc8ejBqr2REPsWxJjrMFsA/ysDCFICn8zEOR9mrqzOu2amhITYuLD8ag6XZf0CFXDrhKqw7+tW8cX66NaDA=="],
|
||||
"@lezer/common": ["@lezer/common@1.3.0", "", {}, "sha512-L9X8uHCYU310o99L3/MpJKYxPzXPOS7S0NmBaM7UO/x2Kb2WbmMLSkfvdr1KxRIFYOpbY0Jhn7CfLSUDzL8arQ=="],
|
||||
|
||||
"@lezer/cpp": ["@lezer/cpp@1.1.3", "", { "dependencies": { "@lezer/common": "^1.2.0", "@lezer/highlight": "^1.0.0", "@lezer/lr": "^1.0.0" } }, "sha512-ykYvuFQKGsRi6IcE+/hCSGUhb/I4WPjd3ELhEblm2wS2cOznDFzO+ubK2c+ioysOnlZ3EduV+MVQFCPzAIoY3w=="],
|
||||
|
||||
"@lezer/highlight": ["@lezer/highlight@1.2.1", "", { "dependencies": { "@lezer/common": "^1.0.0" } }, "sha512-Z5duk4RN/3zuVO7Jq0pGLJ3qynpxUVsh7IbUbGj88+uV2ApSAn6kWg2au3iJb+0Zi7kKtqffIESgNcRXWZWmSA=="],
|
||||
"@lezer/highlight": ["@lezer/highlight@1.2.3", "", { "dependencies": { "@lezer/common": "^1.3.0" } }, "sha512-qXdH7UqTvGfdVBINrgKhDsVTJTxactNNxLk7+UMwZhU13lMHaOBlJe9Vqp907ya56Y3+ed2tlqzys7jDkTmW0g=="],
|
||||
|
||||
"@lezer/lr": ["@lezer/lr@1.4.2", "", { "dependencies": { "@lezer/common": "^1.0.0" } }, "sha512-pu0K1jCIdnQ12aWNaAVU5bzi7Bd1w54J3ECgANPmYLtQKP0HBj2cE/5coBD66MT10xbtIuUr7tg0Shbsvk0mDA=="],
|
||||
"@lezer/lr": ["@lezer/lr@1.4.3", "", { "dependencies": { "@lezer/common": "^1.0.0" } }, "sha512-yenN5SqAxAPv/qMnpWW0AT7l+SxVrgG+u0tNsRQWqbrz66HIl8DnEbBObvy21J5K7+I1v7gsAnlE2VQ5yYVSeA=="],
|
||||
|
||||
"@octokit/app": ["@octokit/app@14.1.0", "", { "dependencies": { "@octokit/auth-app": "^6.0.0", "@octokit/auth-unauthenticated": "^5.0.0", "@octokit/core": "^5.0.0", "@octokit/oauth-app": "^6.0.0", "@octokit/plugin-paginate-rest": "^9.0.0", "@octokit/types": "^12.0.0", "@octokit/webhooks": "^12.0.4" } }, "sha512-g3uEsGOQCBl1+W1rgfwoRFUIR6PtvB2T1E4RpygeUU5LrLvlOqcxrt5lfykIeRpUPpupreGJUYl70fqMDXdTpw=="],
|
||||
|
||||
@@ -145,7 +145,7 @@
|
||||
|
||||
"@sentry/types": ["@sentry/types@7.120.4", "", {}, "sha512-cUq2hSSe6/qrU6oZsEP4InMI5VVdD86aypE+ENrQ6eZEVLTCYm1w6XhW1NvIu3UuWh7gZec4a9J7AFpYxki88Q=="],
|
||||
|
||||
"@types/aws-lambda": ["@types/aws-lambda@8.10.152", "", {}, "sha512-soT/c2gYBnT5ygwiHPmd9a1bftj462NWVk2tKCc1PYHSIacB2UwbTS2zYG4jzag1mRDuzg/OjtxQjQ2NKRB6Rw=="],
|
||||
"@types/aws-lambda": ["@types/aws-lambda@8.10.159", "", {}, "sha512-SAP22WSGNN12OQ8PlCzGzRCZ7QDCwI85dQZbmpz7+mAk+L7j+wI7qnvmdKh+o7A5LaOp6QnOZ2NJphAZQTTHQg=="],
|
||||
|
||||
"@types/btoa-lite": ["@types/btoa-lite@1.0.2", "", {}, "sha512-ZYbcE2x7yrvNFJiU7xJGrpF/ihpkM7zKgw8bha3LNJSesvTtUNxbpzaT7WXBIryf6jovisrxTBvymxMeLLj1Mg=="],
|
||||
|
||||
@@ -155,7 +155,7 @@
|
||||
|
||||
"@types/ms": ["@types/ms@2.1.0", "", {}, "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA=="],
|
||||
|
||||
"@types/node": ["@types/node@24.2.1", "", { "dependencies": { "undici-types": "~7.10.0" } }, "sha512-DRh5K+ka5eJic8CjH7td8QpYEV6Zo10gfRkjHCO3weqZHWDtAaSTFtl4+VMqOJ4N5jcuhZ9/l+yy8rVgw7BQeQ=="],
|
||||
"@types/node": ["@types/node@24.10.1", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ=="],
|
||||
|
||||
"aggregate-error": ["aggregate-error@3.1.0", "", { "dependencies": { "clean-stack": "^2.0.0", "indent-string": "^4.0.0" } }, "sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA=="],
|
||||
|
||||
@@ -187,7 +187,7 @@
|
||||
|
||||
"deprecation": ["deprecation@2.3.1", "", {}, "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ=="],
|
||||
|
||||
"detect-libc": ["detect-libc@2.0.4", "", {}, "sha512-3UDv+G9CsCKO1WKMGw9fwq/SWJYbI0c5Y7LU1AXYoDdbhE2AHQ6N6Nb34sG8Fj7T5APy8qXDCKuuIHd1BR0tVA=="],
|
||||
"detect-libc": ["detect-libc@2.1.2", "", {}, "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ=="],
|
||||
|
||||
"dot-case": ["dot-case@3.0.4", "", { "dependencies": { "no-case": "^3.0.4", "tslib": "^2.0.3" } }, "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w=="],
|
||||
|
||||
@@ -211,27 +211,29 @@
|
||||
|
||||
"jws": ["jws@3.2.2", "", { "dependencies": { "jwa": "^1.4.1", "safe-buffer": "^5.0.1" } }, "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA=="],
|
||||
|
||||
"lightningcss": ["lightningcss@1.30.1", "", { "dependencies": { "detect-libc": "^2.0.3" }, "optionalDependencies": { "lightningcss-darwin-arm64": "1.30.1", "lightningcss-darwin-x64": "1.30.1", "lightningcss-freebsd-x64": "1.30.1", "lightningcss-linux-arm-gnueabihf": "1.30.1", "lightningcss-linux-arm64-gnu": "1.30.1", "lightningcss-linux-arm64-musl": "1.30.1", "lightningcss-linux-x64-gnu": "1.30.1", "lightningcss-linux-x64-musl": "1.30.1", "lightningcss-win32-arm64-msvc": "1.30.1", "lightningcss-win32-x64-msvc": "1.30.1" } }, "sha512-xi6IyHML+c9+Q3W0S4fCQJOym42pyurFiJUHEcEyHS0CeKzia4yZDEsLlqOFykxOdHpNy0NmvVO31vcSqAxJCg=="],
|
||||
"lightningcss": ["lightningcss@1.30.2", "", { "dependencies": { "detect-libc": "^2.0.3" }, "optionalDependencies": { "lightningcss-android-arm64": "1.30.2", "lightningcss-darwin-arm64": "1.30.2", "lightningcss-darwin-x64": "1.30.2", "lightningcss-freebsd-x64": "1.30.2", "lightningcss-linux-arm-gnueabihf": "1.30.2", "lightningcss-linux-arm64-gnu": "1.30.2", "lightningcss-linux-arm64-musl": "1.30.2", "lightningcss-linux-x64-gnu": "1.30.2", "lightningcss-linux-x64-musl": "1.30.2", "lightningcss-win32-arm64-msvc": "1.30.2", "lightningcss-win32-x64-msvc": "1.30.2" } }, "sha512-utfs7Pr5uJyyvDETitgsaqSyjCb2qNRAtuqUeWIAKztsOYdcACf2KtARYXg2pSvhkt+9NfoaNY7fxjl6nuMjIQ=="],
|
||||
|
||||
"lightningcss-darwin-arm64": ["lightningcss-darwin-arm64@1.30.1", "", { "os": "darwin", "cpu": "arm64" }, "sha512-c8JK7hyE65X1MHMN+Viq9n11RRC7hgin3HhYKhrMyaXflk5GVplZ60IxyoVtzILeKr+xAJwg6zK6sjTBJ0FKYQ=="],
|
||||
"lightningcss-android-arm64": ["lightningcss-android-arm64@1.30.2", "", { "os": "android", "cpu": "arm64" }, "sha512-BH9sEdOCahSgmkVhBLeU7Hc9DWeZ1Eb6wNS6Da8igvUwAe0sqROHddIlvU06q3WyXVEOYDZ6ykBZQnjTbmo4+A=="],
|
||||
|
||||
"lightningcss-darwin-x64": ["lightningcss-darwin-x64@1.30.1", "", { "os": "darwin", "cpu": "x64" }, "sha512-k1EvjakfumAQoTfcXUcHQZhSpLlkAuEkdMBsI/ivWw9hL+7FtilQc0Cy3hrx0AAQrVtQAbMI7YjCgYgvn37PzA=="],
|
||||
"lightningcss-darwin-arm64": ["lightningcss-darwin-arm64@1.30.2", "", { "os": "darwin", "cpu": "arm64" }, "sha512-ylTcDJBN3Hp21TdhRT5zBOIi73P6/W0qwvlFEk22fkdXchtNTOU4Qc37SkzV+EKYxLouZ6M4LG9NfZ1qkhhBWA=="],
|
||||
|
||||
"lightningcss-freebsd-x64": ["lightningcss-freebsd-x64@1.30.1", "", { "os": "freebsd", "cpu": "x64" }, "sha512-kmW6UGCGg2PcyUE59K5r0kWfKPAVy4SltVeut+umLCFoJ53RdCUWxcRDzO1eTaxf/7Q2H7LTquFHPL5R+Gjyig=="],
|
||||
"lightningcss-darwin-x64": ["lightningcss-darwin-x64@1.30.2", "", { "os": "darwin", "cpu": "x64" }, "sha512-oBZgKchomuDYxr7ilwLcyms6BCyLn0z8J0+ZZmfpjwg9fRVZIR5/GMXd7r9RH94iDhld3UmSjBM6nXWM2TfZTQ=="],
|
||||
|
||||
"lightningcss-linux-arm-gnueabihf": ["lightningcss-linux-arm-gnueabihf@1.30.1", "", { "os": "linux", "cpu": "arm" }, "sha512-MjxUShl1v8pit+6D/zSPq9S9dQ2NPFSQwGvxBCYaBYLPlCWuPh9/t1MRS8iUaR8i+a6w7aps+B4N0S1TYP/R+Q=="],
|
||||
"lightningcss-freebsd-x64": ["lightningcss-freebsd-x64@1.30.2", "", { "os": "freebsd", "cpu": "x64" }, "sha512-c2bH6xTrf4BDpK8MoGG4Bd6zAMZDAXS569UxCAGcA7IKbHNMlhGQ89eRmvpIUGfKWNVdbhSbkQaWhEoMGmGslA=="],
|
||||
|
||||
"lightningcss-linux-arm64-gnu": ["lightningcss-linux-arm64-gnu@1.30.1", "", { "os": "linux", "cpu": "arm64" }, "sha512-gB72maP8rmrKsnKYy8XUuXi/4OctJiuQjcuqWNlJQ6jZiWqtPvqFziskH3hnajfvKB27ynbVCucKSm2rkQp4Bw=="],
|
||||
"lightningcss-linux-arm-gnueabihf": ["lightningcss-linux-arm-gnueabihf@1.30.2", "", { "os": "linux", "cpu": "arm" }, "sha512-eVdpxh4wYcm0PofJIZVuYuLiqBIakQ9uFZmipf6LF/HRj5Bgm0eb3qL/mr1smyXIS1twwOxNWndd8z0E374hiA=="],
|
||||
|
||||
"lightningcss-linux-arm64-musl": ["lightningcss-linux-arm64-musl@1.30.1", "", { "os": "linux", "cpu": "arm64" }, "sha512-jmUQVx4331m6LIX+0wUhBbmMX7TCfjF5FoOH6SD1CttzuYlGNVpA7QnrmLxrsub43ClTINfGSYyHe2HWeLl5CQ=="],
|
||||
"lightningcss-linux-arm64-gnu": ["lightningcss-linux-arm64-gnu@1.30.2", "", { "os": "linux", "cpu": "arm64" }, "sha512-UK65WJAbwIJbiBFXpxrbTNArtfuznvxAJw4Q2ZGlU8kPeDIWEX1dg3rn2veBVUylA2Ezg89ktszWbaQnxD/e3A=="],
|
||||
|
||||
"lightningcss-linux-x64-gnu": ["lightningcss-linux-x64-gnu@1.30.1", "", { "os": "linux", "cpu": "x64" }, "sha512-piWx3z4wN8J8z3+O5kO74+yr6ze/dKmPnI7vLqfSqI8bccaTGY5xiSGVIJBDd5K5BHlvVLpUB3S2YCfelyJ1bw=="],
|
||||
"lightningcss-linux-arm64-musl": ["lightningcss-linux-arm64-musl@1.30.2", "", { "os": "linux", "cpu": "arm64" }, "sha512-5Vh9dGeblpTxWHpOx8iauV02popZDsCYMPIgiuw97OJ5uaDsL86cnqSFs5LZkG3ghHoX5isLgWzMs+eD1YzrnA=="],
|
||||
|
||||
"lightningcss-linux-x64-musl": ["lightningcss-linux-x64-musl@1.30.1", "", { "os": "linux", "cpu": "x64" }, "sha512-rRomAK7eIkL+tHY0YPxbc5Dra2gXlI63HL+v1Pdi1a3sC+tJTcFrHX+E86sulgAXeI7rSzDYhPSeHHjqFhqfeQ=="],
|
||||
"lightningcss-linux-x64-gnu": ["lightningcss-linux-x64-gnu@1.30.2", "", { "os": "linux", "cpu": "x64" }, "sha512-Cfd46gdmj1vQ+lR6VRTTadNHu6ALuw2pKR9lYq4FnhvgBc4zWY1EtZcAc6EffShbb1MFrIPfLDXD6Xprbnni4w=="],
|
||||
|
||||
"lightningcss-win32-arm64-msvc": ["lightningcss-win32-arm64-msvc@1.30.1", "", { "os": "win32", "cpu": "arm64" }, "sha512-mSL4rqPi4iXq5YVqzSsJgMVFENoa4nGTT/GjO2c0Yl9OuQfPsIfncvLrEW6RbbB24WtZ3xP/2CCmI3tNkNV4oA=="],
|
||||
"lightningcss-linux-x64-musl": ["lightningcss-linux-x64-musl@1.30.2", "", { "os": "linux", "cpu": "x64" }, "sha512-XJaLUUFXb6/QG2lGIW6aIk6jKdtjtcffUT0NKvIqhSBY3hh9Ch+1LCeH80dR9q9LBjG3ewbDjnumefsLsP6aiA=="],
|
||||
|
||||
"lightningcss-win32-x64-msvc": ["lightningcss-win32-x64-msvc@1.30.1", "", { "os": "win32", "cpu": "x64" }, "sha512-PVqXh48wh4T53F/1CCu8PIPCxLzWyCnn/9T5W1Jpmdy5h9Cwd+0YQS6/LwhHXSafuc61/xg9Lv5OrCby6a++jg=="],
|
||||
"lightningcss-win32-arm64-msvc": ["lightningcss-win32-arm64-msvc@1.30.2", "", { "os": "win32", "cpu": "arm64" }, "sha512-FZn+vaj7zLv//D/192WFFVA0RgHawIcHqLX9xuWiQt7P0PtdFEVaxgF9rjM/IRYHQXNnk61/H/gb2Ei+kUQ4xQ=="],
|
||||
|
||||
"lightningcss-win32-x64-msvc": ["lightningcss-win32-x64-msvc@1.30.2", "", { "os": "win32", "cpu": "x64" }, "sha512-5g1yc73p+iAkid5phb4oVFMB45417DkRevRbt/El/gKXJk4jid+vPFF/AXbxn05Aky8PapwzZrdJShv5C0avjw=="],
|
||||
|
||||
"lodash.includes": ["lodash.includes@4.3.0", "", {}, "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w=="],
|
||||
|
||||
@@ -287,7 +289,7 @@
|
||||
|
||||
"scheduler": ["scheduler@0.23.2", "", { "dependencies": { "loose-envify": "^1.1.0" } }, "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ=="],
|
||||
|
||||
"semver": ["semver@7.7.2", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA=="],
|
||||
"semver": ["semver@7.7.3", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q=="],
|
||||
|
||||
"sentence-case": ["sentence-case@3.0.4", "", { "dependencies": { "no-case": "^3.0.4", "tslib": "^2.0.3", "upper-case-first": "^2.0.2" } }, "sha512-8LS0JInaQMCRoQ7YUytAo/xUu5W2XnQxV2HI/6uM6U7CITS1RqPElr30V6uIqyMKM9lJGRVFy5/4CuzcixNYSg=="],
|
||||
|
||||
@@ -303,7 +305,7 @@
|
||||
|
||||
"uglify-js": ["uglify-js@3.19.3", "", { "bin": { "uglifyjs": "bin/uglifyjs" } }, "sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ=="],
|
||||
|
||||
"undici-types": ["undici-types@7.10.0", "", {}, "sha512-t5Fy/nfn+14LuOc2KNYg75vZqClpAiqscVvMygNnlsHBFpSXdJaYtXMcdNLpl/Qvc3P2cB3s6lOV51nqsFq4ag=="],
|
||||
"undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
|
||||
|
||||
"universal-github-app-jwt": ["universal-github-app-jwt@1.2.0", "", { "dependencies": { "@types/jsonwebtoken": "^9.0.0", "jsonwebtoken": "^9.0.2" } }, "sha512-dncpMpnsKBk0eetwfN8D8OUHGfiDhhJ+mtsbMl+7PfW7mYjiH8LIcqRmYMtzYLgSh47HjfdBtrBwIQ/gizKR3g=="],
|
||||
|
||||
|
||||
@@ -10,4 +10,4 @@ preload = "./test/preload.ts"
|
||||
|
||||
[install]
|
||||
linker = "isolated"
|
||||
minimumReleaseAge = 1
|
||||
minimumReleaseAge = 259200 # three days
|
||||
|
||||
@@ -51,6 +51,23 @@ if(ENABLE_ASAN)
|
||||
)
|
||||
endif()
|
||||
|
||||
if(ENABLE_FUZZILLI)
|
||||
register_compiler_flags(
|
||||
DESCRIPTION "Enable coverage instrumentation for fuzzing"
|
||||
-fsanitize-coverage=trace-pc-guard
|
||||
)
|
||||
|
||||
register_linker_flags(
|
||||
DESCRIPTION "Link coverage instrumentation"
|
||||
-fsanitize-coverage=trace-pc-guard
|
||||
)
|
||||
|
||||
register_compiler_flags(
|
||||
DESCRIPTION "Enable fuzzilli-specific code"
|
||||
-DFUZZILLI_ENABLED
|
||||
)
|
||||
endif()
|
||||
|
||||
# --- Optimization level ---
|
||||
if(DEBUG)
|
||||
register_compiler_flags(
|
||||
|
||||
@@ -127,6 +127,8 @@ if (NOT ENABLE_ASAN)
|
||||
set(ENABLE_ZIG_ASAN OFF)
|
||||
endif()
|
||||
|
||||
optionx(ENABLE_FUZZILLI BOOL "If fuzzilli support should be enabled" DEFAULT OFF)
|
||||
|
||||
if(RELEASE AND LINUX AND CI AND NOT ENABLE_ASSERTIONS AND NOT ENABLE_ASAN)
|
||||
set(DEFAULT_LTO ON)
|
||||
else()
|
||||
|
||||
@@ -695,6 +695,7 @@ register_command(
|
||||
-Dcpu=${ZIG_CPU}
|
||||
-Denable_logs=$<IF:$<BOOL:${ENABLE_LOGS}>,true,false>
|
||||
-Denable_asan=$<IF:$<BOOL:${ENABLE_ZIG_ASAN}>,true,false>
|
||||
-Denable_fuzzilli=$<IF:$<BOOL:${ENABLE_FUZZILLI}>,true,false>
|
||||
-Denable_valgrind=$<IF:$<BOOL:${ENABLE_VALGRIND}>,true,false>
|
||||
-Duse_mimalloc=$<IF:$<BOOL:${USE_MIMALLOC_AS_DEFAULT_ALLOCATOR}>,true,false>
|
||||
-Dllvm_codegen_threads=${LLVM_ZIG_CODEGEN_THREADS}
|
||||
|
||||
@@ -55,13 +55,7 @@ optionx(ZIG_OBJECT_FORMAT "obj|bc" "Output file format for Zig object files" DEF
|
||||
optionx(ZIG_LOCAL_CACHE_DIR FILEPATH "The path to local the zig cache directory" DEFAULT ${CACHE_PATH}/zig/local)
|
||||
optionx(ZIG_GLOBAL_CACHE_DIR FILEPATH "The path to the global zig cache directory" DEFAULT ${CACHE_PATH}/zig/global)
|
||||
|
||||
if(CI)
|
||||
set(ZIG_COMPILER_SAFE_DEFAULT ON)
|
||||
else()
|
||||
set(ZIG_COMPILER_SAFE_DEFAULT OFF)
|
||||
endif()
|
||||
|
||||
optionx(ZIG_COMPILER_SAFE BOOL "Download a ReleaseSafe build of the Zig compiler." DEFAULT ${ZIG_COMPILER_SAFE_DEFAULT})
|
||||
optionx(ZIG_COMPILER_SAFE BOOL "Download a ReleaseSafe build of the Zig compiler." DEFAULT ${CI})
|
||||
|
||||
setenv(ZIG_LOCAL_CACHE_DIR ${ZIG_LOCAL_CACHE_DIR})
|
||||
setenv(ZIG_GLOBAL_CACHE_DIR ${ZIG_GLOBAL_CACHE_DIR})
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM debian:bookworm-slim AS build
|
||||
FROM debian:trixie-slim AS build
|
||||
|
||||
# https://github.com/oven-sh/bun/releases
|
||||
ARG BUN_VERSION=latest
|
||||
@@ -55,7 +55,7 @@ RUN apt-get update -qq \
|
||||
&& which bun \
|
||||
&& bun --version
|
||||
|
||||
FROM debian:bookworm-slim
|
||||
FROM debian:trixie-slim
|
||||
|
||||
# Disable the runtime transpiler cache by default inside Docker containers.
|
||||
# On ephemeral containers, the cache is not useful
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM debian:bookworm-slim AS build
|
||||
FROM debian:trixie-slim AS build
|
||||
|
||||
# https://github.com/oven-sh/bun/releases
|
||||
ARG BUN_VERSION=latest
|
||||
@@ -56,7 +56,7 @@ RUN apt-get update -qq \
|
||||
&& rm -f "bun-linux-$build.zip" SHASUMS256.txt.asc SHASUMS256.txt \
|
||||
&& chmod +x /usr/local/bin/bun
|
||||
|
||||
FROM debian:bookworm
|
||||
FROM debian:trixie
|
||||
|
||||
COPY docker-entrypoint.sh /usr/local/bin
|
||||
COPY --from=build /usr/local/bin/bun /usr/local/bin/bun
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM debian:bookworm-slim AS build
|
||||
FROM debian:trixie-slim AS build
|
||||
|
||||
# https://github.com/oven-sh/bun/releases
|
||||
ARG BUN_VERSION=latest
|
||||
@@ -55,7 +55,7 @@ RUN apt-get update -qq \
|
||||
&& which bun \
|
||||
&& bun --version
|
||||
|
||||
FROM gcr.io/distroless/base-nossl-debian11
|
||||
FROM gcr.io/distroless/base-nossl-debian13
|
||||
|
||||
# Disable the runtime transpiler cache by default inside Docker containers.
|
||||
# On ephemeral containers, the cache is not useful
|
||||
|
||||
@@ -72,7 +72,7 @@ Bun's CSS bundler automatically converts this nested syntax into traditional fla
|
||||
|
||||
You can also nest media queries and other at-rules inside selectors, eliminating the need to repeat selector patterns:
|
||||
|
||||
```css title="styles.css" icon="file-code"
|
||||
```scss title="styles.css" icon="file-code"
|
||||
.responsive-element {
|
||||
display: block;
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ These constants are embedded directly into your compiled binary at build time, p
|
||||
|
||||
<Note>
|
||||
For comprehensive examples and advanced patterns, see the [Build-time constants
|
||||
guide](https://bun.com/guides/runtime/build-time-constants).
|
||||
guide](/guides/runtime/build-time-constants).
|
||||
</Note>
|
||||
|
||||
---
|
||||
@@ -183,6 +183,35 @@ console.log(process.execArgv); // ["--smol", "--user-agent=MyBot"]
|
||||
|
||||
---
|
||||
|
||||
## Disabling automatic config loading
|
||||
|
||||
By default, standalone executables look for `.env` and `bunfig.toml` files in the directory where the executable is run. You can disable this behavior at build time for deterministic execution regardless of the user's working directory.
|
||||
|
||||
```bash icon="terminal" terminal
|
||||
# Disable .env loading
|
||||
bun build --compile --no-compile-autoload-dotenv ./app.ts --outfile myapp
|
||||
|
||||
# Disable bunfig.toml loading
|
||||
bun build --compile --no-compile-autoload-bunfig ./app.ts --outfile myapp
|
||||
|
||||
# Disable both
|
||||
bun build --compile --no-compile-autoload-dotenv --no-compile-autoload-bunfig ./app.ts --outfile myapp
|
||||
```
|
||||
|
||||
You can also configure this via the JavaScript API:
|
||||
|
||||
```ts
|
||||
await Bun.build({
|
||||
entrypoints: ["./app.ts"],
|
||||
compile: {
|
||||
autoloadDotenv: false, // Disable .env loading
|
||||
autoloadBunfig: false, // Disable bunfig.toml loading
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Act as the Bun CLI
|
||||
|
||||
<Note>New in Bun v1.2.16</Note>
|
||||
@@ -259,12 +288,12 @@ console.log(`Server running at http://localhost:${server.port}`);
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello World</h1>
|
||||
<script src="./app.js"></script>
|
||||
<script src="./app.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
```ts app.js icon="file-code"
|
||||
```ts app.ts icon="file-code"
|
||||
console.log("Hello from the client!");
|
||||
```
|
||||
|
||||
|
||||
@@ -492,6 +492,28 @@ Bun will lazily resolve and load each plugin and use them to bundle your routes.
|
||||
the CLI.
|
||||
</Note>
|
||||
|
||||
## Inline Environment Variables
|
||||
|
||||
Bun can replace `process.env.*` references in your frontend JavaScript and TypeScript with their actual values at build time. Configure the `env` option in your `bunfig.toml`:
|
||||
|
||||
```toml title="bunfig.toml" icon="settings"
|
||||
[serve.static]
|
||||
env = "PUBLIC_*" # only inline env vars starting with PUBLIC_ (recommended)
|
||||
# env = "inline" # inline all environment variables
|
||||
# env = "disable" # disable env var replacement (default)
|
||||
```
|
||||
|
||||
<Note>
|
||||
This only works with literal `process.env.FOO` references, not `import.meta.env` or indirect access like `const env =
|
||||
process.env; env.FOO`.
|
||||
|
||||
If an environment variable is not set, you may see runtime errors like `ReferenceError: process
|
||||
is not defined` in the browser.
|
||||
|
||||
</Note>
|
||||
|
||||
See the [HTML & static sites documentation](/bundler/html-static#inline-environment-variables) for more details on build-time configuration and examples.
|
||||
|
||||
## How It Works
|
||||
|
||||
Bun uses `HTMLRewriter` to scan for `<script>` and `<link>` tags in HTML files, uses them as entrypoints for Bun's bundler, generates an optimized bundle for the JavaScript/TypeScript/TSX/JSX and CSS files, and serves the result.
|
||||
@@ -632,7 +654,7 @@ const server = serve({
|
||||
console.log(`🚀 Server running on ${server.url}`);
|
||||
```
|
||||
|
||||
```html title="public/index.html"
|
||||
```html title="public/index.html" icon="file-code"
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
@@ -757,7 +779,7 @@ export function App() {
|
||||
}
|
||||
```
|
||||
|
||||
```css title="src/styles.css"
|
||||
```css title="src/styles.css" icon="file-code"
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
@@ -999,7 +1021,7 @@ CMD ["bun", "index.js"]
|
||||
|
||||
### Environment Variables
|
||||
|
||||
```bash title=".env.production" icon="file-code"
|
||||
```ini title=".env.production" icon="file-code"
|
||||
NODE_ENV=production
|
||||
PORT=3000
|
||||
DATABASE_URL=postgresql://user:pass@localhost:5432/myapp
|
||||
|
||||
@@ -9,7 +9,7 @@ Hot Module Replacement (HMR) allows you to update modules in a running applicati
|
||||
|
||||
## `import.meta.hot` API Reference
|
||||
|
||||
Bun implements a client-side HMR API modeled after [Vite's `import.meta.hot` API](https://vitejs.dev/guide/api-hmr.html). It can be checked for with `if (import.meta.hot)`, tree-shaking it in production.
|
||||
Bun implements a client-side HMR API modeled after [Vite's `import.meta.hot` API](https://vite.dev/guide/api-hmr). It can be checked for with `if (import.meta.hot)`, tree-shaking it in production.
|
||||
|
||||
```ts title="index.ts" icon="/icons/typescript.svg"
|
||||
if (import.meta.hot) {
|
||||
@@ -144,7 +144,7 @@ Indicates that multiple dependencies' modules can be accepted. This variant acce
|
||||
|
||||
`import.meta.hot.data` maintains state between module instances during hot replacement, enabling data transfer from previous to new versions. When `import.meta.hot.data` is written into, Bun will also mark this module as capable of self-accepting (equivalent of calling `import.meta.hot.accept()`).
|
||||
|
||||
```jsx title="index.ts" icon="/icons/typescript.svg"
|
||||
```tsx title="index.tsx" icon="/icons/typescript.svg"
|
||||
import { createRoot } from "react-dom/client";
|
||||
import { App } from "./app";
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ bun ./index.html
|
||||
```
|
||||
|
||||
```
|
||||
Bun v1.3.2
|
||||
Bun v1.3.3
|
||||
ready in 6.62ms
|
||||
→ http://localhost:3000/
|
||||
Press h + Enter to show shortcuts
|
||||
@@ -51,7 +51,7 @@ bun index.html
|
||||
```
|
||||
|
||||
```
|
||||
Bun v1.3.2
|
||||
Bun v1.3.3
|
||||
ready in 6.62ms
|
||||
→ http://localhost:3000/
|
||||
Press h + Enter to show shortcuts
|
||||
@@ -81,7 +81,7 @@ bun ./index.html ./about.html
|
||||
```
|
||||
|
||||
```txt
|
||||
Bun v1.3.2
|
||||
Bun v1.3.3
|
||||
ready in 6.62ms
|
||||
→ http://localhost:3000/
|
||||
Routes:
|
||||
@@ -104,7 +104,7 @@ bun ./**/*.html
|
||||
```
|
||||
|
||||
```
|
||||
Bun v1.3.2
|
||||
Bun v1.3.3
|
||||
ready in 6.62ms
|
||||
→ http://localhost:3000/
|
||||
Routes:
|
||||
@@ -122,7 +122,7 @@ bun ./index.html ./about/index.html ./about/foo/index.html
|
||||
```
|
||||
|
||||
```
|
||||
Bun v1.3.2
|
||||
Bun v1.3.3
|
||||
ready in 6.62ms
|
||||
→ http://localhost:3000/
|
||||
Routes:
|
||||
@@ -164,7 +164,7 @@ For example:
|
||||
}
|
||||
```
|
||||
|
||||
```css abc.css
|
||||
```css abc.css icon="file-code"
|
||||
body {
|
||||
background-color: red;
|
||||
}
|
||||
@@ -174,7 +174,7 @@ body {
|
||||
|
||||
This outputs:
|
||||
|
||||
```css
|
||||
```css styles.css icon="file-code"
|
||||
body {
|
||||
background-color: red;
|
||||
}
|
||||
@@ -262,6 +262,93 @@ Then, reference TailwindCSS in your HTML via `<link>` tag, `@import` in CSS, or
|
||||
|
||||
<Info>Only one of those are necessary, not all three.</Info>
|
||||
|
||||
## Inline environment variables
|
||||
|
||||
Bun can replace `process.env.*` references in your JavaScript and TypeScript with their actual values at build time. This is useful for injecting configuration like API URLs or feature flags into your frontend code.
|
||||
|
||||
### Dev server (runtime)
|
||||
|
||||
To inline environment variables when using `bun ./index.html`, configure the `env` option in your `bunfig.toml`:
|
||||
|
||||
```toml title="bunfig.toml" icon="settings"
|
||||
[serve.static]
|
||||
env = "PUBLIC_*" # only inline env vars starting with PUBLIC_ (recommended)
|
||||
# env = "inline" # inline all environment variables
|
||||
# env = "disable" # disable env var replacement (default)
|
||||
```
|
||||
|
||||
<Note>
|
||||
This only works with literal `process.env.FOO` references, not `import.meta.env` or indirect access like `const env =
|
||||
process.env; env.FOO`.
|
||||
|
||||
If an environment variable is not set, you may see runtime errors like `ReferenceError: process
|
||||
is not defined` in the browser.
|
||||
|
||||
</Note>
|
||||
|
||||
Then run the dev server:
|
||||
|
||||
```bash terminal icon="terminal"
|
||||
PUBLIC_API_URL=https://api.example.com bun ./index.html
|
||||
```
|
||||
|
||||
### Build for production
|
||||
|
||||
When building static HTML for production, use the `env` option to inline environment variables:
|
||||
|
||||
<Tabs>
|
||||
<Tab title="CLI">
|
||||
```bash terminal icon="terminal"
|
||||
# Inline all environment variables
|
||||
bun build ./index.html --outdir=dist --env=inline
|
||||
|
||||
# Only inline env vars with a specific prefix (recommended)
|
||||
bun build ./index.html --outdir=dist --env=PUBLIC_*
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab title="API">
|
||||
```ts title="build.ts" icon="/icons/typescript.svg"
|
||||
// Inline all environment variables
|
||||
await Bun.build({
|
||||
entrypoints: ["./index.html"],
|
||||
outdir: "./dist",
|
||||
env: "inline", // [!code highlight]
|
||||
});
|
||||
|
||||
// Only inline env vars with a specific prefix (recommended)
|
||||
await Bun.build({
|
||||
entrypoints: ["./index.html"],
|
||||
outdir: "./dist",
|
||||
env: "PUBLIC_*", // [!code highlight]
|
||||
});
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
### Example
|
||||
|
||||
Given this source file:
|
||||
|
||||
```ts title="app.ts" icon="/icons/typescript.svg"
|
||||
const apiUrl = process.env.PUBLIC_API_URL;
|
||||
console.log(`API URL: ${apiUrl}`);
|
||||
```
|
||||
|
||||
And running with `PUBLIC_API_URL=https://api.example.com`:
|
||||
|
||||
```bash terminal icon="terminal"
|
||||
PUBLIC_API_URL=https://api.example.com bun build ./index.html --outdir=dist --env=PUBLIC_*
|
||||
```
|
||||
|
||||
The bundled output will contain:
|
||||
|
||||
```js title="dist/app.js" icon="/icons/javascript.svg"
|
||||
const apiUrl = "https://api.example.com";
|
||||
console.log(`API URL: ${apiUrl}`);
|
||||
```
|
||||
|
||||
## Echo console logs from browser to terminal
|
||||
|
||||
Bun's dev server supports streaming console logs from the browser to the terminal.
|
||||
@@ -273,7 +360,7 @@ bun ./index.html --console
|
||||
```
|
||||
|
||||
```
|
||||
Bun v1.3.2
|
||||
Bun v1.3.3
|
||||
ready in 6.62ms
|
||||
→ http://localhost:3000/
|
||||
Press h + Enter to show shortcuts
|
||||
@@ -385,7 +472,8 @@ All paths are resolved relative to your HTML file, making it easy to organize yo
|
||||
- Need more configuration options for things like asset handling
|
||||
- Need a way to configure CORS, headers, etc.
|
||||
|
||||
If you want to submit a PR, most of the code is [here](https://github.com/oven-sh/bun/blob/main/src/bun.js/api/bun/html-rewriter.ts). You could even copy paste that file into your project and use it as a starting point.
|
||||
{/* todo: find the correct link to link to as this 404's and there isn't any similar files */}
|
||||
{/* If you want to submit a PR, most of the code is [here](https://github.com/oven-sh/bun/blob/main/src/bun.js/api/bun/html-rewriter.ts). You could even copy paste that file into your project and use it as a starting point. */}
|
||||
|
||||
</Warning>
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ For each file specified in `entrypoints`, Bun will generate a new bundle. This b
|
||||
|
||||
The contents of `out/index.js` will look something like this:
|
||||
|
||||
```ts title="out/index.js" icon="/icons/javascript.svg"
|
||||
```js title="out/index.js" icon="/icons/javascript.svg"
|
||||
// out/index.js
|
||||
// ...
|
||||
// ~20k lines of code
|
||||
@@ -527,7 +527,7 @@ Injects environment variables into the bundled output by converting `process.env
|
||||
|
||||
For the input below:
|
||||
|
||||
```ts title="input.js" icon="/icons/javascript.svg"
|
||||
```js title="input.js" icon="/icons/javascript.svg"
|
||||
// input.js
|
||||
console.log(process.env.FOO);
|
||||
console.log(process.env.BAZ);
|
||||
@@ -535,7 +535,7 @@ console.log(process.env.BAZ);
|
||||
|
||||
The generated bundle will contain the following code:
|
||||
|
||||
```ts title="output.js" icon="/icons/javascript.svg"
|
||||
```js title="output.js" icon="/icons/javascript.svg"
|
||||
// output.js
|
||||
console.log("bar");
|
||||
console.log("123");
|
||||
@@ -580,7 +580,7 @@ console.log(process.env.BAZ);
|
||||
|
||||
The generated bundle will contain the following code:
|
||||
|
||||
```ts title="output.js" icon="/icons/javascript.svg"
|
||||
```js title="output.js" icon="/icons/javascript.svg"
|
||||
console.log(process.env.FOO);
|
||||
console.log("https://acme.com");
|
||||
console.log(process.env.BAZ);
|
||||
@@ -722,7 +722,7 @@ Normally, bundling `index.tsx` would generate a bundle containing the entire sou
|
||||
|
||||
The generated bundle will look something like this:
|
||||
|
||||
```ts title="out/index.js" icon="/icons/javascript.svg"
|
||||
```js title="out/index.js" icon="/icons/javascript.svg"
|
||||
import { z } from "zod";
|
||||
|
||||
// ...
|
||||
@@ -1026,7 +1026,7 @@ Setting `publicPath` will prefix all file paths with the specified value.
|
||||
|
||||
The output file would now look something like this.
|
||||
|
||||
```ts title="out/index.js" icon="/icons/javascript.svg"
|
||||
```js title="out/index.js" icon="/icons/javascript.svg"
|
||||
var logo = "https://cdn.example.com/logo-a7305bdef.svg";
|
||||
```
|
||||
|
||||
@@ -1356,10 +1356,12 @@ interface BuildConfig {
|
||||
* JSX configuration object for controlling JSX transform behavior
|
||||
*/
|
||||
jsx?: {
|
||||
runtime?: "automatic" | "classic";
|
||||
importSource?: string;
|
||||
factory?: string;
|
||||
fragment?: string;
|
||||
importSource?: string;
|
||||
runtime?: "automatic" | "classic";
|
||||
sideEffects?: boolean;
|
||||
development?: boolean;
|
||||
};
|
||||
naming?:
|
||||
| string
|
||||
@@ -1443,13 +1445,20 @@ interface BuildConfig {
|
||||
drop?: string[];
|
||||
|
||||
/**
|
||||
* When set to `true`, the returned promise rejects with an AggregateError when a build failure happens.
|
||||
* When set to `false`, the `success` property of the returned object will be `false` when a build failure happens.
|
||||
* - When set to `true`, the returned promise rejects with an AggregateError when a build failure happens.
|
||||
* - When set to `false`, returns a {@link BuildOutput} with `{success: false}`
|
||||
*
|
||||
* This defaults to `false` in Bun 1.1 and will change to `true` in Bun 1.2
|
||||
* as most usage of `Bun.build` forgets to check for errors.
|
||||
* @default true
|
||||
*/
|
||||
throw?: boolean;
|
||||
|
||||
/**
|
||||
* Custom tsconfig.json file path to use for path resolution.
|
||||
* Equivalent to `--tsconfig-override` in the CLI.
|
||||
*/
|
||||
tsconfig?: string;
|
||||
|
||||
outdir?: string;
|
||||
}
|
||||
|
||||
interface BuildOutput {
|
||||
|
||||
@@ -312,7 +312,7 @@ The `html` loader processes HTML files and bundles any referenced assets. It wil
|
||||
|
||||
For example, given this HTML file:
|
||||
|
||||
```html title="src/index.html"
|
||||
```html title="src/index.html" icon="file-code"
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
@@ -325,7 +325,7 @@ For example, given this HTML file:
|
||||
|
||||
It will output a new HTML file with the bundled assets:
|
||||
|
||||
```html title="dist/index.html"
|
||||
```html title="dist/index.html" icon="file-code"
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
|
||||
@@ -87,7 +87,7 @@ macro();
|
||||
|
||||
When shipping a library containing a macro to npm or another package registry, use the `"macro"` export condition to provide a special version of your package exclusively for the macro environment.
|
||||
|
||||
```json title="package.json" icon="file-code"
|
||||
```json title="package.json" icon="file-json"
|
||||
{
|
||||
"name": "my-package",
|
||||
"exports": {
|
||||
|
||||
@@ -456,7 +456,6 @@
|
||||
"pages": [
|
||||
"/guides/test/run-tests",
|
||||
"/guides/test/watch-mode",
|
||||
"/guides/test/concurrent-test-glob",
|
||||
"/guides/test/migrate-from-jest",
|
||||
"/guides/test/mock-functions",
|
||||
"/guides/test/spy-on",
|
||||
@@ -465,6 +464,7 @@
|
||||
"/guides/test/update-snapshots",
|
||||
"/guides/test/coverage",
|
||||
"/guides/test/coverage-threshold",
|
||||
"/guides/test/concurrent-test-glob",
|
||||
"/guides/test/skip-tests",
|
||||
"/guides/test/todo-tests",
|
||||
"/guides/test/timeout",
|
||||
|
||||
@@ -4,13 +4,9 @@ description: Share feedback, bug reports, and feature requests
|
||||
mode: center
|
||||
---
|
||||
|
||||
import Feedback from "/snippets/cli/feedback.mdx";
|
||||
|
||||
Whether you've found a bug, have a performance issue, or just want to suggest an improvement, here's how you can open a helpful issue:
|
||||
|
||||
<Callout icon="discord">
|
||||
For general questions, please join our [Discord](https://discord.com/invite/CXdq2DP29u).
|
||||
</Callout>
|
||||
<Callout icon="discord">For general questions, please join our [Discord](https://bun.com/discord).</Callout>
|
||||
|
||||
## Reporting Issues
|
||||
|
||||
@@ -56,9 +52,7 @@ Whether you've found a bug, have a performance issue, or just want to suggest an
|
||||
<Note>
|
||||
- For MacOS and Linux: copy the output of `uname -mprs`
|
||||
- For Windows: copy the output of this command in the powershell console:
|
||||
```powershell
|
||||
"$([Environment]::OSVersion | ForEach-Object VersionString) $(if ([Environment]::Is64BitOperatingSystem) { "x64" } else { "x86" })"
|
||||
```
|
||||
`"$([Environment]::OSVersion | ForEach-Object VersionString) $(if ([Environment]::Is64BitOperatingSystem) { "x64" } else { "x86" })"`
|
||||
</Note>
|
||||
</Step>
|
||||
|
||||
@@ -79,7 +73,3 @@ echo "please document X" | bun feedback --email you@example.com
|
||||
```
|
||||
|
||||
You can provide feedback as text arguments, file paths, or piped input.
|
||||
|
||||
---
|
||||
|
||||
<Feedback />
|
||||
|
||||
@@ -26,4 +26,4 @@ const regularArr = Array.from(uintArr);
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -23,4 +23,4 @@ blob.type; // => "application/octet-stream"
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -24,4 +24,4 @@ const nodeBuffer = Buffer.from(arrBuffer, 0, 16); // view first 16 bytes
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -14,4 +14,4 @@ const str = decoder.decode(buf);
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -38,4 +38,4 @@ const arr = new Uint8Array(buffer, 0, 16); // view first 16 bytes
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Utils](https://bun.com/docs/api/utils) for more useful utilities.
|
||||
See [Docs > API > Utils](/runtime/utils) for more useful utilities.
|
||||
|
||||
@@ -13,4 +13,4 @@ const buf = await blob.arrayBuffer();
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -13,4 +13,4 @@ const arr = new DataView(await blob.arrayBuffer());
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -13,4 +13,4 @@ const stream = await blob.stream();
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -14,4 +14,4 @@ const str = await blob.text();
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -13,4 +13,4 @@ const arr = new Uint8Array(await blob.arrayBuffer());
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -13,4 +13,4 @@ const arrBuf = nodeBuf.buffer;
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -13,4 +13,4 @@ const blob = new Blob([buf]);
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -40,4 +40,4 @@ const stream = blob.stream(1024);
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -24,4 +24,4 @@ const str = buf.toString("utf8", 0, 5);
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -13,4 +13,4 @@ buf instanceof Uint8Array; // => true
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -14,4 +14,4 @@ const str = decoder.decode(dv);
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -24,4 +24,4 @@ arr.byteLength; // => 32
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -15,4 +15,4 @@ console.log(await blob.text());
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -13,4 +13,4 @@ const buf = Buffer.from(arr);
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -13,4 +13,4 @@ const dv = new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -40,4 +40,4 @@ const stream = blob.stream(1024);
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -15,4 +15,4 @@ const str = decoder.decode(arr);
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
See [Docs > API > Binary Data](/runtime/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
||||
|
||||
@@ -4,8 +4,6 @@ sidebarTitle: Deploy on Vercel
|
||||
mode: center
|
||||
---
|
||||
|
||||
import { ProductCard } from "/snippets/product-card.mdx";
|
||||
|
||||
[Vercel](https://vercel.com/) is a cloud platform that lets you build, deploy, and scale your apps.
|
||||
|
||||
<Warning>
|
||||
@@ -81,7 +79,7 @@ import { ProductCard } from "/snippets/product-card.mdx";
|
||||
console.log("runtime", process.versions.bun);
|
||||
```
|
||||
```txt
|
||||
runtime 1.3.2
|
||||
runtime 1.3.3
|
||||
```
|
||||
|
||||
[See the Vercel Bun Runtime documentation for feature support →](https://vercel.com/docs/functions/runtimes/bun#feature-support)
|
||||
|
||||
@@ -22,7 +22,7 @@ bun add discord.js
|
||||
|
||||
---
|
||||
|
||||
Before we go further, we need to go to the [Discord developer portal](https://discord.com/developers/applications), login/signup, create a new _Application_, then create a new _Bot_ within that application. Follow the [official guide](https://discordjs.guide/preparations/setting-up-a-bot-application.html#creating-your-bot) for step-by-step instructions.
|
||||
Before we go further, we need to go to the [Discord developer portal](https://discord.com/developers/applications), login/signup, create a new _Application_, then create a new _Bot_ within that application. Follow the [official guide](https://discordjs.guide/legacy/preparations/app-setup#creating-your-bot) for step-by-step instructions.
|
||||
|
||||
---
|
||||
|
||||
@@ -30,7 +30,7 @@ Once complete, you'll be presented with your bot's _private key_. Let's add this
|
||||
|
||||
<Note>This is an example token that has already been invalidated.</Note>
|
||||
|
||||
```txt .env.local icon="settings"
|
||||
```ini .env.local icon="settings"
|
||||
DISCORD_TOKEN=NzkyNzE1NDU0MTk2MDg4ODQy.X-hvzA.Ovy4MCQywSkoMRRclStW4xAYK7I
|
||||
```
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ mode: center
|
||||
Express and other major Node.js HTTP libraries should work out of the box. Bun implements the [`node:http`](https://nodejs.org/api/http.html) and [`node:https`](https://nodejs.org/api/https.html) modules that these libraries rely on.
|
||||
|
||||
<Note>
|
||||
Refer to the [Runtime > Node.js APIs](https://bun.com/docs/runtime/nodejs-apis#node-http) page for more detailed
|
||||
compatibility information.
|
||||
Refer to the [Runtime > Node.js APIs](/runtime/nodejs-compat#node-http) page for more detailed compatibility
|
||||
information.
|
||||
</Note>
|
||||
|
||||
```sh terminal icon="terminal"
|
||||
|
||||
@@ -89,4 +89,4 @@ Moo!
|
||||
|
||||
---
|
||||
|
||||
This is a simple introduction to using Mongoose with TypeScript and Bun. As you build your application, refer to the official [MongoDB](https://docs.mongodb.com/) and [Mongoose](https://mongoosejs.com/docs/) sites for complete documentation.
|
||||
This is a simple introduction to using Mongoose with TypeScript and Bun. As you build your application, refer to the official [MongoDB](https://www.mongodb.com/docs) and [Mongoose](https://mongoosejs.com/docs/) sites for complete documentation.
|
||||
|
||||
@@ -20,7 +20,7 @@ bun add -D drizzle-kit
|
||||
|
||||
Create a `.env.local` file and add your [Neon Postgres connection string](https://neon.tech/docs/connect/connect-from-any-app) to it.
|
||||
|
||||
```txt .env.local icon="settings"
|
||||
```ini .env.local icon="settings"
|
||||
DATABASE_URL=postgresql://usertitle:password@ep-adj-noun-guid.us-east-1.aws.neon.tech/neondb?sslmode=require
|
||||
```
|
||||
|
||||
@@ -33,7 +33,7 @@ import { neon } from "@neondatabase/serverless";
|
||||
import { drizzle } from "drizzle-orm/neon-http";
|
||||
|
||||
// Bun automatically loads the DATABASE_URL from .env.local
|
||||
// Refer to: https://bun.com/docs/runtime/env for more information
|
||||
// Refer to: https://bun.com/docs/runtime/environment-variables for more information
|
||||
const sql = neon(process.env.DATABASE_URL!);
|
||||
|
||||
export const db = drizzle(sql);
|
||||
|
||||
@@ -21,7 +21,7 @@ bun add @neondatabase/serverless
|
||||
|
||||
Create a `.env.local` file and add your [Neon Postgres connection string](https://neon.tech/docs/connect/connect-from-any-app) to it.
|
||||
|
||||
```sh .env.local icon="settings"
|
||||
```ini .env.local icon="settings"
|
||||
DATABASE_URL=postgresql://usertitle:password@ep-adj-noun-guid.us-east-1.aws.neon.tech/neondb?sslmode=require
|
||||
```
|
||||
|
||||
@@ -33,7 +33,7 @@ Paste the following code into your project's `index.ts` file.
|
||||
import { neon } from "@neondatabase/serverless";
|
||||
|
||||
// Bun automatically loads the DATABASE_URL from .env.local
|
||||
// Refer to: https://bun.com/docs/runtime/env for more information
|
||||
// Refer to: https://bun.com/docs/runtime/environment-variables for more information
|
||||
const sql = neon(process.env.DATABASE_URL);
|
||||
|
||||
const rows = await sql`SELECT version()`;
|
||||
|
||||
@@ -14,7 +14,7 @@ bunx nuxi init my-nuxt-app
|
||||
✔ Which package manager would you like to use?
|
||||
bun
|
||||
◐ Installing dependencies...
|
||||
bun install v1.3.2 (16b4bf34)
|
||||
bun install v1.3.3 (16b4bf34)
|
||||
+ @nuxt/devtools@0.8.2
|
||||
+ nuxt@3.7.0
|
||||
785 packages installed [2.67s]
|
||||
|
||||
@@ -62,7 +62,7 @@ mode: center
|
||||
<Step title="Configure database connection">
|
||||
Set up your Postgres database URL in the `.env` file.
|
||||
|
||||
```env .env icon="settings"
|
||||
```ini .env icon="settings"
|
||||
DATABASE_URL="postgresql://username:password@localhost:5432/mydb?schema=public"
|
||||
```
|
||||
</Step>
|
||||
|
||||
@@ -161,4 +161,4 @@ mode: center
|
||||
|
||||
---
|
||||
|
||||
That's it! Now that you've set up Prisma using Bun, we recommend referring to the [official Prisma docs](https://www.prisma.io/docs/concepts/components/prisma-client) as you continue to develop your application.
|
||||
That's it! Now that you've set up Prisma using Bun, we recommend referring to the [official Prisma docs](https://www.prisma.io/docs/orm/prisma-client) as you continue to develop your application.
|
||||
|
||||
@@ -65,14 +65,14 @@ bun create qwik
|
||||
│ bun qwik add │
|
||||
│ │
|
||||
│ Relevant docs: │
|
||||
│ https://qwik.builder.io/docs/getting-started/ │
|
||||
│ https://qwik.dev/docs/getting-started/ │
|
||||
│ │
|
||||
│ Questions? Start the conversation at: │
|
||||
│ https://qwik.builder.io/chat │
|
||||
│ https://qwik.dev/chat │
|
||||
│ https://twitter.com/QwikDev │
|
||||
│ │
|
||||
│ Presentations, Podcasts and Videos: │
|
||||
│ https://qwik.builder.io/media/ │
|
||||
│ https://qwik.dev/media/ │
|
||||
│ │
|
||||
│ Next steps: │
|
||||
│ cd my-app │
|
||||
@@ -111,4 +111,4 @@ Open [http://localhost:5173](http://localhost:5173) with your browser to see the
|
||||
|
||||
---
|
||||
|
||||
Refer to the [Qwik docs](https://qwik.builder.io/docs/getting-started/) for complete documentation.
|
||||
Refer to the [Qwik docs](https://qwik.dev/docs/getting-started/) for complete documentation.
|
||||
|
||||
@@ -20,7 +20,7 @@ bun add @sentry/bun
|
||||
|
||||
Then, initialize the Sentry SDK with your Sentry DSN in your app's entry file. You can find your DSN in your Sentry project settings.
|
||||
|
||||
```js sentry.ts icon="/icons/typescript.svg"
|
||||
```ts sentry.ts icon="/icons/typescript.svg"
|
||||
import * as Sentry from "@sentry/bun";
|
||||
|
||||
// Ensure to call this before importing any other modules!
|
||||
@@ -37,7 +37,7 @@ Sentry.init({
|
||||
|
||||
You can verify that Sentry is working by capturing a test error:
|
||||
|
||||
```js sentry.ts icon="/icons/typescript.svg"
|
||||
```ts sentry.ts icon="/icons/typescript.svg"
|
||||
setTimeout(() => {
|
||||
try {
|
||||
foo();
|
||||
|
||||
@@ -88,7 +88,7 @@ To build for production, you'll need to add the right SvelteKit adapter. Current
|
||||
|
||||
Now, make the following changes to your `svelte.config.js`.
|
||||
|
||||
```ts svelte.config.js icon="file-code"
|
||||
```js svelte.config.js icon="file-code"
|
||||
import adapter from "@sveltejs/adapter-auto"; // [!code --]
|
||||
import adapter from "svelte-adapter-bun"; // [!code ++]
|
||||
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
|
||||
|
||||
@@ -98,7 +98,6 @@ To host your TanStack Start app, you can use [Nitro](https://nitro.build/) or a
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
<Note>
|
||||
You do **not** need the custom `start` script when deploying to Vercel.
|
||||
</Note>
|
||||
|
||||
@@ -34,7 +34,7 @@ mode: center
|
||||
|
||||
Set the `REDIS_URL` environment variable in your `.env` file using the Redis endpoint (not the REST URL):
|
||||
|
||||
```env .env icon="settings"
|
||||
```ini .env icon="settings"
|
||||
REDIS_URL=rediss://********@********.upstash.io:6379
|
||||
```
|
||||
|
||||
|
||||
@@ -74,4 +74,4 @@ bunx --bun vite build
|
||||
|
||||
---
|
||||
|
||||
This is a stripped down guide to get you started with Vite + Bun. For more information, see the [Vite documentation](https://vitejs.dev/guide/).
|
||||
This is a stripped down guide to get you started with Vite + Bun. For more information, see the [Vite documentation](https://vite.dev/guide/).
|
||||
|
||||
@@ -6,7 +6,7 @@ mode: center
|
||||
|
||||
## Extract links from a webpage
|
||||
|
||||
Bun's [HTMLRewriter](https://bun.com/docs/api/html-rewriter) API can be used to efficiently extract links from HTML content. It works by chaining together CSS selectors to match the elements, text, and attributes you want to process. This is a simple example of how to extract links from a webpage. You can pass `.transform` a `Response`, `Blob`, or `string`.
|
||||
Bun's [HTMLRewriter](/runtime/html-rewriter) API can be used to efficiently extract links from HTML content. It works by chaining together CSS selectors to match the elements, text, and attributes you want to process. This is a simple example of how to extract links from a webpage. You can pass `.transform` a `Response`, `Blob`, or `string`.
|
||||
|
||||
```ts extract-links.ts icon="/icons/typescript.svg"
|
||||
async function extractLinks(url: string) {
|
||||
@@ -68,4 +68,4 @@ const websiteLinks = await extractLinksFromURL("https://example.com");
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > HTMLRewriter](https://bun.com/docs/api/html-rewriter) for complete documentation on HTML transformation with Bun.
|
||||
See [Docs > API > HTMLRewriter](/runtime/html-rewriter) for complete documentation on HTML transformation with Bun.
|
||||
|
||||
@@ -6,7 +6,7 @@ mode: center
|
||||
|
||||
## Extract social share images and Open Graph tags
|
||||
|
||||
Bun's [HTMLRewriter](https://bun.com/docs/api/html-rewriter) API can be used to efficiently extract social share images and Open Graph metadata from HTML content. This is particularly useful for building link preview features, social media cards, or web scrapers. We can use HTMLRewriter to match CSS selectors to HTML elements, text, and attributes we want to process.
|
||||
Bun's [HTMLRewriter](/runtime/html-rewriter) API can be used to efficiently extract social share images and Open Graph metadata from HTML content. This is particularly useful for building link preview features, social media cards, or web scrapers. We can use HTMLRewriter to match CSS selectors to HTML elements, text, and attributes we want to process.
|
||||
|
||||
```ts extract-social-meta.ts icon="/icons/typescript.svg"
|
||||
interface SocialMetadata {
|
||||
|
||||
@@ -63,7 +63,7 @@ Our form will send a `POST` request to the `/action` endpoint with the form data
|
||||
|
||||
First we use the [`.formData()`](https://developer.mozilla.org/en-US/docs/Web/API/Request/formData) method on the incoming `Request` to asynchronously parse its contents to a `FormData` instance. Then we can use the [`.get()`](https://developer.mozilla.org/en-US/docs/Web/API/FormData/get) method to extract the value of the `name` and `profilePicture` fields. Here `name` corresponds to a `string` and `profilePicture` is a `Blob`.
|
||||
|
||||
Finally, we write the `Blob` to disk using [`Bun.write()`](https://bun.com/docs/api/file-io#writing-files-bun-write).
|
||||
Finally, we write the `Blob` to disk using [`Bun.write()`](/runtime/file-io#writing-files-bun-write).
|
||||
|
||||
{/* prettier-ignore */}
|
||||
```ts index.ts icon="/icons/typescript.svg"
|
||||
|
||||
@@ -4,7 +4,7 @@ sidebarTitle: Hot reload an HTTP server
|
||||
mode: center
|
||||
---
|
||||
|
||||
Bun supports the [`--hot`](https://bun.com/docs/runtime/hot#hot-mode) flag to run a file with hot reloading enabled. When any module or file changes, Bun re-runs the file.
|
||||
Bun supports the [`--hot`](/runtime/watch-mode#hot-mode) flag to run a file with hot reloading enabled. When any module or file changes, Bun re-runs the file.
|
||||
|
||||
```sh terminal icon="terminal"
|
||||
bun --hot run index.ts
|
||||
|
||||
@@ -9,18 +9,42 @@ In Bun, `fetch` supports sending requests through an HTTP or HTTPS proxy. This i
|
||||
```ts proxy.ts icon="/icons/typescript.svg"
|
||||
await fetch("https://example.com", {
|
||||
// The URL of the proxy server
|
||||
proxy: "https://usertitle:password@proxy.example.com:8080",
|
||||
proxy: "https://username:password@proxy.example.com:8080",
|
||||
});
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
The `proxy` option is a URL string that specifies the proxy server. It can include the username and password if the proxy requires authentication. It can be `http://` or `https://`.
|
||||
The `proxy` option can be a URL string or an object with `url` and optional `headers`. The URL can include the username and password if the proxy requires authentication. It can be `http://` or `https://`.
|
||||
|
||||
---
|
||||
|
||||
## Custom proxy headers
|
||||
|
||||
To send custom headers to the proxy server (useful for proxy authentication tokens, custom routing, etc.), use the object format:
|
||||
|
||||
```ts proxy-headers.ts icon="/icons/typescript.svg"
|
||||
await fetch("https://example.com", {
|
||||
proxy: {
|
||||
url: "https://proxy.example.com:8080",
|
||||
headers: {
|
||||
"Proxy-Authorization": "Bearer my-token",
|
||||
"X-Proxy-Region": "us-east-1",
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
The `headers` property accepts a plain object or a `Headers` instance. These headers are sent directly to the proxy server in `CONNECT` requests (for HTTPS targets) or in the proxy request (for HTTP targets).
|
||||
|
||||
If you provide a `Proxy-Authorization` header, it will override any credentials specified in the proxy URL.
|
||||
|
||||
---
|
||||
|
||||
## Environment variables
|
||||
|
||||
You can also set the `$HTTP_PROXY` or `$HTTPS_PROXY` environment variable to the proxy URL. This is useful when you want to use the same proxy for all requests.
|
||||
|
||||
```sh terminal icon="terminal"
|
||||
HTTPS_PROXY=https://usertitle:password@proxy.example.com:8080 bun run index.ts
|
||||
HTTPS_PROXY=https://username:password@proxy.example.com:8080 bun run index.ts
|
||||
```
|
||||
|
||||
@@ -6,7 +6,7 @@ mode: center
|
||||
|
||||
This starts an HTTP server listening on port `3000`. It demonstrates basic routing with a number of common responses and also handles POST data from standard forms or as JSON.
|
||||
|
||||
See [`Bun.serve`](https://bun.com/docs/api/http) for details.
|
||||
See [`Bun.serve`](/runtime/http/server) for details.
|
||||
|
||||
```ts server.ts icon="/icons/typescript.svg"
|
||||
const server = Bun.serve({
|
||||
|
||||
@@ -6,7 +6,7 @@ mode: center
|
||||
|
||||
This starts an HTTP server listening on port `3000`. It responds to all requests with a `Response` with status `200` and body `"Welcome to Bun!"`.
|
||||
|
||||
See [`Bun.serve`](https://bun.com/docs/api/http) for details.
|
||||
See [`Bun.serve`](/runtime/http/server) for details.
|
||||
|
||||
```ts server.ts icon="/icons/typescript.svg"
|
||||
const server = Bun.serve({
|
||||
|
||||
@@ -4,7 +4,7 @@ sidebarTitle: Stream file response
|
||||
mode: center
|
||||
---
|
||||
|
||||
This snippet reads a file from disk using [`Bun.file()`](https://bun.com/docs/api/file-io#reading-files-bun-file). This returns a `BunFile` instance, which can be passed directly into the `new Response` constructor.
|
||||
This snippet reads a file from disk using [`Bun.file()`](/runtime/file-io#reading-files-bun-file). This returns a `BunFile` instance, which can be passed directly into the `new Response` constructor.
|
||||
|
||||
```ts server.ts icon="/icons/typescript.svg"
|
||||
const path = "/path/to/file.txt";
|
||||
@@ -32,7 +32,7 @@ new Response(Bun.file("./img.png")).headers.get("Content-Type");
|
||||
|
||||
---
|
||||
|
||||
Putting it all together with [`Bun.serve()`](https://bun.com/docs/api/http#bun-serve).
|
||||
Putting it all together with [`Bun.serve()`](/runtime/http/server).
|
||||
|
||||
```ts server.ts icon="/icons/typescript.svg"
|
||||
// static file server
|
||||
@@ -47,4 +47,4 @@ Bun.serve({
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > File I/O](https://bun.com/docs/api/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`.
|
||||
See [Docs > API > File I/O](/runtime/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`.
|
||||
|
||||
@@ -4,7 +4,7 @@ sidebarTitle: Configure TLS
|
||||
mode: center
|
||||
---
|
||||
|
||||
Set the `tls` key to configure TLS. Both `key` and `cert` are required. The `key` should be the contents of your private key; `cert` should be the contents of your issued certificate. Use [`Bun.file()`](https://bun.com/docs/api/file-io#reading-files-bun-file) to read the contents.
|
||||
Set the `tls` key to configure TLS. Both `key` and `cert` are required. The `key` should be the contents of your private key; `cert` should be the contents of your issued certificate. Use [`Bun.file()`](/runtime/file-io#reading-files-bun-file) to read the contents.
|
||||
|
||||
```ts server.ts icon="/icons/typescript.svg"
|
||||
const server = Bun.serve({
|
||||
|
||||
@@ -25,4 +25,4 @@ This will add the package to `devDependencies` in `package.json`.
|
||||
|
||||
---
|
||||
|
||||
See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
See [Docs > Package manager](/pm/cli/install) for complete documentation of Bun's package manager.
|
||||
|
||||
@@ -37,4 +37,4 @@ bun add github:colinhacks/zod
|
||||
|
||||
---
|
||||
|
||||
See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
See [Docs > Package manager](/pm/cli/install) for complete documentation of Bun's package manager.
|
||||
|
||||
@@ -24,4 +24,4 @@ This will add the package to `optionalDependencies` in `package.json`.
|
||||
|
||||
---
|
||||
|
||||
See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
See [Docs > Package manager](/pm/cli/install) for complete documentation of Bun's package manager.
|
||||
|
||||
@@ -17,7 +17,7 @@ This will add the package to `peerDependencies` in `package.json`.
|
||||
```json package.json icon="file-json"
|
||||
{
|
||||
"peerDependencies": {
|
||||
"@types/bun": "^1.3.2" // [!code ++]
|
||||
"@types/bun": "^1.3.3" // [!code ++]
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -30,7 +30,7 @@ Running `bun install` will install peer dependencies by default, unless marked o
|
||||
```json package.json icon="file-json"
|
||||
{
|
||||
"peerDependencies": {
|
||||
"@types/bun": "^1.3.2"
|
||||
"@types/bun": "^1.3.3"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/bun": { // [!code ++]
|
||||
@@ -42,4 +42,4 @@ Running `bun install` will install peer dependencies by default, unless marked o
|
||||
|
||||
---
|
||||
|
||||
See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
See [Docs > Package manager](/pm/cli/install) for complete documentation of Bun's package manager.
|
||||
|
||||
@@ -32,4 +32,4 @@ import { z } from "zod";
|
||||
|
||||
---
|
||||
|
||||
See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
See [Docs > Package manager](/pm/cli/install) for complete documentation of Bun's package manager.
|
||||
|
||||
@@ -41,4 +41,4 @@ bun add zod@next
|
||||
|
||||
---
|
||||
|
||||
See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
See [Docs > Package manager](/pm/cli/install) for complete documentation of Bun's package manager.
|
||||
|
||||
@@ -31,9 +31,9 @@ password = "$NPM_PASSWORD"
|
||||
|
||||
---
|
||||
|
||||
Then assign your Azure Personal Access Token to the `NPM_PASSWORD` environment variable. Bun [automatically reads](https://bun.com/docs/runtime/env) `.env` files, so create a file called `.env` in your project root. There is no need to base-64 encode this token! Bun will do this for you.
|
||||
Then assign your Azure Personal Access Token to the `NPM_PASSWORD` environment variable. Bun [automatically reads](/runtime/environment-variables) `.env` files, so create a file called `.env` in your project root. There is no need to base-64 encode this token! Bun will do this for you.
|
||||
|
||||
```txt .env icon="settings"
|
||||
```ini .env icon="settings"
|
||||
NPM_PASSWORD=<paste token here>
|
||||
```
|
||||
|
||||
@@ -43,7 +43,7 @@ NPM_PASSWORD=<paste token here>
|
||||
|
||||
---
|
||||
|
||||
To configure Azure Artifacts without `bunfig.toml`, you can set the `NPM_CONFIG_REGISTRY` environment variable. The URL should include `:username` and `:_password` as query parameters. Replace `<USERNAME>` and `<PASSWORD>` with the apprropriate values.
|
||||
To configure Azure Artifacts without `bunfig.toml`, you can set the `NPM_CONFIG_REGISTRY` environment variable. The URL should include `:username` and `:_password` as query parameters. Replace `<USERNAME>` and `<PASSWORD>` with the appropriate values.
|
||||
|
||||
```bash terminal icon="terminal"
|
||||
NPM_CONFIG_REGISTRY=https://pkgs.dev.azure.com/my-azure-artifacts-user/_packaging/my-azure-artifacts-user/npm/registry/:username=<USERNAME>:_password=<PASSWORD>
|
||||
|
||||
@@ -20,7 +20,7 @@ registry = "https://usertitle:password@registry.npmjs.org"
|
||||
|
||||
---
|
||||
|
||||
Your `bunfig.toml` can reference environment variables. Bun automatically loads environment variables from `.env.local`, `.env.[NODE_ENV]`, and `.env`. See [Docs > Environment variables](https://bun.com/docs/runtime/env) for more information.
|
||||
Your `bunfig.toml` can reference environment variables. Bun automatically loads environment variables from `.env.local`, `.env.[NODE_ENV]`, and `.env`. See [Docs > Environment variables](/runtime/environment-variables) for more information.
|
||||
|
||||
```toml bunfig.toml icon="settings"
|
||||
[install]
|
||||
@@ -29,4 +29,4 @@ registry = { url = "https://registry.npmjs.org", token = "$npm_token" }
|
||||
|
||||
---
|
||||
|
||||
See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
See [Docs > Package manager](/pm/cli/install) for complete documentation of Bun's package manager.
|
||||
|
||||
@@ -99,7 +99,7 @@ bun update
|
||||
bun update @types/bun --latest
|
||||
|
||||
# Update a dependency to a specific version
|
||||
bun update @types/bun@1.3.2
|
||||
bun update @types/bun@1.3.3
|
||||
|
||||
# Update all dependencies to the latest versions
|
||||
bun update --latest
|
||||
|
||||
@@ -6,7 +6,8 @@ mode: center
|
||||
|
||||
<Note>
|
||||
Bun v1.1.39 introduced `bun.lock`, a JSONC formatted lockfile. `bun.lock` is human-readable and git-diffable without
|
||||
configuration, at no cost to performance. [**Learn more.**](https://bun.com/docs/install/lockfile#text-based-lockfile)
|
||||
configuration, at no cost to performance. In 1.2.0+ it is the default format used for new projects. [**Learn
|
||||
more.**](/pm/lockfile#text-based-lockfile)
|
||||
</Note>
|
||||
|
||||
---
|
||||
|
||||
@@ -22,4 +22,4 @@ z.string();
|
||||
|
||||
---
|
||||
|
||||
See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
See [Docs > Package manager](/pm/cli/install) for complete documentation of Bun's package manager.
|
||||
|
||||
@@ -4,7 +4,7 @@ sidebarTitle: Configure a scoped registry
|
||||
mode: center
|
||||
---
|
||||
|
||||
Private registries can be configured using either [`.npmrc`](https://bun.com/docs/install/npmrc) or [`bunfig.toml`](https://bun.com/docs/runtime/bunfig#install-registry). While both are supported, we recommend using **bunfig.toml** for enhanced flexibility and Bun-specific options.
|
||||
Private registries can be configured using either [`.npmrc`](/pm/npmrc) or [`bunfig.toml`](/runtime/bunfig#install-registry). While both are supported, we recommend using **bunfig.toml** for enhanced flexibility and Bun-specific options.
|
||||
|
||||
To configure a registry for a particular npm scope:
|
||||
|
||||
@@ -28,7 +28,7 @@ To configure a registry for a particular npm scope:
|
||||
|
||||
---
|
||||
|
||||
Your `bunfig.toml` can reference environment variables. Bun automatically loads environment variables from `.env.local`, `.env.[NODE_ENV]`, and `.env`. See [Docs > Environment variables](https://bun.com/docs/runtime/env) for more information.
|
||||
Your `bunfig.toml` can reference environment variables. Bun automatically loads environment variables from `.env.local`, `.env.[NODE_ENV]`, and `.env`. See [Docs > Environment variables](/runtime/environment-variables) for more information.
|
||||
|
||||
```toml bunfig.toml icon="settings"
|
||||
[install.scopes]
|
||||
@@ -37,4 +37,4 @@ Your `bunfig.toml` can reference environment variables. Bun automatically loads
|
||||
|
||||
---
|
||||
|
||||
See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
See [Docs > Package manager](/pm/cli/install) for complete documentation of Bun's package manager.
|
||||
|
||||
@@ -47,4 +47,4 @@ bun install
|
||||
|
||||
---
|
||||
|
||||
See [Docs > Package manager > Trusted dependencies](https://bun.com/docs/install/lifecycle) for complete documentation of trusted dependencies.
|
||||
See [Docs > Package manager > Trusted dependencies](/pm/lifecycle) for complete documentation of trusted dependencies.
|
||||
|
||||
@@ -67,4 +67,4 @@ bun add zod
|
||||
|
||||
---
|
||||
|
||||
See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
See [Docs > Package manager](/pm/cli/install) for complete documentation of Bun's package manager.
|
||||
|
||||
@@ -6,12 +6,13 @@ mode: center
|
||||
|
||||
<Note>
|
||||
Bun v1.1.39 introduced `bun.lock`, a JSONC formatted lockfile. `bun.lock` is human-readable and git-diffable without
|
||||
configuration, at no cost to performance. [**Learn more.**](https://bun.com/docs/install/lockfile#text-based-lockfile)
|
||||
configuration, at no cost to performance. In 1.2.0+ it is the default format used for new projects. [**Learn
|
||||
more.**](/pm/lockfile#text-based-lockfile)
|
||||
</Note>
|
||||
|
||||
---
|
||||
|
||||
Use the `--yarn` flag to generate a Yarn-compatible `yarn.lock` file (in addition to `bun.lock`).
|
||||
Use the `--yarn` flag to generate a Yarn-compatible `yarn.lock` file (in addition to `bun.lock{b}`).
|
||||
|
||||
```sh terminal icon="terminal"
|
||||
bun install --yarn
|
||||
@@ -47,4 +48,4 @@ abab@^2.0.6:
|
||||
|
||||
---
|
||||
|
||||
See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
|
||||
See [Docs > Package manager](/pm/cli/install) for complete documentation of Bun's package manager.
|
||||
|
||||
@@ -15,4 +15,4 @@ process.on("SIGINT", () => {
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Utils](https://bun.com/docs/api/utils) for more useful utilities.
|
||||
See [Docs > API > Utils](/runtime/utils) for more useful utilities.
|
||||
|
||||
@@ -4,7 +4,7 @@ sidebarTitle: Spawn a child process and communicate using IPC
|
||||
mode: center
|
||||
---
|
||||
|
||||
Use [`Bun.spawn()`](https://bun.com/docs/api/spawn) to spawn a child process. When spawning a second `bun` process, you can open a direct inter-process communication (IPC) channel between the two processes.
|
||||
Use [`Bun.spawn()`](/runtime/child-process) to spawn a child process. When spawning a second `bun` process, you can open a direct inter-process communication (IPC) channel between the two processes.
|
||||
|
||||
<Note>
|
||||
This API is only compatible with other `bun` processes. Use `process.execPath` to get a path to the currently running
|
||||
@@ -66,4 +66,4 @@ process.send({ message: "Hello from child as object" });
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Child processes](https://bun.com/docs/api/spawn) for complete documentation.
|
||||
See [Docs > API > Child processes](/runtime/child-process) for complete documentation.
|
||||
|
||||
@@ -12,4 +12,4 @@ Bun.nanoseconds();
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Utils](https://bun.com/docs/api/utils) for more useful utilities.
|
||||
See [Docs > API > Utils](/runtime/utils) for more useful utilities.
|
||||
|
||||
@@ -38,4 +38,4 @@ process.on("exit", code => {
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Utils](https://bun.com/docs/api/utils) for more useful utilities.
|
||||
See [Docs > API > Utils](/runtime/utils) for more useful utilities.
|
||||
|
||||
@@ -4,7 +4,7 @@ sidebarTitle: Read stderr
|
||||
mode: center
|
||||
---
|
||||
|
||||
When using [`Bun.spawn()`](https://bun.com/docs/api/spawn), the child process inherits the `stderr` of the spawning process. If instead you'd prefer to read and handle `stderr`, set the `stderr` option to `"pipe"`.
|
||||
When using [`Bun.spawn()`](/runtime/child-process), the child process inherits the `stderr` of the spawning process. If instead you'd prefer to read and handle `stderr`, set the `stderr` option to `"pipe"`.
|
||||
|
||||
```ts
|
||||
const proc = Bun.spawn(["echo", "hello"], {
|
||||
@@ -31,4 +31,4 @@ if (errors) {
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Child processes](https://bun.com/docs/api/spawn) for complete documentation.
|
||||
See [Docs > API > Child processes](/runtime/child-process) for complete documentation.
|
||||
|
||||
@@ -4,7 +4,7 @@ sidebarTitle: Read stdout
|
||||
mode: center
|
||||
---
|
||||
|
||||
When using [`Bun.spawn()`](https://bun.com/docs/api/spawn), the `stdout` of the child process can be consumed as a `ReadableStream` via `proc.stdout`.
|
||||
When using [`Bun.spawn()`](/runtime/child-process), the `stdout` of the child process can be consumed as a `ReadableStream` via `proc.stdout`.
|
||||
|
||||
```ts
|
||||
const proc = Bun.spawn(["echo", "hello"]);
|
||||
@@ -25,4 +25,4 @@ const proc = Bun.spawn(["echo", "hello"], {
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Child processes](https://bun.com/docs/api/spawn) for complete documentation.
|
||||
See [Docs > API > Child processes](/runtime/child-process) for complete documentation.
|
||||
|
||||
@@ -4,7 +4,7 @@ sidebarTitle: Spawn child process
|
||||
mode: center
|
||||
---
|
||||
|
||||
Use [`Bun.spawn()`](https://bun.com/docs/api/spawn) to spawn a child process.
|
||||
Use [`Bun.spawn()`](/runtime/child-process) to spawn a child process.
|
||||
|
||||
```ts
|
||||
const proc = Bun.spawn(["echo", "hello"]);
|
||||
@@ -40,4 +40,4 @@ output; // => "hello\n"
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Child processes](https://bun.com/docs/api/spawn) for complete documentation.
|
||||
See [Docs > API > Child processes](/runtime/child-process) for complete documentation.
|
||||
|
||||
@@ -59,4 +59,4 @@ Chunk: hello
|
||||
|
||||
---
|
||||
|
||||
See [Docs > API > Utils](https://bun.com/docs/api/utils) for more useful utilities.
|
||||
See [Docs > API > Utils](/runtime/utils) for more useful utilities.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user