mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 23:18:47 +00:00
Compare commits
442 Commits
jarred/byt
...
jarred/dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ac093817d | ||
|
|
8b03f2434a | ||
|
|
438e27e99c | ||
|
|
1042043d9b | ||
|
|
f24e8cb98a | ||
|
|
36bedb0bbc | ||
|
|
a63f09784e | ||
|
|
454316ffc3 | ||
|
|
d4a52f77c7 | ||
|
|
c2311ed06c | ||
|
|
05e8a6dd4d | ||
|
|
75902e6a21 | ||
|
|
aa06455987 | ||
|
|
19a855e02b | ||
|
|
b1a0502c0c | ||
|
|
0399ae0ee9 | ||
|
|
dacb75dc1f | ||
|
|
c370645afc | ||
|
|
e1957228f3 | ||
|
|
9feaab47f5 | ||
|
|
d306e65d0e | ||
|
|
7ba4b1d01e | ||
|
|
906b287e31 | ||
|
|
eabbd5cbfb | ||
|
|
068997b529 | ||
|
|
0612dc7bd9 | ||
|
|
8657d705b8 | ||
|
|
2e59e845fa | ||
|
|
00df6cb4ee | ||
|
|
0d4089ea7c | ||
|
|
27c979129c | ||
|
|
8bb835bf63 | ||
|
|
8bf50cf456 | ||
|
|
01e2cb25e3 | ||
|
|
010e715902 | ||
|
|
8b321cc1c6 | ||
|
|
0b9bab34d8 | ||
|
|
61f0cc497b | ||
|
|
764e20ee19 | ||
|
|
0276f5e4a3 | ||
|
|
5a7b5ceb33 | ||
|
|
a04cf04cd5 | ||
|
|
79284376ca | ||
|
|
452000a2ce | ||
|
|
172aecb02e | ||
|
|
ea57037567 | ||
|
|
80309e4d59 | ||
|
|
48c5256196 | ||
|
|
e1ec32caea | ||
|
|
7f55b1af55 | ||
|
|
fbe405fb89 | ||
|
|
cd561c6bba | ||
|
|
1b5c6fcfb5 | ||
|
|
74e65317f2 | ||
|
|
72d43590a1 | ||
|
|
9049b732db | ||
|
|
1e3d82441c | ||
|
|
ca59ed04bd | ||
|
|
fc7e2e912e | ||
|
|
16915504da | ||
|
|
6d03bdfc03 | ||
|
|
034bcf2b57 | ||
|
|
3223da2734 | ||
|
|
dd67cda545 | ||
|
|
a067619f13 | ||
|
|
c9242dae3a | ||
|
|
8d9b56260b | ||
|
|
964f2a8941 | ||
|
|
694a820a34 | ||
|
|
1d48f91b5e | ||
|
|
7839844abb | ||
|
|
9081073ec4 | ||
|
|
386743b508 | ||
|
|
1789f92991 | ||
|
|
c863341bf4 | ||
|
|
03f5a385b2 | ||
|
|
3c1a1b5634 | ||
|
|
c15190990c | ||
|
|
177239cff5 | ||
|
|
ea7068a531 | ||
|
|
46cd5b10a1 | ||
|
|
b87cf4f247 | ||
|
|
d3bc5e391f | ||
|
|
f9712ce309 | ||
|
|
5e0caa0aa4 | ||
|
|
4cf31f6a57 | ||
|
|
3f257a2905 | ||
|
|
ba126fb330 | ||
|
|
2072fa1d59 | ||
|
|
61024b2b4a | ||
|
|
90e3d6c898 | ||
|
|
e8b652a5d9 | ||
|
|
5131e66fa5 | ||
|
|
c019f86f14 | ||
|
|
354391a263 | ||
|
|
17120cefdc | ||
|
|
be7db0d37a | ||
|
|
299c6c9b21 | ||
|
|
f1c2a611ad | ||
|
|
7d9dd67586 | ||
|
|
ccb0ed13c2 | ||
|
|
b58daf86da | ||
|
|
050a9cecb7 | ||
|
|
0a3ac50931 | ||
|
|
fe0bb68d17 | ||
|
|
bc79a48ce4 | ||
|
|
2081e5b656 | ||
|
|
e30d6d21f5 | ||
|
|
81e1a9d54d | ||
|
|
1faeba01b9 | ||
|
|
19540001d1 | ||
|
|
da0bc0b0d2 | ||
|
|
95e12374ed | ||
|
|
4cc61a1b8c | ||
|
|
5416155449 | ||
|
|
c7b1e5c709 | ||
|
|
444b9d1883 | ||
|
|
197c7abe7d | ||
|
|
653c459660 | ||
|
|
25dbe5cf3f | ||
|
|
2cbb196f29 | ||
|
|
064d7bb56e | ||
|
|
37505ad955 | ||
|
|
c40468ea39 | ||
|
|
29dd4166f2 | ||
|
|
0b5363099b | ||
|
|
282dda62c8 | ||
|
|
fd91e3de0d | ||
|
|
633f4f593d | ||
|
|
fd5e777639 | ||
|
|
770c1c8327 | ||
|
|
41d10ed01e | ||
|
|
bb55b2596d | ||
|
|
197443b2db | ||
|
|
b62f70c23a | ||
|
|
d4ccba67f2 | ||
|
|
43777cffee | ||
|
|
3aedf0692c | ||
|
|
346e97dde2 | ||
|
|
aa37ecb7a5 | ||
|
|
9811a2b53e | ||
|
|
b9e72d0d2e | ||
|
|
b7d4b14b3d | ||
|
|
59e1320fb1 | ||
|
|
e402adaebf | ||
|
|
3773ceeb7e | ||
|
|
162a9b66d8 | ||
|
|
6274f10096 | ||
|
|
978540902c | ||
|
|
b99a1256ff | ||
|
|
8a1d8047f1 | ||
|
|
a473657adb | ||
|
|
775c3b1987 | ||
|
|
7ee98852c6 | ||
|
|
f46df399eb | ||
|
|
c103b57bcc | ||
|
|
3b3cde9e74 | ||
|
|
2482af60d5 | ||
|
|
2245b5efd6 | ||
|
|
155475693b | ||
|
|
f5b42e1507 | ||
|
|
139f2b23a2 | ||
|
|
28006d0ad4 | ||
|
|
c44515eaaf | ||
|
|
e0924ef226 | ||
|
|
9499f21518 | ||
|
|
6b4662ff55 | ||
|
|
a445b45e55 | ||
|
|
82b34bbbdd | ||
|
|
4d905123fa | ||
|
|
c6deb4527c | ||
|
|
f3bca62a77 | ||
|
|
62794850fa | ||
|
|
f53aff0935 | ||
|
|
9c5797e2f5 | ||
|
|
4329a66a1d | ||
|
|
12a4b95b34 | ||
|
|
cf00cb495c | ||
|
|
5763a8e533 | ||
|
|
dedd433cbf | ||
|
|
d6590c4bfa | ||
|
|
07d3d6c9f6 | ||
|
|
631e674842 | ||
|
|
3d19c1156c | ||
|
|
7a069d7214 | ||
|
|
6ebad50543 | ||
|
|
8750f0b884 | ||
|
|
c38bace86c | ||
|
|
9fd18361f2 | ||
|
|
de6739c401 | ||
|
|
2801cb1f4a | ||
|
|
b642e36da2 | ||
|
|
df3337936c | ||
|
|
ea05de59b3 | ||
|
|
601b8e3aaa | ||
|
|
a11d9e2cd4 | ||
|
|
df84f665a5 | ||
|
|
498186764a | ||
|
|
02a7d71b70 | ||
|
|
c9761d4aa6 | ||
|
|
c863e7582f | ||
|
|
d4710c6e86 | ||
|
|
e1f3796677 | ||
|
|
ec07ef83a2 | ||
|
|
eddee1b8cb | ||
|
|
fa1d37b4e3 | ||
|
|
5b0523a32a | ||
|
|
5039310199 | ||
|
|
61e03a2758 | ||
|
|
27abb51561 | ||
|
|
09d0846d1b | ||
|
|
8e7cdb8493 | ||
|
|
538caa4d5e | ||
|
|
24bc236eb7 | ||
|
|
f59050fc23 | ||
|
|
1b092f156b | ||
|
|
6a79b9ef87 | ||
|
|
f62940bbda | ||
|
|
c82345c0a0 | ||
|
|
817d0464f6 | ||
|
|
a5bb525614 | ||
|
|
4cb7910e32 | ||
|
|
d7970946eb | ||
|
|
014fb6be8f | ||
|
|
5c7991b707 | ||
|
|
da5fc817d1 | ||
|
|
407c4e800a | ||
|
|
11070b8e16 | ||
|
|
adfdaab4fd | ||
|
|
bfd7fc06c7 | ||
|
|
bd3abc5a2a | ||
|
|
193193024f | ||
|
|
6edc3a9900 | ||
|
|
1bd44e9ce7 | ||
|
|
c7327d62c2 | ||
|
|
90dda8219f | ||
|
|
885979644d | ||
|
|
13c5b0d9cb | ||
|
|
d6e45afef9 | ||
|
|
300aedd9cc | ||
|
|
d9cf836b67 | ||
|
|
293215778f | ||
|
|
95346bd919 | ||
|
|
ceaaed4848 | ||
|
|
abaa69183b | ||
|
|
3e1075410b | ||
|
|
7a88bb0e1c | ||
|
|
7a790581e0 | ||
|
|
d5cc530024 | ||
|
|
d7548325b1 | ||
|
|
d11fd94cdb | ||
|
|
4cbd040485 | ||
|
|
773484a628 | ||
|
|
71c14fac7b | ||
|
|
b2a728e45d | ||
|
|
390798c172 | ||
|
|
284de53f26 | ||
|
|
5a025abddf | ||
|
|
4ab4b1b131 | ||
|
|
13ea970852 | ||
|
|
ba78d5b2c3 | ||
|
|
ce8767cdc8 | ||
|
|
082a9cb59c | ||
|
|
3c37f25b65 | ||
|
|
a079743a02 | ||
|
|
e0852fd651 | ||
|
|
6bbd1e0685 | ||
|
|
4534f6e635 | ||
|
|
c62a7a77a3 | ||
|
|
ecf5ea389f | ||
|
|
010ef4d119 | ||
|
|
4d77cd53f1 | ||
|
|
3cf353b755 | ||
|
|
fd894f5a65 | ||
|
|
a9969b7db2 | ||
|
|
27a08fca84 | ||
|
|
a398bd62a3 | ||
|
|
2aa7c59727 | ||
|
|
7765b61038 | ||
|
|
8a06ddb1fb | ||
|
|
2e76e69939 | ||
|
|
aa404b14c4 | ||
|
|
a4819b41e9 | ||
|
|
f5bfda9699 | ||
|
|
9f5adfefe3 | ||
|
|
316c8d6c48 | ||
|
|
da87890532 | ||
|
|
576f66c149 | ||
|
|
cd0756c95c | ||
|
|
c92f3f7b72 | ||
|
|
f1226c9767 | ||
|
|
b111e6db02 | ||
|
|
ffffb634c6 | ||
|
|
d109183d3e | ||
|
|
14c9165d6f | ||
|
|
c42539b0bf | ||
|
|
022a567af0 | ||
|
|
cfb8956ac5 | ||
|
|
2bb36ca6b4 | ||
|
|
24b3de1bc3 | ||
|
|
b01ffe6da8 | ||
|
|
579f2ecd51 | ||
|
|
627b0010e0 | ||
|
|
3369e25a70 | ||
|
|
06a40f0b29 | ||
|
|
7989352b39 | ||
|
|
e1ab6fe36b | ||
|
|
14f59568cc | ||
|
|
1855836259 | ||
|
|
c85cf136a5 | ||
|
|
4da85ac9c1 | ||
|
|
9248d81871 | ||
|
|
ba21d6d54b | ||
|
|
32985591eb | ||
|
|
544d399980 | ||
|
|
809992229f | ||
|
|
9a0624bd99 | ||
|
|
ec2c2281cf | ||
|
|
df017990aa | ||
|
|
bf02d04479 | ||
|
|
5910504aeb | ||
|
|
8759527feb | ||
|
|
7b4b299be0 | ||
|
|
ff8c2dcbc4 | ||
|
|
a275ed654b | ||
|
|
7b164ee9de | ||
|
|
fc92921a4a | ||
|
|
44d04968cd | ||
|
|
e6ab636313 | ||
|
|
325d0b1ed6 | ||
|
|
a8e4489e10 | ||
|
|
31980bc151 | ||
|
|
e58df65a75 | ||
|
|
6317d6498f | ||
|
|
9e61b70535 | ||
|
|
58c1372b50 | ||
|
|
88840dcafa | ||
|
|
793a9752c9 | ||
|
|
8f08e84c1e | ||
|
|
3605531e34 | ||
|
|
7dc58e0ce4 | ||
|
|
15a58cca1c | ||
|
|
a3fdfeb924 | ||
|
|
c024e73e6a | ||
|
|
392212b090 | ||
|
|
3ea6133c46 | ||
|
|
5d84f8a102 | ||
|
|
9e329ee605 | ||
|
|
76f6574729 | ||
|
|
50b938561a | ||
|
|
3b75095f0c | ||
|
|
7b127c946d | ||
|
|
b9a63893fe | ||
|
|
ff1a35668f | ||
|
|
b36b4b2888 | ||
|
|
e7e5528632 | ||
|
|
9a5ff02420 | ||
|
|
4e9ee08a4a | ||
|
|
e11ac9d1b8 | ||
|
|
e9414966ca | ||
|
|
b2ae98865b | ||
|
|
e8ed50cd9a | ||
|
|
9dd799d2e6 | ||
|
|
ba28eeece6 | ||
|
|
e9f908fcbf | ||
|
|
654472f217 | ||
|
|
5dcf99424c | ||
|
|
ae91711010 | ||
|
|
ca6ba0fa2d | ||
|
|
3195df8796 | ||
|
|
9d1eace981 | ||
|
|
8e80afbce1 | ||
|
|
efb6b823c9 | ||
|
|
6d348fa759 | ||
|
|
69be630aea | ||
|
|
bca833ad59 | ||
|
|
ef9ea8ae1c | ||
|
|
a844957eb3 | ||
|
|
573927c4bf | ||
|
|
3e97c1caf3 | ||
|
|
b4450db807 | ||
|
|
6a363a38da | ||
|
|
ffa286ef70 | ||
|
|
2fc8785868 | ||
|
|
8ddb92085b | ||
|
|
4ca83be84f | ||
|
|
8aae534270 | ||
|
|
98ee30eccf | ||
|
|
562a65037d | ||
|
|
beb1db967b | ||
|
|
0efbb29581 | ||
|
|
0e883c935c | ||
|
|
497360d543 | ||
|
|
e23491391b | ||
|
|
259bf47abd | ||
|
|
d1ac52da2c | ||
|
|
1ebec90d6e | ||
|
|
f1504c4265 | ||
|
|
21f238a827 | ||
|
|
33be08bde8 | ||
|
|
67b64c3334 | ||
|
|
bfd12eeeba | ||
|
|
004ee11bed | ||
|
|
457c15e424 | ||
|
|
815182799e | ||
|
|
a5cb42c407 | ||
|
|
0dade44a37 | ||
|
|
09d3de918f | ||
|
|
9e13a93215 | ||
|
|
2c5e9e5532 | ||
|
|
9a392b39e2 | ||
|
|
11ed29068f | ||
|
|
ea7b9ea976 | ||
|
|
9bee7a64a2 | ||
|
|
ea6f6dff7f | ||
|
|
342fe232d0 | ||
|
|
89c5e40544 | ||
|
|
95af099a0c | ||
|
|
8686361f4f | ||
|
|
3983010835 | ||
|
|
6bbdbcef33 | ||
|
|
8f397fb5b7 | ||
|
|
34fd2437fd | ||
|
|
bf7d9f272d | ||
|
|
45198e1e45 | ||
|
|
df8ad0cf0b | ||
|
|
a7b46ebbfe | ||
|
|
6090833da6 | ||
|
|
efc9cae938 | ||
|
|
06fa1ed598 | ||
|
|
cd8d037c79 | ||
|
|
5e8fbf57cb | ||
|
|
83a825edff | ||
|
|
85766e90bf | ||
|
|
839ad3732f | ||
|
|
d774baa28a | ||
|
|
6e063fa57b | ||
|
|
a5358fbbd9 | ||
|
|
4a6f179db5 | ||
|
|
270c09bd90 | ||
|
|
d40662760a | ||
|
|
6a922be010 |
78
.agent/agent.mjs
Normal file
78
.agent/agent.mjs
Normal file
@@ -0,0 +1,78 @@
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { readFileSync, existsSync } from "node:fs";
|
||||
import { parseArgs } from "node:util";
|
||||
|
||||
const { positionals, values } = parseArgs({
|
||||
allowPositionals: true,
|
||||
options: {
|
||||
help: {
|
||||
type: "boolean",
|
||||
short: "h",
|
||||
default: false,
|
||||
},
|
||||
interactive: {
|
||||
type: "boolean",
|
||||
short: "i",
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (values.help || positionals.length === 0) {
|
||||
console.log("Usage: node agent.mjs <prompt_name> [extra_args...]");
|
||||
console.log("Example: node agent.mjs triage fix bug in authentication");
|
||||
console.log("Options:");
|
||||
console.log(" -h, --help Show this help message");
|
||||
console.log(" -i, --interactive Run in interactive mode");
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const promptName = positionals[0].toUpperCase();
|
||||
const promptFile = `.agent/${promptName}.md`;
|
||||
const extraArgs = positionals.slice(1);
|
||||
|
||||
if (!existsSync(promptFile)) {
|
||||
console.error(`Error: Prompt file "${promptFile}" not found`);
|
||||
console.error(`Available prompts should be named like: .agent/triage.md, .agent/debug.md, etc.`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
let prompt = readFileSync(promptFile, "utf-8");
|
||||
|
||||
const githubEnvs = Object.entries(process.env)
|
||||
.filter(([key]) => key.startsWith("GITHUB_"))
|
||||
.sort(([a], [b]) => a.localeCompare(b));
|
||||
|
||||
if (githubEnvs.length > 0) {
|
||||
const githubContext = `## GitHub Environment\n\n${githubEnvs
|
||||
.map(([key, value]) => `**${key}**: \`${value}\``)
|
||||
.join("\n")}\n\n---\n\n`;
|
||||
prompt = githubContext + prompt;
|
||||
}
|
||||
|
||||
if (extraArgs.length > 0) {
|
||||
const extraArgsContext = `\n\n## Additional Arguments\n\n${extraArgs.join(" ")}\n\n---\n\n`;
|
||||
prompt = prompt + extraArgsContext;
|
||||
}
|
||||
|
||||
const claudeArgs = [prompt, "--allowedTools=Edit,Write,Replace,Search", "--output-format=json"];
|
||||
if (!values.interactive) {
|
||||
claudeArgs.unshift("--print");
|
||||
}
|
||||
|
||||
const { status, error } = spawnSync("claude", claudeArgs, {
|
||||
stdio: "inherit",
|
||||
encoding: "utf-8",
|
||||
});
|
||||
|
||||
if (error) {
|
||||
console.error("Error running claude:", error);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
process.exit(status || 0);
|
||||
} catch (error) {
|
||||
console.error(`Error reading prompt file "${promptFile}":`, error);
|
||||
process.exit(1);
|
||||
}
|
||||
@@ -128,11 +128,8 @@ const testPlatforms = [
|
||||
{ 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: "ubuntu", release: "24.04", tier: "latest" },
|
||||
{ os: "linux", arch: "aarch64", distro: "ubuntu", release: "20.04", tier: "oldest" },
|
||||
{ os: "linux", arch: "x64", distro: "ubuntu", release: "24.04", tier: "latest" },
|
||||
{ os: "linux", arch: "x64", distro: "ubuntu", release: "20.04", tier: "oldest" },
|
||||
{ os: "linux", arch: "x64", baseline: true, distro: "ubuntu", release: "24.04", tier: "latest" },
|
||||
{ os: "linux", arch: "x64", baseline: true, distro: "ubuntu", release: "20.04", tier: "oldest" },
|
||||
{ os: "linux", arch: "aarch64", abi: "musl", distro: "alpine", release: "3.21", tier: "latest" },
|
||||
{ os: "linux", arch: "x64", abi: "musl", distro: "alpine", release: "3.21", tier: "latest" },
|
||||
{ os: "linux", arch: "x64", abi: "musl", baseline: true, distro: "alpine", release: "3.21", tier: "latest" },
|
||||
@@ -228,13 +225,7 @@ function getRetry(limit = 0) {
|
||||
manual: {
|
||||
permit_on_passed: true,
|
||||
},
|
||||
automatic: [
|
||||
{ exit_status: 1, limit },
|
||||
{ exit_status: -1, limit: 1 },
|
||||
{ exit_status: 255, limit: 1 },
|
||||
{ signal_reason: "cancel", limit: 1 },
|
||||
{ signal_reason: "agent_stop", limit: 1 },
|
||||
],
|
||||
automatic: false,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -315,6 +306,19 @@ function getCppAgent(platform, options) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Platform}
|
||||
*/
|
||||
function getZigPlatform() {
|
||||
return {
|
||||
os: "linux",
|
||||
arch: "aarch64",
|
||||
abi: "musl",
|
||||
distro: "alpine",
|
||||
release: "3.21",
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Platform} platform
|
||||
* @param {PipelineOptions} options
|
||||
@@ -328,21 +332,9 @@ function getZigAgent(platform, options) {
|
||||
// queue: "build-zig",
|
||||
// };
|
||||
|
||||
return getEc2Agent(
|
||||
{
|
||||
os: "linux",
|
||||
arch: "x64",
|
||||
abi: "musl",
|
||||
distro: "alpine",
|
||||
release: "3.21",
|
||||
},
|
||||
options,
|
||||
{
|
||||
instanceType: "c7i.2xlarge",
|
||||
cpuCount: 4,
|
||||
threadsPerCore: 1,
|
||||
},
|
||||
);
|
||||
return getEc2Agent(getZigPlatform(), options, {
|
||||
instanceType: "r8g.large",
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -455,7 +447,7 @@ function getBuildCppStep(platform, options) {
|
||||
BUN_CPP_ONLY: "ON",
|
||||
...getBuildEnv(platform, options),
|
||||
},
|
||||
// We used to build the C++ dependencies and bun in seperate steps.
|
||||
// We used to build the C++ dependencies and bun in separate steps.
|
||||
// However, as long as the zig build takes longer than both sequentially,
|
||||
// it's cheaper to run them in the same step. Can be revisited in the future.
|
||||
command: [`${command} --target bun`, `${command} --target dependencies`],
|
||||
@@ -574,7 +566,7 @@ function getTestBunStep(platform, options, testOptions = {}) {
|
||||
retry: getRetry(),
|
||||
cancel_on_build_failing: isMergeQueue(),
|
||||
parallelism: unifiedTests ? undefined : os === "darwin" ? 2 : 10,
|
||||
timeout_in_minutes: profile === "asan" ? 90 : 30,
|
||||
timeout_in_minutes: profile === "asan" ? 45 : 30,
|
||||
command:
|
||||
os === "windows"
|
||||
? `node .\\scripts\\runner.node.mjs ${args.join(" ")}`
|
||||
@@ -927,7 +919,7 @@ function getOptionsStep() {
|
||||
{
|
||||
key: "unified-builds",
|
||||
select: "Do you want to build each platform in a single step?",
|
||||
hint: "If true, builds will not be split into seperate steps (this will likely slow down the build)",
|
||||
hint: "If true, builds will not be split into separate steps (this will likely slow down the build)",
|
||||
required: false,
|
||||
default: "false",
|
||||
options: booleanOptions,
|
||||
@@ -935,7 +927,7 @@ function getOptionsStep() {
|
||||
{
|
||||
key: "unified-tests",
|
||||
select: "Do you want to run tests in a single step?",
|
||||
hint: "If true, tests will not be split into seperate steps (this will be very slow)",
|
||||
hint: "If true, tests will not be split into separate steps (this will be very slow)",
|
||||
required: false,
|
||||
default: "false",
|
||||
options: booleanOptions,
|
||||
@@ -1113,6 +1105,11 @@ async function getPipeline(options = {}) {
|
||||
steps.push(
|
||||
...relevantBuildPlatforms.map(target => {
|
||||
const imageKey = getImageKey(target);
|
||||
const zigImageKey = getImageKey(getZigPlatform());
|
||||
const dependsOn = imagePlatforms.has(zigImageKey) ? [`${zigImageKey}-build-image`] : [];
|
||||
if (imagePlatforms.has(imageKey)) {
|
||||
dependsOn.push(`${imageKey}-build-image`);
|
||||
}
|
||||
|
||||
return getStepWithDependsOn(
|
||||
{
|
||||
@@ -1122,7 +1119,7 @@ async function getPipeline(options = {}) {
|
||||
? [getBuildBunStep(target, options)]
|
||||
: [getBuildCppStep(target, options), getBuildZigStep(target, options), getLinkBunStep(target, options)],
|
||||
},
|
||||
imagePlatforms.has(imageKey) ? `${imageKey}-build-image` : undefined,
|
||||
...dependsOn,
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
92
.claude/commands/upgrade-nodejs.md
Normal file
92
.claude/commands/upgrade-nodejs.md
Normal file
@@ -0,0 +1,92 @@
|
||||
# Upgrading Bun's Self-Reported Node.js Version
|
||||
|
||||
This guide explains how to upgrade the Node.js version that Bun reports for compatibility with Node.js packages and native addons.
|
||||
|
||||
## Overview
|
||||
|
||||
Bun reports a Node.js version for compatibility with the Node.js ecosystem. This affects:
|
||||
- `process.version` output
|
||||
- Node-API (N-API) compatibility
|
||||
- Native addon ABI compatibility
|
||||
- V8 API compatibility for addons using V8 directly
|
||||
|
||||
## Files That Always Need Updates
|
||||
|
||||
### 1. Bootstrap Scripts
|
||||
- `scripts/bootstrap.sh` - Update `NODEJS_VERSION=`
|
||||
- `scripts/bootstrap.ps1` - Update `$NODEJS_VERSION =`
|
||||
|
||||
### 2. CMake Configuration
|
||||
- `cmake/Options.cmake`
|
||||
- `NODEJS_VERSION` - The Node.js version string (e.g., "24.3.0")
|
||||
- `NODEJS_ABI_VERSION` - The ABI version number (find using command below)
|
||||
|
||||
### 3. Version Strings
|
||||
- `src/bun.js/bindings/BunProcess.cpp`
|
||||
- Update `Bun__versions_node` with the Node.js version
|
||||
- Update `Bun__versions_v8` with the V8 version (find using command below)
|
||||
|
||||
### 4. N-API Version
|
||||
- `src/napi/js_native_api.h`
|
||||
- Update `NAPI_VERSION` define (check Node.js release notes)
|
||||
|
||||
## Files That May Need Updates
|
||||
|
||||
Only check these if the build fails or tests crash after updating version numbers:
|
||||
- V8 compatibility files in `src/bun.js/bindings/v8/` (if V8 API changed)
|
||||
- Test files (if Node.js requires newer C++ standard)
|
||||
|
||||
## Quick Commands to Find Version Info
|
||||
|
||||
```bash
|
||||
# Get latest Node.js version info
|
||||
curl -s https://nodejs.org/dist/index.json | jq '.[0]'
|
||||
|
||||
# Get V8 version for a specific Node.js version (replace v24.3.0)
|
||||
curl -s https://nodejs.org/dist/v24.3.0/node-v24.3.0-headers.tar.gz | tar -xzO node-v24.3.0/include/node/node_version.h | grep V8_VERSION
|
||||
|
||||
# Get ABI version for a specific Node.js version
|
||||
curl -s https://nodejs.org/dist/v24.3.0/node-v24.3.0-headers.tar.gz | tar -xzO node-v24.3.0/include/node/node_version.h | grep NODE_MODULE_VERSION
|
||||
|
||||
# Or use the ABI registry
|
||||
curl -s https://raw.githubusercontent.com/nodejs/node/main/doc/abi_version_registry.json | jq '.NODE_MODULE_VERSION."<version>"'
|
||||
```
|
||||
|
||||
## Update Process
|
||||
|
||||
1. **Gather version info** using the commands above
|
||||
2. **Update the required files** listed in the sections above
|
||||
3. **Build and test**:
|
||||
```bash
|
||||
bun bd
|
||||
bun bd -e "console.log(process.version)"
|
||||
bun bd -e "console.log(process.versions.v8)"
|
||||
bun bd test test/v8/v8.test.ts
|
||||
bun bd test test/napi/napi.test.ts
|
||||
```
|
||||
|
||||
4. **Check for V8 API changes** only if build fails or tests crash:
|
||||
- Compare v8-function-callback.h between versions
|
||||
- Check v8-internal.h for Isolate size changes
|
||||
- Look for new required APIs in build errors
|
||||
|
||||
## If Build Fails or Tests Crash
|
||||
|
||||
The V8 API rarely has breaking changes between minor Node.js versions. If you encounter issues:
|
||||
1. Check build errors for missing symbols or type mismatches
|
||||
2. Compare V8 headers between old and new Node.js versions
|
||||
3. Most issues can be resolved by implementing missing functions or adjusting structures
|
||||
|
||||
## Testing Checklist
|
||||
|
||||
- [ ] `process.version` returns correct version
|
||||
- [ ] `process.versions.v8` returns correct V8 version
|
||||
- [ ] `process.config.variables.node_module_version` returns correct ABI
|
||||
- [ ] V8 tests pass
|
||||
- [ ] N-API tests pass
|
||||
|
||||
## Notes
|
||||
|
||||
- Most upgrades only require updating version numbers
|
||||
- Major V8 version changes (rare) may require API updates
|
||||
- The V8 shim implements only APIs used by common native addons
|
||||
23
.claude/commands/upgrade-webkit.md
Normal file
23
.claude/commands/upgrade-webkit.md
Normal file
@@ -0,0 +1,23 @@
|
||||
Upgrade Bun's Webkit fork to the latest upstream version of Webkit.
|
||||
|
||||
To do that:
|
||||
|
||||
- cd vendor/WebKit
|
||||
- git fetch upstream
|
||||
- git merge upstream main
|
||||
- Fix the merge conflicts
|
||||
- cd ../../ (back to bun)
|
||||
- make jsc-build (this will take about 7 minutes)
|
||||
- While it compiles, in another task review the JSC commits between the last version of Webkit and the new version. Write up a summary of the webkit changes in a file called "webkit-changes.md"
|
||||
- bun run build:local (build a build of Bun with the new Webkit, make sure it compiles)
|
||||
- After making sure it compiles, run some code to make sure things work. something like ./build/debug-local/bun-debug --print '42' should be all you need
|
||||
- cd vendor/WebKit
|
||||
- git commit -am "Upgrade Webkit to the latest version"
|
||||
- git push
|
||||
- get the commit SHA in the vendor/WebKit directory of your new commit
|
||||
- cd ../../ (back to bun)
|
||||
- Update WEBKIT_VERSION in cmake/tools/SetupWebKit.cmake to the commit SHA of your new commit
|
||||
- git checkout -b bun/webkit-upgrade-<commit-sha>
|
||||
- commit + push (without adding the webkit-changes.md file)
|
||||
- create PR titled "Upgrade Webkit to the <commit-sha>", paste your webkit-changes.md into the PR description
|
||||
- delete the webkit-changes.md file
|
||||
10
.cursor/environment.json
Normal file
10
.cursor/environment.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"snapshot": "snapshot-20250706-71021aff-cc0d-4a7f-a468-d443b16c4bf1",
|
||||
"install": "bun install",
|
||||
"terminals": [
|
||||
{
|
||||
"name": "bun build",
|
||||
"command": "bun run build"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,27 +1,41 @@
|
||||
---
|
||||
description: How to build Bun
|
||||
globs:
|
||||
description:
|
||||
globs: src/**/*.cpp,src/**/*.zig
|
||||
alwaysApply: false
|
||||
---
|
||||
# How to build Bun
|
||||
|
||||
## CMake
|
||||
### Build Commands
|
||||
|
||||
Bun is built using CMake, which you can find in `CMakeLists.txt` and in the `cmake/` directory.
|
||||
- **Build debug version**: `bun bd` or `bun run build:debug`
|
||||
- Creates a debug build at `./build/debug/bun-debug`
|
||||
- Compilation takes ~2.5 minutes
|
||||
- **Run tests with your debug build**: `bun bd test <test-file>`
|
||||
- **CRITICAL**: Never use `bun test` directly - it won't include your changes
|
||||
- **Run any command with debug build**: `bun bd <command>`
|
||||
|
||||
* `CMakeLists.txt`
|
||||
* `cmake/`
|
||||
* `Globals.cmake` - macros and functions used by all the other files
|
||||
* `Options.cmake` - build options for configuring the build (e.g. debug/release mode)
|
||||
* `CompilerFlags.cmake` - compiler and linker flags used by all the targets
|
||||
* `tools/` - setup scripts for various build tools (e.g. llvm, zig, webkit, rust, etc.)
|
||||
* `targets/` - targets for bun and its dependencies (e.g. brotli, boringssl, libuv, etc.)
|
||||
### Run a file
|
||||
|
||||
## How to
|
||||
|
||||
There are `package.json` scripts that make it easy to build Bun without calling CMake directly, for example:
|
||||
To run a file, use:
|
||||
|
||||
```sh
|
||||
bun run build # builds a debug build: `build/debug/bun-debug`
|
||||
bun run build:release # builds a release build: `build/release/bun`
|
||||
bun run build:assert # builds a release build with debug assertions: `build/assert/bun`
|
||||
bun bd <file> <...args>
|
||||
```
|
||||
|
||||
**CRITICAL**: Never use `bun <file>` directly. It will not have your changes.
|
||||
|
||||
### Logging
|
||||
|
||||
`BUN_DEBUG_$(SCOPE)=1` enables debug logs for a specific debug log scope.
|
||||
|
||||
Debug logs look like this:
|
||||
|
||||
```zig
|
||||
const log = bun.Output.scoped(.${SCOPE}, false);
|
||||
|
||||
// ...later
|
||||
log("MY DEBUG LOG", .{})
|
||||
```
|
||||
|
||||
### Code Generation
|
||||
|
||||
Code generation happens automatically as part of the build process. There are no commands to run.
|
||||
|
||||
@@ -91,7 +91,7 @@ devTest("html file is watched", {
|
||||
|
||||
`files` holds the initial state, and the callback runs with the server running. `dev.fetch()` runs HTTP requests, while `dev.client()` opens a browser instance to the code.
|
||||
|
||||
Functions `dev.write` and `dev.patch` and `dev.delete` mutate the filesystem. Do not use `node:fs` APIs, as the dev server ones are hooked to wait for hot-reload, and all connected clients to recieve changes.
|
||||
Functions `dev.write` and `dev.patch` and `dev.delete` mutate the filesystem. Do not use `node:fs` APIs, as the dev server ones are hooked to wait for hot-reload, and all connected clients to receive changes.
|
||||
|
||||
When a change performs a hard-reload, that must be explicitly annotated with `expectReload`. This tells `client-fixture.mjs` that the test is meant to reload the page once; All other hard reloads automatically fail the test.
|
||||
|
||||
|
||||
203
.cursor/rules/registering-bun-modules.mdc
Normal file
203
.cursor/rules/registering-bun-modules.mdc
Normal file
@@ -0,0 +1,203 @@
|
||||
# Registering Functions, Objects, and Modules in Bun
|
||||
|
||||
This guide documents the process of adding new functionality to the Bun global object and runtime.
|
||||
|
||||
## Overview
|
||||
|
||||
Bun's architecture exposes functionality to JavaScript through a set of carefully registered functions, objects, and modules. Most core functionality is implemented in Zig, with JavaScript bindings that make these features accessible to users.
|
||||
|
||||
There are several key ways to expose functionality in Bun:
|
||||
|
||||
1. **Global Functions**: Direct methods on the `Bun` object (e.g., `Bun.serve()`)
|
||||
2. **Getter Properties**: Lazily initialized properties on the `Bun` object (e.g., `Bun.sqlite`)
|
||||
3. **Constructor Classes**: Classes available through the `Bun` object (e.g., `Bun.ValkeyClient`)
|
||||
4. **Global Modules**: Modules that can be imported directly (e.g., `import {X} from "bun:*"`)
|
||||
|
||||
## The Registration Process
|
||||
|
||||
Adding new functionality to Bun involves several coordinated steps across multiple files:
|
||||
|
||||
### 1. Implement the Core Functionality in Zig
|
||||
|
||||
First, implement your feature in Zig, typically in its own directory in `src/`. Examples:
|
||||
|
||||
- `src/valkey/` for Redis/Valkey client
|
||||
- `src/semver/` for SemVer functionality
|
||||
- `src/smtp/` for SMTP client
|
||||
|
||||
### 2. Create JavaScript Bindings
|
||||
|
||||
Create bindings that expose your Zig functionality to JavaScript:
|
||||
|
||||
- Create a class definition file (e.g., `js_bindings.classes.ts`) to define the JavaScript interface
|
||||
- Implement `JSYourFeature` struct in a file like `js_your_feature.zig`
|
||||
|
||||
Example from a class definition file:
|
||||
|
||||
```typescript
|
||||
// Example from a .classes.ts file
|
||||
import { define } from "../../codegen/class-definitions";
|
||||
|
||||
export default [
|
||||
define({
|
||||
name: "YourFeature",
|
||||
construct: true,
|
||||
finalize: true,
|
||||
hasPendingActivity: true,
|
||||
memoryCost: true,
|
||||
klass: {},
|
||||
JSType: "0b11101110",
|
||||
proto: {
|
||||
yourMethod: {
|
||||
fn: "yourZigMethod",
|
||||
length: 1,
|
||||
},
|
||||
property: {
|
||||
getter: "getProperty",
|
||||
},
|
||||
},
|
||||
values: ["cachedValues"],
|
||||
}),
|
||||
];
|
||||
```
|
||||
|
||||
### 3. Register with BunObject in `src/bun.js/bindings/BunObject+exports.h`
|
||||
|
||||
Add an entry to the `FOR_EACH_GETTER` macro:
|
||||
|
||||
```c
|
||||
// In BunObject+exports.h
|
||||
#define FOR_EACH_GETTER(macro) \
|
||||
macro(CSRF) \
|
||||
macro(CryptoHasher) \
|
||||
... \
|
||||
macro(YourFeature) \
|
||||
```
|
||||
|
||||
### 4. Create a Getter Function in `src/bun.js/api/BunObject.zig`
|
||||
|
||||
Implement a getter function in `BunObject.zig` that returns your feature:
|
||||
|
||||
```zig
|
||||
// In BunObject.zig
|
||||
pub const YourFeature = toJSGetter(Bun.getYourFeatureConstructor);
|
||||
|
||||
// In the exportAll() function:
|
||||
@export(&BunObject.YourFeature, .{ .name = getterName("YourFeature") });
|
||||
```
|
||||
|
||||
### 5. Implement the Getter Function in a Relevant Zig File
|
||||
|
||||
Implement the function that creates your object:
|
||||
|
||||
```zig
|
||||
// In your main module file (e.g., src/your_feature/your_feature.zig)
|
||||
pub fn getYourFeatureConstructor(globalThis: *JSC.JSGlobalObject, _: *JSC.JSObject) JSC.JSValue {
|
||||
return JSC.API.YourFeature.getConstructor(globalThis);
|
||||
}
|
||||
```
|
||||
|
||||
### 6. Add to Build System
|
||||
|
||||
Ensure your files are included in the build system by adding them to the appropriate targets.
|
||||
|
||||
## Example: Adding a New Module
|
||||
|
||||
Here's a comprehensive example of adding a hypothetical SMTP module:
|
||||
|
||||
1. Create implementation files in `src/smtp/`:
|
||||
|
||||
- `index.zig`: Main entry point that exports everything
|
||||
- `SmtpClient.zig`: Core SMTP client implementation
|
||||
- `js_smtp.zig`: JavaScript bindings
|
||||
- `js_bindings.classes.ts`: Class definition
|
||||
|
||||
2. Define your JS class in `js_bindings.classes.ts`:
|
||||
|
||||
```typescript
|
||||
import { define } from "../../codegen/class-definitions";
|
||||
|
||||
export default [
|
||||
define({
|
||||
name: "EmailClient",
|
||||
construct: true,
|
||||
finalize: true,
|
||||
hasPendingActivity: true,
|
||||
configurable: false,
|
||||
memoryCost: true,
|
||||
klass: {},
|
||||
JSType: "0b11101110",
|
||||
proto: {
|
||||
send: {
|
||||
fn: "send",
|
||||
length: 1,
|
||||
},
|
||||
verify: {
|
||||
fn: "verify",
|
||||
length: 0,
|
||||
},
|
||||
close: {
|
||||
fn: "close",
|
||||
length: 0,
|
||||
},
|
||||
},
|
||||
values: ["connectionPromise"],
|
||||
}),
|
||||
];
|
||||
```
|
||||
|
||||
3. Add getter to `BunObject+exports.h`:
|
||||
|
||||
```c
|
||||
#define FOR_EACH_GETTER(macro) \
|
||||
macro(CSRF) \
|
||||
... \
|
||||
macro(SMTP) \
|
||||
```
|
||||
|
||||
4. Add getter function to `BunObject.zig`:
|
||||
|
||||
```zig
|
||||
pub const SMTP = toJSGetter(Bun.getSmtpConstructor);
|
||||
|
||||
// In exportAll:
|
||||
@export(&BunObject.SMTP, .{ .name = getterName("SMTP") });
|
||||
```
|
||||
|
||||
5. Implement getter in your module:
|
||||
|
||||
```zig
|
||||
pub fn getSmtpConstructor(globalThis: *JSC.JSGlobalObject, _: *JSC.JSObject) JSC.JSValue {
|
||||
return JSC.API.JSEmailClient.getConstructor(globalThis);
|
||||
}
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Follow Naming Conventions**: Align your naming with existing patterns
|
||||
2. **Reference Existing Modules**: Study similar modules like Valkey or S3Client for guidance
|
||||
3. **Memory Management**: Be careful with memory management and reference counting
|
||||
4. **Error Handling**: Use `bun.JSError!JSValue` for proper error propagation
|
||||
5. **Documentation**: Add JSDoc comments to your JavaScript bindings
|
||||
6. **Testing**: Add tests for your new functionality
|
||||
|
||||
## Common Gotchas
|
||||
|
||||
- Be sure to handle reference counting properly with `ref()`/`deref()`
|
||||
- Always implement proper cleanup in `deinit()` and `finalize()`
|
||||
- For network operations, manage socket lifetimes correctly
|
||||
- Use `JSC.Codegen` correctly to generate necessary binding code
|
||||
|
||||
## Related Files
|
||||
|
||||
- `src/bun.js/bindings/BunObject+exports.h`: Registration of getters and functions
|
||||
- `src/bun.js/api/BunObject.zig`: Implementation of getters and object creation
|
||||
- `src/bun.js/api/BunObject.classes.ts`: Class definitions
|
||||
- `.cursor/rules/zig-javascriptcore-classes.mdc`: More details on class bindings
|
||||
|
||||
## Additional Resources
|
||||
|
||||
For more detailed information on specific topics:
|
||||
|
||||
- See `zig-javascriptcore-classes.mdc` for details on creating JS class bindings
|
||||
- Review existing modules like `valkey`, `sqlite`, or `s3` for real-world examples
|
||||
@@ -11,10 +11,10 @@ You'll find all of Bun's tests in the `test/` directory.
|
||||
* `test/`
|
||||
* `cli/` - CLI command tests, like `bun install` or `bun init`
|
||||
* `js/` - JavaScript & TypeScript tests
|
||||
* `bun/` - `Bun` APIs tests, seperated by category, for example: `glob/` for `Bun.Glob` tests
|
||||
* `node/` - Node.js module tests, seperated by module, for example: `assert/` for `node:assert` tests
|
||||
* `bun/` - `Bun` APIs tests, separated by category, for example: `glob/` for `Bun.Glob` tests
|
||||
* `node/` - Node.js module tests, separated by module, for example: `assert/` for `node:assert` tests
|
||||
* `test/` - Vendored Node.js tests, taken from the Node.js repository (does not conform to Bun's test style)
|
||||
* `web/` - Web API tests, seperated by category, for example: `fetch/` for `Request` and `Response` tests
|
||||
* `web/` - Web API tests, separated by category, for example: `fetch/` for `Request` and `Response` tests
|
||||
* `third_party/` - npm package tests, to validate that basic usage works in Bun
|
||||
* `napi/` - N-API tests
|
||||
* `v8/` - V8 C++ API tests
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
---
|
||||
description: How Zig works with JavaScriptCore bindings generator
|
||||
globs:
|
||||
globs:
|
||||
alwaysApply: false
|
||||
---
|
||||
|
||||
# Bun's JavaScriptCore Class Bindings Generator
|
||||
|
||||
This document explains how Bun's class bindings generator works to bridge Zig and JavaScript code through JavaScriptCore (JSC).
|
||||
@@ -24,7 +25,7 @@ The `.classes.ts` files define the JavaScript API using a declarative approach:
|
||||
```typescript
|
||||
// Example: encoding.classes.ts
|
||||
define({
|
||||
name: "TextDecoder",
|
||||
name: "TextDecoder",
|
||||
constructor: true,
|
||||
JSType: "object",
|
||||
finalize: true,
|
||||
@@ -40,17 +41,18 @@ define({
|
||||
},
|
||||
fatal: {
|
||||
// Read-only property
|
||||
getter: true,
|
||||
getter: true,
|
||||
},
|
||||
ignoreBOM: {
|
||||
// Read-only property
|
||||
getter: true,
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
Each class definition specifies:
|
||||
|
||||
- The class name
|
||||
- Whether it has a constructor
|
||||
- JavaScript type (object, function, etc.)
|
||||
@@ -87,7 +89,7 @@ pub const TextDecoder = struct {
|
||||
// Fields
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Prototype methods - note return type includes JSError
|
||||
pub fn decode(
|
||||
this: *TextDecoder,
|
||||
@@ -96,23 +98,23 @@ pub const TextDecoder = struct {
|
||||
) bun.JSError!JSC.JSValue {
|
||||
// Implementation
|
||||
}
|
||||
|
||||
|
||||
// Getters
|
||||
pub fn getEncoding(this: *TextDecoder, globalObject: *JSGlobalObject) JSC.JSValue {
|
||||
return JSC.JSValue.createStringFromUTF8(globalObject, this.encoding);
|
||||
}
|
||||
|
||||
|
||||
pub fn getFatal(this: *TextDecoder, globalObject: *JSGlobalObject) JSC.JSValue {
|
||||
return JSC.JSValue.jsBoolean(this.fatal);
|
||||
}
|
||||
|
||||
|
||||
// Cleanup - note standard pattern of using deinit/deref
|
||||
fn deinit(this: *TextDecoder) void {
|
||||
// Release any retained resources
|
||||
// Free the pointer at the end.
|
||||
bun.destroy(this);
|
||||
}
|
||||
|
||||
|
||||
// Finalize - called by JS garbage collector. This should call deinit, or deref if reference counted.
|
||||
pub fn finalize(this: *TextDecoder) void {
|
||||
this.deinit();
|
||||
@@ -121,6 +123,7 @@ pub const TextDecoder = struct {
|
||||
```
|
||||
|
||||
Key components in the Zig file:
|
||||
|
||||
- The struct containing native state
|
||||
- `pub const js = JSC.Codegen.JS<ClassName>` to include generated code
|
||||
- Constructor and methods using `bun.JSError!JSValue` return type for proper error handling
|
||||
@@ -128,6 +131,7 @@ Key components in the Zig file:
|
||||
- Methods matching the JavaScript interface
|
||||
- Getters/setters for properties
|
||||
- Proper resource cleanup pattern with `deinit()` and `finalize()`
|
||||
- Update `src/bun.js/bindings/generated_classes_list.zig` to include the new class
|
||||
|
||||
## Code Generation System
|
||||
|
||||
@@ -140,6 +144,7 @@ The binding generator produces C++ code that connects JavaScript and Zig:
|
||||
5. **Property Caching**: Implements the caching system for properties
|
||||
|
||||
The generated C++ code includes:
|
||||
|
||||
- A JSC wrapper class (`JSTextDecoder`)
|
||||
- A prototype class (`JSTextDecoderPrototype`)
|
||||
- A constructor function (`JSTextDecoderConstructor`)
|
||||
@@ -152,28 +157,29 @@ The `CallFrame` object provides access to JavaScript execution context:
|
||||
|
||||
```zig
|
||||
pub fn decode(
|
||||
this: *TextDecoder,
|
||||
this: *TextDecoder,
|
||||
globalObject: *JSGlobalObject,
|
||||
callFrame: *JSC.CallFrame
|
||||
) bun.JSError!JSC.JSValue {
|
||||
// Get arguments
|
||||
const input = callFrame.argument(0);
|
||||
const options = callFrame.argument(1);
|
||||
|
||||
|
||||
// Get this value
|
||||
const thisValue = callFrame.thisValue();
|
||||
|
||||
|
||||
// Implementation with error handling
|
||||
if (input.isUndefinedOrNull()) {
|
||||
return globalObject.throw("Input cannot be null or undefined", .{});
|
||||
}
|
||||
|
||||
|
||||
// Return value or throw error
|
||||
return JSC.JSValue.jsString(globalObject, "result");
|
||||
}
|
||||
```
|
||||
|
||||
CallFrame methods include:
|
||||
|
||||
- `argument(i)`: Get the i-th argument
|
||||
- `argumentCount()`: Get the number of arguments
|
||||
- `thisValue()`: Get the `this` value
|
||||
@@ -201,17 +207,17 @@ JSC_DEFINE_CUSTOM_GETTER(TextDecoderPrototype__encodingGetterWrap, (...)) {
|
||||
auto throwScope = DECLARE_THROW_SCOPE(vm);
|
||||
JSTextDecoder* thisObject = jsCast<JSTextDecoder*>(JSValue::decode(encodedThisValue));
|
||||
JSC::EnsureStillAliveScope thisArg = JSC::EnsureStillAliveScope(thisObject);
|
||||
|
||||
|
||||
// Check for cached value and return if present
|
||||
if (JSValue cachedValue = thisObject->m_encoding.get())
|
||||
return JSValue::encode(cachedValue);
|
||||
|
||||
|
||||
// Get value from Zig implementation
|
||||
JSC::JSValue result = JSC::JSValue::decode(
|
||||
TextDecoderPrototype__getEncoding(thisObject->wrapped(), globalObject)
|
||||
);
|
||||
RETURN_IF_EXCEPTION(throwScope, {});
|
||||
|
||||
|
||||
// Store in cache for future access
|
||||
thisObject->m_encoding.set(vm, thisObject, result);
|
||||
RELEASE_AND_RETURN(throwScope, JSValue::encode(result));
|
||||
@@ -253,7 +259,7 @@ This system provides several key benefits:
|
||||
1. **Automatic Memory Management**: The JavaScriptCore GC tracks and manages these values
|
||||
2. **Proper Garbage Collection**: The WriteBarrier ensures values are properly visited during GC
|
||||
3. **Consistent Access**: Zig code can easily get/set these cached JS values
|
||||
4. **Performance**: Cached values avoid repeated computation or serialization
|
||||
4. **Performance**: Cached values avoid repeated computation or serialization
|
||||
|
||||
### Use Cases
|
||||
|
||||
@@ -281,7 +287,7 @@ Bun uses a consistent pattern for resource cleanup:
|
||||
pub fn deinit(this: *TextDecoder) void {
|
||||
// Release resources like strings
|
||||
this._encoding.deref(); // String deref pattern
|
||||
|
||||
|
||||
// Free any buffers
|
||||
if (this.buffer) |buffer| {
|
||||
bun.default_allocator.free(buffer);
|
||||
@@ -312,7 +318,7 @@ Bun uses `bun.JSError!JSValue` return type for proper error handling:
|
||||
|
||||
```zig
|
||||
pub fn decode(
|
||||
this: *TextDecoder,
|
||||
this: *TextDecoder,
|
||||
globalObject: *JSGlobalObject,
|
||||
callFrame: *JSC.CallFrame
|
||||
) bun.JSError!JSC.JSValue {
|
||||
@@ -320,13 +326,14 @@ pub fn decode(
|
||||
if (callFrame.argumentCount() < 1) {
|
||||
return globalObject.throw("Missing required argument", .{});
|
||||
}
|
||||
|
||||
|
||||
// Or returning a success value
|
||||
return JSC.JSValue.jsString(globalObject, "Success!");
|
||||
}
|
||||
```
|
||||
|
||||
This pattern allows Zig functions to:
|
||||
|
||||
1. Return JavaScript values on success
|
||||
2. Throw JavaScript exceptions on error
|
||||
3. Propagate errors automatically through the call stack
|
||||
@@ -339,7 +346,7 @@ The binding system includes robust error handling:
|
||||
// Example of type checking in generated code
|
||||
JSTextDecoder* thisObject = jsDynamicCast<JSTextDecoder*>(callFrame->thisValue());
|
||||
if (UNLIKELY(!thisObject)) {
|
||||
scope.throwException(lexicalGlobalObject,
|
||||
scope.throwException(lexicalGlobalObject,
|
||||
Bun::createInvalidThisError(lexicalGlobalObject, callFrame->thisValue(), "TextDecoder"_s));
|
||||
return {};
|
||||
}
|
||||
@@ -351,7 +358,7 @@ The binding system creates proper JavaScript prototype chains:
|
||||
|
||||
1. **Constructor**: JSTextDecoderConstructor with standard .prototype property
|
||||
2. **Prototype**: JSTextDecoderPrototype with methods and properties
|
||||
3. **Instances**: Each JSTextDecoder instance with __proto__ pointing to prototype
|
||||
3. **Instances**: Each JSTextDecoder instance with **proto** pointing to prototype
|
||||
|
||||
This ensures JavaScript inheritance works as expected:
|
||||
|
||||
@@ -360,7 +367,7 @@ This ensures JavaScript inheritance works as expected:
|
||||
void JSTextDecoderConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSTextDecoderPrototype* prototype)
|
||||
{
|
||||
Base::finishCreation(vm, 0, "TextDecoder"_s, PropertyAdditionMode::WithoutStructureTransition);
|
||||
|
||||
|
||||
// Set up the prototype chain
|
||||
putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
|
||||
ASSERT(inherits(info()));
|
||||
@@ -372,7 +379,7 @@ void JSTextDecoderConstructor::finishCreation(VM& vm, JSC::JSGlobalObject* globa
|
||||
The binding system is optimized for performance:
|
||||
|
||||
1. **Direct Pointer Access**: JavaScript objects maintain a direct pointer to Zig objects
|
||||
2. **Property Caching**: WriteBarrier caching avoids repeated native calls for stable properties
|
||||
2. **Property Caching**: WriteBarrier caching avoids repeated native calls for stable properties
|
||||
3. **Memory Management**: JSC garbage collection integrated with Zig memory management
|
||||
4. **Type Conversion**: Fast paths for common JavaScript/Zig type conversions
|
||||
|
||||
@@ -381,6 +388,7 @@ The binding system is optimized for performance:
|
||||
To create a new class binding in Bun:
|
||||
|
||||
1. **Define the class interface** in a `.classes.ts` file:
|
||||
|
||||
```typescript
|
||||
define({
|
||||
name: "MyClass",
|
||||
@@ -393,12 +401,13 @@ To create a new class binding in Bun:
|
||||
myProperty: {
|
||||
getter: true,
|
||||
cache: true,
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
2. **Implement the native functionality** in a `.zig` file:
|
||||
|
||||
```zig
|
||||
pub const MyClass = struct {
|
||||
// Generated bindings
|
||||
@@ -409,9 +418,9 @@ To create a new class binding in Bun:
|
||||
|
||||
// State
|
||||
value: []const u8,
|
||||
|
||||
|
||||
pub const new = bun.TrivialNew(@This());
|
||||
|
||||
|
||||
// Constructor
|
||||
pub fn constructor(
|
||||
globalObject: *JSGlobalObject,
|
||||
@@ -420,7 +429,7 @@ To create a new class binding in Bun:
|
||||
const arg = callFrame.argument(0);
|
||||
// Implementation
|
||||
}
|
||||
|
||||
|
||||
// Method
|
||||
pub fn myMethod(
|
||||
this: *MyClass,
|
||||
@@ -429,17 +438,17 @@ To create a new class binding in Bun:
|
||||
) bun.JSError!JSC.JSValue {
|
||||
// Implementation
|
||||
}
|
||||
|
||||
|
||||
// Getter
|
||||
pub fn getMyProperty(this: *MyClass, globalObject: *JSGlobalObject) JSC.JSValue {
|
||||
return JSC.JSValue.jsString(globalObject, this.value);
|
||||
}
|
||||
|
||||
|
||||
// Resource cleanup
|
||||
pub fn deinit(this: *MyClass) void {
|
||||
// Clean up resources
|
||||
}
|
||||
|
||||
|
||||
pub fn finalize(this: *MyClass) void {
|
||||
this.deinit();
|
||||
bun.destroy(this);
|
||||
@@ -474,11 +483,13 @@ For each Zig class, the system generates:
|
||||
### 3. Zig Bindings
|
||||
|
||||
- **External Function Declarations**:
|
||||
|
||||
```zig
|
||||
extern fn TextDecoderPrototype__decode(*TextDecoder, *JSC.JSGlobalObject, *JSC.CallFrame) callconv(JSC.conv) JSC.EncodedJSValue;
|
||||
```
|
||||
|
||||
- **Cached Value Accessors**:
|
||||
|
||||
```zig
|
||||
pub fn encodingGetCached(thisValue: JSC.JSValue) ?JSC.JSValue { ... }
|
||||
pub fn encodingSetCached(thisValue: JSC.JSValue, globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void { ... }
|
||||
|
||||
@@ -5,4 +5,6 @@
|
||||
#
|
||||
# git config blame.ignoreRevsFile .git-blame-ignore-revs
|
||||
#
|
||||
4ec410e0d7c5f6a712c323444edbf56b48d432d8 # make @import("bun") work in zig (#19096)
|
||||
4ec410e0d7c5f6a712c323444edbf56b48d432d8 # make @import("bun") work in zig (#19096)
|
||||
dedd433cbf2e2fe38e51bc166e08fbcc601ad42b # JSValue.undefined -> .jsUndefined()
|
||||
6b4662ff55f58247cc2fd22e85b4f9805b0950a5 # JSValue.jsUndefined() -> .js_undefined
|
||||
|
||||
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -54,3 +54,4 @@ test/js/node/test/common linguist-vendored
|
||||
test/js/bun/css/files linguist-vendored
|
||||
|
||||
.vscode/*.json linguist-language=JSON-with-Comments
|
||||
src/cli/init/tsconfig.default.json linguist-language=JSON-with-Comments
|
||||
17
.github/CODEOWNERS
vendored
17
.github/CODEOWNERS
vendored
@@ -1,18 +1,5 @@
|
||||
# Project
|
||||
.github/CODEOWNERS @Jarred-Sumner
|
||||
|
||||
# Build system
|
||||
CMakeLists.txt @Electroid
|
||||
cmake/ @Electroid
|
||||
scripts/ @Electroid
|
||||
|
||||
# CI
|
||||
.buildkite/ @Electroid
|
||||
.github/workflows/ @Electroid
|
||||
|
||||
# Debugger protocol
|
||||
packages/bun-inspector-protocol/ @Electroid
|
||||
packages/bun-debug-adapter-protocol/ @Electroid
|
||||
/.github/CODEOWNERS @Jarred-Sumner
|
||||
|
||||
# Tests
|
||||
test/expectations.txt @Jarred-Sumner
|
||||
/test/expectations.txt @Jarred-Sumner
|
||||
|
||||
1
.github/ISSUE_TEMPLATE/6-crash-report.yml
vendored
1
.github/ISSUE_TEMPLATE/6-crash-report.yml
vendored
@@ -2,6 +2,7 @@ name: Prefilled crash report
|
||||
description: Report a crash in Bun
|
||||
labels:
|
||||
- crash
|
||||
- needs triage
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
|
||||
35
.github/workflows/claude.yml
vendored
Normal file
35
.github/workflows/claude.yml
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
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.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: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Run Claude Code
|
||||
id: claude
|
||||
uses: anthropics/claude-code-action@beta
|
||||
with:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
|
||||
58
.github/workflows/codex-test-sync.yml
vendored
Normal file
58
.github/workflows/codex-test-sync.yml
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
name: Codex Test Sync
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [labeled, opened]
|
||||
|
||||
env:
|
||||
BUN_VERSION: "1.2.15"
|
||||
|
||||
jobs:
|
||||
sync-node-tests:
|
||||
runs-on: ubuntu-latest
|
||||
if: |
|
||||
(github.event.action == 'labeled' && github.event.label.name == 'codex') ||
|
||||
(github.event.action == 'opened' && contains(github.event.pull_request.labels.*.name, 'codex')) ||
|
||||
contains(github.head_ref, 'codex')
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Bun
|
||||
uses: ./.github/actions/setup-bun
|
||||
with:
|
||||
bun-version: ${{ env.BUN_VERSION }}
|
||||
|
||||
- name: Get changed files
|
||||
id: changed-files
|
||||
uses: tj-actions/changed-files@v44
|
||||
with:
|
||||
files: |
|
||||
test/js/node/test/parallel/**/*.{js,mjs,ts}
|
||||
test/js/node/test/sequential/**/*.{js,mjs,ts}
|
||||
|
||||
- name: Sync tests
|
||||
if: steps.changed-files.outputs.any_changed == 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
echo "Changed test files:"
|
||||
echo "${{ steps.changed-files.outputs.all_changed_files }}"
|
||||
|
||||
# Process each changed test file
|
||||
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
|
||||
# Extract test name from file path
|
||||
test_name=$(basename "$file" | sed 's/\.[^.]*$//')
|
||||
echo "Syncing test: $test_name"
|
||||
bun node:test:cp "$test_name"
|
||||
done
|
||||
|
||||
- name: Commit changes
|
||||
uses: stefanzweifel/git-auto-commit-action@v5
|
||||
with:
|
||||
commit_message: "Sync Node.js tests with upstream"
|
||||
5
.github/workflows/format.yml
vendored
5
.github/workflows/format.yml
vendored
@@ -44,7 +44,10 @@ jobs:
|
||||
version: 0.14.0
|
||||
- name: Zig Format
|
||||
run: |
|
||||
zig fmt src/**.zig
|
||||
bun scripts/zig-remove-unreferenced-top-level-decls.ts src/
|
||||
zig fmt src
|
||||
bun scripts/sortImports src
|
||||
zig fmt src
|
||||
- name: Commit
|
||||
uses: stefanzweifel/git-auto-commit-action@v5
|
||||
with:
|
||||
|
||||
41
.github/workflows/glob-sources.yml
vendored
Normal file
41
.github/workflows/glob-sources.yml
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
name: Glob Sources
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
|
||||
env:
|
||||
BUN_VERSION: "1.2.11"
|
||||
|
||||
jobs:
|
||||
glob-sources:
|
||||
name: Glob Sources
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Configure Git
|
||||
run: |
|
||||
git config --global core.autocrlf true
|
||||
git config --global core.ignorecase true
|
||||
git config --global core.precomposeUnicode true
|
||||
- name: Setup Bun
|
||||
uses: ./.github/actions/setup-bun
|
||||
with:
|
||||
bun-version: ${{ env.BUN_VERSION }}
|
||||
- name: Setup Dependencies
|
||||
run: |
|
||||
bun install
|
||||
- name: Glob sources
|
||||
run: bun scripts/glob-sources.mjs
|
||||
- name: Commit
|
||||
uses: stefanzweifel/git-auto-commit-action@v5
|
||||
with:
|
||||
commit_message: "`bun scripts/glob-sources.mjs`"
|
||||
|
||||
27
.github/workflows/labeled.yml
vendored
27
.github/workflows/labeled.yml
vendored
@@ -69,7 +69,6 @@ jobs:
|
||||
shell: bash
|
||||
run: |
|
||||
LABELS=$(bun scripts/read-issue.ts)
|
||||
echo "labels=$LABELS" >> $GITHUB_OUTPUT
|
||||
bun scripts/is-outdated.ts
|
||||
|
||||
if [[ -f "is-outdated.txt" ]]; then
|
||||
@@ -77,12 +76,19 @@ jobs:
|
||||
fi
|
||||
|
||||
if [[ -f "outdated.txt" ]]; then
|
||||
echo "oudated=$(cat outdated.txt)" >> $GITHUB_OUTPUT
|
||||
echo "outdated=$(cat outdated.txt)" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
if [[ -f "is-very-outdated.txt" ]]; then
|
||||
echo "is-very-outdated=true" >> $GITHUB_OUTPUT
|
||||
LABELS="$LABELS,old-version"
|
||||
else
|
||||
echo "is-very-outdated=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
echo "latest=$(cat LATEST)" >> $GITHUB_OUTPUT
|
||||
|
||||
rm -rf is-outdated.txt outdated.txt latest.txt
|
||||
echo "labels=$LABELS" >> $GITHUB_OUTPUT
|
||||
rm -rf is-outdated.txt outdated.txt latest.txt is-very-outdated.txt
|
||||
- name: Generate comment text with Sentry Link
|
||||
if: github.event.label.name == 'crash'
|
||||
# ignore if fail
|
||||
@@ -102,7 +108,14 @@ jobs:
|
||||
if [[ -f "sentry-id.txt" ]]; then
|
||||
echo "sentry-id=$(cat sentry-id.txt)" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Remove old labels
|
||||
uses: actions-cool/issues-helper@v3
|
||||
if: github.event.label.name == 'crash' && steps.add-labels.outputs.is-very-outdated == 'false'
|
||||
with:
|
||||
actions: "remove-labels"
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
issue-number: ${{ github.event.issue.number }}
|
||||
labels: old-version
|
||||
- name: Add labels
|
||||
uses: actions-cool/issues-helper@v3
|
||||
if: github.event.label.name == 'crash'
|
||||
@@ -119,7 +132,7 @@ jobs:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
issue-number: ${{ github.event.issue.number }}
|
||||
body: |
|
||||
@${{ github.event.issue.user.login }}, the latest version of Bun is v${{ steps.add-labels.outputs.latest }}, but this crash was reported on Bun v${{ steps.add-labels.outputs.oudated }}.
|
||||
@${{ github.event.issue.user.login }}, the latest version of Bun is v${{ steps.add-labels.outputs.latest }}, but this crash was reported on Bun v${{ steps.add-labels.outputs.outdated }}.
|
||||
|
||||
Are you able to reproduce this crash on the latest version of Bun?
|
||||
|
||||
@@ -134,7 +147,7 @@ jobs:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
issue-number: ${{ github.event.issue.number }}
|
||||
body: |
|
||||
@${{ github.event.issue.user.login }}, thank you for reporting this crash. The latest version of Bun is v${{ steps.add-labels.outputs.latest }}, but this crash was reported on Bun v${{ steps.add-labels.outputs.oudated }}.
|
||||
@${{ github.event.issue.user.login }}, thank you for reporting this crash. The latest version of Bun is v${{ steps.add-labels.outputs.latest }}, but this crash was reported on Bun v${{ steps.add-labels.outputs.outdated }}.
|
||||
|
||||
Are you able to reproduce this crash on the latest version of Bun?
|
||||
|
||||
|
||||
4
.github/workflows/update-cares.yml
vendored
4
.github/workflows/update-cares.yml
vendored
@@ -50,12 +50,12 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
LATEST_TAG_SHA=$(curl -sL "https://api.github.com/repos/c-ares/c-ares/git/ref/tags/$LATEST_TAG" | jq -r '.object.sha')
|
||||
LATEST_TAG_SHA=$(curl -sL "https://api.github.com/repos/c-ares/c-ares/git/refs/tags/$LATEST_TAG" | jq -r '.object.sha')
|
||||
if [ -z "$LATEST_TAG_SHA" ] || [ "$LATEST_TAG_SHA" = "null" ]; then
|
||||
echo "Error: Could not fetch SHA for tag $LATEST_TAG"
|
||||
exit 1
|
||||
fi
|
||||
LATEST_SHA=$(curl -sL "https://api.github.com/repos/c-ares/c-ares/git/ref/tags/$LATEST_TAG_SHA" | jq -r '.object.sha')
|
||||
LATEST_SHA=$(curl -sL "https://api.github.com/repos/c-ares/c-ares/git/tags/$LATEST_TAG_SHA" | jq -r '.object.sha')
|
||||
if [ -z "$LATEST_SHA" ] || [ "$LATEST_SHA" = "null" ]; then
|
||||
echo "Error: Could not fetch SHA for tag $LATEST_TAG @ $LATEST_TAG_SHA"
|
||||
exit 1
|
||||
|
||||
2
.github/workflows/update-libarchive.yml
vendored
2
.github/workflows/update-libarchive.yml
vendored
@@ -50,7 +50,7 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
LATEST_TAG_SHA=$(curl -sL "https://api.github.com/repos/libarchive/libarchive/git/ref/tags/$LATEST_TAG" | jq -r '.object.sha')
|
||||
LATEST_TAG_SHA=$(curl -sL "https://api.github.com/repos/libarchive/libarchive/git/refs/tags/$LATEST_TAG" | jq -r '.object.sha')
|
||||
if [ -z "$LATEST_TAG_SHA" ] || [ "$LATEST_TAG_SHA" = "null" ]; then
|
||||
echo "Error: Could not fetch SHA for tag $LATEST_TAG"
|
||||
exit 1
|
||||
|
||||
2
.github/workflows/update-libdeflate.yml
vendored
2
.github/workflows/update-libdeflate.yml
vendored
@@ -50,7 +50,7 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
LATEST_TAG_SHA=$(curl -sL "https://api.github.com/repos/ebiggers/libdeflate/git/ref/tags/$LATEST_TAG" | jq -r '.object.sha')
|
||||
LATEST_TAG_SHA=$(curl -sL "https://api.github.com/repos/ebiggers/libdeflate/git/refs/tags/$LATEST_TAG" | jq -r '.object.sha')
|
||||
if [ -z "$LATEST_TAG_SHA" ] || [ "$LATEST_TAG_SHA" = "null" ]; then
|
||||
echo "Error: Could not fetch SHA for tag $LATEST_TAG"
|
||||
exit 1
|
||||
|
||||
2
.github/workflows/update-lolhtml.yml
vendored
2
.github/workflows/update-lolhtml.yml
vendored
@@ -50,7 +50,7 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
LATEST_TAG_SHA=$(curl -sL "https://api.github.com/repos/cloudflare/lol-html/git/ref/tags/$LATEST_TAG" | jq -r '.object.sha')
|
||||
LATEST_TAG_SHA=$(curl -sL "https://api.github.com/repos/cloudflare/lol-html/git/refs/tags/$LATEST_TAG" | jq -r '.object.sha')
|
||||
if [ -z "$LATEST_TAG_SHA" ] || [ "$LATEST_TAG_SHA" = "null" ]; then
|
||||
echo "Error: Could not fetch SHA for tag $LATEST_TAG"
|
||||
exit 1
|
||||
|
||||
2
.github/workflows/update-lshpack.yml
vendored
2
.github/workflows/update-lshpack.yml
vendored
@@ -50,7 +50,7 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
LATEST_TAG_SHA=$(curl -sL "https://api.github.com/repos/litespeedtech/ls-hpack/git/ref/tags/$LATEST_TAG" | jq -r '.object.sha')
|
||||
LATEST_TAG_SHA=$(curl -sL "https://api.github.com/repos/litespeedtech/ls-hpack/git/refs/tags/$LATEST_TAG" | jq -r '.object.sha')
|
||||
if [ -z "$LATEST_TAG_SHA" ] || [ "$LATEST_TAG_SHA" = "null" ]; then
|
||||
echo "Error: Could not fetch SHA for tag $LATEST_TAG"
|
||||
exit 1
|
||||
|
||||
99
.github/workflows/update-zstd.yml
vendored
Normal file
99
.github/workflows/update-zstd.yml
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
name: Update zstd
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 1 * * 0"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
check-update:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Check zstd version
|
||||
id: check-version
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
# Extract the commit hash from the line after COMMIT
|
||||
CURRENT_VERSION=$(awk '/[[:space:]]*COMMIT[[:space:]]*$/{getline; gsub(/^[[:space:]]+|[[:space:]]+$/,"",$0); print}' cmake/targets/CloneZstd.cmake)
|
||||
|
||||
if [ -z "$CURRENT_VERSION" ]; then
|
||||
echo "Error: Could not find COMMIT line in CloneZstd.cmake"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Validate that it looks like a git hash
|
||||
if ! [[ $CURRENT_VERSION =~ ^[0-9a-f]{40}$ ]]; then
|
||||
echo "Error: Invalid git hash format in CloneZstd.cmake"
|
||||
echo "Found: $CURRENT_VERSION"
|
||||
echo "Expected: 40 character hexadecimal string"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT
|
||||
|
||||
LATEST_RELEASE=$(curl -sL https://api.github.com/repos/facebook/zstd/releases/latest)
|
||||
if [ -z "$LATEST_RELEASE" ]; then
|
||||
echo "Error: Failed to fetch latest release from GitHub API"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
LATEST_TAG=$(echo "$LATEST_RELEASE" | jq -r '.tag_name')
|
||||
if [ -z "$LATEST_TAG" ] || [ "$LATEST_TAG" = "null" ]; then
|
||||
echo "Error: Could not extract tag name from GitHub API response"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
LATEST_TAG_SHA=$(curl -sL "https://api.github.com/repos/facebook/zstd/git/refs/tags/$LATEST_TAG" | jq -r '.object.sha')
|
||||
if [ -z "$LATEST_TAG_SHA" ] || [ "$LATEST_TAG_SHA" = "null" ]; then
|
||||
echo "Error: Could not fetch SHA for tag $LATEST_TAG"
|
||||
exit 1
|
||||
fi
|
||||
LATEST_SHA=$(curl -sL "https://api.github.com/repos/facebook/zstd/git/tags/$LATEST_TAG_SHA" | jq -r '.object.sha')
|
||||
if [ -z "$LATEST_SHA" ] || [ "$LATEST_SHA" = "null" ]; then
|
||||
echo "Error: Could not fetch SHA for tag $LATEST_TAG @ $LATEST_TAG_SHA"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! [[ $LATEST_SHA =~ ^[0-9a-f]{40}$ ]]; then
|
||||
echo "Error: Invalid SHA format received from GitHub"
|
||||
echo "Found: $LATEST_SHA"
|
||||
echo "Expected: 40 character hexadecimal string"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "latest=$LATEST_SHA" >> $GITHUB_OUTPUT
|
||||
echo "tag=$LATEST_TAG" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Update version if needed
|
||||
if: success() && steps.check-version.outputs.current != steps.check-version.outputs.latest
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# Handle multi-line format where COMMIT and its value are on separate lines
|
||||
sed -i -E '/[[:space:]]*COMMIT[[:space:]]*$/{n;s/[[:space:]]*([0-9a-f]+)[[:space:]]*$/ ${{ steps.check-version.outputs.latest }}/}' cmake/targets/CloneZstd.cmake
|
||||
|
||||
- name: Create Pull Request
|
||||
if: success() && steps.check-version.outputs.current != steps.check-version.outputs.latest
|
||||
uses: peter-evans/create-pull-request@v4
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
add-paths: |
|
||||
cmake/targets/CloneZstd.cmake
|
||||
commit-message: "deps: update zstd to ${{ steps.check-version.outputs.tag }} (${{ steps.check-version.outputs.latest }})"
|
||||
title: "deps: update zstd to ${{ steps.check-version.outputs.tag }}"
|
||||
delete-branch: true
|
||||
branch: deps/update-zstd-${{ github.run_number }}
|
||||
body: |
|
||||
## What does this PR do?
|
||||
|
||||
Updates zstd to version ${{ steps.check-version.outputs.tag }}
|
||||
|
||||
Compare: https://github.com/facebook/zstd/compare/${{ steps.check-version.outputs.current }}...${{ steps.check-version.outputs.latest }}
|
||||
|
||||
Auto-updated by [this workflow](https://github.com/oven-sh/bun/actions/workflows/update-zstd.yml)
|
||||
17
.lldbinit
17
.lldbinit
@@ -1,16 +1 @@
|
||||
# Tell LLDB what to do when the debugged process receives SIGPWR: pass it through to the process
|
||||
# (-p), but do not stop the process (-s) or notify the user (-n).
|
||||
#
|
||||
# JSC's garbage collector sends this signal (as configured by Bun WebKit in
|
||||
# Thread::initializePlatformThreading() in ThreadingPOSIX.cpp) to the JS thread to suspend or resume
|
||||
# it. So stopping the process would just create noise when debugging any long-running script.
|
||||
process handle -p true -s false -n false SIGPWR
|
||||
|
||||
command script import misctools/lldb/lldb_pretty_printers.py
|
||||
type category enable zig.lang
|
||||
type category enable zig.std
|
||||
|
||||
command script import misctools/lldb/lldb_webkit.py
|
||||
|
||||
command script delete btjs
|
||||
command alias btjs p {printf("gathering btjs trace...\n");printf("%s\n", (char*)dumpBtjsTrace())}
|
||||
command source -C -s true -e true misctools/lldb/init.lldb
|
||||
|
||||
931
.vscode/launch.json
generated
vendored
931
.vscode/launch.json
generated
vendored
File diff suppressed because it is too large
Load Diff
245
CLAUDE.md
Normal file
245
CLAUDE.md
Normal file
@@ -0,0 +1,245 @@
|
||||
This is the Bun repository - an all-in-one JavaScript runtime & toolkit designed for speed, with a bundler, test runner, and Node.js-compatible package manager. It's written primarily in Zig with C++ for JavaScriptCore integration, powered by WebKit's JavaScriptCore engine.
|
||||
|
||||
## Building and Running Bun
|
||||
|
||||
### Build Commands
|
||||
|
||||
- **Build debug version**: `bun bd` or `bun run build:debug`
|
||||
- Creates a debug build at `./build/debug/bun-debug`
|
||||
- Compilation takes ~2.5 minutes
|
||||
- **Run tests with your debug build**: `bun bd test <test-file>`
|
||||
- **CRITICAL**: Never use `bun test` directly - it won't include your changes
|
||||
- **Run any command with debug build**: `bun bd <command>`
|
||||
|
||||
### Other Build Variants
|
||||
|
||||
- `bun run build:release` - Release build
|
||||
|
||||
Address sanitizer is enabled by default in debug builds of Bun.
|
||||
|
||||
## Testing
|
||||
|
||||
### Running Tests
|
||||
|
||||
- **Single test file**: `bun bd test test/js/bun/http/serve.test.ts`
|
||||
- **Fuzzy match test file**: `bun bd test http/serve.test.ts`
|
||||
- **With filter**: `bun bd test test/js/bun/http/serve.test.ts -t "should handle"`
|
||||
|
||||
### Test Organization
|
||||
|
||||
- `test/js/bun/` - Bun-specific API tests (http, crypto, ffi, shell, etc.)
|
||||
- `test/js/node/` - Node.js compatibility tests
|
||||
- `test/js/web/` - Web API tests (fetch, WebSocket, streams, etc.)
|
||||
- `test/cli/` - CLI command tests (install, run, test, etc.)
|
||||
- `test/regression/issue/` - Regression tests (create one per bug fix)
|
||||
- `test/bundler/` - Bundler and transpiler tests
|
||||
- `test/integration/` - End-to-end integration tests
|
||||
- `test/napi/` - N-API compatibility tests
|
||||
- `test/v8/` - V8 C++ API compatibility tests
|
||||
|
||||
### Writing Tests
|
||||
|
||||
Tests use Bun's Jest-compatible test runner with proper test fixtures:
|
||||
|
||||
```typescript
|
||||
import { test, expect } from "bun:test";
|
||||
import { bunEnv, bunExe, tempDirWithFiles } from "harness";
|
||||
|
||||
test("my feature", async () => {
|
||||
// Create temp directory with test files
|
||||
const dir = tempDirWithFiles("test-prefix", {
|
||||
"index.js": `console.log("hello");`,
|
||||
});
|
||||
|
||||
// Spawn Bun process
|
||||
await using proc = Bun.spawn({
|
||||
cmd: [bunExe(), "index.js"],
|
||||
env: bunEnv,
|
||||
cwd: dir,
|
||||
});
|
||||
|
||||
const [stdout, stderr, exitCode] = await Promise.all([
|
||||
new Response(proc.stdout).text(),
|
||||
new Response(proc.stderr).text(),
|
||||
proc.exited,
|
||||
]);
|
||||
|
||||
expect(exitCode).toBe(0);
|
||||
expect(stdout).toBe("hello\n");
|
||||
});
|
||||
```
|
||||
|
||||
## Code Architecture
|
||||
|
||||
### Language Structure
|
||||
|
||||
- **Zig code** (`src/*.zig`): Core runtime, JavaScript bindings, package manager
|
||||
- **C++ code** (`src/bun.js/bindings/*.cpp`): JavaScriptCore bindings, Web APIs
|
||||
- **TypeScript** (`src/js/`): Built-in JavaScript modules with special syntax (see JavaScript Modules section)
|
||||
- **Generated code**: Many files are auto-generated from `.classes.ts` and other sources
|
||||
|
||||
### Core Source Organization
|
||||
|
||||
#### Runtime Core (`src/`)
|
||||
|
||||
- `bun.zig` - Main entry point
|
||||
- `cli.zig` - CLI command orchestration
|
||||
- `js_parser.zig`, `js_lexer.zig`, `js_printer.zig` - JavaScript parsing/printing
|
||||
- `transpiler.zig` - Wrapper around js_parser with sourcemap support
|
||||
- `resolver/` - Module resolution system
|
||||
- `allocators/` - Custom memory allocators for performance
|
||||
|
||||
#### JavaScript Runtime (`src/bun.js/`)
|
||||
|
||||
- `bindings/` - C++ JavaScriptCore bindings
|
||||
- Generated classes from `.classes.ts` files
|
||||
- Manual bindings for complex APIs
|
||||
- `api/` - Bun-specific APIs
|
||||
- `server.zig` - HTTP server implementation
|
||||
- `FFI.zig` - Foreign Function Interface
|
||||
- `crypto.zig` - Cryptographic operations
|
||||
- `glob.zig` - File pattern matching
|
||||
- `node/` - Node.js compatibility layer
|
||||
- Module implementations (fs, path, crypto, etc.)
|
||||
- Process and Buffer APIs
|
||||
- `webcore/` - Web API implementations
|
||||
- `fetch.zig` - Fetch API
|
||||
- `streams.zig` - Web Streams
|
||||
- `Blob.zig`, `Response.zig`, `Request.zig`
|
||||
- `event_loop/` - Event loop and task management
|
||||
|
||||
#### Build Tools & Package Manager
|
||||
|
||||
- `src/bundler/` - JavaScript bundler
|
||||
- Advanced tree-shaking
|
||||
- CSS processing
|
||||
- HTML handling
|
||||
- `src/install/` - Package manager
|
||||
- `lockfile/` - Lockfile handling
|
||||
- `npm.zig` - npm registry client
|
||||
- `lifecycle_script_runner.zig` - Package scripts
|
||||
|
||||
#### Other Key Components
|
||||
|
||||
- `src/shell/` - Cross-platform shell implementation
|
||||
- `src/css/` - CSS parser and processor
|
||||
- `src/http/` - HTTP client implementation
|
||||
- `websocket_client/` - WebSocket client (including deflate support)
|
||||
- `src/sql/` - SQL database integrations
|
||||
- `src/bake/` - Server-side rendering framework
|
||||
|
||||
### JavaScript Class Implementation (C++)
|
||||
|
||||
When implementing JavaScript classes in C++:
|
||||
|
||||
1. Create three classes if there's a public constructor:
|
||||
|
||||
- `class Foo : public JSC::JSDestructibleObject` (if has C++ fields)
|
||||
- `class FooPrototype : public JSC::JSNonFinalObject`
|
||||
- `class FooConstructor : public JSC::InternalFunction`
|
||||
|
||||
2. Define properties using HashTableValue arrays
|
||||
3. Add iso subspaces for classes with C++ fields
|
||||
4. Cache structures in ZigGlobalObject
|
||||
|
||||
## Development Workflow
|
||||
|
||||
### Code Formatting
|
||||
|
||||
- `bun run prettier` - Format JS/TS files
|
||||
- `bun run zig-format` - Format Zig files
|
||||
- `bun run clang-format` - Format C++ files
|
||||
|
||||
### Watching for Changes
|
||||
|
||||
- `bun run watch` - Incremental Zig compilation with error checking
|
||||
- `bun run watch-windows` - Windows-specific watch mode
|
||||
|
||||
### Code Generation
|
||||
|
||||
Code generation happens automatically as part of the build process. The main scripts are:
|
||||
|
||||
- `src/codegen/generate-classes.ts` - Generates Zig & C++ bindings from `*.classes.ts` files
|
||||
- `src/codegen/generate-jssink.ts` - Generates stream-related classes
|
||||
- `src/codegen/bundle-modules.ts` - Bundles built-in modules like `node:fs`
|
||||
- `src/codegen/bundle-functions.ts` - Bundles global functions like `ReadableStream`
|
||||
|
||||
In development, bundled modules can be reloaded without rebuilding Zig by running `bun run build`.
|
||||
|
||||
## JavaScript Modules (`src/js/`)
|
||||
|
||||
Built-in JavaScript modules use special syntax and are organized as:
|
||||
|
||||
- `node/` - Node.js compatibility modules (`node:fs`, `node:path`, etc.)
|
||||
- `bun/` - Bun-specific modules (`bun:ffi`, `bun:sqlite`, etc.)
|
||||
- `thirdparty/` - NPM modules we replace (like `ws`)
|
||||
- `internal/` - Internal modules not exposed to users
|
||||
- `builtins/` - Core JavaScript builtins (streams, console, etc.)
|
||||
|
||||
### Special Syntax in Built-in Modules
|
||||
|
||||
1. **`$` prefix** - Access to private properties and JSC intrinsics:
|
||||
|
||||
```js
|
||||
const arr = $Array.from(...); // Private global
|
||||
map.$set(...); // Private method
|
||||
const arr2 = $newArrayWithSize(5); // JSC intrinsic
|
||||
```
|
||||
|
||||
2. **`require()`** - Must use string literals, resolved at compile time:
|
||||
|
||||
```js
|
||||
const fs = require("fs"); // Directly loads by numeric ID
|
||||
```
|
||||
|
||||
3. **Debug helpers**:
|
||||
|
||||
- `$debug()` - Like console.log but stripped in release builds
|
||||
- `$assert()` - Assertions stripped in release builds
|
||||
- `if($debug) {}` - Check if debug env var is set
|
||||
|
||||
4. **Platform detection**: `process.platform` and `process.arch` are inlined and dead-code eliminated
|
||||
|
||||
5. **Export syntax**: Use `export default` which gets converted to a return statement:
|
||||
```js
|
||||
export default {
|
||||
readFile,
|
||||
writeFile,
|
||||
};
|
||||
```
|
||||
|
||||
Note: These are NOT ES modules. The preprocessor converts `$` to `@` (JSC's actual syntax) and handles the special functions.
|
||||
|
||||
## CI
|
||||
|
||||
Bun uses BuildKite for CI. To get the status of a PR, you can use the following command:
|
||||
|
||||
```bash
|
||||
bun ci
|
||||
```
|
||||
|
||||
## Important Development Notes
|
||||
|
||||
1. **Never use `bun test` or `bun <file>` directly** - always use `bun bd test` or `bun bd <command>`. `bun bd` compiles & runs the debug build.
|
||||
2. **Use `await using`** for proper resource cleanup with Bun APIs (Bun.spawn, Bun.serve, Bun.connect, etc.)
|
||||
3. **Follow existing code style** - check neighboring files for patterns
|
||||
4. **Create regression tests** in `test/regression/issue/` when fixing bugs
|
||||
5. **Use absolute paths** - Always use absolute paths in file operations
|
||||
6. **Avoid shell commands** - Don't use `find` or `grep` in tests; use Bun's Glob and built-in tools
|
||||
7. **Memory management** - In Zig code, be careful with allocators and use defer for cleanup
|
||||
8. **Cross-platform** - Test on macOS, Linux, and Windows when making platform-specific changes
|
||||
9. **Debug builds** - Use `BUN_DEBUG_QUIET_LOGS=1` to disable debug logging, or `BUN_DEBUG_<scope>=1` to enable specific scopes
|
||||
10. **Transpiled source** - Find transpiled files in `/tmp/bun-debug-src/` for debugging
|
||||
|
||||
## Key APIs and Features
|
||||
|
||||
### Bun-Specific APIs
|
||||
|
||||
- **Bun.serve()** - High-performance HTTP server
|
||||
- **Bun.spawn()** - Process spawning with better performance than Node.js
|
||||
- **Bun.file()** - Fast file I/O operations
|
||||
- **Bun.write()** - Unified API for writing to files, stdout, etc.
|
||||
- **Bun.$ (Shell)** - Cross-platform shell scripting
|
||||
- **Bun.SQLite** - Native SQLite integration
|
||||
- **Bun.FFI** - Call native libraries from JavaScript
|
||||
- **Bun.Glob** - Fast file pattern matching
|
||||
@@ -144,6 +144,14 @@ $ bun bd test foo.test.ts
|
||||
$ bun bd ./foo.ts
|
||||
```
|
||||
|
||||
Bun generally takes about 2.5 minutes to compile a debug build when there are Zig changes. If your development workflow is "change one line, save, rebuild", you will spend too much time waiting for the build to finish. Instead:
|
||||
|
||||
- Batch up your changes
|
||||
- Ensure zls is running with incremental watching for LSP errors (if you use VSCode and install Zig and run `bun run build` once to download Zig, this should just work)
|
||||
- Prefer using the debugger ("CodeLLDB" in VSCode) to step through the code.
|
||||
- Use debug logs. `BUN_DEBUG_<scope>=1` will enable debug logging for the corresponding `Output.scoped(.<scope>, false)` logs. You can also set `BUN_DEBUG_QUIET_LOGS=1` to disable all debug logging that isn't explicitly enabled. To dump debug lgos into a file, `BUN_DEBUG=<path-to-file>.log`. Debug logs are aggressively removed in release builds.
|
||||
- src/js/\*\*.ts changes are pretty much instant to rebuild. C++ changes are a bit slower, but still much faster than the Zig code (Zig is one compilation unit, C++ is many).
|
||||
|
||||
## Code generation scripts
|
||||
|
||||
Several code generation scripts are used during Bun's build process. These are run automatically when changes are made to certain files.
|
||||
@@ -179,6 +187,7 @@ To run a release build from a pull request, you can use the `bun-pr` npm package
|
||||
bunx bun-pr <pr-number>
|
||||
bunx bun-pr <branch-name>
|
||||
bunx bun-pr "https://github.com/oven-sh/bun/pull/1234566"
|
||||
bunx bun-pr --asan <pr-number> # Linux x64 only
|
||||
```
|
||||
|
||||
This will download the release build from the pull request and add it to `$PATH` as `bun-${pr-number}`. You can then run the build with `bun-${pr-number}`.
|
||||
@@ -189,24 +198,18 @@ bun-1234566 --version
|
||||
|
||||
This works by downloading the release build from the GitHub Actions artifacts on the linked pull request. You may need the `gh` CLI installed to authenticate with GitHub.
|
||||
|
||||
## Valgrind
|
||||
## AddressSanitizer
|
||||
|
||||
On Linux, valgrind can help find memory issues.
|
||||
[AddressSanitizer](https://en.wikipedia.org/wiki/AddressSanitizer) helps find memory issues, and is enabled by default in debug builds of Bun on Linux and macOS. This includes the Zig code and all dependencies. It makes the Zig code take about 2x longer to build, if that's stopping you from being productive you can disable it by setting `-Denable_asan=$<IF:$<BOOL:${ENABLE_ASAN}>,true,false>` to `-Denable_asan=false` in the `cmake/targets/BuildBun.cmake` file, but generally we recommend batching your changes up between builds.
|
||||
|
||||
Keep in mind:
|
||||
|
||||
- JavaScriptCore doesn't support valgrind. It will report spurious errors.
|
||||
- Valgrind is slow
|
||||
- Mimalloc will sometimes cause spurious errors when debug build is enabled
|
||||
|
||||
You'll need a very recent version of Valgrind due to DWARF 5 debug symbols. You may need to manually compile Valgrind instead of using it from your Linux package manager.
|
||||
|
||||
`--fair-sched=try` is necessary if running multithreaded code in Bun (such as the bundler). Otherwise it will hang.
|
||||
To build a release build with Address Sanitizer, run:
|
||||
|
||||
```bash
|
||||
$ valgrind --fair-sched=try --track-origins=yes bun-debug <args>
|
||||
$ bun run build:release:asan
|
||||
```
|
||||
|
||||
In CI, we run our test suite with at least one target that is built with Address Sanitizer.
|
||||
|
||||
## Building WebKit locally + Debug mode of JSC
|
||||
|
||||
WebKit is not cloned by default (to save time and disk space). To clone and build WebKit locally, run:
|
||||
|
||||
2
Makefile
2
Makefile
@@ -482,7 +482,7 @@ STATIC_MUSL_FLAG ?=
|
||||
WRAP_SYMBOLS_ON_LINUX =
|
||||
|
||||
ifeq ($(OS_NAME), linux)
|
||||
WRAP_SYMBOLS_ON_LINUX = -Wl,--wrap=fcntl -Wl,--wrap=fcntl64 -Wl,--wrap=stat64 -Wl,--wrap=pow -Wl,--wrap=exp -Wl,--wrap=log -Wl,--wrap=log2 \
|
||||
WRAP_SYMBOLS_ON_LINUX = -Wl,--wrap=fcntl -Wl,--wrap=fcntl64 -Wl,--wrap=stat64 -Wl,--wrap=pow -Wl,--wrap=exp -Wl,--wrap=exp2 -Wl,--wrap=log -Wl,--wrap=log2 \
|
||||
-Wl,--wrap=lstat \
|
||||
-Wl,--wrap=stat \
|
||||
-Wl,--wrap=fstat \
|
||||
|
||||
264
README.md
264
README.md
@@ -47,6 +47,8 @@ Bun supports Linux (x64 & arm64), macOS (x64 & Apple Silicon) and Windows (x64).
|
||||
|
||||
> **Linux users** — Kernel version 5.6 or higher is strongly recommended, but the minimum is 5.1.
|
||||
|
||||
> **x64 users** — if you see "illegal instruction" or similar errors, check our [CPU requirements](https://bun.sh/docs/installation#cpu-requirements-and-baseline-builds)
|
||||
|
||||
```sh
|
||||
# with install script (recommended)
|
||||
curl -fsSL https://bun.sh/install | bash
|
||||
@@ -96,10 +98,14 @@ bun upgrade --canary
|
||||
- [`bun init`](https://bun.sh/docs/cli/init)
|
||||
- [`bun create`](https://bun.sh/docs/cli/bun-create)
|
||||
|
||||
- CLI
|
||||
|
||||
- [`bun upgrade`](https://bun.sh/docs/cli/bun-upgrade)
|
||||
|
||||
- Runtime
|
||||
|
||||
- [`bun run`](https://bun.sh/docs/cli/run)
|
||||
- [File types](https://bun.sh/docs/runtime/loaders)
|
||||
- [File types (Loaders)](https://bun.sh/docs/runtime/loaders)
|
||||
- [TypeScript](https://bun.sh/docs/runtime/typescript)
|
||||
- [JSX](https://bun.sh/docs/runtime/jsx)
|
||||
- [Environment variables](https://bun.sh/docs/runtime/env)
|
||||
@@ -108,12 +114,12 @@ bun upgrade --canary
|
||||
- [Node.js compatibility](https://bun.sh/docs/runtime/nodejs-apis)
|
||||
- [Single-file executable](https://bun.sh/docs/bundler/executables)
|
||||
- [Plugins](https://bun.sh/docs/runtime/plugins)
|
||||
- [Watch mode](https://bun.sh/docs/runtime/hot)
|
||||
- [Watch mode / Hot Reloading](https://bun.sh/docs/runtime/hot)
|
||||
- [Module resolution](https://bun.sh/docs/runtime/modules)
|
||||
- [Auto-install](https://bun.sh/docs/runtime/autoimport)
|
||||
- [bunfig.toml](https://bun.sh/docs/runtime/bunfig)
|
||||
- [Debugger](https://bun.sh/docs/runtime/debugger)
|
||||
- [Framework API](https://bun.sh/docs/runtime/framework)
|
||||
- [$ Shell](https://bun.sh/docs/runtime/shell)
|
||||
|
||||
- Package manager
|
||||
|
||||
@@ -122,7 +128,12 @@ bun upgrade --canary
|
||||
- [`bun remove`](https://bun.sh/docs/cli/remove)
|
||||
- [`bun update`](https://bun.sh/docs/cli/update)
|
||||
- [`bun link`](https://bun.sh/docs/cli/link)
|
||||
- [`bun unlink`](https://bun.sh/docs/cli/unlink)
|
||||
- [`bun pm`](https://bun.sh/docs/cli/pm)
|
||||
- [`bun outdated`](https://bun.sh/docs/cli/outdated)
|
||||
- [`bun publish`](https://bun.sh/docs/cli/publish)
|
||||
- [`bun patch`](https://bun.sh/docs/install/patch)
|
||||
- [`bun patch-commit`](https://bun.sh/docs/cli/patch-commit)
|
||||
- [Global cache](https://bun.sh/docs/install/cache)
|
||||
- [Workspaces](https://bun.sh/docs/install/workspaces)
|
||||
- [Lifecycle scripts](https://bun.sh/docs/install/lifecycle)
|
||||
@@ -130,6 +141,7 @@ bun upgrade --canary
|
||||
- [Lockfile](https://bun.sh/docs/install/lockfile)
|
||||
- [Scopes and registries](https://bun.sh/docs/install/registries)
|
||||
- [Overrides and resolutions](https://bun.sh/docs/install/overrides)
|
||||
- [`.npmrc`](https://bun.sh/docs/install/npmrc)
|
||||
|
||||
- Bundler
|
||||
|
||||
@@ -138,6 +150,11 @@ bun upgrade --canary
|
||||
- [Plugins](https://bun.sh/docs/bundler/plugins)
|
||||
- [Macros](https://bun.sh/docs/bundler/macros)
|
||||
- [vs esbuild](https://bun.sh/docs/bundler/vs-esbuild)
|
||||
- [Single-file executable](https://bun.sh/docs/bundler/executables)
|
||||
- [CSS](https://bun.sh/docs/bundler/css)
|
||||
- [HTML](https://bun.sh/docs/bundler/html)
|
||||
- [Hot Module Replacement (HMR)](https://bun.sh/docs/bundler/hmr)
|
||||
- [Full-stack with HTML imports](https://bun.sh/docs/bundler/fullstack)
|
||||
|
||||
- Test runner
|
||||
|
||||
@@ -150,6 +167,10 @@ bun upgrade --canary
|
||||
- [Dates and times](https://bun.sh/docs/test/time)
|
||||
- [DOM testing](https://bun.sh/docs/test/dom)
|
||||
- [Code coverage](https://bun.sh/docs/test/coverage)
|
||||
- [Configuration](https://bun.sh/docs/test/configuration)
|
||||
- [Discovery](https://bun.sh/docs/test/discovery)
|
||||
- [Reporters](https://bun.sh/docs/test/reporters)
|
||||
- [Runtime Behavior](https://bun.sh/docs/test/runtime-behavior)
|
||||
|
||||
- Package runner
|
||||
|
||||
@@ -157,219 +178,235 @@ bun upgrade --canary
|
||||
|
||||
- API
|
||||
|
||||
- [HTTP server](https://bun.sh/docs/api/http)
|
||||
- [HTTP server (`Bun.serve`)](https://bun.sh/docs/api/http)
|
||||
- [WebSockets](https://bun.sh/docs/api/websockets)
|
||||
- [Workers](https://bun.sh/docs/api/workers)
|
||||
- [Binary data](https://bun.sh/docs/api/binary-data)
|
||||
- [Streams](https://bun.sh/docs/api/streams)
|
||||
- [File I/O](https://bun.sh/docs/api/file-io)
|
||||
- [File I/O (`Bun.file`)](https://bun.sh/docs/api/file-io)
|
||||
- [import.meta](https://bun.sh/docs/api/import-meta)
|
||||
- [SQLite](https://bun.sh/docs/api/sqlite)
|
||||
- [SQLite (`bun:sqlite`)](https://bun.sh/docs/api/sqlite)
|
||||
- [PostgreSQL (`Bun.sql`)](https://bun.sh/docs/api/sql)
|
||||
- [Redis (`Bun.redis`)](https://bun.sh/docs/api/redis)
|
||||
- [S3 Client (`Bun.s3`)](https://bun.sh/docs/api/s3)
|
||||
- [FileSystemRouter](https://bun.sh/docs/api/file-system-router)
|
||||
- [TCP sockets](https://bun.sh/docs/api/tcp)
|
||||
- [UDP sockets](https://bun.sh/docs/api/udp)
|
||||
- [Globals](https://bun.sh/docs/api/globals)
|
||||
- [$ Shell](https://bun.sh/docs/runtime/shell)
|
||||
- [Child processes](https://bun.sh/docs/api/spawn)
|
||||
- [Transpiler](https://bun.sh/docs/api/transpiler)
|
||||
- [Child processes (spawn)](https://bun.sh/docs/api/spawn)
|
||||
- [Transpiler (`Bun.Transpiler`)](https://bun.sh/docs/api/transpiler)
|
||||
- [Hashing](https://bun.sh/docs/api/hashing)
|
||||
- [Colors (`Bun.color`)](https://bun.sh/docs/api/color)
|
||||
- [Console](https://bun.sh/docs/api/console)
|
||||
- [FFI](https://bun.sh/docs/api/ffi)
|
||||
- [FFI (`bun:ffi`)](https://bun.sh/docs/api/ffi)
|
||||
- [C Compiler (`bun:ffi` cc)](https://bun.sh/docs/api/cc)
|
||||
- [HTMLRewriter](https://bun.sh/docs/api/html-rewriter)
|
||||
- [Testing](https://bun.sh/docs/api/test)
|
||||
- [Testing (`bun:test`)](https://bun.sh/docs/api/test)
|
||||
- [Cookies (`Bun.Cookie`)](https://bun.sh/docs/api/cookie)
|
||||
- [Utils](https://bun.sh/docs/api/utils)
|
||||
- [Node-API](https://bun.sh/docs/api/node-api)
|
||||
- [Glob](https://bun.sh/docs/api/glob)
|
||||
- [Semver](https://bun.sh/docs/api/semver)
|
||||
|
||||
- Project
|
||||
- [Roadmap](https://bun.sh/docs/project/roadmap)
|
||||
- [Benchmarking](https://bun.sh/docs/project/benchmarking)
|
||||
- [Contributing](https://bun.sh/docs/project/contributing)
|
||||
- [Building Windows](https://bun.sh/docs/project/building-windows)
|
||||
- [License](https://bun.sh/docs/project/licensing)
|
||||
- [Glob (`Bun.Glob`)](https://bun.sh/docs/api/glob)
|
||||
- [Semver (`Bun.semver`)](https://bun.sh/docs/api/semver)
|
||||
- [DNS](https://bun.sh/docs/api/dns)
|
||||
- [fetch API extensions](https://bun.sh/docs/api/fetch)
|
||||
|
||||
## Guides
|
||||
|
||||
- Binary
|
||||
|
||||
- [Convert a Blob to a DataView](https://bun.sh/guides/binary/blob-to-dataview)
|
||||
- [Convert a Blob to a ReadableStream](https://bun.sh/guides/binary/blob-to-stream)
|
||||
- [Convert a Blob to a string](https://bun.sh/guides/binary/blob-to-string)
|
||||
- [Convert a Blob to a Uint8Array](https://bun.sh/guides/binary/blob-to-typedarray)
|
||||
- [Convert a Blob to an ArrayBuffer](https://bun.sh/guides/binary/blob-to-arraybuffer)
|
||||
- [Convert a Buffer to a blob](https://bun.sh/guides/binary/buffer-to-blob)
|
||||
- [Convert a Buffer to a ReadableStream](https://bun.sh/guides/binary/buffer-to-readablestream)
|
||||
- [Convert a Blob to a DataView](https://bun.sh/guides/binary/blob-to-dataview)
|
||||
- [Convert a Buffer to a string](https://bun.sh/guides/binary/buffer-to-string)
|
||||
- [Convert a Buffer to a Uint8Array](https://bun.sh/guides/binary/buffer-to-typedarray)
|
||||
- [Convert a Buffer to an ArrayBuffer](https://bun.sh/guides/binary/buffer-to-arraybuffer)
|
||||
- [Convert a Blob to a ReadableStream](https://bun.sh/guides/binary/blob-to-stream)
|
||||
- [Convert a Blob to a Uint8Array](https://bun.sh/guides/binary/blob-to-typedarray)
|
||||
- [Convert a DataView to a string](https://bun.sh/guides/binary/dataview-to-string)
|
||||
- [Convert a Uint8Array to a Blob](https://bun.sh/guides/binary/typedarray-to-blob)
|
||||
- [Convert a Uint8Array to a Buffer](https://bun.sh/guides/binary/typedarray-to-buffer)
|
||||
- [Convert a Uint8Array to a DataView](https://bun.sh/guides/binary/typedarray-to-dataview)
|
||||
- [Convert a Uint8Array to a ReadableStream](https://bun.sh/guides/binary/typedarray-to-readablestream)
|
||||
- [Convert a Uint8Array to a string](https://bun.sh/guides/binary/typedarray-to-string)
|
||||
- [Convert a Uint8Array to an ArrayBuffer](https://bun.sh/guides/binary/typedarray-to-arraybuffer)
|
||||
- [Convert a Blob to an ArrayBuffer](https://bun.sh/guides/binary/blob-to-arraybuffer)
|
||||
- [Convert an ArrayBuffer to a Blob](https://bun.sh/guides/binary/arraybuffer-to-blob)
|
||||
- [Convert a Buffer to a Uint8Array](https://bun.sh/guides/binary/buffer-to-typedarray)
|
||||
- [Convert a Uint8Array to a Buffer](https://bun.sh/guides/binary/typedarray-to-buffer)
|
||||
- [Convert a Uint8Array to a string](https://bun.sh/guides/binary/typedarray-to-string)
|
||||
- [Convert a Buffer to an ArrayBuffer](https://bun.sh/guides/binary/buffer-to-arraybuffer)
|
||||
- [Convert an ArrayBuffer to a Buffer](https://bun.sh/guides/binary/arraybuffer-to-buffer)
|
||||
- [Convert an ArrayBuffer to a string](https://bun.sh/guides/binary/arraybuffer-to-string)
|
||||
- [Convert a Uint8Array to a DataView](https://bun.sh/guides/binary/typedarray-to-dataview)
|
||||
- [Convert a Buffer to a ReadableStream](https://bun.sh/guides/binary/buffer-to-readablestream)
|
||||
- [Convert a Uint8Array to an ArrayBuffer](https://bun.sh/guides/binary/typedarray-to-arraybuffer)
|
||||
- [Convert an ArrayBuffer to a Uint8Array](https://bun.sh/guides/binary/arraybuffer-to-typedarray)
|
||||
- [Convert an ArrayBuffer to an array of numbers](https://bun.sh/guides/binary/arraybuffer-to-array)
|
||||
- [Convert a Uint8Array to a ReadableStream](https://bun.sh/guides/binary/typedarray-to-readablestream)
|
||||
|
||||
- Ecosystem
|
||||
|
||||
- [Build a frontend using Vite and Bun](https://bun.sh/guides/ecosystem/vite)
|
||||
- [Build an app with Astro and Bun](https://bun.sh/guides/ecosystem/astro)
|
||||
- [Build an app with Next.js and Bun](https://bun.sh/guides/ecosystem/nextjs)
|
||||
- [Use React and JSX](https://bun.sh/guides/ecosystem/react)
|
||||
- [Use EdgeDB with Bun](https://bun.sh/guides/ecosystem/edgedb)
|
||||
- [Use Prisma with Bun](https://bun.sh/guides/ecosystem/prisma)
|
||||
- [Add Sentry to a Bun app](https://bun.sh/guides/ecosystem/sentry)
|
||||
- [Create a Discord bot](https://bun.sh/guides/ecosystem/discordjs)
|
||||
- [Run Bun as a daemon with PM2](https://bun.sh/guides/ecosystem/pm2)
|
||||
- [Use Drizzle ORM with Bun](https://bun.sh/guides/ecosystem/drizzle)
|
||||
- [Build an app with Nuxt and Bun](https://bun.sh/guides/ecosystem/nuxt)
|
||||
- [Build an app with Qwik and Bun](https://bun.sh/guides/ecosystem/qwik)
|
||||
- [Build an app with Astro and Bun](https://bun.sh/guides/ecosystem/astro)
|
||||
- [Build an app with Remix and Bun](https://bun.sh/guides/ecosystem/remix)
|
||||
- [Build an app with SolidStart and Bun](https://bun.sh/guides/ecosystem/solidstart)
|
||||
- [Build an app with SvelteKit and Bun](https://bun.sh/guides/ecosystem/sveltekit)
|
||||
- [Build an HTTP server using Elysia and Bun](https://bun.sh/guides/ecosystem/elysia)
|
||||
- [Build an HTTP server using Express and Bun](https://bun.sh/guides/ecosystem/express)
|
||||
- [Build a frontend using Vite and Bun](https://bun.sh/guides/ecosystem/vite)
|
||||
- [Build an app with Next.js and Bun](https://bun.sh/guides/ecosystem/nextjs)
|
||||
- [Run Bun as a daemon with systemd](https://bun.sh/guides/ecosystem/systemd)
|
||||
- [Deploy a Bun application on Render](https://bun.sh/guides/ecosystem/render)
|
||||
- [Build an HTTP server using Hono and Bun](https://bun.sh/guides/ecosystem/hono)
|
||||
- [Build an app with SvelteKit and Bun](https://bun.sh/guides/ecosystem/sveltekit)
|
||||
- [Build an app with SolidStart and Bun](https://bun.sh/guides/ecosystem/solidstart)
|
||||
- [Build an HTTP server using Elysia and Bun](https://bun.sh/guides/ecosystem/elysia)
|
||||
- [Build an HTTP server using StricJS and Bun](https://bun.sh/guides/ecosystem/stric)
|
||||
- [Containerize a Bun application with Docker](https://bun.sh/guides/ecosystem/docker)
|
||||
- [Create a Discord bot](https://bun.sh/guides/ecosystem/discordjs)
|
||||
- [Deploy a Bun application on Render](https://bun.sh/guides/ecosystem/render)
|
||||
- [Read and write data to MongoDB using Mongoose and Bun](https://bun.sh/guides/ecosystem/mongoose)
|
||||
- [Run Bun as a daemon with PM2](https://bun.sh/guides/ecosystem/pm2)
|
||||
- [Run Bun as a daemon with systemd](https://bun.sh/guides/ecosystem/systemd)
|
||||
- [Build an HTTP server using Express and Bun](https://bun.sh/guides/ecosystem/express)
|
||||
- [Use Neon Postgres through Drizzle ORM](https://bun.sh/guides/ecosystem/neon-drizzle)
|
||||
- [Server-side render (SSR) a React component](https://bun.sh/guides/ecosystem/ssr-react)
|
||||
- [Use Drizzle ORM with Bun](https://bun.sh/guides/ecosystem/drizzle)
|
||||
- [Use EdgeDB with Bun](https://bun.sh/guides/ecosystem/edgedb)
|
||||
- [Read and write data to MongoDB using Mongoose and Bun](https://bun.sh/guides/ecosystem/mongoose)
|
||||
- [Use Neon's Serverless Postgres with Bun](https://bun.sh/guides/ecosystem/neon-serverless-postgres)
|
||||
- [Use Prisma with Bun](https://bun.sh/guides/ecosystem/prisma)
|
||||
- [Use React and JSX](https://bun.sh/guides/ecosystem/react)
|
||||
- [Add Sentry to a Bun app](https://bun.sh/guides/ecosystem/sentry)
|
||||
|
||||
- HTMLRewriter
|
||||
|
||||
- [Extract links from a webpage using HTMLRewriter](https://bun.sh/guides/html-rewriter/extract-links)
|
||||
- [Extract social share images and Open Graph tags](https://bun.sh/guides/html-rewriter/extract-social-meta)
|
||||
|
||||
- HTTP
|
||||
|
||||
- [Common HTTP server usage](https://bun.sh/guides/http/server)
|
||||
- [Configure TLS on an HTTP server](https://bun.sh/guides/http/tls)
|
||||
- [fetch with unix domain sockets in Bun](https://bun.sh/guides/http/fetch-unix)
|
||||
- [Hot reload an HTTP server](https://bun.sh/guides/http/hot)
|
||||
- [Proxy HTTP requests using fetch()](https://bun.sh/guides/http/proxy)
|
||||
- [Common HTTP server usage](https://bun.sh/guides/http/server)
|
||||
- [Write a simple HTTP server](https://bun.sh/guides/http/simple)
|
||||
- [Configure TLS on an HTTP server](https://bun.sh/guides/http/tls)
|
||||
- [Send an HTTP request using fetch](https://bun.sh/guides/http/fetch)
|
||||
- [Proxy HTTP requests using fetch()](https://bun.sh/guides/http/proxy)
|
||||
- [Start a cluster of HTTP servers](https://bun.sh/guides/http/cluster)
|
||||
- [Stream a file as an HTTP Response](https://bun.sh/guides/http/stream-file)
|
||||
- [fetch with unix domain sockets in Bun](https://bun.sh/guides/http/fetch-unix)
|
||||
- [Upload files via HTTP using FormData](https://bun.sh/guides/http/file-uploads)
|
||||
- [Streaming HTTP Server with Async Iterators](https://bun.sh/guides/http/stream-iterator)
|
||||
- [Streaming HTTP Server with Node.js Streams](https://bun.sh/guides/http/stream-node-streams-in-bun)
|
||||
- [Upload files via HTTP using FormData](https://bun.sh/guides/http/file-uploads)
|
||||
- [Write a simple HTTP server](https://bun.sh/guides/http/simple)
|
||||
|
||||
- Install
|
||||
|
||||
- [Add a dependency](https://bun.sh/guides/install/add)
|
||||
- [Add a development dependency](https://bun.sh/guides/install/add-dev)
|
||||
- [Add a Git dependency](https://bun.sh/guides/install/add-git)
|
||||
- [Add a peer dependency](https://bun.sh/guides/install/add-peer)
|
||||
- [Add a tarball dependency](https://bun.sh/guides/install/add-tarball)
|
||||
- [Add a trusted dependency](https://bun.sh/guides/install/trusted)
|
||||
- [Add a development dependency](https://bun.sh/guides/install/add-dev)
|
||||
- [Add a tarball dependency](https://bun.sh/guides/install/add-tarball)
|
||||
- [Add an optional dependency](https://bun.sh/guides/install/add-optional)
|
||||
- [Configure a private registry for an organization scope with bun install](https://bun.sh/guides/install/registry-scope)
|
||||
- [Configure git to diff Bun's lockb lockfile](https://bun.sh/guides/install/git-diff-bun-lockfile)
|
||||
- [Generate a yarn-compatible lockfile](https://bun.sh/guides/install/yarnlock)
|
||||
- [Configuring a monorepo using workspaces](https://bun.sh/guides/install/workspaces)
|
||||
- [Generate a human-readable lockfile](https://bun.sh/guides/install/yarnlock)
|
||||
- [Install a package under a different name](https://bun.sh/guides/install/npm-alias)
|
||||
- [Install dependencies with Bun in GitHub Actions](https://bun.sh/guides/install/cicd)
|
||||
- [Using bun install with Artifactory](https://bun.sh/guides/install/jfrog-artifactory)
|
||||
- [Configure git to diff Bun's lockb lockfile](https://bun.sh/guides/install/git-diff-bun-lockfile)
|
||||
- [Override the default npm registry for bun install](https://bun.sh/guides/install/custom-registry)
|
||||
- [Using bun install with an Azure Artifacts npm registry](https://bun.sh/guides/install/azure-artifacts)
|
||||
- [Using bun install with Artifactory](https://bun.sh/guides/install/jfrog-artifactory)
|
||||
- [Migrate from npm install to bun install](https://bun.sh/guides/install/from-npm-install-to-bun-install)
|
||||
- [Configure a private registry for an organization scope with bun install](https://bun.sh/guides/install/registry-scope)
|
||||
|
||||
- Process
|
||||
|
||||
- [Get the process uptime in nanoseconds](https://bun.sh/guides/process/nanoseconds)
|
||||
- [Read from stdin](https://bun.sh/guides/process/stdin)
|
||||
- [Listen for CTRL+C](https://bun.sh/guides/process/ctrl-c)
|
||||
- [Spawn a child process](https://bun.sh/guides/process/spawn)
|
||||
- [Listen to OS signals](https://bun.sh/guides/process/os-signals)
|
||||
- [Parse command-line arguments](https://bun.sh/guides/process/argv)
|
||||
- [Read from stdin](https://bun.sh/guides/process/stdin)
|
||||
- [Read stderr from a child process](https://bun.sh/guides/process/spawn-stderr)
|
||||
- [Read stdout from a child process](https://bun.sh/guides/process/spawn-stdout)
|
||||
- [Spawn a child process](https://bun.sh/guides/process/spawn)
|
||||
- [Get the process uptime in nanoseconds](https://bun.sh/guides/process/nanoseconds)
|
||||
- [Spawn a child process and communicate using IPC](https://bun.sh/guides/process/ipc)
|
||||
|
||||
- Read file
|
||||
|
||||
- [Read a JSON file](https://bun.sh/guides/read-file/json)
|
||||
- [Check if a file exists](https://bun.sh/guides/read-file/exists)
|
||||
- [Get the MIME type of a file](https://bun.sh/guides/read-file/mime)
|
||||
- [Read a file as a ReadableStream](https://bun.sh/guides/read-file/stream)
|
||||
- [Read a file as a string](https://bun.sh/guides/read-file/string)
|
||||
- [Read a file to a Buffer](https://bun.sh/guides/read-file/buffer)
|
||||
- [Get the MIME type of a file](https://bun.sh/guides/read-file/mime)
|
||||
- [Watch a directory for changes](https://bun.sh/guides/read-file/watch)
|
||||
- [Read a file as a ReadableStream](https://bun.sh/guides/read-file/stream)
|
||||
- [Read a file to a Uint8Array](https://bun.sh/guides/read-file/uint8array)
|
||||
- [Read a file to an ArrayBuffer](https://bun.sh/guides/read-file/arraybuffer)
|
||||
- [Read a JSON file](https://bun.sh/guides/read-file/json)
|
||||
- [Watch a directory for changes](https://bun.sh/guides/read-file/watch)
|
||||
|
||||
- Runtime
|
||||
|
||||
- [Debugging Bun with the VS Code extension](https://bun.sh/guides/runtime/vscode-debugger)
|
||||
- [Debugging Bun with the web debugger](https://bun.sh/guides/runtime/web-debugger)
|
||||
- [Define and replace static globals & constants](https://bun.sh/guides/runtime/define-constant)
|
||||
- [Delete files](https://bun.sh/guides/runtime/delete-file)
|
||||
- [Run a Shell Command](https://bun.sh/guides/runtime/shell)
|
||||
- [Import a JSON file](https://bun.sh/guides/runtime/import-json)
|
||||
- [Import a TOML file](https://bun.sh/guides/runtime/import-toml)
|
||||
- [Import HTML file as text](https://bun.sh/guides/runtime/import-html)
|
||||
- [Install and run Bun in GitHub Actions](https://bun.sh/guides/runtime/cicd)
|
||||
- [Install TypeScript declarations for Bun](https://bun.sh/guides/runtime/typescript)
|
||||
- [Re-map import paths](https://bun.sh/guides/runtime/tsconfig-paths)
|
||||
- [Read environment variables](https://bun.sh/guides/runtime/read-env)
|
||||
- [Run a Shell Command](https://bun.sh/guides/runtime/shell)
|
||||
- [Set a time zone in Bun](https://bun.sh/guides/runtime/timezone)
|
||||
- [Set environment variables](https://bun.sh/guides/runtime/set-env)
|
||||
- [Re-map import paths](https://bun.sh/guides/runtime/tsconfig-paths)
|
||||
- [Delete directories](https://bun.sh/guides/runtime/delete-directory)
|
||||
- [Read environment variables](https://bun.sh/guides/runtime/read-env)
|
||||
- [Import a HTML file as text](https://bun.sh/guides/runtime/import-html)
|
||||
- [Install and run Bun in GitHub Actions](https://bun.sh/guides/runtime/cicd)
|
||||
- [Debugging Bun with the web debugger](https://bun.sh/guides/runtime/web-debugger)
|
||||
- [Install TypeScript declarations for Bun](https://bun.sh/guides/runtime/typescript)
|
||||
- [Debugging Bun with the VS Code extension](https://bun.sh/guides/runtime/vscode-debugger)
|
||||
- [Inspect memory usage using V8 heap snapshots](https://bun.sh/guides/runtime/heap-snapshot)
|
||||
- [Define and replace static globals & constants](https://bun.sh/guides/runtime/define-constant)
|
||||
- [Codesign a single-file JavaScript executable on macOS](https://bun.sh/guides/runtime/codesign-macos-executable)
|
||||
|
||||
- Streams
|
||||
|
||||
- [Convert a Node.js Readable to a Blob](https://bun.sh/guides/streams/node-readable-to-blob)
|
||||
- [Convert a Node.js Readable to a string](https://bun.sh/guides/streams/node-readable-to-string)
|
||||
- [Convert a Node.js Readable to an ArrayBuffer](https://bun.sh/guides/streams/node-readable-to-arraybuffer)
|
||||
- [Convert a Node.js Readable to JSON](https://bun.sh/guides/streams/node-readable-to-json)
|
||||
- [Convert a ReadableStream to JSON](https://bun.sh/guides/streams/to-json)
|
||||
- [Convert a ReadableStream to a Blob](https://bun.sh/guides/streams/to-blob)
|
||||
- [Convert a ReadableStream to a Buffer](https://bun.sh/guides/streams/to-buffer)
|
||||
- [Convert a ReadableStream to a string](https://bun.sh/guides/streams/to-string)
|
||||
- [Convert a ReadableStream to a Uint8Array](https://bun.sh/guides/streams/to-typedarray)
|
||||
- [Convert a ReadableStream to an array of chunks](https://bun.sh/guides/streams/to-array)
|
||||
- [Convert a Node.js Readable to JSON](https://bun.sh/guides/streams/node-readable-to-json)
|
||||
- [Convert a ReadableStream to an ArrayBuffer](https://bun.sh/guides/streams/to-arraybuffer)
|
||||
- [Convert a ReadableStream to JSON](https://bun.sh/guides/streams/to-json)
|
||||
- [Convert a Node.js Readable to a Blob](https://bun.sh/guides/streams/node-readable-to-blob)
|
||||
- [Convert a Node.js Readable to a string](https://bun.sh/guides/streams/node-readable-to-string)
|
||||
- [Convert a Node.js Readable to an Uint8Array](https://bun.sh/guides/streams/node-readable-to-uint8array)
|
||||
- [Convert a Node.js Readable to an ArrayBuffer](https://bun.sh/guides/streams/node-readable-to-arraybuffer)
|
||||
|
||||
- Test
|
||||
|
||||
- [Bail early with the Bun test runner](https://bun.sh/guides/test/bail)
|
||||
- [Generate code coverage reports with the Bun test runner](https://bun.sh/guides/test/coverage)
|
||||
- [Mark a test as a "todo" with the Bun test runner](https://bun.sh/guides/test/todo-tests)
|
||||
- [Migrate from Jest to Bun's test runner](https://bun.sh/guides/test/migrate-from-jest)
|
||||
- [Mock functions in `bun test`](https://bun.sh/guides/test/mock-functions)
|
||||
- [Re-run tests multiple times with the Bun test runner](https://bun.sh/guides/test/rerun-each)
|
||||
- [Run tests in watch mode with Bun](https://bun.sh/guides/test/watch-mode)
|
||||
- [Run your tests with the Bun test runner](https://bun.sh/guides/test/run-tests)
|
||||
- [Set a code coverage threshold with the Bun test runner](https://bun.sh/guides/test/coverage-threshold)
|
||||
- [Set a per-test timeout with the Bun test runner](https://bun.sh/guides/test/timeout)
|
||||
- [Set the system time in Bun's test runner](https://bun.sh/guides/test/mock-clock)
|
||||
- [Skip tests with the Bun test runner](https://bun.sh/guides/test/skip-tests)
|
||||
- [Spy on methods in `bun test`](https://bun.sh/guides/test/spy-on)
|
||||
- [Update snapshots in `bun test`](https://bun.sh/guides/test/update-snapshots)
|
||||
- [Bail early with the Bun test runner](https://bun.sh/guides/test/bail)
|
||||
- [Mock functions in `bun test`](https://bun.sh/guides/test/mock-functions)
|
||||
- [Run tests in watch mode with Bun](https://bun.sh/guides/test/watch-mode)
|
||||
- [Use snapshot testing in `bun test`](https://bun.sh/guides/test/snapshot)
|
||||
- [Skip tests with the Bun test runner](https://bun.sh/guides/test/skip-tests)
|
||||
- [Using Testing Library with Bun](https://bun.sh/guides/test/testing-library)
|
||||
- [Update snapshots in `bun test`](https://bun.sh/guides/test/update-snapshots)
|
||||
- [Run your tests with the Bun test runner](https://bun.sh/guides/test/run-tests)
|
||||
- [Set the system time in Bun's test runner](https://bun.sh/guides/test/mock-clock)
|
||||
- [Set a per-test timeout with the Bun test runner](https://bun.sh/guides/test/timeout)
|
||||
- [Migrate from Jest to Bun's test runner](https://bun.sh/guides/test/migrate-from-jest)
|
||||
- [Write browser DOM tests with Bun and happy-dom](https://bun.sh/guides/test/happy-dom)
|
||||
- [Mark a test as a "todo" with the Bun test runner](https://bun.sh/guides/test/todo-tests)
|
||||
- [Re-run tests multiple times with the Bun test runner](https://bun.sh/guides/test/rerun-each)
|
||||
- [Generate code coverage reports with the Bun test runner](https://bun.sh/guides/test/coverage)
|
||||
- [import, require, and test Svelte components with bun test](https://bun.sh/guides/test/svelte-test)
|
||||
- [Set a code coverage threshold with the Bun test runner](https://bun.sh/guides/test/coverage-threshold)
|
||||
|
||||
- Util
|
||||
|
||||
- [Check if the current file is the entrypoint](https://bun.sh/guides/util/entrypoint)
|
||||
- [Generate a UUID](https://bun.sh/guides/util/javascript-uuid)
|
||||
- [Hash a password](https://bun.sh/guides/util/hash-a-password)
|
||||
- [Escape an HTML string](https://bun.sh/guides/util/escape-html)
|
||||
- [Get the current Bun version](https://bun.sh/guides/util/version)
|
||||
- [Encode and decode base64 strings](https://bun.sh/guides/util/base64)
|
||||
- [Compress and decompress data with gzip](https://bun.sh/guides/util/gzip)
|
||||
- [Sleep for a fixed number of milliseconds](https://bun.sh/guides/util/sleep)
|
||||
- [Detect when code is executed with Bun](https://bun.sh/guides/util/detect-bun)
|
||||
- [Check if two objects are deeply equal](https://bun.sh/guides/util/deep-equals)
|
||||
- [Compress and decompress data with DEFLATE](https://bun.sh/guides/util/deflate)
|
||||
- [Compress and decompress data with gzip](https://bun.sh/guides/util/gzip)
|
||||
- [Get the absolute path to the current entrypoint](https://bun.sh/guides/util/main)
|
||||
- [Get the directory of the current file](https://bun.sh/guides/util/import-meta-dir)
|
||||
- [Check if the current file is the entrypoint](https://bun.sh/guides/util/entrypoint)
|
||||
- [Get the file name of the current file](https://bun.sh/guides/util/import-meta-file)
|
||||
- [Convert a file URL to an absolute path](https://bun.sh/guides/util/file-url-to-path)
|
||||
- [Convert an absolute path to a file URL](https://bun.sh/guides/util/path-to-file-url)
|
||||
- [Detect when code is executed with Bun](https://bun.sh/guides/util/detect-bun)
|
||||
- [Encode and decode base64 strings](https://bun.sh/guides/util/base64)
|
||||
- [Escape an HTML string](https://bun.sh/guides/util/escape-html)
|
||||
- [Get the absolute path of the current file](https://bun.sh/guides/util/import-meta-path)
|
||||
- [Get the absolute path to the current entrypoint](https://bun.sh/guides/util/main)
|
||||
- [Get the current Bun version](https://bun.sh/guides/util/version)
|
||||
- [Get the directory of the current file](https://bun.sh/guides/util/import-meta-dir)
|
||||
- [Get the file name of the current file](https://bun.sh/guides/util/import-meta-file)
|
||||
- [Get the path to an executable bin file](https://bun.sh/guides/util/which-path-to-executable-bin)
|
||||
- [Hash a password](https://bun.sh/guides/util/hash-a-password)
|
||||
- [Sleep for a fixed number of milliseconds](https://bun.sh/guides/util/sleep)
|
||||
|
||||
- WebSocket
|
||||
|
||||
@@ -379,16 +416,17 @@ bun upgrade --canary
|
||||
- [Set per-socket contextual data on a WebSocket](https://bun.sh/guides/websocket/context)
|
||||
|
||||
- Write file
|
||||
- [Append content to a file](https://bun.sh/guides/write-file/append)
|
||||
- [Copy a file to another location](https://bun.sh/guides/write-file/file-cp)
|
||||
|
||||
- [Delete a file](https://bun.sh/guides/write-file/unlink)
|
||||
- [Write a Blob to a file](https://bun.sh/guides/write-file/blob)
|
||||
- [Write a file incrementally](https://bun.sh/guides/write-file/filesink)
|
||||
- [Write a file to stdout](https://bun.sh/guides/write-file/cat)
|
||||
- [Write a ReadableStream to a file](https://bun.sh/guides/write-file/stream)
|
||||
- [Write a Response to a file](https://bun.sh/guides/write-file/response)
|
||||
- [Write a string to a file](https://bun.sh/guides/write-file/basic)
|
||||
- [Write to stdout](https://bun.sh/guides/write-file/stdout)
|
||||
- [Write a file to stdout](https://bun.sh/guides/write-file/cat)
|
||||
- [Write a Blob to a file](https://bun.sh/guides/write-file/blob)
|
||||
- [Write a string to a file](https://bun.sh/guides/write-file/basic)
|
||||
- [Append content to a file](https://bun.sh/guides/write-file/append)
|
||||
- [Write a file incrementally](https://bun.sh/guides/write-file/filesink)
|
||||
- [Write a Response to a file](https://bun.sh/guides/write-file/response)
|
||||
- [Copy a file to another location](https://bun.sh/guides/write-file/file-cp)
|
||||
- [Write a ReadableStream to a file](https://bun.sh/guides/write-file/stream)
|
||||
|
||||
## Contributing
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Enable latest features
|
||||
"lib": ["ESNext"],
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"module": "Preserve",
|
||||
"moduleDetection": "force",
|
||||
"jsx": "react-jsx",
|
||||
"allowJs": true,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Enable latest features
|
||||
"lib": ["ESNext"],
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"module": "Preserve",
|
||||
"moduleDetection": "force",
|
||||
"jsx": "react-jsx",
|
||||
"allowJs": true,
|
||||
|
||||
@@ -50,6 +50,10 @@ bench("murmur64v2 (short)", () => {
|
||||
Bun.hash.murmur64v2(shortStr);
|
||||
});
|
||||
|
||||
bench("rapidhash (short)", () => {
|
||||
Bun.hash.rapidhash(shortStr);
|
||||
});
|
||||
|
||||
bench("wyhash (128 KB)", () => {
|
||||
Bun.hash.wyhash(longStr);
|
||||
});
|
||||
@@ -94,4 +98,8 @@ bench("murmur64v2 (128 KB)", () => {
|
||||
Bun.hash.murmur64v2(longStr);
|
||||
});
|
||||
|
||||
bench("rapidhash (128 KB)", () => {
|
||||
Bun.hash.rapidhash(longStr);
|
||||
});
|
||||
|
||||
run();
|
||||
|
||||
@@ -8,9 +8,9 @@ for (let builtin of builtinModules) {
|
||||
path,
|
||||
`
|
||||
const builtin = ${JSON.stringify(builtin)};
|
||||
const now = require("perf_hooks").performance.now();
|
||||
const now = performance.now();
|
||||
require(builtin);
|
||||
const end = require("perf_hooks").performance.now();
|
||||
const end = performance.now();
|
||||
process.stdout.write(JSON.stringify({builtin, time: end - now}) + "\\n");
|
||||
`,
|
||||
);
|
||||
|
||||
28
bench/snippets/source-map.js
Normal file
28
bench/snippets/source-map.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import { SourceMap } from "node:module";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { bench, run } from "../runner.mjs";
|
||||
const json = JSON.parse(readFileSync(process.argv.at(-1), "utf-8"));
|
||||
|
||||
bench("new SourceMap(json)", () => {
|
||||
return new SourceMap(json);
|
||||
});
|
||||
|
||||
const map = new SourceMap(json);
|
||||
|
||||
const toRotate = [];
|
||||
for (let j = 0; j < 10000; j++) {
|
||||
if (map.findEntry(0, j).generatedColumn) {
|
||||
toRotate.push(j);
|
||||
if (toRotate.length > 5) break;
|
||||
}
|
||||
}
|
||||
let i = 0;
|
||||
bench("findEntry (match)", () => {
|
||||
return map.findEntry(0, toRotate[i++ % 3]).generatedColumn;
|
||||
});
|
||||
|
||||
bench("findEntry (no match)", () => {
|
||||
return map.findEntry(0, 9999).generatedColumn;
|
||||
});
|
||||
|
||||
await run();
|
||||
27
build.zig
27
build.zig
@@ -63,6 +63,7 @@ const BunBuildOptions = struct {
|
||||
/// `./build/codegen` or equivalent
|
||||
codegen_path: []const u8,
|
||||
no_llvm: bool,
|
||||
override_no_export_cpp_apis: bool,
|
||||
|
||||
cached_options_module: ?*Module = null,
|
||||
windows_shim: ?WindowsShim = null,
|
||||
@@ -95,6 +96,7 @@ const BunBuildOptions = struct {
|
||||
opts.addOption(bool, "enable_asan", this.enable_asan);
|
||||
opts.addOption([]const u8, "reported_nodejs_version", b.fmt("{}", .{this.reported_nodejs_version}));
|
||||
opts.addOption(bool, "zig_self_hosted_backend", this.no_llvm);
|
||||
opts.addOption(bool, "override_no_export_cpp_apis", this.override_no_export_cpp_apis);
|
||||
|
||||
const mod = opts.createModule();
|
||||
this.cached_options_module = mod;
|
||||
@@ -206,6 +208,7 @@ pub fn build(b: *Build) !void {
|
||||
const obj_format = b.option(ObjectFormat, "obj_format", "Output file for object files") orelse .obj;
|
||||
|
||||
const no_llvm = b.option(bool, "no_llvm", "Experiment with Zig self hosted backends. No stability guaranteed") orelse false;
|
||||
const override_no_export_cpp_apis = b.option(bool, "override-no-export-cpp-apis", "Override the default export_cpp_apis logic to disable exports") orelse false;
|
||||
|
||||
var build_options = BunBuildOptions{
|
||||
.target = target,
|
||||
@@ -217,6 +220,7 @@ pub fn build(b: *Build) !void {
|
||||
.codegen_path = codegen_path,
|
||||
.codegen_embed = codegen_embed,
|
||||
.no_llvm = no_llvm,
|
||||
.override_no_export_cpp_apis = override_no_export_cpp_apis,
|
||||
|
||||
.version = try Version.parse(bun_version),
|
||||
.canary_revision = canary: {
|
||||
@@ -386,6 +390,12 @@ pub fn build(b: *Build) !void {
|
||||
.{ .os = .windows, .arch = .x86_64 },
|
||||
}, &.{ .Debug, .ReleaseFast });
|
||||
}
|
||||
{
|
||||
const step = b.step("check-windows-debug", "Check for semantic analysis errors on Windows");
|
||||
addMultiCheck(b, step, build_options, &.{
|
||||
.{ .os = .windows, .arch = .x86_64 },
|
||||
}, &.{.Debug});
|
||||
}
|
||||
{
|
||||
const step = b.step("check-macos", "Check for semantic analysis errors on Windows");
|
||||
addMultiCheck(b, step, build_options, &.{
|
||||
@@ -393,6 +403,13 @@ pub fn build(b: *Build) !void {
|
||||
.{ .os = .mac, .arch = .aarch64 },
|
||||
}, &.{ .Debug, .ReleaseFast });
|
||||
}
|
||||
{
|
||||
const step = b.step("check-macos-debug", "Check for semantic analysis errors on Windows");
|
||||
addMultiCheck(b, step, build_options, &.{
|
||||
.{ .os = .mac, .arch = .x86_64 },
|
||||
.{ .os = .mac, .arch = .aarch64 },
|
||||
}, &.{.Debug});
|
||||
}
|
||||
{
|
||||
const step = b.step("check-linux", "Check for semantic analysis errors on Windows");
|
||||
addMultiCheck(b, step, build_options, &.{
|
||||
@@ -400,6 +417,13 @@ pub fn build(b: *Build) !void {
|
||||
.{ .os = .linux, .arch = .aarch64 },
|
||||
}, &.{ .Debug, .ReleaseFast });
|
||||
}
|
||||
{
|
||||
const step = b.step("check-linux-debug", "Check for semantic analysis errors on Windows");
|
||||
addMultiCheck(b, step, build_options, &.{
|
||||
.{ .os = .linux, .arch = .x86_64 },
|
||||
.{ .os = .linux, .arch = .aarch64 },
|
||||
}, &.{.Debug});
|
||||
}
|
||||
|
||||
// zig build translate-c-headers
|
||||
{
|
||||
@@ -476,6 +500,7 @@ fn addMultiCheck(
|
||||
.codegen_path = root_build_options.codegen_path,
|
||||
.no_llvm = root_build_options.no_llvm,
|
||||
.enable_asan = root_build_options.enable_asan,
|
||||
.override_no_export_cpp_apis = root_build_options.override_no_export_cpp_apis,
|
||||
};
|
||||
|
||||
var obj = addBunObject(b, &options);
|
||||
@@ -508,6 +533,8 @@ fn getTranslateC(b: *Build, initial_target: std.Build.ResolvedTarget, optimize:
|
||||
translate_c.defineCMacroRaw(b.fmt("{s}={d}", .{ str, @intFromBool(value) }));
|
||||
}
|
||||
|
||||
translate_c.addIncludePath(b.path("vendor/zstd/lib"));
|
||||
|
||||
if (target.result.os.tag == .windows) {
|
||||
// translate-c is unable to translate the unsuffixed windows functions
|
||||
// like `SetCurrentDirectory` since they are defined with an odd macro
|
||||
|
||||
@@ -88,7 +88,7 @@ endif()
|
||||
if(UNIX)
|
||||
register_compiler_flags(
|
||||
DESCRIPTION "Enable debug symbols"
|
||||
-g3 ${DEBUG}
|
||||
-g3 -gz=zstd ${DEBUG}
|
||||
-g1 ${RELEASE}
|
||||
)
|
||||
|
||||
|
||||
@@ -139,10 +139,10 @@ endif()
|
||||
optionx(REVISION STRING "The git revision of the build" DEFAULT ${DEFAULT_REVISION})
|
||||
|
||||
# Used in process.version, process.versions.node, napi, and elsewhere
|
||||
optionx(NODEJS_VERSION STRING "The version of Node.js to report" DEFAULT "22.6.0")
|
||||
optionx(NODEJS_VERSION STRING "The version of Node.js to report" DEFAULT "24.3.0")
|
||||
|
||||
# Used in process.versions.modules and compared while loading V8 modules
|
||||
optionx(NODEJS_ABI_VERSION STRING "The ABI version of Node.js to report" DEFAULT "127")
|
||||
optionx(NODEJS_ABI_VERSION STRING "The ABI version of Node.js to report" DEFAULT "137")
|
||||
|
||||
if(APPLE)
|
||||
set(DEFAULT_STATIC_SQLITE OFF)
|
||||
|
||||
@@ -44,10 +44,12 @@
|
||||
"src/bun.js/bindings/webcrypto/*/*.cpp",
|
||||
"src/bun.js/bindings/node/*.cpp",
|
||||
"src/bun.js/bindings/node/crypto/*.cpp",
|
||||
"src/bun.js/bindings/node/http/*.cpp",
|
||||
"src/bun.js/bindings/v8/*.cpp",
|
||||
"src/bun.js/bindings/v8/shim/*.cpp",
|
||||
"src/bake/*.cpp",
|
||||
"src/deps/*.cpp",
|
||||
"src/vm/*.cpp",
|
||||
"packages/bun-usockets/src/crypto/*.cpp"
|
||||
]
|
||||
},
|
||||
@@ -59,7 +61,9 @@
|
||||
"packages/bun-usockets/src/internal/*.c",
|
||||
"packages/bun-usockets/src/crypto/*.c",
|
||||
"src/bun.js/bindings/uv-posix-polyfills.c",
|
||||
"src/bun.js/bindings/uv-posix-stubs.c"
|
||||
"src/bun.js/bindings/uv-posix-stubs.c",
|
||||
"src/*.c",
|
||||
"src/bun.js/bindings/node/http/llhttp/*.c"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
31
cmake/scripts/PrepareNodeHeaders.cmake
Normal file
31
cmake/scripts/PrepareNodeHeaders.cmake
Normal file
@@ -0,0 +1,31 @@
|
||||
# This script prepares Node.js headers for use with Bun
|
||||
# It removes conflicting OpenSSL and libuv headers since Bun uses BoringSSL and its own libuv
|
||||
|
||||
if(NOT DEFINED NODE_INCLUDE_DIR)
|
||||
message(FATAL_ERROR "NODE_INCLUDE_DIR not defined")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${NODE_INCLUDE_DIR}/node")
|
||||
message(FATAL_ERROR "Node headers not found at ${NODE_INCLUDE_DIR}/node")
|
||||
endif()
|
||||
|
||||
# Remove OpenSSL headers that conflict with BoringSSL
|
||||
if(EXISTS "${NODE_INCLUDE_DIR}/node/openssl")
|
||||
file(REMOVE_RECURSE "${NODE_INCLUDE_DIR}/node/openssl")
|
||||
message(STATUS "Removed conflicting OpenSSL headers")
|
||||
endif()
|
||||
|
||||
# Remove libuv headers that might conflict
|
||||
if(EXISTS "${NODE_INCLUDE_DIR}/node/uv")
|
||||
file(REMOVE_RECURSE "${NODE_INCLUDE_DIR}/node/uv")
|
||||
message(STATUS "Removed conflicting libuv headers")
|
||||
endif()
|
||||
|
||||
if(EXISTS "${NODE_INCLUDE_DIR}/node/uv.h")
|
||||
file(REMOVE "${NODE_INCLUDE_DIR}/node/uv.h")
|
||||
message(STATUS "Removed conflicting uv.h header")
|
||||
endif()
|
||||
|
||||
# Add the node directory to include path for cppgc
|
||||
# This is needed because cppgc internal headers use relative includes
|
||||
file(WRITE "${NODE_INCLUDE_DIR}/.node-headers-prepared" "1")
|
||||
@@ -20,4 +20,4 @@ src/bake/hmr-runtime-client.ts
|
||||
src/bake/hmr-runtime-error.ts
|
||||
src/bake/hmr-runtime-server.ts
|
||||
src/bake/server/stack-trace-stub.ts
|
||||
src/bake/shared.ts
|
||||
src/bake/shared.ts
|
||||
@@ -4,4 +4,4 @@ src/bun.js/api/BunObject.bind.ts
|
||||
src/bun.js/bindgen_test.bind.ts
|
||||
src/bun.js/bindings/NodeModuleModule.bind.ts
|
||||
src/bun.js/node/node_os.bind.ts
|
||||
src/fmt.bind.ts
|
||||
src/fmt.bind.ts
|
||||
@@ -9,4 +9,4 @@ packages/bun-error/package.json
|
||||
packages/bun-error/runtime-error.ts
|
||||
packages/bun-error/sourcemap.ts
|
||||
packages/bun-error/stack-trace-parser.ts
|
||||
packages/bun-error/tsconfig.json
|
||||
packages/bun-error/tsconfig.json
|
||||
@@ -7,5 +7,9 @@ packages/bun-usockets/src/loop.c
|
||||
packages/bun-usockets/src/quic.c
|
||||
packages/bun-usockets/src/socket.c
|
||||
packages/bun-usockets/src/udp.c
|
||||
src/asan-config.c
|
||||
src/bun.js/bindings/node/http/llhttp/api.c
|
||||
src/bun.js/bindings/node/http/llhttp/http.c
|
||||
src/bun.js/bindings/node/http/llhttp/llhttp.c
|
||||
src/bun.js/bindings/uv-posix-polyfills.c
|
||||
src/bun.js/bindings/uv-posix-stubs.c
|
||||
src/bun.js/bindings/uv-posix-stubs.c
|
||||
@@ -28,6 +28,7 @@ src/bun.js/bindings/BunWorkerGlobalScope.cpp
|
||||
src/bun.js/bindings/c-bindings.cpp
|
||||
src/bun.js/bindings/CallSite.cpp
|
||||
src/bun.js/bindings/CallSitePrototype.cpp
|
||||
src/bun.js/bindings/CatchScopeBinding.cpp
|
||||
src/bun.js/bindings/CodeCoverage.cpp
|
||||
src/bun.js/bindings/ConsoleObject.cpp
|
||||
src/bun.js/bindings/Cookie.cpp
|
||||
@@ -80,6 +81,9 @@ src/bun.js/bindings/JSEnvironmentVariableMap.cpp
|
||||
src/bun.js/bindings/JSFFIFunction.cpp
|
||||
src/bun.js/bindings/JSMockFunction.cpp
|
||||
src/bun.js/bindings/JSNextTickQueue.cpp
|
||||
src/bun.js/bindings/JSNodePerformanceHooksHistogram.cpp
|
||||
src/bun.js/bindings/JSNodePerformanceHooksHistogramConstructor.cpp
|
||||
src/bun.js/bindings/JSNodePerformanceHooksHistogramPrototype.cpp
|
||||
src/bun.js/bindings/JSPropertyIterator.cpp
|
||||
src/bun.js/bindings/JSS3File.cpp
|
||||
src/bun.js/bindings/JSSocketAddressDTO.cpp
|
||||
@@ -96,6 +100,9 @@ src/bun.js/bindings/napi_finalizer.cpp
|
||||
src/bun.js/bindings/napi_handle_scope.cpp
|
||||
src/bun.js/bindings/napi_type_tag.cpp
|
||||
src/bun.js/bindings/napi.cpp
|
||||
src/bun.js/bindings/NapiClass.cpp
|
||||
src/bun.js/bindings/NapiRef.cpp
|
||||
src/bun.js/bindings/NapiWeakValue.cpp
|
||||
src/bun.js/bindings/ncrpyto_engine.cpp
|
||||
src/bun.js/bindings/ncrypto.cpp
|
||||
src/bun.js/bindings/node/crypto/CryptoDhJob.cpp
|
||||
@@ -141,6 +148,13 @@ src/bun.js/bindings/node/crypto/JSSign.cpp
|
||||
src/bun.js/bindings/node/crypto/JSVerify.cpp
|
||||
src/bun.js/bindings/node/crypto/KeyObject.cpp
|
||||
src/bun.js/bindings/node/crypto/node_crypto_binding.cpp
|
||||
src/bun.js/bindings/node/http/JSConnectionsList.cpp
|
||||
src/bun.js/bindings/node/http/JSConnectionsListConstructor.cpp
|
||||
src/bun.js/bindings/node/http/JSConnectionsListPrototype.cpp
|
||||
src/bun.js/bindings/node/http/JSHTTPParser.cpp
|
||||
src/bun.js/bindings/node/http/JSHTTPParserConstructor.cpp
|
||||
src/bun.js/bindings/node/http/JSHTTPParserPrototype.cpp
|
||||
src/bun.js/bindings/node/http/NodeHTTPParser.cpp
|
||||
src/bun.js/bindings/node/NodeTimers.cpp
|
||||
src/bun.js/bindings/NodeAsyncHooks.cpp
|
||||
src/bun.js/bindings/NodeDirent.cpp
|
||||
@@ -153,6 +167,10 @@ src/bun.js/bindings/NodeTLS.cpp
|
||||
src/bun.js/bindings/NodeURL.cpp
|
||||
src/bun.js/bindings/NodeValidator.cpp
|
||||
src/bun.js/bindings/NodeVM.cpp
|
||||
src/bun.js/bindings/NodeVMModule.cpp
|
||||
src/bun.js/bindings/NodeVMScript.cpp
|
||||
src/bun.js/bindings/NodeVMSourceTextModule.cpp
|
||||
src/bun.js/bindings/NodeVMSyntheticModule.cpp
|
||||
src/bun.js/bindings/NoOpForTesting.cpp
|
||||
src/bun.js/bindings/ObjectBindings.cpp
|
||||
src/bun.js/bindings/objects.cpp
|
||||
@@ -161,6 +179,7 @@ src/bun.js/bindings/Path.cpp
|
||||
src/bun.js/bindings/ProcessBindingBuffer.cpp
|
||||
src/bun.js/bindings/ProcessBindingConstants.cpp
|
||||
src/bun.js/bindings/ProcessBindingFs.cpp
|
||||
src/bun.js/bindings/ProcessBindingHTTPParser.cpp
|
||||
src/bun.js/bindings/ProcessBindingNatives.cpp
|
||||
src/bun.js/bindings/ProcessBindingTTYWrap.cpp
|
||||
src/bun.js/bindings/ProcessBindingUV.cpp
|
||||
@@ -409,6 +428,7 @@ src/bun.js/bindings/webcrypto/CryptoAlgorithmSHA224.cpp
|
||||
src/bun.js/bindings/webcrypto/CryptoAlgorithmSHA256.cpp
|
||||
src/bun.js/bindings/webcrypto/CryptoAlgorithmSHA384.cpp
|
||||
src/bun.js/bindings/webcrypto/CryptoAlgorithmSHA512.cpp
|
||||
src/bun.js/bindings/webcrypto/CryptoAlgorithmX25519.cpp
|
||||
src/bun.js/bindings/webcrypto/CryptoDigest.cpp
|
||||
src/bun.js/bindings/webcrypto/CryptoKey.cpp
|
||||
src/bun.js/bindings/webcrypto/CryptoKeyAES.cpp
|
||||
@@ -449,6 +469,7 @@ src/bun.js/bindings/webcrypto/JSRsaOaepParams.cpp
|
||||
src/bun.js/bindings/webcrypto/JSRsaOtherPrimesInfo.cpp
|
||||
src/bun.js/bindings/webcrypto/JSRsaPssParams.cpp
|
||||
src/bun.js/bindings/webcrypto/JSSubtleCrypto.cpp
|
||||
src/bun.js/bindings/webcrypto/JSX25519Params.cpp
|
||||
src/bun.js/bindings/webcrypto/OpenSSLUtilities.cpp
|
||||
src/bun.js/bindings/webcrypto/PhonyWorkQueue.cpp
|
||||
src/bun.js/bindings/webcrypto/SerializedCryptoKeyWrapOpenSSL.cpp
|
||||
@@ -463,4 +484,6 @@ src/bun.js/modules/NodeTTYModule.cpp
|
||||
src/bun.js/modules/NodeUtilTypesModule.cpp
|
||||
src/bun.js/modules/ObjectModule.cpp
|
||||
src/deps/libuwsockets.cpp
|
||||
src/io/io_darwin.cpp
|
||||
src/io/io_darwin.cpp
|
||||
src/vm/Semaphore.cpp
|
||||
src/vm/SigintWatcher.cpp
|
||||
@@ -15,4 +15,4 @@ src/codegen/generate-jssink.ts
|
||||
src/codegen/generate-node-errors.ts
|
||||
src/codegen/helpers.ts
|
||||
src/codegen/internal-module-registry-scanner.ts
|
||||
src/codegen/replacements.ts
|
||||
src/codegen/replacements.ts
|
||||
@@ -52,6 +52,7 @@ src/js/internal/debugger.ts
|
||||
src/js/internal/errors.ts
|
||||
src/js/internal/fifo.ts
|
||||
src/js/internal/fixed_queue.ts
|
||||
src/js/internal/freelist.ts
|
||||
src/js/internal/fs/cp-sync.ts
|
||||
src/js/internal/fs/cp.ts
|
||||
src/js/internal/fs/glob.ts
|
||||
@@ -160,4 +161,4 @@ src/js/thirdparty/node-fetch.ts
|
||||
src/js/thirdparty/undici.js
|
||||
src/js/thirdparty/vercel_fetch.js
|
||||
src/js/thirdparty/ws.js
|
||||
src/js/wasi-runner.js
|
||||
src/js/wasi-runner.js
|
||||
@@ -17,7 +17,8 @@ src/node-fallbacks/stream.js
|
||||
src/node-fallbacks/string_decoder.js
|
||||
src/node-fallbacks/sys.js
|
||||
src/node-fallbacks/timers.js
|
||||
src/node-fallbacks/timers.promises.js
|
||||
src/node-fallbacks/tty.js
|
||||
src/node-fallbacks/url.js
|
||||
src/node-fallbacks/util.js
|
||||
src/node-fallbacks/zlib.js
|
||||
src/node-fallbacks/zlib.js
|
||||
@@ -7,12 +7,14 @@ src/bun.js/api/h2.classes.ts
|
||||
src/bun.js/api/html_rewriter.classes.ts
|
||||
src/bun.js/api/JSBundler.classes.ts
|
||||
src/bun.js/api/postgres.classes.ts
|
||||
src/bun.js/api/ResumableSink.classes.ts
|
||||
src/bun.js/api/S3Client.classes.ts
|
||||
src/bun.js/api/S3Stat.classes.ts
|
||||
src/bun.js/api/server.classes.ts
|
||||
src/bun.js/api/Shell.classes.ts
|
||||
src/bun.js/api/ShellArgs.classes.ts
|
||||
src/bun.js/api/sockets.classes.ts
|
||||
src/bun.js/api/sourcemap.classes.ts
|
||||
src/bun.js/api/streams.classes.ts
|
||||
src/bun.js/api/valkey.classes.ts
|
||||
src/bun.js/api/zlib.classes.ts
|
||||
@@ -20,4 +22,4 @@ src/bun.js/node/node.classes.ts
|
||||
src/bun.js/resolve_message.classes.ts
|
||||
src/bun.js/test/jest.classes.ts
|
||||
src/bun.js/webcore/encoding.classes.ts
|
||||
src/bun.js/webcore/response.classes.ts
|
||||
src/bun.js/webcore/response.classes.ts
|
||||
@@ -10,7 +10,26 @@ src/allocators/NullableAllocator.zig
|
||||
src/analytics/analytics_schema.zig
|
||||
src/analytics/analytics_thread.zig
|
||||
src/api/schema.zig
|
||||
src/ast/Ast.zig
|
||||
src/ast/ASTMemoryAllocator.zig
|
||||
src/ast/B.zig
|
||||
src/ast/base.zig
|
||||
src/ast/Binding.zig
|
||||
src/ast/BundledAst.zig
|
||||
src/ast/CharFreq.zig
|
||||
src/ast/E.zig
|
||||
src/ast/Expr.zig
|
||||
src/ast/G.zig
|
||||
src/ast/Macro.zig
|
||||
src/ast/NewStore.zig
|
||||
src/ast/Op.zig
|
||||
src/ast/S.zig
|
||||
src/ast/Scope.zig
|
||||
src/ast/ServerComponentBoundary.zig
|
||||
src/ast/Stmt.zig
|
||||
src/ast/Symbol.zig
|
||||
src/ast/TS.zig
|
||||
src/ast/UseDirective.zig
|
||||
src/async/posix_event_loop.zig
|
||||
src/async/stub_event_loop.zig
|
||||
src/async/windows_event_loop.zig
|
||||
@@ -32,7 +51,11 @@ src/bun.js/api/bun/h2_frame_parser.zig
|
||||
src/bun.js/api/bun/lshpack.zig
|
||||
src/bun.js/api/bun/process.zig
|
||||
src/bun.js/api/bun/socket.zig
|
||||
src/bun.js/api/bun/socket/Handlers.zig
|
||||
src/bun.js/api/bun/socket/Listener.zig
|
||||
src/bun.js/api/bun/socket/SocketAddress.zig
|
||||
src/bun.js/api/bun/socket/tls_socket_functions.zig
|
||||
src/bun.js/api/bun/socket/WindowsNamedPipeContext.zig
|
||||
src/bun.js/api/bun/spawn.zig
|
||||
src/bun.js/api/bun/spawn/stdio.zig
|
||||
src/bun.js/api/bun/ssl_wrapper.zig
|
||||
@@ -55,13 +78,24 @@ src/bun.js/api/html_rewriter.zig
|
||||
src/bun.js/api/JSBundler.zig
|
||||
src/bun.js/api/JSTranspiler.zig
|
||||
src/bun.js/api/server.zig
|
||||
src/bun.js/api/server/AnyRequestContext.zig
|
||||
src/bun.js/api/server/FileRoute.zig
|
||||
src/bun.js/api/server/HTMLBundle.zig
|
||||
src/bun.js/api/server/HTTPStatusText.zig
|
||||
src/bun.js/api/server/InspectorBunFrontendDevServerAgent.zig
|
||||
src/bun.js/api/server/NodeHTTPResponse.zig
|
||||
src/bun.js/api/server/RequestContext.zig
|
||||
src/bun.js/api/server/ServerConfig.zig
|
||||
src/bun.js/api/server/ServerWebSocket.zig
|
||||
src/bun.js/api/server/SSLConfig.zig
|
||||
src/bun.js/api/server/StaticRoute.zig
|
||||
src/bun.js/api/server/WebSocketServerContext.zig
|
||||
src/bun.js/api/streams.classes.zig
|
||||
src/bun.js/api/Timer.zig
|
||||
src/bun.js/api/Timer/EventLoopTimer.zig
|
||||
src/bun.js/api/Timer/ImmediateObject.zig
|
||||
src/bun.js/api/Timer/TimeoutObject.zig
|
||||
src/bun.js/api/Timer/TimerObjectInternals.zig
|
||||
src/bun.js/api/TOMLObject.zig
|
||||
src/bun.js/api/UnsafeObject.zig
|
||||
src/bun.js/bindgen_test.zig
|
||||
@@ -70,6 +104,7 @@ src/bun.js/bindings/AnyPromise.zig
|
||||
src/bun.js/bindings/bun-simdutf.zig
|
||||
src/bun.js/bindings/CachedBytecode.zig
|
||||
src/bun.js/bindings/CallFrame.zig
|
||||
src/bun.js/bindings/CatchScope.zig
|
||||
src/bun.js/bindings/codegen.zig
|
||||
src/bun.js/bindings/CommonAbortReason.zig
|
||||
src/bun.js/bindings/CommonStrings.zig
|
||||
@@ -86,8 +121,6 @@ src/bun.js/bindings/Exception.zig
|
||||
src/bun.js/bindings/FetchHeaders.zig
|
||||
src/bun.js/bindings/FFI.zig
|
||||
src/bun.js/bindings/generated_classes_list.zig
|
||||
src/bun.js/bindings/GeneratedBindings.zig
|
||||
src/bun.js/bindings/GeneratedJS2Native.zig
|
||||
src/bun.js/bindings/GetterSetter.zig
|
||||
src/bun.js/bindings/HTTPServerAgent.zig
|
||||
src/bun.js/bindings/JSArray.zig
|
||||
@@ -107,6 +140,7 @@ src/bun.js/bindings/JSPropertyIterator.zig
|
||||
src/bun.js/bindings/JSRef.zig
|
||||
src/bun.js/bindings/JSRuntimeType.zig
|
||||
src/bun.js/bindings/JSString.zig
|
||||
src/bun.js/bindings/JSType.zig
|
||||
src/bun.js/bindings/JSUint8Array.zig
|
||||
src/bun.js/bindings/JSValue.zig
|
||||
src/bun.js/bindings/NodeModuleModule.zig
|
||||
@@ -135,6 +169,21 @@ src/bun.js/ConsoleObject.zig
|
||||
src/bun.js/Counters.zig
|
||||
src/bun.js/Debugger.zig
|
||||
src/bun.js/event_loop.zig
|
||||
src/bun.js/event_loop/AnyEventLoop.zig
|
||||
src/bun.js/event_loop/AnyTask.zig
|
||||
src/bun.js/event_loop/AnyTaskWithExtraContext.zig
|
||||
src/bun.js/event_loop/ConcurrentPromiseTask.zig
|
||||
src/bun.js/event_loop/ConcurrentTask.zig
|
||||
src/bun.js/event_loop/CppTask.zig
|
||||
src/bun.js/event_loop/DeferredTaskQueue.zig
|
||||
src/bun.js/event_loop/EventLoopHandle.zig
|
||||
src/bun.js/event_loop/GarbageCollectionController.zig
|
||||
src/bun.js/event_loop/JSCScheduler.zig
|
||||
src/bun.js/event_loop/ManagedTask.zig
|
||||
src/bun.js/event_loop/MiniEventLoop.zig
|
||||
src/bun.js/event_loop/PosixSignalHandle.zig
|
||||
src/bun.js/event_loop/Task.zig
|
||||
src/bun.js/event_loop/WorkTask.zig
|
||||
src/bun.js/hot_reloader.zig
|
||||
src/bun.js/ipc.zig
|
||||
src/bun.js/javascript_core_c_api.zig
|
||||
@@ -178,6 +227,9 @@ src/bun.js/node/util/parse_args_utils.zig
|
||||
src/bun.js/node/util/parse_args.zig
|
||||
src/bun.js/node/util/validators.zig
|
||||
src/bun.js/node/win_watcher.zig
|
||||
src/bun.js/node/zlib/NativeBrotli.zig
|
||||
src/bun.js/node/zlib/NativeZlib.zig
|
||||
src/bun.js/node/zlib/NativeZstd.zig
|
||||
src/bun.js/ProcessAutoKiller.zig
|
||||
src/bun.js/rare_data.zig
|
||||
src/bun.js/ResolveMessage.zig
|
||||
@@ -219,9 +271,11 @@ src/bun.js/webcore/prompt.zig
|
||||
src/bun.js/webcore/ReadableStream.zig
|
||||
src/bun.js/webcore/Request.zig
|
||||
src/bun.js/webcore/Response.zig
|
||||
src/bun.js/webcore/ResumableSink.zig
|
||||
src/bun.js/webcore/S3Client.zig
|
||||
src/bun.js/webcore/S3File.zig
|
||||
src/bun.js/webcore/S3Stat.zig
|
||||
src/bun.js/webcore/ScriptExecutionContext.zig
|
||||
src/bun.js/webcore/Sink.zig
|
||||
src/bun.js/webcore/streams.zig
|
||||
src/bun.js/webcore/TextDecoder.zig
|
||||
@@ -229,14 +283,48 @@ src/bun.js/webcore/TextEncoder.zig
|
||||
src/bun.js/webcore/TextEncoderStreamEncoder.zig
|
||||
src/bun.js/WTFTimer.zig
|
||||
src/bun.zig
|
||||
src/bundler/AstBuilder.zig
|
||||
src/bundler/bundle_v2.zig
|
||||
src/bundler/BundleThread.zig
|
||||
src/bundler/Chunk.zig
|
||||
src/bundler/DeferredBatchTask.zig
|
||||
src/bundler/entry_points.zig
|
||||
src/bundler/Graph.zig
|
||||
src/bundler/HTMLImportManifest.zig
|
||||
src/bundler/linker_context/computeChunks.zig
|
||||
src/bundler/linker_context/computeCrossChunkDependencies.zig
|
||||
src/bundler/linker_context/convertStmtsForChunk.zig
|
||||
src/bundler/linker_context/convertStmtsForChunkForDevServer.zig
|
||||
src/bundler/linker_context/doStep5.zig
|
||||
src/bundler/linker_context/findAllImportedPartsInJSOrder.zig
|
||||
src/bundler/linker_context/findImportedCSSFilesInJSOrder.zig
|
||||
src/bundler/linker_context/findImportedFilesInCSSOrder.zig
|
||||
src/bundler/linker_context/generateChunksInParallel.zig
|
||||
src/bundler/linker_context/generateCodeForFileInChunkJS.zig
|
||||
src/bundler/linker_context/generateCodeForLazyExport.zig
|
||||
src/bundler/linker_context/generateCompileResultForCssChunk.zig
|
||||
src/bundler/linker_context/generateCompileResultForHtmlChunk.zig
|
||||
src/bundler/linker_context/generateCompileResultForJSChunk.zig
|
||||
src/bundler/linker_context/postProcessCSSChunk.zig
|
||||
src/bundler/linker_context/postProcessHTMLChunk.zig
|
||||
src/bundler/linker_context/postProcessJSChunk.zig
|
||||
src/bundler/linker_context/prepareCssAstsForChunk.zig
|
||||
src/bundler/linker_context/renameSymbolsInChunk.zig
|
||||
src/bundler/linker_context/scanImportsAndExports.zig
|
||||
src/bundler/linker_context/writeOutputFilesToDisk.zig
|
||||
src/bundler/LinkerContext.zig
|
||||
src/bundler/LinkerGraph.zig
|
||||
src/bundler/ParseTask.zig
|
||||
src/bundler/ServerComponentParseTask.zig
|
||||
src/bundler/ThreadPool.zig
|
||||
src/bunfig.zig
|
||||
src/cache.zig
|
||||
src/ci_info.zig
|
||||
src/cli.zig
|
||||
src/cli/add_command.zig
|
||||
src/cli/add_completions.zig
|
||||
src/cli/Arguments.zig
|
||||
src/cli/audit_command.zig
|
||||
src/cli/build_command.zig
|
||||
src/cli/bunx_command.zig
|
||||
src/cli/colon_list_type.zig
|
||||
@@ -256,6 +344,8 @@ src/cli/package_manager_command.zig
|
||||
src/cli/patch_command.zig
|
||||
src/cli/patch_commit_command.zig
|
||||
src/cli/pm_trusted_command.zig
|
||||
src/cli/pm_version_command.zig
|
||||
src/cli/pm_view_command.zig
|
||||
src/cli/publish_command.zig
|
||||
src/cli/remove_command.zig
|
||||
src/cli/run_command.zig
|
||||
@@ -383,7 +473,22 @@ src/deps/picohttp.zig
|
||||
src/deps/picohttpparser.zig
|
||||
src/deps/tcc.zig
|
||||
src/deps/uws.zig
|
||||
src/deps/uws/App.zig
|
||||
src/deps/uws/BodyReaderMixin.zig
|
||||
src/deps/uws/ConnectingSocket.zig
|
||||
src/deps/uws/InternalLoopData.zig
|
||||
src/deps/uws/ListenSocket.zig
|
||||
src/deps/uws/Loop.zig
|
||||
src/deps/uws/Request.zig
|
||||
src/deps/uws/Response.zig
|
||||
src/deps/uws/socket.zig
|
||||
src/deps/uws/SocketContext.zig
|
||||
src/deps/uws/Timer.zig
|
||||
src/deps/uws/udp.zig
|
||||
src/deps/uws/UpgradedDuplex.zig
|
||||
src/deps/uws/us_socket_t.zig
|
||||
src/deps/uws/WebSocket.zig
|
||||
src/deps/uws/WindowsNamedPipe.zig
|
||||
src/deps/zig-clap/clap.zig
|
||||
src/deps/zig-clap/clap/args.zig
|
||||
src/deps/zig-clap/clap/comptime.zig
|
||||
@@ -404,6 +509,7 @@ src/fd.zig
|
||||
src/feature_flags.zig
|
||||
src/fmt.zig
|
||||
src/fs.zig
|
||||
src/fs/stat_hash.zig
|
||||
src/futex.zig
|
||||
src/generated_perf_trace_events.zig
|
||||
src/generated_versions_list.zig
|
||||
@@ -418,12 +524,29 @@ src/hive_array.zig
|
||||
src/hmac.zig
|
||||
src/HTMLScanner.zig
|
||||
src/http.zig
|
||||
src/http/header_builder.zig
|
||||
src/http/method.zig
|
||||
src/http/mime_type.zig
|
||||
src/http/url_path.zig
|
||||
src/http/AsyncHTTP.zig
|
||||
src/http/CertificateInfo.zig
|
||||
src/http/Decompressor.zig
|
||||
src/http/Encoding.zig
|
||||
src/http/FetchRedirect.zig
|
||||
src/http/HeaderBuilder.zig
|
||||
src/http/Headers.zig
|
||||
src/http/HTTPCertError.zig
|
||||
src/http/HTTPContext.zig
|
||||
src/http/HTTPRequestBody.zig
|
||||
src/http/HTTPThread.zig
|
||||
src/http/InitError.zig
|
||||
src/http/InternalState.zig
|
||||
src/http/Method.zig
|
||||
src/http/MimeType.zig
|
||||
src/http/ProxyTunnel.zig
|
||||
src/http/SendFile.zig
|
||||
src/http/Signals.zig
|
||||
src/http/ThreadSafeStreamBuffer.zig
|
||||
src/http/URLPath.zig
|
||||
src/http/websocket_client.zig
|
||||
src/http/websocket_client/CppWebSocket.zig
|
||||
src/http/websocket_client/WebSocketDeflate.zig
|
||||
src/http/websocket_client/WebSocketUpgradeClient.zig
|
||||
src/http/websocket_http_client.zig
|
||||
src/http/websocket.zig
|
||||
@@ -432,15 +555,56 @@ src/identity_context.zig
|
||||
src/import_record.zig
|
||||
src/ini.zig
|
||||
src/install/bin.zig
|
||||
src/install/bun.lock.zig
|
||||
src/install/dependency.zig
|
||||
src/install/ExternalSlice.zig
|
||||
src/install/extract_tarball.zig
|
||||
src/install/hoisted_install.zig
|
||||
src/install/install_binding.zig
|
||||
src/install/install.zig
|
||||
src/install/integrity.zig
|
||||
src/install/isolated_install.zig
|
||||
src/install/isolated_install/Hardlinker.zig
|
||||
src/install/isolated_install/Installer.zig
|
||||
src/install/isolated_install/Store.zig
|
||||
src/install/isolated_install/Symlinker.zig
|
||||
src/install/lifecycle_script_runner.zig
|
||||
src/install/lockfile.zig
|
||||
src/install/lockfile/Buffers.zig
|
||||
src/install/lockfile/bun.lock.zig
|
||||
src/install/lockfile/bun.lockb.zig
|
||||
src/install/lockfile/CatalogMap.zig
|
||||
src/install/lockfile/lockfile_json_stringify_for_debugging.zig
|
||||
src/install/lockfile/OverrideMap.zig
|
||||
src/install/lockfile/Package.zig
|
||||
src/install/lockfile/Package/Meta.zig
|
||||
src/install/lockfile/Package/Scripts.zig
|
||||
src/install/lockfile/Package/WorkspaceMap.zig
|
||||
src/install/lockfile/printer/tree_printer.zig
|
||||
src/install/lockfile/printer/Yarn.zig
|
||||
src/install/lockfile/Tree.zig
|
||||
src/install/migration.zig
|
||||
src/install/NetworkTask.zig
|
||||
src/install/npm.zig
|
||||
src/install/PackageInstall.zig
|
||||
src/install/PackageInstaller.zig
|
||||
src/install/PackageManager.zig
|
||||
src/install/PackageManager/CommandLineArguments.zig
|
||||
src/install/PackageManager/install_with_manager.zig
|
||||
src/install/PackageManager/PackageJSONEditor.zig
|
||||
src/install/PackageManager/PackageManagerDirectories.zig
|
||||
src/install/PackageManager/PackageManagerEnqueue.zig
|
||||
src/install/PackageManager/PackageManagerLifecycle.zig
|
||||
src/install/PackageManager/PackageManagerOptions.zig
|
||||
src/install/PackageManager/PackageManagerResolution.zig
|
||||
src/install/PackageManager/patchPackage.zig
|
||||
src/install/PackageManager/processDependencyList.zig
|
||||
src/install/PackageManager/ProgressStrings.zig
|
||||
src/install/PackageManager/runTasks.zig
|
||||
src/install/PackageManager/updatePackageJSONAndInstall.zig
|
||||
src/install/PackageManager/UpdateRequest.zig
|
||||
src/install/PackageManager/WorkspacePackageJSONCache.zig
|
||||
src/install/PackageManagerTask.zig
|
||||
src/install/PackageManifestMap.zig
|
||||
src/install/padding_checker.zig
|
||||
src/install/patch_install.zig
|
||||
src/install/repository.zig
|
||||
@@ -452,11 +616,11 @@ src/install/windows-shim/bun_shim_impl.zig
|
||||
src/io/heap.zig
|
||||
src/io/io.zig
|
||||
src/io/MaxBuf.zig
|
||||
src/io/openForWriting.zig
|
||||
src/io/PipeReader.zig
|
||||
src/io/pipes.zig
|
||||
src/io/PipeWriter.zig
|
||||
src/io/source.zig
|
||||
src/io/time.zig
|
||||
src/js_ast.zig
|
||||
src/js_lexer_tables.zig
|
||||
src/js_lexer.zig
|
||||
@@ -485,6 +649,10 @@ src/options.zig
|
||||
src/output.zig
|
||||
src/OutputFile.zig
|
||||
src/patch.zig
|
||||
src/paths.zig
|
||||
src/paths/EnvPath.zig
|
||||
src/paths/path_buffer_pool.zig
|
||||
src/paths/Path.zig
|
||||
src/perf.zig
|
||||
src/pool.zig
|
||||
src/Progress.zig
|
||||
@@ -523,6 +691,7 @@ src/semver/SemverString.zig
|
||||
src/semver/SlicedString.zig
|
||||
src/semver/Version.zig
|
||||
src/sha.zig
|
||||
src/shell/AllocScope.zig
|
||||
src/shell/braces.zig
|
||||
src/shell/Builtin.zig
|
||||
src/shell/builtin/basename.zig
|
||||
@@ -547,31 +716,118 @@ src/shell/builtin/yes.zig
|
||||
src/shell/EnvMap.zig
|
||||
src/shell/EnvStr.zig
|
||||
src/shell/interpreter.zig
|
||||
src/shell/IO.zig
|
||||
src/shell/IOReader.zig
|
||||
src/shell/IOWriter.zig
|
||||
src/shell/ParsedShellScript.zig
|
||||
src/shell/RefCountedStr.zig
|
||||
src/shell/shell.zig
|
||||
src/shell/states/Assigns.zig
|
||||
src/shell/states/Async.zig
|
||||
src/shell/states/Base.zig
|
||||
src/shell/states/Binary.zig
|
||||
src/shell/states/Cmd.zig
|
||||
src/shell/states/CondExpr.zig
|
||||
src/shell/states/Expansion.zig
|
||||
src/shell/states/If.zig
|
||||
src/shell/states/Pipeline.zig
|
||||
src/shell/states/Script.zig
|
||||
src/shell/states/Stmt.zig
|
||||
src/shell/states/Subshell.zig
|
||||
src/shell/subproc.zig
|
||||
src/shell/util.zig
|
||||
src/shell/Yield.zig
|
||||
src/sourcemap/CodeCoverage.zig
|
||||
src/sourcemap/JSSourceMap.zig
|
||||
src/sourcemap/LineOffsetTable.zig
|
||||
src/sourcemap/sourcemap.zig
|
||||
src/sourcemap/VLQ.zig
|
||||
src/sql/DataCell.zig
|
||||
src/sql/postgres.zig
|
||||
src/sql/postgres/postgres_protocol.zig
|
||||
src/sql/postgres/postgres_types.zig
|
||||
src/sql/postgres/AnyPostgresError.zig
|
||||
src/sql/postgres/AuthenticationState.zig
|
||||
src/sql/postgres/CommandTag.zig
|
||||
src/sql/postgres/ConnectionFlags.zig
|
||||
src/sql/postgres/Data.zig
|
||||
src/sql/postgres/DataCell.zig
|
||||
src/sql/postgres/DebugSocketMonitorReader.zig
|
||||
src/sql/postgres/DebugSocketMonitorWriter.zig
|
||||
src/sql/postgres/ObjectIterator.zig
|
||||
src/sql/postgres/PostgresCachedStructure.zig
|
||||
src/sql/postgres/PostgresProtocol.zig
|
||||
src/sql/postgres/PostgresRequest.zig
|
||||
src/sql/postgres/PostgresSQLConnection.zig
|
||||
src/sql/postgres/PostgresSQLContext.zig
|
||||
src/sql/postgres/PostgresSQLQuery.zig
|
||||
src/sql/postgres/PostgresSQLQueryResultMode.zig
|
||||
src/sql/postgres/PostgresSQLStatement.zig
|
||||
src/sql/postgres/PostgresTypes.zig
|
||||
src/sql/postgres/protocol/ArrayList.zig
|
||||
src/sql/postgres/protocol/Authentication.zig
|
||||
src/sql/postgres/protocol/BackendKeyData.zig
|
||||
src/sql/postgres/protocol/Close.zig
|
||||
src/sql/postgres/protocol/ColumnIdentifier.zig
|
||||
src/sql/postgres/protocol/CommandComplete.zig
|
||||
src/sql/postgres/protocol/CopyData.zig
|
||||
src/sql/postgres/protocol/CopyFail.zig
|
||||
src/sql/postgres/protocol/CopyInResponse.zig
|
||||
src/sql/postgres/protocol/CopyOutResponse.zig
|
||||
src/sql/postgres/protocol/DataRow.zig
|
||||
src/sql/postgres/protocol/DecoderWrap.zig
|
||||
src/sql/postgres/protocol/Describe.zig
|
||||
src/sql/postgres/protocol/ErrorResponse.zig
|
||||
src/sql/postgres/protocol/Execute.zig
|
||||
src/sql/postgres/protocol/FieldDescription.zig
|
||||
src/sql/postgres/protocol/FieldMessage.zig
|
||||
src/sql/postgres/protocol/FieldType.zig
|
||||
src/sql/postgres/protocol/NegotiateProtocolVersion.zig
|
||||
src/sql/postgres/protocol/NewReader.zig
|
||||
src/sql/postgres/protocol/NewWriter.zig
|
||||
src/sql/postgres/protocol/NoticeResponse.zig
|
||||
src/sql/postgres/protocol/NotificationResponse.zig
|
||||
src/sql/postgres/protocol/ParameterDescription.zig
|
||||
src/sql/postgres/protocol/ParameterStatus.zig
|
||||
src/sql/postgres/protocol/Parse.zig
|
||||
src/sql/postgres/protocol/PasswordMessage.zig
|
||||
src/sql/postgres/protocol/PortalOrPreparedStatement.zig
|
||||
src/sql/postgres/protocol/ReadyForQuery.zig
|
||||
src/sql/postgres/protocol/RowDescription.zig
|
||||
src/sql/postgres/protocol/SASLInitialResponse.zig
|
||||
src/sql/postgres/protocol/SASLResponse.zig
|
||||
src/sql/postgres/protocol/StackReader.zig
|
||||
src/sql/postgres/protocol/StartupMessage.zig
|
||||
src/sql/postgres/protocol/TransactionStatusIndicator.zig
|
||||
src/sql/postgres/protocol/WriteWrap.zig
|
||||
src/sql/postgres/protocol/zHelpers.zig
|
||||
src/sql/postgres/QueryBindingIterator.zig
|
||||
src/sql/postgres/SASL.zig
|
||||
src/sql/postgres/Signature.zig
|
||||
src/sql/postgres/SocketMonitor.zig
|
||||
src/sql/postgres/SSLMode.zig
|
||||
src/sql/postgres/Status.zig
|
||||
src/sql/postgres/TLSStatus.zig
|
||||
src/sql/postgres/types/bool.zig
|
||||
src/sql/postgres/types/bytea.zig
|
||||
src/sql/postgres/types/date.zig
|
||||
src/sql/postgres/types/int_types.zig
|
||||
src/sql/postgres/types/json.zig
|
||||
src/sql/postgres/types/numeric.zig
|
||||
src/sql/postgres/types/PostgresString.zig
|
||||
src/sql/postgres/types/Tag.zig
|
||||
src/StandaloneModuleGraph.zig
|
||||
src/StaticHashMap.zig
|
||||
src/string_immutable.zig
|
||||
src/string_types.zig
|
||||
src/string.zig
|
||||
src/string/escapeHTML.zig
|
||||
src/string/HashedString.zig
|
||||
src/string/MutableString.zig
|
||||
src/string/paths.zig
|
||||
src/string/PathString.zig
|
||||
src/string/SmolStr.zig
|
||||
src/string/StringBuilder.zig
|
||||
src/string/StringJoiner.zig
|
||||
src/string/unicode.zig
|
||||
src/string/visible.zig
|
||||
src/string/WTFStringImpl.zig
|
||||
src/sync.zig
|
||||
src/sys_uv.zig
|
||||
@@ -607,4 +863,4 @@ src/windows.zig
|
||||
src/work_pool.zig
|
||||
src/workaround_missing_symbols.zig
|
||||
src/wyhash.zig
|
||||
src/zlib.zig
|
||||
src/zlib.zig
|
||||
@@ -42,11 +42,34 @@ else()
|
||||
set(CONFIGURE_DEPENDS "")
|
||||
endif()
|
||||
|
||||
# --- Dependencies ---
|
||||
|
||||
set(BUN_DEPENDENCIES
|
||||
BoringSSL
|
||||
Brotli
|
||||
Cares
|
||||
Highway
|
||||
LibDeflate
|
||||
LolHtml
|
||||
Lshpack
|
||||
Mimalloc
|
||||
TinyCC
|
||||
Zlib
|
||||
LibArchive # must be loaded after zlib
|
||||
HdrHistogram # must be loaded after zlib
|
||||
Zstd
|
||||
)
|
||||
|
||||
include(CloneZstd)
|
||||
# foreach(dependency ${BUN_DEPENDENCIES})
|
||||
# include(Clone${dependency})
|
||||
# endforeach()
|
||||
|
||||
# --- Codegen ---
|
||||
|
||||
set(BUN_ERROR_SOURCE ${CWD}/packages/bun-error)
|
||||
|
||||
absolute_sources(BUN_ERROR_SOURCES ${CWD}/cmake/BunErrorSources.txt)
|
||||
absolute_sources(BUN_ERROR_SOURCES ${CWD}/cmake/sources/BunErrorSources.txt)
|
||||
|
||||
set(BUN_ERROR_OUTPUT ${CODEGEN_PATH}/bun-error)
|
||||
set(BUN_ERROR_OUTPUTS
|
||||
@@ -135,7 +158,7 @@ register_command(
|
||||
|
||||
set(BUN_NODE_FALLBACKS_SOURCE ${CWD}/src/node-fallbacks)
|
||||
|
||||
absolute_sources(BUN_NODE_FALLBACKS_SOURCES ${CWD}/cmake/NodeFallbacksSources.txt)
|
||||
absolute_sources(BUN_NODE_FALLBACKS_SOURCES ${CWD}/cmake/sources/NodeFallbacksSources.txt)
|
||||
|
||||
set(BUN_NODE_FALLBACKS_OUTPUT ${CODEGEN_PATH}/node-fallbacks)
|
||||
set(BUN_NODE_FALLBACKS_OUTPUTS)
|
||||
@@ -161,14 +184,9 @@ register_command(
|
||||
CWD
|
||||
${BUN_NODE_FALLBACKS_SOURCE}
|
||||
COMMAND
|
||||
${BUN_EXECUTABLE} x
|
||||
esbuild ${ESBUILD_ARGS}
|
||||
${BUN_EXECUTABLE} run build-fallbacks
|
||||
${BUN_NODE_FALLBACKS_OUTPUT}
|
||||
${BUN_NODE_FALLBACKS_SOURCES}
|
||||
--outdir=${BUN_NODE_FALLBACKS_OUTPUT}
|
||||
--format=esm
|
||||
--minify
|
||||
--bundle
|
||||
--platform=browser
|
||||
SOURCES
|
||||
${BUN_NODE_FALLBACKS_SOURCES}
|
||||
${BUN_NODE_FALLBACKS_NODE_MODULES}
|
||||
@@ -235,7 +253,7 @@ register_command(
|
||||
|
||||
set(BUN_ZIG_GENERATED_CLASSES_SCRIPT ${CWD}/src/codegen/generate-classes.ts)
|
||||
|
||||
absolute_sources(BUN_ZIG_GENERATED_CLASSES_SOURCES ${CWD}/cmake/ZigGeneratedClassesSources.txt)
|
||||
absolute_sources(BUN_ZIG_GENERATED_CLASSES_SOURCES ${CWD}/cmake/sources/ZigGeneratedClassesSources.txt)
|
||||
|
||||
set(BUN_ZIG_GENERATED_CLASSES_OUTPUTS
|
||||
${CODEGEN_PATH}/ZigGeneratedClasses.h
|
||||
@@ -268,8 +286,8 @@ register_command(
|
||||
|
||||
set(BUN_JAVASCRIPT_CODEGEN_SCRIPT ${CWD}/src/codegen/bundle-modules.ts)
|
||||
|
||||
absolute_sources(BUN_JAVASCRIPT_SOURCES ${CWD}/cmake/JavaScriptSources.txt)
|
||||
absolute_sources(BUN_JAVASCRIPT_CODEGEN_SOURCES ${CWD}/cmake/JavaScriptCodegenSources.txt)
|
||||
absolute_sources(BUN_JAVASCRIPT_SOURCES ${CWD}/cmake/sources/JavaScriptSources.txt)
|
||||
absolute_sources(BUN_JAVASCRIPT_CODEGEN_SOURCES ${CWD}/cmake/sources/JavaScriptCodegenSources.txt)
|
||||
|
||||
list(APPEND BUN_JAVASCRIPT_CODEGEN_SOURCES
|
||||
${CWD}/src/bun.js/bindings/InternalModuleRegistry.cpp
|
||||
@@ -311,7 +329,7 @@ register_command(
|
||||
|
||||
set(BUN_BAKE_RUNTIME_CODEGEN_SCRIPT ${CWD}/src/codegen/bake-codegen.ts)
|
||||
|
||||
absolute_sources(BUN_BAKE_RUNTIME_SOURCES ${CWD}/cmake/BakeRuntimeSources.txt)
|
||||
absolute_sources(BUN_BAKE_RUNTIME_SOURCES ${CWD}/cmake/sources/BakeRuntimeSources.txt)
|
||||
|
||||
list(APPEND BUN_BAKE_RUNTIME_CODEGEN_SOURCES
|
||||
${CWD}/src/bun.js/bindings/InternalModuleRegistry.cpp
|
||||
@@ -344,7 +362,7 @@ register_command(
|
||||
|
||||
set(BUN_BINDGEN_SCRIPT ${CWD}/src/codegen/bindgen.ts)
|
||||
|
||||
absolute_sources(BUN_BINDGEN_SOURCES ${CWD}/cmake/BindgenSources.txt)
|
||||
absolute_sources(BUN_BINDGEN_SOURCES ${CWD}/cmake/sources/BindgenSources.txt)
|
||||
|
||||
set(BUN_BINDGEN_CPP_OUTPUTS
|
||||
${CODEGEN_PATH}/GeneratedBindings.cpp
|
||||
@@ -413,6 +431,7 @@ set(BUN_OBJECT_LUT_SOURCES
|
||||
${CWD}/src/bun.js/bindings/ProcessBindingConstants.cpp
|
||||
${CWD}/src/bun.js/bindings/ProcessBindingFs.cpp
|
||||
${CWD}/src/bun.js/bindings/ProcessBindingNatives.cpp
|
||||
${CWD}/src/bun.js/bindings/ProcessBindingHTTPParser.cpp
|
||||
${CWD}/src/bun.js/modules/NodeModuleModule.cpp
|
||||
${CODEGEN_PATH}/ZigGeneratedClasses.lut.txt
|
||||
)
|
||||
@@ -426,6 +445,7 @@ set(BUN_OBJECT_LUT_OUTPUTS
|
||||
${CODEGEN_PATH}/ProcessBindingConstants.lut.h
|
||||
${CODEGEN_PATH}/ProcessBindingFs.lut.h
|
||||
${CODEGEN_PATH}/ProcessBindingNatives.lut.h
|
||||
${CODEGEN_PATH}/ProcessBindingHTTPParser.lut.h
|
||||
${CODEGEN_PATH}/NodeModuleModule.lut.h
|
||||
${CODEGEN_PATH}/ZigGeneratedClasses.lut.h
|
||||
)
|
||||
@@ -501,7 +521,7 @@ WEBKIT_ADD_SOURCE_DEPENDENCIES(
|
||||
|
||||
# --- Zig ---
|
||||
|
||||
absolute_sources(BUN_ZIG_SOURCES ${CWD}/cmake/ZigSources.txt)
|
||||
absolute_sources(BUN_ZIG_SOURCES ${CWD}/cmake/sources/ZigSources.txt)
|
||||
|
||||
list(APPEND BUN_ZIG_SOURCES
|
||||
${CWD}/build.zig
|
||||
@@ -585,6 +605,7 @@ register_command(
|
||||
${BUN_ZIG_OUTPUT}
|
||||
TARGETS
|
||||
clone-zig
|
||||
clone-zstd
|
||||
SOURCES
|
||||
${BUN_ZIG_SOURCES}
|
||||
${BUN_ZIG_GENERATED_SOURCES}
|
||||
@@ -598,8 +619,8 @@ set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "build.zig")
|
||||
set(BUN_USOCKETS_SOURCE ${CWD}/packages/bun-usockets)
|
||||
|
||||
# hand written cpp source files. Full list of "source" code (including codegen) is in BUN_CPP_SOURCES
|
||||
absolute_sources(BUN_CXX_SOURCES ${CWD}/cmake/CxxSources.txt)
|
||||
absolute_sources(BUN_C_SOURCES ${CWD}/cmake/CSources.txt)
|
||||
absolute_sources(BUN_CXX_SOURCES ${CWD}/cmake/sources/CxxSources.txt)
|
||||
absolute_sources(BUN_C_SOURCES ${CWD}/cmake/sources/CSources.txt)
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND BUN_CXX_SOURCES ${CWD}/src/bun.js/bindings/windows/rescle.cpp)
|
||||
@@ -629,8 +650,13 @@ register_command(
|
||||
-DDOWNLOAD_PATH=${NODEJS_HEADERS_PATH}
|
||||
-DDOWNLOAD_URL=https://nodejs.org/dist/v${NODEJS_VERSION}/node-v${NODEJS_VERSION}-headers.tar.gz
|
||||
-P ${CWD}/cmake/scripts/DownloadUrl.cmake
|
||||
COMMAND
|
||||
${CMAKE_COMMAND}
|
||||
-DNODE_INCLUDE_DIR=${NODEJS_HEADERS_PATH}/include
|
||||
-P ${CWD}/cmake/scripts/PrepareNodeHeaders.cmake
|
||||
OUTPUTS
|
||||
${NODEJS_HEADERS_PATH}/include/node/node_version.h
|
||||
${NODEJS_HEADERS_PATH}/include/.node-headers-prepared
|
||||
)
|
||||
|
||||
list(APPEND BUN_CPP_SOURCES
|
||||
@@ -652,20 +678,14 @@ if(WIN32)
|
||||
else()
|
||||
set(Bun_VERSION_WITH_TAG ${VERSION})
|
||||
endif()
|
||||
set(BUN_ICO_PATH ${CWD}/src/bun.ico)
|
||||
configure_file(${CWD}/src/bun.ico ${CODEGEN_PATH}/bun.ico COPYONLY)
|
||||
set(BUN_ICO_PATH ${CODEGEN_PATH}/bun.ico)
|
||||
configure_file(
|
||||
${CWD}/src/windows-app-info.rc
|
||||
${CODEGEN_PATH}/windows-app-info.rc
|
||||
@ONLY
|
||||
)
|
||||
add_custom_command(
|
||||
OUTPUT ${CODEGEN_PATH}/windows-app-info.res
|
||||
COMMAND rc.exe /fo ${CODEGEN_PATH}/windows-app-info.res ${CODEGEN_PATH}/windows-app-info.rc
|
||||
DEPENDS ${CODEGEN_PATH}/windows-app-info.rc ${CODEGEN_PATH}/bun.ico
|
||||
COMMENT "Adding Windows resource file ${CODEGEN_PATH}/windows-app-info.res with ico in ${CODEGEN_PATH}/bun.ico"
|
||||
)
|
||||
set(WINDOWS_RESOURCES ${CODEGEN_PATH}/windows-app-info.res)
|
||||
set(WINDOWS_RESOURCES ${CODEGEN_PATH}/windows-app-info.rc)
|
||||
endif()
|
||||
|
||||
# --- Executable ---
|
||||
@@ -737,6 +757,7 @@ target_include_directories(${bun} PRIVATE
|
||||
${CWD}/src/bun.js/bindings/webcore
|
||||
${CWD}/src/bun.js/bindings/webcrypto
|
||||
${CWD}/src/bun.js/bindings/node/crypto
|
||||
${CWD}/src/bun.js/bindings/node/http
|
||||
${CWD}/src/bun.js/bindings/sqlite
|
||||
${CWD}/src/bun.js/bindings/v8
|
||||
${CWD}/src/bun.js/modules
|
||||
@@ -747,9 +768,10 @@ target_include_directories(${bun} PRIVATE
|
||||
${VENDOR_PATH}
|
||||
${VENDOR_PATH}/picohttpparser
|
||||
${NODEJS_HEADERS_PATH}/include
|
||||
${NODEJS_HEADERS_PATH}/include/node
|
||||
)
|
||||
|
||||
if(NOT WIN32)
|
||||
if(NOT WIN32)
|
||||
target_include_directories(${bun} PRIVATE ${CWD}/src/bun.js/bindings/libuv)
|
||||
endif()
|
||||
|
||||
@@ -882,7 +904,7 @@ if(NOT WIN32)
|
||||
-Wno-nullability-completeness
|
||||
-Werror
|
||||
)
|
||||
|
||||
|
||||
if(ENABLE_ASAN)
|
||||
target_compile_options(${bun} PUBLIC
|
||||
-fsanitize=address
|
||||
@@ -895,6 +917,9 @@ if(NOT WIN32)
|
||||
else()
|
||||
target_compile_options(${bun} PUBLIC
|
||||
-Wno-nullability-completeness
|
||||
-Wno-inconsistent-dllimport
|
||||
-Wno-incompatible-pointer-types
|
||||
-Wno-deprecated-declarations
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -940,6 +965,7 @@ if(LINUX)
|
||||
if(NOT ABI STREQUAL "musl")
|
||||
target_link_options(${bun} PUBLIC
|
||||
-Wl,--wrap=exp
|
||||
-Wl,--wrap=exp2
|
||||
-Wl,--wrap=expf
|
||||
-Wl,--wrap=fcntl64
|
||||
-Wl,--wrap=log
|
||||
@@ -1019,6 +1045,7 @@ if(WIN32)
|
||||
target_link_libraries(${bun} PRIVATE
|
||||
${WEBKIT_LIB_PATH}/WTF.lib
|
||||
${WEBKIT_LIB_PATH}/JavaScriptCore.lib
|
||||
${WEBKIT_LIB_PATH}/bmalloc.lib
|
||||
${WEBKIT_LIB_PATH}/sicudtd.lib
|
||||
${WEBKIT_LIB_PATH}/sicuind.lib
|
||||
${WEBKIT_LIB_PATH}/sicuucd.lib
|
||||
@@ -1027,6 +1054,7 @@ if(WIN32)
|
||||
target_link_libraries(${bun} PRIVATE
|
||||
${WEBKIT_LIB_PATH}/WTF.lib
|
||||
${WEBKIT_LIB_PATH}/JavaScriptCore.lib
|
||||
${WEBKIT_LIB_PATH}/bmalloc.lib
|
||||
${WEBKIT_LIB_PATH}/sicudt.lib
|
||||
${WEBKIT_LIB_PATH}/sicuin.lib
|
||||
${WEBKIT_LIB_PATH}/sicuuc.lib
|
||||
@@ -1050,21 +1078,6 @@ endif()
|
||||
|
||||
# --- Dependencies ---
|
||||
|
||||
set(BUN_DEPENDENCIES
|
||||
BoringSSL
|
||||
Brotli
|
||||
Cares
|
||||
Highway
|
||||
LibDeflate
|
||||
LolHtml
|
||||
Lshpack
|
||||
Mimalloc
|
||||
TinyCC
|
||||
Zlib
|
||||
LibArchive # must be loaded after zlib
|
||||
Zstd
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND BUN_DEPENDENCIES Libuv)
|
||||
endif()
|
||||
|
||||
@@ -4,7 +4,7 @@ register_repository(
|
||||
REPOSITORY
|
||||
c-ares/c-ares
|
||||
COMMIT
|
||||
4f4912bce7374f787b10576851b687935f018e17
|
||||
d3a507e920e7af18a5efb7f9f1d8044ed4750013
|
||||
)
|
||||
|
||||
register_cmake_command(
|
||||
|
||||
24
cmake/targets/BuildHdrHistogram.cmake
Normal file
24
cmake/targets/BuildHdrHistogram.cmake
Normal file
@@ -0,0 +1,24 @@
|
||||
register_repository(
|
||||
NAME
|
||||
hdrhistogram
|
||||
REPOSITORY
|
||||
HdrHistogram/HdrHistogram_c
|
||||
COMMIT
|
||||
652d51bcc36744fd1a6debfeb1a8a5f58b14022c
|
||||
)
|
||||
|
||||
register_cmake_command(
|
||||
TARGET
|
||||
hdrhistogram
|
||||
LIBRARIES
|
||||
hdr_histogram_static
|
||||
INCLUDES
|
||||
include
|
||||
LIB_PATH
|
||||
src
|
||||
ARGS
|
||||
-DHDR_HISTOGRAM_BUILD_SHARED=OFF
|
||||
-DHDR_HISTOGRAM_BUILD_STATIC=ON
|
||||
-DHDR_LOG_REQUIRED=DISABLED
|
||||
-DHDR_HISTOGRAM_BUILD_PROGRAMS=OFF
|
||||
)
|
||||
@@ -4,7 +4,7 @@ register_repository(
|
||||
REPOSITORY
|
||||
ebiggers/libdeflate
|
||||
COMMIT
|
||||
78051988f96dc8d8916310d8b24021f01bd9e102
|
||||
96836d7d9d10e3e0d53e6edb54eb908514e336c4
|
||||
)
|
||||
|
||||
register_cmake_command(
|
||||
|
||||
@@ -38,7 +38,11 @@ if(WIN32)
|
||||
set(MIMALLOC_LIBRARY mimalloc-static)
|
||||
endif()
|
||||
elseif(DEBUG)
|
||||
set(MIMALLOC_LIBRARY mimalloc-debug)
|
||||
if (ENABLE_ASAN)
|
||||
set(MIMALLOC_LIBRARY mimalloc-asan-debug)
|
||||
else()
|
||||
set(MIMALLOC_LIBRARY mimalloc-debug)
|
||||
endif()
|
||||
else()
|
||||
set(MIMALLOC_LIBRARY mimalloc)
|
||||
endif()
|
||||
|
||||
@@ -1,12 +1,3 @@
|
||||
register_repository(
|
||||
NAME
|
||||
zstd
|
||||
REPOSITORY
|
||||
facebook/zstd
|
||||
COMMIT
|
||||
794ea1b0afca0f020f4e57b6732332231fb23c70
|
||||
)
|
||||
|
||||
register_cmake_command(
|
||||
TARGET
|
||||
zstd
|
||||
@@ -23,4 +14,6 @@ register_cmake_command(
|
||||
LIBRARIES
|
||||
zstd_static WIN32
|
||||
zstd UNIX
|
||||
INCLUDES
|
||||
lib
|
||||
)
|
||||
|
||||
8
cmake/targets/CloneZstd.cmake
Normal file
8
cmake/targets/CloneZstd.cmake
Normal file
@@ -0,0 +1,8 @@
|
||||
register_repository(
|
||||
NAME
|
||||
zstd
|
||||
REPOSITORY
|
||||
facebook/zstd
|
||||
COMMIT
|
||||
f8745da6ff1ad1e7bab384bd1f9d742439278e99
|
||||
)
|
||||
@@ -2,7 +2,7 @@ option(WEBKIT_VERSION "The version of WebKit to use")
|
||||
option(WEBKIT_LOCAL "If a local version of WebKit should be used instead of downloading")
|
||||
|
||||
if(NOT WEBKIT_VERSION)
|
||||
set(WEBKIT_VERSION 017930ebf915121f8f593bef61cbbca82d78132d)
|
||||
set(WEBKIT_VERSION 29bbdff0f94f362891f8e007ae2a73f9bc3e66d3)
|
||||
endif()
|
||||
|
||||
string(SUBSTRING ${WEBKIT_VERSION} 0 16 WEBKIT_VERSION_PREFIX)
|
||||
@@ -41,14 +41,6 @@ if(WEBKIT_LOCAL)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(EXISTS ${WEBKIT_PATH}/package.json)
|
||||
file(READ ${WEBKIT_PATH}/package.json WEBKIT_PACKAGE_JSON)
|
||||
|
||||
if(WEBKIT_PACKAGE_JSON MATCHES ${WEBKIT_VERSION})
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
set(WEBKIT_OS "windows")
|
||||
elseif(APPLE)
|
||||
@@ -79,14 +71,25 @@ else()
|
||||
set(WEBKIT_SUFFIX "${WEBKIT_SUFFIX}")
|
||||
endif()
|
||||
|
||||
if(ENABLE_ASAN AND ((APPLE AND DEBUG AND ARCH STREQUAL "aarch64") OR (LINUX AND RELEASE)))
|
||||
if(ENABLE_ASAN)
|
||||
# We cannot mix and match ASan Bun + non-ASan WebKit, or vice versa, because some WebKit classes
|
||||
# change their layout according to whether ASan is used, for example:
|
||||
# https://github.com/oven-sh/WebKit/blob/eda8b0fb4fb1aa23db9c2b00933df8b58bcdd289/Source/WTF/wtf/Vector.h#L682
|
||||
set(WEBKIT_SUFFIX "${WEBKIT_SUFFIX}-asan")
|
||||
endif()
|
||||
|
||||
set(WEBKIT_NAME bun-webkit-${WEBKIT_OS}-${WEBKIT_ARCH}${WEBKIT_SUFFIX})
|
||||
setx(WEBKIT_NAME bun-webkit-${WEBKIT_OS}-${WEBKIT_ARCH}${WEBKIT_SUFFIX})
|
||||
set(WEBKIT_FILENAME ${WEBKIT_NAME}.tar.gz)
|
||||
setx(WEBKIT_DOWNLOAD_URL https://github.com/oven-sh/WebKit/releases/download/autobuild-${WEBKIT_VERSION}/${WEBKIT_FILENAME})
|
||||
|
||||
if(EXISTS ${WEBKIT_PATH}/package.json)
|
||||
file(READ ${WEBKIT_PATH}/package.json WEBKIT_PACKAGE_JSON)
|
||||
|
||||
if(WEBKIT_PACKAGE_JSON MATCHES ${WEBKIT_VERSION})
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
file(DOWNLOAD ${WEBKIT_DOWNLOAD_URL} ${CACHE_PATH}/${WEBKIT_FILENAME} SHOW_PROGRESS)
|
||||
file(ARCHIVE_EXTRACT INPUT ${CACHE_PATH}/${WEBKIT_FILENAME} DESTINATION ${CACHE_PATH} TOUCH)
|
||||
file(REMOVE ${CACHE_PATH}/${WEBKIT_FILENAME})
|
||||
|
||||
@@ -20,7 +20,7 @@ else()
|
||||
unsupported(CMAKE_SYSTEM_NAME)
|
||||
endif()
|
||||
|
||||
set(ZIG_COMMIT "a207204ee57a061f2fb96c7bae0c491b609e73a5")
|
||||
set(ZIG_COMMIT "0a0120fa92cd7f6ab244865688b351df634f0707")
|
||||
optionx(ZIG_TARGET STRING "The zig target to use" DEFAULT ${DEFAULT_ZIG_TARGET})
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
@@ -55,13 +55,13 @@ 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 AND CMAKE_HOST_APPLE)
|
||||
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. Only availble on macos aarch64." DEFAULT ${ZIG_COMPILER_SAFE_DEFAULT})
|
||||
optionx(ZIG_COMPILER_SAFE BOOL "Download a ReleaseSafe build of the Zig compiler." DEFAULT ${ZIG_COMPILER_SAFE_DEFAULT})
|
||||
|
||||
setenv(ZIG_LOCAL_CACHE_DIR ${ZIG_LOCAL_CACHE_DIR})
|
||||
setenv(ZIG_GLOBAL_CACHE_DIR ${ZIG_GLOBAL_CACHE_DIR})
|
||||
|
||||
@@ -261,6 +261,7 @@ _bun_pm_completion() {
|
||||
'hash-string\:"print the string used to hash the lockfile" '
|
||||
'hash-print\:"print the hash stored in the current lockfile" '
|
||||
'cache\:"print the path to the cache folder" '
|
||||
'version\:"bump the version in package.json and create a git tag" '
|
||||
)
|
||||
|
||||
_alternative "args:cmd3:(($sub_commands))"
|
||||
@@ -299,6 +300,40 @@ _bun_pm_completion() {
|
||||
$pmargs &&
|
||||
ret=0
|
||||
|
||||
;;
|
||||
version)
|
||||
version_args=(
|
||||
"patch[increment patch version]"
|
||||
"minor[increment minor version]"
|
||||
"major[increment major version]"
|
||||
"prepatch[increment patch version and add pre-release]"
|
||||
"preminor[increment minor version and add pre-release]"
|
||||
"premajor[increment major version and add pre-release]"
|
||||
"prerelease[increment pre-release version]"
|
||||
"from-git[use version from latest git tag]"
|
||||
)
|
||||
|
||||
pmargs=(
|
||||
"--no-git-tag-version[don't create a git commit and tag]"
|
||||
"--allow-same-version[allow bumping to the same version]"
|
||||
"-m[use the given message for the commit]:message"
|
||||
"--message[use the given message for the commit]:message"
|
||||
"--preid[identifier to prefix pre-release versions]:preid"
|
||||
)
|
||||
|
||||
_arguments -s -C \
|
||||
'1: :->cmd' \
|
||||
'2: :->cmd2' \
|
||||
'3: :->increment' \
|
||||
$pmargs &&
|
||||
ret=0
|
||||
|
||||
case $state in
|
||||
increment)
|
||||
_alternative "args:increment:(($version_args))"
|
||||
;;
|
||||
esac
|
||||
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -539,6 +574,7 @@ _bun_update_completion() {
|
||||
'--save[Save to package.json]' \
|
||||
'--dry-run[Don'"'"'t install anything]' \
|
||||
'--frozen-lockfile[Disallow changes to lockfile]' \
|
||||
'--latest[Updates dependencies to latest version, regardless of compatibility]' \
|
||||
'-f[Always request the latest versions from the registry & reinstall all dependencies]' \
|
||||
'--force[Always request the latest versions from the registry & reinstall all dependencies]' \
|
||||
'--cache-dir[Store & load cached data from a specific directory path]:cache-dir' \
|
||||
@@ -572,7 +608,7 @@ _bun_outdated_completion() {
|
||||
'--no-progress[Disable the progress bar]' \
|
||||
'--help[Print this help menu]' &&
|
||||
ret=0
|
||||
|
||||
|
||||
case $state in
|
||||
config)
|
||||
_bun_list_bunfig_toml
|
||||
|
||||
@@ -175,6 +175,7 @@ Bun.hash.xxHash3("data", 1234);
|
||||
Bun.hash.murmur32v3("data", 1234);
|
||||
Bun.hash.murmur32v2("data", 1234);
|
||||
Bun.hash.murmur64v2("data", 1234);
|
||||
Bun.hash.rapidhash("data", 1234);
|
||||
```
|
||||
|
||||
## `Bun.CryptoHasher`
|
||||
|
||||
@@ -326,7 +326,11 @@ Bun.serve({
|
||||
|
||||
### HTML imports
|
||||
|
||||
To add a client-side single-page app, you can use an HTML import:
|
||||
Bun supports importing HTML files directly into your server code, enabling full-stack applications with both server-side and client-side code. HTML imports work in two modes:
|
||||
|
||||
**Development (`bun --hot`):** Assets are bundled on-demand at runtime, enabling hot module replacement (HMR) for a fast, iterative development experience. When you change your frontend code, the browser automatically updates without a full page reload.
|
||||
|
||||
**Production (`bun build`):** When building with `bun build --target=bun`, the `import index from "./index.html"` statement resolves to a pre-built manifest object containing all bundled client assets. `Bun.serve` consumes this manifest to serve optimized assets with zero runtime bundling overhead. This is ideal for deploying to production.
|
||||
|
||||
```ts
|
||||
import myReactSinglePageApp from "./index.html";
|
||||
@@ -338,9 +342,9 @@ Bun.serve({
|
||||
});
|
||||
```
|
||||
|
||||
HTML imports don't just serve HTML. It's a full-featured frontend bundler, transpiler, and toolkit built using Bun's [bundler](https://bun.sh/docs/bundler), JavaScript transpiler and CSS parser.
|
||||
HTML imports don't just serve HTML — it's a full-featured frontend bundler, transpiler, and toolkit built using Bun's [bundler](https://bun.sh/docs/bundler), JavaScript transpiler and CSS parser. You can use this to build full-featured frontends with React, TypeScript, Tailwind CSS, and more.
|
||||
|
||||
You can use this to build a full-featured frontend with React, TypeScript, Tailwind CSS, and more. Check out [/docs/bundler/fullstack](https://bun.sh/docs/bundler/fullstack) to learn more.
|
||||
For a complete guide on building full-stack applications with HTML imports, including detailed examples and best practices, see [/docs/bundler/fullstack](https://bun.sh/docs/bundler/fullstack).
|
||||
|
||||
### Practical example: REST API
|
||||
|
||||
|
||||
@@ -160,7 +160,8 @@ const writer = s3file.writer({
|
||||
partSize: 5 * 1024 * 1024,
|
||||
});
|
||||
for (let i = 0; i < 10; i++) {
|
||||
await writer.write(bigFile);
|
||||
writer.write(bigFile);
|
||||
await writer.flush();
|
||||
}
|
||||
await writer.end();
|
||||
```
|
||||
|
||||
@@ -34,7 +34,7 @@ const proc = Bun.spawn(["cat"], {
|
||||
),
|
||||
});
|
||||
|
||||
const text = await new Response(proc.stdout).text();
|
||||
const text = await proc.stdout.text();
|
||||
console.log(text); // "const input = "hello world".repeat(400); ..."
|
||||
```
|
||||
|
||||
@@ -113,14 +113,34 @@ proc.stdin.flush();
|
||||
proc.stdin.end();
|
||||
```
|
||||
|
||||
Passing a `ReadableStream` to `stdin` lets you pipe data from a JavaScript `ReadableStream` directly to the subprocess's input:
|
||||
|
||||
```ts
|
||||
const stream = new ReadableStream({
|
||||
start(controller) {
|
||||
controller.enqueue("Hello from ");
|
||||
controller.enqueue("ReadableStream!");
|
||||
controller.close();
|
||||
},
|
||||
});
|
||||
|
||||
const proc = Bun.spawn(["cat"], {
|
||||
stdin: stream,
|
||||
stdout: "pipe",
|
||||
});
|
||||
|
||||
const output = await new Response(proc.stdout).text();
|
||||
console.log(output); // "Hello from ReadableStream!"
|
||||
```
|
||||
|
||||
## Output streams
|
||||
|
||||
You can read results from the subprocess via the `stdout` and `stderr` properties. By default these are instances of `ReadableStream`.
|
||||
|
||||
```ts
|
||||
const proc = Bun.spawn(["bun", "--version"]);
|
||||
const text = await new Response(proc.stdout).text();
|
||||
console.log(text); // => "$BUN_LATEST_VERSION"
|
||||
const text = await proc.stdout.text();
|
||||
console.log(text); // => "$BUN_LATEST_VERSION\n"
|
||||
```
|
||||
|
||||
Configure the output stream by passing one of the following values to `stdout/stderr`:
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
See the [`bun test`](https://bun.sh/docs/cli/test) documentation.
|
||||
@@ -582,11 +582,11 @@ Compresses a `Uint8Array` using zlib's DEFLATE algorithm.
|
||||
const buf = Buffer.from("hello".repeat(100));
|
||||
const compressed = Bun.deflateSync(buf);
|
||||
|
||||
buf; // => Uint8Array(25)
|
||||
compressed; // => Uint8Array(10)
|
||||
buf; // => Buffer(500)
|
||||
compressed; // => Uint8Array(12)
|
||||
```
|
||||
|
||||
The second argument supports the same set of configuration options as [`Bun.gzipSync`](#bungzipsync).
|
||||
The second argument supports the same set of configuration options as [`Bun.gzipSync`](#bun-gzipsync).
|
||||
|
||||
## `Bun.inflateSync()`
|
||||
|
||||
|
||||
@@ -126,6 +126,81 @@ The `--sourcemap` argument embeds a sourcemap compressed with zstd, so that erro
|
||||
|
||||
The `--bytecode` argument enables bytecode compilation. Every time you run JavaScript code in Bun, JavaScriptCore (the engine) will compile your source code into bytecode. We can move this parsing work from runtime to bundle time, saving you startup time.
|
||||
|
||||
## Full-stack executables
|
||||
|
||||
{% note %}
|
||||
|
||||
New in Bun v1.2.17
|
||||
|
||||
{% /note %}
|
||||
|
||||
Bun's `--compile` flag can create standalone executables that contain both server and client code, making it ideal for full-stack applications. When you import an HTML file in your server code, Bun automatically bundles all frontend assets (JavaScript, CSS, etc.) and embeds them into the executable. When Bun sees the HTML import on the server, it kicks off a frontend build process to bundle JavaScript, CSS, and other assets.
|
||||
|
||||
{% codetabs %}
|
||||
|
||||
```ts#server.ts
|
||||
import { serve } from "bun";
|
||||
import index from "./index.html";
|
||||
|
||||
const server = serve({
|
||||
routes: {
|
||||
"/": index,
|
||||
"/api/hello": { GET: () => Response.json({ message: "Hello from API" }) },
|
||||
},
|
||||
});
|
||||
|
||||
console.log(`Server running at http://localhost:${server.port}`);
|
||||
```
|
||||
|
||||
```html#index.html
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>My App</title>
|
||||
<link rel="stylesheet" href="./styles.css">
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello World</h1>
|
||||
<script src="./app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
```js#app.js
|
||||
console.log("Hello from the client!");
|
||||
```
|
||||
|
||||
```css#styles.css
|
||||
body {
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
```
|
||||
|
||||
{% /codetabs %}
|
||||
|
||||
To build this into a single executable:
|
||||
|
||||
```sh
|
||||
bun build --compile ./server.ts --outfile myapp
|
||||
```
|
||||
|
||||
This creates a self-contained binary that includes:
|
||||
|
||||
- Your server code
|
||||
- The Bun runtime
|
||||
- All frontend assets (HTML, CSS, JavaScript)
|
||||
- Any npm packages used by your server
|
||||
|
||||
The result is a single file that can be deployed anywhere without needing Node.js, Bun, or any dependencies installed. Just run:
|
||||
|
||||
```sh
|
||||
./myapp
|
||||
```
|
||||
|
||||
Bun automatically handles serving the frontend assets with proper MIME types and cache headers. The HTML import is replaced with a manifest object that `Bun.serve` uses to efficiently serve pre-bundled assets.
|
||||
|
||||
For more details on building full-stack applications with Bun, see the [full-stack guide](/docs/bundler/fullstack).
|
||||
|
||||
## Worker
|
||||
|
||||
To use workers in a standalone executable, add the worker's entrypoint to the CLI arguments:
|
||||
@@ -174,7 +249,7 @@ $ ./hello
|
||||
|
||||
Standalone executables support embedding files.
|
||||
|
||||
To embed files into an executable with `bun build --compile`, import the file in your code
|
||||
To embed files into an executable with `bun build --compile`, import the file in your code.
|
||||
|
||||
```ts
|
||||
// this becomes an internal file path
|
||||
@@ -353,5 +428,4 @@ Currently, the `--compile` flag can only accept a single entrypoint at a time an
|
||||
- `--splitting`
|
||||
- `--public-path`
|
||||
- `--target=node` or `--target=browser`
|
||||
- `--format` - always outputs a binary executable. Internally, it's almost esm.
|
||||
- `--no-bundle` - we always bundle everything into the executable.
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
Using `Bun.serve()`'s `routes` option, you can run your frontend and backend in the same app with no extra steps.
|
||||
|
||||
To get started, import HTML files and pass them to the `routes` option in `Bun.serve()`.
|
||||
|
||||
```ts
|
||||
@@ -234,7 +232,92 @@ When `console: true` is set, Bun will stream console logs from the browser to th
|
||||
|
||||
#### Production mode
|
||||
|
||||
When serving your app in production, set `development: false` in `Bun.serve()`.
|
||||
Hot reloading and `development: true` helps you iterate quickly, but in production, your server should be as fast as possible and have as few external dependencies as possible.
|
||||
|
||||
##### Ahead of time bundling (recommended)
|
||||
|
||||
As of Bun v1.2.17, you can use `Bun.build` or `bun build` to bundle your full-stack application ahead of time.
|
||||
|
||||
```sh
|
||||
$ bun build --target=bun --production --outdir=dist ./src/index.ts
|
||||
```
|
||||
|
||||
When Bun's bundler sees an HTML import from server-side code, it will bundle the referenced JavaScript/TypeScript/TSX/JSX and CSS files into a manifest object that Bun.serve() can use to serve the assets.
|
||||
|
||||
```ts
|
||||
import { serve } from "bun";
|
||||
import index from "./index.html";
|
||||
|
||||
serve({
|
||||
routes: { "/": index },
|
||||
});
|
||||
```
|
||||
|
||||
{% details summary="Internally, the `index` variable is a manifest object that looks something like this" %}
|
||||
|
||||
```json
|
||||
{
|
||||
"index": "./index.html",
|
||||
"files": [
|
||||
{
|
||||
"input": "index.html",
|
||||
"path": "./index-f2me3qnf.js",
|
||||
"loader": "js",
|
||||
"isEntry": true,
|
||||
"headers": {
|
||||
"etag": "eet6gn75",
|
||||
"content-type": "text/javascript;charset=utf-8"
|
||||
}
|
||||
},
|
||||
{
|
||||
"input": "index.html",
|
||||
"path": "./index.html",
|
||||
"loader": "html",
|
||||
"isEntry": true,
|
||||
"headers": {
|
||||
"etag": "r9njjakd",
|
||||
"content-type": "text/html;charset=utf-8"
|
||||
}
|
||||
},
|
||||
{
|
||||
"input": "index.html",
|
||||
"path": "./index-gysa5fmk.css",
|
||||
"loader": "css",
|
||||
"isEntry": true,
|
||||
"headers": {
|
||||
"etag": "50zb7x61",
|
||||
"content-type": "text/css;charset=utf-8"
|
||||
}
|
||||
},
|
||||
{
|
||||
"input": "logo.svg",
|
||||
"path": "./logo-kygw735p.svg",
|
||||
"loader": "file",
|
||||
"isEntry": false,
|
||||
"headers": {
|
||||
"etag": "kygw735p",
|
||||
"content-type": "application/octet-stream"
|
||||
}
|
||||
},
|
||||
{
|
||||
"input": "react.svg",
|
||||
"path": "./react-ck11dneg.svg",
|
||||
"loader": "file",
|
||||
"isEntry": false,
|
||||
"headers": {
|
||||
"etag": "ck11dneg",
|
||||
"content-type": "application/octet-stream"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
{% /details %}
|
||||
|
||||
##### Runtime bundling
|
||||
|
||||
When adding a build step is too complicated, you can set `development: false` in `Bun.serve()`.
|
||||
|
||||
- Enable in-memory caching of bundled assets. Bun will bundle assets lazily on the first request to an `.html` file, and cache the result in memory until the server restarts.
|
||||
- Enables `Cache-Control` headers and `ETag` headers
|
||||
@@ -298,7 +381,6 @@ Note: this is currently in `bunfig.toml` to make it possible to know statically
|
||||
Bun uses [`HTMLRewriter`](/docs/api/html-rewriter) to scan for `<script>` and `<link>` tags in HTML files, uses them as entrypoints for [Bun's bundler](/docs/bundler), generates an optimized bundle for the JavaScript/TypeScript/TSX/JSX and CSS files, and serves the result.
|
||||
|
||||
1. **`<script>` processing**
|
||||
|
||||
- Transpiles TypeScript, JSX, and TSX in `<script>` tags
|
||||
- Bundles imported dependencies
|
||||
- Generates sourcemaps for debugging
|
||||
@@ -309,7 +391,6 @@ Bun uses [`HTMLRewriter`](/docs/api/html-rewriter) to scan for `<script>` and `<
|
||||
```
|
||||
|
||||
2. **`<link>` processing**
|
||||
|
||||
- Processes CSS imports and `<link>` tags
|
||||
- Concatenates CSS files
|
||||
- Rewrites `url` and asset paths to include content-addressable hashes in URLs
|
||||
@@ -319,18 +400,15 @@ Bun uses [`HTMLRewriter`](/docs/api/html-rewriter) to scan for `<script>` and `<
|
||||
```
|
||||
|
||||
3. **`<img>` & asset processing**
|
||||
|
||||
- Links to assets are rewritten to include content-addressable hashes in URLs
|
||||
- Small assets in CSS files are inlined into `data:` URLs, reducing the total number of HTTP requests sent over the wire
|
||||
|
||||
4. **Rewrite HTML**
|
||||
|
||||
- Combines all `<script>` tags into a single `<script>` tag with a content-addressable hash in the URL
|
||||
- Combines all `<link>` tags into a single `<link>` tag with a content-addressable hash in the URL
|
||||
- Outputs a new HTML file
|
||||
|
||||
5. **Serve**
|
||||
|
||||
- All the output files from the bundler are exposed as static routes, using the same mechanism internally as when you pass a `Response` object to [`static` in `Bun.serve()`](/docs/api/http#static-routes).
|
||||
|
||||
This works similarly to how [`Bun.build` processes HTML files](/docs/bundler/html).
|
||||
|
||||
@@ -206,6 +206,38 @@ Each call to `console.log` or `console.error` will be broadcast to the terminal
|
||||
|
||||
Internally, this reuses the existing WebSocket connection from hot module reloading to send the logs.
|
||||
|
||||
### Edit files in the browser
|
||||
|
||||
Bun's frontend dev server has support for [Automatic Workspace Folders](https://chromium.googlesource.com/devtools/devtools-frontend/+/main/docs/ecosystem/automatic_workspace_folders.md) in Chrome DevTools, which lets you save edits to files in the browser.
|
||||
|
||||
{% image src="/images/bun-chromedevtools.gif" alt="Bun's frontend dev server has support for Automatic Workspace Folders in Chrome DevTools, which lets you save edits to files in the browser." /%}
|
||||
|
||||
{% details summary="How it works" %}
|
||||
|
||||
Bun's dev server automatically adds a `/.well-known/appspecific/com.chrome.devtools.json` route to the server.
|
||||
|
||||
This route returns a JSON object with the following shape:
|
||||
|
||||
```json
|
||||
{
|
||||
"workspace": {
|
||||
"root": "/path/to/your/project",
|
||||
"uuid": "a-unique-identifier-for-this-workspace"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
For security reasons, this is only enabled when:
|
||||
|
||||
1. The request is coming from localhost, 127.0.0.1, or ::1.
|
||||
2. Hot Module Reloading is enabled.
|
||||
3. The `chromeDevToolsAutomaticWorkspaceFolders` flag is set to `true` or `undefined`.
|
||||
4. There are no other routes that match the request.
|
||||
|
||||
You can disable this by passing `development: { chromeDevToolsAutomaticWorkspaceFolders: false }` in `Bun.serve`'s options.
|
||||
|
||||
{% /details %}
|
||||
|
||||
## Keyboard Shortcuts
|
||||
|
||||
While the server is running:
|
||||
|
||||
@@ -26,6 +26,7 @@ The bundler is a key piece of infrastructure in the JavaScript ecosystem. As a b
|
||||
- **Reducing HTTP requests.** A single package in `node_modules` may consist of hundreds of files, and large applications may have dozens of such dependencies. Loading each of these files with a separate HTTP request becomes untenable very quickly, so bundlers are used to convert our application source code into a smaller number of self-contained "bundles" that can be loaded with a single request.
|
||||
- **Code transforms.** Modern apps are commonly built with languages or tools like TypeScript, JSX, and CSS modules, all of which must be converted into plain JavaScript and CSS before they can be consumed by a browser. The bundler is the natural place to configure these transformations.
|
||||
- **Framework features.** Frameworks rely on bundler plugins & code transformations to implement common patterns like file-system routing, client-server code co-location (think `getServerSideProps` or Remix loaders), and server components.
|
||||
- **Full-stack Applications.** Bun's bundler can handle both server and client code in a single command, enabling optimized production builds and single-file executables. With build-time HTML imports, you can bundle your entire application — frontend assets and backend server — into a single deployable unit.
|
||||
|
||||
Let's jump into the bundler API.
|
||||
|
||||
@@ -324,7 +325,7 @@ Depending on the target, Bun will apply different module resolution rules and op
|
||||
---
|
||||
|
||||
- `bun`
|
||||
- For generating bundles that are intended to be run by the Bun runtime. In many cases, it isn't necessary to bundle server-side code; you can directly execute the source code without modification. However, bundling your server code can reduce startup times and improve running performance.
|
||||
- For generating bundles that are intended to be run by the Bun runtime. In many cases, it isn't necessary to bundle server-side code; you can directly execute the source code without modification. However, bundling your server code can reduce startup times and improve running performance. This is the target to use for building full-stack applications with build-time HTML imports, where both server and client code are bundled together.
|
||||
|
||||
All bundles generated with `target: "bun"` are marked with a special `// @bun` pragma, which indicates to the Bun runtime that there's no need to re-transpile the file before execution.
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ console.log(contents); // => "Hello, world!"
|
||||
import html from "./index.html" with { type: "text" };
|
||||
```
|
||||
|
||||
When referenced during a build, the contents are into the bundle as a string.
|
||||
When referenced during a build, the contents are inlined into the bundle as a string.
|
||||
|
||||
```ts
|
||||
var contents = `Hello, world!`;
|
||||
@@ -262,6 +262,20 @@ Currently, the list of selectors is:
|
||||
- `video[poster]`
|
||||
- `video[src]`
|
||||
|
||||
{% callout %}
|
||||
|
||||
**HTML Loader Behavior in Different Contexts**
|
||||
|
||||
The `html` loader behaves differently depending on how it's used:
|
||||
|
||||
1. **Static Build:** When you run `bun build ./index.html`, Bun produces a static site with all assets bundled and hashed.
|
||||
|
||||
2. **Runtime:** When you run `bun run server.ts` (where `server.ts` imports an HTML file), Bun bundles assets on-the-fly during development, enabling features like hot module replacement.
|
||||
|
||||
3. **Full-stack Build:** When you run `bun build --target=bun server.ts` (where `server.ts` imports an HTML file), the import resolves to a manifest object that `Bun.serve` uses to efficiently serve pre-bundled assets in production.
|
||||
|
||||
{% /callout %}
|
||||
|
||||
### `sh` loader
|
||||
|
||||
**Bun Shell loader**. Default for `.sh` files
|
||||
|
||||
@@ -125,7 +125,7 @@ In Bun's CLI, simple boolean flags like `--minify` do not accept an argument. Ot
|
||||
|
||||
- `--target`
|
||||
- n/a
|
||||
- No supported. Bun's bundler performs no syntactic down-leveling at this time.
|
||||
- Not supported. Bun's bundler performs no syntactic down-leveling at this time.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -308,14 +308,12 @@ IF remote template
|
||||
1. GET `registry.npmjs.org/@bun-examples/${template}/latest` and parse it
|
||||
2. GET `registry.npmjs.org/@bun-examples/${template}/-/${template}-${latestVersion}.tgz`
|
||||
3. Decompress & extract `${template}-${latestVersion}.tgz` into `${destination}`
|
||||
|
||||
- If there are files that would overwrite, warn and exit unless `--force` is passed
|
||||
|
||||
IF GitHub repo
|
||||
|
||||
1. Download the tarball from GitHub’s API
|
||||
2. Decompress & extract into `${destination}`
|
||||
|
||||
- If there are files that would overwrite, warn and exit unless `--force` is passed
|
||||
|
||||
ELSE IF local template
|
||||
@@ -333,7 +331,6 @@ ELSE IF local template
|
||||
7. Run `${npmClient} install` unless `--no-install` is passed OR no dependencies are in package.json
|
||||
8. Run any tasks defined in `"bun-create": { "postinstall" }` with the npm client
|
||||
9. Run `git init; git add -A .; git commit -am "Initial Commit";`
|
||||
|
||||
- Rename `gitignore` to `.gitignore`. NPM automatically removes `.gitignore` files from appearing in packages.
|
||||
- If there are dependencies, this runs in a separate thread concurrently while node_modules are being installed
|
||||
- Using libgit2 if available was tested and performed 3x slower in microbenchmarks
|
||||
|
||||
@@ -28,7 +28,7 @@ $ bun install --filter '!pkg-c'
|
||||
$ bun install --filter './packages/*'
|
||||
|
||||
# Save as above, but exclude the root package.json
|
||||
$ bun install --filter --filter '!./' --filter './packages/*'
|
||||
$ bun install --filter '!./' --filter './packages/*'
|
||||
```
|
||||
|
||||
Similarly, `bun outdated` will display outdated dependencies for all packages in the monorepo, and `--filter` can be used to restrict the command to a subset of the packages:
|
||||
|
||||
65
docs/cli/info.md
Normal file
65
docs/cli/info.md
Normal file
@@ -0,0 +1,65 @@
|
||||
`bun info` displays package metadata from the npm registry.
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
$ bun info react
|
||||
```
|
||||
|
||||
This will display information about the `react` package, including its latest version, description, homepage, dependencies, and more.
|
||||
|
||||
## Viewing specific versions
|
||||
|
||||
To view information about a specific version:
|
||||
|
||||
```bash
|
||||
$ bun info react@18.0.0
|
||||
```
|
||||
|
||||
## Viewing specific properties
|
||||
|
||||
You can also query specific properties from the package metadata:
|
||||
|
||||
```bash
|
||||
$ bun info react version
|
||||
$ bun info react dependencies
|
||||
$ bun info react repository.url
|
||||
```
|
||||
|
||||
## JSON output
|
||||
|
||||
To get the output in JSON format, use the `--json` flag:
|
||||
|
||||
```bash
|
||||
$ bun info react --json
|
||||
```
|
||||
|
||||
## Alias
|
||||
|
||||
`bun pm view` is an alias for `bun info`:
|
||||
|
||||
```bash
|
||||
$ bun pm view react # equivalent to: bun info react
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
```bash
|
||||
# View basic package information
|
||||
$ bun info is-number
|
||||
|
||||
# View a specific version
|
||||
$ bun info is-number@7.0.0
|
||||
|
||||
# View all available versions
|
||||
$ bun info is-number versions
|
||||
|
||||
# View package dependencies
|
||||
$ bun info express dependencies
|
||||
|
||||
# View package homepage
|
||||
$ bun info lodash homepage
|
||||
|
||||
# Get JSON output
|
||||
$ bun info react --json
|
||||
```
|
||||
@@ -40,3 +40,32 @@ At the end, it runs `bun install` to install `@types/bun`.
|
||||
{% /details %}
|
||||
|
||||
{% bunCLIUsage command="init" /%}
|
||||
|
||||
## React
|
||||
|
||||
The `--react` flag will scaffold a React project:
|
||||
|
||||
```bash
|
||||
$ bun init --react
|
||||
```
|
||||
|
||||
The `--react` flag accepts the following values:
|
||||
|
||||
- `tailwind` - Scaffold a React project with Tailwind CSS
|
||||
- `shadcn` - Scaffold a React project with Shadcn/UI and Tailwind CSS
|
||||
|
||||
### React + TailwindCSS
|
||||
|
||||
This will create a React project with Tailwind CSS configured with Bun's bundler and dev server.
|
||||
|
||||
```bash
|
||||
$ bun init --react=tailwind
|
||||
```
|
||||
|
||||
### React + @shadcn/ui
|
||||
|
||||
This will create a React project with shadcn/ui and Tailwind CSS configured with Bun's bundler and dev server.
|
||||
|
||||
```bash
|
||||
$ bun init --react=shadcn
|
||||
```
|
||||
|
||||
@@ -151,3 +151,45 @@ $ bun pm default-trusted
|
||||
```
|
||||
|
||||
see the current list on GitHub [here](https://github.com/oven-sh/bun/blob/main/src/install/default-trusted-dependencies.txt)
|
||||
|
||||
## version
|
||||
|
||||
To display current package version and help:
|
||||
|
||||
```bash
|
||||
$ bun pm version
|
||||
bun pm version v$BUN_LATEST_VERSION (ca7428e9)
|
||||
Current package version: v1.0.0
|
||||
|
||||
Increment:
|
||||
patch 1.0.0 → 1.0.1
|
||||
minor 1.0.0 → 1.1.0
|
||||
major 1.0.0 → 2.0.0
|
||||
prerelease 1.0.0 → 1.0.1-0
|
||||
prepatch 1.0.0 → 1.0.1-0
|
||||
preminor 1.0.0 → 1.1.0-0
|
||||
premajor 1.0.0 → 2.0.0-0
|
||||
from-git Use version from latest git tag
|
||||
1.2.3 Set specific version
|
||||
|
||||
Options:
|
||||
--no-git-tag-version Skip git operations
|
||||
--allow-same-version Prevents throwing error if version is the same
|
||||
--message=<val>, -m Custom commit message, use %s for version substitution
|
||||
--preid=<val> Prerelease identifier (i.e beta → 1.0.1-beta.0)
|
||||
--force, -f Bypass dirty git history check
|
||||
|
||||
Examples:
|
||||
$ bun pm version patch
|
||||
$ bun pm version 1.2.3 --no-git-tag-version
|
||||
$ bun pm version prerelease --preid beta --message "Release beta: %s"
|
||||
```
|
||||
|
||||
To bump the version in `package.json`:
|
||||
|
||||
```bash
|
||||
$ bun pm version patch
|
||||
v1.0.1
|
||||
```
|
||||
|
||||
Supports `patch`, `minor`, `major`, `premajor`, `preminor`, `prepatch`, `prerelease`, `from-git`, or specific versions like `1.2.3`. By default creates git commit and tag unless `--no-git-tag-version` was used to skip.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Use `bun publish` to publish a package to the npm registry.
|
||||
|
||||
`bun publish` will automatically pack your package into a tarball, strip workspace protocols from the `package.json` (resolving versions if necessary), and publish to the registry specified in your configuration files. Both `bunfig.toml` and `.npmrc` files are supported.
|
||||
`bun publish` will automatically pack your package into a tarball, strip catalog and workspace protocols from the `package.json` (resolving versions if necessary), and publish to the registry specified in your configuration files. Both `bunfig.toml` and `.npmrc` files are supported.
|
||||
|
||||
```sh
|
||||
## Publishing the package from the current working directory
|
||||
|
||||
@@ -30,7 +30,7 @@ $ bun add @prisma/client
|
||||
We'll use the Prisma CLI with `bunx` to initialize our schema and migration directory. For simplicity we'll be using an in-memory SQLite database.
|
||||
|
||||
```bash
|
||||
$ bunx prisma init --datasource-provider sqlite
|
||||
$ bunx --bun prisma init --datasource-provider sqlite
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
@@ -1,49 +1,50 @@
|
||||
---
|
||||
name: Use React and JSX
|
||||
name: Build a React app with Bun
|
||||
---
|
||||
|
||||
React just works with Bun. Bun supports `.jsx` and `.tsx` files out of the box.
|
||||
Bun supports `.jsx` and `.tsx` files out of the box. React just works with Bun.
|
||||
|
||||
Remember that JSX is just a special syntax for including HTML-like syntax in JavaScript files. React uses JSX syntax, as do alternatives like [Preact](https://preactjs.com/) and [Solid](https://www.solidjs.com/). Bun's internal transpiler converts JSX syntax into vanilla JavaScript before execution.
|
||||
|
||||
---
|
||||
|
||||
Bun _assumes_ you're using React (unless you [configure it otherwise](https://bun.sh/docs/runtime/bunfig#jsx)) so a line like this:
|
||||
|
||||
```
|
||||
const element = <h1>Hello, world!</h1>;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
is internally converted into something like this:
|
||||
|
||||
```ts
|
||||
// jsxDEV
|
||||
import { jsx } from "react/jsx-dev-runtime";
|
||||
|
||||
const element = jsx("h1", { children: "Hello, world!" });
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
This code requires `react` to run, so make sure you've installed React.
|
||||
Create a new React app with `bun init --react`. This gives you a template with a simple React app and a simple API server together in one full-stack app.
|
||||
|
||||
```bash
|
||||
$ bun install react
|
||||
# Create a new React app
|
||||
$ bun init --react
|
||||
|
||||
# Run the app in development mode
|
||||
$ bun dev
|
||||
|
||||
# Build as a static site for production
|
||||
$ bun run build
|
||||
|
||||
# Run the server in production
|
||||
$ bun start
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Bun implements special logging for JSX components to make debugging easier.
|
||||
### Hot Reloading
|
||||
|
||||
Run `bun dev` to start the app in development mode. This will start the API server and the React app with hot reloading.
|
||||
|
||||
### Full-Stack App
|
||||
|
||||
Run `bun start` to start the API server and frontend together in one process.
|
||||
|
||||
### Static Site
|
||||
|
||||
Run `bun run build` to build the app as a static site. This will create a `dist` directory with the built app and all the assets.
|
||||
|
||||
```bash
|
||||
$ bun run log-my-component.tsx
|
||||
<Component message="Hello world!" />
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
As far as "official support" for React goes, that's it. React is a library like any other, and Bun can run that library. Bun is not a framework, so you should use a framework like [Vite](https://vitejs.dev/) to build an app with server-side rendering and hot reloading in the browser.
|
||||
|
||||
Refer to [Runtime > JSX](https://bun.sh/docs/runtime/jsx) for complete documentation on configuring JSX.
|
||||
├── src/
|
||||
│ ├── index.tsx # Server entry point with API routes
|
||||
│ ├── frontend.tsx # React app entry point with HMR
|
||||
│ ├── App.tsx # Main React component
|
||||
│ ├── APITester.tsx # Component for testing API endpoints
|
||||
│ ├── index.html # HTML template
|
||||
│ ├── index.css # Styles
|
||||
│ └── *.svg # Static assets
|
||||
├── package.json # Dependencies and scripts
|
||||
├── tsconfig.json # TypeScript configuration
|
||||
├── bunfig.toml # Bun configuration
|
||||
└── bun.lock # Lock file
|
||||
```
|
||||
|
||||
@@ -13,14 +13,14 @@ proc.stderr; // => ReadableStream
|
||||
|
||||
---
|
||||
|
||||
To read `stderr` until the child process exits, use the [`Bun.readableStreamToText()`](https://bun.sh/docs/api/utils#bun-readablestreamto) convenience function.
|
||||
To read `stderr` until the child process exits, use .text()
|
||||
|
||||
```ts
|
||||
const proc = Bun.spawn(["echo", "hello"], {
|
||||
stderr: "pipe",
|
||||
});
|
||||
|
||||
const errors: string = await Bun.readableStreamToText(proc.stderr);
|
||||
const errors: string = await proc.stderr.text();
|
||||
if (errors) {
|
||||
// handle errors
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ When using [`Bun.spawn()`](https://bun.sh/docs/api/spawn), the `stdout` of the c
|
||||
```ts
|
||||
const proc = Bun.spawn(["echo", "hello"]);
|
||||
|
||||
const output = await new Response(proc.stdout).text();
|
||||
const output = await proc.stdout.text();
|
||||
output; // => "hello"
|
||||
```
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ By default, the `stdout` of the child process can be consumed as a `ReadableStre
|
||||
```ts
|
||||
const proc = Bun.spawn(["echo", "hello"]);
|
||||
|
||||
const output = await new Response(proc.stdout).text();
|
||||
output; // => "hello"
|
||||
const output = await proc.stdout.text();
|
||||
output; // => "hello\n"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
@@ -18,7 +18,7 @@ Below is the full set of recommended `compilerOptions` for a Bun project. With t
|
||||
// Environment setup & latest features
|
||||
"lib": ["ESNext"],
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"module": "Preserve",
|
||||
"moduleDetection": "force",
|
||||
"jsx": "react-jsx",
|
||||
"allowJs": true,
|
||||
@@ -34,6 +34,7 @@ Below is the full set of recommended `compilerOptions` for a Bun project. With t
|
||||
"skipLibCheck": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"noImplicitOverride": true,
|
||||
|
||||
// Some stricter flags (disabled by default)
|
||||
"noUnusedLocals": false,
|
||||
|
||||
@@ -46,7 +46,7 @@ test
|
||||
The `snap.test.ts.snap` file is a JavaScript file that exports a serialized version of the value passed into `expect()`. The `{foo: "bar"}` object has been serialized to JSON.
|
||||
|
||||
```js
|
||||
// Bun Snapshot v1, https://goo.gl/fbAQLP
|
||||
// Bun Snapshot v1, https://bun.sh/docs/test/snapshots
|
||||
|
||||
exports[`snapshot 1`] = `
|
||||
{
|
||||
|
||||
37
docs/install/audit.md
Normal file
37
docs/install/audit.md
Normal file
@@ -0,0 +1,37 @@
|
||||
`bun audit` checks your installed packages for known security vulnerabilities.
|
||||
|
||||
Run the command in a project with a `bun.lock` file:
|
||||
|
||||
```bash
|
||||
$ bun audit
|
||||
```
|
||||
|
||||
Bun sends the list of installed packages and versions to NPM, and prints a report of any vulnerabilities that were found. Packages installed from registries other than the default registry are skipped.
|
||||
|
||||
If no vulnerabilities are found, the command prints:
|
||||
|
||||
```
|
||||
No vulnerabilities found
|
||||
```
|
||||
|
||||
When vulnerabilities are detected, each affected package is listed along with the severity, a short description and a link to the advisory. At the end of the report Bun prints a summary and hints for updating:
|
||||
|
||||
```
|
||||
3 vulnerabilities (1 high, 2 moderate)
|
||||
To update all dependencies to the latest compatible versions:
|
||||
bun update
|
||||
To update all dependencies to the latest versions (including breaking changes):
|
||||
bun update --latest
|
||||
```
|
||||
|
||||
### `--json`
|
||||
|
||||
Use the `--json` flag to print the raw JSON response from the registry instead of the formatted report:
|
||||
|
||||
```bash
|
||||
$ bun audit --json
|
||||
```
|
||||
|
||||
### Exit code
|
||||
|
||||
`bun audit` will exit with code `0` if no vulnerabilities are found and `1` if the report lists any vulnerabilities. This will still happen even if `--json` is passed.
|
||||
296
docs/install/catalogs.md
Normal file
296
docs/install/catalogs.md
Normal file
@@ -0,0 +1,296 @@
|
||||
Catalogs in Bun provide a straightforward way to share common dependency versions across multiple packages in a monorepo. Rather than specifying the same versions repeatedly in each workspace package, you define them once in the root package.json and reference them consistently throughout your project.
|
||||
|
||||
## Overview
|
||||
|
||||
Unlike traditional dependency management where each workspace package needs to independently specify versions, catalogs let you:
|
||||
|
||||
1. Define version catalogs in the root package.json
|
||||
2. Reference these versions with a simple `catalog:` protocol
|
||||
3. Update all packages simultaneously by changing the version in just one place
|
||||
|
||||
This is especially useful in large monorepos where dozens of packages need to use the same version of key dependencies.
|
||||
|
||||
## How to Use Catalogs
|
||||
|
||||
### Directory Structure Example
|
||||
|
||||
Consider a monorepo with the following structure:
|
||||
|
||||
```
|
||||
my-monorepo/
|
||||
├── package.json
|
||||
├── bun.lock
|
||||
└── packages/
|
||||
├── app/
|
||||
│ └── package.json
|
||||
├── ui/
|
||||
│ └── package.json
|
||||
└── utils/
|
||||
└── package.json
|
||||
```
|
||||
|
||||
### 1. Define Catalogs in Root package.json
|
||||
|
||||
In your root-level `package.json`, add a `catalog` or `catalogs` field within the `workspaces` object:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "my-monorepo",
|
||||
"workspaces": {
|
||||
"packages": ["packages/*"],
|
||||
"catalog": {
|
||||
"react": "^19.0.0",
|
||||
"react-dom": "^19.0.0"
|
||||
},
|
||||
"catalogs": {
|
||||
"testing": {
|
||||
"jest": "30.0.0",
|
||||
"testing-library": "14.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 2. Reference Catalog Versions in Workspace Packages
|
||||
|
||||
In your workspace packages, use the `catalog:` protocol to reference versions:
|
||||
|
||||
**packages/app/package.json**
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "app",
|
||||
"dependencies": {
|
||||
"react": "catalog:",
|
||||
"react-dom": "catalog:",
|
||||
"jest": "catalog:testing"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**packages/ui/package.json**
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "ui",
|
||||
"dependencies": {
|
||||
"react": "catalog:",
|
||||
"react-dom": "catalog:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest": "catalog:testing",
|
||||
"testing-library": "catalog:testing"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 3. Run Bun Install
|
||||
|
||||
Run `bun install` to install all dependencies according to the catalog versions.
|
||||
|
||||
## Catalog vs Catalogs
|
||||
|
||||
Bun supports two ways to define catalogs:
|
||||
|
||||
1. **`catalog`** (singular): A single default catalog for commonly used dependencies
|
||||
|
||||
```json
|
||||
"catalog": {
|
||||
"react": "^19.0.0",
|
||||
"react-dom": "^19.0.0"
|
||||
}
|
||||
```
|
||||
|
||||
Reference with simply `catalog:`:
|
||||
|
||||
```json
|
||||
"dependencies": {
|
||||
"react": "catalog:"
|
||||
}
|
||||
```
|
||||
|
||||
2. **`catalogs`** (plural): Multiple named catalogs for grouping dependencies
|
||||
|
||||
```json
|
||||
"catalogs": {
|
||||
"testing": {
|
||||
"jest": "30.0.0"
|
||||
},
|
||||
"ui": {
|
||||
"tailwind": "4.0.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Reference with `catalog:<name>`:
|
||||
|
||||
```json
|
||||
"dependencies": {
|
||||
"jest": "catalog:testing",
|
||||
"tailwind": "catalog:ui"
|
||||
}
|
||||
```
|
||||
|
||||
## Benefits of Using Catalogs
|
||||
|
||||
- **Consistency**: Ensures all packages use the same version of critical dependencies
|
||||
- **Maintenance**: Update a dependency version in one place instead of across multiple package.json files
|
||||
- **Clarity**: Makes it obvious which dependencies are standardized across your monorepo
|
||||
- **Simplicity**: No need for complex version resolution strategies or external tools
|
||||
|
||||
## Real-World Example
|
||||
|
||||
Here's a more comprehensive example for a React application:
|
||||
|
||||
**Root package.json**
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "react-monorepo",
|
||||
"workspaces": {
|
||||
"packages": ["packages/*"],
|
||||
"catalog": {
|
||||
"react": "^19.0.0",
|
||||
"react-dom": "^19.0.0",
|
||||
"react-router-dom": "^6.15.0"
|
||||
},
|
||||
"catalogs": {
|
||||
"build": {
|
||||
"webpack": "5.88.2",
|
||||
"babel": "7.22.10"
|
||||
},
|
||||
"testing": {
|
||||
"jest": "29.6.2",
|
||||
"react-testing-library": "14.0.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "5.1.6"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**packages/app/package.json**
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "app",
|
||||
"dependencies": {
|
||||
"react": "catalog:",
|
||||
"react-dom": "catalog:",
|
||||
"react-router-dom": "catalog:",
|
||||
"@monorepo/ui": "workspace:*",
|
||||
"@monorepo/utils": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"webpack": "catalog:build",
|
||||
"babel": "catalog:build",
|
||||
"jest": "catalog:testing",
|
||||
"react-testing-library": "catalog:testing"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**packages/ui/package.json**
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "@monorepo/ui",
|
||||
"dependencies": {
|
||||
"react": "catalog:",
|
||||
"react-dom": "catalog:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest": "catalog:testing",
|
||||
"react-testing-library": "catalog:testing"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**packages/utils/package.json**
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "@monorepo/utils",
|
||||
"dependencies": {
|
||||
"react": "catalog:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest": "catalog:testing"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Updating Versions
|
||||
|
||||
To update versions across all packages, simply change the version in the root package.json:
|
||||
|
||||
```json
|
||||
"catalog": {
|
||||
"react": "^19.1.0", // Updated from ^19.0.0
|
||||
"react-dom": "^19.1.0" // Updated from ^19.0.0
|
||||
}
|
||||
```
|
||||
|
||||
Then run `bun install` to update all packages.
|
||||
|
||||
## Lockfile Integration
|
||||
|
||||
Bun's lockfile tracks catalog versions, making it easy to ensure consistent installations across different environments. The lockfile includes:
|
||||
|
||||
- The catalog definitions from your package.json
|
||||
- The resolution of each cataloged dependency
|
||||
|
||||
```
|
||||
// bun.lock (excerpt)
|
||||
{
|
||||
"lockfileVersion": 1,
|
||||
"workspaces": {
|
||||
"": {
|
||||
"name": "react-monorepo",
|
||||
},
|
||||
"packages/app": {
|
||||
"name": "app",
|
||||
"dependencies": {
|
||||
"react": "catalog:",
|
||||
"react-dom": "catalog:",
|
||||
...
|
||||
},
|
||||
},
|
||||
...
|
||||
},
|
||||
"catalog": {
|
||||
"react": "^19.0.0",
|
||||
"react-dom": "^19.0.0",
|
||||
...
|
||||
},
|
||||
"catalogs": {
|
||||
"build": {
|
||||
"webpack": "5.88.2",
|
||||
...
|
||||
},
|
||||
...
|
||||
},
|
||||
"packages": {
|
||||
...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Limitations and Edge Cases
|
||||
|
||||
- Catalog references must match a dependency defined in either `catalog` or one of the named `catalogs`
|
||||
- Empty strings and whitespace in catalog names are ignored (treated as default catalog)
|
||||
- Invalid dependency versions in catalogs will fail to resolve during `bun install`
|
||||
- Catalogs are only available within workspaces; they cannot be used outside the monorepo
|
||||
|
||||
Bun's catalog system provides a powerful yet simple way to maintain consistency across your monorepo without introducing additional complexity to your workflow.
|
||||
|
||||
## Publishing
|
||||
|
||||
When you run `bun publish` or `bun pm pack`, Bun automatically replaces
|
||||
`catalog:` references in your `package.json` with the resolved version numbers.
|
||||
The published package includes regular semver strings and no longer depends on
|
||||
your catalog definitions.
|
||||
@@ -83,6 +83,14 @@ Workspaces have a couple major benefits.
|
||||
- **Dependencies can be de-duplicated.** If `a` and `b` share a common dependency, it will be _hoisted_ to the root `node_modules` directory. This reduces redundant disk usage and minimizes "dependency hell" issues associated with having multiple versions of a package installed simultaneously.
|
||||
- **Run scripts in multiple packages.** You can use the [`--filter` flag](https://bun.sh/docs/cli/filter) to easily run `package.json` scripts in multiple packages in your workspace.
|
||||
|
||||
## Share versions with Catalogs
|
||||
|
||||
When many packages need the same dependency versions, catalogs let you define
|
||||
those versions once in the root `package.json` and reference them from your
|
||||
workspaces using the `catalog:` protocol. Updating the catalog automatically
|
||||
updates every package that references it. See
|
||||
[Catalogs](https://bun.sh/docs/install/catalogs) for details.
|
||||
|
||||
{% callout %}
|
||||
⚡️ **Speed** — Installs are fast, even for big monorepos. Bun installs the [Remix](https://github.com/remix-run/remix) monorepo in about `500ms` on Linux.
|
||||
|
||||
|
||||
@@ -206,7 +206,7 @@ $ iex "& {$(irm https://bun.sh/install.ps1)} -Version $BUN_LATEST_VERSION"
|
||||
|
||||
## Downloading Bun binaries directly
|
||||
|
||||
To download Bun binaries directly, you can visit the [releases page](https://github.com/oven-sh/bun/releases) page on GitHub.
|
||||
To download Bun binaries directly, you can visit the [releases page](https://github.com/oven-sh/bun/releases) on GitHub.
|
||||
|
||||
For convenience, here are download links for the latest version:
|
||||
|
||||
@@ -223,7 +223,16 @@ For convenience, here are download links for the latest version:
|
||||
|
||||
The `musl` binaries are built for distributions that do not ship with the glibc libraries by default, instead relying on musl. The two most popular distros are Void Linux and Alpine Linux, with the latter is used heavily in Docker containers. If you encounter an error like the following: `bun: /lib/x86_64-linux-gnu/libm.so.6: version GLIBC_2.29' not found (required by bun)`, try using the musl binary. Bun's install script automatically chooses the correct binary for your system.
|
||||
|
||||
Bun's `x64` binaries target the Haswell CPU architecture, which means they require AVX and AVX2 instructions. For Linux and Windows, the `x64-baseline` binaries are also available which target the Nehalem architecture. If you run into an "Illegal Instruction" error when running Bun, try using the `baseline` binaries instead. Bun's install scripts automatically chooses the correct binary for your system which helps avoid this issue. Baseline builds are slower than regular builds, so use them only if necessary.
|
||||
### CPU requirements and `baseline` builds
|
||||
|
||||
Bun's `x64` binaries target the Haswell CPU architecture, which means they require AVX and AVX2 instructions. For Linux and Windows, the `x64-baseline` binaries are also available which target the Nehalem architecture. If you run into an "Illegal Instruction" error when running Bun, try using the `baseline` binaries instead. Bun's install script automatically chooses the correct binary for your system which helps avoid this issue. Baseline builds are slower than regular builds, so use them only if necessary.
|
||||
|
||||
| Build | Intel requirement | AMD requirement |
|
||||
| ------------ | ------------------------------------------------------------------ | ------------------ |
|
||||
| x64 | Haswell (4th generation Core) or newer, except some low-end models | Excavator or newer |
|
||||
| x64-baseline | Nehalem (1st generation Core) or newer | Bulldozer or newer |
|
||||
|
||||
Bun does not currently support any CPUs older than the `baseline` target, which mandates the SSE4.2 extension.
|
||||
|
||||
Bun also publishes `darwin-x64-baseline` binaries, but these are just a copy of the `darwin-x64` ones so they still have the same CPU requirement. We only maintain these since some tools expect them to exist. Bun requires macOS 13.0 or later, which does not support any CPUs that don't meet our requirement.
|
||||
|
||||
|
||||
@@ -183,6 +183,9 @@ export default {
|
||||
page("install/workspaces", "Workspaces", {
|
||||
description: "Bun's package manager supports workspaces and monorepo development workflows.",
|
||||
}),
|
||||
page("install/catalogs", "Catalogs", {
|
||||
description: "Use catalogs to share dependency versions between packages in a monorepo.",
|
||||
}),
|
||||
page("install/lifecycle", "Lifecycle scripts", {
|
||||
description: "How Bun handles package lifecycle scripts with trustedDependencies",
|
||||
}),
|
||||
@@ -204,6 +207,9 @@ export default {
|
||||
description:
|
||||
"Patch dependencies in your project to fix bugs or add features without vendoring the entire package.",
|
||||
}),
|
||||
page("install/audit", "Audit dependencies", {
|
||||
description: "Check installed packages for vulnerabilities.",
|
||||
}),
|
||||
page("install/npmrc", ".npmrc support", {
|
||||
description: "Bun supports loading some configuration options from .npmrc",
|
||||
}),
|
||||
@@ -389,7 +395,7 @@ export default {
|
||||
page("api/cc", "C Compiler", {
|
||||
description: `Build & run native C from JavaScript with Bun's native C compiler API`,
|
||||
}), // "`bun:ffi`"),
|
||||
page("api/test", "Testing", {
|
||||
page("cli/test", "Testing", {
|
||||
description: `Bun's built-in test runner is fast and uses Jest-compatible syntax.`,
|
||||
}), // "`bun:test`"),
|
||||
page("api/utils", "Utils", {
|
||||
|
||||
@@ -58,7 +58,7 @@ Then add the following to your `compilerOptions` in `tsconfig.json`:
|
||||
"compilerOptions": {
|
||||
"lib": ["ESNext"],
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"module": "Preserve",
|
||||
"moduleDetection": "force",
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
|
||||
@@ -19,31 +19,43 @@ Click the link in the right column to jump to the associated documentation.
|
||||
|
||||
---
|
||||
|
||||
- HTTP server
|
||||
- HTTP Server
|
||||
- [`Bun.serve`](https://bun.sh/docs/api/http#bun-serve)
|
||||
|
||||
---
|
||||
|
||||
- Shell
|
||||
- [`$`](https://bun.sh/docs/runtime/shell)
|
||||
|
||||
---
|
||||
|
||||
- Bundler
|
||||
- [`Bun.build`](https://bun.sh/docs/bundler)
|
||||
|
||||
---
|
||||
|
||||
- File I/O
|
||||
- [`Bun.file`](https://bun.sh/docs/api/file-io#reading-files-bun-file)
|
||||
[`Bun.write`](https://bun.sh/docs/api/file-io#writing-files-bun-write)
|
||||
- [`Bun.file`](https://bun.sh/docs/api/file-io#reading-files-bun-file), [`Bun.write`](https://bun.sh/docs/api/file-io#writing-files-bun-write), `Bun.stdin`, `Bun.stdout`, `Bun.stderr`
|
||||
|
||||
---
|
||||
|
||||
- Child processes
|
||||
- [`Bun.spawn`](https://bun.sh/docs/api/spawn#spawn-a-process-bun-spawn)
|
||||
[`Bun.spawnSync`](https://bun.sh/docs/api/spawn#blocking-api-bun-spawnsync)
|
||||
- Child Processes
|
||||
- [`Bun.spawn`](https://bun.sh/docs/api/spawn#spawn-a-process-bun-spawn), [`Bun.spawnSync`](https://bun.sh/docs/api/spawn#blocking-api-bun-spawnsync)
|
||||
|
||||
---
|
||||
|
||||
- TCP
|
||||
- [`Bun.listen`](https://bun.sh/docs/api/tcp#start-a-server-bun-listen)
|
||||
[`Bun.connect`](https://bun.sh/docs/api/tcp#start-a-server-bun-listen)
|
||||
- TCP Sockets
|
||||
- [`Bun.listen`](https://bun.sh/docs/api/tcp#start-a-server-bun-listen), [`Bun.connect`](https://bun.sh/docs/api/tcp#start-a-server-bun-listen)
|
||||
|
||||
---
|
||||
|
||||
- UDP Sockets
|
||||
- [`Bun.udpSocket`](https://bun.sh/docs/api/udp)
|
||||
|
||||
---
|
||||
|
||||
- WebSockets
|
||||
- `new WebSocket()` (client), [`Bun.serve`](https://bun.sh/docs/api/websockets) (server)
|
||||
|
||||
---
|
||||
|
||||
@@ -57,44 +69,53 @@ Click the link in the right column to jump to the associated documentation.
|
||||
|
||||
---
|
||||
|
||||
- Streaming HTML Transformations
|
||||
- Streaming HTML
|
||||
- [`HTMLRewriter`](https://bun.sh/docs/api/html-rewriter)
|
||||
|
||||
---
|
||||
|
||||
- Hashing
|
||||
- [`Bun.hash`](https://bun.sh/docs/api/hashing#bun-hash)
|
||||
[`Bun.CryptoHasher`](https://bun.sh/docs/api/hashing#bun-cryptohasher)
|
||||
- [`Bun.password`](https://bun.sh/docs/api/hashing#bun-password), [`Bun.hash`](https://bun.sh/docs/api/hashing#bun-hash), [`Bun.CryptoHasher`](https://bun.sh/docs/api/hashing#bun-cryptohasher), `Bun.sha`
|
||||
|
||||
---
|
||||
|
||||
- import.meta
|
||||
- [`import.meta`](https://bun.sh/docs/api/import-meta)
|
||||
|
||||
---
|
||||
|
||||
<!-- - [DNS](https://bun.sh/docs/api/dns)
|
||||
- `Bun.dns`
|
||||
|
||||
--- -->
|
||||
|
||||
- SQLite
|
||||
- [`bun:sqlite`](https://bun.sh/docs/api/sqlite)
|
||||
|
||||
---
|
||||
|
||||
- FFI
|
||||
- PostgreSQL Client
|
||||
- [`Bun.SQL`](https://bun.sh/docs/api/sql), `Bun.sql`
|
||||
|
||||
---
|
||||
|
||||
- Redis (Valkey) Client
|
||||
- [`Bun.RedisClient`](https://bun.sh/docs/api/redis), `Bun.redis`
|
||||
|
||||
---
|
||||
|
||||
- FFI (Foreign Function Interface)
|
||||
- [`bun:ffi`](https://bun.sh/docs/api/ffi)
|
||||
|
||||
---
|
||||
|
||||
- DNS
|
||||
- [`Bun.dns.lookup`](https://bun.sh/docs/api/dns), `Bun.dns.prefetch`, `Bun.dns.getCacheStats`
|
||||
|
||||
---
|
||||
|
||||
- Testing
|
||||
- [`bun:test`](https://bun.sh/docs/cli/test)
|
||||
|
||||
---
|
||||
|
||||
- Node-API
|
||||
- [`Node-API`](https://bun.sh/docs/api/node-api)
|
||||
- Workers
|
||||
- [`new Worker()`](https://bun.sh/docs/api/workers)
|
||||
|
||||
---
|
||||
|
||||
- Module Loaders
|
||||
- [`Bun.plugin`](https://bun.sh/docs/bundler/plugins)
|
||||
|
||||
---
|
||||
|
||||
@@ -103,27 +124,84 @@ Click the link in the right column to jump to the associated documentation.
|
||||
|
||||
---
|
||||
|
||||
- Cookies
|
||||
- [`Bun.Cookie`](https://bun.sh/docs/api/cookie), [`Bun.CookieMap`](https://bun.sh/docs/api/cookie)
|
||||
|
||||
---
|
||||
|
||||
- Node-API
|
||||
- [`Node-API`](https://bun.sh/docs/api/node-api)
|
||||
|
||||
---
|
||||
|
||||
- `import.meta`
|
||||
- [`import.meta`](https://bun.sh/docs/api/import-meta)
|
||||
|
||||
---
|
||||
|
||||
- Utilities
|
||||
- [`Bun.version`](https://bun.sh/docs/api/utils#bun-version)
|
||||
[`Bun.revision`](https://bun.sh/docs/api/utils#bun-revision)
|
||||
[`Bun.env`](https://bun.sh/docs/api/utils#bun-env)
|
||||
[`Bun.main`](https://bun.sh/docs/api/utils#bun-main)
|
||||
[`Bun.sleep()`](https://bun.sh/docs/api/utils#bun-sleep)
|
||||
[`Bun.sleepSync()`](https://bun.sh/docs/api/utils#bun-sleepsync)
|
||||
[`Bun.which()`](https://bun.sh/docs/api/utils#bun-which)
|
||||
[`Bun.peek()`](https://bun.sh/docs/api/utils#bun-peek)
|
||||
[`Bun.openInEditor()`](https://bun.sh/docs/api/utils#bun-openineditor)
|
||||
[`Bun.deepEquals()`](https://bun.sh/docs/api/utils#bun-deepequals)
|
||||
[`Bun.escapeHTML()`](https://bun.sh/docs/api/utils#bun-escapehtml)
|
||||
[`Bun.fileURLToPath()`](https://bun.sh/docs/api/utils#bun-fileurltopath)
|
||||
[`Bun.pathToFileURL()`](https://bun.sh/docs/api/utils#bun-pathtofileurl)
|
||||
[`Bun.gzipSync()`](https://bun.sh/docs/api/utils#bun-gzipsync)
|
||||
[`Bun.gunzipSync()`](https://bun.sh/docs/api/utils#bun-gunzipsync)
|
||||
[`Bun.deflateSync()`](https://bun.sh/docs/api/utils#bun-deflatesync)
|
||||
[`Bun.inflateSync()`](https://bun.sh/docs/api/utils#bun-inflatesync)
|
||||
[`Bun.inspect()`](https://bun.sh/docs/api/utils#bun-inspect)
|
||||
[`Bun.nanoseconds()`](https://bun.sh/docs/api/utils#bun-nanoseconds)
|
||||
[`Bun.readableStreamTo*()`](https://bun.sh/docs/api/utils#bun-readablestreamto)
|
||||
[`Bun.resolveSync()`](https://bun.sh/docs/api/utils#bun-resolvesync)
|
||||
- [`Bun.version`](https://bun.sh/docs/api/utils#bun-version), [`Bun.revision`](https://bun.sh/docs/api/utils#bun-revision), [`Bun.env`](https://bun.sh/docs/api/utils#bun-env), [`Bun.main`](https://bun.sh/docs/api/utils#bun-main)
|
||||
|
||||
---
|
||||
|
||||
- Sleep & Timing
|
||||
- [`Bun.sleep()`](https://bun.sh/docs/api/utils#bun-sleep), [`Bun.sleepSync()`](https://bun.sh/docs/api/utils#bun-sleepsync), [`Bun.nanoseconds()`](https://bun.sh/docs/api/utils#bun-nanoseconds)
|
||||
|
||||
---
|
||||
|
||||
- Random & UUID
|
||||
- [`Bun.randomUUIDv7()`](https://bun.sh/docs/api/utils#bun-randomuuidv7)
|
||||
|
||||
---
|
||||
|
||||
- System & Environment
|
||||
- [`Bun.which()`](https://bun.sh/docs/api/utils#bun-which)
|
||||
|
||||
---
|
||||
|
||||
- Comparison & Inspection
|
||||
- [`Bun.peek()`](https://bun.sh/docs/api/utils#bun-peek), [`Bun.deepEquals()`](https://bun.sh/docs/api/utils#bun-deepequals), `Bun.deepMatch`, [`Bun.inspect()`](https://bun.sh/docs/api/utils#bun-inspect)
|
||||
|
||||
---
|
||||
|
||||
- String & Text Processing
|
||||
- [`Bun.escapeHTML()`](https://bun.sh/docs/api/utils#bun-escapehtml), [`Bun.stringWidth()`](https://bun.sh/docs/api/utils#bun-stringwidth), `Bun.indexOfLine`
|
||||
|
||||
---
|
||||
|
||||
- URL & Path Utilities
|
||||
- [`Bun.fileURLToPath()`](https://bun.sh/docs/api/utils#bun-fileurltopath), [`Bun.pathToFileURL()`](https://bun.sh/docs/api/utils#bun-pathtofileurl)
|
||||
|
||||
---
|
||||
|
||||
- Compression
|
||||
- [`Bun.gzipSync()`](https://bun.sh/docs/api/utils#bun-gzipsync), [`Bun.gunzipSync()`](https://bun.sh/docs/api/utils#bun-gunzipsync), [`Bun.deflateSync()`](https://bun.sh/docs/api/utils#bun-deflatesync), [`Bun.inflateSync()`](https://bun.sh/docs/api/utils#bun-inflatesync), `Bun.zstdCompressSync()`, `Bun.zstdDecompressSync()`, `Bun.zstdCompress()`, `Bun.zstdDecompress()`
|
||||
|
||||
---
|
||||
|
||||
- Stream Processing
|
||||
- [`Bun.readableStreamTo*()`](https://bun.sh/docs/api/utils#bun-readablestreamto), `Bun.readableStreamToBytes()`, `Bun.readableStreamToBlob()`, `Bun.readableStreamToFormData()`, `Bun.readableStreamToJSON()`, `Bun.readableStreamToArray()`
|
||||
|
||||
---
|
||||
|
||||
- Memory & Buffer Management
|
||||
- `Bun.ArrayBufferSink`, `Bun.allocUnsafe`, `Bun.concatArrayBuffers`
|
||||
|
||||
---
|
||||
|
||||
- Module Resolution
|
||||
- [`Bun.resolveSync()`](https://bun.sh/docs/api/utils#bun-resolvesync)
|
||||
|
||||
---
|
||||
|
||||
- Parsing & Formatting
|
||||
- [`Bun.semver`](https://bun.sh/docs/api/semver), `Bun.TOML.parse`, [`Bun.color`](https://bun.sh/docs/api/color)
|
||||
|
||||
---
|
||||
|
||||
- Low-level / Internals
|
||||
- `Bun.mmap`, `Bun.gc`, `Bun.generateHeapSnapshot`, [`bun:jsc`](https://bun.sh/docs/api/bun-jsc)
|
||||
|
||||
---
|
||||
|
||||
{% /table %}
|
||||
|
||||
@@ -76,7 +76,7 @@ The `define` field allows you to replace certain global identifiers with constan
|
||||
|
||||
### `loader`
|
||||
|
||||
Configure how Bun maps file extensions to loaders. This is useful for loading files that aren't natively supported by Bun. If
|
||||
Configure how Bun maps file extensions to loaders. This is useful for loading files that aren't natively supported by Bun.
|
||||
|
||||
```toml
|
||||
[loader]
|
||||
@@ -353,6 +353,8 @@ dryRun = false
|
||||
|
||||
To configure the directory where Bun puts globally installed packages.
|
||||
|
||||
Environment variable: `BUN_INSTALL_GLOBAL_DIR`
|
||||
|
||||
```toml
|
||||
[install]
|
||||
# where `bun install --global` installs packages
|
||||
@@ -363,6 +365,8 @@ globalDir = "~/.bun/install/global"
|
||||
|
||||
To configure the directory where Bun installs globally installed binaries and CLIs.
|
||||
|
||||
Environment variable: `BUN_INSTALL_BIN`
|
||||
|
||||
```toml
|
||||
# where globally-installed package bins are linked
|
||||
globalBinDir = "~/.bun/bin"
|
||||
@@ -382,6 +386,17 @@ registry = { url = "https://registry.npmjs.org", token = "123456" }
|
||||
registry = "https://username:password@registry.npmjs.org"
|
||||
```
|
||||
|
||||
### `install.linkWorkspacePackages`
|
||||
|
||||
To configure how workspace packages are linked, use the `install.linkWorkspacePackages` option.
|
||||
|
||||
Whether to link workspace packages from the monorepo root to their respective `node_modules` directories. Default `true`.
|
||||
|
||||
```toml
|
||||
[install]
|
||||
linkWorkspacePackages = true
|
||||
```
|
||||
|
||||
### `install.scopes`
|
||||
|
||||
To configure a registry for a particular scope (e.g. `@myorg/<package>`) use `install.scopes`. You can reference environment variables with `$variable` notation.
|
||||
|
||||
@@ -120,7 +120,7 @@ This page is updated regularly to reflect compatibility status of the latest ver
|
||||
|
||||
### [`node:net`](https://nodejs.org/api/net.html)
|
||||
|
||||
🟡 `SocketAddress` class not exposed (but implemented). `BlockList` exists but is a no-op.
|
||||
🟢 Fully implemented.
|
||||
|
||||
### [`node:perf_hooks`](https://nodejs.org/api/perf_hooks.html)
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ Once the plugin is registered, `.yaml` and `.yml` files can be directly imported
|
||||
{% codetabs %}
|
||||
|
||||
```ts#index.ts
|
||||
import data from "./data.yml"
|
||||
import * as data from "./data.yml"
|
||||
|
||||
console.log(data);
|
||||
```
|
||||
|
||||
@@ -206,13 +206,11 @@ Understanding how `mock.module()` works helps you use it more effectively:
|
||||
2. **Lazy Evaluation**: The mock factory callback is only evaluated when the module is actually imported or required.
|
||||
|
||||
3. **Path Resolution**: Bun automatically resolves the module specifier as though you were doing an import, supporting:
|
||||
|
||||
- Relative paths (`'./module'`)
|
||||
- Absolute paths (`'/path/to/module'`)
|
||||
- Package names (`'lodash'`)
|
||||
|
||||
4. **Import Timing Effects**:
|
||||
|
||||
- When mocking before first import: No side effects from the original module occur
|
||||
- When mocking after import: The original module's side effects have already happened
|
||||
- For this reason, using `--preload` is recommended for mocks that need to prevent side effects
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user