mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 23:18:47 +00:00
Compare commits
416 Commits
repl
...
jarred/upd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b02425d87 | ||
|
|
b444c0b98d | ||
|
|
15880308b7 | ||
|
|
89bb526e14 | ||
|
|
63a00791fa | ||
|
|
a6af1c89b9 | ||
|
|
08bf8b8ad1 | ||
|
|
0c3c57cc35 | ||
|
|
237a5ada47 | ||
|
|
0a2d490bf8 | ||
|
|
ea956e58e9 | ||
|
|
46b5069c40 | ||
|
|
f7618aba20 | ||
|
|
e020ecec15 | ||
|
|
8775d37559 | ||
|
|
54d25b8f6b | ||
|
|
960922bba9 | ||
|
|
c21be13be4 | ||
|
|
c0b758ad45 | ||
|
|
d65fdb6035 | ||
|
|
a97847a494 | ||
|
|
eddb0078b5 | ||
|
|
fa7d7bd1e4 | ||
|
|
72bdd380af | ||
|
|
10bee33909 | ||
|
|
6afa78120a | ||
|
|
6514dcf4cb | ||
|
|
d3caf37b49 | ||
|
|
315125c43a | ||
|
|
f6fbf86910 | ||
|
|
e1117c6ae5 | ||
|
|
4bdec01619 | ||
|
|
2e8d9d4607 | ||
|
|
640b0b4df9 | ||
|
|
16be721d8a | ||
|
|
26794680dd | ||
|
|
5fedc8bd6c | ||
|
|
e62fef6765 | ||
|
|
387f1260c9 | ||
|
|
e60b3607c1 | ||
|
|
31d96a1b7f | ||
|
|
3ee09bfe79 | ||
|
|
3d37684253 | ||
|
|
06a82b7725 | ||
|
|
1d6d639352 | ||
|
|
7cd1dc2817 | ||
|
|
57d1ae234c | ||
|
|
8608b5286a | ||
|
|
a5f76e690a | ||
|
|
a0081f9e29 | ||
|
|
4d2b442a33 | ||
|
|
0268807be2 | ||
|
|
f354a29683 | ||
|
|
e5b62bf074 | ||
|
|
e05d190e6a | ||
|
|
d7b43f8ea1 | ||
|
|
648d5aecf3 | ||
|
|
dc55492698 | ||
|
|
2b2927dedc | ||
|
|
500c52af62 | ||
|
|
c1deec3c16 | ||
|
|
fbbf184b1d | ||
|
|
e127c520a9 | ||
|
|
80195557c9 | ||
|
|
9e26485b04 | ||
|
|
5cf29df066 | ||
|
|
1bf36cf123 | ||
|
|
d060474f3a | ||
|
|
fae646da3b | ||
|
|
298515c368 | ||
|
|
2a14d9e5c9 | ||
|
|
549d01a4d6 | ||
|
|
aec0d35f9b | ||
|
|
b5c80d9476 | ||
|
|
17fa9378e9 | ||
|
|
6cde1d3b89 | ||
|
|
6d842e7dcb | ||
|
|
9d9fcbbdeb | ||
|
|
cd09bb0e9b | ||
|
|
bbc70d2b73 | ||
|
|
3eca2c7fee | ||
|
|
af0cb893b5 | ||
|
|
7027493196 | ||
|
|
bd4523798f | ||
|
|
6326eb4246 | ||
|
|
96411580c1 | ||
|
|
3f463786a5 | ||
|
|
43f092807b | ||
|
|
b8817ab188 | ||
|
|
ef7f679edf | ||
|
|
57010cc448 | ||
|
|
b6a4161cc5 | ||
|
|
a5908e9f27 | ||
|
|
72f9017b21 | ||
|
|
93f1d91083 | ||
|
|
ec0e931e9f | ||
|
|
a229cfd3c6 | ||
|
|
966b636e5d | ||
|
|
ee93f1b88c | ||
|
|
ffd21e98e7 | ||
|
|
a3db02832e | ||
|
|
1445775d64 | ||
|
|
feefaf00d7 | ||
|
|
25e69c71e7 | ||
|
|
9d5459221f | ||
|
|
341c1c1804 | ||
|
|
b218c40a5d | ||
|
|
09d6e8553b | ||
|
|
0502c134e8 | ||
|
|
e34ff61339 | ||
|
|
8684a59029 | ||
|
|
b297fabd17 | ||
|
|
b05e10cd8b | ||
|
|
92a5d845ae | ||
|
|
030407c52e | ||
|
|
cfc56dafeb | ||
|
|
b011f94250 | ||
|
|
66cdb077ad | ||
|
|
4a1573e007 | ||
|
|
0b4a34bbd6 | ||
|
|
d1e9b33cac | ||
|
|
abfc10afeb | ||
|
|
a18ef053a4 | ||
|
|
6abc9af472 | ||
|
|
e1cf08b3a6 | ||
|
|
28f3453466 | ||
|
|
9c45487763 | ||
|
|
01d2cb5d98 | ||
|
|
2664dfad9b | ||
|
|
e0c5debc57 | ||
|
|
e160223627 | ||
|
|
b00588e98c | ||
|
|
ac19c7c62e | ||
|
|
539eec85db | ||
|
|
b7951511a3 | ||
|
|
b65862e23b | ||
|
|
5f66b4e729 | ||
|
|
7319142fd8 | ||
|
|
365fc0d39d | ||
|
|
34d191be67 | ||
|
|
5c6d7760a5 | ||
|
|
3c7b9353e1 | ||
|
|
64a717ab33 | ||
|
|
bbff5b7735 | ||
|
|
2e06dbaffe | ||
|
|
19151bb1d2 | ||
|
|
f8343f25b8 | ||
|
|
67defd95af | ||
|
|
aa3355dc82 | ||
|
|
8c612adcdb | ||
|
|
711a2bcdd1 | ||
|
|
689b28455c | ||
|
|
4439f16155 | ||
|
|
ff7f642099 | ||
|
|
1456c72648 | ||
|
|
5d09a06100 | ||
|
|
4a0eb19038 | ||
|
|
edee1e3d04 | ||
|
|
e2fb524993 | ||
|
|
ee33d5ced4 | ||
|
|
53fd9ff4bf | ||
|
|
e3558b626c | ||
|
|
5defdf3e28 | ||
|
|
f8d7f50cdb | ||
|
|
ddb1189b2d | ||
|
|
4fce34854b | ||
|
|
615beee1ae | ||
|
|
ef98a1b761 | ||
|
|
8709fd7855 | ||
|
|
ebc7b037ed | ||
|
|
f4e7f6db7c | ||
|
|
f6eaf4bc78 | ||
|
|
fc14902f73 | ||
|
|
d362a8b9ec | ||
|
|
8677ae9fb1 | ||
|
|
66d490d109 | ||
|
|
19fc8ecba2 | ||
|
|
ed9e64805f | ||
|
|
8ca691693f | ||
|
|
4b5dcc8a6a | ||
|
|
d2328285f9 | ||
|
|
346f8e9c94 | ||
|
|
b34da183bd | ||
|
|
db1263662c | ||
|
|
63afadcb91 | ||
|
|
8b690aaf0d | ||
|
|
9b7fb8b0f3 | ||
|
|
cc54b62fac | ||
|
|
9d3f60d44e | ||
|
|
b453ec38d6 | ||
|
|
1b949d4f5a | ||
|
|
0647216687 | ||
|
|
6df837cff1 | ||
|
|
c55b2c56a4 | ||
|
|
eb1dc7eede | ||
|
|
79dd196edd | ||
|
|
333e217c32 | ||
|
|
f77df12894 | ||
|
|
8f8ab301b4 | ||
|
|
0800f7017c | ||
|
|
8c1c2a0d9d | ||
|
|
bab9889601 | ||
|
|
b27b04690b | ||
|
|
c7de270bbb | ||
|
|
c66d4a724b | ||
|
|
9acc081c3a | ||
|
|
630bbfca91 | ||
|
|
57e38e8312 | ||
|
|
ffa88a1f81 | ||
|
|
2a6fdc2298 | ||
|
|
bca88b67e3 | ||
|
|
c6899940ab | ||
|
|
639a12f59f | ||
|
|
25aa51dfc4 | ||
|
|
c6b25adeea | ||
|
|
0404d09cc7 | ||
|
|
f5b37fa0b0 | ||
|
|
4e0c589562 | ||
|
|
a098c6e5f6 | ||
|
|
383d5b55d6 | ||
|
|
80e1f32ca1 | ||
|
|
eca93d4257 | ||
|
|
77781e2fa1 | ||
|
|
0a318ecca1 | ||
|
|
08426962fa | ||
|
|
7f45866d76 | ||
|
|
5e6490d905 | ||
|
|
b651b16fdd | ||
|
|
caa192480c | ||
|
|
6d8056554e | ||
|
|
43c463f078 | ||
|
|
787281ee5e | ||
|
|
cb057e61ba | ||
|
|
b54e3f3c04 | ||
|
|
7f2e40af46 | ||
|
|
d976b22c95 | ||
|
|
575a85a3fd | ||
|
|
8eabb4d1d5 | ||
|
|
99a92465f3 | ||
|
|
37edd5a6e3 | ||
|
|
29b22175bf | ||
|
|
75697890ce | ||
|
|
7662f99ee0 | ||
|
|
1e99419127 | ||
|
|
cd1846a414 | ||
|
|
a39b0d86a0 | ||
|
|
6cc5872765 | ||
|
|
898962770e | ||
|
|
7d0db82bb3 | ||
|
|
4b00144211 | ||
|
|
92f2d9ab27 | ||
|
|
56c471a005 | ||
|
|
20f61b2369 | ||
|
|
9168be4f15 | ||
|
|
d26addeca1 | ||
|
|
f84fbd6e3e | ||
|
|
f2a8575e4d | ||
|
|
29a6ece6c6 | ||
|
|
9c44ec1b0d | ||
|
|
819a1fde28 | ||
|
|
31fec8f704 | ||
|
|
c5e8271cdc | ||
|
|
da7db2230f | ||
|
|
94e9f8bdca | ||
|
|
2e6898470e | ||
|
|
d606958f11 | ||
|
|
ced69d3818 | ||
|
|
b262b0153a | ||
|
|
75e68e356b | ||
|
|
31691e3898 | ||
|
|
332141a6f2 | ||
|
|
308237752a | ||
|
|
e8d58f24af | ||
|
|
07b10bbc16 | ||
|
|
969b0cf539 | ||
|
|
23b1276ee2 | ||
|
|
a983ec713f | ||
|
|
a31d69bf93 | ||
|
|
f3fe4508ae | ||
|
|
96a1d5382f | ||
|
|
e923e23270 | ||
|
|
f815ffa467 | ||
|
|
6e1472b9f8 | ||
|
|
92e95c86dd | ||
|
|
8ae9aeea6b | ||
|
|
4ebed280dc | ||
|
|
b31d76b03d | ||
|
|
0a5e44cd39 | ||
|
|
49a44eef0f | ||
|
|
fa2ef0972b | ||
|
|
9976e3f528 | ||
|
|
fbafbd3394 | ||
|
|
66c0401426 | ||
|
|
631c826866 | ||
|
|
088bea026e | ||
|
|
503c808929 | ||
|
|
0927624608 | ||
|
|
cf834964a6 | ||
|
|
6ac70a6dd2 | ||
|
|
a8cef7ae75 | ||
|
|
c99caccdb2 | ||
|
|
22f14129e5 | ||
|
|
d37602f316 | ||
|
|
cb52556bd1 | ||
|
|
03d9bcd440 | ||
|
|
972a6f29cc | ||
|
|
932fa35f99 | ||
|
|
9c9f4ed6ad | ||
|
|
4f8edb825f | ||
|
|
cb01cb0d4a | ||
|
|
64033f11cc | ||
|
|
1c570b41bc | ||
|
|
500bd15fb5 | ||
|
|
687e31dc3a | ||
|
|
c3455c0cee | ||
|
|
9101774593 | ||
|
|
9a0ea00705 | ||
|
|
ec6b75ff54 | ||
|
|
a18e3ff451 | ||
|
|
eeb790a2f1 | ||
|
|
878b473085 | ||
|
|
6161c201e1 | ||
|
|
32664df254 | ||
|
|
15f7bacb8b | ||
|
|
473513db7e | ||
|
|
75b5c71540 | ||
|
|
c9c62f37e5 | ||
|
|
18b521d9b8 | ||
|
|
534fd30dbd | ||
|
|
3b2c0941e4 | ||
|
|
8d3829114e | ||
|
|
5f9c30b717 | ||
|
|
c55574b4d3 | ||
|
|
2f27e24778 | ||
|
|
b910db74be | ||
|
|
b37cb98a6e | ||
|
|
263382103f | ||
|
|
8777c3f72c | ||
|
|
996491f719 | ||
|
|
12c2da0ebf | ||
|
|
a3166457d3 | ||
|
|
b1bd93bffc | ||
|
|
4c113d1866 | ||
|
|
f9d2e687f5 | ||
|
|
31aec4ebe3 | ||
|
|
b432006e43 | ||
|
|
015f0a6e9a | ||
|
|
07a6443a80 | ||
|
|
6e4f746ace | ||
|
|
b5a3bed7f2 | ||
|
|
8615b8ad6b | ||
|
|
4992839232 | ||
|
|
03b8e9d5cf | ||
|
|
f267c1d097 | ||
|
|
c4507a5db3 | ||
|
|
c9a0ea96cd | ||
|
|
ca461f9e83 | ||
|
|
9c4765f616 | ||
|
|
e091290748 | ||
|
|
350403663e | ||
|
|
895f3824b5 | ||
|
|
58e69ef9f4 | ||
|
|
decad91d24 | ||
|
|
ea56182c5a | ||
|
|
9d6a8ee79d | ||
|
|
b55b511f68 | ||
|
|
49b9306dce | ||
|
|
2956ed4289 | ||
|
|
51d3d43822 | ||
|
|
edea4f095a | ||
|
|
07c88435e0 | ||
|
|
7121c1d6ab | ||
|
|
60dc76676c | ||
|
|
f64b504bae | ||
|
|
97153c5a5f | ||
|
|
d48ff53e4e | ||
|
|
afcbed218c | ||
|
|
682406c42c | ||
|
|
6fe40f383a | ||
|
|
e2d327881c | ||
|
|
4280f74429 | ||
|
|
8139a20c9f | ||
|
|
620f6c51ce | ||
|
|
ffe4f561a3 | ||
|
|
c896792c37 | ||
|
|
088491cb59 | ||
|
|
f27ef667c7 | ||
|
|
7d9820d478 | ||
|
|
b5da5168bf | ||
|
|
61569fab80 | ||
|
|
0887825f54 | ||
|
|
6d02b18680 | ||
|
|
1b8c6f266f | ||
|
|
989dd92ea8 | ||
|
|
9e3cabc540 | ||
|
|
3170cf08ba | ||
|
|
182d3f1567 | ||
|
|
189f0f7c36 | ||
|
|
a05a1780c1 | ||
|
|
822a00c4d5 | ||
|
|
f6a621f36a | ||
|
|
5b9d8b87c4 | ||
|
|
a7c3bc8a5a | ||
|
|
5424ea3403 | ||
|
|
4b63ced72d | ||
|
|
c8883a39a5 | ||
|
|
36e5a072a9 | ||
|
|
57a06745a4 | ||
|
|
4360ec83b4 | ||
|
|
3b9829f171 | ||
|
|
849a2cdfae | ||
|
|
77f1f2480d | ||
|
|
5e074209c6 | ||
|
|
0c2675c8d3 | ||
|
|
a79440f0c3 | ||
|
|
daaac7792c |
35
.github/ISSUE_TEMPLATE/1-install-problem.yml
vendored
35
.github/ISSUE_TEMPLATE/1-install-problem.yml
vendored
@@ -1,35 +0,0 @@
|
||||
name: 📥 Install Problem
|
||||
description: Report an issue during install or upgrade
|
||||
labels: [bug, install]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thank you for submitting a bug report. It helps make Bun better.
|
||||
|
||||
If you need help or support using Bun, and are not reporting an issue, please
|
||||
join our [Discord](https://discord.gg/CXdq2DP29u) server, where you can ask questions in the [`#help`](https://discord.gg/32EtH6p7HN) forum.
|
||||
|
||||
Please try to include as much information as possible.
|
||||
- type: input
|
||||
attributes:
|
||||
label: What platform is your computer?
|
||||
description: |
|
||||
For MacOS and Linux: copy the output of `uname -mprs`
|
||||
For Windows: copy the output of `"$([Environment]::OSVersion | ForEach-Object VersionString) $(if ([Environment]::Is64BitOperatingSystem) { "x64" } else { "x86" })"` in the PowerShell console
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: How did you attempt to install or upgrade?
|
||||
description: Please provide the commands you ran to install or upgrade.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: What do you see instead?
|
||||
description: If possible, please provide text instead of a screenshot.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Additional information
|
||||
description: Is there anything else you think we should know?
|
||||
4
.github/ISSUE_TEMPLATE/2-bug-report.yml
vendored
4
.github/ISSUE_TEMPLATE/2-bug-report.yml
vendored
@@ -10,7 +10,11 @@ body:
|
||||
If you need help or support using Bun, and are not reporting a bug, please
|
||||
join our [Discord](https://discord.gg/CXdq2DP29u) server, where you can ask questions in the [`#help`](https://discord.gg/32EtH6p7HN) forum.
|
||||
|
||||
Make sure you are running the [latest](https://bun.sh/docs/installation#upgrading) version of Bun.
|
||||
The bug you are experiencing may already have been fixed.
|
||||
|
||||
Please try to include as much information as possible.
|
||||
|
||||
- type: input
|
||||
attributes:
|
||||
label: What version of Bun is running?
|
||||
|
||||
2
.github/ISSUE_TEMPLATE/3-feature-request.yml
vendored
2
.github/ISSUE_TEMPLATE/3-feature-request.yml
vendored
@@ -8,7 +8,7 @@ body:
|
||||
Thank you for submitting an idea. It helps make Bun better.
|
||||
|
||||
If you want to discuss Bun, or learn how others are using Bun, please
|
||||
join our [Discord](https://discord.gg/CXdq2DP29u) server, where you can share in the [`#feedback-ideas`](https://discord.gg/unwUnHBNqy) channel.
|
||||
join our [Discord](https://discord.gg/CXdq2DP29u) server, where you can share in the [`#feedback`](https://discord.gg/unwUnHBNqy) channel.
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: What is the problem this feature would solve?
|
||||
|
||||
41
.github/workflows/bun-framework-next.yml
vendored
41
.github/workflows/bun-framework-next.yml
vendored
@@ -1,41 +0,0 @@
|
||||
name: bun-framework-next
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- packages/bun-framework-next/**/*
|
||||
branches: [main, bun-framework-next-actions]
|
||||
pull_request:
|
||||
paths:
|
||||
- packages/bun-framework-next/**/*
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: lint, test and build on Node ${{ matrix.node }} and ${{ matrix.os }}
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node: ["14.x"]
|
||||
os: [macOS-latest]
|
||||
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Use Node ${{ matrix.node }}
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
|
||||
- name: Install PNPM
|
||||
uses: pnpm/action-setup@v2.0.1
|
||||
with:
|
||||
version: 6.21.0
|
||||
|
||||
- name: Install dependencies
|
||||
run: cd packages/bun-framework-next && pnpm install
|
||||
|
||||
- name: Type check bun-framework-next
|
||||
run: cd packages/bun-framework-next && pnpm check
|
||||
3
.github/workflows/bun-linux-aarch64.yml
vendored
3
.github/workflows/bun-linux-aarch64.yml
vendored
@@ -28,6 +28,7 @@ jobs:
|
||||
runs-on: ${{matrix.runner}}
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
timeout-minutes: 90
|
||||
permissions: write-all
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
@@ -36,7 +37,7 @@ jobs:
|
||||
arch: aarch64
|
||||
build_arch: arm64
|
||||
runner: linux-arm64
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-linux-arm64-lto.tar.gz"
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-linux-arm64-lto.tar.gz"
|
||||
webkit_basename: "bun-webkit-linux-arm64-lto"
|
||||
build_machine_arch: aarch64
|
||||
|
||||
|
||||
55
.github/workflows/bun-linux-build.yml
vendored
55
.github/workflows/bun-linux-build.yml
vendored
@@ -37,6 +37,7 @@ jobs:
|
||||
runs-on: ${{matrix.runner}}
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
timeout-minutes: 90
|
||||
permissions: write-all
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -46,7 +47,7 @@ jobs:
|
||||
arch: x86_64
|
||||
build_arch: amd64
|
||||
runner: big-ubuntu
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-linux-amd64-lto.tar.gz"
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-linux-amd64-lto.tar.gz"
|
||||
webkit_basename: "bun-webkit-linux-amd64-lto"
|
||||
build_machine_arch: x86_64
|
||||
- cpu: nehalem
|
||||
@@ -54,7 +55,7 @@ jobs:
|
||||
arch: x86_64
|
||||
build_arch: amd64
|
||||
runner: big-ubuntu
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-linux-amd64-lto.tar.gz"
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-linux-amd64-lto.tar.gz"
|
||||
webkit_basename: "bun-webkit-linux-amd64-lto"
|
||||
build_machine_arch: x86_64
|
||||
|
||||
@@ -152,7 +153,25 @@ jobs:
|
||||
name: "Canary (${{github.sha}})"
|
||||
tag: "canary"
|
||||
artifacts: "${{runner.temp}}/release/bun-${{matrix.tag}}.zip,${{runner.temp}}/release/bun-${{matrix.tag}}-profile.zip"
|
||||
- uses: sarisia/actions-status-discord@v1
|
||||
if: failure() && github.repository_owner == 'oven-sh' && github.event_name == 'pull_request'
|
||||
with:
|
||||
title: ""
|
||||
webhook: ${{ secrets.DISCORD_WEBHOOK }}
|
||||
status: ${{ job.status }}
|
||||
noprefix: true
|
||||
nocontext: true
|
||||
description: |
|
||||
Pull Request
|
||||
### [${{github.event.pull_request.title}}](https://github.com/oven-sh/bun/pull/${{github.event.number}})
|
||||
|
||||
@${{ github.actor }}
|
||||
|
||||
Build failed on ${{ matrix.tag }}:
|
||||
|
||||
**[View build output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})**
|
||||
|
||||
[Commit ${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})
|
||||
linux-test:
|
||||
name: Tests ${{matrix.tag}}
|
||||
runs-on: ubuntu-latest
|
||||
@@ -180,8 +199,8 @@ jobs:
|
||||
with:
|
||||
name: bun-${{matrix.tag}}
|
||||
path: ${{runner.temp}}/release
|
||||
- id: install
|
||||
name: Install
|
||||
- id: install-bun
|
||||
name: Install Bun
|
||||
run: |
|
||||
cd ${{runner.temp}}/release
|
||||
unzip bun-${{matrix.tag}}.zip
|
||||
@@ -189,6 +208,13 @@ jobs:
|
||||
chmod +x bun
|
||||
pwd >> $GITHUB_PATH
|
||||
./bun --version
|
||||
- id: install-dependnecies
|
||||
name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update && sudo apt-get install -y openssl
|
||||
bun install --verbose
|
||||
bun install --cwd=test --verbose
|
||||
bun install --cwd=packages/bun-internal-test --verbose
|
||||
- id: test
|
||||
name: Test (node runner)
|
||||
env:
|
||||
@@ -197,11 +223,24 @@ jobs:
|
||||
TLS_POSTGRES_DATABASE_URL: ${{ secrets.TLS_POSTGRES_DATABASE_URL }}
|
||||
# if: ${{github.event.inputs.use_bun == 'false'}}
|
||||
run: |
|
||||
sudo apt-get update && sudo apt-get install -y openssl
|
||||
bun install
|
||||
bun install --cwd test
|
||||
bun install --cwd packages/bun-internal-test
|
||||
node packages/bun-internal-test/src/runner.node.mjs || true
|
||||
- uses: sarisia/actions-status-discord@v1
|
||||
if: always() && steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request'
|
||||
with:
|
||||
title: ""
|
||||
webhook: ${{ secrets.DISCORD_WEBHOOK }}
|
||||
status: "failure"
|
||||
noprefix: true
|
||||
nocontext: true
|
||||
description: |
|
||||
Pull Request
|
||||
### ❌ [${{github.event.pull_request.title}}](https://github.com/oven-sh/bun/pull/${{github.event.number}})
|
||||
|
||||
@${{ github.actor }}, there are ${{ steps.test.outputs.failing_tests_count }} files with test failures on ${{ matrix.tag }}:
|
||||
|
||||
${{ steps.test.outputs.failing_tests }}
|
||||
|
||||
**[View test output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})**
|
||||
- name: Comment on PR
|
||||
if: steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request'
|
||||
uses: thollander/actions-comment-pull-request@v2
|
||||
|
||||
94
.github/workflows/bun-mac-aarch64.yml
vendored
94
.github/workflows/bun-mac-aarch64.yml
vendored
@@ -115,36 +115,36 @@ jobs:
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64-baseline
|
||||
# obj: bun-obj-darwin-x64-baseline
|
||||
# runner: macos-11
|
||||
# runner: macos-12
|
||||
# artifact: bun-obj-darwin-x64-baseline
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# dependencies: true
|
||||
# compile_obj: false
|
||||
# - cpu: haswell
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64
|
||||
# obj: bun-obj-darwin-x64
|
||||
# runner: macos-11
|
||||
# runner: macos-12
|
||||
# artifact: bun-obj-darwin-x64
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# dependencies: true
|
||||
# compile_obj: false
|
||||
# - cpu: nehalem
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64-baseline
|
||||
# obj: bun-obj-darwin-x64-baseline
|
||||
# runner: macos-11
|
||||
# runner: macos-12
|
||||
# artifact: bun-obj-darwin-x64-baseline
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# dependencies: false
|
||||
# compile_obj: true
|
||||
# - cpu: haswell
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64
|
||||
# obj: bun-obj-darwin-x64
|
||||
# runner: macos-11
|
||||
# runner: macos-12
|
||||
# artifact: bun-obj-darwin-x64
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# dependencies: false
|
||||
# compile_obj: true
|
||||
- cpu: native
|
||||
@@ -152,14 +152,14 @@ jobs:
|
||||
tag: bun-darwin-aarch64
|
||||
obj: bun-obj-darwin-aarch64
|
||||
artifact: bun-obj-darwin-aarch64
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-arm64-lto.tar.gz"
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-arm64-lto.tar.gz"
|
||||
runner: macos-arm64
|
||||
dependencies: true
|
||||
compile_obj: true
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Checkout submodules
|
||||
run: git submodule update --init --recursive --depth=1 --progress -j $(sysctl -n hw.ncpu)
|
||||
run: git submodule update --init --recursive --depth=1 --progress -j $(sysctl -n hw.ncpu) --force
|
||||
- name: Install dependencies
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
@@ -172,11 +172,11 @@ jobs:
|
||||
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
|
||||
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
|
||||
run: |
|
||||
brew install ccache rust llvm@15 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
|
||||
brew install ccache rust llvm@16 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
|
||||
echo "$(brew --prefix ccache)/bin" >> $GITHUB_PATH
|
||||
echo "$(brew --prefix coreutils)/libexec/gnubin" >> $GITHUB_PATH
|
||||
echo "$(brew --prefix llvm@15)/bin" >> $GITHUB_PATH
|
||||
brew link --overwrite llvm@15
|
||||
echo "$(brew --prefix llvm@16)/bin" >> $GITHUB_PATH
|
||||
brew link --overwrite llvm@16
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
with:
|
||||
@@ -247,6 +247,7 @@ jobs:
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
needs: [macOS-cpp, macos-object-files]
|
||||
timeout-minutes: 90
|
||||
permissions: write-all
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
@@ -255,29 +256,29 @@ jobs:
|
||||
# tag: bun-darwin-x64-baseline
|
||||
# obj: bun-obj-darwin-x64-baseline
|
||||
# package: bun-darwin-x64
|
||||
# runner: macos-11
|
||||
# runner: macos-12
|
||||
# artifact: bun-obj-darwin-x64-baseline
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# - cpu: haswell
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64
|
||||
# obj: bun-obj-darwin-x64
|
||||
# package: bun-darwin-x64
|
||||
# runner: macos-11
|
||||
# runner: macos-12
|
||||
# artifact: bun-obj-darwin-x64
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
- cpu: native
|
||||
arch: aarch64
|
||||
tag: bun-darwin-aarch64
|
||||
obj: bun-obj-darwin-aarch64
|
||||
package: bun-darwin-aarch64
|
||||
artifact: bun-obj-darwin-aarch64
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-arm64-lto.tar.gz"
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-arm64-lto.tar.gz"
|
||||
runner: macos-arm64
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Checkout submodules
|
||||
run: git submodule update --init --recursive --depth=1 --progress -j $(sysctl -n hw.ncpu)
|
||||
run: git submodule update --init --recursive --depth=1 --progress -j $(sysctl -n hw.ncpu) --force
|
||||
- name: Install dependencies
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
@@ -290,10 +291,10 @@ jobs:
|
||||
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
|
||||
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
|
||||
run: |
|
||||
brew install rust ccache llvm@15 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
|
||||
brew install rust ccache llvm@16 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
|
||||
echo "$(brew --prefix coreutils)/libexec/gnubin" >> $GITHUB_PATH
|
||||
echo "$(brew --prefix llvm@15)/bin" >> $GITHUB_PATH
|
||||
brew link --overwrite llvm@15
|
||||
echo "$(brew --prefix llvm@16)/bin" >> $GITHUB_PATH
|
||||
brew link --overwrite llvm@16
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
with:
|
||||
@@ -392,6 +393,25 @@ jobs:
|
||||
name: "Canary (${{github.sha}})"
|
||||
tag: "canary"
|
||||
artifacts: "${{runner.temp}}/release/${{matrix.tag}}.zip,${{runner.temp}}/release/${{matrix.tag}}-profile.zip"
|
||||
- uses: sarisia/actions-status-discord@v1
|
||||
if: failure() && github.repository_owner == 'oven-sh' && github.event_name == 'pull_request'
|
||||
with:
|
||||
title: ""
|
||||
webhook: ${{ secrets.DISCORD_WEBHOOK }}
|
||||
status: ${{ job.status }}
|
||||
noprefix: true
|
||||
nocontext: true
|
||||
description: |
|
||||
Pull Request
|
||||
### [${{github.event.pull_request.title}}](https://github.com/oven-sh/bun/pull/${{github.event.number}})
|
||||
|
||||
@${{ github.actor }}
|
||||
|
||||
Build failed on ${{ matrix.tag }}:
|
||||
|
||||
**[View build output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})**
|
||||
|
||||
[Commit ${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})
|
||||
macOS-test:
|
||||
name: Tests ${{matrix.tag}}
|
||||
runs-on: ${{ matrix.runner }}
|
||||
@@ -419,8 +439,8 @@ jobs:
|
||||
with:
|
||||
name: ${{matrix.tag}}
|
||||
path: ${{runner.temp}}/release
|
||||
- id: install
|
||||
name: Install
|
||||
- id: install-bun
|
||||
name: Install Bun
|
||||
run: |
|
||||
cd ${{runner.temp}}/release
|
||||
unzip ${{matrix.tag}}.zip
|
||||
@@ -428,6 +448,12 @@ jobs:
|
||||
chmod +x bun
|
||||
pwd >> $GITHUB_PATH
|
||||
./bun --version
|
||||
- id: install
|
||||
name: Install dependencies
|
||||
run: |
|
||||
bun install --verbose
|
||||
bun install --cwd=test --verbose
|
||||
bun install --cwd=packages/bun-internal-test --verbose
|
||||
- id: test
|
||||
name: Test (node runner)
|
||||
env:
|
||||
@@ -436,10 +462,24 @@ jobs:
|
||||
TLS_POSTGRES_DATABASE_URL: ${{ secrets.TLS_POSTGRES_DATABASE_URL }}
|
||||
# if: ${{github.event.inputs.use_bun == 'false'}}
|
||||
run: |
|
||||
bun install
|
||||
bun install --cwd test
|
||||
bun install --cwd packages/bun-internal-test
|
||||
node packages/bun-internal-test/src/runner.node.mjs || true
|
||||
- uses: sarisia/actions-status-discord@v1
|
||||
if: always() && steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request'
|
||||
with:
|
||||
title: ""
|
||||
webhook: ${{ secrets.DISCORD_WEBHOOK }}
|
||||
status: "failure"
|
||||
noprefix: true
|
||||
nocontext: true
|
||||
description: |
|
||||
Pull Request
|
||||
### ❌ [${{github.event.pull_request.title}}](https://github.com/oven-sh/bun/pull/${{github.event.number}})
|
||||
|
||||
@${{ github.actor }}, there are ${{ steps.test.outputs.failing_tests_count }} files with test failures on ${{ matrix.tag }}:
|
||||
|
||||
${{ steps.test.outputs.failing_tests }}
|
||||
|
||||
**[View test output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})**
|
||||
- name: Comment on PR
|
||||
if: steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request'
|
||||
uses: thollander/actions-comment-pull-request@v2
|
||||
|
||||
99
.github/workflows/bun-mac-x64-baseline.yml
vendored
99
.github/workflows/bun-mac-x64-baseline.yml
vendored
@@ -115,36 +115,36 @@ jobs:
|
||||
arch: x86_64
|
||||
tag: bun-darwin-x64-baseline
|
||||
obj: bun-obj-darwin-x64-baseline
|
||||
runner: macos-11
|
||||
runner: macos-12
|
||||
artifact: bun-obj-darwin-x64-baseline
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
dependencies: true
|
||||
compile_obj: false
|
||||
# - cpu: haswell
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64
|
||||
# obj: bun-obj-darwin-x64
|
||||
# runner: macos-11
|
||||
# runner: macos-12
|
||||
# artifact: bun-obj-darwin-x64
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# dependencies: true
|
||||
# compile_obj: false
|
||||
- cpu: nehalem
|
||||
arch: x86_64
|
||||
tag: bun-darwin-x64-baseline
|
||||
obj: bun-obj-darwin-x64-baseline
|
||||
runner: macos-11
|
||||
runner: macos-12
|
||||
artifact: bun-obj-darwin-x64-baseline
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
dependencies: false
|
||||
compile_obj: true
|
||||
# - cpu: haswell
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64
|
||||
# obj: bun-obj-darwin-x64
|
||||
# runner: macos-11
|
||||
# runner: macos-12
|
||||
# artifact: bun-obj-darwin-x64
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# dependencies: false
|
||||
# compile_obj: true
|
||||
# - cpu: native
|
||||
@@ -152,14 +152,14 @@ jobs:
|
||||
# tag: bun-darwin-aarch64
|
||||
# obj: bun-obj-darwin-aarch64
|
||||
# artifact: bun-obj-darwin-aarch64
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# runner: macos-arm64
|
||||
# dependencies: true
|
||||
# compile_obj: true
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Checkout submodules
|
||||
run: git submodule update --init --recursive --depth=1 --progress -j $(sysctl -n hw.ncpu)
|
||||
run: git submodule update --init --recursive --depth=1 --progress -j $(sysctl -n hw.ncpu) --force
|
||||
- name: Install dependencies
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
@@ -172,11 +172,11 @@ jobs:
|
||||
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
|
||||
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
|
||||
run: |
|
||||
brew install ccache rust llvm@15 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
|
||||
brew install ccache rust llvm@16 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
|
||||
echo "$(brew --prefix ccache)/bin" >> $GITHUB_PATH
|
||||
echo "$(brew --prefix coreutils)/libexec/gnubin" >> $GITHUB_PATH
|
||||
echo "$(brew --prefix llvm@15)/bin" >> $GITHUB_PATH
|
||||
brew link --overwrite llvm@15
|
||||
echo "$(brew --prefix llvm@16)/bin" >> $GITHUB_PATH
|
||||
brew link --overwrite llvm@16
|
||||
- name: ccache (dependencies)
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
if: matrix.dependencies
|
||||
@@ -248,6 +248,7 @@ jobs:
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
needs: [macOS-cpp, macos-object-files]
|
||||
timeout-minutes: 90
|
||||
permissions: write-all
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
@@ -256,29 +257,29 @@ jobs:
|
||||
tag: bun-darwin-x64-baseline
|
||||
obj: bun-obj-darwin-x64-baseline
|
||||
package: bun-darwin-x64
|
||||
runner: macos-11
|
||||
runner: macos-12
|
||||
artifact: bun-obj-darwin-x64-baseline
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# - cpu: haswell
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64
|
||||
# obj: bun-obj-darwin-x64
|
||||
# package: bun-darwin-x64
|
||||
# runner: macos-11
|
||||
# runner: macos-12
|
||||
# artifact: bun-obj-darwin-x64
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# - cpu: native
|
||||
# arch: aarch64
|
||||
# tag: bun-darwin-aarch64
|
||||
# obj: bun-obj-darwin-aarch64
|
||||
# package: bun-darwin-aarch64
|
||||
# artifact: bun-obj-darwin-aarch64
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# runner: macos-arm64
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Checkout submodules
|
||||
run: git submodule update --init --recursive --depth=1 --progress -j $(sysctl -n hw.ncpu)
|
||||
run: git submodule update --init --recursive --depth=1 --progress -j $(sysctl -n hw.ncpu) --force
|
||||
- name: Install dependencies
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
@@ -291,10 +292,10 @@ jobs:
|
||||
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
|
||||
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
|
||||
run: |
|
||||
brew install ccache rust llvm@15 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
|
||||
brew install ccache rust llvm@16 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
|
||||
echo "$(brew --prefix coreutils)/libexec/gnubin" >> $GITHUB_PATH
|
||||
echo "$(brew --prefix llvm@15)/bin" >> $GITHUB_PATH
|
||||
brew link --overwrite llvm@15
|
||||
echo "$(brew --prefix llvm@16)/bin" >> $GITHUB_PATH
|
||||
brew link --overwrite llvm@16
|
||||
- name: ccache (link)
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
with:
|
||||
@@ -396,6 +397,25 @@ jobs:
|
||||
name: "Canary (${{github.sha}})"
|
||||
tag: "canary"
|
||||
artifacts: "${{runner.temp}}/release/${{matrix.tag}}.zip,${{runner.temp}}/release/${{matrix.tag}}-profile.zip"
|
||||
- uses: sarisia/actions-status-discord@v1
|
||||
if: failure() && github.repository_owner == 'oven-sh' && github.event_name == 'pull_request'
|
||||
with:
|
||||
title: ""
|
||||
webhook: ${{ secrets.DISCORD_WEBHOOK }}
|
||||
status: ${{ job.status }}
|
||||
noprefix: true
|
||||
nocontext: true
|
||||
description: |
|
||||
Pull Request
|
||||
### [${{github.event.pull_request.title}}](https://github.com/oven-sh/bun/pull/${{github.event.number}})
|
||||
|
||||
@${{ github.actor }}
|
||||
|
||||
Build failed on ${{ matrix.tag }}:
|
||||
|
||||
**[View build output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})**
|
||||
|
||||
[Commit ${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})
|
||||
macOS-test:
|
||||
name: Tests ${{matrix.tag}}
|
||||
runs-on: ${{ matrix.runner }}
|
||||
@@ -410,7 +430,7 @@ jobs:
|
||||
matrix:
|
||||
include:
|
||||
- tag: bun-darwin-x64-baseline
|
||||
runner: macos-11
|
||||
runner: macos-12
|
||||
steps:
|
||||
- id: checkout
|
||||
name: Checkout
|
||||
@@ -423,8 +443,8 @@ jobs:
|
||||
with:
|
||||
name: ${{matrix.tag}}
|
||||
path: ${{runner.temp}}/release
|
||||
- id: install
|
||||
name: Install
|
||||
- id: install-bun
|
||||
name: Install Bun
|
||||
run: |
|
||||
cd ${{runner.temp}}/release
|
||||
unzip ${{matrix.tag}}.zip
|
||||
@@ -432,6 +452,12 @@ jobs:
|
||||
chmod +x bun
|
||||
pwd >> $GITHUB_PATH
|
||||
./bun --version
|
||||
- id: install
|
||||
name: Install dependencies
|
||||
run: |
|
||||
bun install --verbose
|
||||
bun install --cwd=test --verbose
|
||||
bun install --cwd=packages/bun-internal-test --verbose
|
||||
- id: test
|
||||
name: Test (node runner)
|
||||
env:
|
||||
@@ -440,10 +466,27 @@ jobs:
|
||||
TLS_POSTGRES_DATABASE_URL: ${{ secrets.TLS_POSTGRES_DATABASE_URL }}
|
||||
# if: ${{github.event.inputs.use_bun == 'false'}}
|
||||
run: |
|
||||
bun install
|
||||
bun install --cwd test
|
||||
bun install --cwd packages/bun-internal-test
|
||||
node packages/bun-internal-test/src/runner.node.mjs || true
|
||||
- uses: sarisia/actions-status-discord@v1
|
||||
if: always() && steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request'
|
||||
with:
|
||||
title: ""
|
||||
webhook: ${{ secrets.DISCORD_WEBHOOK }}
|
||||
status: "failure"
|
||||
noprefix: true
|
||||
nocontext: true
|
||||
description: |
|
||||
Pull Request
|
||||
### ❌ [${{github.event.pull_request.title}}](https://github.com/oven-sh/bun/pull/${{github.event.number}})
|
||||
|
||||
Hey @${{ github.actor }},
|
||||
|
||||
${{ steps.test.outputs.failing_tests_count }} files with test failures on ${{ matrix.tag }}:
|
||||
|
||||
${{ steps.test.outputs.failing_tests }}
|
||||
|
||||
**[View test output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})**
|
||||
|
||||
- name: Comment on PR
|
||||
if: steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request'
|
||||
uses: thollander/actions-comment-pull-request@v2
|
||||
|
||||
96
.github/workflows/bun-mac-x64.yml
vendored
96
.github/workflows/bun-mac-x64.yml
vendored
@@ -115,36 +115,36 @@ jobs:
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64-baseline
|
||||
# obj: bun-obj-darwin-x64-baseline
|
||||
# runner: macos-11
|
||||
# runner: macos-12
|
||||
# artifact: bun-obj-darwin-x64-baseline
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# dependencies: true
|
||||
# compile_obj: false
|
||||
- cpu: haswell
|
||||
arch: x86_64
|
||||
tag: bun-darwin-x64
|
||||
obj: bun-obj-darwin-x64
|
||||
runner: macos-11
|
||||
runner: macos-12
|
||||
artifact: bun-obj-darwin-x64
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
dependencies: true
|
||||
compile_obj: false
|
||||
# - cpu: nehalem
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64-baseline
|
||||
# obj: bun-obj-darwin-x64-baseline
|
||||
# runner: macos-11
|
||||
# runner: macos-12
|
||||
# artifact: bun-obj-darwin-x64-baseline
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# dependencies: false
|
||||
# compile_obj: true
|
||||
- cpu: haswell
|
||||
arch: x86_64
|
||||
tag: bun-darwin-x64
|
||||
obj: bun-obj-darwin-x64
|
||||
runner: macos-11
|
||||
runner: macos-12
|
||||
artifact: bun-obj-darwin-x64
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
dependencies: false
|
||||
compile_obj: true
|
||||
# - cpu: native
|
||||
@@ -152,14 +152,14 @@ jobs:
|
||||
# tag: bun-darwin-aarch64
|
||||
# obj: bun-obj-darwin-aarch64
|
||||
# artifact: bun-obj-darwin-aarch64
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-arm64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-arm64-lto.tar.gz"
|
||||
# runner: macos-arm64
|
||||
# dependencies: true
|
||||
# compile_obj: true
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Checkout submodules
|
||||
run: git submodule update --init --recursive --depth=1 --progress -j $(sysctl -n hw.ncpu)
|
||||
run: git submodule update --init --recursive --depth=1 --progress -j $(sysctl -n hw.ncpu) --force
|
||||
- name: Install dependencies
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
@@ -172,10 +172,10 @@ jobs:
|
||||
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
|
||||
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
|
||||
run: |
|
||||
brew install rust ccache llvm@15 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
|
||||
brew install rust ccache llvm@16 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
|
||||
echo "$(brew --prefix coreutils)/libexec/gnubin" >> $GITHUB_PATH
|
||||
echo "$(brew --prefix llvm@15)/bin" >> $GITHUB_PATH
|
||||
brew link --overwrite llvm@15
|
||||
echo "$(brew --prefix llvm@16)/bin" >> $GITHUB_PATH
|
||||
brew link --overwrite llvm@16
|
||||
- name: Download WebKit
|
||||
if: matrix.compile_obj
|
||||
env:
|
||||
@@ -250,6 +250,7 @@ jobs:
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
needs: [macOS-cpp, macos-object-files]
|
||||
timeout-minutes: 90
|
||||
permissions: write-all
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
@@ -258,29 +259,29 @@ jobs:
|
||||
# tag: bun-darwin-x64-baseline
|
||||
# obj: bun-obj-darwin-x64-baseline
|
||||
# package: bun-darwin-x64
|
||||
# runner: macos-11
|
||||
# runner: macos-12
|
||||
# artifact: bun-obj-darwin-x64-baseline
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
- cpu: haswell
|
||||
arch: x86_64
|
||||
tag: bun-darwin-x64
|
||||
obj: bun-obj-darwin-x64
|
||||
package: bun-darwin-x64
|
||||
runner: macos-11
|
||||
runner: macos-12
|
||||
artifact: bun-obj-darwin-x64
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
# - cpu: native
|
||||
# arch: aarch64
|
||||
# tag: bun-darwin-aarch64
|
||||
# obj: bun-obj-darwin-aarch64
|
||||
# package: bun-darwin-aarch64
|
||||
# artifact: bun-obj-darwin-aarch64
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-arm64-lto.tar.gz"
|
||||
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-arm64-lto.tar.gz"
|
||||
# runner: macos-arm64
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Checkout submodules
|
||||
run: git submodule update --init --recursive --depth=1 --progress -j $(sysctl -n hw.ncpu)
|
||||
run: git submodule update --init --recursive --depth=1 --progress -j $(sysctl -n hw.ncpu) --force
|
||||
- name: Install dependencies
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
@@ -293,10 +294,10 @@ jobs:
|
||||
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
|
||||
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
|
||||
run: |
|
||||
brew install rust ccache llvm@15 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
|
||||
brew install rust ccache llvm@16 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
|
||||
echo "$(brew --prefix coreutils)/libexec/gnubin" >> $GITHUB_PATH
|
||||
echo "$(brew --prefix llvm@15)/bin" >> $GITHUB_PATH
|
||||
brew link --overwrite llvm@15
|
||||
echo "$(brew --prefix llvm@16)/bin" >> $GITHUB_PATH
|
||||
brew link --overwrite llvm@16
|
||||
- name: Download WebKit
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
@@ -398,6 +399,25 @@ jobs:
|
||||
name: "Canary (${{github.sha}})"
|
||||
tag: "canary"
|
||||
artifacts: "${{runner.temp}}/release/${{matrix.tag}}.zip,${{runner.temp}}/release/${{matrix.tag}}-profile.zip"
|
||||
- uses: sarisia/actions-status-discord@v1
|
||||
if: failure() && github.repository_owner == 'oven-sh' && github.event_name == 'pull_request'
|
||||
with:
|
||||
title: ""
|
||||
webhook: ${{ secrets.DISCORD_WEBHOOK }}
|
||||
status: ${{ job.status }}
|
||||
noprefix: true
|
||||
nocontext: true
|
||||
description: |
|
||||
Pull Request
|
||||
### [${{github.event.pull_request.title}}](https://github.com/oven-sh/bun/pull/${{github.event.number}})
|
||||
|
||||
@${{ github.actor }}
|
||||
|
||||
Build failed on ${{ matrix.tag }}:
|
||||
|
||||
**[View build output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})**
|
||||
|
||||
[Commit ${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})
|
||||
macOS-test:
|
||||
name: Tests ${{matrix.tag}}
|
||||
runs-on: ${{ matrix.runner }}
|
||||
@@ -412,7 +432,7 @@ jobs:
|
||||
matrix:
|
||||
include:
|
||||
- tag: bun-darwin-x64
|
||||
runner: macos-11
|
||||
runner: macos-12
|
||||
steps:
|
||||
- id: checkout
|
||||
name: Checkout
|
||||
@@ -425,8 +445,8 @@ jobs:
|
||||
with:
|
||||
name: ${{matrix.tag}}
|
||||
path: ${{runner.temp}}/release
|
||||
- id: install
|
||||
name: Install
|
||||
- id: install-bun
|
||||
name: Install Bun
|
||||
run: |
|
||||
cd ${{runner.temp}}/release
|
||||
unzip ${{matrix.tag}}.zip
|
||||
@@ -434,6 +454,12 @@ jobs:
|
||||
chmod +x bun
|
||||
pwd >> $GITHUB_PATH
|
||||
./bun --version
|
||||
- id: install
|
||||
name: Install dependencies
|
||||
run: |
|
||||
bun install --verbose
|
||||
bun install --cwd=test --verbose
|
||||
bun install --cwd=packages/bun-internal-test --verbose
|
||||
- id: test
|
||||
name: Test (node runner)
|
||||
env:
|
||||
@@ -442,10 +468,24 @@ jobs:
|
||||
TLS_POSTGRES_DATABASE_URL: ${{ secrets.TLS_POSTGRES_DATABASE_URL }}
|
||||
# if: ${{github.event.inputs.use_bun == 'false'}}
|
||||
run: |
|
||||
bun install
|
||||
bun install --cwd test
|
||||
bun install --cwd packages/bun-internal-test
|
||||
node packages/bun-internal-test/src/runner.node.mjs || true
|
||||
- uses: sarisia/actions-status-discord@v1
|
||||
if: always() && steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request'
|
||||
with:
|
||||
title: ""
|
||||
webhook: ${{ secrets.DISCORD_WEBHOOK }}
|
||||
status: "failure"
|
||||
noprefix: true
|
||||
nocontext: true
|
||||
description: |
|
||||
Pull Request
|
||||
### ❌ [${{github.event.pull_request.title}}](https://github.com/oven-sh/bun/pull/${{github.event.number}})
|
||||
|
||||
@${{ github.actor }}, there are ${{ steps.test.outputs.failing_tests_count }} files with test failures on ${{ matrix.tag }}:
|
||||
|
||||
${{ steps.test.outputs.failing_tests }}
|
||||
|
||||
**[View test output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})**
|
||||
- name: Comment on PR
|
||||
if: steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request'
|
||||
uses: thollander/actions-comment-pull-request@v2
|
||||
|
||||
179
.github/workflows/bun-release-canary.yml
vendored
179
.github/workflows/bun-release-canary.yml
vendored
@@ -1,179 +0,0 @@
|
||||
name: bun-release-canary
|
||||
concurrency: release-canary
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 14 * * *" # every day at 6am PST
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
sign:
|
||||
name: Sign Release
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
defaults:
|
||||
run:
|
||||
working-directory: packages/bun-release
|
||||
steps:
|
||||
- id: checkout
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- id: setup-gpg
|
||||
name: Setup GPG
|
||||
uses: crazy-max/ghaction-import-gpg@v5
|
||||
with:
|
||||
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
|
||||
passphrase: ${{ secrets.GPG_PASSPHRASE }}
|
||||
- id: setup-bun
|
||||
name: Setup Bun
|
||||
uses: oven-sh/setup-bun@v1
|
||||
with:
|
||||
bun-version: canary
|
||||
- id: bun-install
|
||||
name: Install Dependencies
|
||||
run: bun install
|
||||
- id: bun-run
|
||||
name: Sign Release
|
||||
run: |
|
||||
echo "$GPG_PASSPHRASE" | bun upload-assets -- "canary"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
|
||||
npm:
|
||||
name: Release to NPM
|
||||
runs-on: ubuntu-latest
|
||||
needs: sign
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
defaults:
|
||||
run:
|
||||
working-directory: packages/bun-release
|
||||
steps:
|
||||
- id: checkout
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- id: setup-bun
|
||||
name: Setup Bun
|
||||
uses: oven-sh/setup-bun@v1
|
||||
with:
|
||||
bun-version: canary
|
||||
- id: bun-install
|
||||
name: Install Dependencies
|
||||
run: bun install
|
||||
- id: bun-run
|
||||
name: Release
|
||||
run: bun upload-npm -- canary publish
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
# npm-types:
|
||||
# name: Release types to NPM
|
||||
# runs-on: ubuntu-latest
|
||||
# defaults:
|
||||
# run:
|
||||
# working-directory: packages/bun-types
|
||||
# steps:
|
||||
# - id: checkout
|
||||
# name: Checkout
|
||||
# uses: actions/checkout@v3
|
||||
# - id: setup-node
|
||||
# name: Setup Node.js
|
||||
# uses: actions/setup-node@v3
|
||||
# with:
|
||||
# node-version: latest
|
||||
# - id: setup-bun
|
||||
# name: Setup Bun
|
||||
# uses: oven-sh/setup-bun@v1
|
||||
# with:
|
||||
# bun-version: canary
|
||||
# - id: bun-install
|
||||
# name: Install Dependencies
|
||||
# run: bun install
|
||||
# - id: setup-env
|
||||
# name: Setup Environment
|
||||
# run: |
|
||||
# SHA=$(git rev-parse --short "$GITHUB_SHA")
|
||||
# VERSION=$(bun --version)
|
||||
# TAG="${VERSION}-canary.$(date '+%Y%m%d').1+${SHA}"
|
||||
# echo "Setup tag: ${TAG}"
|
||||
# echo "TAG=${TAG}" >> ${GITHUB_ENV}
|
||||
# - id: bun-run
|
||||
# name: Build
|
||||
# run: bun run build
|
||||
# env:
|
||||
# BUN_VERSION: ${{ env.TAG }}
|
||||
# - id: npm-publish
|
||||
# name: Release
|
||||
# uses: JS-DevTools/npm-publish@v1
|
||||
# with:
|
||||
# package: packages/bun-types/dist/package.json
|
||||
# token: ${{ secrets.NPM_TOKEN }}
|
||||
# tag: canary
|
||||
docker:
|
||||
name: Release to Dockerhub
|
||||
runs-on: ubuntu-latest
|
||||
needs: sign
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
steps:
|
||||
- id: checkout
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- id: qemu
|
||||
name: Setup Docker QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
- id: buildx
|
||||
name: Setup Docker buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
- id: metadata
|
||||
name: Setup Docker metadata
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: oven/bun
|
||||
tags: canary
|
||||
- id: login
|
||||
name: Login to Docker
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
- id: push
|
||||
name: Push to Docker
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: ./dockerhub
|
||||
file: ./dockerhub/Dockerfile-debian
|
||||
platforms: linux/amd64,linux/arm64
|
||||
builder: ${{ steps.buildx.outputs.name }}
|
||||
push: true
|
||||
tags: ${{ steps.metadata.outputs.tags }}
|
||||
labels: ${{ steps.metadata.outputs.labels }}
|
||||
build-args: |
|
||||
BUN_VERSION=canary
|
||||
s3:
|
||||
name: Upload to S3
|
||||
runs-on: ubuntu-latest
|
||||
needs: sign
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
defaults:
|
||||
run:
|
||||
working-directory: packages/bun-release
|
||||
steps:
|
||||
- id: checkout
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- id: setup-bun
|
||||
name: Setup Bun
|
||||
uses: oven-sh/setup-bun@v1
|
||||
with:
|
||||
bun-version: canary
|
||||
- id: bun-install
|
||||
name: Install Dependencies
|
||||
run: bun install
|
||||
- id: bun-run
|
||||
name: Release
|
||||
run: bun upload-s3 -- canary
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
|
||||
AWS_ENDPOINT: ${{ secrets.AWS_ENDPOINT }}
|
||||
AWS_BUCKET: bun
|
||||
236
.github/workflows/bun-release.yml
vendored
236
.github/workflows/bun-release.yml
vendored
@@ -1,52 +1,71 @@
|
||||
name: bun-release
|
||||
concurrency: release
|
||||
env:
|
||||
BUN_VERSION: ${{ github.event.inputs.tag || github.event.release.tag_name || 'canary' }}
|
||||
BUN_LATEST: ${{ github.event.inputs.is-latest || github.event.release.prerelease == 'false' }}
|
||||
on:
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
schedule:
|
||||
- cron: "0 14 * * *" # every day at 6am PST
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
is-latest:
|
||||
description: Is this the latest release?
|
||||
type: boolean
|
||||
default: false
|
||||
tag:
|
||||
type: string
|
||||
description: The tag to publish
|
||||
description: What is the release tag? (e.g. "1.0.2", "canary")
|
||||
required: true
|
||||
use-docker:
|
||||
description: Should Docker images be released?
|
||||
type: boolean
|
||||
default: false
|
||||
use-npm:
|
||||
description: Should npm packages be published?
|
||||
type: boolean
|
||||
default: false
|
||||
use-homebrew:
|
||||
description: Should binaries be released to Homebrew?
|
||||
type: boolean
|
||||
default: false
|
||||
use-s3:
|
||||
description: Should binaries be uploaded to S3?
|
||||
type: boolean
|
||||
default: false
|
||||
use-types:
|
||||
description: Should types be released to npm?
|
||||
type: boolean
|
||||
default: false
|
||||
jobs:
|
||||
sign:
|
||||
name: Sign Release
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
if: ${{ github.repository_owner == 'oven-sh' }}
|
||||
permissions:
|
||||
contents: write
|
||||
defaults:
|
||||
run:
|
||||
working-directory: packages/bun-release
|
||||
steps:
|
||||
- id: checkout
|
||||
name: Checkout
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- id: setup-env
|
||||
name: Setup Environment
|
||||
run: |
|
||||
TAG="${{ github.event.inputs.tag }}"
|
||||
TAG="${TAG:-"${{ github.event.release.tag_name }}"}"
|
||||
echo "Setup tag: ${TAG}"
|
||||
echo "TAG=${TAG}" >> ${GITHUB_ENV}
|
||||
- id: setup-gpg
|
||||
name: Setup GPG
|
||||
- name: Setup GPG
|
||||
uses: crazy-max/ghaction-import-gpg@v5
|
||||
with:
|
||||
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
|
||||
passphrase: ${{ secrets.GPG_PASSPHRASE }}
|
||||
- id: setup-bun
|
||||
name: Setup Bun
|
||||
- name: Setup Bun
|
||||
uses: oven-sh/setup-bun@v1
|
||||
with:
|
||||
bun-version: canary
|
||||
- id: bun-install
|
||||
name: Install Dependencies
|
||||
bun-version: latest
|
||||
- name: Install Dependencies
|
||||
run: bun install
|
||||
- id: bun-run
|
||||
name: Sign Release
|
||||
- name: Sign Release
|
||||
run: |
|
||||
echo "$GPG_PASSPHRASE" | bun upload-assets -- "${{ env.TAG }}"
|
||||
echo "$GPG_PASSPHRASE" | bun upload-assets -- "${{ env.BUN_VERSION }}"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
|
||||
@@ -54,32 +73,23 @@ jobs:
|
||||
name: Release to NPM
|
||||
runs-on: ubuntu-latest
|
||||
needs: sign
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.use-npm == 'true' }}
|
||||
permissions:
|
||||
contents: read
|
||||
defaults:
|
||||
run:
|
||||
working-directory: packages/bun-release
|
||||
steps:
|
||||
- id: checkout
|
||||
name: Checkout
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- id: setup-env
|
||||
name: Setup Environment
|
||||
run: |
|
||||
TAG="${{ github.event.inputs.tag }}"
|
||||
TAG="${TAG:-"${{ github.event.release.tag_name }}"}"
|
||||
echo "Setup tag: ${TAG}"
|
||||
echo "TAG=${TAG}" >> ${GITHUB_ENV}
|
||||
- id: setup-bun
|
||||
name: Setup Bun
|
||||
- name: Setup Bun
|
||||
uses: oven-sh/setup-bun@v1
|
||||
with:
|
||||
bun-version: canary
|
||||
- id: bun-install
|
||||
name: Install Dependencies
|
||||
bun-version: latest
|
||||
- name: Install Dependencies
|
||||
run: bun install
|
||||
- id: bun-run
|
||||
name: Release
|
||||
run: bun upload-npm -- "${{ env.TAG }}" publish
|
||||
- name: Release
|
||||
run: bun upload-npm -- "${{ env.BUN_VERSION }}" publish
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
@@ -87,41 +97,37 @@ jobs:
|
||||
name: Release types to NPM
|
||||
runs-on: ubuntu-latest
|
||||
needs: sign
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.use-types == 'true' }}
|
||||
permissions:
|
||||
contents: read
|
||||
defaults:
|
||||
run:
|
||||
working-directory: packages/bun-types
|
||||
steps:
|
||||
- id: checkout
|
||||
name: Checkout
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- id: setup-env
|
||||
name: Setup Environment
|
||||
run: |
|
||||
TAG="${{ github.event.inputs.tag }}"
|
||||
TAG="${TAG:-"${{ github.event.release.tag_name }}"}"
|
||||
echo "Setup tag: ${TAG}"
|
||||
echo "TAG=${TAG}" >> ${GITHUB_ENV}
|
||||
- id: setup-node
|
||||
name: Setup Node.js
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: latest
|
||||
- id: setup-bun
|
||||
name: Setup Bun
|
||||
- name: Setup Bun
|
||||
uses: oven-sh/setup-bun@v1
|
||||
with:
|
||||
bun-version: canary
|
||||
- id: bun-install
|
||||
name: Install Dependencies
|
||||
- name: Install Dependencies
|
||||
run: bun install
|
||||
- id: bun-run
|
||||
name: Build
|
||||
- name: Setup Tag
|
||||
if: ${{ env.BUN_VERSION == 'canary' }}
|
||||
run: |
|
||||
VERSION=$(bun --version)
|
||||
TAG="${VERSION}-canary.$(date +'%Y%m%dT%H%M%S')"
|
||||
echo "Setup tag: ${TAG}"
|
||||
echo "TAG=${TAG}" >> ${GITHUB_ENV}
|
||||
- name: Build
|
||||
run: bun run build
|
||||
env:
|
||||
BUN_VERSION: ${{ env.TAG }}
|
||||
- id: npm-publish
|
||||
name: Release
|
||||
BUN_VERSION: ${{ env.TAG || env.BUN_VERSION }}
|
||||
- name: Release
|
||||
uses: JS-DevTools/npm-publish@v1
|
||||
with:
|
||||
package: packages/bun-types/dist/package.json
|
||||
@@ -130,20 +136,28 @@ jobs:
|
||||
name: Release to Dockerhub
|
||||
runs-on: ubuntu-latest
|
||||
needs: sign
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.use-docker == 'true' }}
|
||||
permissions:
|
||||
contents: read
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- variant: debian
|
||||
suffix: ''
|
||||
- variant: debian
|
||||
suffix: -debian
|
||||
- variant: slim
|
||||
suffix: -slim
|
||||
dir: debian-slim
|
||||
- variant: alpine
|
||||
suffix: -alpine
|
||||
- variant: distroless
|
||||
suffix: -distroless
|
||||
steps:
|
||||
- id: checkout
|
||||
name: Checkout
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- id: environment
|
||||
name: Setup Environment
|
||||
run: |
|
||||
TAG="${{ github.event.inputs.tag }}"
|
||||
TAG="${TAG:-"${{ github.event.release.tag_name }}"}"
|
||||
echo "Setup tag: ${TAG}"
|
||||
echo "TAG=${TAG}" >> ${GITHUB_ENV}
|
||||
- id: qemu
|
||||
name: Setup Docker QEMU
|
||||
- name: Setup Docker emulator
|
||||
uses: docker/setup-qemu-action@v2
|
||||
- id: buildx
|
||||
name: Setup Docker buildx
|
||||
@@ -155,67 +169,60 @@ jobs:
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: oven/bun
|
||||
flavor: |
|
||||
latest=false
|
||||
tags: |
|
||||
type=match,pattern=(bun-v)?(\d+.\d+.\d+),group=2,value=${{ env.TAG }}
|
||||
type=match,pattern=(bun-v)?(\d+.\d+),group=2,value=${{ env.TAG }}
|
||||
- id: login
|
||||
name: Login to Docker
|
||||
type=raw,value=latest,enable=${{ env.BUN_LATEST == 'true' && matrix.suffix == '' }}
|
||||
type=raw,value=${{ matrix.variant }},enable=${{ env.BUN_LATEST == 'true' }}
|
||||
type=match,pattern=(bun-v)?(canary|\d+.\d+.\d+),group=2,value=${{ env.BUN_VERSION }},suffix=${{ matrix.suffix }}
|
||||
type=match,pattern=(bun-v)?(canary|\d+.\d+),group=2,value=${{ env.BUN_VERSION }},suffix=${{ matrix.suffix }}
|
||||
type=match,pattern=(bun-v)?(canary|\d+),group=2,value=${{ env.BUN_VERSION }},suffix=${{ matrix.suffix }}
|
||||
- name: Login to Docker
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
- id: push
|
||||
name: Push to Docker
|
||||
- name: Push to Docker
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: ./dockerhub
|
||||
file: ./dockerhub/Dockerfile-debian
|
||||
context: ./dockerhub/${{ matrix.dir || matrix.variant }}
|
||||
platforms: linux/amd64,linux/arm64
|
||||
builder: ${{ steps.buildx.outputs.name }}
|
||||
push: true
|
||||
tags: ${{ steps.metadata.outputs.tags }}
|
||||
labels: ${{ steps.metadata.outputs.labels }}
|
||||
build-args: |
|
||||
BUN_VERSION=${{ env.TAG }}
|
||||
BUN_VERSION=${{ env.BUN_VERSION }}
|
||||
homebrew:
|
||||
name: Release to Homebrew
|
||||
runs-on: ubuntu-latest
|
||||
needs: sign
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
permissions:
|
||||
contents: read
|
||||
if: ${{ github.event_name == 'release' || github.event.inputs.use-homebrew == 'true' }}
|
||||
steps:
|
||||
- id: checkout
|
||||
name: Checkout
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: oven-sh/homebrew-bun
|
||||
token: ${{ secrets.ROBOBUN_TOKEN }}
|
||||
- id: setup-gpg
|
||||
- id: gpg
|
||||
name: Setup GPG
|
||||
uses: crazy-max/ghaction-import-gpg@v5
|
||||
with:
|
||||
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
|
||||
passphrase: ${{ secrets.GPG_PASSPHRASE }}
|
||||
- id: setup-env
|
||||
name: Setup Environment
|
||||
run: |
|
||||
TAG="${{ github.event.inputs.tag }}"
|
||||
TAG="${TAG:-"${{ github.event.release.tag_name }}"}"
|
||||
echo "Setup tag: ${TAG}"
|
||||
echo "TAG=${TAG}" >> ${GITHUB_ENV}
|
||||
- id: setup-ruby
|
||||
name: Setup Ruby
|
||||
- name: Setup Ruby
|
||||
uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: "2.6"
|
||||
- id: update-tap
|
||||
name: Update Tap
|
||||
run: ruby scripts/release.rb "${{ env.TAG }}"
|
||||
- id: commit-tap
|
||||
name: Commit Tap
|
||||
- name: Update Tap
|
||||
run: ruby scripts/release.rb "${{ env.BUN_VERSION }}"
|
||||
- name: Commit Tap
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
commit_options: --gpg-sign=${{ steps.setup-gpg.outputs.keyid }}
|
||||
commit_message: Release ${{ env.TAG }}
|
||||
commit_options: --gpg-sign=${{ steps.gpg.outputs.keyid }}
|
||||
commit_message: Release ${{ env.BUN_VERSION }}
|
||||
commit_user_name: robobun
|
||||
commit_user_email: robobun@oven.sh
|
||||
commit_author: robobun <robobun@oven.sh>
|
||||
@@ -223,32 +230,23 @@ jobs:
|
||||
name: Upload to S3
|
||||
runs-on: ubuntu-latest
|
||||
needs: sign
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.use-s3 == 'true' }}
|
||||
permissions:
|
||||
contents: read
|
||||
defaults:
|
||||
run:
|
||||
working-directory: packages/bun-release
|
||||
steps:
|
||||
- id: checkout
|
||||
name: Checkout
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- id: setup-env
|
||||
name: Setup Environment
|
||||
run: |
|
||||
TAG="${{ github.event.inputs.tag }}"
|
||||
TAG="${TAG:-"${{ github.event.release.tag_name }}"}"
|
||||
echo "Setup tag: ${TAG}"
|
||||
echo "TAG=${TAG}" >> ${GITHUB_ENV}
|
||||
- id: setup-bun
|
||||
name: Setup Bun
|
||||
- name: Setup Bun
|
||||
uses: oven-sh/setup-bun@v1
|
||||
with:
|
||||
bun-version: canary
|
||||
- id: bun-install
|
||||
name: Install Dependencies
|
||||
bun-version: latest
|
||||
- name: Install Dependencies
|
||||
run: bun install
|
||||
- id: bun-run
|
||||
name: Release
|
||||
run: bun upload-s3 -- "${{ env.TAG }}"
|
||||
- name: Release
|
||||
run: bun upload-s3 -- "${{ env.BUN_VERSION }}"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -6,6 +6,7 @@ packages/*/*.wasm
|
||||
profile.json
|
||||
|
||||
node_modules
|
||||
.envrc
|
||||
.swcrc
|
||||
yarn.lock
|
||||
dist
|
||||
@@ -123,6 +124,7 @@ cold-jsc-start
|
||||
cold-jsc-start.d
|
||||
|
||||
/test.ts
|
||||
/test.js
|
||||
|
||||
src/js/out/modules*
|
||||
src/js/out/functions*
|
||||
@@ -132,4 +134,4 @@ src/js/out/DebugPath.h
|
||||
make-dev-stats.csv
|
||||
|
||||
.uuid
|
||||
tsconfig.tsbuildinfo
|
||||
tsconfig.tsbuildinfo
|
||||
|
||||
@@ -10,4 +10,4 @@ fi
|
||||
|
||||
# sets up vscode C++ intellisense
|
||||
rm -f .vscode/clang++
|
||||
ln -s $(which clang++-15 || which clang++) .vscode/clang++ 2>/dev/null
|
||||
ln -s $(which clang++-16 || which clang++) .vscode/clang++ 2>/dev/null
|
||||
|
||||
39
Dockerfile
39
Dockerfile
@@ -10,7 +10,7 @@ ARG ARCH=x86_64
|
||||
ARG BUILD_MACHINE_ARCH=x86_64
|
||||
ARG TRIPLET=${ARCH}-linux-gnu
|
||||
ARG BUILDARCH=amd64
|
||||
ARG WEBKIT_TAG=2023-aug3-5
|
||||
ARG WEBKIT_TAG=2023-sept15
|
||||
ARG ZIG_TAG=jul1
|
||||
ARG ZIG_VERSION="0.12.0-dev.163+6780a6bbf"
|
||||
ARG WEBKIT_BASENAME="bun-webkit-linux-$BUILDARCH"
|
||||
@@ -20,19 +20,17 @@ ARG ZIG_FILENAME=${ZIG_FOLDERNAME}.tar.xz
|
||||
ARG WEBKIT_URL="https://github.com/oven-sh/WebKit/releases/download/$WEBKIT_TAG/${WEBKIT_BASENAME}.tar.gz"
|
||||
ARG ZIG_URL="https://ziglang.org/builds/${ZIG_FILENAME}"
|
||||
ARG GIT_SHA=""
|
||||
ARG BUN_BASE_VERSION=0.8
|
||||
ARG BUN_BASE_VERSION=1.0
|
||||
|
||||
FROM bitnami/minideb:bullseye as bun-base
|
||||
|
||||
RUN install_packages ca-certificates curl wget lsb-release software-properties-common gnupg gnupg1 gnupg2
|
||||
|
||||
RUN wget https://apt.llvm.org/llvm.sh && \
|
||||
chmod +x llvm.sh && \
|
||||
./llvm.sh 15
|
||||
|
||||
RUN install_packages \
|
||||
RUN install_packages ca-certificates curl wget lsb-release software-properties-common gnupg gnupg1 gnupg2 && \
|
||||
echo "deb https://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-16 main" > /etc/apt/sources.list.d/llvm.list && \
|
||||
echo "deb-src https://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-16 main" >> /etc/apt/sources.list.d/llvm.list && \
|
||||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \
|
||||
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \
|
||||
install_packages \
|
||||
cmake \
|
||||
curl \
|
||||
file \
|
||||
git \
|
||||
gnupg \
|
||||
@@ -46,16 +44,16 @@ RUN install_packages \
|
||||
rsync \
|
||||
ruby \
|
||||
unzip \
|
||||
clang-16 \
|
||||
lld-16 \
|
||||
lldb-16 \
|
||||
clangd-16 \
|
||||
xz-utils \
|
||||
bash tar gzip ccache
|
||||
|
||||
ENV CXX=clang++-15
|
||||
ENV CC=clang-15
|
||||
|
||||
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \
|
||||
install_packages nodejs && \
|
||||
bash tar gzip ccache nodejs && \
|
||||
npm install -g esbuild
|
||||
|
||||
ENV CXX=clang++-16
|
||||
ENV CC=clang-16
|
||||
|
||||
ARG DEBIAN_FRONTEND
|
||||
ARG GITHUB_WORKSPACE
|
||||
@@ -72,10 +70,10 @@ ARG ZIG_FILENAME
|
||||
|
||||
ENV WEBKIT_OUT_DIR=${WEBKIT_DIR}
|
||||
ENV BUILDARCH=${BUILDARCH}
|
||||
ENV AR=/usr/bin/llvm-ar-15
|
||||
ENV AR=/usr/bin/llvm-ar-16
|
||||
ENV ZIG "${ZIG_PATH}/zig"
|
||||
ENV PATH="$ZIG/bin:$PATH"
|
||||
ENV LD=lld-15
|
||||
ENV LD=lld-16
|
||||
|
||||
RUN mkdir -p $BUN_DIR $BUN_DEPS_OUT_DIR
|
||||
|
||||
@@ -157,7 +155,7 @@ COPY src/deps/lol-html ${BUN_DIR}/src/deps/lol-html
|
||||
|
||||
ENV CCACHE_DIR=/ccache
|
||||
|
||||
RUN --mount=type=cache,target=/ccache export PATH=$PATH:$HOME/.cargo/bin && export CC=$(which clang-15) && cd ${BUN_DIR} && \
|
||||
RUN --mount=type=cache,target=/ccache export PATH=$PATH:$HOME/.cargo/bin && export CC=$(which clang-16) && cd ${BUN_DIR} && \
|
||||
make lolhtml && rm -rf src/deps/lol-html Makefile
|
||||
|
||||
FROM bun-base as mimalloc
|
||||
@@ -288,6 +286,7 @@ COPY packages/bun-uws ${BUN_DIR}/packages/bun-uws
|
||||
COPY packages/bun-usockets ${BUN_DIR}/packages/bun-usockets
|
||||
COPY src/deps/zlib ${BUN_DIR}/src/deps/zlib
|
||||
COPY src/deps/boringssl/include ${BUN_DIR}/src/deps/boringssl/include
|
||||
COPY src/deps/c-ares/include ${BUN_DIR}/src/deps/c-ares/include
|
||||
COPY src/deps/libuwsockets.cpp ${BUN_DIR}/src/deps/libuwsockets.cpp
|
||||
COPY src/deps/_libusockets.h ${BUN_DIR}/src/deps/_libusockets.h
|
||||
|
||||
|
||||
75
Makefile
75
Makefile
@@ -38,7 +38,7 @@ NATIVE_OR_OLD_MARCH = -march=nehalem
|
||||
endif
|
||||
|
||||
MIN_MACOS_VERSION ?= $(DEFAULT_MIN_MACOS_VERSION)
|
||||
BUN_BASE_VERSION = 0.8
|
||||
BUN_BASE_VERSION = 1.0
|
||||
|
||||
CI ?= false
|
||||
|
||||
@@ -82,9 +82,9 @@ ZIG ?= $(shell which zig 2>/dev/null || echo -e "error: Missing zig. Please make
|
||||
# This is easier to happen than you'd expect.
|
||||
# Using realpath here causes issues because clang uses clang++ as a symlink
|
||||
# so if that's resolved, it won't build for C++
|
||||
REAL_CC = $(shell which clang-15 2>/dev/null || which clang 2>/dev/null)
|
||||
REAL_CXX = $(shell which clang++-15 2>/dev/null || which clang++ 2>/dev/null)
|
||||
CLANG_FORMAT = $(shell which clang-format-15 2>/dev/null || which clang-format 2>/dev/null)
|
||||
REAL_CC = $(shell which clang-16 2>/dev/null || which clang 2>/dev/null)
|
||||
REAL_CXX = $(shell which clang++-16 2>/dev/null || which clang++ 2>/dev/null)
|
||||
CLANG_FORMAT = $(shell which clang-format-16 2>/dev/null || which clang-format 2>/dev/null)
|
||||
|
||||
CC = $(REAL_CC)
|
||||
CXX = $(REAL_CXX)
|
||||
@@ -108,14 +108,14 @@ CC_WITH_CCACHE = $(CCACHE_PATH) $(CC)
|
||||
ifeq ($(OS_NAME),darwin)
|
||||
# Find LLVM
|
||||
ifeq ($(wildcard $(LLVM_PREFIX)),)
|
||||
LLVM_PREFIX = $(shell brew --prefix llvm@15)
|
||||
LLVM_PREFIX = $(shell brew --prefix llvm@16)
|
||||
endif
|
||||
ifeq ($(wildcard $(LLVM_PREFIX)),)
|
||||
LLVM_PREFIX = $(shell brew --prefix llvm)
|
||||
endif
|
||||
ifeq ($(wildcard $(LLVM_PREFIX)),)
|
||||
# This is kinda ugly, but I can't find a better way to error :(
|
||||
LLVM_PREFIX = $(shell echo -e "error: Unable to find llvm. Please run 'brew install llvm@15' or set LLVM_PREFIX=/path/to/llvm")
|
||||
LLVM_PREFIX = $(shell echo -e "error: Unable to find llvm. Please run 'brew install llvm@16' or set LLVM_PREFIX=/path/to/llvm")
|
||||
endif
|
||||
|
||||
LDFLAGS += -L$(LLVM_PREFIX)/lib
|
||||
@@ -155,7 +155,7 @@ CMAKE_FLAGS_WITHOUT_RELEASE = -DCMAKE_C_COMPILER=$(CC) \
|
||||
-DCMAKE_OSX_DEPLOYMENT_TARGET=$(MIN_MACOS_VERSION) \
|
||||
$(CMAKE_CXX_COMPILER_LAUNCHER_FLAG) \
|
||||
-DCMAKE_AR=$(AR) \
|
||||
-DCMAKE_RANLIB=$(which llvm-15-ranlib 2>/dev/null || which llvm-ranlib 2>/dev/null)
|
||||
-DCMAKE_RANLIB=$(which llvm-16-ranlib 2>/dev/null || which llvm-ranlib 2>/dev/null)
|
||||
|
||||
|
||||
|
||||
@@ -177,7 +177,7 @@ endif
|
||||
|
||||
ifeq ($(OS_NAME),linux)
|
||||
LIBICONV_PATH =
|
||||
AR = $(shell which llvm-ar-15 2>/dev/null || which llvm-ar 2>/dev/null || which ar 2>/dev/null)
|
||||
AR = $(shell which llvm-ar-16 2>/dev/null || which llvm-ar 2>/dev/null || which ar 2>/dev/null)
|
||||
endif
|
||||
|
||||
OPTIMIZATION_LEVEL=-O3 $(MARCH_NATIVE)
|
||||
@@ -274,7 +274,7 @@ STRIP=/usr/bin/strip
|
||||
endif
|
||||
|
||||
ifeq ($(OS_NAME),linux)
|
||||
STRIP=$(shell which llvm-strip 2>/dev/null || which llvm-strip-15 2>/dev/null || which strip 2>/dev/null || echo "Missing strip")
|
||||
STRIP=$(shell which llvm-strip 2>/dev/null || which llvm-strip-16 2>/dev/null || which strip 2>/dev/null || echo "Missing strip")
|
||||
endif
|
||||
|
||||
|
||||
@@ -550,7 +550,7 @@ tinycc:
|
||||
cd $(TINYCC_DIR) && \
|
||||
make clean && \
|
||||
AR=$(AR) $(CCACHE_CC_FLAG) CFLAGS='$(CFLAGS_WITHOUT_MARCH) $(NATIVE_OR_OLD_MARCH) -mtune=native $(TINYCC_CFLAGS)' ./configure --enable-static --cc=$(CCACHE_CC_OR_CC) --ar=$(AR) --config-predefs=yes && \
|
||||
make -j10 && \
|
||||
make libtcc.a -j10 && \
|
||||
cp $(TINYCC_DIR)/*.a $(BUN_DEPS_OUT_DIR)
|
||||
|
||||
PYTHON=$(shell which python 2>/dev/null || which python3 2>/dev/null || which python2 2>/dev/null)
|
||||
@@ -664,7 +664,7 @@ endif
|
||||
.PHONY: assert-deps
|
||||
assert-deps:
|
||||
@echo "Checking if the required utilities are available..."
|
||||
@if [ $(CLANG_VERSION) -lt "15" ]; then echo -e "ERROR: clang version >=15 required, found: $(CLANG_VERSION). Install with:\n\n $(POSIX_PKG_MANAGER) install llvm@15"; exit 1; fi
|
||||
@if [ $(CLANG_VERSION) -lt "15" ]; then echo -e "ERROR: clang version >=15 required, found: $(CLANG_VERSION). Install with:\n\n $(POSIX_PKG_MANAGER) install llvm@16"; exit 1; fi
|
||||
@cmake --version >/dev/null 2>&1 || (echo -e "ERROR: cmake is required."; exit 1)
|
||||
@$(PYTHON) --version >/dev/null 2>&1 || (echo -e "ERROR: python is required."; exit 1)
|
||||
@$(ESBUILD) --version >/dev/null 2>&1 || (echo -e "ERROR: esbuild is required."; exit 1)
|
||||
@@ -811,7 +811,7 @@ fmt-cpp:
|
||||
|
||||
.PHONY: fmt-zig
|
||||
fmt-zig:
|
||||
cd src && zig fmt **/*.zig
|
||||
cd src && $(ZIG) fmt **/*.zig
|
||||
|
||||
.PHONY: fmt
|
||||
fmt: fmt-cpp fmt-zig
|
||||
@@ -945,7 +945,7 @@ headers:
|
||||
$(ZIG) translate-c src/bun.js/bindings/headers.h > src/bun.js/bindings/headers.zig
|
||||
$(BUN_OR_NODE) misctools/headers-cleaner.js
|
||||
$(ZIG) fmt src/bun.js/bindings/headers.zig
|
||||
$(CLANG_FORMAT) -i src/bun.js/bindings/ZigGeneratedCode.cpp
|
||||
$(CLANG_FORMAT) -i src/bun.js/bindings/ZigGeneratedCode.cpp
|
||||
|
||||
.PHONY: jsc-bindings-headers
|
||||
jsc-bindings-headers: headers
|
||||
@@ -1291,7 +1291,7 @@ jsc-build-linux-compile-config:
|
||||
jsc-build-linux-compile-build:
|
||||
mkdir -p $(WEBKIT_RELEASE_DIR) && \
|
||||
cd $(WEBKIT_RELEASE_DIR) && \
|
||||
CFLAGS="$(CFLAGS) -Wl,--whole-archive -ffat-lto-objects" CXXFLAGS="$(CXXFLAGS) -Wl,--whole-archive -ffat-lto-objects" -DUSE_BUN_JSC_ADDITIONS=ON \
|
||||
CFLAGS="$(CFLAGS) -Wl,--whole-archive -ffat-lto-objects" CXXFLAGS="$(CXXFLAGS) -Wl,--whole-archive -ffat-lto-objects -DUSE_BUN_JSC_ADDITIONS=ON" \
|
||||
cmake --build $(WEBKIT_RELEASE_DIR) --config relwithdebuginfo --target jsc
|
||||
|
||||
|
||||
@@ -1482,7 +1482,7 @@ bun-relink: bun-relink-copy bun-link-lld-release bun-link-lld-release-dsym
|
||||
bun-relink-fast: bun-relink-copy bun-link-lld-release-no-lto
|
||||
|
||||
wasm-return1:
|
||||
zig build-lib -OReleaseSmall test/bun.js/wasm-return-1-test.zig -femit-bin=test/bun.js/wasm-return-1-test.wasm -target wasm32-freestanding
|
||||
$(ZIG) build-lib -OReleaseSmall test/bun.js/wasm-return-1-test.zig -femit-bin=test/bun.js/wasm-return-1-test.wasm -target wasm32-freestanding
|
||||
|
||||
generate-classes:
|
||||
bun src/bun.js/scripts/generate-classes.ts
|
||||
@@ -1518,7 +1518,7 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
|
||||
${MMD_IF_LOCAL} \
|
||||
-fno-exceptions \
|
||||
-fno-rtti \
|
||||
-ferror-limit=1000 \
|
||||
-ferror-limit=10 \
|
||||
$(EMIT_LLVM) \
|
||||
-c -o $@ $<
|
||||
|
||||
@@ -1529,7 +1529,7 @@ $(OBJ_DIR)/%.o: src/bun.js/modules/%.cpp
|
||||
${MMD_IF_LOCAL} \
|
||||
-fno-exceptions \
|
||||
-fno-rtti \
|
||||
-ferror-limit=1000 \
|
||||
-ferror-limit=10 \
|
||||
$(EMIT_LLVM) \
|
||||
-c -o $@ $<
|
||||
|
||||
@@ -1540,7 +1540,7 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/webcore/%.cpp
|
||||
${MMD_IF_LOCAL} \
|
||||
-fno-exceptions \
|
||||
-fno-rtti \
|
||||
-ferror-limit=1000 \
|
||||
-ferror-limit=10 \
|
||||
$(EMIT_LLVM) \
|
||||
-c -o $@ $<
|
||||
|
||||
@@ -1551,7 +1551,7 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/sqlite/%.cpp
|
||||
${MMD_IF_LOCAL} \
|
||||
-fno-exceptions \
|
||||
-fno-rtti \
|
||||
-ferror-limit=1000 \
|
||||
-ferror-limit=10 \
|
||||
$(EMIT_LLVM) \
|
||||
-c -o $@ $<
|
||||
|
||||
@@ -1562,7 +1562,7 @@ $(OBJ_DIR)/%.o: src/io/%.cpp
|
||||
${MMD_IF_LOCAL} \
|
||||
-fno-exceptions \
|
||||
-fno-rtti \
|
||||
-ferror-limit=1000 \
|
||||
-ferror-limit=10 \
|
||||
$(EMIT_LLVM) \
|
||||
-c -o $@ $<
|
||||
|
||||
@@ -1573,7 +1573,7 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/node_os/%.cpp
|
||||
${MMD_IF_LOCAL} \
|
||||
-fno-exceptions \
|
||||
-fno-rtti \
|
||||
-ferror-limit=1000 \
|
||||
-ferror-limit=10 \
|
||||
$(EMIT_LLVM) \
|
||||
-c -o $@ $<
|
||||
|
||||
@@ -1584,7 +1584,7 @@ $(OBJ_DIR)/%.o: src/js/out/%.cpp
|
||||
${MMD_IF_LOCAL} \
|
||||
-fno-exceptions \
|
||||
-fno-rtti \
|
||||
-ferror-limit=1000 \
|
||||
-ferror-limit=10 \
|
||||
$(EMIT_LLVM) \
|
||||
-c -o $@ $<
|
||||
|
||||
@@ -1596,7 +1596,7 @@ $(OBJ_DIR)/%.o: src/bun.js/bindings/webcrypto/%.cpp
|
||||
${MMD_IF_LOCAL} \
|
||||
-fno-exceptions \
|
||||
-fno-rtti \
|
||||
-ferror-limit=1000 \
|
||||
-ferror-limit=10 \
|
||||
$(EMIT_LLVM) \
|
||||
-c -o $@ $<
|
||||
|
||||
@@ -1610,7 +1610,7 @@ $(DEBUG_OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
|
||||
${MMD_IF_LOCAL} \
|
||||
-fno-exceptions \
|
||||
-fno-rtti \
|
||||
-ferror-limit=1000 \
|
||||
-ferror-limit=10 \
|
||||
-DBUN_DEBUG \
|
||||
$(EMIT_LLVM_FOR_DEBUG) \
|
||||
-g3 -c -o $@ $<
|
||||
@@ -1625,7 +1625,7 @@ $(DEBUG_OBJ_DIR)/%.o: $(SRC_DIR)/webcore/%.cpp
|
||||
${MMD_IF_LOCAL} \
|
||||
-fno-exceptions \
|
||||
-fno-rtti \
|
||||
-ferror-limit=1000 \
|
||||
-ferror-limit=10 \
|
||||
$(EMIT_LLVM_FOR_DEBUG) \
|
||||
-DBUN_DEBUG \
|
||||
-g3 -c -o $@ $<
|
||||
@@ -1638,7 +1638,7 @@ $(DEBUG_OBJ_DIR)/%.o: src/io/%.cpp
|
||||
${MMD_IF_LOCAL} \
|
||||
-fno-exceptions \
|
||||
-fno-rtti \
|
||||
-ferror-limit=1000 \
|
||||
-ferror-limit=10 \
|
||||
-DBUN_DEBUG \
|
||||
$(EMIT_LLVM_FOR_DEBUG) \
|
||||
-g3 -c -o $@ $<
|
||||
@@ -1654,7 +1654,7 @@ $(DEBUG_OBJ_DIR)/%.o: $(SRC_DIR)/sqlite/%.cpp
|
||||
${MMD_IF_LOCAL} \
|
||||
-fno-exceptions \
|
||||
-fno-rtti \
|
||||
-ferror-limit=1000 \
|
||||
-ferror-limit=10 \
|
||||
$(EMIT_LLVM_FOR_DEBUG) \
|
||||
-DBUN_DEBUG \
|
||||
-g3 -c -o $@ $<
|
||||
@@ -1669,7 +1669,7 @@ $(DEBUG_OBJ_DIR)/%.o: $(SRC_DIR)/node_os/%.cpp
|
||||
${MMD_IF_LOCAL} \
|
||||
-fno-exceptions \
|
||||
-fno-rtti \
|
||||
-ferror-limit=1000 \
|
||||
-ferror-limit=10 \
|
||||
$(EMIT_LLVM_FOR_DEBUG) \
|
||||
-DBUN_DEBUG \
|
||||
-g3 -c -o $@ $<
|
||||
@@ -1684,7 +1684,7 @@ $(DEBUG_OBJ_DIR)/%.o: src/js/out/%.cpp
|
||||
${MMD_IF_LOCAL} \
|
||||
-fno-exceptions \
|
||||
-fno-rtti \
|
||||
-ferror-limit=1000 \
|
||||
-ferror-limit=10 \
|
||||
$(EMIT_LLVM_FOR_DEBUG) \
|
||||
-DBUN_DEBUG \
|
||||
-g3 -c -o $@ $<
|
||||
@@ -1697,7 +1697,7 @@ $(DEBUG_OBJ_DIR)/%.o: src/bun.js/modules/%.cpp
|
||||
${MMD_IF_LOCAL} \
|
||||
-fno-exceptions \
|
||||
-fno-rtti \
|
||||
-ferror-limit=1000 \
|
||||
-ferror-limit=10 \
|
||||
$(EMIT_LLVM_FOR_DEBUG) \
|
||||
-DBUN_DEBUG \
|
||||
-g3 -c -o $@ $<
|
||||
@@ -1712,7 +1712,7 @@ $(DEBUG_OBJ_DIR)/%.o: src/bun.js/bindings/webcrypto/%.cpp
|
||||
-fno-exceptions \
|
||||
-I$(SRC_DIR) \
|
||||
-fno-rtti \
|
||||
-ferror-limit=1000 \
|
||||
-ferror-limit=10 \
|
||||
$(EMIT_LLVM_FOR_DEBUG) \
|
||||
-DBUN_DEBUG \
|
||||
-g3 -c -o $@ $<
|
||||
@@ -1825,7 +1825,7 @@ endif
|
||||
build-unit: # to build your unit tests
|
||||
@rm -rf zig-out/bin/$(testname)
|
||||
@mkdir -p zig-out/bin
|
||||
zig test $(realpath $(testpath)) \
|
||||
$(ZIG) test $(realpath $(testpath)) \
|
||||
$(testfilterflag) \
|
||||
$(PACKAGE_MAP) \
|
||||
--main-pkg-path $(BUN_DIR) \
|
||||
@@ -1843,7 +1843,7 @@ build-unit: # to build your unit tests
|
||||
run-all-unit-tests: # to run your unit tests
|
||||
@rm -rf zig-out/bin/__main_test
|
||||
@mkdir -p zig-out/bin
|
||||
zig test src/main.zig \
|
||||
$(ZIG) test src/main.zig \
|
||||
$(PACKAGE_MAP) \
|
||||
--main-pkg-path $(BUN_DIR) \
|
||||
--test-no-exec \
|
||||
@@ -1880,7 +1880,7 @@ PACKAGE_MAP = --pkg-begin async_io $(BUN_DIR)/src/io/io_darwin.zig --pkg-begin b
|
||||
|
||||
.PHONY: base64
|
||||
base64:
|
||||
cd $(BUN_DEPS_DIR)/base64 && make clean && cmake $(CMAKE_FLAGS) . && make
|
||||
cd $(BUN_DEPS_DIR)/base64 && make clean && rm -rf CMakeCache.txt CMakeFiles && cmake $(CMAKE_FLAGS) . && make
|
||||
cp $(BUN_DEPS_DIR)/base64/libbase64.a $(BUN_DEPS_OUT_DIR)/libbase64.a
|
||||
|
||||
.PHONY: cold-jsc-start
|
||||
@@ -1891,7 +1891,7 @@ cold-jsc-start:
|
||||
${MMD_IF_LOCAL} \
|
||||
-fno-exceptions \
|
||||
-fno-rtti \
|
||||
-ferror-limit=1000 \
|
||||
-ferror-limit=10 \
|
||||
$(LIBICONV_PATH) \
|
||||
$(DEFAULT_LINKER_FLAGS) \
|
||||
$(PLATFORM_LINKER_FLAGS) \
|
||||
@@ -1915,9 +1915,14 @@ vendor-dev: assert-deps submodule npm-install-dev vendor-without-npm
|
||||
.PHONY: bun
|
||||
bun: vendor identifier-cache build-obj bun-link-lld-release bun-codesign-release-local
|
||||
|
||||
.PHONY: static-hash-table
|
||||
static-hash-table:
|
||||
bun src/js/_codegen/static-hash-tables.ts
|
||||
|
||||
.PHONY: cpp
|
||||
cpp: ## compile src/js/builtins + all c++ code then link
|
||||
@make clean-bindings js
|
||||
@make static-hash-table
|
||||
@make bindings -j$(CPU_COUNT)
|
||||
@make link
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
## What is Bun?
|
||||
|
||||
> **Bun is still under development.** Use it to speed up your development workflows or run simpler production code in resource-constrained environments like serverless functions. We're working on more complete Node.js compatibility and integration with existing frameworks. Join the [Discord](https://bun.sh/discord) and watch the [GitHub repository](https://github.com/oven-sh/bun) to keep tabs on future releases.
|
||||
> **Bun is under active development.** Use it to speed up your development workflows or run simpler production code in resource-constrained environments like serverless functions. We're working on more complete Node.js compatibility and integration with existing frameworks. Join the [Discord](https://bun.sh/discord) and watch the [GitHub repository](https://github.com/oven-sh/bun) to keep tabs on future releases.
|
||||
|
||||
Bun is an all-in-one toolkit for JavaScript and TypeScript apps. It ships as a single executable called `bun`.
|
||||
|
||||
@@ -93,7 +93,8 @@ bun upgrade --canary
|
||||
- [`bun run`](https://bun.sh/docs/cli/run)
|
||||
- [`bun install`](https://bun.sh/docs/cli/install)
|
||||
- [`bun test`](https://bun.sh/docs/cli/test)
|
||||
- [`bun create`](https://bun.sh/docs/cli/create)
|
||||
- [`bun init`](https://bun.sh/docs/templates#bun-init)
|
||||
- [`bun create`](https://bun.sh/docs/templates#bun-create)
|
||||
- [`bunx`](https://bun.sh/docs/cli/bunx)
|
||||
- Runtime
|
||||
- [Runtime](https://bun.sh/docs/runtime/index)
|
||||
|
||||
12
SECURITY.md
Normal file
12
SECURITY.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| 1.x.x | :white_check_mark: |
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
Report any discovered vulnerabilities to the Bun team by emailing `security@bun.sh`. Your report will acknowledged within 5 days, and a team member will be assigned as the primary handler. To the greatest extent possible, the security team will endeavor to keep you informed of the progress being made towards a fix and full announcement, and may ask for additional information or guidance surrounding the reported issue.
|
||||
|
||||
@@ -10,7 +10,7 @@ To run in Bun:
|
||||
|
||||
```bash
|
||||
# so it doesn't run the vitest one
|
||||
bun wiptest expect-to-equal.test.js
|
||||
bun test expect-to-equal.test.js
|
||||
```
|
||||
|
||||
To run in Jest:
|
||||
|
||||
@@ -1,11 +1,33 @@
|
||||
# `install` benchmark
|
||||
|
||||
Requires [`hyperfine`](https://github.com/sharkdp/hyperfine)
|
||||
Requires [`hyperfine`](https://github.com/sharkdp/hyperfine). The goal of this benchmark is to compare installation performance of Bun with other package managers _when caches are hot_.
|
||||
|
||||
```
|
||||
### With lockfile, online mode
|
||||
|
||||
To run the benchmark with the standard "install" command for each package manager:
|
||||
|
||||
```sh
|
||||
$ hyperfine --prepare 'rm -rf node_modules' --warmup 1 --runs 3 'bun install' 'pnpm install' 'yarn' 'npm install'
|
||||
```
|
||||
|
||||
### With lockfile, offline mode
|
||||
|
||||
Even though all packages are cached, some tools may hit the npm API during the version resolution step. (This is not the same as re-downloading a package.) To entirely avoid network calls, the other package managers require `--prefer-offline/--offline` flag. To run the benchmark using "offline" mode:
|
||||
|
||||
```sh
|
||||
$ hyperfine --prepare 'rm -rf node_modules' --runs 1 'bun install' 'pnpm install --prefer-offline' 'yarn --offline' 'npm install --prefer-offline'
|
||||
```
|
||||
|
||||
### Without lockfile, offline mode
|
||||
|
||||
To run the benchmark with offline mode but without lockfiles:
|
||||
|
||||
```sh
|
||||
$ hyperfine --prepare 'rm -rf node_modules' --warmup 1 'rm bun.lockb && bun install' 'rm pnpm-lock.yaml && pnpm install --prefer-offline' 'rm yarn.lock && yarn --offline' 'rm package-lock.json && npm install --prefer-offline'
|
||||
```
|
||||
|
||||
##
|
||||
|
||||
To check that the app is working as expected:
|
||||
|
||||
```
|
||||
|
||||
@@ -77,4 +77,24 @@ bench("ConventionalPrivates", () => {
|
||||
new Foo().run();
|
||||
});
|
||||
|
||||
const _state = Symbol("state");
|
||||
const _inc = Symbol("inc");
|
||||
|
||||
bench("SymbolPrivates", () => {
|
||||
class Foo {
|
||||
[_state] = 1;
|
||||
[_inc] = 13;
|
||||
|
||||
run() {
|
||||
let n = 1000000;
|
||||
while (n-- > 0) {
|
||||
this[_state] += this[_inc];
|
||||
}
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
new Foo().run();
|
||||
});
|
||||
|
||||
await run();
|
||||
|
||||
22
bench/snippets/rmdir.mjs
Normal file
22
bench/snippets/rmdir.mjs
Normal file
@@ -0,0 +1,22 @@
|
||||
import { tmpdir } from "node:os";
|
||||
import { promises, existsSync, mkdirSync } from "node:fs";
|
||||
const count = 1024 * 12;
|
||||
|
||||
var queue = new Array(count);
|
||||
var paths = new Array(count);
|
||||
for (let i = 0; i < count; i++) {
|
||||
const path = `${tmpdir()}/${Date.now()}.rm.dir${i}`;
|
||||
try {
|
||||
mkdirSync(path);
|
||||
} catch (e) {}
|
||||
paths[i] = path;
|
||||
queue[i] = promises.rmdir(path);
|
||||
}
|
||||
|
||||
await Promise.all(queue);
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
if (existsSync(paths[i])) {
|
||||
throw new Error(`Path ${paths[i]} was not removed`);
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,8 @@ bench("writeFile(/tmp/foo.txt, short string)", async () => {
|
||||
await writeFile("/tmp/foo.txt", "short string", "utf8");
|
||||
});
|
||||
|
||||
const buffer = Buffer.from("short string");
|
||||
bench("writeFile(/tmp/foo.txt, Buffer.from(short string))", async () => {
|
||||
await writeFile("/tmp/foo.txt", buffer);
|
||||
await writeFile("/tmp/foo.txt", Buffer.from("short string"));
|
||||
});
|
||||
|
||||
const fd = openSync("/tmp/foo.txt", "w");
|
||||
@@ -22,7 +21,7 @@ bench("write(fd, short string)", () => {
|
||||
});
|
||||
|
||||
bench("write(fd, Uint8Array(short string))", () => {
|
||||
const bytesWritten = write(fd, buffer);
|
||||
const bytesWritten = write(fd, Buffer.from("short string"));
|
||||
if (bytesWritten !== 12) throw new Error("wrote !== 12");
|
||||
});
|
||||
|
||||
|
||||
@@ -224,7 +224,7 @@ pub fn build_(b: *Build) !void {
|
||||
|
||||
var default_build_options: BunBuildOptions = brk: {
|
||||
const is_baseline = arch.isX86() and (target.cpu_model == .baseline or
|
||||
!std.Target.x86.featureSetHas(target.getCpuFeatures(), .avx2));
|
||||
!std.Target.x86.featureSetHas(target.getCpuFeatures(), .avx));
|
||||
|
||||
var git_sha: [:0]const u8 = "";
|
||||
if (b.env_map.get("GITHUB_SHA") orelse b.env_map.get("GIT_SHA")) |sha| {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
[test]
|
||||
# Large monorepos (like Bun) may want to specify the test directory more specifically
|
||||
# By default, `bun test` scans every single folder recurisvely which, if you
|
||||
# have a gigantic submodule (like WebKit), it has to do lots of directory
|
||||
# By default, `bun test` scans every single folder recursively which, if you
|
||||
# have a gigantic submodule (like WebKit), requires lots of directory
|
||||
# traversals
|
||||
#
|
||||
# Instead, we can just make it scan only the test directory for Bun's runtime tests
|
||||
# Instead, we can only scan the test directory for Bun's runtime tests
|
||||
root = "test"
|
||||
|
||||
@@ -92,12 +92,12 @@ _bun_completions() {
|
||||
PACKAGE_OPTIONS[REMOVE_OPTIONS_LONG]="";
|
||||
PACKAGE_OPTIONS[REMOVE_OPTIONS_SHORT]="";
|
||||
|
||||
PACKAGE_OPTIONS[SHARED_OPTIONS_LONG]="--config --yarn --production --frozen-lockfile --no-save --dry-run --lockfile --force --cache-dir --no-cache --silent --verbose --global --cwd --backend --link-native-bins --help";
|
||||
PACKAGE_OPTIONS[SHARED_OPTIONS_LONG]="--config --yarn --production --frozen-lockfile --no-save --dry-run --force --cache-dir --no-cache --silent --verbose --global --cwd --backend --link-native-bins --help";
|
||||
PACKAGE_OPTIONS[SHARED_OPTIONS_SHORT]="-c -y -p -f -g";
|
||||
|
||||
PM_OPTIONS[LONG_OPTIONS]="--config --yarn --production --frozen-lockfile --no-save --dry-run --lockfile --force --cache-dir --no-cache --silent --verbose --no-progress --no-summary --no-verify --ignore-scripts --global --cwd --backend --link-native-bins --help"
|
||||
PM_OPTIONS[LONG_OPTIONS]="--config --yarn --production --frozen-lockfile --no-save --dry-run --force --cache-dir --no-cache --silent --verbose --no-progress --no-summary --no-verify --ignore-scripts --global --cwd --backend --link-native-bins --help"
|
||||
PM_OPTIONS[SHORT_OPTIONS]="-c -y -p -f -g"
|
||||
|
||||
|
||||
local cur_word="${COMP_WORDS[${COMP_CWORD}]}";
|
||||
local prev="${COMP_WORDS[$(( COMP_CWORD - 1 ))]}";
|
||||
|
||||
|
||||
1357
completions/bun.zsh
1357
completions/bun.zsh
File diff suppressed because it is too large
Load Diff
@@ -119,9 +119,6 @@ subcommands:
|
||||
- no-save --
|
||||
- dry-run -- "Don't install anything"
|
||||
- force -- "Always request the latest versions from the registry & reinstall all dependenices"
|
||||
- name: lockfile
|
||||
type: string
|
||||
summary: "Store & load a lockfile at a specific filepath"
|
||||
- name: cache-dir
|
||||
type: string
|
||||
summary: "Store & load cached data from a specific directory path"
|
||||
@@ -160,9 +157,6 @@ subcommands:
|
||||
- no-cache -- "Ignore manifest cache entirely"
|
||||
- silent -- "Don't output anything"
|
||||
- verbose -- "Excessively verbose logging"
|
||||
- name: lockfile
|
||||
type: string
|
||||
summary: "Store & load a lockfile at a specific filepath"
|
||||
- name: cache-dir
|
||||
type: string
|
||||
summary: "Store & load cached data from a specific directory path"
|
||||
@@ -198,9 +192,6 @@ subcommands:
|
||||
- no-save --
|
||||
- dry-run -- "Don't install anything"
|
||||
- force -- "Always request the latest versions from the registry & reinstall all dependenices"
|
||||
- name: lockfile
|
||||
type: string
|
||||
summary: "Store & load a lockfile at a specific filepath"
|
||||
- name: cache-dir
|
||||
type: string
|
||||
summary: "Store & load cached data from a specific directory path"
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
# bun:alpine
|
||||
# Not officially supported (yet)
|
||||
|
||||
ARG GLIBC_RELEASE=2.35-r0
|
||||
|
||||
FROM alpine:latest AS build
|
||||
|
||||
WORKDIR /tmp
|
||||
RUN apk --no-cache add unzip
|
||||
|
||||
ARG GLIBC_RELEASE
|
||||
RUN wget https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \
|
||||
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_RELEASE}/glibc-${GLIBC_RELEASE}.apk
|
||||
|
||||
ADD https://github.com/oven-sh/bun/releases/latest/download/bun-linux-x64.zip bun-linux-x64.zip
|
||||
RUN unzip bun-linux-x64.zip
|
||||
|
||||
FROM alpine:latest
|
||||
|
||||
ARG GLIBC_RELEASE
|
||||
COPY --from=build /tmp/sgerrand.rsa.pub /etc/apk/keys
|
||||
COPY --from=build /tmp/glibc-${GLIBC_RELEASE}.apk /tmp
|
||||
COPY --from=build /tmp/bun-linux-x64/bun /usr/local/bin
|
||||
|
||||
RUN apk --no-cache --force-overwrite add /tmp/glibc-${GLIBC_RELEASE}.apk \
|
||||
&& rm /etc/apk/keys/sgerrand.rsa.pub \
|
||||
&& rm /tmp/glibc-${GLIBC_RELEASE}.apk
|
||||
|
||||
RUN bun --version
|
||||
@@ -1,77 +0,0 @@
|
||||
FROM debian:bullseye-slim AS build
|
||||
|
||||
# https://github.com/oven-sh/bun/releases
|
||||
ARG BUN_VERSION=latest
|
||||
|
||||
RUN apt-get update -qq \
|
||||
&& apt-get install -qq --no-install-recommends \
|
||||
ca-certificates \
|
||||
curl \
|
||||
dirmngr \
|
||||
gpg \
|
||||
gpg-agent \
|
||||
unzip \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& arch="$(dpkg --print-architecture)" \
|
||||
&& case "${arch##*-}" in \
|
||||
amd64) build="x64-baseline";; \
|
||||
arm64) build="aarch64";; \
|
||||
*) echo "error: unsupported architecture: ($arch)"; exit 1 ;; \
|
||||
esac \
|
||||
&& version="$BUN_VERSION" \
|
||||
&& case "$version" in \
|
||||
latest | canary | bun-v*) tag="$version"; ;; \
|
||||
v*) tag="bun-$version"; ;; \
|
||||
*) tag="bun-v$version"; ;; \
|
||||
esac \
|
||||
&& case "$tag" in \
|
||||
latest) release="latest/download"; ;; \
|
||||
*) release="download/$tag"; ;; \
|
||||
esac \
|
||||
&& curl "https://github.com/oven-sh/bun/releases/$release/bun-linux-$build.zip" \
|
||||
-fsSLO \
|
||||
--compressed \
|
||||
--retry 5 \
|
||||
|| (echo "error: unknown release: ($tag)" && exit 1) \
|
||||
&& for key in \
|
||||
"F3DCC08A8572C0749B3E18888EAB4D40A7B22B59" \
|
||||
; do \
|
||||
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" \
|
||||
|| gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \
|
||||
done \
|
||||
&& gpg --update-trustdb \
|
||||
&& curl "https://github.com/oven-sh/bun/releases/$release/SHASUMS256.txt.asc" \
|
||||
-fsSLO \
|
||||
--compressed \
|
||||
--retry 5 \
|
||||
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
|
||||
|| (echo "error: failed to verify release: ($tag)" && exit 1) \
|
||||
&& grep " bun-linux-$build.zip\$" SHASUMS256.txt | sha256sum -c - \
|
||||
|| (echo "error: failed to verify release: ($tag)" && exit 1) \
|
||||
&& unzip "bun-linux-$build.zip" \
|
||||
&& mv "bun-linux-$build/bun" /usr/local/bin/bun \
|
||||
&& rm -f "bun-linux-$build.zip" SHASUMS256.txt.asc SHASUMS256.txt \
|
||||
&& chmod +x /usr/local/bin/bun \
|
||||
&& ln -s /usr/local/bin/bun /usr/local/bin/bunx \
|
||||
&& which bun \
|
||||
&& which bunx \
|
||||
&& bun --version
|
||||
|
||||
FROM debian:bullseye-slim
|
||||
|
||||
RUN groupadd bun \
|
||||
--gid 1000 \
|
||||
&& useradd bun \
|
||||
--uid 1000 \
|
||||
--gid bun \
|
||||
--shell /bin/sh \
|
||||
--create-home
|
||||
|
||||
COPY docker-entrypoint.sh /usr/local/bin
|
||||
COPY --from=build /usr/local/bin/bun /usr/local/bin
|
||||
COPY --from=build /usr/local/bin/bunx /usr/local/bin
|
||||
|
||||
WORKDIR /home/bun/app
|
||||
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
||||
CMD ["/usr/local/bin/bun"]
|
||||
113
dockerhub/alpine/Dockerfile
Normal file
113
dockerhub/alpine/Dockerfile
Normal file
@@ -0,0 +1,113 @@
|
||||
FROM alpine:3.18 AS build
|
||||
|
||||
# https://github.com/oven-sh/bun/releases
|
||||
ARG BUN_VERSION=latest
|
||||
|
||||
# TODO: Instead of downloading glibc from a third-party source, we should
|
||||
# build it from source. This is a temporary solution.
|
||||
# See: https://github.com/sgerrand/alpine-pkg-glibc
|
||||
|
||||
# https://github.com/sgerrand/alpine-pkg-glibc/releases
|
||||
# https://github.com/sgerrand/alpine-pkg-glibc/issues/176
|
||||
ARG GLIBC_VERSION=2.34-r0
|
||||
|
||||
# https://github.com/oven-sh/bun/issues/5545#issuecomment-1722461083
|
||||
ARG GLIBC_VERSION_AARCH64=2.26-r1
|
||||
|
||||
RUN apk --no-cache add \
|
||||
ca-certificates \
|
||||
curl \
|
||||
dirmngr \
|
||||
gpg \
|
||||
gpg-agent \
|
||||
unzip \
|
||||
&& arch="$(apk --print-arch)" \
|
||||
&& case "${arch##*-}" in \
|
||||
x86_64) build="x64-baseline";; \
|
||||
aarch64) build="aarch64";; \
|
||||
*) echo "error: unsupported architecture: $arch"; exit 1 ;; \
|
||||
esac \
|
||||
&& version="$BUN_VERSION" \
|
||||
&& case "$version" in \
|
||||
latest | canary | bun-v*) tag="$version"; ;; \
|
||||
v*) tag="bun-$version"; ;; \
|
||||
*) tag="bun-v$version"; ;; \
|
||||
esac \
|
||||
&& case "$tag" in \
|
||||
latest) release="latest/download"; ;; \
|
||||
*) release="download/$tag"; ;; \
|
||||
esac \
|
||||
&& curl "https://github.com/oven-sh/bun/releases/$release/bun-linux-$build.zip" \
|
||||
-fsSLO \
|
||||
--compressed \
|
||||
--retry 5 \
|
||||
|| (echo "error: failed to download: $tag" && exit 1) \
|
||||
&& for key in \
|
||||
"F3DCC08A8572C0749B3E18888EAB4D40A7B22B59" \
|
||||
; do \
|
||||
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" \
|
||||
|| gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \
|
||||
done \
|
||||
&& curl "https://github.com/oven-sh/bun/releases/$release/SHASUMS256.txt.asc" \
|
||||
-fsSLO \
|
||||
--compressed \
|
||||
--retry 5 \
|
||||
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
|
||||
|| (echo "error: failed to verify: $tag" && exit 1) \
|
||||
&& grep " bun-linux-$build.zip\$" SHASUMS256.txt | sha256sum -c - \
|
||||
|| (echo "error: failed to verify: $tag" && exit 1) \
|
||||
&& unzip "bun-linux-$build.zip" \
|
||||
&& mv "bun-linux-$build/bun" /usr/local/bin/bun \
|
||||
&& rm -f "bun-linux-$build.zip" SHASUMS256.txt.asc SHASUMS256.txt \
|
||||
&& chmod +x /usr/local/bin/bun \
|
||||
&& cd /tmp \
|
||||
&& case "${arch##*-}" in \
|
||||
x86_64) curl "https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk" \
|
||||
-fsSLO \
|
||||
--compressed \
|
||||
--retry 5 \
|
||||
|| (echo "error: failed to download: glibc v${GLIBC_VERSION}" && exit 1) \
|
||||
&& mv "glibc-${GLIBC_VERSION}.apk" glibc.apk \
|
||||
&& curl "https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-bin-${GLIBC_VERSION}.apk" \
|
||||
-fsSLO \
|
||||
--compressed \
|
||||
--retry 5 \
|
||||
|| (echo "error: failed to download: glibc-bin v${GLIBC_VERSION}" && exit 1) \
|
||||
&& mv "glibc-bin-${GLIBC_VERSION}.apk" glibc-bin.apk ;; \
|
||||
aarch64) curl "https://raw.githubusercontent.com/squishyu/alpine-pkg-glibc-aarch64-bin/master/glibc-${GLIBC_VERSION_AARCH64}.apk" \
|
||||
-fsSLO \
|
||||
--compressed \
|
||||
--retry 5 \
|
||||
|| (echo "error: failed to download: glibc v${GLIBC_VERSION_AARCH64}" && exit 1) \
|
||||
&& mv "glibc-${GLIBC_VERSION_AARCH64}.apk" glibc.apk \
|
||||
&& curl "https://raw.githubusercontent.com/squishyu/alpine-pkg-glibc-aarch64-bin/master/glibc-bin-${GLIBC_VERSION_AARCH64}.apk" \
|
||||
-fsSLO \
|
||||
--compressed \
|
||||
--retry 5 \
|
||||
|| (echo "error: failed to download: glibc-bin v${GLIBC_VERSION_AARCH64}" && exit 1) \
|
||||
&& mv "glibc-bin-${GLIBC_VERSION_AARCH64}.apk" glibc-bin.apk ;; \
|
||||
*) echo "error: unsupported architecture '$arch'"; exit 1 ;; \
|
||||
esac
|
||||
|
||||
FROM alpine:3.18
|
||||
|
||||
COPY --from=build /tmp/glibc.apk /tmp/
|
||||
COPY --from=build /tmp/glibc-bin.apk /tmp/
|
||||
COPY --from=build /usr/local/bin/bun /usr/local/bin/
|
||||
COPY docker-entrypoint.sh /usr/local/bin/
|
||||
|
||||
RUN addgroup -g 1000 bun \
|
||||
&& adduser -u 1000 -G bun -s /bin/sh -D bun \
|
||||
&& apk --no-cache --force-overwrite --allow-untrusted add \
|
||||
/tmp/glibc.apk \
|
||||
/tmp/glibc-bin.apk \
|
||||
&& rm /tmp/glibc.apk \
|
||||
&& rm /tmp/glibc-bin.apk \
|
||||
&& ln -s /usr/local/bin/bun /usr/local/bin/bunx \
|
||||
&& which bun \
|
||||
&& which bunx \
|
||||
&& bun --version
|
||||
|
||||
WORKDIR /home/bun/app
|
||||
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
||||
CMD ["/usr/local/bin/bun"]
|
||||
@@ -1,7 +1,7 @@
|
||||
FROM debian:bullseye-slim AS build
|
||||
|
||||
# https://github.com/oven-sh/bun/releases
|
||||
ARG BUN_VERSION=0.5.7
|
||||
ARG BUN_VERSION=latest
|
||||
|
||||
RUN apt-get update -qq \
|
||||
&& apt-get install -qq --no-install-recommends \
|
||||
@@ -17,7 +17,7 @@ RUN apt-get update -qq \
|
||||
&& case "${arch##*-}" in \
|
||||
amd64) build="x64-baseline";; \
|
||||
arm64) build="aarch64";; \
|
||||
*) echo "error: unsupported architecture: ($arch)"; exit 1 ;; \
|
||||
*) echo "error: unsupported architecture: $arch"; exit 1 ;; \
|
||||
esac \
|
||||
&& version="$BUN_VERSION" \
|
||||
&& case "$version" in \
|
||||
@@ -33,44 +33,44 @@ RUN apt-get update -qq \
|
||||
-fsSLO \
|
||||
--compressed \
|
||||
--retry 5 \
|
||||
|| (echo "error: unknown release: ($tag)" && exit 1) \
|
||||
|| (echo "error: failed to download: $tag" && exit 1) \
|
||||
&& for key in \
|
||||
"F3DCC08A8572C0749B3E18888EAB4D40A7B22B59" \
|
||||
; do \
|
||||
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" \
|
||||
|| gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \
|
||||
done \
|
||||
&& gpg --update-trustdb \
|
||||
&& curl "https://github.com/oven-sh/bun/releases/$release/SHASUMS256.txt.asc" \
|
||||
-fsSLO \
|
||||
--compressed \
|
||||
--retry 5 \
|
||||
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
|
||||
|| (echo "error: failed to verify release: ($tag)" && exit 1) \
|
||||
|| (echo "error: failed to verify: $tag" && exit 1) \
|
||||
&& grep " bun-linux-$build.zip\$" SHASUMS256.txt | sha256sum -c - \
|
||||
|| (echo "error: failed to verify release: ($tag)" && exit 1) \
|
||||
|| (echo "error: failed to verify: $tag" && exit 1) \
|
||||
&& unzip "bun-linux-$build.zip" \
|
||||
&& mv "bun-linux-$build/bun" /usr/local/bin/bun \
|
||||
&& rm -f "bun-linux-$build.zip" SHASUMS256.txt.asc SHASUMS256.txt \
|
||||
&& chmod +x /usr/local/bin/bun \
|
||||
&& ln -s /usr/local/bin/bun /usr/local/bin/bunx \
|
||||
&& which bun \
|
||||
&& which bunx \
|
||||
&& bun --version
|
||||
|
||||
FROM debian:bullseye-slim
|
||||
|
||||
COPY docker-entrypoint.sh /usr/local/bin
|
||||
COPY --from=build /usr/local/bin/bun /usr/local/bin/bun
|
||||
|
||||
RUN groupadd bun \
|
||||
--gid 1000 \
|
||||
&& useradd bun \
|
||||
--uid 1000 \
|
||||
--gid bun \
|
||||
--shell /bin/sh \
|
||||
--create-home
|
||||
|
||||
COPY docker-entrypoint.sh /usr/local/bin
|
||||
COPY --from=build /usr/local/bin/bun /usr/local/bin
|
||||
COPY --from=build /usr/local/bin/bunx /usr/local/bin
|
||||
--create-home \
|
||||
&& ln -s /usr/local/bin/bun /usr/local/bin/bunx \
|
||||
&& which bun \
|
||||
&& which bunx \
|
||||
&& bun --version
|
||||
|
||||
WORKDIR /home/bun/app
|
||||
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
FROM debian:bullseye-slim AS build
|
||||
|
||||
# https://github.com/oven-sh/bun/releases
|
||||
ARG BUN_VERSION=0.5.7
|
||||
ARG BUN_VERSION=latest
|
||||
|
||||
RUN apt-get update -qq \
|
||||
&& apt-get install -qq --no-install-recommends \
|
||||
@@ -17,7 +17,7 @@ RUN apt-get update -qq \
|
||||
&& case "${arch##*-}" in \
|
||||
amd64) build="x64-baseline";; \
|
||||
arm64) build="aarch64";; \
|
||||
*) echo "error: unsupported architecture: ($arch)"; exit 1 ;; \
|
||||
*) echo "error: unsupported architecture: $arch"; exit 1 ;; \
|
||||
esac \
|
||||
&& version="$BUN_VERSION" \
|
||||
&& case "$version" in \
|
||||
@@ -33,44 +33,42 @@ RUN apt-get update -qq \
|
||||
-fsSLO \
|
||||
--compressed \
|
||||
--retry 5 \
|
||||
|| (echo "error: unknown release: ($tag)" && exit 1) \
|
||||
|| (echo "error: failed to download: $tag" && exit 1) \
|
||||
&& for key in \
|
||||
"F3DCC08A8572C0749B3E18888EAB4D40A7B22B59" \
|
||||
; do \
|
||||
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" \
|
||||
|| gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \
|
||||
done \
|
||||
&& gpg --update-trustdb \
|
||||
&& curl "https://github.com/oven-sh/bun/releases/$release/SHASUMS256.txt.asc" \
|
||||
-fsSLO \
|
||||
--compressed \
|
||||
--retry 5 \
|
||||
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
|
||||
|| (echo "error: failed to verify release: ($tag)" && exit 1) \
|
||||
|| (echo "error: failed to verify: $tag" && exit 1) \
|
||||
&& grep " bun-linux-$build.zip\$" SHASUMS256.txt | sha256sum -c - \
|
||||
|| (echo "error: failed to verify release: ($tag)" && exit 1) \
|
||||
|| (echo "error: failed to verify: $tag" && exit 1) \
|
||||
&& unzip "bun-linux-$build.zip" \
|
||||
&& mv "bun-linux-$build/bun" /usr/local/bin/bun \
|
||||
&& rm -f "bun-linux-$build.zip" SHASUMS256.txt.asc SHASUMS256.txt \
|
||||
&& chmod +x /usr/local/bin/bun \
|
||||
&& ln -s /usr/local/bin/bun /usr/local/bin/bunx \
|
||||
&& which bun \
|
||||
&& which bunx \
|
||||
&& bun --version
|
||||
&& chmod +x /usr/local/bin/bun
|
||||
|
||||
FROM debian:bullseye
|
||||
|
||||
COPY docker-entrypoint.sh /usr/local/bin
|
||||
COPY --from=build /usr/local/bin/bun /usr/local/bin/bun
|
||||
|
||||
RUN groupadd bun \
|
||||
--gid 1000 \
|
||||
&& useradd bun \
|
||||
--uid 1000 \
|
||||
--gid bun \
|
||||
--shell /bin/sh \
|
||||
--create-home
|
||||
|
||||
COPY docker-entrypoint.sh /usr/local/bin
|
||||
COPY --from=build /usr/local/bin/bun /usr/local/bin
|
||||
COPY --from=build /usr/local/bin/bunx /usr/local/bin
|
||||
--create-home \
|
||||
&& ln -s /usr/local/bin/bun /usr/local/bin/bunx \
|
||||
&& which bun \
|
||||
&& which bunx \
|
||||
&& bun --version
|
||||
|
||||
WORKDIR /home/bun/app
|
||||
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
FROM debian:bullseye-slim AS build
|
||||
# Not officially supported (yet)
|
||||
|
||||
# https://github.com/oven-sh/bun/releases
|
||||
ARG BUN_VERSION=latest
|
||||
@@ -18,7 +17,7 @@ RUN apt-get update -qq \
|
||||
&& case "${arch##*-}" in \
|
||||
amd64) build="x64-baseline";; \
|
||||
arm64) build="aarch64";; \
|
||||
*) echo "error: unsupported architecture: ($arch)"; exit 1 ;; \
|
||||
*) echo "error: unsupported architecture: $arch"; exit 1 ;; \
|
||||
esac \
|
||||
&& version="$BUN_VERSION" \
|
||||
&& case "$version" in \
|
||||
@@ -34,36 +33,37 @@ RUN apt-get update -qq \
|
||||
-fsSLO \
|
||||
--compressed \
|
||||
--retry 5 \
|
||||
|| (echo "error: unknown release: ($tag)" && exit 1) \
|
||||
|| (echo "error: failed to download: $tag" && exit 1) \
|
||||
&& for key in \
|
||||
"F3DCC08A8572C0749B3E18888EAB4D40A7B22B59" \
|
||||
; do \
|
||||
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" \
|
||||
|| gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \
|
||||
done \
|
||||
&& gpg --update-trustdb \
|
||||
&& curl "https://github.com/oven-sh/bun/releases/$release/SHASUMS256.txt.asc" \
|
||||
-fsSLO \
|
||||
--compressed \
|
||||
--retry 5 \
|
||||
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
|
||||
|| (echo "error: failed to verify release: ($tag)" && exit 1) \
|
||||
|| (echo "error: failed to verify: $tag" && exit 1) \
|
||||
&& grep " bun-linux-$build.zip\$" SHASUMS256.txt | sha256sum -c - \
|
||||
|| (echo "error: failed to verify release: ($tag)" && exit 1) \
|
||||
|| (echo "error: failed to verify: $tag" && exit 1) \
|
||||
&& unzip "bun-linux-$build.zip" \
|
||||
&& mv "bun-linux-$build/bun" /usr/local/bin/bun \
|
||||
&& rm -f "bun-linux-$build.zip" SHASUMS256.txt.asc SHASUMS256.txt \
|
||||
&& chmod +x /usr/local/bin/bun \
|
||||
&& ln -s /usr/local/bin/bun /usr/local/bin/bunx \
|
||||
&& which bun \
|
||||
&& which bunx \
|
||||
&& bun --version
|
||||
|
||||
FROM gcr.io/distroless/base-nossl-debian11
|
||||
|
||||
COPY --from=build /usr/local/bin/bun /usr/local/bin
|
||||
COPY --from=build /usr/local/bin/bunx /usr/local/bin
|
||||
COPY --from=build /usr/local/bin/bun /usr/local/bin/
|
||||
|
||||
# Temporarily use the `build`-stage image binaries to create a symlink:
|
||||
RUN --mount=type=bind,from=build,source=/usr/bin,target=/usr/bin \
|
||||
--mount=type=bind,from=build,source=/bin,target=/bin <<EOF
|
||||
ln -s /usr/local/bin/bun /usr/local/bin/bunx
|
||||
which bunx
|
||||
EOF
|
||||
|
||||
WORKDIR /app
|
||||
ENTRYPOINT ["/usr/local/bin/bun"]
|
||||
CMD ["/usr/local/bin/bun"]
|
||||
@@ -74,7 +74,7 @@ dv.getUint8(0); // => 3
|
||||
// [0x11, 0x0, 0x0, 0x0]
|
||||
```
|
||||
|
||||
Now lets write a `Uint16` at byte offset `1`. This requires two bytes. We're using the value `513`, which is `2 * 256 + 1`; in bytes, that's `00000010 00000001`.
|
||||
Now let's write a `Uint16` at byte offset `1`. This requires two bytes. We're using the value `513`, which is `2 * 256 + 1`; in bytes, that's `00000010 00000001`.
|
||||
|
||||
```ts
|
||||
dv.setUint16(1, 513);
|
||||
@@ -90,7 +90,7 @@ console.log(dv.getUint8(1)); // => 2
|
||||
console.log(dv.getUint8(2)); // => 1
|
||||
```
|
||||
|
||||
Attempting to write a value that requires more space than is available in the underlying `ArrayBuffer` will cuase an error. Below we attempt to write a `Float64` (which requires 8 bytes) at byte offset `0`, but there are only four total bytes in the buffer.
|
||||
Attempting to write a value that requires more space than is available in the underlying `ArrayBuffer` will cause an error. Below we attempt to write a `Float64` (which requires 8 bytes) at byte offset `0`, but there are only four total bytes in the buffer.
|
||||
|
||||
```ts
|
||||
dv.setFloat64(0, 3.1415);
|
||||
@@ -412,7 +412,7 @@ For complete documentation, refer to the [Node.js documentation](https://nodejs.
|
||||
|
||||
`Blob` is a Web API commonly used for representing files. `Blob` was initially implemented in browsers (unlike `ArrayBuffer` which is part of JavaScript itself), but it is now supported in Node and Bun.
|
||||
|
||||
It isn't common to directly create `Blob` instances. More often, you'll recieve instances of `Blob` from an external source (like an `<input type="file">` element in the browser) or library. That said, it is possible to create a `Blob` from one or more string or binary "blob parts".
|
||||
It isn't common to directly create `Blob` instances. More often, you'll receive instances of `Blob` from an external source (like an `<input type="file">` element in the browser) or library. That said, it is possible to create a `Blob` from one or more string or binary "blob parts".
|
||||
|
||||
```ts
|
||||
const blob = new Blob(["<html>Hello</html>"], {
|
||||
@@ -507,7 +507,7 @@ for await (const chunk of stream) {
|
||||
}
|
||||
```
|
||||
|
||||
For a more complete discusson of streams in Bun, see [API > Streams](/docs/api/streams).
|
||||
For a more complete discussion of streams in Bun, see [API > Streams](/docs/api/streams).
|
||||
|
||||
## Conversion
|
||||
|
||||
|
||||
@@ -229,7 +229,11 @@ const lib = linkSymbols({
|
||||
},
|
||||
});
|
||||
|
||||
const [major, minor, patch] = [lib.symbols.getMajor(), lib.symbols.getMinor(), lib.symbols.getPatch()];
|
||||
const [major, minor, patch] = [
|
||||
lib.symbols.getMajor(),
|
||||
lib.symbols.getMinor(),
|
||||
lib.symbols.getPatch(),
|
||||
];
|
||||
```
|
||||
|
||||
## Callbacks
|
||||
@@ -249,10 +253,13 @@ const {
|
||||
},
|
||||
});
|
||||
|
||||
const searchIterator = new JSCallback((ptr, length) => /hello/.test(new CString(ptr, length)), {
|
||||
returns: "bool",
|
||||
args: ["ptr", "usize"],
|
||||
});
|
||||
const searchIterator = new JSCallback(
|
||||
(ptr, length) => /hello/.test(new CString(ptr, length)),
|
||||
{
|
||||
returns: "bool",
|
||||
args: ["ptr", "usize"],
|
||||
},
|
||||
);
|
||||
|
||||
const str = Buffer.from("wwutwutwutwutwutwutwutwutwutwutut\0", "utf8");
|
||||
if (search(ptr(str), searchIterator)) {
|
||||
@@ -376,10 +383,6 @@ If you want to track when a `TypedArray` is no longer in use from JavaScript, yo
|
||||
|
||||
#### From C, Rust, Zig, etc
|
||||
|
||||
{% callout %}
|
||||
**Note** — Available in Bun v0.1.8 and later.
|
||||
{% /callout %}
|
||||
|
||||
If you want to track when a `TypedArray` is no longer in use from C or FFI, you can pass a callback and an optional context pointer to `toArrayBuffer` or `toBuffer`. This function is called at some point later, once the garbage collector frees the underlying `ArrayBuffer` JavaScript object.
|
||||
|
||||
The expected signature is the same as in [JavaScriptCore's C API](https://developer.apple.com/documentation/javascriptcore/jstypedarraybytesdeallocator?language=objc):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<!-- **Note** — The `Bun.file` and `Bun.write` APIs documented on this page are heavily optimized and represent the recommended way to perform file-system tasks using Bun. Existing Node.js projects may use Bun's [nearly complete](/docs/runtime/nodejs-apis#node-fs) implementation of the [`node:fs`](https://nodejs.org/api/fs.html) module. -->
|
||||
|
||||
**Note** — The `Bun.file` and `Bun.write` APIs documented on this page are heavily optimized and represent the recommended way to perform file-system tasks using Bun. For operations that are not yet available with `Bun.file`, such as `mkdir`, you can use Bun's [nearly complete](/docs/runtime/nodejs-apis#node-fs) implementation of the [`node:fs`](https://nodejs.org/api/fs.html) module.
|
||||
**Note** — The `Bun.file` and `Bun.write` APIs documented on this page are heavily optimized and represent the recommended way to perform file-system tasks using Bun. For operations that are not yet available with `Bun.file`, such as `mkdir` or `readdir`, you can use Bun's [nearly complete](/docs/runtime/nodejs-apis#node-fs) implementation of the [`node:fs`](https://nodejs.org/api/fs.html) module.
|
||||
|
||||
{% /callout %}
|
||||
|
||||
@@ -195,7 +195,7 @@ const input = Bun.file("input.txt");
|
||||
await Bun.write(Bun.stdout, input);
|
||||
```
|
||||
|
||||
To write an HTTP response to disk:
|
||||
To write the body of an HTTP response to disk:
|
||||
|
||||
```ts
|
||||
const response = await fetch("https://bun.sh");
|
||||
|
||||
@@ -93,6 +93,7 @@ interface Bun {
|
||||
style: "nextjs";
|
||||
origin?: string;
|
||||
assetPrefix?: string;
|
||||
fileExtensions?: string[];
|
||||
});
|
||||
|
||||
reload(): void;
|
||||
|
||||
@@ -6,10 +6,6 @@ Bun implements the `createHash` and `createHmac` functions from [`node:crypto`](
|
||||
|
||||
## `Bun.password`
|
||||
|
||||
{% callout %}
|
||||
**Note** — Added in Bun 0.6.8.
|
||||
{% /callout %}
|
||||
|
||||
`Bun.password` is a collection of utility functions for hashing and verifying passwords with various cryptographically secure algorithms.
|
||||
|
||||
```ts
|
||||
@@ -136,7 +132,7 @@ hasher.digest();
|
||||
Once initialized, data can be incrementally fed to to the hasher using `.update()`. This method accepts `string`, `TypedArray`, and `ArrayBuffer`.
|
||||
|
||||
```ts
|
||||
const hasher = new Bun.CryptoHasher();
|
||||
const hasher = new Bun.CryptoHasher("sha256");
|
||||
|
||||
hasher.update("hello world");
|
||||
hasher.update(new Uint8Array([1, 2, 3]));
|
||||
@@ -174,7 +170,7 @@ hasher.update("hello world", "latin1");
|
||||
After the data has been feed into the hasher, a final hash can be computed using `.digest()`. By default, this method returns a `Uint8Array` containing the hash.
|
||||
|
||||
```ts
|
||||
const hasher = new Bun.CryptoHasher();
|
||||
const hasher = new Bun.CryptoHasher("sha256");
|
||||
hasher.update("hello world");
|
||||
|
||||
hasher.digest();
|
||||
|
||||
@@ -13,7 +13,7 @@ Start an HTTP server in Bun with `Bun.serve`.
|
||||
```ts
|
||||
Bun.serve({
|
||||
fetch(req) {
|
||||
return new Response(`Bun!`);
|
||||
return new Response("Bun!");
|
||||
},
|
||||
});
|
||||
```
|
||||
@@ -24,9 +24,9 @@ The `fetch` handler handles incoming requests. It receives a [`Request`](https:/
|
||||
Bun.serve({
|
||||
fetch(req) {
|
||||
const url = new URL(req.url);
|
||||
if (url.pathname === "/") return new Response(`Home page!`);
|
||||
if (url.pathname === "/") return new Response("Home page!");
|
||||
if (url.pathname === "/blog") return new Response("Blog!");
|
||||
return new Response(`404!`);
|
||||
return new Response("404!");
|
||||
},
|
||||
});
|
||||
```
|
||||
@@ -38,7 +38,7 @@ Bun.serve({
|
||||
port: 8080, // defaults to $BUN_PORT, $PORT, $NODE_PORT otherwise 3000
|
||||
hostname: "mydomain.com", // defaults to "0.0.0.0"
|
||||
fetch(req) {
|
||||
return new Response(`404!`);
|
||||
return new Response("404!");
|
||||
},
|
||||
});
|
||||
```
|
||||
@@ -71,7 +71,7 @@ In development mode, Bun will surface errors in-browser with a built-in error pa
|
||||
|
||||
{% image src="/images/exception_page.png" caption="Bun's built-in 500 page" /%}
|
||||
|
||||
To handle server-side errors, implement an `error` handler. This function should return a `Response` to served to the client when an error occurs. This response will supercede Bun's default error page in `development` mode.
|
||||
To handle server-side errors, implement an `error` handler. This function should return a `Response` to serve to the client when an error occurs. This response will supersede Bun's default error page in `development` mode.
|
||||
|
||||
```ts
|
||||
Bun.serve({
|
||||
@@ -140,12 +140,6 @@ Bun.serve({
|
||||
});
|
||||
```
|
||||
|
||||
{% callout %}
|
||||
|
||||
**Note** — Earlier versions of Bun supported passing a file path as `keyFile` and `certFile`; this has been deprecated as of `v0.6.3`.
|
||||
|
||||
{% /callout %}
|
||||
|
||||
If your private key is encrypted with a passphrase, provide a value for `passphrase` to decrypt it.
|
||||
|
||||
```ts-diff
|
||||
@@ -198,7 +192,7 @@ import {type Serve} from "bun";
|
||||
|
||||
export default {
|
||||
fetch(req) {
|
||||
return new Response(`Bun!`);
|
||||
return new Response("Bun!");
|
||||
},
|
||||
} satisfies Serve;
|
||||
```
|
||||
@@ -218,9 +212,7 @@ $ bun --hot server.ts
|
||||
To stream a file, return a `Response` object with a `BunFile` object as the body.
|
||||
|
||||
```ts
|
||||
import { serve, file } from "bun";
|
||||
|
||||
serve({
|
||||
Bun.serve({
|
||||
fetch(req) {
|
||||
return new Response(Bun.file("./hello.txt"));
|
||||
},
|
||||
@@ -231,7 +223,7 @@ serve({
|
||||
⚡️ **Speed** — Bun automatically uses the [`sendfile(2)`](https://man7.org/linux/man-pages/man2/sendfile.2.html) system call when possible, enabling zero-copy file transfers in the kernel—the fastest way to send files.
|
||||
{% /callout %}
|
||||
|
||||
**[v0.3.0+]** You can send part of a file using the [`slice(start, end)`](https://developer.mozilla.org/en-US/docs/Web/API/Blob/slice) method on the `Bun.file` object. This automatically sets the `Content-Range` and `Content-Length` headers on the `Response` object.
|
||||
You can send part of a file using the [`slice(start, end)`](https://developer.mozilla.org/en-US/docs/Web/API/Blob/slice) method on the `Bun.file` object. This automatically sets the `Content-Range` and `Content-Length` headers on the `Response` object.
|
||||
|
||||
```ts
|
||||
Bun.serve({
|
||||
@@ -260,7 +252,7 @@ Below are Bun and Node.js implementations of a simple HTTP server that responds
|
||||
```ts#Bun
|
||||
Bun.serve({
|
||||
fetch(req: Request) {
|
||||
return new Response(`Bun!`);
|
||||
return new Response("Bun!");
|
||||
},
|
||||
port: 3000,
|
||||
});
|
||||
|
||||
@@ -39,7 +39,7 @@ import.meta.resolveSync("zod")
|
||||
---
|
||||
|
||||
- `import.meta.resolve{Sync}`
|
||||
- Resolve a module specifier (e.g. `"zod"` or `"./file.tsx`) to an absolute path. While file would be imported if the specifier were imported from this file?
|
||||
- Resolve a module specifier (e.g. `"zod"` or `"./file.tsx"`) to an absolute path. While file would be imported if the specifier were imported from this file?
|
||||
|
||||
```ts
|
||||
import.meta.resolveSync("zod");
|
||||
|
||||
@@ -28,7 +28,9 @@ By default, the input stream of the subprocess is undefined; it can be configure
|
||||
|
||||
```ts
|
||||
const proc = Bun.spawn(["cat"], {
|
||||
stdin: await fetch("https://raw.githubusercontent.com/oven-sh/bun/main/examples/hashing.js"),
|
||||
stdin: await fetch(
|
||||
"https://raw.githubusercontent.com/oven-sh/bun/main/examples/hashing.js",
|
||||
),
|
||||
});
|
||||
|
||||
const text = await new Response(proc.stdout).text();
|
||||
@@ -209,7 +211,7 @@ Bun's `spawnSync` spawns processes 60% faster than the Node.js `child_process` m
|
||||
```bash
|
||||
$ bun spawn.mjs
|
||||
cpu: Apple M1 Max
|
||||
runtime: bun 0.2.0 (arm64-darwin)
|
||||
runtime: bun 1.x (arm64-darwin)
|
||||
|
||||
benchmark time (avg) (min … max) p75 p99 p995
|
||||
--------------------------------------------------------- -----------------------------
|
||||
@@ -230,10 +232,15 @@ A simple reference of the Spawn API and types are shown below. The real types ha
|
||||
```ts
|
||||
interface Bun {
|
||||
spawn(command: string[], options?: SpawnOptions.OptionsObject): Subprocess;
|
||||
spawnSync(command: string[], options?: SpawnOptions.OptionsObject): SyncSubprocess;
|
||||
spawnSync(
|
||||
command: string[],
|
||||
options?: SpawnOptions.OptionsObject,
|
||||
): SyncSubprocess;
|
||||
|
||||
spawn(options: { cmd: string[] } & SpawnOptions.OptionsObject): Subprocess;
|
||||
spawnSync(options: { cmd: string[] } & SpawnOptions.OptionsObject): SyncSubprocess;
|
||||
spawnSync(
|
||||
options: { cmd: string[] } & SpawnOptions.OptionsObject,
|
||||
): SyncSubprocess;
|
||||
}
|
||||
|
||||
namespace SpawnOptions {
|
||||
@@ -243,7 +250,12 @@ namespace SpawnOptions {
|
||||
stdin?: SpawnOptions.Readable;
|
||||
stdout?: SpawnOptions.Writable;
|
||||
stderr?: SpawnOptions.Writable;
|
||||
onExit?: (proc: Subprocess, exitCode: number | null, signalCode: string | null, error: Error | null) => void;
|
||||
onExit?: (
|
||||
proc: Subprocess,
|
||||
exitCode: number | null,
|
||||
signalCode: string | null,
|
||||
error: Error | null,
|
||||
) => void;
|
||||
}
|
||||
|
||||
type Readable =
|
||||
|
||||
@@ -99,6 +99,20 @@ const query = db.prepare("SELECT * FROM foo WHERE bar = ?");
|
||||
|
||||
{% /callout %}
|
||||
|
||||
## WAL mode
|
||||
|
||||
SQLite supports [write-ahead log mode](https://www.sqlite.org/wal.html) (WAL) which dramatically improves performance, especially in situations with many concurrent writes. It's broadly recommended to enable WAL mode for most typical applications.
|
||||
|
||||
To enable WAL mode, run this pragma query at the beginning of your application:
|
||||
|
||||
```ts
|
||||
db.exec("PRAGMA journal_mode = WAL;");
|
||||
```
|
||||
|
||||
{% details summary="What is WAL mode" %}
|
||||
In WAL mode, writes to the database are written directly to a separate file called the "WAL file" (write-ahead log). This file will be later integrated into the main database file. Think of it as a buffer for pending writes. Refer to the [SQLite docs](https://www.sqlite.org/wal.html) for a more detailed overview.
|
||||
{% /details %}
|
||||
|
||||
## Statements
|
||||
|
||||
A `Statement` is a _prepared query_, which means it's been parsed and compiled into an efficient binary form. It can be executed multiple times in a performant way.
|
||||
|
||||
@@ -76,12 +76,6 @@ Bun.listen({
|
||||
});
|
||||
```
|
||||
|
||||
{% callout %}
|
||||
|
||||
**Note** — Earlier versions of Bun supported passing a file path as `keyFile` and `certFile`; this has been deprecated as of `v0.6.3`.
|
||||
|
||||
{% /callout %}
|
||||
|
||||
The `key` and `cert` fields expect the _contents_ of your TLS key and certificate. This can be a string, `BunFile`, `TypedArray`, or `Buffer`.
|
||||
|
||||
```ts
|
||||
@@ -95,7 +89,7 @@ Bun.listen({
|
||||
// string
|
||||
key: fs.readFileSync("./key.pem", "utf8"),
|
||||
// array of above
|
||||
key: [Bun.file('./key1.pem'), Bun.file('./key2.pem')]
|
||||
key: [Bun.file("./key1.pem"), Bun.file("./key2.pem")],
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
@@ -76,7 +76,7 @@ await transpiler.transform("<div>hi!</div>", "tsx");
|
||||
```
|
||||
|
||||
{% details summary="Nitty gritty" %}
|
||||
The `.tranform()` method runs the transpiler in Bun's worker threadpool, so if you run it 100 times, it will run it across `Math.floor($cpu_count * 0.8)` threads, without blocking the main JavaScript thread.
|
||||
The `.transform()` method runs the transpiler in Bun's worker threadpool, so if you run it 100 times, it will run it across `Math.floor($cpu_count * 0.8)` threads, without blocking the main JavaScript thread.
|
||||
|
||||
If your code uses a macro, it will potentially spawn a new copy of Bun's JavaScript runtime environment in that new thread.
|
||||
{% /details %}
|
||||
@@ -160,7 +160,6 @@ export const name = "hello";
|
||||
`;
|
||||
|
||||
const result = transpiler.scanImports(code);
|
||||
`);
|
||||
```
|
||||
|
||||
```json#Results
|
||||
|
||||
@@ -43,7 +43,7 @@ This is analogous to the [`require.main = module` trick](https://stackoverflow.c
|
||||
|
||||
## `Bun.sleep()`
|
||||
|
||||
`Bun.sleep(ms: number)` (added in Bun v0.5.6)
|
||||
`Bun.sleep(ms: number)`
|
||||
|
||||
Returns a `Promise` that resolves after the given number of milliseconds.
|
||||
|
||||
@@ -65,7 +65,7 @@ console.log("hello one second later!");
|
||||
|
||||
## `Bun.sleepSync()`
|
||||
|
||||
`Bun.sleepSync(ms: number)` (added in Bun v0.5.6)
|
||||
`Bun.sleepSync(ms: number)`
|
||||
|
||||
A blocking synchronous version of `Bun.sleep`.
|
||||
|
||||
@@ -108,7 +108,7 @@ console.log(ls); // null
|
||||
|
||||
## `Bun.peek()`
|
||||
|
||||
`Bun.peek(prom: Promise)` (added in Bun v0.2.2)
|
||||
`Bun.peek(prom: Promise)`
|
||||
|
||||
Reads a promise's result without `await` or `.then`, but only if the promise has already fulfilled or rejected.
|
||||
|
||||
@@ -183,7 +183,7 @@ const currentFile = import.meta.url;
|
||||
Bun.openInEditor(currentFile);
|
||||
```
|
||||
|
||||
You can override this via the `debug.editor` setting in your [`bunfig.toml`](/docs/runtime/configuration)
|
||||
You can override this via the `debug.editor` setting in your [`bunfig.toml`](/docs/runtime/bunfig)
|
||||
|
||||
```toml-diff#bunfig.toml
|
||||
+ [debug]
|
||||
@@ -204,7 +204,7 @@ Bun.ArrayBufferSink;
|
||||
|
||||
## `Bun.deepEquals()`
|
||||
|
||||
Nestedly checks if two objects are equivalent. This is used internally by `expect().toEqual()` in `bun:test`.
|
||||
Recursively checks if two objects are equivalent. This is used internally by `expect().toEqual()` in `bun:test`.
|
||||
|
||||
```ts
|
||||
const foo = { a: 1, b: 2, c: { d: 3 } };
|
||||
|
||||
@@ -87,7 +87,7 @@ ws.send(new Uint8Array([1, 2, 3])); // TypedArray | DataView
|
||||
|
||||
### Headers
|
||||
|
||||
Once the upgrade succeeds, Bun will send a `101 Switching Protocols` response per the [spec](https://developer.mozilla.org/en-US/docs/Web/HTTP/Protocol_upgrade_mechanism). Additional `headers` can be attched to this `Response` in the call to `server.upgrade()`.
|
||||
Once the upgrade succeeds, Bun will send a `101 Switching Protocols` response per the [spec](https://developer.mozilla.org/en-US/docs/Web/HTTP/Protocol_upgrade_mechanism). Additional `headers` can be attached to this `Response` in the call to `server.upgrade()`.
|
||||
|
||||
```ts
|
||||
Bun.serve({
|
||||
@@ -161,7 +161,7 @@ socket.addEventListener("message", event => {
|
||||
|
||||
### Pub/Sub
|
||||
|
||||
Bun's `ServerWebSocket` implementation implements a native publish-subscribe API for topic-based broadcasting. Individual sockets can `.subscribe()` to a topic (specified with a string identifier) and `.publish()` messages to all other subscribers to that topic. This topic-based broadcast API is similar to [MQTT](https://en.wikipedia.org/wiki/MQTT) and [Redis Pub/Sub](https://redis.io/topics/pubsub).
|
||||
Bun's `ServerWebSocket` implementation implements a native publish-subscribe API for topic-based broadcasting. Individual sockets can `.subscribe()` to a topic (specified with a string identifier) and `.publish()` messages to all other subscribers to that topic (excluding itself). This topic-based broadcast API is similar to [MQTT](https://en.wikipedia.org/wiki/MQTT) and [Redis Pub/Sub](https://redis.io/topics/pubsub).
|
||||
|
||||
```ts
|
||||
const server = Bun.serve<{ username: string }>({
|
||||
@@ -200,7 +200,18 @@ const server = Bun.serve<{ username: string }>({
|
||||
console.log(`Listening on ${server.hostname}:${server.port}`);
|
||||
```
|
||||
|
||||
Calling `.publish(data)` will send the message to all subscribers of a topic _except_ the socket that called `.publish()`.
|
||||
Calling `.publish(data)` will send the message to all subscribers of a topic _except_ the socket that called `.publish()`. To send a message to all subscribers of a topic, use the `.publish()` method on the `Server` instance.
|
||||
|
||||
```ts
|
||||
const server = Bun.serve({
|
||||
websocket: {
|
||||
// ...
|
||||
},
|
||||
});
|
||||
|
||||
// listen for some external event
|
||||
server.publish("the-group-chat", "Hello world");
|
||||
```
|
||||
|
||||
### Compression
|
||||
|
||||
@@ -236,7 +247,11 @@ This gives you better control over backpressure in your server.
|
||||
|
||||
## Connect to a `Websocket` server
|
||||
|
||||
To connect to an external socket server, either from a browser or from Bun, create an instance of `WebSocket` with the constructor.
|
||||
{% callout %}
|
||||
**🚧** — The `WebSocket` client still does not pass the full [Autobahn test suite](https://github.com/crossbario/autobahn-testsuite) and should not be considered ready for production.
|
||||
{% /callout %}
|
||||
|
||||
Bun implements the `WebSocket` class. To create a WebSocket client that connects to a `ws://` or `wss://` server, create an instance of `WebSocket`, as you would in the browser.
|
||||
|
||||
```ts
|
||||
const socket = new WebSocket("ws://localhost:3000");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{% callout %}
|
||||
`Worker` support was added in Bun v0.7.0.
|
||||
**🚧** — The `Worker` API is still experimental and should not be considered ready for production.
|
||||
{% /callout %}
|
||||
|
||||
[`Worker`](https://developer.mozilla.org/en-US/docs/Web/API/Worker) lets you start and communicate with a new JavaScript instance running on a separate thread while sharing I/O resources with the main thread.
|
||||
@@ -10,7 +10,7 @@ Bun implements a minimal version of the [Web Workers API](https://developer.mozi
|
||||
|
||||
Like in browsers, [`Worker`](https://developer.mozilla.org/en-US/docs/Web/API/Worker) is a global. Use it to create a new worker thread.
|
||||
|
||||
From the main thread:
|
||||
### From the main thread
|
||||
|
||||
```js#Main_thread
|
||||
const workerURL = new URL("worker.ts", import.meta.url).href;
|
||||
@@ -22,16 +22,25 @@ worker.onmessage = event => {
|
||||
};
|
||||
```
|
||||
|
||||
Worker thread:
|
||||
### Worker thread
|
||||
|
||||
```ts#worker.ts_(Worker_thread)
|
||||
// prevents TS errors
|
||||
declare var self: Worker;
|
||||
|
||||
self.onmessage = (event: MessageEvent) => {
|
||||
console.log(event.data);
|
||||
postMessage("world");
|
||||
};
|
||||
```
|
||||
|
||||
You can use `import`/`export` syntax in your worker code. Unlike in browsers, there's no need to specify `{type: "module"}` to use ES Modules.
|
||||
To prevent TypeScript errors when using `self`, add this line to the top of your worker file.
|
||||
|
||||
```ts
|
||||
declare var self: Worker;
|
||||
```
|
||||
|
||||
You can use `import` and `export` syntax in your worker code. Unlike in browsers, there's no need to specify `{type: "module"}` to use ES Modules.
|
||||
|
||||
To simplify error handling, the initial script to load is resolved at the time `new Worker(url)` is called.
|
||||
|
||||
@@ -123,14 +132,14 @@ By default, an active `Worker` will keep the main (spawning) process alive, so a
|
||||
|
||||
### `worker.unref()`
|
||||
|
||||
To stop a running worker from keeping the process alive, call `worker.unref()`. This decouples the lifetime of the worker to the lifetime of the main process, and is equivlent to what Node.js' `worker_threads` does.
|
||||
To stop a running worker from keeping the process alive, call `worker.unref()`. This decouples the lifetime of the worker to the lifetime of the main process, and is equivalent to what Node.js' `worker_threads` does.
|
||||
|
||||
```ts
|
||||
const worker = new Worker(new URL("worker.ts", import.meta.url).href);
|
||||
worker.unref();
|
||||
```
|
||||
|
||||
Note: `worker.unref()` is not available in browers.
|
||||
Note: `worker.unref()` is not available in browsers.
|
||||
|
||||
### `worker.ref()`
|
||||
|
||||
@@ -151,7 +160,7 @@ const worker = new Worker(new URL("worker.ts", import.meta.url).href, {
|
||||
});
|
||||
```
|
||||
|
||||
Note: `worker.ref()` is not available in browers.
|
||||
Note: `worker.ref()` is not available in browsers.
|
||||
|
||||
## Memory usage with `smol`
|
||||
|
||||
|
||||
@@ -52,7 +52,6 @@ Run this with `bun cat.js /path/to/big/file`.
|
||||
## Reading from standard input
|
||||
|
||||
```ts
|
||||
// As of Bun v0.3.0, console is an AsyncIterable
|
||||
for await (const line of console) {
|
||||
// line of text from stdin
|
||||
console.log(line);
|
||||
|
||||
@@ -28,7 +28,7 @@ All imported files and packages are bundled into the executable, along with a co
|
||||
- `--outdir` — use `outfile` instead.
|
||||
- `--external`
|
||||
- `--splitting`
|
||||
- `--publicPath`
|
||||
- `--public-path`
|
||||
|
||||
{% /callout %}
|
||||
|
||||
|
||||
@@ -29,6 +29,10 @@ The bundler is a key piece of infrastructure in the JavaScript ecosystem. As a b
|
||||
|
||||
Let's jump into the bundler API.
|
||||
|
||||
{% callout %}
|
||||
Note that the Bun bundler is not intended to replace `tsc` for typechecking or generating type declarations.
|
||||
{% /callout %}
|
||||
|
||||
## Basic example
|
||||
|
||||
Let's build our first bundle. You have the following two files, which implement a simple client-side rendered React app.
|
||||
@@ -132,6 +136,14 @@ Visit `http://localhost:5000` to see your bundled app in action.
|
||||
|
||||
{% /details %}
|
||||
|
||||
## Watch mode
|
||||
|
||||
Like the runtime and test runner, the bundler supports watch mode natively.
|
||||
|
||||
```sh
|
||||
$ bun build ./index.tsx --outdir ./out --watch
|
||||
```
|
||||
|
||||
## Content types
|
||||
|
||||
Like the Bun runtime, the bundler supports an array of file types out of the box. The following table breaks down the bundler's set of standard "loaders". Refer to [Bundler > File types](/docs/runtime/loaders) for full documentation.
|
||||
@@ -960,7 +972,7 @@ By specifying `.` as `root`, the generated file structure will look like this:
|
||||
|
||||
A prefix to be appended to any import paths in bundled code.
|
||||
|
||||
<!-- $ bun build ./index.tsx --outdir ./out --publicPath https://cdn.example.com -->
|
||||
<!-- $ bun build ./index.tsx --outdir ./out --public-path https://cdn.example.com -->
|
||||
|
||||
In many cases, generated bundles will contain no `import` statements. After all, the goal of bundling is to combine all of the code into a single file. However there are a number of cases with the generated bundles will contain `import` statements.
|
||||
|
||||
@@ -1084,7 +1096,7 @@ interface BuildArtifact extends Blob {
|
||||
The `outputs` array contains all the files that were generated by the build. Each artifact implements the `Blob` interface.
|
||||
|
||||
```ts
|
||||
const build = Bun.build({
|
||||
const build = await Bun.build({
|
||||
/* */
|
||||
});
|
||||
|
||||
@@ -1128,7 +1140,7 @@ Each artifact also contains the following properties:
|
||||
Similar to `BunFile`, `BuildArtifact` objects can be passed directly into `new Response()`.
|
||||
|
||||
```ts
|
||||
const build = Bun.build({
|
||||
const build = await Bun.build({
|
||||
/* */
|
||||
});
|
||||
|
||||
@@ -1144,7 +1156,7 @@ The Bun runtime implements special pretty-printing of `BuildArtifact` object to
|
||||
|
||||
```ts#Build_script
|
||||
// build.ts
|
||||
const build = Bun.build({/* */});
|
||||
const build = await Bun.build({/* */});
|
||||
|
||||
const artifact = build.outputs[0];
|
||||
console.log(artifact);
|
||||
|
||||
@@ -40,7 +40,7 @@ When a user visits this website, the files are loaded in the following order:
|
||||
|
||||
This approach works, it requires three round-trip HTTP requests before the browser is ready to render the page. On slow internet connections, this may add up to a non-trivial delay.
|
||||
|
||||
This example is extremely simplistic. A modern app may be loading dozens of modules from `node_modules`, each consisting of hundrends of files. Loading each of these files with a separate HTTP request becomes untenable very quickly. While most of these requests will be running in parallel, the number of round-trip requests can still be very high; plus, there are limits on how many simultaneous requests a browser can make.
|
||||
This example is extremely simplistic. A modern app may be loading dozens of modules from `node_modules`, each consisting of hundred of files. Loading each of these files with a separate HTTP request becomes untenable very quickly. While most of these requests will be running in parallel, the number of round-trip requests can still be very high; plus, there are limits on how many simultaneous requests a browser can make.
|
||||
|
||||
{% callout %}
|
||||
Some recent advances like modulepreload and HTTP/3 are intended to solve some of these problems, but at the moment bundling is still the most performant approach.
|
||||
|
||||
@@ -16,7 +16,7 @@ Parses the code and applies a set of default transforms, like dead-code eliminat
|
||||
|
||||
**JavaScript + JSX.**. Default for `.js` and `.jsx`.
|
||||
|
||||
Same as the `js` loader, but JSX syntax is supported. By default, JSX is downconverted to plain JavaScript; the details of how this is done depends on the `jsx*` compiler options in your `tsconfig.json`. Refer to the TypeScript documentation [on JSX](https://www.typescriptlang.org/docs/handbook/jsx.html) for more information.
|
||||
Same as the `js` loader, but JSX syntax is supported. By default, JSX is down-converted to plain JavaScript; the details of how this is done depends on the `jsx*` compiler options in your `tsconfig.json`. Refer to the TypeScript documentation [on JSX](https://www.typescriptlang.org/docs/handbook/jsx.html) for more information.
|
||||
|
||||
### `ts`
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ if (returnFalse()) {
|
||||
}
|
||||
```
|
||||
|
||||
## Serializablility
|
||||
## Serializability
|
||||
|
||||
Bun's transpiler needs to be able to serialize the result of the macro so it can be inlined into the AST. All JSON-compatible data structures are supported:
|
||||
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
{% callout %}
|
||||
**Note** — Introduced in Bun v0.1.11.
|
||||
{% /callout %}
|
||||
|
||||
Bun provides a universal plugin API that can be used to extend both the _runtime_ and _bundler_.
|
||||
|
||||
Plugins intercept imports and perform custom loading logic: reading files, transpiling code, etc. They can be used to add support for additional file types, like `.scss` or `.yaml`. In the context of Bun's bundler, plugins can be used to implement framework-level features like CSS extraction, macros, and client-server code co-location.
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
{% callout %}
|
||||
**Note** — Available in Bun v0.6.0 and later.
|
||||
{% /callout %}
|
||||
|
||||
Bun's bundler API is inspired heavily by [esbuild](https://esbuild.github.io/). Migrating to Bun's bundler from esbuild should be relatively painless. This guide will briefly explain why you might consider migrating to Bun's bundler and provide a side-by-side API comparison reference for those who are already familiar with esbuild's API.
|
||||
|
||||
There are a few behavioral differences to note.
|
||||
@@ -129,13 +125,13 @@ 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 downleveling at this time.
|
||||
- No supported. Bun's bundler performs no syntactic down-leveling at this time.
|
||||
|
||||
---
|
||||
|
||||
- `--watch`
|
||||
- n/a
|
||||
- Not applicable
|
||||
- `--watch`
|
||||
- No differences
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@ If you pass `-y` or `--yes`, it will assume you want to continue without asking
|
||||
|
||||
At the end, it runs `bun install` to install `bun-types`.
|
||||
|
||||
Added in Bun v0.1.7.
|
||||
|
||||
#### How is `bun init` different than `bun create`?
|
||||
|
||||
`bun init` is for blank projects. `bun create` applies templates.
|
||||
|
||||
@@ -47,7 +47,7 @@ registry = "https://registry.yarnpkg.com/"
|
||||
# Install for production? This is the equivalent to the "--production" CLI argument
|
||||
production = false
|
||||
|
||||
# Disallow changes to lockfile? This is the equivalent to the "--fozen-lockfile" CLI argument
|
||||
# Disallow changes to lockfile? This is the equivalent to the "--frozen-lockfile" CLI argument
|
||||
frozenLockfile = false
|
||||
|
||||
# Don't actually install
|
||||
@@ -89,12 +89,6 @@ disableManifest = false
|
||||
# Note: it does not load the lockfile, it just converts bun.lockb into a yarn.lock
|
||||
print = "yarn"
|
||||
|
||||
# Path to read bun.lockb from
|
||||
path = "bun.lockb"
|
||||
|
||||
# Path to save bun.lockb to
|
||||
savePath = "bun.lockb"
|
||||
|
||||
# Save the lockfile to disk
|
||||
save = true
|
||||
|
||||
@@ -142,8 +136,6 @@ export interface Cache {
|
||||
|
||||
export interface Lockfile {
|
||||
print?: "yarn";
|
||||
path: string;
|
||||
savePath: string;
|
||||
save: boolean;
|
||||
}
|
||||
```
|
||||
@@ -156,7 +148,6 @@ Environment variables have a higher priority than `bunfig.toml`.
|
||||
| -------------------------------- | ------------------------------------------------------------- |
|
||||
| BUN_CONFIG_REGISTRY | Set an npm registry (default: <https://registry.npmjs.org>) |
|
||||
| BUN_CONFIG_TOKEN | Set an auth token (currently does nothing) |
|
||||
| BUN_CONFIG_LOCKFILE_SAVE_PATH | File path to save the lockfile to (default: bun.lockb) |
|
||||
| BUN_CONFIG_YARN_LOCKFILE | Save a Yarn v1-style yarn.lock |
|
||||
| BUN_CONFIG_LINK_NATIVE_BINS | Point `bin` in package.json to a platform-specific dependency |
|
||||
| BUN_CONFIG_SKIP_SAVE_LOCKFILE | Don’t save a lockfile |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Bundling is currently an important mechanism for building complex web apps.
|
||||
|
||||
Modern apps typically consist of a large number of files and package dependencies. Despite the fact that modern browsers support [ES Module](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) imports, it's still too slow to fetch each file via inidividual HTTP requests. _Bundling_ is the process of concatenating several source files into a single large file that can be loaded in a single request.
|
||||
Modern apps typically consist of a large number of files and package dependencies. Despite the fact that modern browsers support [ES Module](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) imports, it's still too slow to fetch each file via individual HTTP requests. _Bundling_ is the process of concatenating several source files into a single large file that can be loaded in a single request.
|
||||
|
||||
{% callout %}
|
||||
**On bundling** — Despite recent advances like [`modulepreload`](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel/modulepreload) and [HTTP/3](https://en.wikipedia.org/wiki/HTTP/3), bundling is still the most performant approach.
|
||||
|
||||
@@ -50,7 +50,7 @@ Running `bun create` performs the following steps:
|
||||
- Initialize a fresh Git repo. Opt out with the `--no-git` flag.
|
||||
- Run the template's configured `start` script, if defined.
|
||||
|
||||
## Official templates
|
||||
<!-- ## Official templates
|
||||
|
||||
The following official templates are available.
|
||||
|
||||
@@ -73,7 +73,7 @@ Welcome to bun! Create a new project by pasting any of the following:
|
||||
|
||||
{% callout %}
|
||||
⚡️ **Speed** — At the time of writing, `bun create react app` runs ~11x faster on a M1 Macbook Pro than `yarn create react-app app`.
|
||||
{% /callout %}
|
||||
{% /callout %} -->
|
||||
|
||||
## GitHub repos
|
||||
|
||||
|
||||
@@ -23,9 +23,7 @@ sudo apt install --install-recommends linux-generic-hwe-20.04
|
||||
|
||||
{% /details %}
|
||||
|
||||
## Manage dependencies
|
||||
|
||||
### `bun install`
|
||||
## `bun install`
|
||||
|
||||
To install all dependencies of a project:
|
||||
|
||||
@@ -43,7 +41,7 @@ Running `bun install` will:
|
||||
- **Run** your project's `{pre|post}install` and `{pre|post}prepare` scripts at the appropriate time. For security reasons Bun _does not execute_ lifecycle scripts of installed dependencies.
|
||||
- **Write** a `bun.lockb` lockfile to the project root.
|
||||
|
||||
To install in production mode (i.e. without `devDependencies`):
|
||||
To install in production mode (i.e. without `devDependencies` or `optionalDependencies`):
|
||||
|
||||
```bash
|
||||
$ bun install --production
|
||||
@@ -69,7 +67,7 @@ $ bun install --silent # no logging
|
||||
```
|
||||
|
||||
{% details summary="Configuring behavior" %}
|
||||
The default behavior of `bun install` can be configured in `bun.toml`:
|
||||
The default behavior of `bun install` can be configured in `bunfig.toml`:
|
||||
|
||||
```toml
|
||||
[install]
|
||||
@@ -95,7 +93,7 @@ dryRun = false
|
||||
|
||||
{% /details %}
|
||||
|
||||
### `bun add`
|
||||
## `bun add`
|
||||
|
||||
To add a particular package:
|
||||
|
||||
@@ -177,7 +175,7 @@ To view a complete list of options for a given command:
|
||||
$ bun add --help
|
||||
```
|
||||
|
||||
### `bun remove`
|
||||
## `bun remove`
|
||||
|
||||
To remove a dependency:
|
||||
|
||||
@@ -185,7 +183,17 @@ To remove a dependency:
|
||||
$ bun remove preact
|
||||
```
|
||||
|
||||
## Local packages (`bun link`)
|
||||
## `bun update`
|
||||
|
||||
To update all dependencies to the latest version _that's compatible with the version range specified in your `package.json`_:
|
||||
|
||||
```sh
|
||||
$ bun update
|
||||
```
|
||||
|
||||
This will not edit your `package.json`. There's currently no command to force-update all dependencies to the latest version regardless version ranges.
|
||||
|
||||
## `bun link`
|
||||
|
||||
Use `bun link` in a local directory to register the current package as a "linkable" package.
|
||||
|
||||
@@ -197,7 +205,7 @@ $ cat package.json
|
||||
"version": "1.0.0"
|
||||
}
|
||||
$ bun link
|
||||
bun link v0.5.7 (7416672e)
|
||||
bun link v1.x (7416672e)
|
||||
Success! Registered "cool-pkg"
|
||||
|
||||
To use cool-pkg in a project, run:
|
||||
@@ -289,7 +297,7 @@ Bun supports a variety of protocols, including [`github`](https://docs.npmjs.com
|
||||
|
||||
## Tarball dependencies
|
||||
|
||||
A package name can correspond to a publically hosted `.tgz` file. During `bun install`, Bun will download and install the package from the specified tarball URL, rather than from the package registry.
|
||||
A package name can correspond to a publicly hosted `.tgz` file. During `bun install`, Bun will download and install the package from the specified tarball URL, rather than from the package registry.
|
||||
|
||||
```json#package.json
|
||||
{
|
||||
|
||||
@@ -1,5 +1,28 @@
|
||||
The `bun` CLI can be used to execute JavaScript/TypeScript files, `package.json` scripts, and [executable packages](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#bin).
|
||||
|
||||
## Performance
|
||||
|
||||
Bun is designed to start fast and run fast.
|
||||
|
||||
Under the hood Bun uses the [JavaScriptCore engine](https://developer.apple.com/documentation/javascriptcore), which is developed by Apple for Safari. In most cases, the startup and running performance is faster than V8, the engine used by Node.js and Chromium-based browsers. Its transpiler and runtime are written in Zig, a modern, high-performance language. On Linux, this translates into startup times [4x faster](https://twitter.com/jarredsumner/status/1499225725492076544) than Node.js.
|
||||
|
||||
{% table %}
|
||||
|
||||
---
|
||||
|
||||
- `bun hello.js`
|
||||
- `5.2ms`
|
||||
|
||||
---
|
||||
|
||||
- `node hello.js`
|
||||
- `25.1ms`
|
||||
|
||||
{% /table %}
|
||||
{% caption content="Running a simple Hello World script on Linux" /%}
|
||||
|
||||
<!-- {% image src="/images/bun-run-speed.jpeg" caption="Bun vs Node.js vs Deno running Hello World" /%} -->
|
||||
|
||||
<!-- ## Speed -->
|
||||
|
||||
<!--
|
||||
@@ -26,10 +49,11 @@ $ bun run index.ts
|
||||
$ bun run index.tsx
|
||||
```
|
||||
|
||||
The "naked" `bun` command is equivalent to `bun run`.
|
||||
Alternatively, you can omit the `run` keyword and use the "naked" command; it behaves identically.
|
||||
|
||||
```bash
|
||||
$ bun index.tsx
|
||||
$ bun index.js
|
||||
```
|
||||
|
||||
### `--watch`
|
||||
@@ -40,12 +64,19 @@ To run a file in watch mode, use the `--watch` flag.
|
||||
$ bun --watch run index.tsx
|
||||
```
|
||||
|
||||
### `--smol`
|
||||
|
||||
{% callout %}
|
||||
Added in Bun v0.7.0.
|
||||
**Note** — When using `bun run`, put Bun flags like `--watch` immediately after `bun`.
|
||||
|
||||
```bash
|
||||
$ bun --watch run dev # ✔️ do this
|
||||
$ bun run dev --watch # ❌ don't do this
|
||||
```
|
||||
|
||||
Flags that occur at the end of the command will be ignored and passed through to the `"dev"` script itself.
|
||||
{% /callout %}
|
||||
|
||||
### `--smol`
|
||||
|
||||
In memory-constrained environments, use the `--smol` flag to reduce memory usage at a cost to performance.
|
||||
|
||||
```bash
|
||||
@@ -58,6 +89,10 @@ $ bun --smol run index.tsx
|
||||
Compare to `npm run <script>` or `yarn <script>`
|
||||
{% /note %}
|
||||
|
||||
```sh
|
||||
$ bun [bun flags] run <script> [script flags]
|
||||
```
|
||||
|
||||
Your `package.json` can define a number of named `"scripts"` that correspond to shell commands.
|
||||
|
||||
```jsonc
|
||||
@@ -70,10 +105,10 @@ Your `package.json` can define a number of named `"scripts"` that correspond to
|
||||
}
|
||||
```
|
||||
|
||||
Use `bun <script>` to execute these scripts.
|
||||
Use `bun run <script>` to execute these scripts.
|
||||
|
||||
```bash
|
||||
$ bun clean
|
||||
$ bun run clean
|
||||
$ rm -rf dist && echo 'Done.'
|
||||
Cleaning...
|
||||
Done.
|
||||
@@ -108,22 +143,18 @@ quickstart scripts:
|
||||
|
||||
Bun respects lifecycle hooks. For instance, `bun run clean` will execute `preclean` and `postclean`, if defined. If the `pre<script>` fails, Bun will not execute the script itself.
|
||||
|
||||
## Environment variables
|
||||
### `--bun`
|
||||
|
||||
Bun automatically loads environment variables from `.env` files before running a file, script, or executable. The following files are checked, in order:
|
||||
It's common for `package.json` scripts to reference locally-installed CLIs like `vite` or `next`. These CLIs are often JavaScript files marked with a [shebang](<https://en.wikipedia.org/wiki/Shebang_(Unix)>) to indicate that they should be executed with `node`.
|
||||
|
||||
1. `.env.local` (first)
|
||||
2. `NODE_ENV` === `"production"` ? `.env.production` : `.env.development`
|
||||
3. `.env`
|
||||
```js
|
||||
#!/usr/bin/env node
|
||||
|
||||
To debug environment variables, run `bun run env` to view a list of resolved environment variables.
|
||||
// do stuff
|
||||
```
|
||||
|
||||
## Performance
|
||||
By default, Bun respects this shebang and executes the script with `node`. However, you can override this behavior with the `--bun` flag. For Node.js-based CLIs, this will run the CLI with Bun instead of Node.js.
|
||||
|
||||
Bun is designed to start fast and run fast.
|
||||
|
||||
Under the hood Bun uses the [JavaScriptCore engine](https://developer.apple.com/documentation/javascriptcore), which is developed by Apple for Safari. In most cases, the startup and running performance is faster than V8, the engine used by Node.js and Chromium-based browsers. Its transpiler and runtime are written in Zig, a modern, high-performance language. On Linux, this translates into startup times [4x faster](https://twitter.com/jarredsumner/status/1499225725492076544) than Node.js.
|
||||
|
||||
{% image src="/images/bun-run-speed.jpeg" caption="Bun vs Node.js vs Deno running Hello World" /%}
|
||||
|
||||
<!-- If no `node_modules` directory is found in the working directory or above, Bun will abandon Node.js-style module resolution in favor of the `Bun module resolution algorithm`. Under Bun-style module resolution, all packages are _auto-installed_ on the fly into a [global module cache](/docs/install/cache). For full details on this algorithm, refer to [Runtime > Modules](/docs/runtime/modules). -->
|
||||
```bash
|
||||
$ bun run --bun vite
|
||||
```
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Bun ships with a fast built-in test runner. Tests are executed with the Bun runtime, and support the following features.
|
||||
Bun ships with a fast, built-in, Jest-compatible test runner. Tests are executed with the Bun runtime, and support the following features.
|
||||
|
||||
- TypeScript and JSX
|
||||
- Lifecycle hooks
|
||||
@@ -7,6 +7,10 @@ Bun ships with a fast built-in test runner. Tests are executed with the Bun runt
|
||||
- Watch mode with `--watch`
|
||||
- Script pre-loading with `--preload`
|
||||
|
||||
{% callout %}
|
||||
Bun aims for compatibility with Jest, but not everything is implemented. To track compatibility, see [this tracking issue](https://github.com/oven-sh/bun/issues/1825).
|
||||
{% /callout %}
|
||||
|
||||
## Run tests
|
||||
|
||||
```bash
|
||||
@@ -103,7 +107,11 @@ See [Test > Lifecycle](/docs/test/lifecycle) for complete documentation.
|
||||
|
||||
## Mocks
|
||||
|
||||
Create mocks with the `mock` function. Mocks are automatically reset between tests.
|
||||
{% callout %}
|
||||
Module mocking (`jest.mock()`) is not yet supported. Track support for it [here](https://github.com/oven-sh/bun/issues/5394).
|
||||
{% /callout %}
|
||||
|
||||
Create mock functions with the `mock` function. Mocks are automatically reset between tests.
|
||||
|
||||
```ts
|
||||
import { test, expect, mock } from "bun:test";
|
||||
@@ -117,11 +125,38 @@ test("random", async () => {
|
||||
});
|
||||
```
|
||||
|
||||
Alternatively, you can use `jest.fn()`, it behaves identically.
|
||||
|
||||
```ts-diff
|
||||
- import { test, expect, mock } from "bun:test";
|
||||
+ import { test, expect, jest } from "bun:test";
|
||||
|
||||
- const random = mock(() => Math.random());
|
||||
+ const random = jest.fn(() => Math.random());
|
||||
```
|
||||
|
||||
See [Test > Mocks](/docs/test/mocks) for complete documentation.
|
||||
|
||||
## Snapshot testing
|
||||
|
||||
Snapshots are supported by `bun test`. See [Test > Snapshots](/docs/test/snapshots) for complete documentation.
|
||||
Snapshots are supported by `bun test`.
|
||||
|
||||
```ts
|
||||
// example usage of toMatchSnapshot
|
||||
import { test, expect } from "bun:test";
|
||||
|
||||
test("snapshot", async () => {
|
||||
expect({ a: 1 }).toMatchSnapshot();
|
||||
});
|
||||
```
|
||||
|
||||
To update snapshots, use the `--update-snapshots` flag.
|
||||
|
||||
```sh
|
||||
$ bun test --update-snapshots
|
||||
```
|
||||
|
||||
See [Test > Snapshots](/docs/test/snapshots) for complete documentation.
|
||||
|
||||
## UI & DOM testing
|
||||
|
||||
|
||||
@@ -1,151 +0,0 @@
|
||||
{% callout %}
|
||||
**Warning** — This will soon have breaking changes. It was designed when Bun was mostly a dev server and not a JavaScript runtime.
|
||||
{% /callout %}
|
||||
|
||||
Frameworks preconfigure Bun to enable developers to use Bun with their existing tooling.
|
||||
|
||||
Frameworks are configured via the `framework` object in the `package.json` of the framework (not in the application’s `package.json`):
|
||||
|
||||
Here is an example:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "bun-framework-next",
|
||||
"version": "0.0.0-18",
|
||||
"description": "",
|
||||
"framework": {
|
||||
"displayName": "Next.js",
|
||||
"static": "public",
|
||||
"assetPrefix": "_next/",
|
||||
"router": {
|
||||
"dir": ["pages", "src/pages"],
|
||||
"extensions": [".js", ".ts", ".tsx", ".jsx"]
|
||||
},
|
||||
"css": "onimportcss",
|
||||
"development": {
|
||||
"client": "client.development.tsx",
|
||||
"fallback": "fallback.development.tsx",
|
||||
"server": "server.development.tsx",
|
||||
"css": "onimportcss",
|
||||
"define": {
|
||||
"client": {
|
||||
".env": "NEXT_PUBLIC_",
|
||||
"defaults": {
|
||||
"process.env.__NEXT_TRAILING_SLASH": "false",
|
||||
"process.env.NODE_ENV": "\"development\"",
|
||||
"process.env.__NEXT_ROUTER_BASEPATH": "''",
|
||||
"process.env.__NEXT_SCROLL_RESTORATION": "false",
|
||||
"process.env.__NEXT_I18N_SUPPORT": "false",
|
||||
"process.env.__NEXT_HAS_REWRITES": "false",
|
||||
"process.env.__NEXT_ANALYTICS_ID": "null",
|
||||
"process.env.__NEXT_OPTIMIZE_CSS": "false",
|
||||
"process.env.__NEXT_CROSS_ORIGIN": "''",
|
||||
"process.env.__NEXT_STRICT_MODE": "false",
|
||||
"process.env.__NEXT_IMAGE_OPTS": "null"
|
||||
}
|
||||
},
|
||||
"server": {
|
||||
".env": "NEXT_",
|
||||
"defaults": {
|
||||
"process.env.__NEXT_TRAILING_SLASH": "false",
|
||||
"process.env.__NEXT_OPTIMIZE_FONTS": "false",
|
||||
"process.env.NODE_ENV": "\"development\"",
|
||||
"process.env.__NEXT_OPTIMIZE_IMAGES": "false",
|
||||
"process.env.__NEXT_OPTIMIZE_CSS": "false",
|
||||
"process.env.__NEXT_ROUTER_BASEPATH": "''",
|
||||
"process.env.__NEXT_SCROLL_RESTORATION": "false",
|
||||
"process.env.__NEXT_I18N_SUPPORT": "false",
|
||||
"process.env.__NEXT_HAS_REWRITES": "false",
|
||||
"process.env.__NEXT_ANALYTICS_ID": "null",
|
||||
"process.env.__NEXT_CROSS_ORIGIN": "''",
|
||||
"process.env.__NEXT_STRICT_MODE": "false",
|
||||
"process.env.__NEXT_IMAGE_OPTS": "null",
|
||||
"global": "globalThis",
|
||||
"window": "undefined"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Here are type definitions:
|
||||
|
||||
```ts
|
||||
type Framework = Environment & {
|
||||
// This changes what’s printed in the console on load
|
||||
displayName?: string;
|
||||
|
||||
// This allows a prefix to be added (and ignored) to requests.
|
||||
// Useful for integrating an existing framework that expects internal routes to have a prefix
|
||||
// e.g. "_next"
|
||||
assetPrefix?: string;
|
||||
|
||||
development?: Environment;
|
||||
production?: Environment;
|
||||
|
||||
// The directory used for serving unmodified assets like fonts and images
|
||||
// Defaults to "public" if exists, else "static", else disabled.
|
||||
static?: string;
|
||||
|
||||
// "onimportcss" disables the automatic "onimportcss" feature
|
||||
// If the framework does routing, you may want to handle CSS manually
|
||||
// "facade" removes CSS imports from JavaScript files,
|
||||
// and replaces an imported object with a proxy that mimics CSS module support without doing any class renaming.
|
||||
css?: "onimportcss" | "facade";
|
||||
|
||||
// Bun's filesystem router
|
||||
router?: Router;
|
||||
};
|
||||
|
||||
type Define = {
|
||||
// By passing ".env", Bun will automatically load .env.local, .env.development, and .env if exists in the project root
|
||||
// (in addition to the processes’ environment variables)
|
||||
// When "*", all environment variables will be automatically injected into the JavaScript loader
|
||||
// When a string like "NEXT_PUBLIC_", only environment variables starting with that prefix will be injected
|
||||
|
||||
".env": string | "*";
|
||||
|
||||
// These environment variables will be injected into the JavaScript loader
|
||||
// These are the equivalent of Webpack’s resolve.alias and esbuild’s --define.
|
||||
// Values are parsed as JSON, so they must be valid JSON. The only exception is '' is a valid string, to simplify writing stringified JSON in JSON.
|
||||
// If not set, `process.env.NODE_ENV` will be transformed into "development".
|
||||
"defaults": Record<string, string>;
|
||||
};
|
||||
|
||||
type Environment = {
|
||||
// This is a wrapper for the client-side entry point for a route.
|
||||
// This allows frameworks to run initialization code on pages.
|
||||
client: string;
|
||||
// This is a wrapper for the server-side entry point for a route.
|
||||
// This allows frameworks to run initialization code on pages.
|
||||
server: string;
|
||||
// This runs when "server" code fails to load due to an exception.
|
||||
fallback: string;
|
||||
|
||||
// This is how environment variables and .env is configured.
|
||||
define?: Define;
|
||||
};
|
||||
|
||||
// Bun's filesystem router
|
||||
// Currently, Bun supports pages by either an absolute match or a parameter match.
|
||||
// pages/index.tsx will be executed on navigation to "/" and "/index"
|
||||
// pages/posts/[id].tsx will be executed on navigation to "/posts/123"
|
||||
// Routes & parameters are automatically passed to `fallback` and `server`.
|
||||
type Router = {
|
||||
// This determines the folder to look for pages
|
||||
dir: string[];
|
||||
|
||||
// These are the allowed file extensions for pages.
|
||||
extensions?: string[];
|
||||
};
|
||||
```
|
||||
|
||||
To use a framework, you pass `bun bun --use package-name`.
|
||||
|
||||
Your framework’s `package.json` `name` should start with `bun-framework-`. This is so that people can type something like `bun bun --use next` and it will check `bun-framework-next` first. This is similar to how Babel plugins tend to start with `babel-plugin-`.
|
||||
|
||||
For developing frameworks, you can also do `bun bun --use ./relative-path-to-framework`.
|
||||
|
||||
If you’re interested in adding a framework integration, please reach out. There’s a lot here, and it’s not entirely documented yet.
|
||||
@@ -1,33 +0,0 @@
|
||||
To create a new Next.js app with bun:
|
||||
|
||||
```bash
|
||||
$ bun create next ./app
|
||||
$ cd app
|
||||
$ bun dev # start dev server
|
||||
```
|
||||
|
||||
To use an existing Next.js app with bun:
|
||||
|
||||
```bash
|
||||
$ bun add bun-framework-next
|
||||
$ echo "framework = 'next'" > bunfig.toml
|
||||
$ bun bun # bundle dependencies
|
||||
$ bun dev # start dev server
|
||||
```
|
||||
|
||||
Many of Next.js’ features are supported, but not all.
|
||||
|
||||
Here’s what doesn’t work yet:
|
||||
|
||||
- `getStaticPaths`
|
||||
- same-origin `fetch` inside of `getStaticProps` or `getServerSideProps`
|
||||
- locales, zones, `assetPrefix` (workaround: change `--origin \"http://localhost:3000/assetPrefixInhere\"`)
|
||||
- `next/image` is polyfilled to a regular `<img src>` tag.
|
||||
- `proxy` and anything else in `next.config.js`
|
||||
- API routes, middleware (middleware is easier to support, though! Similar SSR API)
|
||||
- styled-jsx (technically not Next.js, but often used with it)
|
||||
- React Server Components
|
||||
|
||||
When using Next.js, Bun automatically reads configuration from `.env.local`, `.env.development` and `.env` (in that order). `process.env.NEXT_PUBLIC_` and `process.env.NEXT_` automatically are replaced via `--define`.
|
||||
|
||||
Currently, any time you import new dependencies from `node_modules`, you will need to re-run `bun bun --use next`. This will eventually be automatic.
|
||||
@@ -1,36 +0,0 @@
|
||||
[Buchta](https://buchtajs.com) is a fullstack framework designed to take full advantage of Bun's strengths. It currently supports Preact and Svelte.
|
||||
|
||||
To get started:
|
||||
|
||||
```bash
|
||||
$ bunx buchta init myapp
|
||||
Project templates:
|
||||
- svelte
|
||||
- default
|
||||
- preact
|
||||
Name of template: preact
|
||||
Do you want TSX? y
|
||||
Do you want SSR? y
|
||||
Enable livereload? y
|
||||
Buchta Preact project was setup successfully!
|
||||
$ cd myapp
|
||||
$ bun install
|
||||
$ bunx buchta serve
|
||||
```
|
||||
|
||||
To implement a simple HTTP server with Buchta:
|
||||
|
||||
```ts#server.ts
|
||||
import { Buchta, type BuchtaRequest, type BuchtaResponse } from "buchta";
|
||||
|
||||
const app = new Buchta();
|
||||
|
||||
app.get("/api/hello/", (req: BuchtaRequest, res: BuchtaResponse) => {
|
||||
res.send("Hello, World!");
|
||||
});
|
||||
|
||||
app.run();
|
||||
```
|
||||
|
||||
|
||||
For more information, refer to Buchta's [documentation](https://buchtajs.com/docs/).
|
||||
@@ -2,7 +2,7 @@
|
||||
name: Convert a Blob to a ReadableStream
|
||||
---
|
||||
|
||||
The [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) class provides a number of methods for consuming its contents in different formats, inluding `.stream()`. This returns `Promise<ReadableStream>`.
|
||||
The [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) class provides a number of methods for consuming its contents in different formats, including `.stream()`. This returns `Promise<ReadableStream>`.
|
||||
|
||||
```ts
|
||||
const blob = new Blob(["hello world"]);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
name: Convert a Blob to a string
|
||||
---
|
||||
|
||||
The [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) class provides a number of methods for consuming its contents in different formats, inluding `.text()`.
|
||||
The [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) class provides a number of methods for consuming its contents in different formats, including `.text()`.
|
||||
|
||||
```ts
|
||||
const blob = new Blob(["hello world"]);
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
name: Build an app with Astro and Bun
|
||||
---
|
||||
|
||||
Initialize a fresh Astro app with `bunx create-astro`. The `create-astro` package detects when you are using `bunx` and will automatically install dependencies using `bun`.
|
||||
Initialize a fresh Astro app with `bun create astro`. The `create-astro` package detects when you are using `bunx` and will automatically install dependencies using `bun`.
|
||||
|
||||
```sh
|
||||
$ bunx create-astro
|
||||
$ bun create astro
|
||||
╭─────╮ Houston:
|
||||
│ ◠ ◡ ◠ We're glad to have you on board.
|
||||
╰─────╯
|
||||
|
||||
astro v2.10.5 Launch sequence initiated.
|
||||
astro v3.1.4 Launch sequence initiated.
|
||||
|
||||
dir Where should we create your new project?
|
||||
./fumbling-field
|
||||
@@ -55,21 +55,17 @@ By default, Bun will run the dev server with Node.js. To use the Bun runtime ins
|
||||
|
||||
```sh
|
||||
$ bunx --bun astro dev
|
||||
🚀 astro v2.10.5 started in 200ms
|
||||
🚀 astro v3.1.4 started in 200ms
|
||||
|
||||
┃ Local http://localhost:3000/
|
||||
┃ Local http://localhost:4321/
|
||||
┃ Network use --host to expose
|
||||
|
||||
01:48:34 PM [content] Watching src/content/ for changes
|
||||
01:48:34 PM [content] Types generated
|
||||
01:48:34 PM [astro] update /.astro/types.d.ts
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. Astro will hot-reload your app as you edit your source files.
|
||||
Open [http://localhost:4321](http://localhost:4321) with your browser to see the result. Astro will hot-reload your app as you edit your source files.
|
||||
|
||||
{% image src="https://github.com/vitejs/vite/assets/3084745/bb1d5063-32f4-4598-b33e-50b44a1c4e8a" caption="An Astro starter app running on Bun" %}
|
||||
{% image src="https://i.imgur.com/Dswiu6w.png" caption="An Astro v3 starter app running on Bun" %}
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
name: Create a Discord bot
|
||||
---
|
||||
|
||||
Discord.js works [out of the box](https://bun.sh/blog/bun-v0.6.7) with Bun. Let's write a simple bot. First create a directory and initialize it with `bun init`.
|
||||
Discord.js works out of the box with Bun. Let's write a simple bot. First create a directory and initialize it with `bun init`.
|
||||
|
||||
```bash
|
||||
mkdir my-bot
|
||||
@@ -74,4 +74,4 @@ Ready! Logged in as my-bot#1234
|
||||
|
||||
---
|
||||
|
||||
You're up and running with a bare-bones Discord.js bot! This is a basic guide to setting up your bot with Bun; we recommend the [official Discord docs](https://discordjs.guide/) for complete information on the `discord.js` API.
|
||||
You're up and running with a bare-bones Discord.js bot! This is a basic guide to setting up your bot with Bun; we recommend the [official discord.js docs](https://discordjs.guide/) for complete information on the `discord.js` API.
|
||||
|
||||
@@ -21,7 +21,7 @@ const app = new Elysia()
|
||||
.get('/', () => 'Hello Elysia')
|
||||
.listen(8080)
|
||||
|
||||
console.log(`🦊 Elysia is running at on port ${app.server.port}...`)
|
||||
console.log(`🦊 Elysia is running at on port ${app.server?.port}...`)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
@@ -18,7 +18,7 @@ export default app;
|
||||
Use `create-hono` to get started with one of Hono's project templates. Select `bun` when prompted for a template.
|
||||
|
||||
```bash
|
||||
$ bunx create-hono myapp
|
||||
$ bun create hono myapp
|
||||
✔ Which template do you want to use? › bun
|
||||
cloned honojs/starter#main to /path/to/myapp
|
||||
✔ Copied project files
|
||||
|
||||
@@ -33,11 +33,18 @@ const animalSchema = new mongoose.Schema(
|
||||
{
|
||||
name: {type: String, required: true},
|
||||
sound: {type: String, required: true},
|
||||
},
|
||||
{
|
||||
methods: {
|
||||
speak() {
|
||||
console.log(`${this.sound}!`);
|
||||
},
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
export type Animal = mongoose.InferSchemaType<typeof animalSchema>;
|
||||
export const Animal = mongoose.model('Kitten', animalSchema);
|
||||
export const Animal = mongoose.model('Animal', animalSchema);
|
||||
```
|
||||
|
||||
---
|
||||
@@ -62,13 +69,13 @@ await cow.save(); // saves to the database
|
||||
const animals = await Animal.find();
|
||||
animals[0].speak(); // logs "Moo!"
|
||||
|
||||
// disconect
|
||||
// disconnect
|
||||
await mongoose.disconnect();
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Lets run this with `bun run`.
|
||||
Let's run this with `bun run`.
|
||||
|
||||
```bash
|
||||
$ bun run index.ts
|
||||
|
||||
@@ -3,7 +3,7 @@ name: Build an app with Next.js and Bun
|
||||
---
|
||||
|
||||
{% callout %}
|
||||
Next.js currently relies on Node.js APIs that Bun does not yet implement. The guide below uses Bun to initialize a project and install dependencies, but it uses Node.js to run the dev server.
|
||||
The Next.js [App Router](https://nextjs.org/docs/app) currently relies on Node.js APIs that Bun does not yet implement. The guide below uses Bun to initialize a project and install dependencies, but it uses Node.js to run the dev server.
|
||||
{% /callout %}
|
||||
|
||||
---
|
||||
@@ -11,7 +11,7 @@ Next.js currently relies on Node.js APIs that Bun does not yet implement. The gu
|
||||
Initialize a Next.js app with `create-next-app`. This automatically installs dependencies using `npm`.
|
||||
|
||||
```sh
|
||||
$ bunx create-next-app
|
||||
$ bun create next-app
|
||||
✔ What is your project named? … my-app
|
||||
✔ Would you like to use TypeScript with this project? … No / Yes
|
||||
✔ Would you like to use ESLint with this project? … No / Yes
|
||||
@@ -23,7 +23,16 @@ Creating a new Next.js app in /path/to/my-app.
|
||||
|
||||
---
|
||||
|
||||
To start the dev server, run `bun run dev` from the project root.
|
||||
To start the dev server with Bun, run `bun --bun run dev` from the project root.
|
||||
|
||||
```sh
|
||||
$ cd my-app
|
||||
$ bun --bun run dev
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
To run the dev server with Node.js instead, omit `--bun`.
|
||||
|
||||
```sh
|
||||
$ cd my-app
|
||||
@@ -32,4 +41,4 @@ $ bun run dev
|
||||
|
||||
---
|
||||
|
||||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. Any changes you make to `pages/index.tsx` will be hot-reloaded in the browser.
|
||||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. Any changes you make to `(pages/app)/index.tsx` will be hot-reloaded in the browser.
|
||||
|
||||
@@ -9,7 +9,7 @@ $ bunx nuxi init my-nuxt-app
|
||||
✔ Which package manager would you like to use?
|
||||
bun
|
||||
◐ Installing dependencies...
|
||||
bun install v0.8.1 (16b4bf34)
|
||||
bun install v1.x (16b4bf34)
|
||||
+ @nuxt/devtools@0.8.2
|
||||
+ nuxt@3.7.0
|
||||
785 packages installed [2.67s]
|
||||
@@ -22,7 +22,7 @@ bun install v0.8.1 (16b4bf34)
|
||||
|
||||
---
|
||||
|
||||
To start the dev server, run `bun run dev` from the project root. This will execute the `nuxt dev` command (as defined in the `"dev"` script in `package.json`).
|
||||
To start the dev server, run `bun --bun run dev` from the project root. This will execute the `nuxt dev` command (as defined in the `"dev"` script in `package.json`).
|
||||
|
||||
{% callout %}
|
||||
The `nuxt` CLI uses Node.js by default; passing the `--bun` flag forces the dev server to use the Bun runtime instead.
|
||||
@@ -45,9 +45,9 @@ Nuxt 3.6.5 with Nitro 2.5.2
|
||||
|
||||
---
|
||||
|
||||
Once the dev server spins up, open [http://localhost:3000](http://localhost:3000) to see the app. The app will render Nuxt's built-in `WelcomePage` template component.
|
||||
Once the dev server spins up, open [http://localhost:3000](http://localhost:3000) to see the app. The app will render Nuxt's built-in `NuxtWelcome` template component.
|
||||
|
||||
To start developing your app, replace `<WelcomePage />` in `app.vue` with your own UI.
|
||||
To start developing your app, replace `<NuxtWelcome />` in `app.vue` with your own UI.
|
||||
|
||||
{% image src="https://github.com/oven-sh/bun/assets/3084745/2c683ecc-3298-4bb0-b8c0-cf4cfaea1daa" caption="Demo Nuxt app running on localhost" /%}
|
||||
|
||||
|
||||
@@ -2,20 +2,26 @@
|
||||
name: Get started using Prisma
|
||||
---
|
||||
|
||||
{% callout %}
|
||||
**Note** — At the moment Prisma needs Node.js to be installed to run certain generation code. Make sure Node.js is installed in the environment where you're running `bunx prisma` commands.
|
||||
{% /callout %}
|
||||
|
||||
---
|
||||
|
||||
Prisma works out of the box with Bun. First, create a directory and initialize it with `bun init`.
|
||||
|
||||
```bash
|
||||
mkdir prisma-app
|
||||
cd prisma-app
|
||||
bun init
|
||||
$ mkdir prisma-app
|
||||
$ cd prisma-app
|
||||
$ bun init
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Then add Prisma as a dependency.
|
||||
Then install the Prisma CLI (`prisma`) and Prisma Client (`@prisma/client`) as dependencies.
|
||||
|
||||
```bash
|
||||
bun add prisma
|
||||
$ bun add prisma @prisma/client
|
||||
```
|
||||
|
||||
---
|
||||
@@ -23,7 +29,7 @@ bun add prisma
|
||||
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 prisma init --datasource-provider sqlite
|
||||
```
|
||||
|
||||
---
|
||||
@@ -54,14 +60,37 @@ Then generate and run initial migration.
|
||||
This will generate a `.sql` migration file in `prisma/migrations`, create a new SQLite instance, and execute the migration against the new instance.
|
||||
|
||||
```bash
|
||||
bunx prisma migrate dev --name init
|
||||
$ bunx prisma migrate dev --name init
|
||||
Environment variables loaded from .env
|
||||
Prisma schema loaded from prisma/schema.prisma
|
||||
Datasource "db": SQLite database "dev.db" at "file:./dev.db"
|
||||
|
||||
SQLite database dev.db created at file:./dev.db
|
||||
|
||||
Applying migration `20230928182242_init`
|
||||
|
||||
The following migration(s) have been created and applied from new schema changes:
|
||||
|
||||
migrations/
|
||||
└─ 20230928182242_init/
|
||||
└─ migration.sql
|
||||
|
||||
Your database is now in sync with your schema.
|
||||
|
||||
✔ Generated Prisma Client (v5.3.1) to ./node_modules/@prisma/client in 41ms
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Prisma automatically generates our _Prisma client_ whenever we execute a new migration. The client provides a fully typed API for reading and writing from our database.
|
||||
As indicated in the output, Prisma re-generates our _Prisma client_ whenever we execute a new migration. The client provides a fully typed API for reading and writing from our database. You can manually re-generate the client with the Prisma CLI.
|
||||
|
||||
It can be imported from `@prisma/client`.
|
||||
```sh
|
||||
$ bunx prisma generate
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
We can import the generated client from `@prisma/client`.
|
||||
|
||||
```ts#src/index.ts
|
||||
import {PrismaClient} from "@prisma/client";
|
||||
|
||||
107
docs/guides/ecosystem/qwik.md
Normal file
107
docs/guides/ecosystem/qwik.md
Normal file
@@ -0,0 +1,107 @@
|
||||
---
|
||||
name: Build an app with Qwik and Bun
|
||||
---
|
||||
|
||||
Initialize a new Qwik app with `bunx create-qwik`.
|
||||
|
||||
The `create-qwik` package detects when you are using `bunx` and will automatically install dependencies using `bun`.
|
||||
|
||||
```sh
|
||||
$ bun create qwik
|
||||
|
||||
............
|
||||
.::: :--------:.
|
||||
.:::: .:-------:.
|
||||
.:::::. .:-------.
|
||||
::::::. .:------.
|
||||
::::::. :-----:
|
||||
::::::. .:-----.
|
||||
:::::::. .-----.
|
||||
::::::::.. ---:.
|
||||
.:::::::::. :-:.
|
||||
..::::::::::::
|
||||
...::::
|
||||
|
||||
|
||||
┌ Let's create a Qwik App ✨ (v1.2.10)
|
||||
│
|
||||
◇ Where would you like to create your new project? (Use '.' or './' for current directory)
|
||||
│ ./my-app
|
||||
│
|
||||
● Creating new project in /path/to/my-app ... 🐇
|
||||
│
|
||||
◇ Select a starter
|
||||
│ Basic App
|
||||
│
|
||||
◇ Would you like to install bun dependencies?
|
||||
│ Yes
|
||||
│
|
||||
◇ Initialize a new git repository?
|
||||
│ No
|
||||
│
|
||||
◇ Finishing the install. Wanna hear a joke?
|
||||
│ Yes
|
||||
│
|
||||
○ ────────────────────────────────────────────────────────╮
|
||||
│ │
|
||||
│ How do you know if there’s an elephant under your bed? │
|
||||
│ Your head hits the ceiling! │
|
||||
│ │
|
||||
├──────────────────────────────────────────────────────────╯
|
||||
│
|
||||
◇ App Created 🐰
|
||||
│
|
||||
◇ Installed bun dependencies 📋
|
||||
│
|
||||
○ Result ─────────────────────────────────────────────╮
|
||||
│ │
|
||||
│ Success! Project created in my-app directory │
|
||||
│ │
|
||||
│ Integrations? Add Netlify, Cloudflare, Tailwind... │
|
||||
│ bun qwik add │
|
||||
│ │
|
||||
│ Relevant docs: │
|
||||
│ https://qwik.builder.io/docs/getting-started/ │
|
||||
│ │
|
||||
│ Questions? Start the conversation at: │
|
||||
│ https://qwik.builder.io/chat │
|
||||
│ https://twitter.com/QwikDev │
|
||||
│ │
|
||||
│ Presentations, Podcasts and Videos: │
|
||||
│ https://qwik.builder.io/media/ │
|
||||
│ │
|
||||
│ Next steps: │
|
||||
│ cd my-app │
|
||||
│ bun start │
|
||||
│ │
|
||||
│ │
|
||||
├──────────────────────────────────────────────────────╯
|
||||
│
|
||||
└ Happy coding! 🎉
|
||||
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Run `bun run dev` to start the development server.
|
||||
|
||||
```sh
|
||||
$ bun run dev
|
||||
$ vite--mode ssr
|
||||
|
||||
VITE v4.4.7 ready in 1190 ms
|
||||
|
||||
➜ Local: http://localhost:5173/
|
||||
➜ Network: use --host to expose
|
||||
➜ press h to show help
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Open [http://localhost:5173](http://localhost:5173) with your browser to see the result. Qwik will hot-reload your app as you edit your source files.
|
||||
|
||||
{% image src="https://github.com/oven-sh/bun/assets/3084745/ec35f2f7-03dd-4c90-851e-fb4ad150bb28" alt="Qwik screenshot" /%}
|
||||
|
||||
---
|
||||
|
||||
Refer to the [Qwik docs](https://qwik.builder.io/docs/getting-started/) for complete documentation.
|
||||
@@ -2,29 +2,48 @@
|
||||
name: Use React and JSX
|
||||
---
|
||||
|
||||
React just works with Bun. Bun supports `.jsx` and `.tsx` files out of the box. Bun's internal transpiler converts JSX syntax into vanilla JavaScript before execution.
|
||||
React just works with Bun. Bun supports `.jsx` and `.tsx` files out of the box.
|
||||
|
||||
```tsx#react.tsx
|
||||
function Component(props: {message: string}) {
|
||||
return (
|
||||
<body>
|
||||
<h1 style={{color: 'red'}}>{props.message}</h1>
|
||||
</body>
|
||||
);
|
||||
}
|
||||
Remember that JSX is just a special syntax for including HTML-like syntax in JavaScript files. It's commonReact uses JSX syntax, as do other React alternatives like [Preact](https://preactjs.com/) and [Solid](https://www.solidjs.com/). Bun's internal transpiler converts JSX syntax into vanilla JavaScript before execution.
|
||||
|
||||
console.log(<Component message="Hello world!" />);
|
||||
---
|
||||
|
||||
Bun _assumes_ you're using React (unless you [configure it otherwise](/docs/runtime/bunfig#jsx)) so a line like this:
|
||||
|
||||
```
|
||||
const element = <h1>Hello, world!</h1>;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Bun implements special logging for JSX to make debugging easier.
|
||||
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 you've installed React.
|
||||
|
||||
```bash
|
||||
$ bun run react.tsx
|
||||
$ bun install react
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Bun implements special logging for JSX components to make debugging easier.
|
||||
|
||||
```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](/docs/runtime/jsx) for complete documentation on configuring JSX.
|
||||
|
||||
@@ -3,7 +3,7 @@ name: Build an app with Remix and Bun
|
||||
---
|
||||
|
||||
{% callout %}
|
||||
Remix currently relies on Node.js APIs that Bun does not yet implement. The guide below uses Bun to initialize a project and install dependencies, but it uses Node.js to run the dev server.
|
||||
Currently the Remix development server (`remix dev`) relies on Node.js APIs that Bun does not yet implement. The guide below uses Bun to initialize a project and install dependencies, but it uses Node.js to run the dev server.
|
||||
{% /callout %}
|
||||
|
||||
---
|
||||
@@ -11,14 +11,14 @@ Remix currently relies on Node.js APIs that Bun does not yet implement. The guid
|
||||
Initialize a Remix app with `create-remix`.
|
||||
|
||||
```sh
|
||||
$ bunx create-remix
|
||||
$ bun create remix
|
||||
|
||||
remix v1.19.3 💿 Let's build a better website...
|
||||
|
||||
dir Where should we create your new project?
|
||||
./my-app
|
||||
|
||||
◼ Using basic template See https://remix.run/docs/pages/templates for more
|
||||
◼ Using basic template See https://remix.run/docs/en/main/guides/templates#templates for more
|
||||
✔ Template copied
|
||||
|
||||
git Initialize a new git repository?
|
||||
@@ -58,3 +58,21 @@ $ bun run dev
|
||||
Open [http://localhost:3000](http://localhost:3000) to see the app. Any changes you make to `app/routes/_index.tsx` will be hot-reloaded in the browser.
|
||||
|
||||
{% image src="https://github.com/oven-sh/bun/assets/3084745/c26f1059-a5d4-4c0b-9a88-d9902472fd77" caption="Remix app running on localhost" /%}
|
||||
|
||||
---
|
||||
|
||||
To build and start your app, run `bun run build` then `bun run start` from the project root.
|
||||
|
||||
```sh
|
||||
$ bun run build
|
||||
$ remix build
|
||||
info building... (NODE_ENV=production)
|
||||
info built (158ms)
|
||||
$ bun start
|
||||
$ remix-serve ./build/index.js
|
||||
[remix-serve] http://localhost:3000 (http://192.168.86.237:3000)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Read the [Remix docs](https://remix.run/) for more information on how to build apps with Remix.
|
||||
|
||||
@@ -11,7 +11,7 @@ SolidStart currently relies on Node.js APIs that Bun does not yet implement. The
|
||||
Initialize a SolidStart app with `create-solid`.
|
||||
|
||||
```sh
|
||||
$ bunx create-solid my-app
|
||||
$ bun create solid my-app
|
||||
create-solid version 0.2.31
|
||||
|
||||
Welcome to the SolidStart setup wizard!
|
||||
@@ -30,7 +30,7 @@ cloned solidjs/solid-start#main to /path/to/my-app/.solid-start
|
||||
|
||||
---
|
||||
|
||||
As instructed by the `create-solid` CLI, lets install our dependencies.
|
||||
As instructed by the `create-solid` CLI, let's install our dependencies.
|
||||
|
||||
```sh
|
||||
$ cd my-app
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
name: Build an app with SvelteKit and Bun
|
||||
---
|
||||
|
||||
Use `bunx` to scaffold your app with the `create-svelte` CLI. Answer the prompts to slect a template and set up your development environment.
|
||||
Use `bun create` to scaffold your app with the `svelte` package. Answer the prompts to select a template and set up your development environment.
|
||||
|
||||
```sh
|
||||
$ bunx create-svelte my-app
|
||||
$ bun create svelte@latest my-app
|
||||
┌ Welcome to SvelteKit!
|
||||
│
|
||||
◇ Which Svelte app template?
|
||||
@@ -63,3 +63,58 @@ Visit [http://localhost:5173](http://localhost:5173/) in a browser to see the te
|
||||
---
|
||||
|
||||
If you edit and save `src/routes/+page.svelte`, you should see your changes hot-reloaded in the browser.
|
||||
|
||||
---
|
||||
|
||||
To build for production, you'll need to add the right SvelteKit adapter. Currently we recommend the
|
||||
|
||||
`bun add -D svelte-adapter-bun`.
|
||||
|
||||
Now, make the following changes to your `svelte.config.js`.
|
||||
|
||||
```ts-diff
|
||||
- import adapter from "@sveltejs/adapter-auto";
|
||||
+ import adapter from "svelte-adapter-bun";
|
||||
import { vitePreprocess } from "@sveltejs/kit/vite";
|
||||
|
||||
/** @type {import('@sveltejs/kit').Config} */
|
||||
const config = {
|
||||
kit: {
|
||||
adapter: adapter(),
|
||||
},
|
||||
preprocess: vitePreprocess(),
|
||||
};
|
||||
|
||||
export default config;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
To build a production bundle:
|
||||
|
||||
```sh
|
||||
$ bun run build
|
||||
$ vite build
|
||||
|
||||
vite v4.4.9 building SSR bundle for production...
|
||||
transforming (60) node_modules/@sveltejs/kit/src/utils/escape.js
|
||||
|
||||
✓ 98 modules transformed.
|
||||
Generated an empty chunk: "entries/endpoints/waitlist/_server.ts".
|
||||
|
||||
vite v4.4.9 building for production...
|
||||
✓ 92 modules transformed.
|
||||
Generated an empty chunk: "7".
|
||||
.svelte-kit/output/client/_app/version.json 0.03 kB │ gzip: 0.05 kB
|
||||
|
||||
...
|
||||
|
||||
.svelte-kit/output/server/index.js 86.47 kB
|
||||
|
||||
Run npm run preview to preview your production build locally.
|
||||
|
||||
> Using svelte-adapter-bun
|
||||
✔ Start server with: bun ./build/index.js
|
||||
✔ done
|
||||
✓ built in 7.81s
|
||||
```
|
||||
|
||||
@@ -8,10 +8,10 @@ While Vite currently works with Bun, it has not been heavily optimized, nor has
|
||||
|
||||
---
|
||||
|
||||
Vite works out of the box with Bun (v0.7 and later). Get started with one of Vite's templates.
|
||||
Vite works out of the box with Bun. Get started with one of Vite's templates.
|
||||
|
||||
```bash
|
||||
$ bunx create-vite my-app
|
||||
$ bun create vite my-app
|
||||
✔ Select a framework: › React
|
||||
✔ Select a variant: › TypeScript + SWC
|
||||
Scaffolding project in /path/to/my-app...
|
||||
|
||||
@@ -59,7 +59,7 @@ Listening on http://localhost:4000
|
||||
|
||||
Our form will send a `POST` request to the `/action` endpoint with the form data. Let's handle that request in our server.
|
||||
|
||||
First we use the [`.formData()`](https://developer.mozilla.org/en-US/docs/Web/API/Request/formData) method on the incoming `Request` to asynchonously parse its contents to a `FormData` instance. Then we can use the [`.get()`](https://developer.mozilla.org/en-US/docs/Web/API/FormData/get) method to extract the value of the `name` and `profilePicture` fields. Here `name` corresponds to a `string` and `profilePicture` is a `Blob`.
|
||||
First we use the [`.formData()`](https://developer.mozilla.org/en-US/docs/Web/API/Request/formData) method on the incoming `Request` to asynchronously parse its contents to a `FormData` instance. Then we can use the [`.get()`](https://developer.mozilla.org/en-US/docs/Web/API/FormData/get) method to extract the value of the `name` and `profilePicture` fields. Here `name` corresponds to a `string` and `profilePicture` is a `Blob`.
|
||||
|
||||
Finally, we write the `Blob` to disk using [`Bun.write()`](/docs/api/file-io#writing-files-bun-write).
|
||||
|
||||
@@ -81,7 +81,7 @@ const server = Bun.serve({
|
||||
+ if (url.pathname === '/action') {
|
||||
+ const formdata = await req.formData();
|
||||
+ const name = formdata.get('name');
|
||||
+ const profilePicture = formdata.get('profilePicture');+
|
||||
+ const profilePicture = formdata.get('profilePicture');
|
||||
+ if (!profilePicture) throw new Error('Must upload a profile picture.');
|
||||
+ // write profilePicture to disk
|
||||
+ await Bun.write('profilePicture.png', profilePicture);
|
||||
|
||||
73
docs/guides/install/azure-artifacts.md
Normal file
73
docs/guides/install/azure-artifacts.md
Normal file
@@ -0,0 +1,73 @@
|
||||
---
|
||||
name: Using bun install with an Azure Artifacts npm registry
|
||||
---
|
||||
|
||||
{% callout %}
|
||||
In [Azure Artifact's](https://learn.microsoft.com/en-us/azure/devops/artifacts/npm/npmrc?view=azure-devops&tabs=windows%2Cclassic) instructions for `.npmrc`, they say to base64 encode the password. Do not do this for `bun install`. Bun will automatically base64 encode the password for you if needed.
|
||||
{% /callout %}
|
||||
|
||||
[Azure Artifacts](https://azure.microsoft.com/en-us/products/devops/artifacts) is a package management system for Azure DevOps. It allows you to host your own private npm registry, npm packages, and other types of packages as well.
|
||||
|
||||
---
|
||||
|
||||
### Configure with bunfig.toml
|
||||
|
||||
---
|
||||
|
||||
To use it with `bun install`, add a `bunfig.toml` file to your project with the following contents. Make sure to replace `my-azure-artifacts-user` with your Azure Artifacts username, such as `jarred1234`.
|
||||
|
||||
```toml#bunfig.toml
|
||||
[install.registry]
|
||||
url = "https://pkgs.dev.azure.com/my-azure-artifacts-user/_packaging/my-azure-artifacts-user/npm/registry"
|
||||
username = "my-azure-artifacts-user"
|
||||
# Bun v1.0.3+ supports using an environment variable here
|
||||
password = "$NPM_PASSWORD"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Then assign your Azure Personal Access Token to the the `NPM_PASSWORD` environment variable. Bun [automatically reads](/docs/runtime/env) `.env` files, so create a file called `.env` in your project root. There is no need to base-64 encode this token! Bun will do this for you.
|
||||
|
||||
```txt#.env
|
||||
NPM_PASSWORD=<paste token here>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Configure with environment variables
|
||||
|
||||
---
|
||||
|
||||
To configure Azure Artifacts without `bunfig.toml`, you can set the `NPM_CONFIG_REGISTRY` environment variable. The URL should include `:username` and `:_password` as query parameters. Replace `<USERNAME>` and `<PASSWORD>` with the apprropriate values.
|
||||
|
||||
```bash#shell
|
||||
NPM_CONFIG_REGISTRY=https://pkgs.dev.azure.com/my-azure-artifacts-user/_packaging/my-azure-artifacts-user/npm/registry/:username=<USERNAME>:_password=<PASSWORD>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Don't base64 encode the password
|
||||
|
||||
---
|
||||
|
||||
In [Azure Artifact's](https://learn.microsoft.com/en-us/azure/devops/artifacts/npm/npmrc?view=azure-devops&tabs=windows%2Cclassic) instructions for `.npmrc`, they say to base64 encode the password. Do not do this for `bun install`. Bun will automatically base64 encode the password for you if needed.
|
||||
|
||||
{% callout %}
|
||||
**Tip** — If it ends with `==`, it probably is base64 encoded.
|
||||
{% /callout %}
|
||||
|
||||
---
|
||||
|
||||
To decode a base64-encoded password, open your browser console and run:
|
||||
|
||||
```js
|
||||
atob("<base64-encoded password>");
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Alternatively, use the `base64` command line tool, but doing so means it may be saved in your terminal history which is not recommended:
|
||||
|
||||
```bash
|
||||
echo "base64-encoded-password" | base64 --decode
|
||||
```
|
||||
@@ -18,7 +18,7 @@ registry = "https://username:password@registry.npmjs.org"
|
||||
|
||||
---
|
||||
|
||||
Your `bunfig.toml` can reference environment variables. Bun automatically loads environment variables from `.env.local`, `.env.[NODE_ENV]`, and `.env`. See [Docs > Environment variables](/docs/cli/run#environment-variables) for more information.
|
||||
Your `bunfig.toml` can reference environment variables. Bun automatically loads environment variables from `.env.local`, `.env.[NODE_ENV]`, and `.env`. See [Docs > Environment variables](/docs/runtime/env) for more information.
|
||||
|
||||
```toml#bunfig.toml
|
||||
[install]
|
||||
|
||||
28
docs/guides/install/jfrog-artifactory.md
Normal file
28
docs/guides/install/jfrog-artifactory.md
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
name: Using bun install with Artifactory
|
||||
---
|
||||
|
||||
[JFrog Artifactory](https://jfrog.com/artifactory/) is a package management system for npm, Docker, Maven, NuGet, Ruby, Helm, and more. It allows you to host your own private npm registry, npm packages, and other types of packages as well.
|
||||
|
||||
To use it with `bun install`, add a `bunfig.toml` file to your project with the following contents:
|
||||
|
||||
---
|
||||
|
||||
### Configure with bunfig.toml
|
||||
|
||||
Make sure to replace `MY_SUBDOMAIN` with your JFrog Artifactory subdomain, such as `jarred1234` and MY_TOKEN with your JFrog Artifactory token.
|
||||
|
||||
```toml#bunfig.toml
|
||||
[install.registry]
|
||||
url = "https://MY_SUBDOMAIN.jfrog.io/artifactory/api/npm/npm/_auth=MY_TOKEN"
|
||||
# Bun v1.0.3+ supports using an environment variable here
|
||||
# url = "$NPM_CONFIG_REGISTRY"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Configure with `$NPM_CONFIG_REGISTRY`
|
||||
|
||||
Like with npm, you can use the `NPM_CONFIG_REGISTRY` environment variable to configure JFrog Artifactory with bun install.
|
||||
|
||||
---
|
||||
@@ -11,7 +11,11 @@ Bun does not read `.npmrc` files; instead private registries are configured via
|
||||
|
||||
# as an object with username/password
|
||||
# you can reference environment variables
|
||||
"@myorg2" = { username = "myusername", password = "$npm_pass", url = "https://registry.myorg.com/" }
|
||||
"@myorg2" = {
|
||||
username = "myusername",
|
||||
password = "$npm_pass",
|
||||
url = "https://registry.myorg.com/"
|
||||
}
|
||||
|
||||
# as an object with token
|
||||
"@myorg3" = { token = "$npm_token", url = "https://registry.myorg.com/" }
|
||||
@@ -20,7 +24,7 @@ Bun does not read `.npmrc` files; instead private registries are configured via
|
||||
|
||||
---
|
||||
|
||||
Your `bunfig.toml` can reference environment variables. Bun automatically loads environment variables from `.env.local`, `.env.[NODE_ENV]`, and `.env`. See [Docs > Environment variables](/docs/cli/run#environment-variables) for more information.
|
||||
Your `bunfig.toml` can reference environment variables. Bun automatically loads environment variables from `.env.local`, `.env.[NODE_ENV]`, and `.env`. See [Docs > Environment variables](/docs/runtime/env) for more information.
|
||||
|
||||
```toml#bunfig.toml
|
||||
[install.scopes]
|
||||
|
||||
50
docs/guides/install/trusted.md
Normal file
50
docs/guides/install/trusted.md
Normal file
@@ -0,0 +1,50 @@
|
||||
---
|
||||
name: Add a trusted dependency
|
||||
---
|
||||
|
||||
Unlike other npm clients, Bun does not execute arbitrary lifecycle scripts for installed dependencies, such as `postinstall` and `node-gyp` builds. These scripts represent a potential security risk, as they can execute arbitrary code on your machine.
|
||||
|
||||
{% callout %}
|
||||
Soon, Bun will include a built-in allow-list that automatically allows lifecycle scripts to be run by popular packages that are known to be safe. This is still under development.
|
||||
{% /callout %}
|
||||
|
||||
---
|
||||
|
||||
If you are seeing one of the following errors, you are probably trying to use a package that uses `postinstall` to work properly:
|
||||
|
||||
- `error: could not determine executable to run for package`
|
||||
- `InvalidExe`
|
||||
|
||||
---
|
||||
|
||||
To tell Bun to allow lifecycle scripts for a particular package, add the package to `trustedDependencies` in your package.json.
|
||||
|
||||
Note that this only allows lifecycle scripts for the specific package listed in `trustedDependencies`, _not_ the dependencies of that dependency!
|
||||
|
||||
<!-- Bun maintains an allow-list of popular packages containing `postinstall` scripts that are known to be safe. To run lifecycle scripts for packages that aren't on this list, add the package to `trustedDependencies` in your package.json. -->
|
||||
|
||||
```json-diff
|
||||
{
|
||||
"name": "my-app",
|
||||
"version": "1.0.0",
|
||||
+ "trustedDependencies": ["my-trusted-package"]
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Once this is added, run a fresh install. Bun will re-install your dependencies and properly install
|
||||
|
||||
```sh
|
||||
$ rm -rf node_modules
|
||||
$ rm bun.lockb
|
||||
$ bun install
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Note that this only allows lifecycle scripts for the specific package listed in `trustedDependencies`, _not_ the dependencies of that dependency!
|
||||
|
||||
---
|
||||
|
||||
See [Docs > Package manager > Trusted dependencies](/docs/cli/install#trusted-dependencies) for complete documentation of trusted dependencies.
|
||||
@@ -4,6 +4,8 @@ name: Configuring a monorepo using workspaces
|
||||
|
||||
Bun's package manager supports npm `"workspaces"`. This allows you to split a codebase into multiple distinct "packages" that live in the same repository, can depend on each other, and (when possible) share a `node_modules` directory.
|
||||
|
||||
Clone [this sample project](https://github.com/colinhacks/bun-workspaces) to experiment with workspaces.
|
||||
|
||||
---
|
||||
|
||||
The root `package.json` should not contain any `"dependencies"`, `"devDependencies"`, etc. Each individual package should be self-contained and declare its own dependencies. Similarly, it's conventional to declare `"private": true` to avoid accidentally publishing the root package to `npm`.
|
||||
@@ -35,13 +37,13 @@ It's common to place all packages in a `packages` directory. The `"workspaces"`
|
||||
|
||||
---
|
||||
|
||||
To add one workspace as a dependency of another, modify its `package.json`. Here were adding `stuff-a` as a dependency of `stuff-b`.
|
||||
To add dependencies between workspaces, use the `"workspace:*"` syntax. Here we're adding `stuff-a` as a dependency of `stuff-b`.
|
||||
|
||||
```json#packages/stuff-b/package.json
|
||||
```json-diff#packages/stuff-b/package.json
|
||||
{
|
||||
"name": "stuff-b",
|
||||
"dependencies": {
|
||||
+ "stuff-a": "*"
|
||||
+ "stuff-a": "workspace:*"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -8,7 +8,7 @@ The `Bun.file()` function accepts a path and returns a `BunFile` instance. Use t
|
||||
const path = "/path/to/package.json";
|
||||
const file = Bun.file(path);
|
||||
|
||||
file.exists(); // boolean;
|
||||
await file.exists(); // boolean;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
@@ -29,4 +29,4 @@ FOOBAR=aaaaaa
|
||||
|
||||
---
|
||||
|
||||
See [Docs > Runtime > Environment variables](/docs/cli/run#environment-variables) for more information on using environment variables with Bun.
|
||||
See [Docs > Runtime > Environment variables](/docs/runtime/env) for more information on using environment variables with Bun.
|
||||
|
||||
@@ -34,4 +34,4 @@ $ FOO=helloworld bun run dev
|
||||
|
||||
---
|
||||
|
||||
See [Docs > Runtime > Environment variables](/docs/cli/run#environment-variables) for more information on using environment variables with Bun.
|
||||
See [Docs > Runtime > Environment variables](/docs/runtime/env) for more information on using environment variables with Bun.
|
||||
|
||||
@@ -8,8 +8,8 @@ Bun reads the `paths` field in your `tsconfig.json` to re-write import paths. Th
|
||||
{
|
||||
"compilerOptions": {
|
||||
"paths": {
|
||||
"my-custom-name": "zod",
|
||||
"@components/*": "./src/components/*"
|
||||
"my-custom-name": ["zod"],
|
||||
"@components/*": ["./src/components/*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
69
docs/guides/runtime/typescript.md
Normal file
69
docs/guides/runtime/typescript.md
Normal file
@@ -0,0 +1,69 @@
|
||||
---
|
||||
name: Install TypeScript declarations for Bun
|
||||
---
|
||||
|
||||
To install TypeScript definitions for Bun's built-in APIs in your project, install `bun-types`.
|
||||
|
||||
```sh
|
||||
$ bun add -d bun-types # dev dependency
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Then include `"bun-types"` in the `compilerOptions.types` in your `tsconfig.json`:
|
||||
|
||||
```json-diff
|
||||
{
|
||||
"compilerOptions": {
|
||||
+ "types": ["bun-types"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Unfortunately, setting a value for `"types"` means that TypeScript will ignore other global type definitions, including `lib: ["dom"]`. If you need to add DOM types into your project, add the following [triple-slash directives](https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html) at the top of any TypeScript file in your project.
|
||||
|
||||
```ts
|
||||
/// <reference lib="dom" />
|
||||
/// <reference lib="dom.iterable" />
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Below is the full set of recommended `compilerOptions` for a Bun project. With this `tsconfig.json`, you can use top-level await, extensioned or extensionless imports, and JSX.
|
||||
|
||||
```jsonc
|
||||
{
|
||||
"compilerOptions": {
|
||||
// add Bun type definitions
|
||||
"types": ["bun-types"],
|
||||
|
||||
// enable latest features
|
||||
"lib": ["esnext"],
|
||||
"module": "esnext",
|
||||
"target": "esnext",
|
||||
|
||||
// if TS 5.x+
|
||||
"moduleResolution": "bundler",
|
||||
"noEmit": true,
|
||||
"allowImportingTsExtensions": true,
|
||||
"moduleDetection": "force",
|
||||
// if TS 4.x or earlier
|
||||
// "moduleResolution": "nodenext",
|
||||
|
||||
"jsx": "react-jsx", // support JSX
|
||||
"allowJs": true, // allow importing `.js` from `.ts`
|
||||
"esModuleInterop": true, // allow default imports for CommonJS modules
|
||||
|
||||
// best practices
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"skipLibCheck": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Refer to [Ecosystem > TypeScript](/docs/runtime/typescript) for a complete guide to TypeScript support in Bun.
|
||||
47
docs/guides/runtime/vscode-debugger.md
Normal file
47
docs/guides/runtime/vscode-debugger.md
Normal file
@@ -0,0 +1,47 @@
|
||||
---
|
||||
name: Debugging Bun with the VS Code extension
|
||||
---
|
||||
|
||||
{% note %}
|
||||
|
||||
VSCode extension support is currently buggy. We recommend the [Web Debugger](https://bun.sh/guides/runtime/web-debugger) for now.
|
||||
|
||||
{% /note %}
|
||||
|
||||
Bun speaks the [WebKit Inspector Protocol](https://github.com/oven-sh/bun/blob/main/packages/bun-vscode/types/jsc.d.ts) so you can debug your code with an interactive debugger.
|
||||
|
||||
---
|
||||
|
||||
To install the extension, visit the [Bun for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=oven.bun-vscode) page on the VS Code marketplace website, then click Install.
|
||||
|
||||
{% image src="https://github.com/oven-sh/bun/assets/3084745/7c8c80e6-d49e-457a-a45e-45ebed946d56" /%}
|
||||
|
||||
---
|
||||
|
||||
Alternatively, search `bun-vscode` in the Extensions tab of VS Code.
|
||||
|
||||
{% image src="https://github.com/oven-sh/bun/assets/3084745/664b4c40-944c-4076-a4c2-f812aebd3dc9" /%}
|
||||
|
||||
---
|
||||
|
||||
Make sure you are installing the extension published by the verified Oven organization.
|
||||
|
||||
{% image src="https://github.com/oven-sh/bun/assets/3084745/73e6b09f-9ff1-4d85-b725-c5eb7215b6ae" /%}
|
||||
|
||||
---
|
||||
|
||||
Once installed, two new Bun-specific commands will appear in the Command Palette. To open the palette, click View > Command Palette, or type `Ctrl+Shift+P` (Windows, Linux) or `Cmd+Shift+P` on (Mac).
|
||||
|
||||
---
|
||||
|
||||
The `Bun: Run File` command will execute your code and print the output to the Debug Console in VS Code. Breakpoints will be ignored; this is similar to executing the file with `bun <file>` from the command line.
|
||||
|
||||
{% image src="https://github.com/oven-sh/bun/assets/3084745/1b2c7fd9-fbb9-486a-84d0-eb7ec135ded3" /%}
|
||||
|
||||
---
|
||||
|
||||
The `Bun: Debug File` command will execute your code and print the output to the Debug Console in VS Code. You can set breakpoints in your code by clicking to the left of a line number; a red dot should appear.
|
||||
|
||||
When you run the file with `Bun: Debug File`, execution will pause at the breakpoint. You can inspect the variables in scope and step through the code line-by-line using the VS Code controls.
|
||||
|
||||
{% image src="https://github.com/oven-sh/bun/assets/3084745/c579a36c-eb21-4a58-bc9c-74612aad82af" /%}
|
||||
@@ -49,7 +49,7 @@ test("set button text", () => {
|
||||
|
||||
---
|
||||
|
||||
With Happy DOM propertly configured, this test runs as expected.
|
||||
With Happy DOM properly configured, this test runs as expected.
|
||||
|
||||
```sh
|
||||
$ bun test
|
||||
|
||||
112
docs/guides/test/migrate-from-jest.md
Normal file
112
docs/guides/test/migrate-from-jest.md
Normal file
@@ -0,0 +1,112 @@
|
||||
---
|
||||
name: Migrate from Jest to Bun's test runner
|
||||
---
|
||||
|
||||
In many cases, Bun's test runner can run Jest test suites with no code changes. Just run `bun test` instead of `npx jest`, `yarn test`, etc.
|
||||
|
||||
```sh-diff
|
||||
- $ npx jest
|
||||
- $ yarn test
|
||||
+ $ bun test
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
There's often no need for code changes.
|
||||
|
||||
- Bun internally re-writes imports from `@jest/globals` to use the `bun:test` equivalents.
|
||||
- If you're relying on Jest to inject `test`, `expect`, etc. as globals, Bun does that too.
|
||||
|
||||
But if you'd rather switch to the `bun:test` imports, you can do that too.
|
||||
|
||||
```ts-diff
|
||||
- import {test, expect} from "@jest/globals";
|
||||
+ import {test, expect} from "bun:test";
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Bun implements the vast majority of Jest's matchers, but compatibility isn't 100% yet. Refer to the full compatibility table at [Docs > Test runner > Writing tests](/docs/test/writing#matchers).
|
||||
|
||||
Some notable missing features:
|
||||
|
||||
- `expect.extend()`
|
||||
- `expect().toMatchInlineSnapshot()`
|
||||
- `expect().toHaveBeenCalledWith()`
|
||||
- `expect().toHaveReturned()`
|
||||
|
||||
---
|
||||
|
||||
If you're using `testEnvironment: "jsdom"` to run your tests in a browser-like environment, you should follow the [DOM testing with Bun and happy-dom](/guides/test/happy-dom) guide to inject browser APIs into the global scope. This guide relies on [`happy-dom`](https://github.com/capricorn86/happy-dom), which is a leaner and faster alternative to [`jsdom`](https://github.com/jsdom/jsdom).
|
||||
|
||||
At the moment jsdom does not work in Bun due to its internal use of V8 APIs. Track support for it [here](https://github.com/oven-sh/bun/issues/3554).
|
||||
|
||||
```toml#bunfig.toml
|
||||
[test]
|
||||
preload = ["./happy-dom.ts"]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Replace `bail` in your Jest config with the `--bail` CLI flag.
|
||||
|
||||
<!-- ```ts-diff
|
||||
- import type {Config} from 'jest';
|
||||
-
|
||||
- const config: Config = {
|
||||
- bail: 3
|
||||
- };
|
||||
``` -->
|
||||
|
||||
```sh-diff
|
||||
$ bun test --bail 3
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Replace `collectCoverage` with the `--coverage` CLI flag.
|
||||
|
||||
<!-- ```ts-diff
|
||||
- import type {Config} from 'jest';
|
||||
-
|
||||
- const config: Config = {
|
||||
- collectCoverageFrom: [
|
||||
- '**/*.{js,jsx}',
|
||||
- '!**/node_modules/**',
|
||||
- '!**/vendor/**',
|
||||
- ],
|
||||
- };
|
||||
``` -->
|
||||
|
||||
```sh
|
||||
$ bun test --coverage
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Replace `testTimeout` with the `--test-timeout` CLI flag.
|
||||
|
||||
```sh
|
||||
$ bun test --timeout 10000
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Many other flags become irrelevant or obsolete when using `bun test`.
|
||||
|
||||
- `transform` — Buns supports TypeScript & JSX. Other file types can be configured with [Plugins](/docs/runtime/plugins).
|
||||
- `extensionsToTreatAsEsm`
|
||||
- `haste` — Bun uses it's own internal source maps
|
||||
- `watchman`, `watchPlugins`, `watchPathIgnorePatterns` — use `--watch` to run tests in watch mode
|
||||
- `verbose` — set `logLevel: "debug"` in [`bunfig.toml`](/docs/runtime/bunfig#loglevel)
|
||||
|
||||
---
|
||||
|
||||
Settings that aren't mentioned here are not supported or have no equivalent. Please [file a feature request](https://github.com/oven-sh/bun) if something important is missing.
|
||||
|
||||
---
|
||||
|
||||
See also:
|
||||
|
||||
- [Mark a test as a todo](/guides/test/todo-tests)
|
||||
- [Docs > Test runner > Writing tests](/docs/test/writing)
|
||||
@@ -47,7 +47,7 @@ random.mock.results;
|
||||
These extra properties make it possible to write `expect` assertions about usage of the mock function, including how many times it was called, the arguments, and the return values.
|
||||
|
||||
```ts
|
||||
import { test, mock } from "bun:test";
|
||||
import { test, expect, mock } from "bun:test";
|
||||
|
||||
const random = mock((multiplier: number) => multiplier * Math.random());
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ Here's what the output of a typical test run looks like. In this case, there are
|
||||
|
||||
```sh
|
||||
$ bun test
|
||||
bun test v0.8.0 (9c68abdb)
|
||||
bun test v1.x (9c68abdb)
|
||||
|
||||
test.test.js:
|
||||
✓ add [0.87ms]
|
||||
@@ -47,7 +47,7 @@ To only run certain test files, pass a positional argument to `bun test`. The ru
|
||||
|
||||
```sh
|
||||
$ bun test test3
|
||||
bun test v0.8.0 (9c68abdb)
|
||||
bun test v1.x (9c68abdb)
|
||||
|
||||
test3.test.js:
|
||||
✓ add [1.40ms]
|
||||
@@ -85,7 +85,7 @@ Adding `-t add` will only run tests with "add" in the name. This works with test
|
||||
|
||||
```sh
|
||||
$ bun test -t add
|
||||
bun test v0.8.0 (9c68abdb)
|
||||
bun test v1.x (9c68abdb)
|
||||
|
||||
test.test.js:
|
||||
✓ add [1.79ms]
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user