mirror of
https://github.com/oven-sh/bun
synced 2026-02-03 07:28:53 +00:00
Compare commits
821 Commits
repl
...
test-ecosy
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57916d9426 | ||
|
|
cf9ebff4e3 | ||
|
|
2f1733b48f | ||
|
|
bfe979946e | ||
|
|
0c532eac7b | ||
|
|
70e57a7da0 | ||
|
|
fdece8611a | ||
|
|
1147c70881 | ||
|
|
3c97f568a7 | ||
|
|
310d0c5646 | ||
|
|
d79fa7ac1a | ||
|
|
906ba8b2a0 | ||
|
|
54df5c032d | ||
|
|
70039ff038 | ||
|
|
90654143bb | ||
|
|
bc114fb9d3 | ||
|
|
f3727f00dc | ||
|
|
6389a6e24f | ||
|
|
851b19ee0e | ||
|
|
ebae02a08b | ||
|
|
809266fc7a | ||
|
|
98885279eb | ||
|
|
666e615889 | ||
|
|
0b99b01b0e | ||
|
|
eb98b61201 | ||
|
|
a043497fb4 | ||
|
|
f5115835da | ||
|
|
34881922c8 | ||
|
|
44b9960113 | ||
|
|
713d72703d | ||
|
|
383a615d21 | ||
|
|
6ee42f7719 | ||
|
|
1840de3661 | ||
|
|
6aa1319fd9 | ||
|
|
6a7b1a3208 | ||
|
|
5c23d670a3 | ||
|
|
22818e6806 | ||
|
|
0abe3745d2 | ||
|
|
ea0ffde991 | ||
|
|
194294f5b5 | ||
|
|
7f10622a84 | ||
|
|
a71a9e3447 | ||
|
|
53ee2d77b2 | ||
|
|
3d58437fc8 | ||
|
|
6517252153 | ||
|
|
5f86b839b4 | ||
|
|
5692f82aaf | ||
|
|
93714292bf | ||
|
|
0766fb5ae8 | ||
|
|
e83a9132d5 | ||
|
|
bc4146295f | ||
|
|
d8be3e51b4 | ||
|
|
6ba4e950cc | ||
|
|
81067477dc | ||
|
|
d8ca6ca699 | ||
|
|
05ef3329c4 | ||
|
|
ab93f9f74e | ||
|
|
8db407e9a7 | ||
|
|
5eb6f83251 | ||
|
|
1b8d7d5cb1 | ||
|
|
bf32d36e4c | ||
|
|
e9661c2953 | ||
|
|
0b66fd643e | ||
|
|
778bad9dfd | ||
|
|
ef8b9efaa4 | ||
|
|
864d59f822 | ||
|
|
f5bf67bd1b | ||
|
|
075c09401a | ||
|
|
c23579d66c | ||
|
|
6c200c089c | ||
|
|
3eb086f5fa | ||
|
|
fbff18a723 | ||
|
|
6e7014c91b | ||
|
|
711ea1604b | ||
|
|
538a243453 | ||
|
|
8be492c080 | ||
|
|
6c7a0e5a79 | ||
|
|
f4d14c02c7 | ||
|
|
3ca2d8ae5e | ||
|
|
c23aed993f | ||
|
|
11e07caaa4 | ||
|
|
e4de49df2a | ||
|
|
47e1fbe468 | ||
|
|
8353ba7857 | ||
|
|
606c80b049 | ||
|
|
d1436e3ecc | ||
|
|
7e0e007e3e | ||
|
|
2e74f7f079 | ||
|
|
2c81c2a13f | ||
|
|
d9a0fd4f59 | ||
|
|
d1ec8f86f3 | ||
|
|
85c997513d | ||
|
|
904134cc75 | ||
|
|
15e4f1bad3 | ||
|
|
09b8b6b468 | ||
|
|
4dfc7feae0 | ||
|
|
77e6b946f4 | ||
|
|
31814934f3 | ||
|
|
b43a8b54cf | ||
|
|
a165306fd9 | ||
|
|
056d45cf6b | ||
|
|
46955e95ef | ||
|
|
e6e4ffb4ae | ||
|
|
5946e13e27 | ||
|
|
8f3e278ab9 | ||
|
|
547ed6d74d | ||
|
|
d4adcb3ccf | ||
|
|
d4628992d8 | ||
|
|
24b4b2c16d | ||
|
|
35bac672bb | ||
|
|
d649f69404 | ||
|
|
7ce5061343 | ||
|
|
20d9e25ae2 | ||
|
|
89c76f2b45 | ||
|
|
a9a68c3143 | ||
|
|
d1c1c8fb5f | ||
|
|
4228ecea98 | ||
|
|
909a821d3d | ||
|
|
7a4e0158d6 | ||
|
|
228bfbd24a | ||
|
|
45e1bc3a21 | ||
|
|
e1489d4fe3 | ||
|
|
273f612c77 | ||
|
|
a82b2b2d04 | ||
|
|
bf767b53d7 | ||
|
|
1db1941577 | ||
|
|
49f86c87b4 | ||
|
|
346e27083f | ||
|
|
6d666da4b9 | ||
|
|
feca0c2647 | ||
|
|
bf806602d8 | ||
|
|
e3ab7408c9 | ||
|
|
c49a5a7d7d | ||
|
|
450397a277 | ||
|
|
f63eba952e | ||
|
|
eaa9ba99fa | ||
|
|
f0cbc79d8b | ||
|
|
01e0136d7c | ||
|
|
520845217e | ||
|
|
42d8a0b44b | ||
|
|
84414f8fe8 | ||
|
|
046d197519 | ||
|
|
1250655ddb | ||
|
|
29b1a4f61b | ||
|
|
2d5698c719 | ||
|
|
c08e8a76ef | ||
|
|
03298eb8dd | ||
|
|
a86a57e1b8 | ||
|
|
45f2eac44c | ||
|
|
b05e753c9f | ||
|
|
f7f6233ea8 | ||
|
|
6d5c513195 | ||
|
|
131b96bbba | ||
|
|
b7587b76e0 | ||
|
|
ee43932189 | ||
|
|
9082193568 | ||
|
|
b52e503ce4 | ||
|
|
e581f732d7 | ||
|
|
c939ec1544 | ||
|
|
a2f2ed5411 | ||
|
|
55f636ffb8 | ||
|
|
cbba20804e | ||
|
|
91c2edc0f2 | ||
|
|
09a4d864da | ||
|
|
11e7937c3c | ||
|
|
22a7e3a310 | ||
|
|
4fbde727d2 | ||
|
|
990ca9cb9d | ||
|
|
21e32c042e | ||
|
|
d85bd49d87 | ||
|
|
c0853959c2 | ||
|
|
fef7920b17 | ||
|
|
b5a04827e1 | ||
|
|
bb5d6fff77 | ||
|
|
8d3a0ddd47 | ||
|
|
75aa963fef | ||
|
|
b0126b5962 | ||
|
|
a7251047b7 | ||
|
|
2f301e8404 | ||
|
|
3fae8933e5 | ||
|
|
c3a7b574c8 | ||
|
|
fa25d60df8 | ||
|
|
8130d9f3e1 | ||
|
|
3ba9647858 | ||
|
|
c77c6ea53e | ||
|
|
98f20170a3 | ||
|
|
e954bce301 | ||
|
|
8554683297 | ||
|
|
5d1a7d8d5a | ||
|
|
39101d16c3 | ||
|
|
e7a83ad70e | ||
|
|
142cdf1714 | ||
|
|
2d4011b22f | ||
|
|
eeb3f7be18 | ||
|
|
12272bb527 | ||
|
|
4403c40755 | ||
|
|
2a405f691e | ||
|
|
75393e02b8 | ||
|
|
e646853d7a | ||
|
|
3912f4d064 | ||
|
|
53d1acb0a5 | ||
|
|
23d2c4c8e4 | ||
|
|
732650d6a4 | ||
|
|
b29d68bbaf | ||
|
|
715be35764 | ||
|
|
e259056bd8 | ||
|
|
68146d0544 | ||
|
|
7e09c7ca1e | ||
|
|
4d780837ac | ||
|
|
cbc5ca770b | ||
|
|
2972cfadfb | ||
|
|
6be17538e7 | ||
|
|
e5ccce1e89 | ||
|
|
08fdbb3c7d | ||
|
|
8880bf1026 | ||
|
|
d7cb7884c3 | ||
|
|
bb19677ae4 | ||
|
|
a7a74b73f2 | ||
|
|
e4394ef5cc | ||
|
|
e4e811d0a7 | ||
|
|
6851a57ebd | ||
|
|
3b25c8637b | ||
|
|
d1244c8b1f | ||
|
|
d1a7bb4a69 | ||
|
|
a0bd8365da | ||
|
|
16a0801058 | ||
|
|
c4156376d9 | ||
|
|
4ff54139b7 | ||
|
|
8d2e0725e7 | ||
|
|
700f932ddf | ||
|
|
7485c7c7cb | ||
|
|
46a337cbc8 | ||
|
|
58d9a0d770 | ||
|
|
8f42d8c2dd | ||
|
|
b5fb980145 | ||
|
|
2b8aae05d1 | ||
|
|
2327737b14 | ||
|
|
58ce044607 | ||
|
|
85bde43c2f | ||
|
|
4fb5ab0ca8 | ||
|
|
c275cecfd1 | ||
|
|
6a2768f247 | ||
|
|
7bcf60324a | ||
|
|
c700a70872 | ||
|
|
ce4e1894f6 | ||
|
|
f60167c015 | ||
|
|
042a6cdbce | ||
|
|
85a0d71c52 | ||
|
|
fa1bbec023 | ||
|
|
1496681297 | ||
|
|
3906d17165 | ||
|
|
f297b95436 | ||
|
|
fafd9368f5 | ||
|
|
1836ecd2ed | ||
|
|
4cdaabd433 | ||
|
|
4a74a46780 | ||
|
|
b62c010e95 | ||
|
|
074534b292 | ||
|
|
b0393fba62 | ||
|
|
7166fe10b5 | ||
|
|
2890ad53c4 | ||
|
|
01e3474600 | ||
|
|
756eee087a | ||
|
|
4b2cdc4fc1 | ||
|
|
184528e4eb | ||
|
|
8cf7d6157a | ||
|
|
68324daf78 | ||
|
|
66debb1ce4 | ||
|
|
d5d9fc4684 | ||
|
|
f6b694ee2c | ||
|
|
bb623196a3 | ||
|
|
e9948f1291 | ||
|
|
378385ba60 | ||
|
|
ef5930e8bc | ||
|
|
0173571b19 | ||
|
|
35259c0c1d | ||
|
|
e7cba822e4 | ||
|
|
0d34e7a141 | ||
|
|
aedc8c0ead | ||
|
|
9c0cd5c030 | ||
|
|
2f10398c74 | ||
|
|
49ef5bccec | ||
|
|
dcbcf9803a | ||
|
|
e731eff382 | ||
|
|
a57d7ecb5b | ||
|
|
d187563d36 | ||
|
|
e91436e524 | ||
|
|
bbc2e96090 | ||
|
|
f53eb7cd59 | ||
|
|
98d19fa624 | ||
|
|
a3958190e8 | ||
|
|
6504bfef74 | ||
|
|
220cb0eb94 | ||
|
|
01e04e3341 | ||
|
|
0853e19f53 | ||
|
|
a9b8e3ecc8 | ||
|
|
bec6161dce | ||
|
|
8c580e6764 | ||
|
|
c5354951ba | ||
|
|
f1658e2e58 | ||
|
|
90d7f33522 | ||
|
|
d9c0273421 | ||
|
|
d65b1fd80b | ||
|
|
7becb5ec74 | ||
|
|
c3f5baa091 | ||
|
|
800ad150ff | ||
|
|
5608e59270 | ||
|
|
e31ed84b1b | ||
|
|
548b1d02f2 | ||
|
|
f63955a01f | ||
|
|
2996ef7156 | ||
|
|
2b1f3438e6 | ||
|
|
2a8f3a3b4e | ||
|
|
a87aa2fafe | ||
|
|
9b5e66453b | ||
|
|
46f978838d | ||
|
|
21576589c6 | ||
|
|
d7062eb367 | ||
|
|
851dc9aadc | ||
|
|
d08e112d41 | ||
|
|
77d7e47019 | ||
|
|
1bad64bc5e | ||
|
|
0794767291 | ||
|
|
d7c8a58453 | ||
|
|
4fab8fee21 | ||
|
|
3f2df4526e | ||
|
|
d6d4ead438 | ||
|
|
4e67862753 | ||
|
|
584e6dd1c2 | ||
|
|
4bb753295d | ||
|
|
892593c73b | ||
|
|
691cf338c2 | ||
|
|
beb746e5ea | ||
|
|
89faee2522 | ||
|
|
969da088f5 | ||
|
|
c50be68790 | ||
|
|
2fbb95142a | ||
|
|
755e16d962 | ||
|
|
b1063edf3e | ||
|
|
edb4cbac2b | ||
|
|
a59a69e21b | ||
|
|
4c9e009971 | ||
|
|
4531cf18c2 | ||
|
|
31bda68f24 | ||
|
|
1bf28e0d77 | ||
|
|
6a17ebe669 | ||
|
|
39446ebdb8 | ||
|
|
c2c3b0d4a9 | ||
|
|
9a90d90966 | ||
|
|
05781dd91e | ||
|
|
a6a474a83f | ||
|
|
44dd744f0a | ||
|
|
df4ec8aaad | ||
|
|
0348b169d6 | ||
|
|
54dbf3ba21 | ||
|
|
5f09a4dd0a | ||
|
|
e58e85cd5c | ||
|
|
6301778a58 | ||
|
|
3667b93871 | ||
|
|
0a8aab6b23 | ||
|
|
6a73f2b1e7 | ||
|
|
99a78f8540 | ||
|
|
8d4b296bd2 | ||
|
|
a9e1792607 | ||
|
|
0965e6ddfd | ||
|
|
35109160ca | ||
|
|
bb9933fa7e | ||
|
|
673f6fc634 | ||
|
|
09663a5558 | ||
|
|
66b15a8df6 | ||
|
|
96aa9c0a38 | ||
|
|
46736d5ecb | ||
|
|
25cf4016d3 | ||
|
|
48635fd910 | ||
|
|
456d6be022 | ||
|
|
16cf1fe5f3 | ||
|
|
e0e9bc16bf | ||
|
|
30b8993edd | ||
|
|
5c37d5293c | ||
|
|
323ae0f2a3 | ||
|
|
7ef4cd26ac | ||
|
|
df1b0c4332 | ||
|
|
4a2e1574e4 | ||
|
|
5a315f4df0 | ||
|
|
f0a914ea8d | ||
|
|
d4a458a95b | ||
|
|
5c8233515a | ||
|
|
c5c7934ebc | ||
|
|
b0ffe68675 | ||
|
|
5da79a8366 | ||
|
|
ff88510e5f | ||
|
|
df9461ecc5 | ||
|
|
98e9e9b112 | ||
|
|
9308e1bf09 | ||
|
|
aa8ccce952 | ||
|
|
ffe6bb0b7f | ||
|
|
b7982ac131 | ||
|
|
60e7ae9aee | ||
|
|
86e4f72f00 | ||
|
|
0ca9a7889a | ||
|
|
476fa4deda | ||
|
|
4f1710d2d6 | ||
|
|
1acc8191f5 | ||
|
|
0ee04261b9 | ||
|
|
745b6b94ee | ||
|
|
47651f321a | ||
|
|
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 |
@@ -1,17 +1,15 @@
|
||||
node_modules
|
||||
**/node_modules
|
||||
src/bun.js/WebKit/LayoutTests
|
||||
zig-out
|
||||
zig-build
|
||||
**/*.o
|
||||
**/*.a
|
||||
|
||||
examples
|
||||
|
||||
**/*.o
|
||||
**/.next
|
||||
.git
|
||||
src/bun.js/WebKit
|
||||
**/CMakeCache.txt
|
||||
**/node_modules
|
||||
.git
|
||||
examples
|
||||
node_modules
|
||||
packages/**/bun
|
||||
packages/**/bun-profile
|
||||
src/bun.js/WebKit
|
||||
src/bun.js/WebKit/LayoutTests
|
||||
zig-build
|
||||
zig-cache
|
||||
zig-out
|
||||
33
.gitattributes
vendored
33
.gitattributes
vendored
@@ -17,37 +17,28 @@
|
||||
*.mjs text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
|
||||
*.mts text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
|
||||
|
||||
*.lockb binary diff=lockb
|
||||
|
||||
.vscode/launch.json linguist-generated
|
||||
src/api/schema.d.ts linguist-generated
|
||||
fixture.*.c linguist-generated
|
||||
src/api/schema.js linguist-generated
|
||||
src/bun.js/bindings/sqlite/sqlite3.c linguist-vendored
|
||||
src/bun.js/bindings/sqlite/sqlite3_local.h linguist-vendored
|
||||
*.lockb binary diff=lockb
|
||||
src/bun.js/bindings/simdutf.cpp linguist-vendored
|
||||
src/bun.js/bindings/simdutf.h linguist-vendored
|
||||
|
||||
src/js/out/WebCoreJSBuiltins.cpp linguist-generated
|
||||
src/js/out/WebCoreJSBuiltins.h linguist-generated
|
||||
src/js/out/WebCoreJSBuiltins.d.ts linguist-generated
|
||||
|
||||
src/bun.js/bindings/ZigGeneratedClasses.h linguist-generated
|
||||
src/bun.js/bindings/ZigGeneratedClasses.cpp linguist-generated
|
||||
|
||||
*-fixture* linguist-generated
|
||||
src/bun.js/bindings/ZigGeneratedCode.h linguist-generated
|
||||
src/bun.js/bindings/ZigGeneratedCode.cpp linguist-generated
|
||||
|
||||
src/bun.js/bindings/headers.h linguist-generated
|
||||
src/bun.js/bindings/headers.zig linguist-generated
|
||||
|
||||
src/bun.js/bindings/JSSink.h linguist-generated
|
||||
src/bun.js/bindings/JSSink.zig linguist-generated
|
||||
packages/bun-uws/fuzzing/seed-corpus/**/* linguist-generated
|
||||
|
||||
src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h linguist-generated
|
||||
src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h linguist-generated
|
||||
src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h linguist-generated
|
||||
src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h linguist-generated
|
||||
src/bun.js/bindings/sqlite/sqlite3.c linguist-vendored
|
||||
src/bun.js/bindings/sqlite/sqlite3_local.h linguist-vendored
|
||||
src/bun.js/bindings/simdutf.cpp linguist-vendored
|
||||
src/bun.js/bindings/simdutf.h linguist-vendored
|
||||
|
||||
docs/**/* linguist-documentation
|
||||
|
||||
packages/bun-uws/fuzzing/seed-corpus/**/* linguist-generated
|
||||
# Don't count tests in the language stats - https://github.com/github-linguist/linguist/blob/master/docs/overrides.md
|
||||
test/**/* linguist-documentation
|
||||
bench/**/* linguist-documentation
|
||||
examples/**/* linguist-documentation
|
||||
|
||||
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?
|
||||
|
||||
18
.github/pull_request_template.md
vendored
18
.github/pull_request_template.md
vendored
@@ -19,18 +19,17 @@ This adds a new flag --bail to bun test. When set, it will stop running tests af
|
||||
|
||||
<!-- If JavaScript/TypeScript modules or builtins changed:
|
||||
|
||||
- [ ] I ran `make js` and committed the transpiled changes
|
||||
- [ ] I or my editor ran Prettier on the changed files (or I ran `bun fmt`)
|
||||
- [ ] I included a test for the new code, or an existing test covers it
|
||||
- [ ] I included a test for the new code, or existing tests cover it
|
||||
- [ ] I ran my tests locally and they pass (`bun-debug test test-file-name.test`)
|
||||
|
||||
-->
|
||||
|
||||
<!-- If Zig files changed:
|
||||
|
||||
- [ ] I checked the lifetime of memory allocated to verify it's (1) freed and (2) only freed when it should be
|
||||
- [ ] I or my editor ran `zig fmt` on the changed files
|
||||
- [ ] I included a test for the new code, or an existing test covers it
|
||||
- [ ] JSValue used outside outside of the stack is either wrapped in a JSC.Strong or is JSValueProtect'ed
|
||||
- [ ] I wrote TypeScript/JavaScript tests and they pass locally (`bun-debug test test-file-name.test`)
|
||||
-->
|
||||
|
||||
<!-- If new methods, getters, or setters were added to a publicly exposed class:
|
||||
@@ -43,17 +42,6 @@ This adds a new flag --bail to bun test. When set, it will stop running tests af
|
||||
- [ ] I made sure that specific versions of dependencies are used instead of ranged or tagged versions
|
||||
-->
|
||||
|
||||
<!-- If functions were added to exports.zig or bindings.zig
|
||||
|
||||
- [ ] I ran `make headers` to regenerate the C header file
|
||||
|
||||
-->
|
||||
|
||||
<!-- If \*.classes.ts files were added or changed:
|
||||
|
||||
- [ ] I ran `make codegen` to regenerate the C++ and Zig code
|
||||
-->
|
||||
|
||||
<!-- If a new builtin ESM/CJS module was added:
|
||||
|
||||
- [ ] I updated Aliases in `module_loader.zig` to include the new module
|
||||
|
||||
50
.github/workflows/bun-ecosystem-test.yml
vendored
50
.github/workflows/bun-ecosystem-test.yml
vendored
@@ -1,50 +0,0 @@
|
||||
name: bun-ecosystem-test
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 15 * * *" # every day at 7am PST
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: "The version of Bun to run"
|
||||
required: true
|
||||
default: "canary"
|
||||
type: string
|
||||
jobs:
|
||||
test:
|
||||
name: ${{ matrix.tag }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
timeout-minutes: 10
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
tag: linux-x64
|
||||
url: linux/x64?avx2=true
|
||||
- os: ubuntu-latest
|
||||
tag: linux-x64-baseline
|
||||
url: linux/x64?baseline=true
|
||||
# FIXME: runner fails with "No tests found"?
|
||||
#- os: macos-latest
|
||||
# tag: darwin-x64
|
||||
# url: darwin/x64?avx2=true
|
||||
- os: macos-latest
|
||||
tag: darwin-x64-baseline
|
||||
url: darwin/x64?baseline=true
|
||||
steps:
|
||||
- id: checkout
|
||||
name: Checkout
|
||||
uses: Bhacaz/checkout-files@v2
|
||||
with:
|
||||
files: packages/bun-internal-test
|
||||
- id: setup
|
||||
name: Setup
|
||||
uses: oven-sh/setup-bun@v1
|
||||
with:
|
||||
bun-download-url: https://bun.sh/download/${{ github.event.inputs.version }}/${{ matrix.url }}
|
||||
- id: test
|
||||
name: Test
|
||||
working-directory: packages/bun-internal-test
|
||||
run: bun run test:ecosystem
|
||||
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
|
||||
30
.github/workflows/bun-linux-aarch64.yml
vendored
30
.github/workflows/bun-linux-aarch64.yml
vendored
@@ -4,11 +4,6 @@ concurrency:
|
||||
group: bun-linux-aarch64-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
TEST_TAG: bun-test'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
@@ -16,6 +11,17 @@ on:
|
||||
paths:
|
||||
- "src/**/*"
|
||||
- "test/**/*"
|
||||
- "packages/bun-usockets/src/**/*"
|
||||
- "build.zig"
|
||||
- "Makefile"
|
||||
- "Dockerfile"
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "src/**/*"
|
||||
- "test/**/*"
|
||||
- "packages/bun-usockets/src/**/*"
|
||||
- "build.zig"
|
||||
- "Makefile"
|
||||
- "Dockerfile"
|
||||
@@ -28,6 +34,7 @@ jobs:
|
||||
runs-on: ${{matrix.runner}}
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
timeout-minutes: 90
|
||||
permissions: write-all
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
@@ -36,10 +43,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_basename: "bun-webkit-linux-arm64-lto"
|
||||
build_machine_arch: aarch64
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
@@ -71,9 +75,7 @@ jobs:
|
||||
BUILDARCH=${{matrix.build_arch}}
|
||||
BUILD_MACHINE_ARCH=${{matrix.build_machine_arch}}
|
||||
CPU_TARGET=${{matrix.cpu}}
|
||||
WEBKIT_URL=${{matrix.webkit_url}}
|
||||
GIT_SHA=${{github.sha}}
|
||||
WEBKIT_BASENAME=${{matrix.webkit_basename}}
|
||||
platforms: linux/${{matrix.build_arch}}
|
||||
target: artifact
|
||||
outputs: type=local,dest=${{runner.temp}}/release
|
||||
@@ -109,14 +111,6 @@ jobs:
|
||||
with:
|
||||
name: bun-${{matrix.tag}}
|
||||
path: ${{runner.temp}}/release/bun-${{matrix.tag}}.zip
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: bun-obj-${{matrix.tag}}
|
||||
path: ${{runner.temp}}/release/bun-obj
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{matrix.tag}}-dependencies
|
||||
path: ${{runner.temp}}/release/bun-dependencies
|
||||
- name: Release
|
||||
id: release
|
||||
uses: ncipollo/release-action@v1
|
||||
|
||||
109
.github/workflows/bun-linux-build.yml
vendored
109
.github/workflows/bun-linux-build.yml
vendored
@@ -4,11 +4,6 @@ concurrency:
|
||||
group: bun-linux-build-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
TEST_TAG: bun-test'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
@@ -16,6 +11,7 @@ on:
|
||||
paths:
|
||||
- "src/**/*"
|
||||
- "test/**/*"
|
||||
- "packages/bun-usockets/src/**/*"
|
||||
- "build.zig"
|
||||
- "Makefile"
|
||||
- "Dockerfile"
|
||||
@@ -25,6 +21,7 @@ on:
|
||||
paths:
|
||||
- "src/**/*"
|
||||
- "test/**/*"
|
||||
- "packages/bun-usockets/src/**/*"
|
||||
- "build.zig"
|
||||
- "Makefile"
|
||||
- "Dockerfile"
|
||||
@@ -37,6 +34,7 @@ jobs:
|
||||
runs-on: ${{matrix.runner}}
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
timeout-minutes: 90
|
||||
permissions: write-all
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -46,22 +44,44 @@ 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_basename: "bun-webkit-linux-amd64-lto"
|
||||
build_machine_arch: x86_64
|
||||
assertions: "OFF"
|
||||
zig_optimize: "ReleaseFast"
|
||||
target: "artifact"
|
||||
- cpu: nehalem
|
||||
tag: linux-x64-baseline
|
||||
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_basename: "bun-webkit-linux-amd64-lto"
|
||||
build_machine_arch: x86_64
|
||||
assertions: "OFF"
|
||||
zig_optimize: "ReleaseFast"
|
||||
target: "artifact"
|
||||
# - cpu: haswell
|
||||
# tag: linux-x64-assertions
|
||||
# arch: x86_64
|
||||
# build_arch: amd64
|
||||
# runner: big-ubuntu
|
||||
# build_machine_arch: x86_64
|
||||
# assertions: "ON"
|
||||
# zig_optimize: "ReleaseSafe"
|
||||
# target: "artifact-assertions"
|
||||
# - cpu: nehalem
|
||||
# tag: linux-x64-baseline-assertions
|
||||
# arch: x86_64
|
||||
# build_arch: amd64
|
||||
# runner: big-ubuntu
|
||||
# build_machine_arch: x86_64
|
||||
# assertions: "ON"
|
||||
# zig_optimize: "ReleaseSafe"
|
||||
# target: "artifact-assertions"
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
ref: ${{github.sha}}
|
||||
clean: true
|
||||
- uses: docker/setup-buildx-action@v2
|
||||
id: buildx
|
||||
with:
|
||||
@@ -89,11 +109,17 @@ jobs:
|
||||
BUILDARCH=${{matrix.build_arch}}
|
||||
BUILD_MACHINE_ARCH=${{matrix.build_machine_arch}}
|
||||
CPU_TARGET=${{matrix.cpu}}
|
||||
WEBKIT_URL=${{matrix.webkit_url}}
|
||||
GIT_SHA=${{github.sha}}
|
||||
WEBKIT_BASENAME=${{matrix.webkit_basename}}
|
||||
ASSERTIONS=${{matrix.assertions}}
|
||||
ZIG_OPTIMIZE=${{matrix.zig_optimize}}
|
||||
SCCACHE_BUCKET=bun
|
||||
SCCACHE_REGION=auto
|
||||
SCCACHE_S3_USE_SSL=true
|
||||
SCCACHE_ENDPOINT=${{ secrets.CACHE_S3_ENDPOINT }}
|
||||
AWS_ACCESS_KEY_ID=${{ secrets.CACHE_S3_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }}
|
||||
platforms: linux/${{matrix.build_arch}}
|
||||
target: artifact
|
||||
target: ${{matrix.target}}
|
||||
outputs: type=local,dest=${{runner.temp}}/release
|
||||
- name: Zip
|
||||
run: |
|
||||
@@ -152,13 +178,33 @@ 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
|
||||
needs: [linux]
|
||||
if: github.event_name == 'pull_request'
|
||||
timeout-minutes: 20
|
||||
permissions:
|
||||
pull-requests: write
|
||||
outputs:
|
||||
failing_tests: ${{ steps.test.outputs.failing_tests }}
|
||||
failing_tests_count: ${{ steps.test.outputs.failing_tests_count }}
|
||||
@@ -168,20 +214,23 @@ jobs:
|
||||
include:
|
||||
- tag: linux-x64
|
||||
- tag: linux-x64-baseline
|
||||
- tag: linux-x64-assertions
|
||||
- tag: linux-x64-baseline-assertions
|
||||
steps:
|
||||
- id: checkout
|
||||
name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: false
|
||||
clean: true
|
||||
- id: download
|
||||
name: Download
|
||||
uses: actions/download-artifact@v3
|
||||
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 +238,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 +253,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
|
||||
|
||||
460
.github/workflows/bun-mac-aarch64.yml
vendored
460
.github/workflows/bun-mac-aarch64.yml
vendored
@@ -5,9 +5,8 @@ concurrency:
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
TEST_TAG: bun-test'
|
||||
LLVM_VERSION: 16
|
||||
BUN_DOWNLOAD_URL_BASE: https://pub-5e11e972747a44bf9aaf9394f185a982.r2.dev/releases/latest
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -15,6 +14,7 @@ on:
|
||||
paths:
|
||||
- "src/**/*"
|
||||
- "test/**/*"
|
||||
- "packages/bun-usockets/src/**/*"
|
||||
- "build.zig"
|
||||
- "Makefile"
|
||||
- "Dockerfile"
|
||||
@@ -23,6 +23,7 @@ on:
|
||||
paths:
|
||||
- "src/**/*"
|
||||
- "test/**/*"
|
||||
- "packages/bun-usockets/src/**/*"
|
||||
- "build.zig"
|
||||
- "Makefile"
|
||||
- "Dockerfile"
|
||||
@@ -30,79 +31,134 @@ on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
macos-object-files:
|
||||
name: macOS Object
|
||||
macOS-zig:
|
||||
name: macOS Zig Object
|
||||
runs-on: med-ubuntu
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
# - cpu: nehalem
|
||||
# arch: x86_64
|
||||
# tag: bun-obj-darwin-x64-baseline
|
||||
# - cpu: haswell
|
||||
# arch: x86_64
|
||||
# tag: bun-obj-darwin-x64
|
||||
- cpu: native
|
||||
arch: aarch64
|
||||
tag: bun-obj-darwin-aarch64
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
- uses: docker/setup-buildx-action@v2
|
||||
- uses: actions/checkout@v4
|
||||
# - name: Checkout submodules
|
||||
# run: git submodule update --init --recursive --depth=1 --progress --force
|
||||
|
||||
- name: Setup Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
id: buildx
|
||||
with:
|
||||
install: true
|
||||
- name: Run
|
||||
run: |
|
||||
rm -rf ${{runner.temp}}/release
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Build and push
|
||||
|
||||
- name: Compile Zig Object
|
||||
uses: docker/build-push-action@v3
|
||||
if: runner.arch == 'X64'
|
||||
with:
|
||||
context: .
|
||||
push: false
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=min
|
||||
# This doesnt seem to work
|
||||
# cache-from: type=s3,endpoint_url=${{ secrets.CACHE_S3_ENDPOINT }},blobs_prefix=docker_blobs/,manifests_prefix=docker_manifests/,access_key_id=${{ secrets.CACHE_S3_ACCESS_KEY_ID }},secret_access_key=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }},bucket=bun,region=auto
|
||||
# cache-to: type=s3,endpoint_url=${{ secrets.CACHE_S3_ENDPOINT }},blobs_prefix=docker_blobs/,manifests_prefix=docker_manifests/,access_key_id=${{ secrets.CACHE_S3_ACCESS_KEY_ID }},secret_access_key=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }},bucket=bun,region=auto
|
||||
build-args: |
|
||||
BUILDARCH=${{ runner.arch == 'X64' && 'amd64' || 'arm64' }}
|
||||
BUILD_MACHINE_ARCH=${{ runner.arch == 'X64' && 'x86_64' || 'aarch64' }}
|
||||
ARCH=${{ matrix.arch }}
|
||||
BUILDARCH=amd64
|
||||
BUILD_MACHINE_ARCH=x86_64
|
||||
CPU_TARGET=${{ matrix.cpu }}
|
||||
TRIPLET=${{matrix.arch}}-macos-none
|
||||
GIT_SHA=${{github.sha}}
|
||||
platforms: linux/amd64
|
||||
TRIPLET=${{ matrix.arch }}-macos-none
|
||||
GIT_SHA=${{ github.sha }}
|
||||
platforms: linux/${{ runner.arch == 'X64' && 'amd64' || 'arm64' }}
|
||||
target: build_release_obj
|
||||
outputs: type=local,dest=${{runner.temp}}/release
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v3
|
||||
if: runner.arch == 'ARM64'
|
||||
with:
|
||||
context: .
|
||||
push: false
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=min
|
||||
build-args: |
|
||||
ARCH=${{ matrix.arch }}
|
||||
BUILDARCH=arm64
|
||||
BUILD_MACHINE_ARCH=aarch64
|
||||
CPU_TARGET=${{ matrix.cpu }}
|
||||
TRIPLET=${{matrix.arch}}-macos-none
|
||||
GIT_SHA=${{github.sha}}
|
||||
platforms: linux/arm64
|
||||
target: build_release_obj
|
||||
outputs: type=local,dest=${{runner.temp}}/release
|
||||
- uses: actions/upload-artifact@v3
|
||||
|
||||
- name: Upload Zig Object
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.tag }}
|
||||
path: ${{runner.temp}}/release/bun.o
|
||||
path: ${{runner.temp}}/release/bun-zig.o
|
||||
|
||||
macOS-dependencies:
|
||||
name: macOS Dependencies
|
||||
runs-on: ${{ matrix.runner }}
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
timeout-minutes: 15
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- cpu: native
|
||||
arch: aarch64
|
||||
tag: bun-darwin-aarch64
|
||||
obj: bun-obj-darwin-aarch64
|
||||
artifact: bun-obj-darwin-aarch64
|
||||
runner: macos-arm64
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Checkout submodules
|
||||
run: git submodule update --init --recursive --depth=1 --progress --force
|
||||
|
||||
- name: Install system dependencies
|
||||
env:
|
||||
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
|
||||
HOMEBREW_NO_AUTO_UPDATE: 1
|
||||
HOMEBREW_NO_INSTALL_CLEANUP: 1
|
||||
run: |
|
||||
brew install sccache ccache rust llvm@$LLVM_VERSION pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config --force
|
||||
echo "$(brew --prefix ccache)/bin" >> $GITHUB_PATH
|
||||
# echo "$(brew --prefix sccache)/bin" >> $GITHUB_PATH
|
||||
echo "$(brew --prefix coreutils)/libexec/gnubin" >> $GITHUB_PATH
|
||||
echo "$(brew --prefix llvm@$LLVM_VERSION)/bin" >> $GITHUB_PATH
|
||||
brew link --overwrite llvm@$LLVM_VERSION
|
||||
|
||||
- name: Hash submodule versions
|
||||
run: |
|
||||
print_data() {
|
||||
git submodule | grep -v WebKit
|
||||
llvm-config --version
|
||||
rustc --version
|
||||
cat $(echo scripts/build*.sh scripts/all-dependencies.sh | tr " " "\n" | sort)
|
||||
}
|
||||
echo "sha=$(print_data | sha1sum | cut -c 1-10)" >> $GITHUB_OUTPUT
|
||||
id: submodule-versions
|
||||
|
||||
- name: Cache submodule dependencies
|
||||
id: cache-deps-restore
|
||||
uses: actions/cache/restore@v3
|
||||
with:
|
||||
path: ${{runner.temp}}/bun-deps
|
||||
key: bun-deps-${{ matrix.tag }}-${{ steps.submodule-versions.outputs.sha }}
|
||||
|
||||
- name: Compile submodule dependencies
|
||||
if: ${{ !steps.cache-deps-restore.outputs.cache-hit }}
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
|
||||
run: |
|
||||
mkdir -p $BUN_DEPS_OUT_DIR
|
||||
bash ./scripts/clean-dependencies.sh
|
||||
bash ./scripts/all-dependencies.sh
|
||||
|
||||
- name: Cache submodule dependencies
|
||||
if: ${{ !steps.cache-deps-restore.outputs.cache-hit }}
|
||||
id: cache-deps-save
|
||||
uses: actions/cache/save@v3
|
||||
with:
|
||||
path: ${{runner.temp}}/bun-deps
|
||||
key: ${{ steps.cache-deps-restore.outputs.cache-primary-key }}
|
||||
|
||||
- name: Upload submodule dependencies
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.tag }}-deps
|
||||
path: ${{runner.temp}}/bun-deps
|
||||
|
||||
macOS-cpp:
|
||||
name: macOS C++
|
||||
runs-on: ${{ matrix.runner }}
|
||||
@@ -111,256 +167,145 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
# - cpu: nehalem
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64-baseline
|
||||
# obj: bun-obj-darwin-x64-baseline
|
||||
# runner: macos-11
|
||||
# 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"
|
||||
# dependencies: true
|
||||
# compile_obj: false
|
||||
# - cpu: haswell
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64
|
||||
# obj: bun-obj-darwin-x64
|
||||
# runner: macos-11
|
||||
# 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"
|
||||
# dependencies: true
|
||||
# compile_obj: false
|
||||
# - cpu: nehalem
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64-baseline
|
||||
# obj: bun-obj-darwin-x64-baseline
|
||||
# runner: macos-11
|
||||
# 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"
|
||||
# dependencies: false
|
||||
# compile_obj: true
|
||||
# - cpu: haswell
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64
|
||||
# obj: bun-obj-darwin-x64
|
||||
# runner: macos-11
|
||||
# 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"
|
||||
# dependencies: false
|
||||
# compile_obj: true
|
||||
- cpu: native
|
||||
arch: aarch64
|
||||
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"
|
||||
runner: macos-arm64
|
||||
dependencies: true
|
||||
compile_obj: true
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Checkout submodules
|
||||
run: git submodule update --init --recursive --depth=1 --progress -j $(sysctl -n hw.ncpu)
|
||||
- name: Install dependencies
|
||||
run: git submodule update --init --recursive --depth=1 --progress --force
|
||||
|
||||
- name: Install system dependencies
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
|
||||
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
|
||||
HOMEBREW_NO_AUTO_UPDATE: 1
|
||||
HOMEBREW_NO_INSTALL_CLEANUP: 1
|
||||
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
|
||||
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 sccache ccache rust llvm@$LLVM_VERSION pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config --force
|
||||
echo "$(brew --prefix ccache)/bin" >> $GITHUB_PATH
|
||||
# echo "$(brew --prefix sccache)/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@$LLVM_VERSION)/bin" >> $GITHUB_PATH
|
||||
brew link --overwrite llvm@$LLVM_VERSION
|
||||
|
||||
# TODO: replace with sccache
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
with:
|
||||
key: ${{ runner.os }}-ccache-${{ matrix.tag }}
|
||||
restore-keys: ${{ runner.os }}-ccache-${{ matrix.tag }}
|
||||
- name: Download WebKit
|
||||
if: matrix.compile_obj
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
|
||||
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
|
||||
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
|
||||
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
|
||||
BUN_RELEASE_DIR: ${{ runner.temp }}/release
|
||||
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
|
||||
run: |
|
||||
rm -rf $JSC_BASE_DIR
|
||||
mkdir -p $JSC_BASE_DIR
|
||||
curl -L ${{ matrix.webkit_url }} | tar -xz -C $JSC_BASE_DIR --strip-components=1
|
||||
- name: Compile dependencies
|
||||
if: matrix.dependencies
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
|
||||
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
|
||||
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
|
||||
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
|
||||
BUN_RELEASE_DIR: ${{ runner.temp }}/release
|
||||
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
|
||||
run: |
|
||||
mkdir -p $BUN_DEPS_OUT_DIR
|
||||
make vendor-without-check
|
||||
|
||||
- name: Compile C++
|
||||
if: matrix.compile_obj
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
|
||||
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
|
||||
SOURCE_DIR: ${{ github.workspace }}
|
||||
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
|
||||
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
|
||||
BUN_RELEASE_DIR: ${{ runner.temp }}/release
|
||||
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
|
||||
run: |
|
||||
mkdir -p $OBJ_DIR $BUN_DEPS_OUT_DIR
|
||||
make clean-bindings
|
||||
make -j $(sysctl -n hw.ncpu) release-bindings
|
||||
mkdir -p $OBJ_DIR
|
||||
cd $OBJ_DIR
|
||||
|
||||
cmake -S $SOURCE_DIR -B $OBJ_DIR \
|
||||
-G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUN_CPP_ONLY=1 \
|
||||
-DNO_CONFIGURE_DEPENDS=1
|
||||
|
||||
bash compile-cpp-only.sh -v
|
||||
|
||||
- name: Upload C++
|
||||
if: matrix.compile_obj
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.tag }}-cpp
|
||||
path: ${{ runner.temp }}/bun-cpp-obj
|
||||
- name: Upload Dependencies
|
||||
if: matrix.dependencies
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.tag }}-deps
|
||||
path: ${{runner.temp}}/bun-deps
|
||||
macOS:
|
||||
path: ${{ runner.temp }}/bun-cpp-obj/bun-cpp-objects.a
|
||||
macOS-link:
|
||||
name: macOS Link
|
||||
runs-on: ${{ matrix.runner }}
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
needs: [macOS-cpp, macos-object-files]
|
||||
timeout-minutes: 90
|
||||
needs: [macOS-zig, macOS-cpp, macOS-dependencies]
|
||||
timeout-minutes: 60
|
||||
permissions: write-all
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
# - cpu: nehalem
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64-baseline
|
||||
# obj: bun-obj-darwin-x64-baseline
|
||||
# package: bun-darwin-x64
|
||||
# runner: macos-11
|
||||
# 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"
|
||||
# - cpu: haswell
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64
|
||||
# obj: bun-obj-darwin-x64
|
||||
# package: bun-darwin-x64
|
||||
# runner: macos-11
|
||||
# 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"
|
||||
- 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"
|
||||
runner: macos-arm64
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
ref: ${{github.sha}}
|
||||
clean: true
|
||||
- name: Checkout submodules
|
||||
run: git submodule update --init --recursive --depth=1 --progress -j $(sysctl -n hw.ncpu)
|
||||
- name: Install dependencies
|
||||
run: git submodule update --init --recursive --depth=1 --progress --force
|
||||
|
||||
- name: Install system dependencies
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
|
||||
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
|
||||
HOMEBREW_NO_AUTO_UPDATE: 1
|
||||
HOMEBREW_NO_INSTALL_CLEANUP: 1
|
||||
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
|
||||
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 ccache llvm@$LLVM_VERSION pkg-config coreutils libtool cmake libiconv openssl@1.1 ninja --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
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
with:
|
||||
key: ${{ runner.os }}-ccache-${{ matrix.tag }}-link
|
||||
restore-keys: ${{ runner.os }}-ccache-${{ matrix.tag }}-link
|
||||
- name: Download WebKit
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
|
||||
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
|
||||
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
|
||||
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
|
||||
run: |
|
||||
rm -rf $JSC_BASE_DIR
|
||||
mkdir -p $JSC_BASE_DIR
|
||||
curl -L ${{ matrix.webkit_url }} | tar -xz -C $JSC_BASE_DIR --strip-components=1
|
||||
echo "$(brew --prefix llvm@$LLVM_VERSION)/bin" >> $GITHUB_PATH
|
||||
brew link --overwrite llvm@$LLVM_VERSION
|
||||
|
||||
curl -LO "$BUN_DOWNLOAD_URL_BASE/bun-darwin-${{matrix.arch}}.zip"
|
||||
unzip bun-darwin-${{matrix.arch}}.zip
|
||||
mkdir -p ${{ runner.temp }}/.bun/bin
|
||||
mv bun-darwin-${{matrix.arch}}/bun ${{ runner.temp }}/.bun/bin/bun
|
||||
chmod +x ${{ runner.temp }}/.bun/bin/bun
|
||||
echo "${{ runner.temp }}/.bun/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Download C++
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.tag }}-cpp
|
||||
path: ${{ runner.temp }}/bun-cpp-obj
|
||||
- name: Download Dependencies
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.tag }}-deps
|
||||
path: ${{ runner.temp }}/bun-deps
|
||||
- name: Download Object
|
||||
|
||||
- name: Download Zig Object
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.obj }}
|
||||
path: ${{ runner.temp }}/release
|
||||
|
||||
- name: Downloaded submodule dependencies
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.tag }}-deps
|
||||
path: ${{runner.temp}}/bun-deps
|
||||
|
||||
- name: Link
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
|
||||
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
|
||||
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
|
||||
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
|
||||
BUN_RELEASE_DIR: ${{ runner.temp }}/release
|
||||
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
|
||||
run: |
|
||||
rm -rf packages/${{ matrix.package }}
|
||||
mkdir -p packages/${{ matrix.package }}
|
||||
mv ${{ runner.temp }}/release/* packages/${{ matrix.package }}/
|
||||
make bun-link-lld-release copy-to-bun-release-dir-bin
|
||||
SRC_DIR=$PWD
|
||||
mkdir ${{runner.temp}}/link-build
|
||||
cd ${{runner.temp}}/link-build
|
||||
cmake $SRC_DIR \
|
||||
-G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUN_LINK_ONLY=1 \
|
||||
-DBUN_ZIG_OBJ="${{ runner.temp }}/release/bun-zig.o" \
|
||||
-DBUN_CPP_ARCHIVE="${{ runner.temp }}/bun-cpp-obj/bun-cpp-objects.a" \
|
||||
-DBUN_DEPS_OUT_DIR="${{runner.temp}}/bun-deps" \
|
||||
-DNO_CONFIGURE_DEPENDS=1
|
||||
ninja -v
|
||||
- name: Zip
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
|
||||
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
|
||||
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
|
||||
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
|
||||
BUN_RELEASE_DIR: ${{ runner.temp }}/release
|
||||
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
|
||||
run: |
|
||||
cd ${{runner.temp}}/release
|
||||
cd ${{runner.temp}}/link-build
|
||||
chmod +x bun-profile bun
|
||||
|
||||
mkdir ${{matrix.tag}}-profile
|
||||
mkdir ${{matrix.tag}}
|
||||
|
||||
/usr/bin/strip -S bun
|
||||
mkdir -p ${{matrix.tag}}-profile/ ${{matrix.tag}}/
|
||||
|
||||
mv bun-profile ${{matrix.tag}}-profile/bun-profile
|
||||
mv bun ${{matrix.tag}}/bun
|
||||
@@ -370,11 +315,11 @@ jobs:
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{matrix.tag}}-profile
|
||||
path: ${{runner.temp}}/release/${{matrix.tag}}-profile.zip
|
||||
path: ${{runner.temp}}/link-build/${{matrix.tag}}-profile.zip
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{matrix.tag}}
|
||||
path: ${{runner.temp}}/release/${{matrix.tag}}.zip
|
||||
path: ${{runner.temp}}/link-build/${{matrix.tag}}.zip
|
||||
- name: Release
|
||||
id: release
|
||||
uses: ncipollo/release-action@v1
|
||||
@@ -391,12 +336,33 @@ jobs:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
name: "Canary (${{github.sha}})"
|
||||
tag: "canary"
|
||||
artifacts: "${{runner.temp}}/release/${{matrix.tag}}.zip,${{runner.temp}}/release/${{matrix.tag}}-profile.zip"
|
||||
artifacts: "${{runner.temp}}/link-build/${{matrix.tag}}.zip,${{runner.temp}}/link-build/${{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 }}
|
||||
needs: [macOS]
|
||||
needs: [macOS-link]
|
||||
if: github.event_name == 'pull_request' && github.repository_owner == 'oven-sh'
|
||||
permissions:
|
||||
pull-requests: write
|
||||
timeout-minutes: 30
|
||||
outputs:
|
||||
failing_tests: ${{ steps.test.outputs.failing_tests }}
|
||||
@@ -419,8 +385,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 +394,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 +408,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
|
||||
|
||||
474
.github/workflows/bun-mac-x64-baseline.yml
vendored
474
.github/workflows/bun-mac-x64-baseline.yml
vendored
@@ -5,9 +5,8 @@ concurrency:
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
TEST_TAG: bun-test'
|
||||
LLVM_VERSION: 16
|
||||
BUN_DOWNLOAD_URL_BASE: https://pub-5e11e972747a44bf9aaf9394f185a982.r2.dev/releases/latest
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -15,6 +14,7 @@ on:
|
||||
paths:
|
||||
- "src/**/*"
|
||||
- "test/**/*"
|
||||
- "packages/bun-usockets/src/**/*"
|
||||
- "build.zig"
|
||||
- "Makefile"
|
||||
- "Dockerfile"
|
||||
@@ -23,6 +23,7 @@ on:
|
||||
paths:
|
||||
- "src/**/*"
|
||||
- "test/**/*"
|
||||
- "packages/bun-usockets/src/**/*"
|
||||
- "build.zig"
|
||||
- "Makefile"
|
||||
- "Dockerfile"
|
||||
@@ -47,62 +48,129 @@ jobs:
|
||||
# arch: aarch64
|
||||
# tag: bun-obj-darwin-aarch64
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
- uses: docker/setup-buildx-action@v2
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
id: buildx
|
||||
with:
|
||||
install: true
|
||||
- name: Run
|
||||
run: |
|
||||
rm -rf ${{runner.temp}}/release
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Build and push
|
||||
|
||||
- name: Compile Zig Object
|
||||
uses: docker/build-push-action@v3
|
||||
if: runner.arch == 'X64'
|
||||
with:
|
||||
context: .
|
||||
push: false
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=min
|
||||
# This doesnt seem to work
|
||||
# cache-from: type=s3,endpoint_url=${{ secrets.CACHE_S3_ENDPOINT }},blobs_prefix=docker_blobs/,manifests_prefix=docker_manifests/,access_key_id=${{ secrets.CACHE_S3_ACCESS_KEY_ID }},secret_access_key=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }},bucket=bun,region=auto
|
||||
# cache-to: type=s3,endpoint_url=${{ secrets.CACHE_S3_ENDPOINT }},blobs_prefix=docker_blobs/,manifests_prefix=docker_manifests/,access_key_id=${{ secrets.CACHE_S3_ACCESS_KEY_ID }},secret_access_key=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }},bucket=bun,region=auto
|
||||
# This was used before, but also does not really work
|
||||
cache-from: type=local,src=/tmp/.buildx-cache-${{matrix.tag}}
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache-${{matrix.tag}}
|
||||
build-args: |
|
||||
BUILDARCH=${{ runner.arch == 'X64' && 'amd64' || 'arm64' }}
|
||||
BUILD_MACHINE_ARCH=${{ runner.arch == 'X64' && 'x86_64' || 'aarch64' }}
|
||||
ARCH=${{ matrix.arch }}
|
||||
BUILDARCH=amd64
|
||||
BUILD_MACHINE_ARCH=x86_64
|
||||
CPU_TARGET=${{ matrix.cpu }}
|
||||
TRIPLET=${{matrix.arch}}-macos-none
|
||||
GIT_SHA=${{github.sha}}
|
||||
platforms: linux/amd64
|
||||
TRIPLET=${{ matrix.arch }}-macos-none
|
||||
GIT_SHA=${{ github.sha }}
|
||||
|
||||
SCCACHE_BUCKET=bun
|
||||
SCCACHE_REGION=auto
|
||||
SCCACHE_S3_USE_SSL=true
|
||||
SCCACHE_ENDPOINT=${{ secrets.CACHE_S3_ENDPOINT }}
|
||||
AWS_ACCESS_KEY_ID=${{ secrets.CACHE_S3_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }}
|
||||
platforms: linux/${{ runner.arch == 'X64' && 'amd64' || 'arm64' }}
|
||||
target: build_release_obj
|
||||
outputs: type=local,dest=${{runner.temp}}/release
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v3
|
||||
if: runner.arch == 'ARM64'
|
||||
with:
|
||||
context: .
|
||||
push: false
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=min
|
||||
build-args: |
|
||||
ARCH=${{ matrix.arch }}
|
||||
BUILDARCH=arm64
|
||||
BUILD_MACHINE_ARCH=aarch64
|
||||
CPU_TARGET=${{ matrix.cpu }}
|
||||
TRIPLET=${{matrix.arch}}-macos-none
|
||||
GIT_SHA=${{github.sha}}
|
||||
platforms: linux/arm64
|
||||
target: build_release_obj
|
||||
outputs: type=local,dest=${{runner.temp}}/release
|
||||
- uses: actions/upload-artifact@v3
|
||||
|
||||
- name: Upload Zig Object
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.tag }}
|
||||
path: ${{runner.temp}}/release/bun.o
|
||||
path: ${{runner.temp}}/release/bun-zig.o
|
||||
macOS-dependencies:
|
||||
name: macOS Dependencies
|
||||
runs-on: ${{ matrix.runner }}
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
timeout-minutes: 15
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- cpu: nehalem
|
||||
arch: x86_64
|
||||
tag: bun-darwin-x64-baseline
|
||||
obj: bun-obj-darwin-x64-baseline
|
||||
runner: macos-12
|
||||
artifact: bun-obj-darwin-x64-baseline
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Checkout submodules
|
||||
run: git submodule update --init --recursive --depth=1 --progress --force
|
||||
|
||||
- name: Install system dependencies
|
||||
env:
|
||||
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
|
||||
HOMEBREW_NO_AUTO_UPDATE: 1
|
||||
HOMEBREW_NO_INSTALL_CLEANUP: 1
|
||||
run: |
|
||||
brew install sccache ccache rust llvm@$LLVM_VERSION pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config --force
|
||||
echo "$(brew --prefix ccache)/bin" >> $GITHUB_PATH
|
||||
# echo "$(brew --prefix sccache)/bin" >> $GITHUB_PATH
|
||||
echo "$(brew --prefix coreutils)/libexec/gnubin" >> $GITHUB_PATH
|
||||
echo "$(brew --prefix llvm@$LLVM_VERSION)/bin" >> $GITHUB_PATH
|
||||
brew link --overwrite llvm@$LLVM_VERSION
|
||||
|
||||
- name: Hash submodule versions
|
||||
run: |
|
||||
print_data() {
|
||||
git submodule | grep -v WebKit
|
||||
llvm-config --version
|
||||
rustc --version
|
||||
cat $(echo scripts/build*.sh scripts/all-dependencies.sh | tr " " "\n" | sort)
|
||||
}
|
||||
echo "sha=$(print_data | sha1sum | cut -c 1-10)" >> $GITHUB_OUTPUT
|
||||
id: submodule-versions
|
||||
|
||||
- name: Cache submodule dependencies
|
||||
id: cache-deps-restore
|
||||
uses: actions/cache/restore@v3
|
||||
with:
|
||||
path: ${{runner.temp}}/bun-deps
|
||||
key: bun-deps-${{ matrix.tag }}-${{ steps.submodule-versions.outputs.sha }}
|
||||
|
||||
- name: Compile submodule dependencies
|
||||
if: ${{ !steps.cache-deps-restore.outputs.cache-hit }}
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
|
||||
run: |
|
||||
mkdir -p $BUN_DEPS_OUT_DIR
|
||||
bash ./scripts/clean-dependencies.sh
|
||||
bash ./scripts/all-dependencies.sh
|
||||
|
||||
- name: Cache submodule dependencies
|
||||
if: ${{ !steps.cache-deps-restore.outputs.cache-hit }}
|
||||
id: cache-deps-save
|
||||
uses: actions/cache/save@v3
|
||||
with:
|
||||
path: ${{runner.temp}}/bun-deps
|
||||
key: ${{ steps.cache-deps-restore.outputs.cache-primary-key }}
|
||||
|
||||
- name: Upload submodule dependencies
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.tag }}-deps
|
||||
path: ${{runner.temp}}/bun-deps
|
||||
|
||||
macOS-cpp:
|
||||
name: macOS C++
|
||||
runs-on: ${{ matrix.runner }}
|
||||
@@ -115,139 +183,70 @@ 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"
|
||||
dependencies: true
|
||||
compile_obj: false
|
||||
# - cpu: haswell
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64
|
||||
# obj: bun-obj-darwin-x64
|
||||
# runner: macos-11
|
||||
# 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"
|
||||
# dependencies: true
|
||||
# compile_obj: false
|
||||
- cpu: nehalem
|
||||
arch: x86_64
|
||||
tag: bun-darwin-x64-baseline
|
||||
obj: bun-obj-darwin-x64-baseline
|
||||
runner: macos-11
|
||||
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"
|
||||
dependencies: false
|
||||
compile_obj: true
|
||||
# - cpu: haswell
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64
|
||||
# obj: bun-obj-darwin-x64
|
||||
# runner: macos-11
|
||||
# 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"
|
||||
# dependencies: false
|
||||
# compile_obj: true
|
||||
# - cpu: native
|
||||
# arch: aarch64
|
||||
# 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"
|
||||
# runner: macos-arm64
|
||||
# dependencies: true
|
||||
# compile_obj: true
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Checkout submodules
|
||||
run: git submodule update --init --recursive --depth=1 --progress -j $(sysctl -n hw.ncpu)
|
||||
- name: Install dependencies
|
||||
run: git submodule update --init --recursive --depth=1 --progress --force
|
||||
|
||||
- name: Install system dependencies
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
|
||||
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
|
||||
HOMEBREW_NO_AUTO_UPDATE: 1
|
||||
HOMEBREW_NO_INSTALL_CLEANUP: 1
|
||||
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
|
||||
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 sccache ccache rust llvm@$LLVM_VERSION pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config --force
|
||||
echo "$(brew --prefix ccache)/bin" >> $GITHUB_PATH
|
||||
# echo "$(brew --prefix sccache)/bin" >> $GITHUB_PATH
|
||||
echo "$(brew --prefix coreutils)/libexec/gnubin" >> $GITHUB_PATH
|
||||
echo "$(brew --prefix llvm@15)/bin" >> $GITHUB_PATH
|
||||
brew link --overwrite llvm@15
|
||||
- name: ccache (dependencies)
|
||||
echo "$(brew --prefix llvm@$LLVM_VERSION)/bin" >> $GITHUB_PATH
|
||||
brew link --overwrite llvm@$LLVM_VERSION
|
||||
|
||||
curl -LO "$BUN_DOWNLOAD_URL_BASE/bun-darwin-x64-baseline.zip"
|
||||
unzip bun-darwin-x64-baseline.zip
|
||||
mkdir -p ${{ runner.temp }}/.bun/bin
|
||||
mv bun-darwin-x64-baseline/bun ${{ runner.temp }}/.bun/bin/bun
|
||||
chmod +x ${{ runner.temp }}/.bun/bin/bun
|
||||
echo "${{ runner.temp }}/.bun/bin" >> $GITHUB_PATH
|
||||
|
||||
# TODO: replace with sccache
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
if: matrix.dependencies
|
||||
with:
|
||||
key: ${{ runner.os }}-ccache-${{ matrix.tag }}-dependencies
|
||||
restore-keys: ${{ runner.os }}-ccache-${{ matrix.tag }}-dependencies
|
||||
- name: ccache (c++)
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
if: matrix.compile_obj
|
||||
with:
|
||||
key: ${{ runner.os }}-ccache-${{ matrix.tag }}-obj
|
||||
restore-keys: ${{ runner.os }}-ccache-${{ matrix.tag }}-obj
|
||||
- name: Download WebKit
|
||||
if: matrix.compile_obj
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
|
||||
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
|
||||
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
|
||||
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
|
||||
run: |
|
||||
rm -rf $JSC_BASE_DIR
|
||||
mkdir -p $JSC_BASE_DIR
|
||||
curl -L ${{ matrix.webkit_url }} | tar -xz -C $JSC_BASE_DIR --strip-components=1
|
||||
- name: Compile dependencies
|
||||
if: matrix.dependencies
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
|
||||
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
|
||||
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
|
||||
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
|
||||
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
|
||||
run: |
|
||||
mkdir -p $OBJ_DIR $BUN_DEPS_OUT_DIR
|
||||
make vendor-without-check
|
||||
key: ${{ runner.os }}-ccache-${{ matrix.tag }}
|
||||
restore-keys: ${{ runner.os }}-ccache-${{ matrix.tag }}
|
||||
|
||||
- name: Compile C++
|
||||
if: matrix.compile_obj
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
|
||||
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
|
||||
SOURCE_DIR: ${{ github.workspace }}
|
||||
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
|
||||
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
|
||||
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
|
||||
run: |
|
||||
mkdir -p $OBJ_DIR $BUN_DEPS_OUT_DIR
|
||||
make -j $(sysctl -n hw.ncpu) release-bindings
|
||||
mkdir -p $OBJ_DIR
|
||||
cd $OBJ_DIR
|
||||
|
||||
cmake -S $SOURCE_DIR -B $OBJ_DIR \
|
||||
-G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUN_CPP_ONLY=1 \
|
||||
-DNO_CONFIGURE_DEPENDS=1
|
||||
|
||||
bash compile-cpp-only.sh -v
|
||||
|
||||
- name: Upload C++
|
||||
if: matrix.compile_obj
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.tag }}-cpp
|
||||
path: ${{ runner.temp }}/bun-cpp-obj
|
||||
- name: Upload Dependencies
|
||||
if: matrix.dependencies
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.tag }}-deps
|
||||
path: ${{runner.temp}}/bun-deps
|
||||
path: ${{ runner.temp }}/bun-cpp-obj/bun-cpp-objects.a
|
||||
macOS:
|
||||
name: macOS Link
|
||||
runs-on: ${{ matrix.runner }}
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
needs: [macOS-cpp, macos-object-files]
|
||||
needs: [macOS-cpp, macos-object-files, macOS-dependencies]
|
||||
timeout-minutes: 90
|
||||
permissions: write-all
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
@@ -256,115 +255,72 @@ 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"
|
||||
# - cpu: haswell
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64
|
||||
# obj: bun-obj-darwin-x64
|
||||
# package: bun-darwin-x64
|
||||
# runner: macos-11
|
||||
# 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"
|
||||
# - 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"
|
||||
# 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)
|
||||
- name: Install dependencies
|
||||
run: git submodule update --init --recursive --depth=1 --progress --force
|
||||
|
||||
- name: Install system dependencies
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
|
||||
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
|
||||
HOMEBREW_NO_AUTO_UPDATE: 1
|
||||
HOMEBREW_NO_INSTALL_CLEANUP: 1
|
||||
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
|
||||
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 llvm@$LLVM_VERSION pkg-config coreutils libtool cmake libiconv openssl@1.1 ninja --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
|
||||
- name: ccache (link)
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
with:
|
||||
key: ${{ runner.os }}-ccache-${{ matrix.tag }}-link
|
||||
restore-keys: ${{ runner.os }}-ccache-${{ matrix.tag }}-link
|
||||
- name: Download WebKit
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
|
||||
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
|
||||
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
|
||||
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
|
||||
BUN_RELEASE_DIR: ${{ runner.temp }}/release
|
||||
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
|
||||
run: |
|
||||
rm -rf $JSC_BASE_DIR
|
||||
mkdir -p $JSC_BASE_DIR
|
||||
curl -L ${{ matrix.webkit_url }} | tar -xz -C $JSC_BASE_DIR --strip-components=1
|
||||
echo "$(brew --prefix llvm@$LLVM_VERSION)/bin" >> $GITHUB_PATH
|
||||
brew link --overwrite llvm@$LLVM_VERSION
|
||||
|
||||
curl -LO "$BUN_DOWNLOAD_URL_BASE/bun-darwin-x64-baseline.zip"
|
||||
unzip bun-darwin-x64-baseline.zip
|
||||
mkdir -p ${{ runner.temp }}/.bun/bin
|
||||
mv bun-darwin-x64-baseline/bun ${{ runner.temp }}/.bun/bin/bun
|
||||
chmod +x ${{ runner.temp }}/.bun/bin/bun
|
||||
echo "${{ runner.temp }}/.bun/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Download C++
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.tag }}-cpp
|
||||
path: ${{ runner.temp }}/bun-cpp-obj
|
||||
- name: Download Dependencies
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.tag }}-deps
|
||||
path: ${{ runner.temp }}/bun-deps
|
||||
- name: Download Object
|
||||
|
||||
- name: Download Zig Object
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.obj }}
|
||||
path: ${{ runner.temp }}/release
|
||||
|
||||
- name: Downloaded submodule dependencies
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.tag }}-deps
|
||||
path: ${{runner.temp}}/bun-deps
|
||||
|
||||
- name: Link
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
|
||||
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
|
||||
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
|
||||
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
|
||||
BUN_RELEASE_DIR: ${{ runner.temp }}/release
|
||||
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
|
||||
run: |
|
||||
rm -rf packages/${{ matrix.package }}
|
||||
mkdir -p packages/${{ matrix.package }}
|
||||
mv ${{ runner.temp }}/release/* packages/${{ matrix.package }}/
|
||||
make bun-link-lld-release copy-to-bun-release-dir-bin
|
||||
SRC_DIR=$PWD
|
||||
mkdir ${{runner.temp}}/link-build
|
||||
cd ${{runner.temp}}/link-build
|
||||
cmake $SRC_DIR \
|
||||
-G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUN_LINK_ONLY=1 \
|
||||
-DBUN_ZIG_OBJ="${{ runner.temp }}/release/bun-zig.o" \
|
||||
-DBUN_CPP_ARCHIVE="${{ runner.temp }}/bun-cpp-obj/bun-cpp-objects.a" \
|
||||
-DBUN_DEPS_OUT_DIR="${{runner.temp}}/bun-deps" \
|
||||
-DNO_CONFIGURE_DEPENDS=1
|
||||
ninja -v
|
||||
- name: Zip
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
|
||||
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
|
||||
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
|
||||
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
|
||||
BUN_RELEASE_DIR: ${{ runner.temp }}/release
|
||||
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
|
||||
run: |
|
||||
cd ${{runner.temp}}/release
|
||||
cd ${{runner.temp}}/link-build
|
||||
chmod +x bun-profile bun
|
||||
|
||||
mkdir ${{matrix.tag}}-profile
|
||||
mkdir ${{matrix.tag}}
|
||||
|
||||
/usr/bin/strip -S bun
|
||||
mkdir -p ${{matrix.tag}}-profile/ ${{matrix.tag}}/
|
||||
|
||||
mv bun-profile ${{matrix.tag}}-profile/bun-profile
|
||||
mv bun ${{matrix.tag}}/bun
|
||||
@@ -374,11 +330,11 @@ jobs:
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{matrix.tag}}-profile
|
||||
path: ${{runner.temp}}/release/${{matrix.tag}}-profile.zip
|
||||
path: ${{runner.temp}}/link-build/${{matrix.tag}}-profile.zip
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{matrix.tag}}
|
||||
path: ${{runner.temp}}/release/${{matrix.tag}}.zip
|
||||
path: ${{runner.temp}}/link-build/${{matrix.tag}}.zip
|
||||
- name: Release
|
||||
id: release
|
||||
uses: ncipollo/release-action@v1
|
||||
@@ -395,12 +351,33 @@ jobs:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
name: "Canary (${{github.sha}})"
|
||||
tag: "canary"
|
||||
artifacts: "${{runner.temp}}/release/${{matrix.tag}}.zip,${{runner.temp}}/release/${{matrix.tag}}-profile.zip"
|
||||
artifacts: "${{runner.temp}}/link-build/${{matrix.tag}}.zip,${{runner.temp}}/link-build/${{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}}
|
||||
name: macOS Test
|
||||
runs-on: ${{ matrix.runner }}
|
||||
needs: [macOS]
|
||||
if: github.event_name == 'pull_request' && github.repository_owner == 'oven-sh'
|
||||
permissions:
|
||||
pull-requests: write
|
||||
timeout-minutes: 30
|
||||
outputs:
|
||||
failing_tests: ${{ steps.test.outputs.failing_tests }}
|
||||
@@ -410,7 +387,7 @@ jobs:
|
||||
matrix:
|
||||
include:
|
||||
- tag: bun-darwin-x64-baseline
|
||||
runner: macos-11
|
||||
runner: macos-12
|
||||
steps:
|
||||
- id: checkout
|
||||
name: Checkout
|
||||
@@ -423,8 +400,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 +409,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 +423,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
|
||||
|
||||
480
.github/workflows/bun-mac-x64.yml
vendored
480
.github/workflows/bun-mac-x64.yml
vendored
@@ -5,9 +5,8 @@ concurrency:
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
TEST_TAG: bun-test'
|
||||
LLVM_VERSION: 16
|
||||
BUN_DOWNLOAD_URL_BASE: https://pub-5e11e972747a44bf9aaf9394f185a982.r2.dev/releases/latest
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -15,6 +14,7 @@ on:
|
||||
paths:
|
||||
- "src/**/*"
|
||||
- "test/**/*"
|
||||
- "packages/bun-usockets/src/**/*"
|
||||
- "build.zig"
|
||||
- "Makefile"
|
||||
- "Dockerfile"
|
||||
@@ -23,6 +23,7 @@ on:
|
||||
paths:
|
||||
- "src/**/*"
|
||||
- "test/**/*"
|
||||
- "packages/bun-usockets/src/**/*"
|
||||
- "build.zig"
|
||||
- "Makefile"
|
||||
- "Dockerfile"
|
||||
@@ -30,8 +31,8 @@ on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
macos-object-files:
|
||||
name: macOS Object
|
||||
macOS-zig:
|
||||
name: macOS Zig Object
|
||||
runs-on: med-ubuntu
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
strategy:
|
||||
@@ -43,66 +44,131 @@ jobs:
|
||||
- cpu: haswell
|
||||
arch: x86_64
|
||||
tag: bun-obj-darwin-x64
|
||||
# - cpu: native
|
||||
# arch: aarch64
|
||||
# tag: bun-obj-darwin-aarch64
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
- uses: docker/setup-buildx-action@v2
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
id: buildx
|
||||
with:
|
||||
install: true
|
||||
- name: Run
|
||||
run: |
|
||||
rm -rf ${{runner.temp}}/release
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Build and push
|
||||
|
||||
- name: Compile Zig Object
|
||||
uses: docker/build-push-action@v3
|
||||
if: runner.arch == 'X64'
|
||||
with:
|
||||
context: .
|
||||
push: false
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=min
|
||||
# This doesnt seem to work
|
||||
# cache-from: type=s3,endpoint_url=${{ secrets.CACHE_S3_ENDPOINT }},blobs_prefix=docker_blobs/,manifests_prefix=docker_manifests/,access_key_id=${{ secrets.CACHE_S3_ACCESS_KEY_ID }},secret_access_key=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }},bucket=bun,region=auto
|
||||
# cache-to: type=s3,endpoint_url=${{ secrets.CACHE_S3_ENDPOINT }},blobs_prefix=docker_blobs/,manifests_prefix=docker_manifests/,access_key_id=${{ secrets.CACHE_S3_ACCESS_KEY_ID }},secret_access_key=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }},bucket=bun,region=auto
|
||||
# This was used before, but also does not really work
|
||||
cache-from: type=local,src=/tmp/.buildx-cache-${{matrix.tag}}
|
||||
cache-to: type=local,dest=/tmp/.buildx-cache-${{matrix.tag}}
|
||||
build-args: |
|
||||
BUILDARCH=${{ runner.arch == 'X64' && 'amd64' || 'arm64' }}
|
||||
BUILD_MACHINE_ARCH=${{ runner.arch == 'X64' && 'x86_64' || 'aarch64' }}
|
||||
ARCH=${{ matrix.arch }}
|
||||
BUILDARCH=amd64
|
||||
BUILD_MACHINE_ARCH=x86_64
|
||||
CPU_TARGET=${{ matrix.cpu }}
|
||||
TRIPLET=${{matrix.arch}}-macos-none
|
||||
GIT_SHA=${{github.sha}}
|
||||
platforms: linux/amd64
|
||||
TRIPLET=${{ matrix.arch }}-macos-none
|
||||
GIT_SHA=${{ github.sha }}
|
||||
|
||||
SCCACHE_BUCKET=bun
|
||||
SCCACHE_REGION=auto
|
||||
SCCACHE_S3_USE_SSL=true
|
||||
SCCACHE_ENDPOINT=${{ secrets.CACHE_S3_ENDPOINT }}
|
||||
AWS_ACCESS_KEY_ID=${{ secrets.CACHE_S3_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }}
|
||||
platforms: linux/${{ runner.arch == 'X64' && 'amd64' || 'arm64' }}
|
||||
target: build_release_obj
|
||||
outputs: type=local,dest=${{runner.temp}}/release
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v3
|
||||
if: runner.arch == 'ARM64'
|
||||
with:
|
||||
context: .
|
||||
push: false
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=min
|
||||
build-args: |
|
||||
ARCH=${{ matrix.arch }}
|
||||
BUILDARCH=arm64
|
||||
BUILD_MACHINE_ARCH=aarch64
|
||||
CPU_TARGET=${{ matrix.cpu }}
|
||||
TRIPLET=${{matrix.arch}}-macos-none
|
||||
GIT_SHA=${{github.sha}}
|
||||
platforms: linux/arm64
|
||||
target: build_release_obj
|
||||
outputs: type=local,dest=${{runner.temp}}/release
|
||||
- uses: actions/upload-artifact@v3
|
||||
|
||||
- name: Upload Zig Object
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.tag }}
|
||||
path: ${{runner.temp}}/release/bun.o
|
||||
path: ${{runner.temp}}/release/bun-zig.o
|
||||
|
||||
macOS-dependencies:
|
||||
name: macOS Dependencies
|
||||
runs-on: ${{ matrix.runner }}
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
timeout-minutes: 15
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- cpu: haswell
|
||||
arch: x86_64
|
||||
tag: bun-darwin-x64
|
||||
obj: bun-obj-darwin-x64
|
||||
runner: macos-12
|
||||
artifact: bun-obj-darwin-x64
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Checkout submodules
|
||||
run: git submodule update --init --recursive --depth=1 --progress --force
|
||||
|
||||
- name: Install system dependencies
|
||||
env:
|
||||
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
|
||||
HOMEBREW_NO_AUTO_UPDATE: 1
|
||||
HOMEBREW_NO_INSTALL_CLEANUP: 1
|
||||
run: |
|
||||
brew install sccache ccache rust llvm@$LLVM_VERSION pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config --force
|
||||
echo "$(brew --prefix ccache)/bin" >> $GITHUB_PATH
|
||||
# echo "$(brew --prefix sccache)/bin" >> $GITHUB_PATH
|
||||
echo "$(brew --prefix coreutils)/libexec/gnubin" >> $GITHUB_PATH
|
||||
echo "$(brew --prefix llvm@$LLVM_VERSION)/bin" >> $GITHUB_PATH
|
||||
brew link --overwrite llvm@$LLVM_VERSION
|
||||
|
||||
- name: Hash submodule versions
|
||||
run: |
|
||||
print_data() {
|
||||
git submodule | grep -v WebKit
|
||||
llvm-config --version
|
||||
rustc --version
|
||||
cat $(echo scripts/build*.sh scripts/all-dependencies.sh | tr " " "\n" | sort)
|
||||
}
|
||||
echo "sha=$(print_data | sha1sum | cut -c 1-10)" >> $GITHUB_OUTPUT
|
||||
id: submodule-versions
|
||||
|
||||
- name: Cache submodule dependencies
|
||||
id: cache-deps-restore
|
||||
uses: actions/cache/restore@v3
|
||||
with:
|
||||
path: ${{runner.temp}}/bun-deps
|
||||
key: bun-deps-${{ matrix.tag }}-${{ steps.submodule-versions.outputs.sha }}
|
||||
|
||||
- name: Compile submodule dependencies
|
||||
if: ${{ !steps.cache-deps-restore.outputs.cache-hit }}
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
|
||||
run: |
|
||||
mkdir -p $BUN_DEPS_OUT_DIR
|
||||
bash ./scripts/clean-dependencies.sh
|
||||
bash ./scripts/all-dependencies.sh
|
||||
|
||||
- name: Cache submodule dependencies
|
||||
if: ${{ !steps.cache-deps-restore.outputs.cache-hit }}
|
||||
id: cache-deps-save
|
||||
uses: actions/cache/save@v3
|
||||
with:
|
||||
path: ${{runner.temp}}/bun-deps
|
||||
key: ${{ steps.cache-deps-restore.outputs.cache-primary-key }}
|
||||
|
||||
- name: Upload submodule dependencies
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.tag }}-deps
|
||||
path: ${{runner.temp}}/bun-deps
|
||||
|
||||
macOS-cpp:
|
||||
name: macOS C++
|
||||
runs-on: ${{ matrix.runner }}
|
||||
@@ -111,262 +177,149 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
# - cpu: nehalem
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64-baseline
|
||||
# obj: bun-obj-darwin-x64-baseline
|
||||
# runner: macos-11
|
||||
# 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"
|
||||
# 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"
|
||||
dependencies: true
|
||||
compile_obj: false
|
||||
# - cpu: nehalem
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64-baseline
|
||||
# obj: bun-obj-darwin-x64-baseline
|
||||
# runner: macos-11
|
||||
# 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"
|
||||
# dependencies: false
|
||||
# compile_obj: true
|
||||
- cpu: haswell
|
||||
arch: x86_64
|
||||
tag: bun-darwin-x64
|
||||
obj: bun-obj-darwin-x64
|
||||
runner: macos-11
|
||||
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"
|
||||
dependencies: false
|
||||
compile_obj: true
|
||||
# - cpu: native
|
||||
# arch: aarch64
|
||||
# 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"
|
||||
# runner: macos-arm64
|
||||
# dependencies: true
|
||||
# compile_obj: true
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- name: Checkout submodules
|
||||
run: git submodule update --init --recursive --depth=1 --progress -j $(sysctl -n hw.ncpu)
|
||||
- name: Install dependencies
|
||||
run: git submodule update --init --recursive --depth=1 --progress --force
|
||||
|
||||
- name: Install system dependencies
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
|
||||
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
|
||||
HOMEBREW_NO_AUTO_UPDATE: 1
|
||||
HOMEBREW_NO_INSTALL_CLEANUP: 1
|
||||
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
|
||||
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 sccache ccache rust llvm@$LLVM_VERSION pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config --force
|
||||
# echo "$(brew --prefix sccache)/bin" >> $GITHUB_PATH
|
||||
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
|
||||
- name: Download WebKit
|
||||
if: matrix.compile_obj
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
|
||||
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
|
||||
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
|
||||
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
|
||||
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
|
||||
run: |
|
||||
rm -rf $JSC_BASE_DIR
|
||||
mkdir -p $JSC_BASE_DIR
|
||||
curl -L ${{ matrix.webkit_url }} | tar -xz -C $JSC_BASE_DIR --strip-components=1
|
||||
- name: ccache (dependencies)
|
||||
echo "$(brew --prefix llvm@$LLVM_VERSION)/bin" >> $GITHUB_PATH
|
||||
brew link --overwrite llvm@$LLVM_VERSION
|
||||
|
||||
curl -LO "$BUN_DOWNLOAD_URL_BASE/bun-darwin-x64.zip"
|
||||
unzip bun-darwin-x64.zip
|
||||
mkdir -p ${{ runner.temp }}/.bun/bin
|
||||
mv bun-darwin-x64/bun ${{ runner.temp }}/.bun/bin/bun
|
||||
chmod +x ${{ runner.temp }}/.bun/bin/bun
|
||||
echo "${{ runner.temp }}/.bun/bin" >> $GITHUB_PATH
|
||||
|
||||
# TODO: replace with sccache
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
if: matrix.dependencies
|
||||
with:
|
||||
key: ${{ runner.os }}-ccache-${{ matrix.tag }}-dependencies
|
||||
restore-keys: ${{ runner.os }}-ccache-${{ matrix.tag }}-dependencies
|
||||
- name: ccache (c++)
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
if: matrix.compile_obj
|
||||
with:
|
||||
key: ${{ runner.os }}-ccache-${{ matrix.tag }}-obj
|
||||
restore-keys: ${{ runner.os }}-ccache-${{ matrix.tag }}-obj
|
||||
- name: Compile dependencies
|
||||
if: matrix.dependencies
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
|
||||
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
|
||||
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
|
||||
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
|
||||
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
|
||||
run: |
|
||||
mkdir -p $OBJ_DIR $BUN_DEPS_OUT_DIR
|
||||
make vendor-without-check
|
||||
key: ${{ runner.os }}-ccache-${{ matrix.tag }}
|
||||
restore-keys: ${{ runner.os }}-ccache-${{ matrix.tag }}
|
||||
|
||||
- name: Compile C++
|
||||
if: matrix.compile_obj
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
|
||||
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
|
||||
SOURCE_DIR: ${{ github.workspace }}
|
||||
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
|
||||
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
|
||||
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
|
||||
run: |
|
||||
mkdir -p $OBJ_DIR $BUN_DEPS_OUT_DIR
|
||||
make -j $(sysctl -n hw.ncpu) release-bindings
|
||||
mkdir -p $OBJ_DIR
|
||||
cd $OBJ_DIR
|
||||
|
||||
cmake -S $SOURCE_DIR -B $OBJ_DIR \
|
||||
-G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUN_CPP_ONLY=1 \
|
||||
-DNO_CONFIGURE_DEPENDS=1
|
||||
|
||||
bash compile-cpp-only.sh -v
|
||||
|
||||
- name: Upload C++
|
||||
if: matrix.compile_obj
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.tag }}-cpp
|
||||
path: ${{ runner.temp }}/bun-cpp-obj
|
||||
- name: Upload Dependencies
|
||||
if: matrix.dependencies
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.tag }}-deps
|
||||
path: ${{runner.temp}}/bun-deps
|
||||
|
||||
path: ${{ runner.temp }}/bun-cpp-obj/bun-cpp-objects.a
|
||||
macOS:
|
||||
name: macOS Link
|
||||
runs-on: ${{ matrix.runner }}
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
needs: [macOS-cpp, macos-object-files]
|
||||
needs: [macOS-cpp, macOS-zig, macOS-dependencies]
|
||||
timeout-minutes: 90
|
||||
permissions: write-all
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
# - cpu: nehalem
|
||||
# arch: x86_64
|
||||
# tag: bun-darwin-x64-baseline
|
||||
# obj: bun-obj-darwin-x64-baseline
|
||||
# package: bun-darwin-x64
|
||||
# runner: macos-11
|
||||
# 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"
|
||||
- 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"
|
||||
# - 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"
|
||||
# runner: macos-arm64
|
||||
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-4/bun-webkit-macos-amd64-lto.tar.gz"
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Checkout submodules
|
||||
run: git submodule update --init --recursive --depth=1 --progress -j $(sysctl -n hw.ncpu)
|
||||
- name: Install dependencies
|
||||
run: git submodule update --init --recursive --depth=1 --progress --force
|
||||
|
||||
- name: Install system dependencies
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
|
||||
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
|
||||
HOMEBREW_NO_AUTO_UPDATE: 1
|
||||
HOMEBREW_NO_INSTALL_CLEANUP: 1
|
||||
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
|
||||
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 ccache llvm@$LLVM_VERSION pkg-config coreutils libtool cmake libiconv openssl@1.1 ninja --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
|
||||
- name: Download WebKit
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
|
||||
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
|
||||
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
|
||||
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
|
||||
BUN_RELEASE_DIR: ${{ runner.temp }}/release
|
||||
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
|
||||
run: |
|
||||
rm -rf $JSC_BASE_DIR
|
||||
mkdir -p $JSC_BASE_DIR
|
||||
curl -L ${{ matrix.webkit_url }} | tar -xz -C $JSC_BASE_DIR --strip-components=1
|
||||
echo "$(brew --prefix llvm@$LLVM_VERSION)/bin" >> $GITHUB_PATH
|
||||
brew link --overwrite llvm@$LLVM_VERSION
|
||||
|
||||
curl -LO "$BUN_DOWNLOAD_URL_BASE/bun-darwin-x64-baseline.zip"
|
||||
unzip bun-darwin-x64-baseline.zip
|
||||
mkdir -p ${{ runner.temp }}/.bun/bin
|
||||
mv bun-darwin-x64-baseline/bun ${{ runner.temp }}/.bun/bin/bun
|
||||
chmod +x ${{ runner.temp }}/.bun/bin/bun
|
||||
echo "${{ runner.temp }}/.bun/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Download C++
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.tag }}-cpp
|
||||
path: ${{ runner.temp }}/bun-cpp-obj
|
||||
- name: Download Dependencies
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.tag }}-deps
|
||||
path: ${{ runner.temp }}/bun-deps
|
||||
- name: Download Object
|
||||
|
||||
- name: Download Zig Object
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: ${{ matrix.obj }}
|
||||
path: ${{ runner.temp }}/release
|
||||
- name: ccache (link)
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
|
||||
- name: Downloaded submodule dependencies
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
key: ${{ runner.os }}-ccache-${{ matrix.tag }}-link
|
||||
restore-keys: ${{ runner.os }}-ccache-${{ matrix.tag }}-link
|
||||
name: ${{ matrix.tag }}-deps
|
||||
path: ${{runner.temp}}/bun-deps
|
||||
|
||||
- name: Link
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
|
||||
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
|
||||
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
|
||||
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
|
||||
BUN_RELEASE_DIR: ${{ runner.temp }}/release
|
||||
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
|
||||
run: |
|
||||
rm -rf packages/${{ matrix.package }}
|
||||
mkdir -p packages/${{ matrix.package }}
|
||||
mv ${{ runner.temp }}/release/* packages/${{ matrix.package }}/
|
||||
make bun-link-lld-release copy-to-bun-release-dir-bin
|
||||
SRC_DIR=$PWD
|
||||
mkdir ${{runner.temp}}/link-build
|
||||
cd ${{runner.temp}}/link-build
|
||||
cmake $SRC_DIR \
|
||||
-G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUN_LINK_ONLY=1 \
|
||||
-DBUN_ZIG_OBJ="${{ runner.temp }}/release/bun-zig.o" \
|
||||
-DBUN_CPP_ARCHIVE="${{ runner.temp }}/bun-cpp-obj/bun-cpp-objects.a" \
|
||||
-DBUN_DEPS_OUT_DIR="${{runner.temp}}/bun-deps" \
|
||||
-DNO_CONFIGURE_DEPENDS=1
|
||||
ninja -v
|
||||
- name: Zip
|
||||
env:
|
||||
CPU_TARGET: ${{ matrix.cpu }}
|
||||
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
|
||||
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
|
||||
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
|
||||
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
|
||||
BUN_RELEASE_DIR: ${{ runner.temp }}/release
|
||||
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
|
||||
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
|
||||
run: |
|
||||
cd ${{runner.temp}}/release
|
||||
cd ${{runner.temp}}/link-build
|
||||
chmod +x bun-profile bun
|
||||
|
||||
mkdir ${{matrix.tag}}-profile
|
||||
mkdir ${{matrix.tag}}
|
||||
|
||||
/usr/bin/strip -S bun
|
||||
mkdir -p ${{matrix.tag}}-profile/ ${{matrix.tag}}/
|
||||
|
||||
mv bun-profile ${{matrix.tag}}-profile/bun-profile
|
||||
mv bun ${{matrix.tag}}/bun
|
||||
@@ -376,11 +329,11 @@ jobs:
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{matrix.tag}}-profile
|
||||
path: ${{runner.temp}}/release/${{matrix.tag}}-profile.zip
|
||||
path: ${{runner.temp}}/link-build/${{matrix.tag}}-profile.zip
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{matrix.tag}}
|
||||
path: ${{runner.temp}}/release/${{matrix.tag}}.zip
|
||||
path: ${{runner.temp}}/link-build/${{matrix.tag}}.zip
|
||||
- name: Release
|
||||
id: release
|
||||
uses: ncipollo/release-action@v1
|
||||
@@ -397,12 +350,33 @@ jobs:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
name: "Canary (${{github.sha}})"
|
||||
tag: "canary"
|
||||
artifacts: "${{runner.temp}}/release/${{matrix.tag}}.zip,${{runner.temp}}/release/${{matrix.tag}}-profile.zip"
|
||||
artifacts: "${{runner.temp}}/link-build/${{matrix.tag}}.zip,${{runner.temp}}/link-build/${{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 }}
|
||||
needs: [macOS]
|
||||
if: github.event_name == 'pull_request' && github.repository_owner == 'oven-sh'
|
||||
permissions:
|
||||
pull-requests: write
|
||||
timeout-minutes: 30
|
||||
outputs:
|
||||
failing_tests: ${{ steps.test.outputs.failing_tests }}
|
||||
@@ -412,7 +386,7 @@ jobs:
|
||||
matrix:
|
||||
include:
|
||||
- tag: bun-darwin-x64
|
||||
runner: macos-11
|
||||
runner: macos-12
|
||||
steps:
|
||||
- id: checkout
|
||||
name: Checkout
|
||||
@@ -425,8 +399,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 +408,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 +422,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
|
||||
54
.github/workflows/bun-release-types-canary.yml
vendored
54
.github/workflows/bun-release-types-canary.yml
vendored
@@ -1,54 +0,0 @@
|
||||
name: bun-release-types-canary
|
||||
concurrency: release-canary
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "packages/bun-types/**"
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
npm-types:
|
||||
name: Release types to NPM
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
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%dT%H%M%S')"
|
||||
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
|
||||
246
.github/workflows/bun-release.yml
vendored
246
.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.tag_name) && 'true' || '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,45 @@ 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
|
||||
bun-version: latest
|
||||
- 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 (canary)
|
||||
if: ${{ env.BUN_VERSION == 'canary' }}
|
||||
uses: JS-DevTools/npm-publish@v1
|
||||
with:
|
||||
package: packages/bun-types/dist/package.json
|
||||
token: ${{ secrets.NPM_TOKEN }}
|
||||
tag: canary
|
||||
- name: Release (latest)
|
||||
if: ${{ env.BUN_LATEST == 'true' }}
|
||||
uses: JS-DevTools/npm-publish@v1
|
||||
with:
|
||||
package: packages/bun-types/dist/package.json
|
||||
@@ -130,20 +144,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 +177,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 +238,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 }}
|
||||
|
||||
337
.github/workflows/bun-windows-x64.yml
vendored
Normal file
337
.github/workflows/bun-windows-x64.yml
vendored
Normal file
@@ -0,0 +1,337 @@
|
||||
name: bun-windows-x64
|
||||
|
||||
concurrency:
|
||||
group: bun-windows-x64-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
# note: in other files, this version is only the major version, but for windows it is the full version
|
||||
LLVM_VERSION: 16.0.6
|
||||
BUN_DOWNLOAD_URL_BASE: https://pub-5e11e972747a44bf9aaf9394f185a982.r2.dev/releases/latest
|
||||
|
||||
cpu: native
|
||||
arch: x86_64
|
||||
tag: bun-windows-x64
|
||||
# TODO: wire this up to workflow_dispatch.
|
||||
# github's expression syntax makes this hard to set a default to true
|
||||
canary: true
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- "src/**/*"
|
||||
- "test/**/*"
|
||||
- "packages/bun-usockets/src/**/*"
|
||||
- "build.zig"
|
||||
- "Makefile"
|
||||
- "Dockerfile"
|
||||
pull_request:
|
||||
branches: [main]
|
||||
paths:
|
||||
- "src/**/*"
|
||||
- "test/**/*"
|
||||
- "packages/bun-usockets/src/**/*"
|
||||
- "build.zig"
|
||||
- "Makefile"
|
||||
- "Dockerfile"
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
# inputs:
|
||||
# is-canary:
|
||||
# type: boolean
|
||||
# description: Is Canary Build?
|
||||
# default: true
|
||||
|
||||
jobs:
|
||||
windows-zig:
|
||||
name: Zig Build
|
||||
runs-on: med-ubuntu
|
||||
timeout-minutes: 60
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
id: buildx
|
||||
with:
|
||||
install: true
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Calculate Canary Revision
|
||||
if: ${{ env.canary == 'true' }}
|
||||
id: canary
|
||||
run: |
|
||||
echo "canary_revision=$(GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" bash ./scripts/calculate-canary-revision.sh --raw)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Compile Zig Object
|
||||
uses: docker/build-push-action@v3
|
||||
if: runner.arch == 'X64'
|
||||
with:
|
||||
context: .
|
||||
push: false
|
||||
# This doesnt seem to work
|
||||
# cache-from: type=s3,endpoint_url=${{ secrets.CACHE_S3_ENDPOINT }},blobs_prefix=docker_blobs/,manifests_prefix=docker_manifests/,access_key_id=${{ secrets.CACHE_S3_ACCESS_KEY_ID }},secret_access_key=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }},bucket=bun,region=auto
|
||||
# cache-to: type=s3,endpoint_url=${{ secrets.CACHE_S3_ENDPOINT }},blobs_prefix=docker_blobs/,manifests_prefix=docker_manifests/,access_key_id=${{ secrets.CACHE_S3_ACCESS_KEY_ID }},secret_access_key=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }},bucket=bun,region=auto
|
||||
build-args: |
|
||||
BUILDARCH=${{ runner.arch == 'X64' && 'amd64' || 'arm64' }}
|
||||
BUILD_MACHINE_ARCH=${{ runner.arch == 'X64' && 'x86_64' || 'aarch64' }}
|
||||
ARCH=${{ env.arch }}
|
||||
CPU_TARGET=${{ env.cpu }}
|
||||
TRIPLET=${{ env.arch }}-windows-msvc
|
||||
GIT_SHA=${{ github.sha }}
|
||||
CANARY=${{ env.canary == 'true' && steps.canary.outputs.canary_revision || '0' }}
|
||||
platforms: linux/${{ runner.arch == 'X64' && 'amd64' || 'arm64' }}
|
||||
target: build_release_obj
|
||||
outputs: type=local,dest=${{runner.temp}}/release
|
||||
|
||||
- name: Upload Zig Object
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ env.tag }}-zig
|
||||
path: ${{runner.temp}}/release/bun-zig.o
|
||||
|
||||
windows-dependencies:
|
||||
name: Dependencies
|
||||
runs-on: windows
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Clone Submodules
|
||||
run: .\scripts\update-submodules.ps1
|
||||
- name: Hash submodule versions
|
||||
shell: pwsh
|
||||
run: |
|
||||
$data = "$(& {
|
||||
git submodule | Where-Object { $_ -notmatch 'WebKit' }
|
||||
clang --version
|
||||
rustc --version
|
||||
Get-Content -Path (Get-ChildItem -Path 'scripts/build*.sh', 'scripts/all-dependencies.sh' | Sort-Object -Property Name).FullName | Out-String
|
||||
})"
|
||||
$hash = ( -join ((New-Object -TypeName System.Security.Cryptography.SHA1CryptoServiceProvider).ComputeHash([System.Text.Encoding]::UTF8.GetBytes($data)) | ForEach-Object { $_.ToString("x2") } )).Substring(0, 10)
|
||||
echo "sha=${hash}" >> $env:GITHUB_OUTPUT
|
||||
id: submodule-versions
|
||||
|
||||
- name: Try fetch dependencies
|
||||
id: cache-deps-restore
|
||||
uses: actions/cache/restore@v3
|
||||
with:
|
||||
path: bun-deps
|
||||
key: bun-deps-${{ env.tag }}-${{ steps.submodule-versions.outputs.sha }}
|
||||
|
||||
- name: Install LLVM ${{ env.LLVM_VERSION }}
|
||||
if: ${{ !steps.cache-deps-restore.outputs.cache-hit }}
|
||||
uses: KyleMayes/install-llvm-action@1a3da29f56261a1e1f937ec88f0856a9b8321d7e
|
||||
with:
|
||||
version: ${{ env.LLVM_VERSION }}
|
||||
|
||||
- name: Install Ninja
|
||||
if: ${{ !steps.cache-deps-restore.outputs.cache-hit }}
|
||||
run: choco install -y ninja
|
||||
|
||||
- name: Build Dependencies
|
||||
if: ${{ !steps.cache-deps-restore.outputs.cache-hit }}
|
||||
run: |
|
||||
.\scripts\env.ps1
|
||||
Invoke-WebRequest -Uri "https://www.nasm.us/pub/nasm/releasebuilds/2.16.01/win64/nasm-2.16.01-win64.zip" -OutFile nasm.zip
|
||||
Expand-Archive nasm.zip (mkdir -Force "nasm")
|
||||
$Nasm = (Get-ChildItem "nasm")
|
||||
$env:Path += ";${Nasm}"
|
||||
$env:BUN_DEPS_OUT_DIR = (mkdir -Force "./bun-deps")
|
||||
.\scripts\all-dependencies.ps1
|
||||
|
||||
- name: Upload Dependencies
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ env.tag }}-deps
|
||||
path: bun-deps/
|
||||
|
||||
- name: Cache Dependencies
|
||||
if: ${{ !steps.cache-deps-restore.outputs.cache-hit }}
|
||||
id: cache-deps-save
|
||||
uses: actions/cache/save@v3
|
||||
with:
|
||||
path: bun-deps
|
||||
key: ${{ steps.cache-deps-restore.outputs.cache-primary-key }}
|
||||
|
||||
windows-codegen:
|
||||
name: Codegen
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: |
|
||||
curl -fsSL $BUN_DOWNLOAD_URL_BASE/bun-linux-x64.zip > bun.zip
|
||||
unzip bun.zip
|
||||
export PATH="$PWD/bun-linux-x64:$PATH"
|
||||
./scripts/cross-compile-codegen.sh win32 x64
|
||||
# Sort of a hack to do this step in the codegen stage
|
||||
- name: Calculate Canary Revision
|
||||
if: ${{ env.canary == 'true' }}
|
||||
run: |
|
||||
echo "canary_revision=$(GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" bash ./scripts/calculate-canary-revision.sh --raw)" > build-codegen-win32-x64/.canary_revision
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ env.tag }}-codegen
|
||||
path: build-codegen-win32-x64/
|
||||
|
||||
windows-cpp:
|
||||
name: C++ Build
|
||||
needs: [windows-codegen]
|
||||
runs-on: windows
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
timeout-minutes: 90
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: KyleMayes/install-llvm-action@1a3da29f56261a1e1f937ec88f0856a9b8321d7e
|
||||
with:
|
||||
version: ${{ env.LLVM_VERSION }}
|
||||
- run: choco install -y ninja
|
||||
- name: Download Codegen
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: ${{ env.tag }}-codegen
|
||||
path: build
|
||||
- name: Build C++
|
||||
run: |
|
||||
# Using SCCache is blocked by
|
||||
# https://github.com/mozilla/sccache/issues/1843
|
||||
# https://github.com/mozilla/sccache/pull/1856
|
||||
# $sczip = "sccache-v0.6.0-x86_64-pc-windows-msvc"
|
||||
|
||||
# Invoke-WebRequest -Uri "https://github.com/mozilla/sccache/releases/download/v0.6.0/${sczip}.zip" -OutFile "${sczip}.zip"
|
||||
# Expand-Archive "${sczip}.zip"
|
||||
# $env:SCCACHE_BUCKET="bun"
|
||||
# $env:SCCACHE_REGION="auto"
|
||||
# $env:SCCACHE_S3_USE_SSL="true"
|
||||
# $env:SCCACHE_ENDPOINT="${{ secrets.CACHE_S3_ENDPOINT }}"
|
||||
# $env:AWS_ACCESS_KEY_ID="${{ secrets.CACHE_S3_ACCESS_KEY_ID }}"
|
||||
# $env:AWS_SECRET_ACCESS_KEY="${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }}"
|
||||
# $SCCACHE="$PWD/${sczip}/${sczip}/sccache.exe"
|
||||
|
||||
$CANARY_REVISION = if (Test-Path build/.canary_revision) { Get-Content build/.canary_revision } else { "0" }
|
||||
|
||||
.\scripts\env.ps1
|
||||
.\scripts\update-submodules.ps1
|
||||
.\scripts\build-libuv.ps1 -CloneOnly $True
|
||||
cd build
|
||||
# "-DCCACHE_PROGRAM=${SCCACHE}"
|
||||
# TODO(@paperdave): pass the proper revision of canary here. without it,
|
||||
# the properties window will display the wrong version.
|
||||
# not really a big deal for time being. should be resolved before release
|
||||
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release `
|
||||
-DNO_CODEGEN=1 `
|
||||
-DNO_CONFIGURE_DEPENDS=1 `
|
||||
"-DCANARY=${CANARY_REVISION}" `
|
||||
-DBUN_CPP_ONLY=1
|
||||
if ($LASTEXITCODE -ne 0) { throw "CMake configuration failed" }
|
||||
.\compile-cpp-only.ps1 -v
|
||||
if ($LASTEXITCODE -ne 0) { throw "C++ compilation failed" }
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ env.tag }}-cpp
|
||||
path: build/bun-cpp-objects.a
|
||||
|
||||
windows-link:
|
||||
name: Link
|
||||
needs: [windows-dependencies, windows-codegen, windows-cpp, windows-zig]
|
||||
runs-on: windows-latest
|
||||
if: github.repository_owner == 'oven-sh'
|
||||
timeout-minutes: 30
|
||||
permissions: write-all
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: KyleMayes/install-llvm-action@1a3da29f56261a1e1f937ec88f0856a9b8321d7e
|
||||
with:
|
||||
version: ${{ env.LLVM_VERSION }}
|
||||
- run: choco install -y ninja
|
||||
- name: Download Codegen
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: ${{ env.tag }}-codegen
|
||||
path: build
|
||||
- name: Download Dependencies
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: ${{ env.tag }}-deps
|
||||
path: bun-deps
|
||||
- name: Download Zig Object
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: ${{ env.tag }}-zig
|
||||
path: bun-zig
|
||||
- name: Download C++ Objects
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: ${{ env.tag }}-cpp
|
||||
path: bun-cpp
|
||||
- name: Link
|
||||
run: |
|
||||
.\scripts\update-submodules.ps1
|
||||
.\scripts\env.ps1
|
||||
Set-Location build
|
||||
$CANARY_REVISION = if (Test-Path build/.canary_revision) { Get-Content build/.canary_revision } else { "0" }
|
||||
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release `
|
||||
-DNO_CODEGEN=1 `
|
||||
-DNO_CONFIGURE_DEPENDS=1 `
|
||||
"-DCANARY=${CANARY_REVISION}" `
|
||||
-DBUN_LINK_ONLY=1 `
|
||||
"-DBUN_DEPS_OUT_DIR=$(Resolve-Path ../bun-deps)" `
|
||||
"-DBUN_CPP_ARCHIVE=$(Resolve-Path ../bun-cpp/bun-cpp-objects.a)" `
|
||||
"-DBUN_ZIG_OBJ=$(Resolve-Path ../bun-zig/bun-zig.o)"
|
||||
if ($LASTEXITCODE -ne 0) { throw "CMake configuration failed" }
|
||||
ninja -v
|
||||
if ($LASTEXITCODE -ne 0) { throw "Link failed!" }
|
||||
- name: Package
|
||||
run: |
|
||||
$Dist = mkdir -Force "${{ env.tag }}"
|
||||
cp -r build\bun.exe "$Dist\bun.exe"
|
||||
Compress-Archive $Dist ${{ env.tag }}.zip
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ${{ env.tag }}
|
||||
path: ${{ env.tag }}.zip
|
||||
- name: Release
|
||||
id: release
|
||||
uses: ncipollo/release-action@v1
|
||||
if: |
|
||||
github.repository_owner == 'oven-sh'
|
||||
&& github.ref == 'refs/heads/main'
|
||||
with:
|
||||
prerelease: true
|
||||
body: "This canary release of Bun corresponds to the commit [${{ github.sha }}]"
|
||||
allowUpdates: true
|
||||
replacesArtifacts: true
|
||||
generateReleaseNotes: true
|
||||
artifactErrorsFailBuild: true
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
name: "Canary (${{github.sha}})"
|
||||
tag: "canary"
|
||||
artifacts: "${{env.tag}}.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 ${{ env.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}})
|
||||
45
.github/workflows/format.yml
vendored
Normal file
45
.github/workflows/format.yml
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
name: autofix.ci # Must be named this for autofix.ci to work
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
env:
|
||||
ZIG_VERSION: 0.12.0-dev.1604+caae40c21
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
format:
|
||||
name: format
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: |
|
||||
src
|
||||
packages
|
||||
test
|
||||
bench
|
||||
- name: Setup Bun
|
||||
uses: oven-sh/setup-bun@v1
|
||||
with:
|
||||
bun-version: latest
|
||||
- name: Setup Zig
|
||||
uses: goto-bus-stop/setup-zig@c7b6cdd3adba8f8b96984640ff172c37c93f73ee
|
||||
with:
|
||||
version: ${{ env.ZIG_VERSION }}
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
bun install
|
||||
- name: Format
|
||||
run: |
|
||||
bun fmt
|
||||
bun fmt:zig
|
||||
- name: Commit # https://autofix.ci/
|
||||
uses: autofix-ci/action@d3e591514b99d0fca6779455ff8338516663f7cc
|
||||
76
.github/workflows/prettier-fmt.yml
vendored
76
.github/workflows/prettier-fmt.yml
vendored
@@ -1,76 +0,0 @@
|
||||
name: prettier
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- jarred/test-actions
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
prettier-fmt:
|
||||
name: prettier
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
prettier_fmt_errs: ${{ steps.fmt.outputs.prettier_fmt_errs }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- id: setup
|
||||
name: Setup
|
||||
uses: oven-sh/setup-bun@v1
|
||||
with:
|
||||
bun-version: latest
|
||||
- id: install
|
||||
name: Install prettier
|
||||
run: bun install
|
||||
- name: Run prettier
|
||||
id: fmt
|
||||
run: |
|
||||
rm -f .failed
|
||||
bun prettier --check "./bench/**/*.{ts,tsx,js,jsx,mjs}" "./test/**/*.{ts,tsx,js,jsx,mjs}" "./src/**/*.{ts,tsx,js,jsx}" --config .prettierrc.cjs 2> prettier-fmt.err > prettier-fmt1.err || echo 'failed' > .failed
|
||||
|
||||
if [ -s .failed ]; then
|
||||
delimiter="$(openssl rand -hex 8)"
|
||||
echo "prettier_fmt_errs<<${delimiter}" >> "${GITHUB_OUTPUT}"
|
||||
cat prettier-fmt.err >> "${GITHUB_OUTPUT}"
|
||||
cat prettier-fmt1.err >> "${GITHUB_OUTPUT}"
|
||||
echo "${delimiter}" >> "${GITHUB_OUTPUT}"
|
||||
fi
|
||||
- name: Comment on PR
|
||||
if: steps.fmt.outputs.prettier_fmt_errs != ''
|
||||
uses: thollander/actions-comment-pull-request@v2
|
||||
with:
|
||||
comment_tag: prettier-fmt
|
||||
message: |
|
||||
❌ @${{ github.actor }} `prettier` reported errors
|
||||
|
||||
```js
|
||||
${{ steps.fmt.outputs.prettier_fmt_errs }}
|
||||
```
|
||||
|
||||
To one-off fix this manually, run:
|
||||
```sh
|
||||
bun fmt
|
||||
```
|
||||
|
||||
You might need to run `bun install` locally and configure your text editor to [auto-format on save](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode).
|
||||
|
||||
<sup>[#${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})</sup>
|
||||
- name: Uncomment on PR
|
||||
if: steps.fmt.outputs.prettier_fmt_errs == ''
|
||||
uses: thollander/actions-comment-pull-request@v2
|
||||
with:
|
||||
comment_tag: prettier-fmt
|
||||
mode: upsert
|
||||
create_if_not_exists: false
|
||||
message: |
|
||||
✅ `prettier` errors have been resolved. Thank you.
|
||||
|
||||
<sup>[#${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})</sup>
|
||||
- name: Fail the job
|
||||
if: steps.fmt.outputs.prettier_fmt_errs != ''
|
||||
run: exit 1
|
||||
87
.github/workflows/zig-fmt.yml
vendored
87
.github/workflows/zig-fmt.yml
vendored
@@ -1,87 +0,0 @@
|
||||
name: zig-fmt
|
||||
|
||||
env:
|
||||
ZIG_VERSION: 0.12.0-dev.163+6780a6bbf
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- jarred/test-actions
|
||||
paths:
|
||||
- "src/**/*.zig"
|
||||
- "src/*.zig"
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
zig-fmt:
|
||||
name: zig fmt
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
zig_fmt_errs: ${{ steps.fmt.outputs.zig_fmt_errs }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Install zig
|
||||
run: |
|
||||
curl https://ziglang.org/builds/zig-linux-x86_64-${{env.ZIG_VERSION}}.tar.xz -L -o zig.tar.xz
|
||||
tar -xf zig.tar.xz
|
||||
echo "$(pwd)/zig-linux-x86_64-${{env.ZIG_VERSION}}" >> $GITHUB_PATH
|
||||
- name: Run zig fmt
|
||||
id: fmt
|
||||
run: |
|
||||
zig fmt --check src/*.zig src/**/*.zig 2> zig-fmt.err > zig-fmt.err2 || echo "Failed"
|
||||
delimiter="$(openssl rand -hex 8)"
|
||||
echo "zig_fmt_errs<<${delimiter}" >> "${GITHUB_OUTPUT}"
|
||||
|
||||
if [ -s zig-fmt.err ]; then
|
||||
echo "// The following errors occurred:" >> "${GITHUB_OUTPUT}"
|
||||
cat zig-fmt.err >> "${GITHUB_OUTPUT}"
|
||||
fi
|
||||
|
||||
if [ -s zig-fmt.err2 ]; then
|
||||
echo "// The following files were not formatted:" >> "${GITHUB_OUTPUT}"
|
||||
cat zig-fmt.err2 >> "${GITHUB_OUTPUT}"
|
||||
fi
|
||||
|
||||
echo "${delimiter}" >> "${GITHUB_OUTPUT}"
|
||||
- name: Comment on PR
|
||||
if: steps.fmt.outputs.zig_fmt_errs != ''
|
||||
uses: thollander/actions-comment-pull-request@v2
|
||||
with:
|
||||
comment_tag: zig-fmt
|
||||
message: |
|
||||
❌ @${{ github.actor }} `zig fmt` reported errors. Consider configuring your text editor to [auto-format on save](https://github.com/ziglang/vscode-zig)
|
||||
|
||||
```zig
|
||||
// # zig fmt --check src/*.zig src/**/*.zig
|
||||
${{ steps.fmt.outputs.zig_fmt_errs }}
|
||||
```
|
||||
|
||||
To one-off fix this manually, run:
|
||||
|
||||
```sh
|
||||
zig fmt src/*.zig src/**/*.zig
|
||||
```
|
||||
|
||||
<sup>[#${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})</sup>
|
||||
<sup>zig v${{env.ZIG_VERSION}}</sup>
|
||||
|
||||
- name: Uncomment on PR
|
||||
if: steps.fmt.outputs.zig_fmt_errs == ''
|
||||
uses: thollander/actions-comment-pull-request@v2
|
||||
with:
|
||||
comment_tag: zig-fmt
|
||||
mode: upsert
|
||||
create_if_not_exists: false
|
||||
message: |
|
||||
✅ `zig fmt` errors have been resolved. Thank you.
|
||||
|
||||
<sup>[#${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})</sup>
|
||||
<sup>zig v${{env.ZIG_VERSION}}</sup>
|
||||
|
||||
- name: Fail the job
|
||||
if: steps.fmt.outputs.zig_fmt_errs != ''
|
||||
run: exit 1
|
||||
31
.gitignore
vendored
31
.gitignore
vendored
@@ -6,6 +6,7 @@ packages/*/*.wasm
|
||||
profile.json
|
||||
|
||||
node_modules
|
||||
.envrc
|
||||
.swcrc
|
||||
yarn.lock
|
||||
dist
|
||||
@@ -109,7 +110,7 @@ misctools/machbench
|
||||
*.big
|
||||
.eslintcache
|
||||
|
||||
bun-webkit
|
||||
/bun-webkit
|
||||
|
||||
src/deps/c-ares/build
|
||||
src/bun.js/bindings-obj
|
||||
@@ -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,29 @@ src/js/out/DebugPath.h
|
||||
make-dev-stats.csv
|
||||
|
||||
.uuid
|
||||
tsconfig.tsbuildinfo
|
||||
tsconfig.tsbuildinfo
|
||||
|
||||
test/js/bun/glob/fixtures
|
||||
*.lib
|
||||
*.pdb
|
||||
CMakeFiles
|
||||
build.ninja
|
||||
.ninja_deps
|
||||
.ninja_log
|
||||
CMakeCache.txt
|
||||
cmake_install.cmake
|
||||
compile_commands.json
|
||||
|
||||
*.lib
|
||||
x64
|
||||
**/*.vcxproj*
|
||||
**/*.sln*
|
||||
**/*.dir
|
||||
**/*.pdb
|
||||
|
||||
/.webkit-cache
|
||||
/.cache
|
||||
/src/deps/libuv
|
||||
/build-*/
|
||||
|
||||
.vs
|
||||
|
||||
49
.gitmodules
vendored
49
.gitmodules
vendored
@@ -1,10 +1,3 @@
|
||||
[submodule "src/deps/picohttpparser"]
|
||||
path = src/deps/picohttpparser
|
||||
url = https://github.com/h2o/picohttpparser.git
|
||||
ignore = dirty
|
||||
depth = 1
|
||||
shallow = true
|
||||
fetchRecurseSubmodules = false
|
||||
[submodule "src/javascript/jsc/WebKit"]
|
||||
path = src/bun.js/WebKit
|
||||
url = https://github.com/oven-sh/WebKit.git
|
||||
@@ -13,6 +6,13 @@ depth = 1
|
||||
update = none
|
||||
shallow = true
|
||||
fetchRecurseSubmodules = false
|
||||
[submodule "src/deps/picohttpparser"]
|
||||
path = src/deps/picohttpparser
|
||||
url = https://github.com/h2o/picohttpparser.git
|
||||
ignore = dirty
|
||||
depth = 1
|
||||
shallow = true
|
||||
fetchRecurseSubmodules = false
|
||||
[submodule "src/deps/mimalloc"]
|
||||
path = src/deps/mimalloc
|
||||
url = https://github.com/Jarred-Sumner/mimalloc.git
|
||||
@@ -56,15 +56,30 @@ depth = 1
|
||||
shallow = true
|
||||
fetchRecurseSubmodules = false
|
||||
[submodule "src/deps/c-ares"]
|
||||
path = src/deps/c-ares
|
||||
url = https://github.com/c-ares/c-ares.git
|
||||
path = src/deps/c-ares
|
||||
url = https://github.com/c-ares/c-ares.git
|
||||
ignore = dirty
|
||||
depth = 1
|
||||
shallow = true
|
||||
fetchRecurseSubmodules = false
|
||||
[submodule "src/deps/zstd"]
|
||||
path = src/deps/zstd
|
||||
url = https://github.com/facebook/zstd.git
|
||||
ignore = dirty
|
||||
path = src/deps/zstd
|
||||
url = https://github.com/facebook/zstd.git
|
||||
ignore = dirty
|
||||
depth = 1
|
||||
shallow = true
|
||||
fetchRecurseSubmodules = false
|
||||
[submodule "src/deps/base64"]
|
||||
path = src/deps/base64
|
||||
url = https://github.com/aklomp/base64.git
|
||||
ignore = dirty
|
||||
depth = 1
|
||||
shallow = true
|
||||
path = src/deps/base64
|
||||
url = https://github.com/aklomp/base64.git
|
||||
ignore = dirty
|
||||
depth = 1
|
||||
shallow = true
|
||||
fetchRecurseSubmodules = false
|
||||
[submodule "src/deps/ls-hpack"]
|
||||
path = src/deps/ls-hpack
|
||||
url = https://github.com/litespeedtech/ls-hpack.git
|
||||
ignore = dirty
|
||||
depth = 1
|
||||
shallow = true
|
||||
fetchRecurseSubmodules = false
|
||||
@@ -1,21 +0,0 @@
|
||||
// I would have made this a bash script but there isn't an easy way to track
|
||||
// time in bash sub-second cross platform.
|
||||
import fs from "fs";
|
||||
const start = Date.now() + 5;
|
||||
const result = Bun.spawnSync(process.argv.slice(2), {
|
||||
stdio: ["inherit", "inherit", "inherit"],
|
||||
});
|
||||
const end = Date.now();
|
||||
const diff = (Math.max(Math.round(end - start), 0) / 1000).toFixed(3);
|
||||
const success = result.exitCode === 0;
|
||||
try {
|
||||
const line = `${new Date().toISOString()}, ${success ? "success" : "fail"}, ${diff}\n`;
|
||||
if (fs.existsSync(".scripts/make-dev-stats.csv")) {
|
||||
fs.appendFileSync(".scripts/make-dev-stats.csv", line);
|
||||
} else {
|
||||
fs.writeFileSync(".scripts/make-dev-stats.csv", line);
|
||||
}
|
||||
} catch {
|
||||
// Ignore
|
||||
}
|
||||
process.exit(result.exitCode);
|
||||
@@ -1,13 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -euxo pipefail
|
||||
|
||||
# if bun-webkit node_modules directory exists
|
||||
if [ -d ./node_modules/bun-webkit ]; then
|
||||
rm -f bun-webkit
|
||||
# get the first matching bun-webkit-* directory name
|
||||
ln -s ./node_modules/$(ls ./node_modules | grep bun-webkit- | head -n 1) ./bun-webkit
|
||||
fi
|
||||
|
||||
# sets up vscode C++ intellisense
|
||||
rm -f .vscode/clang++
|
||||
ln -s $(which clang++-15 || which clang++) .vscode/clang++ 2>/dev/null
|
||||
80
.vscode/c_cpp_properties.json
vendored
80
.vscode/c_cpp_properties.json
vendored
@@ -1,16 +1,64 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Mac",
|
||||
"name": "Debug",
|
||||
"forcedInclude": ["${workspaceFolder}/src/bun.js/bindings/root.h"],
|
||||
"includePath": [
|
||||
"${workspaceFolder}/../webkit-build/include/",
|
||||
"${workspaceFolder}/bun-webkit/include/",
|
||||
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/",
|
||||
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/ICU/Headers/",
|
||||
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/JavaScriptCore/PrivateHeaders/",
|
||||
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/WTF/Headers",
|
||||
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/bmalloc/Headers/",
|
||||
"${workspaceFolder}/build/bun-webkit/include",
|
||||
"${workspaceFolder}/build/codegen",
|
||||
"${workspaceFolder}/src/bun.js/bindings/",
|
||||
"${workspaceFolder}/src/bun.js/bindings/webcore/",
|
||||
"${workspaceFolder}/src/bun.js/bindings/sqlite/",
|
||||
"${workspaceFolder}/src/bun.js/bindings/webcrypto/",
|
||||
"${workspaceFolder}/src/bun.js/modules/",
|
||||
"${workspaceFolder}/src/js/builtins/",
|
||||
"${workspaceFolder}/src/deps/boringssl/include/",
|
||||
"${workspaceFolder}/src/deps",
|
||||
"${workspaceFolder}/src/napi/*",
|
||||
"${workspaceFolder}/packages/bun-usockets/src",
|
||||
"${workspaceFolder}/packages/"
|
||||
],
|
||||
"browse": {
|
||||
"path": [
|
||||
"${workspaceFolder}/build/bun-webkit/include",
|
||||
"${workspaceFolder}/src/bun.js/bindings",
|
||||
"${workspaceFolder}/src/napi/*",
|
||||
"${workspaceFolder}/src/js/builtins/*",
|
||||
"${workspaceFolder}/src/bun.js/modules/*",
|
||||
"${workspaceFolder}/src/deps/*",
|
||||
"${workspaceFolder}/src/deps/boringssl/include/*",
|
||||
"${workspaceFolder}/packages/bun-usockets/*",
|
||||
"${workspaceFolder}/packages/bun-uws/*",
|
||||
"${workspaceFolder}/src/napi/*"
|
||||
],
|
||||
"limitSymbolsToIncludedHeaders": true,
|
||||
"databaseFilename": ".vscode/cppdb"
|
||||
},
|
||||
"defines": [
|
||||
"STATICALLY_LINKED_WITH_JavaScriptCore=1",
|
||||
"STATICALLY_LINKED_WITH_WTF=1",
|
||||
"BUILDING_WITH_CMAKE=1",
|
||||
"NOMINMAX",
|
||||
"ENABLE_INSPECTOR_ALTERNATE_DISPATCHERS=0",
|
||||
"BUILDING_JSCONLY__",
|
||||
"USE_FOUNDATION=1",
|
||||
"ASSERT_ENABLED=1",
|
||||
"DU_DISABLE_RENAMING=1"
|
||||
],
|
||||
"macFrameworkPath": [],
|
||||
"compilerPath": "${workspaceFolder}/.vscode/clang++",
|
||||
"cStandard": "c17",
|
||||
"cppStandard": "c++20"
|
||||
},
|
||||
{
|
||||
"name": "BunWithJSCDebug",
|
||||
"forcedInclude": ["${workspaceFolder}/src/bun.js/bindings/root.h"],
|
||||
"includePath": [
|
||||
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Debug/",
|
||||
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Debug/ICU/Headers/",
|
||||
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Debug/JavaScriptCore/PrivateHeaders/",
|
||||
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Debug/WTF/Headers",
|
||||
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Debug/bmalloc/Headers/",
|
||||
"${workspaceFolder}/src/bun.js/bindings/",
|
||||
"${workspaceFolder}/src/bun.js/bindings/webcore/",
|
||||
"${workspaceFolder}/src/bun.js/bindings/sqlite/",
|
||||
@@ -26,13 +74,11 @@
|
||||
],
|
||||
"browse": {
|
||||
"path": [
|
||||
"${workspaceFolder}/../webkit-build/include/",
|
||||
"${workspaceFolder}/bun-webkit/include/",
|
||||
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/",
|
||||
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/ICU/Headers/",
|
||||
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/JavaScriptCore/PrivateHeaders/**",
|
||||
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/WTF/Headers/**",
|
||||
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/bmalloc/Headers/**",
|
||||
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Debug/",
|
||||
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Debug/ICU/Headers/",
|
||||
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Debug/JavaScriptCore/PrivateHeaders/**",
|
||||
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Debug/WTF/Headers/**",
|
||||
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Debug/bmalloc/Headers/**",
|
||||
"${workspaceFolder}/src/bun.js/bindings/*",
|
||||
"${workspaceFolder}/src/bun.js/bindings/*",
|
||||
"${workspaceFolder}/src/napi/*",
|
||||
@@ -49,7 +95,7 @@
|
||||
"${workspaceFolder}/src/napi"
|
||||
],
|
||||
"limitSymbolsToIncludedHeaders": true,
|
||||
"databaseFilename": ".vscode/cppdb"
|
||||
"databaseFilename": ".vscode/cppdb_debug"
|
||||
},
|
||||
"defines": [
|
||||
"STATICALLY_LINKED_WITH_JavaScriptCore=1",
|
||||
@@ -59,7 +105,7 @@
|
||||
"ENABLE_INSPECTOR_ALTERNATE_DISPATCHERS=0",
|
||||
"BUILDING_JSCONLY__",
|
||||
"USE_FOUNDATION=1",
|
||||
"ASSERT_ENABLED=0",
|
||||
"ASSERT_ENABLED=1",
|
||||
"DU_DISABLE_RENAMING=1"
|
||||
],
|
||||
"macFrameworkPath": [],
|
||||
|
||||
13
.vscode/launch.json
generated
vendored
13
.vscode/launch.json
generated
vendored
@@ -82,7 +82,7 @@
|
||||
"request": "launch",
|
||||
"name": "bun test [*]",
|
||||
"program": "bun-debug",
|
||||
"args": ["test"],
|
||||
"args": ["test", "js/node"],
|
||||
"cwd": "${workspaceFolder}/test",
|
||||
"env": {
|
||||
"FORCE_COLOR": "1",
|
||||
@@ -96,7 +96,7 @@
|
||||
"request": "launch",
|
||||
"name": "bun test [*] (fast)",
|
||||
"program": "bun-debug",
|
||||
"args": ["test"],
|
||||
"args": ["test", "js"],
|
||||
// The cwd here must be the same as in CI. Or you will cause test failures that only happen in CI.
|
||||
"cwd": "${workspaceFolder}/test",
|
||||
"env": {
|
||||
@@ -124,7 +124,7 @@
|
||||
"request": "launch",
|
||||
"name": "bun run [file]",
|
||||
"program": "bun-debug",
|
||||
"args": ["run", "${file}", "${file}"],
|
||||
"args": ["run", "${file}"],
|
||||
"cwd": "${fileDirname}",
|
||||
"env": {
|
||||
"FORCE_COLOR": "1",
|
||||
@@ -307,13 +307,10 @@
|
||||
"name": "bun install",
|
||||
"program": "bun-debug",
|
||||
"args": ["install"],
|
||||
"cwd": "${fileDirname}",
|
||||
"cwd": "/Users/jarred/Build/worky",
|
||||
"console": "internalConsole",
|
||||
"env": {
|
||||
"BUN_DEBUG_QUIET_LOGS": "1"
|
||||
}
|
||||
"env": {}
|
||||
},
|
||||
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
|
||||
92
.vscode/settings.json
vendored
92
.vscode/settings.json
vendored
@@ -7,44 +7,36 @@
|
||||
"search.followSymlinks": false,
|
||||
"search.useIgnoreFiles": true,
|
||||
"zig.buildOnSave": false,
|
||||
// We do this until we upgrade to latest Zig so that zls doesn't break our code.
|
||||
"zig.formattingProvider": "extension",
|
||||
"zig.buildArgs": ["obj", "-Dfor-editor"],
|
||||
"zig.formattingProvider": "zls",
|
||||
"zig.buildOption": "build",
|
||||
"zig.buildFilePath": "${workspaceFolder}/build.zig",
|
||||
"zig.initialSetupDone": true,
|
||||
"editor.formatOnSave": true,
|
||||
"[zig]": {
|
||||
"editor.tabSize": 4,
|
||||
"editor.useTabStops": false,
|
||||
"editor.defaultFormatter": "ziglang.vscode-zig",
|
||||
"editor.formatOnSave": true
|
||||
"editor.defaultFormatter": "ziglang.vscode-zig"
|
||||
},
|
||||
"[ts]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.formatOnSave": true
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"[js]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.formatOnSave": true
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"zig.zls.enableInlayHints": false,
|
||||
|
||||
"git.ignoreSubmodules": true,
|
||||
"[jsx]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.formatOnSave": true
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"[tsx]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"[yaml]": {
|
||||
"editor.formatOnSave": true
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"[yaml]": {},
|
||||
"[markdown]": {
|
||||
"editor.unicodeHighlight.ambiguousCharacters": false,
|
||||
"editor.unicodeHighlight.invisibleCharacters": false,
|
||||
"diffEditor.ignoreTrimWhitespace": false,
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.formatOnSave": true,
|
||||
"editor.wordWrap": "on",
|
||||
"editor.quickSuggestions": {
|
||||
"comments": "off",
|
||||
@@ -64,8 +56,6 @@
|
||||
"**/*.xcscheme": true,
|
||||
"**/*.pem": true,
|
||||
"**/*.xcodeproj": true,
|
||||
"test/snapshots": true,
|
||||
"test/snapshots-no-hmr": true,
|
||||
"src/bun.js/WebKit": true,
|
||||
"src/deps/libarchive": true,
|
||||
"src/deps/mimalloc": true,
|
||||
@@ -78,27 +68,26 @@
|
||||
"src/deps/c-ares": true,
|
||||
"src/deps/tinycc": true,
|
||||
"src/deps/zstd": true,
|
||||
"test/snippets/package-json-exports/_node_modules_copy": true,
|
||||
"src/js/out": true,
|
||||
"src/packages/bun-uws/fuzzing/seed-corpus/": true
|
||||
"**/*.i": true,
|
||||
"packages/bun-uws/fuzzing/seed-corpus/**/*": true
|
||||
},
|
||||
"C_Cpp.files.exclude": {
|
||||
"**/.vscode": true,
|
||||
"src/bun.js/WebKit/JSTests": true,
|
||||
"src/bun.js/WebKit/Tools": true,
|
||||
"src/bun.js/WebKit/WebDriverTests": true,
|
||||
"src/bun.js/WebKit/WebKit.xcworkspace": true,
|
||||
"src/bun.js/WebKit/WebKitLibraries": true,
|
||||
"src/bun.js/WebKit/Websites": true,
|
||||
"src/bun.js/WebKit/resources": true,
|
||||
"src/bun.js/WebKit/LayoutTests": true,
|
||||
"src/bun.js/WebKit/ManualTests": true,
|
||||
"src/bun.js/WebKit/PerformanceTests": true,
|
||||
"src/bun.js/WebKit/WebKitLegacy": true,
|
||||
"src/bun.js/WebKit/WebCore": true,
|
||||
"src/bun.js/WebKit/WebDriver": true,
|
||||
"src/bun.js/WebKit/WebKitBuild": true,
|
||||
"src/bun.js/WebKit/WebInspectorUI": true
|
||||
"WebKit/JSTests": true,
|
||||
"WebKit/Tools": true,
|
||||
"WebKit/WebDriverTests": true,
|
||||
"WebKit/WebKit.xcworkspace": true,
|
||||
"WebKit/WebKitLibraries": true,
|
||||
"WebKit/Websites": true,
|
||||
"WebKit/resources": true,
|
||||
"WebKit/LayoutTests": true,
|
||||
"WebKit/ManualTests": true,
|
||||
"WebKit/PerformanceTests": true,
|
||||
"WebKit/WebKitLegacy": true,
|
||||
"WebKit/WebCore": true,
|
||||
"WebKit/WebDriver": true,
|
||||
"WebKit/WebKitBuild": true,
|
||||
"WebKit/WebInspectorUI": true
|
||||
},
|
||||
"[cpp]": {
|
||||
"editor.defaultFormatter": "xaver.clang-format"
|
||||
@@ -189,20 +178,12 @@
|
||||
"set": "cpp",
|
||||
"__memory": "cpp",
|
||||
"memory_resource": "cpp",
|
||||
"resource.h": "c",
|
||||
"sysinfo.h": "c",
|
||||
"*.tcc": "cpp",
|
||||
"list": "cpp",
|
||||
"shared_mutex": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"variant": "cpp",
|
||||
"sysctl.h": "c",
|
||||
"interface_adresses.h": "c",
|
||||
"interface_addresses.h": "c",
|
||||
"ctype.h": "c",
|
||||
"ethernet.h": "c",
|
||||
"inet.h": "c",
|
||||
"packet.h": "c",
|
||||
"queue": "cpp",
|
||||
"compare": "cpp",
|
||||
"concepts": "cpp",
|
||||
@@ -218,9 +199,24 @@
|
||||
"regex": "cpp",
|
||||
"span": "cpp",
|
||||
"valarray": "cpp",
|
||||
"codecvt": "cpp"
|
||||
"codecvt": "cpp",
|
||||
"xtr1common": "cpp",
|
||||
"stop_token": "cpp",
|
||||
"xfacet": "cpp",
|
||||
"xhash": "cpp",
|
||||
"xiosbase": "cpp",
|
||||
"xlocale": "cpp",
|
||||
"xlocbuf": "cpp",
|
||||
"xlocinfo": "cpp",
|
||||
"xlocmes": "cpp",
|
||||
"xlocmon": "cpp",
|
||||
"xlocnum": "cpp",
|
||||
"xloctime": "cpp",
|
||||
"xmemory": "cpp",
|
||||
"xstring": "cpp",
|
||||
"xtree": "cpp",
|
||||
"xutility": "cpp"
|
||||
},
|
||||
"cmake.configureOnOpen": false,
|
||||
"C_Cpp.errorSquiggles": "enabled",
|
||||
"eslint.workingDirectories": ["packages/bun-types"],
|
||||
"typescript.tsdk": "node_modules/typescript/lib"
|
||||
|
||||
29
.vscode/tasks.json
vendored
29
.vscode/tasks.json
vendored
@@ -2,33 +2,10 @@
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build",
|
||||
"label": "Rebuild Debug",
|
||||
"command": "ninja",
|
||||
"args": ["-Cbuild"],
|
||||
"type": "process",
|
||||
"command": "zig",
|
||||
"args": ["build"],
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
"reveal": "silent",
|
||||
"focus": false,
|
||||
"panel": "shared",
|
||||
"showReuseMessage": false,
|
||||
"clear": false
|
||||
},
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "run",
|
||||
"type": "process",
|
||||
"command": "zig",
|
||||
"args": ["run", "${file}"],
|
||||
"group": "build",
|
||||
"presentation": {
|
||||
"showReuseMessage": false,
|
||||
"clear": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
1291
CMakeLists.txt
Normal file
1291
CMakeLists.txt
Normal file
File diff suppressed because it is too large
Load Diff
@@ -10,7 +10,7 @@ Today (February 2023), Bun's codebase has five distinct parts:
|
||||
|
||||
- JavaScript, JSX, & TypeScript transpiler, module resolver, and related code
|
||||
- JavaScript runtime ([`src/bun.js/`](src/bun.js/))
|
||||
- JavaScript runtime bindings ([`src/bun.zig/bindings/**/*.cpp`](src/bun.zig/bindings/))
|
||||
- JavaScript runtime bindings ([`src/bun.js/bindings/**/*.cpp`](src/bun.js/bindings/))
|
||||
- Package manager ([`src/install/`](src/install/))
|
||||
- Shared utilities ([`src/string_immutable.zig`](src/string_immutable.zig))
|
||||
|
||||
@@ -18,7 +18,7 @@ The JavaScript transpiler & module resolver is mostly independent from the runti
|
||||
|
||||
## Getting started
|
||||
|
||||
Please refer to [Bun's Development Guide](https://bun.sh/docs/project/development) to get your dev environment setup!
|
||||
Please refer to [Bun's Development Guide](https://bun.sh/docs/project/contributing) to get your dev environment setup!
|
||||
|
||||
## Memory management in Bun
|
||||
|
||||
|
||||
886
Dockerfile
886
Dockerfile
File diff suppressed because it is too large
Load Diff
176
Makefile
176
Makefile
@@ -38,8 +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
|
||||
|
||||
AR=
|
||||
@@ -66,7 +65,7 @@ PACKAGE_JSON_VERSION = $(BUN_BASE_VERSION).$(BUILD_ID)
|
||||
BUN_BUILD_TAG = bun-v$(PACKAGE_JSON_VERSION)
|
||||
BUN_RELEASE_BIN = $(PACKAGE_DIR)/bun
|
||||
PRETTIER ?= $(shell which prettier 2>/dev/null || echo "./node_modules/.bin/prettier")
|
||||
ESBUILD = $(shell which esbuild 2>/dev/null || echo "./node_modules/.bin/esbuild")
|
||||
ESBUILD = "$(shell which esbuild 2>/dev/null || echo "./node_modules/.bin/esbuild")"
|
||||
DSYMUTIL ?= $(shell which dsymutil 2>/dev/null || which dsymutil-15 2>/dev/null)
|
||||
WEBKIT_DIR ?= $(realpath src/bun.js/WebKit)
|
||||
WEBKIT_RELEASE_DIR ?= $(WEBKIT_DIR)/WebKitBuild/Release
|
||||
@@ -74,7 +73,7 @@ WEBKIT_DEBUG_DIR ?= $(WEBKIT_DIR)/WebKitBuild/Debug
|
||||
WEBKIT_RELEASE_DIR_LTO ?= $(WEBKIT_DIR)/WebKitBuild/ReleaseLTO
|
||||
|
||||
|
||||
NPM_CLIENT ?= $(shell which bun 2>/dev/null || which npm 2>/dev/null)
|
||||
NPM_CLIENT = "$(shell which bun 2>/dev/null || which npm 2>/dev/null)"
|
||||
ZIG ?= $(shell which zig 2>/dev/null || echo -e "error: Missing zig. Please make sure zig is in PATH. Or set ZIG=/path/to-zig-executable")
|
||||
|
||||
# We must use the same compiler version for the JavaScriptCore bindings and JavaScriptCore
|
||||
@@ -82,9 +81,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 +107,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 +154,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 +176,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)
|
||||
@@ -187,11 +186,6 @@ BUN_CFLAGS = $(MACOS_MIN_FLAG) $(MARCH_NATIVE) $(OPTIMIZATION_LEVEL) -fno-excep
|
||||
BUN_TMP_DIR := /tmp/make-bun
|
||||
CFLAGS=$(CFLAGS_WITHOUT_MARCH) $(MARCH_NATIVE)
|
||||
|
||||
DEFAULT_USE_BMALLOC := 1
|
||||
|
||||
|
||||
USE_BMALLOC ?= DEFAULT_USE_BMALLOC
|
||||
|
||||
# Set via postinstall
|
||||
ifeq (,$(realpath $(JSC_BASE_DIR)))
|
||||
JSC_BASE_DIR = $(realpath $(firstword $(wildcard bun-webkit)))
|
||||
@@ -274,7 +268,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
|
||||
|
||||
|
||||
@@ -380,9 +374,7 @@ ICU_FLAGS ?=
|
||||
# Ideally, we could just look up the linker search paths
|
||||
ifeq ($(OS_NAME),linux)
|
||||
LIB_ICU_PATH ?= $(JSC_LIB)
|
||||
ICU_FLAGS += $(LIB_ICU_PATH)/libicuuc.a $(LIB_ICU_PATH)/libicudata.a $(LIB_ICU_PATH)/libicui18n.a
|
||||
else
|
||||
LIB_ICU_PATH ?= $(BUN_DEPS_DIR)
|
||||
ICU_FLAGS += $(LIB_ICU_PATH)/libicuuc.a $(LIB_ICU_PATH)/libicudata.a $(LIB_ICU_PATH)/libicui18n.a
|
||||
endif
|
||||
|
||||
ifeq ($(OS_NAME),darwin)
|
||||
@@ -463,7 +455,8 @@ ARCHIVE_FILES_WITHOUT_LIBCRYPTO = $(MINIMUM_ARCHIVE_FILES) \
|
||||
-lusockets \
|
||||
-lcares \
|
||||
-lzstd \
|
||||
$(BUN_DEPS_OUT_DIR)/libuwsockets.o
|
||||
$(BUN_DEPS_OUT_DIR)/libuwsockets.o \
|
||||
$(BUN_DEPS_OUT_DIR)/liblshpack.a
|
||||
|
||||
ARCHIVE_FILES = $(ARCHIVE_FILES_WITHOUT_LIBCRYPTO)
|
||||
|
||||
@@ -550,7 +543,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 +657,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)
|
||||
@@ -757,14 +750,24 @@ wasm: api mimalloc-wasm build-obj-wasm-small
|
||||
build-obj-safe:
|
||||
$(ZIG) build obj -Doptimize=ReleaseSafe -Dcpu="$(CPU_TARGET)"
|
||||
|
||||
UWS_CC_FLAGS = -pthread -DLIBUS_USE_OPENSSL=1 -DUWS_HTTPRESPONSE_NO_WRITEMARK=1 -DLIBUS_USE_BORINGSSL=1 -DWITH_BORINGSSL=1 -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion $(UWS_INCLUDE) -DUWS_WITH_PROXY
|
||||
UWS_CC_FLAGS = -pthread -DLIBUS_USE_OPENSSL=1 -DUWS_HTTPRESPONSE_NO_WRITEMARK=1 -DLIBUS_USE_BORINGSSL=1 -DWITH_BORINGSSL=1 -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion $(UWS_INCLUDE) -DUWS_WITH_PROXY
|
||||
UWS_CXX_FLAGS = $(UWS_CC_FLAGS) -std=$(CXX_VERSION) -fno-exceptions -fno-rtti
|
||||
UWS_LDFLAGS = -I$(BUN_DEPS_DIR)/boringssl/include -I$(ZLIB_INCLUDE_DIR)
|
||||
USOCKETS_DIR = $(BUN_DIR)/packages/bun-usockets
|
||||
USOCKETS_SRC_DIR = $(USOCKETS_DIR)/src
|
||||
|
||||
|
||||
LSHPACK_SRC_DIR = $(BUN_DEPS_DIR)/ls-hpack
|
||||
LSHPACK_CC_FLAGS = -DXXH_HEADER_NAME="<xxhash.h>"
|
||||
LSHPACK_LDFLAGS = -I$(LSHPACK_SRC_DIR) -I$(LSHPACK_SRC_DIR)/deps/xxhash
|
||||
|
||||
lshpack:
|
||||
rm -rf $(LSHPACK_SRC_DIR)/*.i $(LSHPACK_SRC_DIR)/*.bc $(LSHPACK_SRC_DIR)/*.o $(LSHPACK_SRC_DIR)/*.s $(LSHPACK_SRC_DIR)/*.ii $(LSHPACK_SRC_DIR)/*.s
|
||||
cd $(LSHPACK_SRC_DIR) && $(CC_WITH_CCACHE) -I$(LSHPACK_SRC_DIR) -fno-builtin-malloc -fno-builtin-free -fno-builtin-realloc $(EMIT_LLVM_FOR_RELEASE) $(MACOS_MIN_FLAG) -fPIC $(CFLAGS) $(LSHPACK_CC_FLAGS) -save-temps -I$(BUN_DEPS_DIR)/uws/lshpack/src $(LSHPACK_LDFLAGS) -g $(DEFAULT_LINKER_FLAGS) $(PLATFORM_LINKER_FLAGS) $(OPTIMIZATION_LEVEL) -c $(wildcard $(LSHPACK_SRC_DIR)/lshpack.c) $(wildcard $(LSHPACK_SRC_DIR)/deps/**/*.c)
|
||||
cd $(LSHPACK_SRC_DIR) && $(AR) rcvs $(BUN_DEPS_OUT_DIR)/liblshpack.a $(LSHPACK_SRC_DIR)/*.{o,bc}
|
||||
|
||||
usockets:
|
||||
rm -rf $(USOCKETS_DIR)/*.i $(USOCKETS_DIR)/*.bc $(USOCKETS_DIR)/*.o $(USOCKETS_DIR)/*.s $(USOCKETS_DIR)/*.ii $(USOCKETS_DIR)/*.s
|
||||
rm -rf $(USOCKETS_DIR)/*.i $(USOCKETS_DIR)/*.bc $(USOCKETS_DIR)/*.o $(USOCKETS_DIR)/*.s $(USOCKETS_DIR)/*.ii $(USOCKETS_DIR)/*.s $(BUN_DEPS_OUT_DIR)/libusockets.a
|
||||
cd $(USOCKETS_DIR) && $(CC_WITH_CCACHE) -I$(USOCKETS_SRC_DIR) -fno-builtin-malloc -fno-builtin-free -fno-builtin-realloc $(EMIT_LLVM_FOR_RELEASE) $(MACOS_MIN_FLAG) -fPIC $(CFLAGS) $(UWS_CC_FLAGS) -save-temps -I$(BUN_DEPS_DIR)/uws/uSockets/src $(UWS_LDFLAGS) -g $(DEFAULT_LINKER_FLAGS) $(PLATFORM_LINKER_FLAGS) $(OPTIMIZATION_LEVEL) -c $(wildcard $(USOCKETS_SRC_DIR)/*.c) $(wildcard $(USOCKETS_SRC_DIR)/**/*.c)
|
||||
cd $(USOCKETS_DIR) && $(CXX_WITH_CCACHE) -I$(USOCKETS_SRC_DIR) -fno-builtin-malloc -fno-builtin-free -fno-builtin-realloc $(EMIT_LLVM_FOR_RELEASE) $(MACOS_MIN_FLAG) -fPIC $(CXXFLAGS) $(UWS_CXX_FLAGS) -save-temps -I$(BUN_DEPS_DIR)/uws/uSockets/src $(UWS_LDFLAGS) -g $(DEFAULT_LINKER_FLAGS) $(PLATFORM_LINKER_FLAGS) $(OPTIMIZATION_LEVEL) -c $(wildcard $(USOCKETS_SRC_DIR)/*.cpp) $(wildcard $(USOCKETS_SRC_DIR)/**/*.cpp)
|
||||
cd $(USOCKETS_DIR) && $(AR) rcvs $(BUN_DEPS_OUT_DIR)/libusockets.a $(USOCKETS_DIR)/*.{o,bc}
|
||||
@@ -811,7 +814,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
|
||||
@@ -833,10 +836,10 @@ fallback_decoder:
|
||||
|
||||
.PHONY: runtime_js
|
||||
runtime_js:
|
||||
@NODE_ENV=production $(ESBUILD) --define:process.env.NODE_ENV="production" --target=esnext --bundle src/runtime/index.ts --format=iife --platform=browser --global-name=BUN_RUNTIME --minify --external:/bun:* > src/runtime.out.js; cat src/runtime.footer.js >> src/runtime.out.js
|
||||
@NODE_ENV=production $(ESBUILD) --define:process.env.NODE_ENV="production" --target=esnext --bundle src/runtime/index-with-refresh.ts --format=iife --platform=browser --global-name=BUN_RUNTIME --minify --external:/bun:* > src/runtime.out.refresh.js; cat src/runtime.footer.with-refresh.js >> src/runtime.out.refresh.js
|
||||
@NODE_ENV=production $(ESBUILD) --define:process.env.NODE_ENV="production" --target=esnext --bundle src/runtime/index-without-hmr.ts --format=iife --platform=node --global-name=BUN_RUNTIME --minify --external:/bun:* > src/runtime.node.pre.out.js; cat src/runtime.node.pre.out.js src/runtime.footer.node.js > src/runtime.node.out.js
|
||||
@NODE_ENV=production $(ESBUILD) --define:process.env.NODE_ENV="production" --target=esnext --bundle src/runtime/index-without-hmr.ts --format=iife --platform=node --global-name=BUN_RUNTIME --minify --external:/bun:* > src/runtime.bun.pre.out.js; cat src/runtime.bun.pre.out.js src/runtime.footer.bun.js > src/runtime.bun.out.js
|
||||
@NODE_ENV=production $(ESBUILD) --define:process.env.NODE_ENV=\"production\" --target=esnext --bundle src/runtime/index.ts --format=iife --platform=browser --global-name=BUN_RUNTIME --minify --external:/bun:* > src/runtime.out.js; cat src/runtime.footer.js >> src/runtime.out.js
|
||||
@NODE_ENV=production $(ESBUILD) --define:process.env.NODE_ENV=\"production\" --target=esnext --bundle src/runtime/index-with-refresh.ts --format=iife --platform=browser --global-name=BUN_RUNTIME --minify --external:/bun:* > src/runtime.out.refresh.js; cat src/runtime.footer.with-refresh.js >> src/runtime.out.refresh.js
|
||||
@NODE_ENV=production $(ESBUILD) --define:process.env.NODE_ENV=\"production\" --target=esnext --bundle src/runtime/index-without-hmr.ts --format=iife --platform=node --global-name=BUN_RUNTIME --minify --external:/bun:* > src/runtime.node.pre.out.js; cat src/runtime.node.pre.out.js src/runtime.footer.node.js > src/runtime.node.out.js
|
||||
@NODE_ENV=production $(ESBUILD) --define:process.env.NODE_ENV=\"production\" --target=esnext --bundle src/runtime/index-without-hmr.ts --format=iife --platform=node --global-name=BUN_RUNTIME --minify --external:/bun:* > src/runtime.bun.pre.out.js; cat src/runtime.bun.pre.out.js src/runtime.footer.bun.js > src/runtime.bun.out.js
|
||||
|
||||
.PHONY: runtime_js_dev
|
||||
runtime_js_dev:
|
||||
@@ -937,6 +940,9 @@ clone-submodules:
|
||||
|
||||
.PHONY: headers
|
||||
headers:
|
||||
echo please don't run the headers generator anymore. i don't think it works.
|
||||
echo if you really need it, run make headers2
|
||||
headers2:
|
||||
rm -f /tmp/build-jsc-headers src/bun.js/bindings/headers.zig
|
||||
touch src/bun.js/bindings/headers.zig
|
||||
$(ZIG) build headers-obj
|
||||
@@ -945,7 +951,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
|
||||
@@ -1251,6 +1257,7 @@ jsc-build-mac-compile-debug:
|
||||
-DENABLE_FTL_JIT=ON \
|
||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
|
||||
-DUSE_BUN_JSC_ADDITIONS=ON \
|
||||
-DENABLE_BUN_SKIP_FAILING_ASSERTIONS=ON \
|
||||
-DALLOW_LINE_AND_COLUMN_NUMBER_IN_BUILTINS=ON \
|
||||
-G Ninja \
|
||||
$(CMAKE_FLAGS_WITHOUT_RELEASE) \
|
||||
@@ -1291,7 +1298,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
|
||||
|
||||
|
||||
@@ -1326,7 +1333,7 @@ release-bindings: $(OBJ_DIR) $(OBJ_FILES) $(WEBCORE_OBJ_FILES) $(SQLITE_OBJ_FILE
|
||||
# Do not add $(DEBUG_DIR) to this list
|
||||
# It will break caching, causing you to have to wait for every .cpp file to rebuild.
|
||||
.PHONY: bindings
|
||||
bindings: $(DEBUG_OBJ_DIR) $(DEBUG_OBJ_FILES) $(DEBUG_WEBCORE_OBJ_FILES) $(DEBUG_SQLITE_OBJ_FILES) $(DEBUG_NODE_OS_OBJ_FILES) $(DEBUG_BUILTINS_OBJ_FILES) $(DEBUG_IO_FILES) $(DEBUG_MODULES_OBJ_FILES) $(DEBUG_WEBCRYPTO_OBJ_FILES)
|
||||
bindings-real: $(DEBUG_OBJ_DIR) $(DEBUG_OBJ_FILES) $(DEBUG_WEBCORE_OBJ_FILES) $(DEBUG_SQLITE_OBJ_FILES) $(DEBUG_NODE_OS_OBJ_FILES) $(DEBUG_BUILTINS_OBJ_FILES) $(DEBUG_IO_FILES) $(DEBUG_MODULES_OBJ_FILES) $(DEBUG_WEBCRYPTO_OBJ_FILES)
|
||||
|
||||
.PHONY: jsc-bindings-mac
|
||||
jsc-bindings-mac: bindings
|
||||
@@ -1360,7 +1367,7 @@ mimalloc-debug:
|
||||
-GNinja \
|
||||
. \
|
||||
&& ninja
|
||||
cp $(BUN_DEPS_DIR)/mimalloc/$(_MIMALLOC_DEBUG_FILE) $(BUN_DEPS_OUT_DIR)/$(MIMALLOC_FILE)
|
||||
cp $(BUN_DEPS_DIR)/mimalloc/$(_MIMALLOC_DEBUG_FILE) $(BUN_DEPS_OUT_DIR)/$(_MIMALLOC_DEBUG_FILE)
|
||||
|
||||
|
||||
# mimalloc is built as object files so that it can overload the system malloc on linux
|
||||
@@ -1482,15 +1489,15 @@ 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
|
||||
bun src/codegen/generate-classes.ts
|
||||
$(ZIG) fmt src/bun.js/bindings/generated_classes.zig
|
||||
$(CLANG_FORMAT) -i src/bun.js/bindings/ZigGeneratedClasses.h src/bun.js/bindings/ZigGeneratedClasses.cpp
|
||||
|
||||
generate-sink:
|
||||
bun src/bun.js/scripts/generate-jssink.js
|
||||
bun src/codegen/generate-jssink.js
|
||||
$(CLANG_FORMAT) -i src/bun.js/bindings/JSSink.cpp src/bun.js/bindings/JSSink.h
|
||||
./src/bun.js/scripts/create_hash_table src/bun.js/bindings/JSSink.cpp > src/bun.js/bindings/JSSinkLookupTable.h
|
||||
$(SED) -i -e 's/#include "Lookup.h"//' src/bun.js/bindings/JSSinkLookupTable.h
|
||||
@@ -1518,7 +1525,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 +1536,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 +1547,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 +1558,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 +1569,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 +1580,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 +1591,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 +1603,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 +1617,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 +1632,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 +1645,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 +1661,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 +1676,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 +1691,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 +1704,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 +1719,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 +1832,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 +1850,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 +1887,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 +1898,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) \
|
||||
@@ -1900,7 +1907,7 @@ cold-jsc-start:
|
||||
misctools/cold-jsc-start.cpp -o cold-jsc-start
|
||||
|
||||
.PHONY: vendor-without-npm
|
||||
vendor-without-npm: node-fallbacks runtime_js fallback_decoder bun_error mimalloc picohttp zlib boringssl libarchive lolhtml sqlite usockets uws tinycc c-ares zstd base64
|
||||
vendor-without-npm: node-fallbacks runtime_js fallback_decoder bun_error mimalloc picohttp zlib boringssl libarchive lolhtml sqlite usockets uws lshpack tinycc c-ares zstd base64
|
||||
|
||||
|
||||
.PHONY: vendor-without-check
|
||||
@@ -1913,41 +1920,30 @@ vendor: assert-deps submodule vendor-without-check
|
||||
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
|
||||
bun:
|
||||
@echo 'makefile is deprecated - use `cmake` / `bun run build`'
|
||||
@echo 'See https://bun.sh/docs/project/contributing for more details'
|
||||
|
||||
.PHONY: cpp
|
||||
cpp: ## compile src/js/builtins + all c++ code then link
|
||||
@make clean-bindings js
|
||||
@make bindings -j$(CPU_COUNT)
|
||||
@make link
|
||||
cpp:
|
||||
@echo 'makefile is deprecated - use `cmake` / `bun run build`'
|
||||
@echo 'See https://bun.sh/docs/project/contributing for more details'
|
||||
|
||||
.PHONY: cpp
|
||||
cpp-no-link:
|
||||
@make clean-bindings js
|
||||
@make bindings -j$(CPU_COUNT)
|
||||
zig:
|
||||
@echo 'makefile is deprecated - use `cmake` / `bun run build`'
|
||||
@echo 'See https://bun.sh/docs/project/contributing for more details'
|
||||
|
||||
.PHONY: zig
|
||||
zig: ## compile zig code then link
|
||||
@make mkdir-dev dev-obj link
|
||||
dev:
|
||||
@echo 'makefile is deprecated - use `cmake` / `bun run build`'
|
||||
@echo 'See https://bun.sh/docs/project/contributing for more details'
|
||||
|
||||
.PHONY: zig-no-link
|
||||
zig-no-link:
|
||||
@make mkdir-dev dev-obj
|
||||
setup:
|
||||
@echo 'makefile is deprecated - use `cmake` / `bun run build`'
|
||||
@echo 'See https://bun.sh/docs/project/contributing for more details'
|
||||
|
||||
.PHONY: dev
|
||||
dev: # combo of `make cpp` and `make zig`
|
||||
@make cpp-no-link zig-no-link -j2
|
||||
@make link
|
||||
bindings:
|
||||
@echo 'makefile is deprecated - use `cmake` / `bun run build`'
|
||||
@echo 'See https://bun.sh/docs/project/contributing for more details'
|
||||
|
||||
.PHONY: setup
|
||||
setup: vendor-dev identifier-cache clean-bindings
|
||||
make jsc-check dev
|
||||
@echo ""
|
||||
@echo "First build complete!"
|
||||
@echo "\"bun-debug\" is available at $(DEBUG_BIN)/bun-debug"
|
||||
@echo ""
|
||||
|
||||
.PHONY: help
|
||||
help: ## to print this help
|
||||
@echo "For detailed build instructions, see https://bun.sh/docs/project/development"
|
||||
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9_-]+:.*?## / {gsub("\\\\n",sprintf("\n%22c",""), $$2);printf "\033[36m%-20s\033[0m \t\t%s\n", $$1, $$2}' $(MAKEFILE_LIST)
|
||||
help:
|
||||
@echo 'makefile is deprecated - use `cmake` / `bun run build`'
|
||||
@echo 'See https://bun.sh/docs/project/contributing for more details'
|
||||
|
||||
@@ -24,14 +24,14 @@
|
||||
|
||||
## 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`.
|
||||
|
||||
At its core is the _Bun runtime_, a fast JavaScript runtime designed as a drop-in replacement for Node.js. It's written in Zig and powered by JavaScriptCore under the hood, dramatically reducing startup times and memory usage.
|
||||
|
||||
```bash
|
||||
bun run index.tsx # TS and JSX supported out of the box
|
||||
bun run index.tsx # TS and JSX supported out-of-the-box
|
||||
```
|
||||
|
||||
The `bun` command-line tool also implements a test runner, script runner, and Node.js-compatible package manager. Instead of 1,000 node_modules for development, you only need `bun`. Bun's built-in tools are significantly faster than existing options and usable in existing Node.js projects with little to no changes.
|
||||
@@ -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/cli/init)
|
||||
- [`bun create`](https://bun.sh/docs/cli/bun-create)
|
||||
- [`bunx`](https://bun.sh/docs/cli/bunx)
|
||||
- Runtime
|
||||
- [Runtime](https://bun.sh/docs/runtime/index)
|
||||
@@ -127,7 +128,7 @@ bun upgrade --canary
|
||||
|
||||
## Contributing
|
||||
|
||||
Refer to the [Project > Development](https://bun.sh/docs/project/development) guide to start contributing to Bun.
|
||||
Refer to the [Project > Contributing](https://bun.sh/docs/project/contributing) guide to start contributing to Bun.
|
||||
|
||||
## License
|
||||
|
||||
|
||||
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.
|
||||
|
||||
BIN
bench/bun.lockb
BIN
bench/bun.lockb
Binary file not shown.
@@ -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:
|
||||
|
||||
19
bench/glob/match.mjs
Normal file
19
bench/glob/match.mjs
Normal file
@@ -0,0 +1,19 @@
|
||||
import micromatch from "micromatch";
|
||||
import { bench, run } from "mitata";
|
||||
|
||||
const Glob = typeof Bun !== "undefined" ? Bun.Glob : undefined;
|
||||
const doMatch = typeof Bun === "undefined" ? micromatch.isMatch : (a, b) => new Glob(b).match(a);
|
||||
|
||||
bench((Glob ? "Bun.Glob - " : "micromatch - ") + "**/*.js", () => {
|
||||
doMatch("foo/bar.js", "**/*.js");
|
||||
});
|
||||
|
||||
bench((Glob ? "Bun.Glob - " : "micromatch - ") + "*.js", () => {
|
||||
doMatch("bar.js", "*.js");
|
||||
});
|
||||
|
||||
await run({
|
||||
avg: true,
|
||||
min_max: true,
|
||||
percentiles: true,
|
||||
});
|
||||
113
bench/glob/scan.mjs
Normal file
113
bench/glob/scan.mjs
Normal file
@@ -0,0 +1,113 @@
|
||||
import { run, bench, group } from "mitata";
|
||||
import fg from "fast-glob";
|
||||
import { fdir } from "fdir";
|
||||
|
||||
const normalPattern = "*.ts";
|
||||
const recursivePattern = "**/*.ts";
|
||||
const nodeModulesPattern = "**/node_modules/**/*.js";
|
||||
|
||||
const benchFdir = false;
|
||||
const cwd = undefined;
|
||||
|
||||
const bunOpts = {
|
||||
cwd,
|
||||
followSymlinks: false,
|
||||
absolute: true,
|
||||
};
|
||||
|
||||
const fgOpts = {
|
||||
cwd,
|
||||
followSymbolicLinks: false,
|
||||
onlyFiles: false,
|
||||
absolute: true,
|
||||
};
|
||||
|
||||
const Glob = "Bun" in globalThis ? globalThis.Bun.Glob : undefined;
|
||||
|
||||
group({ name: `async pattern="${normalPattern}"`, summary: true }, () => {
|
||||
bench("fast-glob", async () => {
|
||||
const entries = await fg.glob([normalPattern], fgOpts);
|
||||
});
|
||||
|
||||
if (Glob)
|
||||
bench("Bun.Glob", async () => {
|
||||
const entries = await Array.fromAsync(new Glob(normalPattern).scan(bunOpts));
|
||||
});
|
||||
|
||||
if (benchFdir)
|
||||
bench("fdir", async () => {
|
||||
const entries = await new fdir().withFullPaths().glob(normalPattern).crawl(process.cwd()).withPromise();
|
||||
});
|
||||
});
|
||||
|
||||
group({ name: `async-recursive pattern="${recursivePattern}"`, summary: true }, () => {
|
||||
bench("fast-glob", async () => {
|
||||
const entries = await fg.glob([recursivePattern], fgOpts);
|
||||
});
|
||||
|
||||
if (Glob)
|
||||
bench("Bun.Glob", async () => {
|
||||
const entries = await Array.fromAsync(new Glob(recursivePattern).scan(bunOpts));
|
||||
});
|
||||
|
||||
if (benchFdir)
|
||||
bench("fdir", async () => {
|
||||
const entries = await new fdir().withFullPaths().glob(recursivePattern).crawl(process.cwd()).withPromise();
|
||||
});
|
||||
});
|
||||
|
||||
group({ name: `sync pattern="${normalPattern}"`, summary: true }, () => {
|
||||
bench("fast-glob", () => {
|
||||
const entries = fg.globSync([normalPattern], fgOpts);
|
||||
});
|
||||
|
||||
if (Glob)
|
||||
bench("Bun.Glob", () => {
|
||||
const entries = [...new Glob(normalPattern).scanSync(bunOpts)];
|
||||
});
|
||||
|
||||
if (benchFdir)
|
||||
bench("fdir", async () => {
|
||||
const entries = new fdir().withFullPaths().glob(normalPattern).crawl(process.cwd()).sync();
|
||||
});
|
||||
});
|
||||
|
||||
group({ name: `sync-recursive pattern="${recursivePattern}"`, summary: true }, () => {
|
||||
bench("fast-glob", () => {
|
||||
const entries = fg.globSync([recursivePattern], fgOpts);
|
||||
});
|
||||
|
||||
if (Glob)
|
||||
bench("Bun.Glob", () => {
|
||||
const entries = [...new Glob(recursivePattern).scanSync(bunOpts)];
|
||||
});
|
||||
|
||||
if (benchFdir)
|
||||
bench("fdir", async () => {
|
||||
const entries = new fdir().withFullPaths().glob(recursivePattern).crawl(process.cwd()).sync();
|
||||
});
|
||||
});
|
||||
|
||||
group({ name: `node_modules pattern="${nodeModulesPattern}"`, summary: true }, () => {
|
||||
bench("fast-glob", async () => {
|
||||
const entries = await fg.glob([nodeModulesPattern], fgOpts);
|
||||
});
|
||||
|
||||
if (Glob)
|
||||
bench("Bun.Glob", async () => {
|
||||
const entries = await Array.fromAsync(new Glob(nodeModulesPattern).scan(bunOpts));
|
||||
});
|
||||
|
||||
if (benchFdir)
|
||||
bench("fdir", async () => {
|
||||
const entries = await new fdir().withFullPaths().glob(nodeModulesPattern).crawl(process.cwd()).withPromise();
|
||||
});
|
||||
});
|
||||
|
||||
await run({
|
||||
avg: true,
|
||||
colors: false,
|
||||
min_max: true,
|
||||
collect: true,
|
||||
percentiles: true,
|
||||
});
|
||||
@@ -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:
|
||||
|
||||
```
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
"benchmark": "^2.1.4",
|
||||
"esbuild": "^0.14.12",
|
||||
"eventemitter3": "^5.0.0",
|
||||
"fast-glob": "3.3.1",
|
||||
"fdir": "^6.1.0",
|
||||
"mitata": "^0.1.6"
|
||||
},
|
||||
"scripts": {
|
||||
|
||||
@@ -6,23 +6,30 @@ bench("await 1", async function () {
|
||||
return await 1;
|
||||
});
|
||||
|
||||
function callnextTick(resolve) {
|
||||
process.nextTick(resolve);
|
||||
}
|
||||
if (typeof process !== "undefined") {
|
||||
bench("process.nextTick x 100", async function () {
|
||||
var remaining = 100;
|
||||
var cb, promise;
|
||||
promise = new Promise(resolve => {
|
||||
cb = resolve;
|
||||
});
|
||||
|
||||
function awaitNextTick() {
|
||||
return new Promise(callnextTick);
|
||||
}
|
||||
for (let i = 0; i < 100; i++) {
|
||||
process.nextTick(() => {
|
||||
if (--remaining === 0) cb();
|
||||
});
|
||||
}
|
||||
|
||||
bench("promise.nextTick", async function () {
|
||||
return awaitNextTick();
|
||||
});
|
||||
return promise;
|
||||
});
|
||||
|
||||
bench("await 1 x 100", async function () {
|
||||
for (let i = 0; i < 100; i++) await 1;
|
||||
});
|
||||
}
|
||||
|
||||
bench("await new Promise(resolve => resolve())", async function () {
|
||||
await new Promise(resolve => resolve());
|
||||
});
|
||||
bench("Promise.all(Array.from({length: 100}, () => new Promise((resolve) => resolve())))", async function () {
|
||||
return Promise.all(Array.from({ length: 100 }, () => Promise.resolve(1)));
|
||||
});
|
||||
|
||||
await run();
|
||||
|
||||
@@ -4,5 +4,9 @@ var i = 0;
|
||||
const server = createServer((req, res) => {
|
||||
res.writeHead(200);
|
||||
res.end("Hello, World!" + i);
|
||||
if (i++ === 200_000 - 1) queueMicrotask(() => process.exit(0));
|
||||
if (i++ === 200_000 - 1)
|
||||
setTimeout(() => {
|
||||
console.log("RSS", (process.memoryUsage().rss / 1024 / 1024) | 0, "MB");
|
||||
process.exit(0);
|
||||
}, 0);
|
||||
}).listen(parseInt(process.env.PORT || "3000", 10));
|
||||
|
||||
52
bench/snippets/new-incomingmessage.mjs
Normal file
52
bench/snippets/new-incomingmessage.mjs
Normal file
@@ -0,0 +1,52 @@
|
||||
import { bench, run } from "./runner.mjs";
|
||||
import { IncomingMessage } from "node:http";
|
||||
|
||||
const headers = {
|
||||
date: "Mon, 06 Nov 2023 05:12:49 GMT",
|
||||
expires: "-1",
|
||||
"cache-control": "private, max-age=0",
|
||||
"content-type": "text/html; charset=ISO-8859-1",
|
||||
"content-security-policy-report-only":
|
||||
"object-src 'none';base-uri 'self';script-src 'nonce-lcrU7l9xScCq4urW13K9gw' 'strict-dynamic' 'report-sample' 'unsafe-eval' 'unsafe-inline' https: http:;report-uri https://csp.withgoogle.com/csp/gws/other-hp",
|
||||
"x-xss-protection": "0",
|
||||
"x-frame-options": "SAMEORIGIN",
|
||||
"accept-ranges": "none",
|
||||
vary: "Accept-Encoding",
|
||||
"transfer-encoding": "chunked",
|
||||
"set-cookie": [
|
||||
"1P_JAR=2023-11-06-05; expires=Wed, 06-Dec-2023 05:12:49 GMT; path=/; domain=.google.com; Secure",
|
||||
"AEC=Ackid1TiuGtRsmu1yaDCAdL1u1J4eM4S67simzDHfWaMPQzH-UB4DZkRwm8; expires=Sat, 04-May-2024 05:12:49 GMT; path=/; domain=.google.com; Secure; HttpOnly; SameSite=lax",
|
||||
"NID=511=jQcg9cM7vjKawWnf6f3qhs3WDIIN2gaRq3i4bdMiVRWFkaFNYmiI-Xquf1kAmWGcmDN0skldS7uHheru3CMJrWjMt56VaaqO6Pilb54jFjQS_ZJRfG3Uc7dGV5WXGV-slUGE1Bicxlajdn0E_R8tZOoWiFzFDQW7YGmyfRqWQ2k; expires=Tue, 07-May-2024 05:12:49 GMT; path=/; domain=.google.com; HttpOnly",
|
||||
],
|
||||
p3p: 'CP="This is not a P3P policy! See g.co/p3phelp for more info."',
|
||||
server: "gws",
|
||||
"alt-svc": 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000',
|
||||
};
|
||||
|
||||
const request = new Request("https://www.google.com/", {
|
||||
headers: new Headers(headers),
|
||||
method: "GET",
|
||||
});
|
||||
|
||||
// const server = Bun.serve({
|
||||
// port: 8080,
|
||||
// async fetch(request) {
|
||||
// // bench("new IncomingMessage()", b => {
|
||||
// // for (let i = 0; i < 1000; i++) {
|
||||
// // new IncomingMessage(request);
|
||||
// // }
|
||||
// // });
|
||||
// const msg = new IncomingMessage(request);
|
||||
// console.log(msg.headers, msg.rawHeaders, msg.url);
|
||||
// // await run();
|
||||
// return new Response("Hello, world!");
|
||||
// },
|
||||
// });
|
||||
|
||||
bench("new IncomingMessage()", b => {
|
||||
for (let i = 0; i < 1000; i++) {
|
||||
new IncomingMessage(request);
|
||||
}
|
||||
});
|
||||
|
||||
await run();
|
||||
@@ -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();
|
||||
|
||||
@@ -1,13 +1,50 @@
|
||||
import { readdirSync } from "fs";
|
||||
import { readdirSync, readdir as readdirCb } from "fs";
|
||||
import { readdir } from "fs/promises";
|
||||
import { bench, run } from "./runner.mjs";
|
||||
import { argv } from "process";
|
||||
import { fileURLToPath } from "url";
|
||||
import { relative, resolve } from "path";
|
||||
import { createHash } from "crypto";
|
||||
|
||||
const dir = argv.length > 2 ? argv[2] : "/tmp";
|
||||
let dir = resolve(argv.length > 2 ? argv[2] : fileURLToPath(new URL("../../node_modules", import.meta.url)));
|
||||
if (dir.includes(process.cwd())) {
|
||||
dir = relative(process.cwd(), dir);
|
||||
}
|
||||
|
||||
const count = readdirSync(dir).length;
|
||||
bench(`readdir("${dir}")`, () => {
|
||||
readdirSync(dir, { withFileTypes: true });
|
||||
const result = await readdir(dir, { recursive: true });
|
||||
const count = result.length;
|
||||
const syncCount = readdirSync(dir, { recursive: true }).length;
|
||||
|
||||
const hash = createHash("sha256").update(result.sort().join("\n")).digest("hex");
|
||||
|
||||
bench(`await readdir("${dir}", {recursive: true})`, async () => {
|
||||
await readdir(dir, { recursive: true });
|
||||
});
|
||||
|
||||
bench(`await readdir("${dir}", {recursive: true}) x 10`, async () => {
|
||||
const promises = [
|
||||
readdir(dir, { recursive: true }),
|
||||
readdir(dir, { recursive: true }),
|
||||
readdir(dir, { recursive: true }),
|
||||
readdir(dir, { recursive: true }),
|
||||
readdir(dir, { recursive: true }),
|
||||
readdir(dir, { recursive: true }),
|
||||
readdir(dir, { recursive: true }),
|
||||
readdir(dir, { recursive: true }),
|
||||
readdir(dir, { recursive: true }),
|
||||
readdir(dir, { recursive: true }),
|
||||
readdir(dir, { recursive: true }),
|
||||
];
|
||||
await Promise.all(promises);
|
||||
});
|
||||
|
||||
bench(`await readdir("${dir}", {recursive: false})`, async () => {
|
||||
await readdir(dir, { recursive: false });
|
||||
});
|
||||
|
||||
await run();
|
||||
console.log("\n\nFor", count, "files/dirs in", dir);
|
||||
console.log("\n", count, "files/dirs in", dir, "\n", "SHA256:", hash, "\n");
|
||||
|
||||
if (count !== syncCount) {
|
||||
throw new Error(`Mismatched file counts: ${count} async !== ${syncCount} sync`);
|
||||
}
|
||||
|
||||
25
bench/snippets/require-builtins.mjs
Normal file
25
bench/snippets/require-builtins.mjs
Normal file
@@ -0,0 +1,25 @@
|
||||
import { bench, run } from "./runner.mjs";
|
||||
import { builtinModules } from "node:module";
|
||||
import { writeFile } from "node:fs/promises";
|
||||
import { spawnSync } from "child_process";
|
||||
|
||||
for (let builtin of builtinModules) {
|
||||
const path = `/tmp/require.${builtin.replaceAll("/", "_")}.cjs`;
|
||||
await writeFile(
|
||||
path,
|
||||
`
|
||||
const builtin = ${JSON.stringify(builtin)};
|
||||
const now = require("perf_hooks").performance.now();
|
||||
require(builtin);
|
||||
const end = require("perf_hooks").performance.now();
|
||||
process.stdout.write(JSON.stringify({builtin, time: end - now}) + "\\n");
|
||||
`,
|
||||
);
|
||||
const result = spawnSync(typeof Bun !== "undefined" ? "bun" : "node", [path], {
|
||||
stdio: ["inherit", "inherit", "inherit"],
|
||||
env: {
|
||||
...process.env,
|
||||
NODE_NO_WARNINGS: "1",
|
||||
},
|
||||
});
|
||||
}
|
||||
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`);
|
||||
}
|
||||
}
|
||||
143
bench/snippets/semver.mjs
Normal file
143
bench/snippets/semver.mjs
Normal file
@@ -0,0 +1,143 @@
|
||||
import { satisfies } from "semver";
|
||||
import { bench, run } from "./runner.mjs";
|
||||
const tests = [
|
||||
["~1.2.3", "1.2.3", true],
|
||||
["~1.2", "1.2.0", true],
|
||||
["~1", "1.0.0", true],
|
||||
["~1", "1.2.0", true],
|
||||
["~1", "1.2.999", true],
|
||||
["~0.2.3", "0.2.3", true],
|
||||
["~0.2", "0.2.0", true],
|
||||
["~0.2", "0.2.1", true],
|
||||
["~0 ", "0.0.0", true],
|
||||
|
||||
["~1.2.3", "1.3.0", false],
|
||||
["~1.2", "1.3.0", false],
|
||||
["~1", "2.0.0", false],
|
||||
["~0.2.3", "0.3.0", false],
|
||||
["~0.2.3", "1.0.0", false],
|
||||
["~0 ", "1.0.0", false],
|
||||
["~0.2", "0.1.0", false],
|
||||
["~0.2", "0.3.0", false],
|
||||
|
||||
["~3.0.5", "3.3.0", false],
|
||||
|
||||
["^1.1.4", "1.1.4", true],
|
||||
|
||||
[">=3", "3.5.0", true],
|
||||
[">=3", "2.999.999", false],
|
||||
[">=3", "3.5.1", true],
|
||||
[">=3.x.x", "3.x.x", false],
|
||||
|
||||
["<6 >= 5", "5.0.0", true],
|
||||
["<6 >= 5", "4.0.0", false],
|
||||
["<6 >= 5", "6.0.0", false],
|
||||
["<6 >= 5", "6.0.1", false],
|
||||
|
||||
[">2", "3", false],
|
||||
[">2", "2.1", false],
|
||||
[">2", "2", false],
|
||||
[">2", "1.0", false],
|
||||
[">1.3", "1.3.1", false],
|
||||
[">1.3", "2.0.0", true],
|
||||
[">2.1.0", "2.2.0", true],
|
||||
["<=2.2.99999", "2.2.0", true],
|
||||
[">=2.1.99999", "2.2.0", true],
|
||||
["<2.2.99999", "2.2.0", true],
|
||||
[">2.1.99999", "2.2.0", true],
|
||||
[">1.0.0", "2.0.0", true],
|
||||
["1.0.0", "1.0.0", true],
|
||||
["1.0.0", "2.0.0", false],
|
||||
|
||||
["1.0.0 || 2.0.0", "1.0.0", true],
|
||||
["2.0.0 || 1.0.0", "1.0.0", true],
|
||||
["1.0.0 || 2.0.0", "2.0.0", true],
|
||||
["2.0.0 || 1.0.0", "2.0.0", true],
|
||||
["2.0.0 || >1.0.0", "2.0.0", true],
|
||||
|
||||
[">1.0.0 <2.0.0 <2.0.1 >1.0.1", "1.0.2", true],
|
||||
|
||||
["2.x", "2.0.0", true],
|
||||
["2.x", "2.1.0", true],
|
||||
["2.x", "2.2.0", true],
|
||||
["2.x", "2.3.0", true],
|
||||
["2.x", "2.1.1", true],
|
||||
["2.x", "2.2.2", true],
|
||||
["2.x", "2.3.3", true],
|
||||
|
||||
["<2.0.1 >1.0.0", "2.0.0", true],
|
||||
["<=2.0.1 >=1.0.0", "2.0.0", true],
|
||||
|
||||
["^2", "2.0.0", true],
|
||||
["^2", "2.9.9", true],
|
||||
["~2", "2.0.0", true],
|
||||
["~2", "2.1.0", true],
|
||||
["~2.2", "2.2.1", true],
|
||||
|
||||
["2.1.0 || > 2.2 || >3", "2.1.0", true],
|
||||
[" > 2.2 || >3 || 2.1.0", "2.1.0", true],
|
||||
[" > 2.2 || 2.1.0 || >3", "2.1.0", true],
|
||||
["> 2.2 || 2.1.0 || >3", "2.3.0", true],
|
||||
["> 2.2 || 2.1.0 || >3", "2.2.1", false],
|
||||
["> 2.2 || 2.1.0 || >3", "2.2.0", false],
|
||||
["> 2.2 || 2.1.0 || >3", "2.3.0", true],
|
||||
["> 2.2 || 2.1.0 || >3", "3.0.1", true],
|
||||
["~2", "2.0.0", true],
|
||||
["~2", "2.1.0", true],
|
||||
|
||||
["1.2.0 - 1.3.0", "1.2.2", true],
|
||||
["1.2 - 1.3", "1.2.2", true],
|
||||
["1 - 1.3", "1.2.2", true],
|
||||
["1 - 1.3", "1.3.0", true],
|
||||
["1.2 - 1.3", "1.3.1", true],
|
||||
["1.2 - 1.3", "1.4.0", false],
|
||||
["1 - 1.3", "1.3.1", true],
|
||||
|
||||
["1.2 - 1.3 || 5.0", "6.4.0", false],
|
||||
["1.2 - 1.3 || 5.0", "1.2.1", true],
|
||||
["5.0 || 1.2 - 1.3", "1.2.1", true],
|
||||
["1.2 - 1.3 || 5.0", "5.0", false],
|
||||
["5.0 || 1.2 - 1.3", "5.0", false],
|
||||
["1.2 - 1.3 || 5.0", "5.0.2", true],
|
||||
["5.0 || 1.2 - 1.3", "5.0.2", true],
|
||||
["1.2 - 1.3 || 5.0", "5.0.2", true],
|
||||
["5.0 || 1.2 - 1.3", "5.0.2", true],
|
||||
["5.0 || 1.2 - 1.3 || >8", "9.0.2", true],
|
||||
];
|
||||
|
||||
bench("semver.satisfies x " + tests.length, () => {
|
||||
for (const [range, version, expected] of tests) {
|
||||
if (satisfies(version, range) !== expected) {
|
||||
throw new Error("Unexpected result for " + range + " " + version);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (typeof Bun !== "undefined") {
|
||||
const satisfies = Bun.semver.satisfies;
|
||||
bench("Bun.semver.satisfies x " + tests.length, () => {
|
||||
for (const [range, version, expected] of tests) {
|
||||
if (satisfies(version, range) !== expected) {
|
||||
throw new Error("Unexpected result for " + range + " " + version);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
bench("semver.satisfies", () => {
|
||||
const [range, version, expected] = tests[0];
|
||||
if (satisfies(version, range) !== expected) {
|
||||
throw new Error("Unexpected result for " + range + " " + version);
|
||||
}
|
||||
});
|
||||
if (typeof Bun !== "undefined") {
|
||||
const satisfies = Bun.semver.satisfies;
|
||||
bench("Bun.semver.satisfies", () => {
|
||||
const [range, version, expected] = tests[0];
|
||||
if (satisfies(version, range) !== expected) {
|
||||
throw new Error("Unexpected result for " + range + " " + version);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
await run();
|
||||
@@ -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");
|
||||
});
|
||||
|
||||
|
||||
235
build.zig
235
build.zig
@@ -1,31 +1,22 @@
|
||||
const std = @import("std");
|
||||
const pathRel = std.fs.path.relative;
|
||||
const builtin = @import("builtin");
|
||||
const Wyhash = @import("./src/wyhash.zig").Wyhash;
|
||||
|
||||
const zig_version = builtin.zig_version;
|
||||
|
||||
/// Do not rename this constant. It is scanned by some scripts to determine which zig version to install.
|
||||
const recommended_zig_version = "0.12.0-dev.1604+caae40c21";
|
||||
|
||||
var is_debug_build = false;
|
||||
fn moduleSource(comptime out: []const u8) FileSource {
|
||||
if (comptime std.fs.path.dirname(@src().file)) |base| {
|
||||
const outpath = comptime base ++ std.fs.path.sep_str ++ out;
|
||||
return FileSource.relative(outpath);
|
||||
} else {
|
||||
return FileSource.relative(out);
|
||||
}
|
||||
|
||||
fn exists(path: []const u8) bool {
|
||||
_ = std.fs.openFileAbsolute(path, .{ .mode = .read_only }) catch return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
const color_map = std.ComptimeStringMap([]const u8, .{
|
||||
&.{ "black", "30m" },
|
||||
&.{ "blue", "34m" },
|
||||
&.{ "b", "1m" },
|
||||
&.{ "d", "2m" },
|
||||
&.{ "cyan", "36m" },
|
||||
&.{ "green", "32m" },
|
||||
&.{ "magenta", "35m" },
|
||||
&.{ "red", "31m" },
|
||||
&.{ "white", "37m" },
|
||||
&.{ "yellow", "33m" },
|
||||
});
|
||||
|
||||
fn addInternalPackages(b: *Build, step: *CompileStep, _: std.mem.Allocator, _: []const u8, target: anytype) !void {
|
||||
var io: *Module = brk: {
|
||||
const io: *Module = brk: {
|
||||
if (target.isDarwin()) {
|
||||
break :brk b.createModule(.{
|
||||
.source_file = FileSource.relative("src/io/io_darwin.zig"),
|
||||
@@ -46,11 +37,38 @@ fn addInternalPackages(b: *Build, step: *CompileStep, _: std.mem.Allocator, _: [
|
||||
};
|
||||
|
||||
step.addModule("async_io", io);
|
||||
|
||||
step.addModule("zlib-internal", brk: {
|
||||
if (target.isWindows()) {
|
||||
break :brk b.createModule(.{ .source_file = FileSource.relative("src/deps/zlib.win32.zig") });
|
||||
}
|
||||
|
||||
break :brk b.createModule(.{ .source_file = FileSource.relative("src/deps/zlib.posix.zig") });
|
||||
});
|
||||
|
||||
const async_: *Module = brk: {
|
||||
if (target.isDarwin() or target.isLinux() or target.isFreeBSD()) {
|
||||
break :brk b.createModule(.{
|
||||
.source_file = FileSource.relative("src/async/posix_event_loop.zig"),
|
||||
});
|
||||
} else if (target.isWindows()) {
|
||||
break :brk b.createModule(.{
|
||||
.source_file = FileSource.relative("src/async/windows_event_loop.zig"),
|
||||
});
|
||||
}
|
||||
|
||||
break :brk b.createModule(.{
|
||||
.source_file = FileSource.relative("src/async/stub_event_loop.zig"),
|
||||
});
|
||||
};
|
||||
step.addModule("async", async_);
|
||||
}
|
||||
|
||||
const BunBuildOptions = struct {
|
||||
canary: bool = false,
|
||||
is_canary: bool = false,
|
||||
canary_revision: u32 = 0,
|
||||
sha: [:0]const u8 = "",
|
||||
version: []const u8 = "",
|
||||
baseline: bool = false,
|
||||
bindgen: bool = false,
|
||||
sizegen: bool = false,
|
||||
@@ -59,6 +77,8 @@ const BunBuildOptions = struct {
|
||||
runtime_js_version: u64 = 0,
|
||||
fallback_html_version: u64 = 0,
|
||||
|
||||
tinycc: bool = true,
|
||||
|
||||
pub fn updateRuntime(this: *BunBuildOptions) anyerror!void {
|
||||
if (std.fs.cwd().openFile("src/runtime.out.js", .{ .mode = .read_only })) |file| {
|
||||
defer file.close();
|
||||
@@ -89,7 +109,13 @@ const BunBuildOptions = struct {
|
||||
|
||||
pub fn step(this: BunBuildOptions, b: anytype) *std.build.OptionsStep {
|
||||
var opts = b.addOptions();
|
||||
opts.addOption(@TypeOf(this.canary), "is_canary", this.canary);
|
||||
opts.addOption(@TypeOf(this.is_canary), "is_canary", this.is_canary);
|
||||
opts.addOption(@TypeOf(this.canary_revision), "canary_revision", this.canary_revision);
|
||||
opts.addOption(
|
||||
std.SemanticVersion,
|
||||
"version",
|
||||
std.SemanticVersion.parse(this.version) catch @panic(b.fmt("Invalid version: {s}", .{this.version})),
|
||||
);
|
||||
opts.addOption(@TypeOf(this.sha), "sha", this.sha);
|
||||
opts.addOption(@TypeOf(this.baseline), "baseline", this.baseline);
|
||||
opts.addOption(@TypeOf(this.bindgen), "bindgen", this.bindgen);
|
||||
@@ -97,35 +123,15 @@ const BunBuildOptions = struct {
|
||||
opts.addOption(@TypeOf(this.base_path), "base_path", this.base_path);
|
||||
opts.addOption(@TypeOf(this.runtime_js_version), "runtime_js_version", this.runtime_js_version);
|
||||
opts.addOption(@TypeOf(this.fallback_html_version), "fallback_html_version", this.fallback_html_version);
|
||||
opts.addOption(@TypeOf(this.tinycc), "tinycc", this.tinycc);
|
||||
return opts;
|
||||
}
|
||||
};
|
||||
|
||||
// relative to the prefix
|
||||
var output_dir: []const u8 = "";
|
||||
fn panicIfNotFound(comptime filepath: []const u8) []const u8 {
|
||||
var file = std.fs.cwd().openFile(filepath, .{ .optimize = .read_only }) catch |err| {
|
||||
std.debug.panic("error: {s} opening {s}. Please ensure you've downloaded git submodules, and ran `make vendor`, `make jsc`.", .{ filepath, @errorName(err) });
|
||||
};
|
||||
file.close();
|
||||
|
||||
return filepath;
|
||||
}
|
||||
|
||||
const fmt = struct {
|
||||
pub usingnamespace @import("std").fmt;
|
||||
|
||||
pub fn hexInt(value: anytype) @TypeOf(std.fmt.fmtSliceHexLower("")) {
|
||||
return std.fmt.fmtSliceHexLower(std.mem.asBytes(&value));
|
||||
}
|
||||
|
||||
pub fn hexIntUp(value: anytype) @TypeOf(std.fmt.fmtSliceHexUpper("")) {
|
||||
return std.fmt.fmtSliceHexUpper(std.mem.asBytes(&value));
|
||||
}
|
||||
};
|
||||
|
||||
var x64 = "x64";
|
||||
var optimize: std.builtin.OptimizeMode = undefined;
|
||||
var optimize: std.builtin.OptimizeMode = .Debug;
|
||||
|
||||
const Build = std.Build;
|
||||
const CrossTarget = std.zig.CrossTarget;
|
||||
@@ -146,6 +152,26 @@ pub fn build(b: *Build) !void {
|
||||
}
|
||||
|
||||
pub fn build_(b: *Build) !void {
|
||||
switch (comptime zig_version.order(std.SemanticVersion.parse(recommended_zig_version) catch unreachable)) {
|
||||
.eq => {},
|
||||
.lt => {
|
||||
@compileError("The minimum version of Zig required to compile Bun is " ++ recommended_zig_version ++ ", found " ++ @import("builtin").zig_version_string ++ ". Please follow the instructions at https://bun.sh/docs/project/contributing. You may need to re-run `bun setup`.");
|
||||
},
|
||||
.gt => {
|
||||
const colors = std.io.getStdErr().supportsAnsiEscapeCodes();
|
||||
std.debug.print(
|
||||
"{s}WARNING:\nBun recommends Zig version '{s}', but found '{s}', build may fail...\nMake sure you are following the instructions at https://bun.sh/docs/project/contributing\n{s}You can update to the right version using 'zigup {s}'\n\n",
|
||||
.{
|
||||
if (colors) "\x1b[1;33m" else "",
|
||||
recommended_zig_version,
|
||||
builtin.zig_version_string,
|
||||
if (colors) "\x1b[0m" else "",
|
||||
recommended_zig_version,
|
||||
},
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
// Standard target options allows the person running `zig build` to choose
|
||||
// what target to build for. Here we do not override the defaults, which
|
||||
// means any target is allowed, and the default is native. Other options
|
||||
@@ -155,8 +181,14 @@ pub fn build_(b: *Build) !void {
|
||||
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
|
||||
optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
var generated_code_directory = b.option([]const u8, "generated-code", "Set the generated code directory") orelse "";
|
||||
|
||||
if (generated_code_directory.len == 0) {
|
||||
generated_code_directory = b.pathFromRoot("build/codegen");
|
||||
}
|
||||
|
||||
var output_dir_buf = std.mem.zeroes([4096]u8);
|
||||
var bin_label = if (optimize == std.builtin.OptimizeMode.Debug) "packages/debug-bun-" else "packages/bun-";
|
||||
const bin_label = if (optimize == std.builtin.OptimizeMode.Debug) "packages/debug-bun-" else "packages/bun-";
|
||||
|
||||
var triplet_buf: [64]u8 = undefined;
|
||||
var os_tagname = @tagName(target.getOs().tag);
|
||||
@@ -174,7 +206,7 @@ pub fn build_(b: *Build) !void {
|
||||
&triplet_buf,
|
||||
os_tagname,
|
||||
);
|
||||
var osname = triplet_buf[0..os_tagname.len];
|
||||
const osname = triplet_buf[0..os_tagname.len];
|
||||
triplet_buf[osname.len] = '-';
|
||||
|
||||
std.mem.copy(u8, triplet_buf[osname.len + 1 ..], @tagName(target.getCpuArch()));
|
||||
@@ -185,17 +217,19 @@ pub fn build_(b: *Build) !void {
|
||||
cpuArchName = cpuArchName[0..3];
|
||||
}
|
||||
|
||||
var triplet = triplet_buf[0 .. osname.len + cpuArchName.len + 1];
|
||||
const triplet = triplet_buf[0 .. osname.len + cpuArchName.len + 1];
|
||||
|
||||
if (b.option([]const u8, "output-dir", "target to install to") orelse std.os.getenv("OUTPUT_DIR")) |output_dir_| {
|
||||
output_dir = try pathRel(b.allocator, b.install_prefix, output_dir_);
|
||||
const outfile_maybe = b.option([]const u8, "output-file", "target to install to");
|
||||
|
||||
if (outfile_maybe) |outfile| {
|
||||
output_dir = try pathRel(b.allocator, b.install_prefix, std.fs.path.dirname(outfile) orelse "");
|
||||
} else {
|
||||
const output_dir_base = try std.fmt.bufPrint(&output_dir_buf, "{s}{s}", .{ bin_label, triplet });
|
||||
output_dir = try pathRel(b.allocator, b.install_prefix, output_dir_base);
|
||||
}
|
||||
|
||||
is_debug_build = optimize == OptimizeMode.Debug;
|
||||
const bun_executable_name = if (optimize == std.builtin.OptimizeMode.Debug) "bun-debug" else "bun";
|
||||
const bun_executable_name = if (outfile_maybe) |outfile| std.fs.path.basename(outfile[0 .. outfile.len - std.fs.path.extension(outfile).len]) else if (is_debug_build) "bun-debug" else "bun";
|
||||
const root_src = if (target.getOsTag() == std.Target.Os.Tag.freestanding)
|
||||
"root_wasm.zig"
|
||||
else
|
||||
@@ -217,10 +251,31 @@ pub fn build_(b: *Build) !void {
|
||||
.root_source_file = FileSource.relative(root_src),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.main_pkg_path = .{ .cwd_relative = b.pathFromRoot(".") },
|
||||
.main_mod_path = .{ .cwd_relative = b.pathFromRoot(".") },
|
||||
});
|
||||
|
||||
b.reference_trace = 16;
|
||||
if (!exists(b.pathFromRoot(try std.fs.path.join(b.allocator, &.{
|
||||
"src",
|
||||
"js_lexer",
|
||||
"id_continue_bitset.blob",
|
||||
})))) {
|
||||
const identifier_data = b.pathFromRoot(try std.fs.path.join(b.allocator, &.{ "src", "js_lexer", "identifier_data.zig" }));
|
||||
var run_step = b.addSystemCommand(&.{
|
||||
b.zig_exe,
|
||||
"run",
|
||||
identifier_data,
|
||||
});
|
||||
run_step.has_side_effects = true;
|
||||
obj.step.dependOn(&run_step.step);
|
||||
}
|
||||
|
||||
b.reference_trace = if (b.option(u32, "reference-trace", "Set the reference trace")) |trace|
|
||||
if (trace == 0)
|
||||
null
|
||||
else
|
||||
trace
|
||||
else
|
||||
16;
|
||||
|
||||
var default_build_options: BunBuildOptions = brk: {
|
||||
const is_baseline = arch.isX86() and (target.cpu_model == .baseline or
|
||||
@@ -231,7 +286,7 @@ pub fn build_(b: *Build) !void {
|
||||
git_sha = b.allocator.dupeZ(u8, sha) catch unreachable;
|
||||
} else {
|
||||
sha: {
|
||||
const result = std.ChildProcess.exec(.{
|
||||
const result = std.ChildProcess.run(.{
|
||||
.allocator = b.allocator,
|
||||
.argv = &.{
|
||||
"git",
|
||||
@@ -246,9 +301,17 @@ pub fn build_(b: *Build) !void {
|
||||
}
|
||||
}
|
||||
|
||||
const is_canary = (std.os.getenvZ("BUN_CANARY") orelse "0")[0] == '1';
|
||||
const is_canary, const canary_revision = if (b.option(u32, "canary", "Treat this as a canary build")) |rev|
|
||||
if (rev == 0)
|
||||
.{ false, 0 }
|
||||
else
|
||||
.{ true, rev }
|
||||
else
|
||||
.{ false, 0 };
|
||||
break :brk .{
|
||||
.canary = is_canary,
|
||||
.is_canary = is_canary,
|
||||
.canary_revision = canary_revision,
|
||||
.version = b.option([]const u8, "version", "Value of `Bun.version`") orelse "0.0.0",
|
||||
.sha = git_sha,
|
||||
.baseline = is_baseline,
|
||||
.bindgen = false,
|
||||
@@ -283,8 +346,8 @@ pub fn build_(b: *Build) !void {
|
||||
min_version,
|
||||
max_version,
|
||||
obj.target.getCpuModel().name,
|
||||
}) catch unreachable;
|
||||
std.io.getStdErr().writer().print("Output: {s}/{s}\n\n", .{ output_dir, bun_executable_name }) catch unreachable;
|
||||
}) catch {};
|
||||
std.io.getStdErr().writer().print("Zig v{s}\n", .{builtin.zig_version_string}) catch {};
|
||||
|
||||
defer obj_step.dependOn(&obj.step);
|
||||
|
||||
@@ -303,13 +366,23 @@ pub fn build_(b: *Build) !void {
|
||||
|
||||
obj.addOptions("build_options", actual_build_options.step(b));
|
||||
|
||||
obj.linkLibC();
|
||||
// Generated Code
|
||||
// TODO: exit with a better error early if these files do not exist. it is an indication someone ran `zig build` directly without the code generators.
|
||||
obj.addModule("ZigGeneratedClasses", b.createModule(.{
|
||||
.source_file = .{ .path = b.pathJoin(&.{ generated_code_directory, "ZigGeneratedClasses.zig" }) },
|
||||
}));
|
||||
obj.addModule("ResolvedSourceTag", b.createModule(.{
|
||||
.source_file = .{ .path = b.pathJoin(&.{ generated_code_directory, "ResolvedSourceTag.zig" }) },
|
||||
}));
|
||||
|
||||
obj.linkLibC();
|
||||
obj.dll_export_fns = true;
|
||||
obj.strip = false;
|
||||
obj.bundle_compiler_rt = false;
|
||||
obj.omit_frame_pointer = optimize != .Debug;
|
||||
obj.subsystem = .Console;
|
||||
|
||||
// Disable stack probing on x86 so we don't need to include compiler_rt
|
||||
if (target.getCpuArch().isX86()) obj.disable_stack_probing = true;
|
||||
if (target.getCpuArch().isX86() or target.isWindows()) obj.disable_stack_probing = true;
|
||||
|
||||
if (b.option(bool, "for-editor", "Do not emit bin, just check for errors") orelse false) {
|
||||
// obj.emit_bin = .no_emit;
|
||||
@@ -331,7 +404,7 @@ pub fn build_(b: *Build) !void {
|
||||
.root_source_file = FileSource.relative("src/bindgen.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.main_pkg_path = obj.main_pkg_path,
|
||||
.main_mod_path = obj.main_mod_path,
|
||||
});
|
||||
defer headers_step.dependOn(&headers_obj.step);
|
||||
try configureObjectStep(b, headers_obj, headers_step, @TypeOf(target), target);
|
||||
@@ -348,7 +421,7 @@ pub fn build_(b: *Build) !void {
|
||||
.root_source_file = FileSource.relative("root_wasm.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.main_pkg_path = obj.main_pkg_path,
|
||||
.main_mod_path = obj.main_mod_path,
|
||||
});
|
||||
defer wasm_step.dependOn(&wasm.step);
|
||||
wasm.strip = false;
|
||||
@@ -367,7 +440,7 @@ pub fn build_(b: *Build) !void {
|
||||
.root_source_file = FileSource.relative("misctools/http_bench.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.main_pkg_path = obj.main_pkg_path,
|
||||
.main_mod_path = obj.main_mod_path,
|
||||
});
|
||||
defer headers_step.dependOn(&headers_obj.step);
|
||||
try configureObjectStep(b, headers_obj, headers_step, @TypeOf(target), target);
|
||||
@@ -381,7 +454,7 @@ pub fn build_(b: *Build) !void {
|
||||
.root_source_file = FileSource.relative("misctools/machbench.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.main_pkg_path = obj.main_pkg_path,
|
||||
.main_mod_path = obj.main_mod_path,
|
||||
});
|
||||
defer headers_step.dependOn(&headers_obj.step);
|
||||
try configureObjectStep(b, headers_obj, headers_step, @TypeOf(target), target);
|
||||
@@ -395,7 +468,7 @@ pub fn build_(b: *Build) !void {
|
||||
.root_source_file = FileSource.relative("misctools/fetch.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.main_pkg_path = obj.main_pkg_path,
|
||||
.main_mod_path = obj.main_mod_path,
|
||||
});
|
||||
defer headers_step.dependOn(&headers_obj.step);
|
||||
try configureObjectStep(b, headers_obj, headers_step, @TypeOf(target), target);
|
||||
@@ -409,7 +482,7 @@ pub fn build_(b: *Build) !void {
|
||||
.root_source_file = FileSource.relative("src/bench/string-handling.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.main_pkg_path = obj.main_pkg_path,
|
||||
.main_mod_path = obj.main_mod_path,
|
||||
});
|
||||
defer headers_step.dependOn(&headers_obj.step);
|
||||
try configureObjectStep(b, headers_obj, headers_step, @TypeOf(target), target);
|
||||
@@ -423,7 +496,7 @@ pub fn build_(b: *Build) !void {
|
||||
.root_source_file = FileSource.relative("src/sha.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.main_pkg_path = obj.main_pkg_path,
|
||||
.main_mod_path = obj.main_mod_path,
|
||||
});
|
||||
defer headers_step.dependOn(&headers_obj.step);
|
||||
try configureObjectStep(b, headers_obj, headers_step, @TypeOf(target), target);
|
||||
@@ -437,7 +510,7 @@ pub fn build_(b: *Build) !void {
|
||||
.root_source_file = FileSource.relative("src/sourcemap/vlq_bench.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.main_pkg_path = obj.main_pkg_path,
|
||||
.main_mod_path = obj.main_mod_path,
|
||||
});
|
||||
defer headers_step.dependOn(&headers_obj.step);
|
||||
try configureObjectStep(b, headers_obj, headers_step, @TypeOf(target), target);
|
||||
@@ -451,7 +524,7 @@ pub fn build_(b: *Build) !void {
|
||||
.root_source_file = FileSource.relative("misctools/tgz.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.main_pkg_path = obj.main_pkg_path,
|
||||
.main_mod_path = obj.main_mod_path,
|
||||
});
|
||||
defer headers_step.dependOn(&headers_obj.step);
|
||||
try configureObjectStep(b, headers_obj, headers_step, @TypeOf(target), target);
|
||||
@@ -461,14 +534,14 @@ pub fn build_(b: *Build) !void {
|
||||
{
|
||||
const headers_step = b.step("test", "Build test");
|
||||
|
||||
var test_file = b.option([]const u8, "test-file", "Input file for test");
|
||||
var test_bin_ = b.option([]const u8, "test-bin", "Emit bin to");
|
||||
var test_filter = b.option([]const u8, "test-filter", "Filter for test");
|
||||
const test_file = b.option([]const u8, "test-file", "Input file for test");
|
||||
const test_bin_ = b.option([]const u8, "test-bin", "Emit bin to");
|
||||
const test_filter = b.option([]const u8, "test-filter", "Filter for test");
|
||||
|
||||
var headers_obj: *CompileStep = b.addTest(.{
|
||||
.root_source_file = FileSource.relative(test_file orelse "src/main.zig"),
|
||||
.target = target,
|
||||
.main_pkg_path = obj.main_pkg_path,
|
||||
.main_mod_path = obj.main_mod_path,
|
||||
});
|
||||
headers_obj.filter = test_filter;
|
||||
if (test_bin_) |test_bin| {
|
||||
@@ -490,7 +563,19 @@ pub fn build_(b: *Build) !void {
|
||||
headers_obj.addOptions("build_options", default_build_options.step(b));
|
||||
}
|
||||
|
||||
b.default_step.dependOn(obj_step);
|
||||
// Running `zig build` with no arguments is almost always a mistake.
|
||||
const mistake_message = b.addSystemCommand(&.{
|
||||
"echo",
|
||||
\\
|
||||
\\error: To build Bun from source, please use `bun run setup` instead of `zig build`"
|
||||
\\
|
||||
\\If you want to build the zig code only, run:
|
||||
\\ 'zig build obj -Dgenerated-code=./build/codegen [...opts]'
|
||||
\\
|
||||
\\For more info, see https://bun.sh/docs/project/contributing
|
||||
\\
|
||||
});
|
||||
b.default_step.dependOn(&mistake_message.step);
|
||||
}
|
||||
|
||||
pub var original_make_fn: ?*const fn (step: *std.build.Step) anyerror!void = null;
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -84,7 +84,7 @@ _bun_completions() {
|
||||
|
||||
local SUBCOMMANDS="dev bun create run install add remove upgrade completions discord help init pm x";
|
||||
|
||||
GLOBAL_OPTIONS[LONG_OPTIONS]="--use --cwd --bunfile --server-bunfile --config --disable-react-fast-refresh --disable-hmr --extension-order --jsx-factory --jsx-fragment --extension-order --jsx-factory --jsx-fragment --jsx-import-source --jsx-production --jsx-runtime --main-fields --no-summary --version --platform --public-dir --tsconfig-override --define --external --help --inject --loader --origin --port --dump-environment-variables --dump-limits --disable-bun-js";
|
||||
GLOBAL_OPTIONS[LONG_OPTIONS]="--use --cwd --bunfile --server-bunfile --config --disable-react-fast-refresh --disable-hmr --env-file --extension-order --jsx-factory --jsx-fragment --extension-order --jsx-factory --jsx-fragment --jsx-import-source --jsx-production --jsx-runtime --main-fields --no-summary --version --platform --public-dir --tsconfig-override --define --external --help --inject --loader --origin --port --dump-environment-variables --dump-limits --disable-bun-js";
|
||||
GLOBAL_OPTIONS[SHORT_OPTIONS]="-c -v -d -e -h -i -l -u -p";
|
||||
|
||||
PACKAGE_OPTIONS[ADD_OPTIONS_LONG]="--development --optional";
|
||||
@@ -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 ))]}";
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ function __bun_last_cmd --argument-names n
|
||||
end
|
||||
|
||||
set -l bun_install_boolean_flags yarn production optional development no-save dry-run force no-cache silent verbose global
|
||||
set -l bun_install_boolean_flags_descriptions "Write a yarn.lock file (yarn v1)" "Don't install devDependencies" "Add dependency to optionalDependencies" "Add dependency to devDependencies" "Don't install devDependencies" "Don't install anything" "Always request the latest versions from the registry & reinstall all dependenices" "Ignore manifest cache entirely" "Don't output anything" "Excessively verbose logging" "Use global folder"
|
||||
set -l bun_install_boolean_flags_descriptions "Write a yarn.lock file (yarn v1)" "Don't install devDependencies" "Add dependency to optionalDependencies" "Add dependency to devDependencies" "Don't install devDependencies" "Don't install anything" "Always request the latest versions from the registry & reinstall all dependencies" "Ignore manifest cache entirely" "Don't output anything" "Excessively verbose logging" "Use global folder"
|
||||
|
||||
set -l bun_builtin_cmds dev create help bun upgrade discord run install remove add init link unlink pm x
|
||||
set -l bun_builtin_cmds_without_run dev create help bun upgrade discord install remove add init pm x
|
||||
|
||||
1359
completions/bun.zsh
1359
completions/bun.zsh
File diff suppressed because it is too large
Load Diff
@@ -78,6 +78,9 @@ subcommands:
|
||||
- name: server-bunfile
|
||||
type: string
|
||||
summary: "Use a specific .bun file for SSR in bun dev (default: node_modules.server.bun)"
|
||||
- name: env-file
|
||||
type: string
|
||||
summary: "Load environment variables from the specified file(s)"
|
||||
- name: extension-order
|
||||
type: string
|
||||
summary: "defaults to: .tsx,.ts,.jsx,.js,.json"
|
||||
@@ -118,10 +121,7 @@ subcommands:
|
||||
- frozen-lockfile -- "Disallow changes to lockfile"
|
||||
- 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"
|
||||
- force -- "Always request the latest versions from the registry & reinstall all dependencies"
|
||||
- name: cache-dir
|
||||
type: string
|
||||
summary: "Store & load cached data from a specific directory path"
|
||||
@@ -156,13 +156,10 @@ subcommands:
|
||||
- frozen-lockfile -- "Disallow changes to lockfile"
|
||||
- no-save --
|
||||
- dry-run -- "Don't install anything"
|
||||
- force -- "Always request the latest versions from the registry & reinstall all dependenices"
|
||||
- force -- "Always request the latest versions from the registry & reinstall all dependencies"
|
||||
- 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"
|
||||
@@ -197,10 +194,7 @@ subcommands:
|
||||
- frozen-lockfile -- "Disallow changes to lockfile"
|
||||
- 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"
|
||||
- force -- "Always request the latest versions from the registry & reinstall all dependencies"
|
||||
- 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"]
|
||||
118
dockerhub/alpine/Dockerfile
Normal file
118
dockerhub/alpine/Dockerfile
Normal file
@@ -0,0 +1,118 @@
|
||||
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
|
||||
|
||||
# Disable the runtime transpiler cache by default inside Docker containers.
|
||||
# On ephemeral containers, the cache is not useful
|
||||
ARG BUN_RUNTIME_TRANSPILER_CACHE_PATH=0
|
||||
ENV BUN_RUNTIME_TRANSPILER_CACHE_PATH=${BUN_RUNTIME_TRANSPILER_CACHE_PATH}
|
||||
|
||||
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,49 @@ 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
|
||||
|
||||
# Disable the runtime transpiler cache by default inside Docker containers.
|
||||
# On ephemeral containers, the cache is not useful
|
||||
ARG BUN_RUNTIME_TRANSPILER_CACHE_PATH=0
|
||||
ENV BUN_RUNTIME_TRANSPILER_CACHE_PATH=${BUN_RUNTIME_TRANSPILER_CACHE_PATH}
|
||||
|
||||
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,47 @@ 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
|
||||
|
||||
# Disable the runtime transpiler cache by default inside Docker containers.
|
||||
# On ephemeral containers, the cache is not useful
|
||||
ARG BUN_RUNTIME_TRANSPILER_CACHE_PATH=0
|
||||
ENV BUN_RUNTIME_TRANSPILER_CACHE_PATH=${BUN_RUNTIME_TRANSPILER_CACHE_PATH}
|
||||
|
||||
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,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
|
||||
|
||||
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
|
||||
# Disable the runtime transpiler cache by default inside Docker containers.
|
||||
# On ephemeral containers, the cache is not useful
|
||||
ARG BUN_RUNTIME_TRANSPILER_CACHE_PATH=0
|
||||
ENV BUN_RUNTIME_TRANSPILER_CACHE_PATH=${BUN_RUNTIME_TRANSPILER_CACHE_PATH}
|
||||
|
||||
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"]
|
||||
@@ -26,10 +26,10 @@ Below is a quick "cheat sheet" that doubles as a table of contents. Click an ite
|
||||
|
||||
---
|
||||
|
||||
<!-- - [`File`](#file)
|
||||
- _Browser only_. A subclass of `Blob` that represents a file. Has a `name` and `lastModified` timestamp. There is experimental support in Node.js v20; Bun does not support `File` yet; most of its functionality is provided by `BunFile`.
|
||||
- [`File`](#file)
|
||||
- A subclass of `Blob` that represents a file. Has a `name` and `lastModified` timestamp. There is experimental support in Node.js v20.
|
||||
|
||||
--- -->
|
||||
---
|
||||
|
||||
- [`BunFile`](#bunfile)
|
||||
- _Bun only_. A subclass of `Blob` that represents a lazily-loaded file on disk. Created with `Bun.file(path)`.
|
||||
@@ -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");
|
||||
@@ -300,7 +300,7 @@ interface BunFile {
|
||||
readonly type: string;
|
||||
|
||||
text(): Promise<string>;
|
||||
stream(): Promise<ReadableStream>;
|
||||
stream(): ReadableStream;
|
||||
arrayBuffer(): Promise<ArrayBuffer>;
|
||||
json(): Promise<any>;
|
||||
writer(params: { highWaterMark?: number }): FileSink;
|
||||
|
||||
@@ -93,6 +93,7 @@ interface Bun {
|
||||
style: "nextjs";
|
||||
origin?: string;
|
||||
assetPrefix?: string;
|
||||
fileExtensions?: string[];
|
||||
});
|
||||
|
||||
reload(): void;
|
||||
|
||||
110
docs/api/glob.md
Normal file
110
docs/api/glob.md
Normal file
@@ -0,0 +1,110 @@
|
||||
Bun includes a fast native implementation of file globbing.
|
||||
|
||||
## Quickstart
|
||||
|
||||
**Scan a directory for files matching `*.ts`**:
|
||||
|
||||
```ts
|
||||
import { Glob } from "bun";
|
||||
|
||||
const glob = new Glob("*.ts");
|
||||
|
||||
for await (const file of glob.scan(".")) {
|
||||
console.log(file); // => "index.ts"
|
||||
}
|
||||
```
|
||||
|
||||
**Match a string against a glob pattern**:
|
||||
|
||||
```ts
|
||||
import { Glob } from "bun";
|
||||
|
||||
const glob = new Glob("*.ts");
|
||||
|
||||
glob.match("index.ts"); // => true
|
||||
glob.match("index.js"); // => false
|
||||
```
|
||||
|
||||
`Glob` is a class which implements the following interface:
|
||||
|
||||
```ts
|
||||
class Glob {
|
||||
scan(root: string | ScanOptions): AsyncIterable<string>;
|
||||
scanSync(root: string | ScanOptions): Iterable<string>;
|
||||
|
||||
match(path: string): boolean;
|
||||
}
|
||||
|
||||
interface ScanOptions {
|
||||
/**
|
||||
* The root directory to start matching from. Defaults to `process.cwd()`
|
||||
*/
|
||||
cwd?: string;
|
||||
|
||||
/**
|
||||
* Allow patterns to match entries that begin with a period (`.`).
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
dot?: boolean;
|
||||
|
||||
/**
|
||||
* Return the absolute path for entries.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
absolute?: boolean;
|
||||
|
||||
/**
|
||||
* Indicates whether to traverse descendants of symbolic link directories.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
followSymlinks?: boolean;
|
||||
|
||||
/**
|
||||
* Throw an error when symbolic link is broken
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
throwErrorOnBrokenSymlink?: boolean;
|
||||
|
||||
/**
|
||||
* Return only files.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
onlyFiles?: boolean;
|
||||
}
|
||||
```
|
||||
|
||||
## Supported Glob Patterns
|
||||
|
||||
Bun supports the following glob patterns:
|
||||
|
||||
### `*` - Match any number of characters except `/`
|
||||
|
||||
```ts
|
||||
const glob = new Glob("*.ts");
|
||||
glob.match("index.ts"); // => true
|
||||
glob.match("src/index.ts"); // => false
|
||||
```
|
||||
|
||||
### `**` - Match any number of characters including `/`
|
||||
|
||||
```ts
|
||||
const glob = new Glob("**/*.ts");
|
||||
glob.match("index.ts"); // => true
|
||||
glob.match("src/index.ts"); // => true
|
||||
glob.match("src/index.js"); // => false
|
||||
```
|
||||
|
||||
### `{a,b,c}` - Match any of the given patterns
|
||||
|
||||
```ts
|
||||
const glob = new Glob("{a,b,c}.ts");
|
||||
glob.match("a.ts"); // => true
|
||||
glob.match("b.ts"); // => true
|
||||
glob.match("c.ts"); // => true
|
||||
glob.match("d.ts"); // => false
|
||||
```
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
@@ -38,8 +38,13 @@ import.meta.resolveSync("zod")
|
||||
|
||||
---
|
||||
|
||||
- `import.meta.env`
|
||||
- An alias to `process.env`.
|
||||
|
||||
---
|
||||
|
||||
- `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");
|
||||
|
||||
52
docs/api/semver.md
Normal file
52
docs/api/semver.md
Normal file
@@ -0,0 +1,52 @@
|
||||
Bun implements a semantic versioning API which can be used to compare versions and determine if a version is compatible with another range of versions. The versions and ranges are designed to be compatible with `node-semver`, which is used by npm clients.
|
||||
|
||||
It's about 20x faster than `node-semver`.
|
||||
|
||||

|
||||
|
||||
Currently, this API is two functions.
|
||||
|
||||
#### `Bun.semver.satisfies(version: string, range: string): boolean`
|
||||
|
||||
Returns `true` if `version` satisfies `range`, otherwise `false`.
|
||||
|
||||
Example:
|
||||
|
||||
```typescript
|
||||
import { semver } from "bun";
|
||||
|
||||
semver.satisfies("1.0.0", "^1.0.0"); // true
|
||||
semver.satisfies("1.0.0", "^1.0.1"); // false
|
||||
semver.satisfies("1.0.0", "~1.0.0"); // true
|
||||
semver.satisfies("1.0.0", "~1.0.1"); // false
|
||||
semver.satisfies("1.0.0", "1.0.0"); // true
|
||||
semver.satisfies("1.0.0", "1.0.1"); // false
|
||||
semver.satisfies("1.0.1", "1.0.0"); // false
|
||||
semver.satisfies("1.0.0", "1.0.x"); // true
|
||||
semver.satisfies("1.0.0", "1.x.x"); // true
|
||||
semver.satisfies("1.0.0", "x.x.x"); // true
|
||||
semver.satisfies("1.0.0", "1.0.0 - 2.0.0"); // true
|
||||
semver.satisfies("1.0.0", "1.0.0 - 1.0.1"); // true
|
||||
```
|
||||
|
||||
If `range` is invalid, it returns false. If `version` is invalid, it returns false.
|
||||
|
||||
#### `Bun.semver.order(versionA: string, versionB: string): 0 | 1 | -1`
|
||||
|
||||
Returns `0` if `versionA` and `versionB` are equal, `1` if `versionA` is greater than `versionB`, and `-1` if `versionA` is less than `versionB`.
|
||||
|
||||
Example:
|
||||
|
||||
```typescript
|
||||
import { semver } from "bun";
|
||||
|
||||
semver.order("1.0.0", "1.0.0"); // 0
|
||||
semver.order("1.0.0", "1.0.1"); // -1
|
||||
semver.order("1.0.1", "1.0.0"); // 1
|
||||
|
||||
const unsorted = ["1.0.0", "1.0.1", "1.0.0-alpha", "1.0.0-beta", "1.0.0-rc"];
|
||||
unsorted.sort(semver.order); // ["1.0.0-alpha", "1.0.0-beta", "1.0.0-rc", "1.0.0", "1.0.1"]
|
||||
console.log(unsorted);
|
||||
```
|
||||
|
||||
If you need other semver functions, feel free to open an issue or pull request.
|
||||
@@ -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();
|
||||
@@ -181,6 +183,60 @@ const proc = Bun.spawn(["echo", "hello"]);
|
||||
proc.unref();
|
||||
```
|
||||
|
||||
## Inter-process communication (IPC)
|
||||
|
||||
Bun supports direct inter-process communication channel between two `bun` processes. To receive messages from a spawned Bun subprocess, specify an `ipc` handler.
|
||||
{%callout%}
|
||||
**Note** — This API is only compatible with other `bun` processes. Use `process.execPath` to get a path to the currently running `bun` executable.
|
||||
{%/callout%}
|
||||
|
||||
```ts#parent.ts
|
||||
const child = Bun.spawn(["bun", "child.ts"], {
|
||||
ipc(message) {
|
||||
/**
|
||||
* The message received from the sub process
|
||||
**/
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
The parent process can send messages to the subprocess using the `.send()` method on the returned `Subprocess` instance. A reference to the sending subprocess is also available as the second argument in the `ipc` handler.
|
||||
|
||||
```ts#parent.ts
|
||||
const childProc = Bun.spawn(["bun", "child.ts"], {
|
||||
ipc(message, childProc) {
|
||||
/**
|
||||
* The message received from the sub process
|
||||
**/
|
||||
childProc.send("Respond to child")
|
||||
},
|
||||
});
|
||||
|
||||
childProc.send("I am your father"); // The parent can send messages to the child as well
|
||||
```
|
||||
|
||||
Meanwhile the child process can send messages to its parent using with `process.send()` and receive messages with `process.on("message")`. This is the same API used for `child_process.fork()` in Node.js.
|
||||
|
||||
```ts#child.ts
|
||||
process.send("Hello from child as string");
|
||||
process.send({ message: "Hello from child as object" });
|
||||
|
||||
process.on("message", (message) => {
|
||||
// print message from parent
|
||||
console.log(message);
|
||||
});
|
||||
```
|
||||
|
||||
All messages are serialized using the JSC `serialize` API, which allows for the same set of [transferrable types](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Transferable_objects) supported by `postMessage` and `structuredClone`, including strings, typed arrays, streams, and objects.
|
||||
|
||||
```ts#child.ts
|
||||
// send a string
|
||||
process.send("Hello from child as string");
|
||||
|
||||
// send an object
|
||||
process.send({ message: "Hello from child as object" });
|
||||
```
|
||||
|
||||
## Blocking API (`Bun.spawnSync()`)
|
||||
|
||||
Bun provides a synchronous equivalent of `Bun.spawn` called `Bun.spawnSync`. This is a blocking API that supports the same inputs and parameters as `Bun.spawn`. It returns a `SyncSubprocess` object, which differs from `Subprocess` in a few ways.
|
||||
@@ -209,7 +265,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 +286,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 +304,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 } };
|
||||
@@ -398,7 +398,7 @@ buf; // => Uint8Array(25)
|
||||
compressed; // => Uint8Array(10)
|
||||
```
|
||||
|
||||
The second argument supports the same set of configuration options as [`Bun.gzipSync`](#bun.gzipSync).
|
||||
The second argument supports the same set of configuration options as [`Bun.gzipSync`](#bungzipsync).
|
||||
|
||||
## `Bun.inflateSync()`
|
||||
|
||||
|
||||
@@ -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 }>({
|
||||
@@ -192,7 +192,7 @@ const server = Bun.serve<{ username: string }>({
|
||||
close(ws) {
|
||||
const msg = `${ws.data.username} has left the chat`;
|
||||
ws.unsubscribe("the-group-chat");
|
||||
ws.publish("the-group-chat", msg);
|
||||
server.publish("the-group-chat", msg);
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -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.
|
||||
@@ -316,7 +328,7 @@ Depending on the target, Bun will apply different module resolution rules and op
|
||||
|
||||
All bundles generated with `target: "bun"` are marked with a special `// @bun` pragma, which indicates to the Bun runtime that there's no need to re-transpile the file before execution.
|
||||
|
||||
If any entrypoints contains a Bun shebang (`#!/usr/bin/env bun`) the bundler will default to `target: "bun"` instead of `"browser`.
|
||||
If any entrypoints contains a Bun shebang (`#!/usr/bin/env bun`) the bundler will default to `target: "bun"` instead of `"browser"`.
|
||||
|
||||
---
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -1040,7 +1052,7 @@ $ bun build ./index.tsx --outdir ./out --define 'STRING="value"' --define "neste
|
||||
|
||||
### `loader`
|
||||
|
||||
A map of file extensions to [built-in loader names](https://bun.sh/docs/bundler/loaders#built-in-loaders). This can be used to quickly customize how certain file files are loaded.
|
||||
A map of file extensions to [built-in loader names](https://bun.sh/docs/bundler/loaders#built-in-loaders). This can be used to quickly customize how certain files are loaded.
|
||||
|
||||
{% codetabs %}
|
||||
|
||||
@@ -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
|
||||
|
||||
---
|
||||
|
||||
|
||||
155
docs/cli/add.md
Normal file
155
docs/cli/add.md
Normal file
@@ -0,0 +1,155 @@
|
||||
To add a particular package:
|
||||
|
||||
```bash
|
||||
$ bun add preact
|
||||
```
|
||||
|
||||
To specify a version, version range, or tag:
|
||||
|
||||
```bash
|
||||
$ bun add zod@3.20.0
|
||||
$ bun add zod@^3.0.0
|
||||
$ bun add zod@latest
|
||||
```
|
||||
|
||||
## `--dev`
|
||||
|
||||
{% callout %}
|
||||
**Alias** — `--development`, `-d`, `-D`
|
||||
{% /callout %}
|
||||
|
||||
To add a package as a dev dependency (`"devDependencies"`):
|
||||
|
||||
```bash
|
||||
$ bun add --dev @types/react
|
||||
$ bun add -d @types/react
|
||||
```
|
||||
|
||||
## `--optional`
|
||||
|
||||
To add a package as an optional dependency (`"optionalDependencies"`):
|
||||
|
||||
```bash
|
||||
$ bun add --optional lodash
|
||||
```
|
||||
|
||||
## `--exact`
|
||||
|
||||
To add a package and pin to the resolved version, use `--exact`. This will resolve the version of the package and add it to your `package.json` with an exact version number instead of a version range.
|
||||
|
||||
```bash
|
||||
$ bun add react --exact
|
||||
$ bun add react -E
|
||||
```
|
||||
|
||||
This will add the following to your `package.json`:
|
||||
|
||||
```jsonc
|
||||
{
|
||||
"dependencies": {
|
||||
// without --exact
|
||||
"react": "^18.2.0", // this matches >= 18.2.0 < 19.0.0
|
||||
|
||||
// with --exact
|
||||
"react": "18.2.0" // this matches only 18.2.0 exactly
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
To view a complete list of options for this command:
|
||||
|
||||
```bash
|
||||
$ bun add --help
|
||||
```
|
||||
|
||||
## `--global`
|
||||
|
||||
{% callout %}
|
||||
**Note** — This would not modify package.json of your current project folder.
|
||||
**Alias** - `bun add --global`, `bun add -g`, `bun install --global` and `bun install -g`
|
||||
{% /callout %}
|
||||
|
||||
To install a package globally, use the `-g`/`--global` flag. This will not modify the `package.json` of your current project. Typically this is used for installing command-line tools.
|
||||
|
||||
```bash
|
||||
$ bun add --global cowsay # or `bun add -g cowsay`
|
||||
$ cowsay "Bun!"
|
||||
______
|
||||
< Bun! >
|
||||
------
|
||||
\ ^__^
|
||||
\ (oo)\_______
|
||||
(__)\ )\/\
|
||||
||----w |
|
||||
|| ||
|
||||
```
|
||||
|
||||
{% details summary="Configuring global installation behavior" %}
|
||||
|
||||
```toml
|
||||
[install]
|
||||
# where `bun add --global` installs packages
|
||||
globalDir = "~/.bun/install/global"
|
||||
|
||||
# where globally-installed package bins are linked
|
||||
globalBinDir = "~/.bun/bin"
|
||||
```
|
||||
|
||||
{% /details %}
|
||||
|
||||
## Trusted dependencies
|
||||
|
||||
Unlike other npm clients, Bun does not execute arbitrary lifecycle scripts for installed dependencies, such as `postinstall`. These scripts represent a potential security risk, as they can execute arbitrary code on your machine.
|
||||
|
||||
To tell Bun to allow lifecycle scripts for a particular package, add the package to `trustedDependencies` in your package.json.
|
||||
|
||||
```json-diff
|
||||
{
|
||||
"name": "my-app",
|
||||
"version": "1.0.0",
|
||||
+ "trustedDependencies": ["my-trusted-package"]
|
||||
}
|
||||
```
|
||||
|
||||
Bun reads this field and will run lifecycle scripts for `my-trusted-package`.
|
||||
|
||||
<!-- 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. -->
|
||||
|
||||
## Git dependencies
|
||||
|
||||
To add a dependency from a git repository:
|
||||
|
||||
```bash
|
||||
$ bun add git@github.com:moment/moment.git
|
||||
```
|
||||
|
||||
Bun supports a variety of protocols, including [`github`](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#github-urls), [`git`](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#git-urls-as-dependencies), `git+ssh`, `git+https`, and many more.
|
||||
|
||||
```json
|
||||
{
|
||||
"dependencies": {
|
||||
"dayjs": "git+https://github.com/iamkun/dayjs.git",
|
||||
"lodash": "git+ssh://github.com/lodash/lodash.git#4.17.21",
|
||||
"moment": "git@github.com:moment/moment.git",
|
||||
"zod": "github:colinhacks/zod"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Tarball dependencies
|
||||
|
||||
A package name can correspond to a publicly hosted `.tgz` file. During installation, Bun will download and install the package from the specified tarball URL, rather than from the package registry.
|
||||
|
||||
```sh
|
||||
$ bun add zod@https://registry.npmjs.org/zod/-/zod-3.21.4.tgz
|
||||
```
|
||||
|
||||
This will add the following line to your `package.json`:
|
||||
|
||||
```json#package.json
|
||||
{
|
||||
"dependencies": {
|
||||
"zod": "https://registry.npmjs.org/zod/-/zod-3.21.4.tgz"
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,56 +1,55 @@
|
||||
## `bun init`
|
||||
|
||||
Scaffold an empty project with the interactive `bun init` command.
|
||||
|
||||
```bash
|
||||
$ bun init
|
||||
bun init helps you get started with a minimal project and tries to
|
||||
guess sensible defaults. Press ^C anytime to quit.
|
||||
|
||||
package name (quickstart):
|
||||
entry point (index.ts):
|
||||
|
||||
Done! A package.json file was saved in the current directory.
|
||||
+ index.ts
|
||||
+ .gitignore
|
||||
+ tsconfig.json (for editor auto-complete)
|
||||
+ README.md
|
||||
|
||||
To get started, run:
|
||||
bun run index.ts
|
||||
```
|
||||
|
||||
Press `enter` to accept the default answer for each prompt, or pass the `-y` flag to auto-accept the defaults.
|
||||
|
||||
## `bun create`
|
||||
|
||||
Template a new Bun project with `bun create`.
|
||||
|
||||
```bash
|
||||
$ bun create <template> <destination>
|
||||
```
|
||||
|
||||
{% callout %}
|
||||
**Note** — You don’t need `bun create` to use Bun. You don’t need any configuration at all. This command exists to make getting started a bit quicker and easier.
|
||||
{% /callout %}
|
||||
|
||||
A template can take a number of forms:
|
||||
Template a new Bun project with `bun create`. This is a flexible command that can be used to create a new project with a `create-<template>` npm package, a GitHub repo, or a local template.
|
||||
|
||||
```bash
|
||||
$ bun create <template> # an official template (remote)
|
||||
$ bun create <username>/<repo> # a GitHub repo (remote)
|
||||
$ bun create <local-template> # a custom template (local)
|
||||
If you're looking to create a brand new empty project, use [`bun init`](/docs/cli/init).
|
||||
|
||||
## From `npm`
|
||||
|
||||
```sh
|
||||
$ bun create <template> [<destination>]
|
||||
```
|
||||
|
||||
Running `bun create` performs the following steps:
|
||||
Assuming you don't have a [local template](#from-a-local-template) with the same name, this command will download and execute the `create-<template>` package from npm. The following two commands will behave identically:
|
||||
|
||||
- Download the template (remote templates only)
|
||||
- Copy all template files into the destination folder. By default Bun will _not overwrite_ any existing files. Use the `--force` flag to overwrite existing files.
|
||||
```sh
|
||||
$ bun create remix
|
||||
$ bunx create-remix
|
||||
```
|
||||
|
||||
Refer to the documentation of the associated `create-<template>` package for complete documentation and usage instructions.
|
||||
|
||||
## From GitHub
|
||||
|
||||
This will download the contents of the GitHub repo to disk.
|
||||
|
||||
```bash
|
||||
$ bun create <user>/<repo>
|
||||
$ bun create github.com/<user>/<repo>
|
||||
```
|
||||
|
||||
Optionally specify a name for the destination folder. If no destination is specified, the repo name will be used.
|
||||
|
||||
```bash
|
||||
$ bun create <user>/<repo> mydir
|
||||
$ bun create github.com/<user>/<repo> mydir
|
||||
```
|
||||
|
||||
Bun will perform the following steps:
|
||||
|
||||
- Download the template
|
||||
- Copy all template files into the destination folder
|
||||
- Install dependencies with `bun install`.
|
||||
- Initialize a fresh Git repo. Opt out with the `--no-git` flag.
|
||||
- Run the template's configured `start` script, if defined.
|
||||
|
||||
### Official templates
|
||||
{% callout %}
|
||||
By default Bun will _not overwrite_ any existing files. Use the `--force` flag to overwrite existing files.
|
||||
{% /callout %}
|
||||
|
||||
<!-- ### Official templates
|
||||
|
||||
The following official templates are available.
|
||||
|
||||
@@ -73,9 +72,9 @@ 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
|
||||
<!-- ### GitHub repos
|
||||
|
||||
A template of the form `<username>/<repo>` will be downloaded from GitHub.
|
||||
|
||||
@@ -90,9 +89,9 @@ $ bun create github.com/ahfarmer/calculator ./myapp
|
||||
$ bun create https://github.com/ahfarmer/calculator ./myapp
|
||||
```
|
||||
|
||||
Bun installs the files as they currently exist current default branch (usually `main` or `master`). Unlike `git clone` it doesn't download the commit history or configure a remote.
|
||||
Bun installs the files as they currently exist current default branch (usually `main` or `master`). Unlike `git clone` it doesn't download the commit history or configure a remote. -->
|
||||
|
||||
### Local templates
|
||||
## From a local template
|
||||
|
||||
{% callout %}
|
||||
**⚠️ Warning** — Unlike remote templates, running `bun create` with a local template will delete the entire destination folder if it already exists! Be careful.
|
||||
@@ -124,26 +123,9 @@ Then, create a `package.json` file in that directory with the following contents
|
||||
|
||||
You can run `bun create foo` elsewhere on your file system to verify that Bun is correctly finding your local template.
|
||||
|
||||
{% table %}
|
||||
#### Setup logic
|
||||
|
||||
---
|
||||
|
||||
- `postinstall`
|
||||
- runs after installing dependencies
|
||||
|
||||
---
|
||||
|
||||
- `preinstall`
|
||||
- runs before installing dependencies
|
||||
|
||||
<!-- ---
|
||||
|
||||
- `start`
|
||||
- a command to auto-start the application -->
|
||||
|
||||
{% /table %}
|
||||
|
||||
Each of these can correspond to a string or array of strings. An array of commands will be executed in order. Here is an example:
|
||||
You can specify pre- and post-install setup scripts in the `"bun-create"` section of your local template's `package.json`.
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -162,11 +144,27 @@ Each of these can correspond to a string or array of strings. An array of comman
|
||||
}
|
||||
```
|
||||
|
||||
When cloning a template, `bun create` will automatically remove the `"bun-create"` section from `package.json` before writing it to the destination folder.
|
||||
The following fields are supported. Each of these can correspond to a string or array of strings. An array of commands will be executed in order.
|
||||
|
||||
### Reference
|
||||
{% table %}
|
||||
|
||||
#### CLI flags
|
||||
---
|
||||
|
||||
- `postinstall`
|
||||
- runs after installing dependencies
|
||||
|
||||
---
|
||||
|
||||
- `preinstall`
|
||||
- runs before installing dependencies
|
||||
|
||||
{% /table %}
|
||||
|
||||
After cloning a template, `bun create` will automatically remove the `"bun-create"` section from `package.json` before writing it to the destination folder.
|
||||
|
||||
## Reference
|
||||
|
||||
### CLI flags
|
||||
|
||||
{% table %}
|
||||
|
||||
@@ -195,7 +193,7 @@ When cloning a template, `bun create` will automatically remove the `"bun-create
|
||||
|
||||
{% /table %}
|
||||
|
||||
#### Environment variables
|
||||
### Environment variables
|
||||
|
||||
{% table %}
|
||||
|
||||
@@ -209,7 +207,7 @@ When cloning a template, `bun create` will automatically remove the `"bun-create
|
||||
|
||||
---
|
||||
|
||||
- `GITHUB_API_TOKEN`
|
||||
- `GITHUB_ACCESS_TOKEN`
|
||||
- This lets `bun create` work with private repositories or if you get rate-limited
|
||||
|
||||
{% /table %}
|
||||
@@ -21,7 +21,7 @@ Configuring with `bunfig.toml` is optional. Bun tries to be zero configuration i
|
||||
|
||||
# Scope name The value can be a URL string or an object
|
||||
"@mybigcompany" = { token = "123456", url = "https://registry.mybigcompany.com" }
|
||||
# URL is optional and fallsback to the default registry
|
||||
# URL is optional and falls back to the default registry
|
||||
|
||||
# The "@" in the scope is optional
|
||||
mybigcompany2 = { token = "123456" }
|
||||
@@ -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
|
||||
@@ -59,8 +59,8 @@ optional = true
|
||||
# Install local devDependencies (default: true)
|
||||
dev = true
|
||||
|
||||
# Install peerDependencies (default: false)
|
||||
peer = false
|
||||
# Install peerDependencies (default: true)
|
||||
peer = true
|
||||
|
||||
# When using `bun install -g`, install packages here
|
||||
globalDir = "~/.bun/install/global"
|
||||
@@ -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 |
|
||||
@@ -179,7 +170,7 @@ bun stores normalized `cpu` and `os` values from npm in the lockfile, along with
|
||||
|
||||
## Peer dependencies?
|
||||
|
||||
Peer dependencies are handled similarly to yarn. `bun install` does not automatically install peer dependencies and will try to choose an existing dependency.
|
||||
Peer dependencies are handled similarly to yarn. `bun install` will automatically install peer dependencies. If the dependency is marked optional in `peerDependenciesMeta`, an existing dependency will be chosen if possible.
|
||||
|
||||
## 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.
|
||||
|
||||
@@ -1,256 +0,0 @@
|
||||
## `bun init`
|
||||
|
||||
Scaffold an empty project with `bun init`. It's an interactive tool.
|
||||
|
||||
```bash
|
||||
$ bun init
|
||||
bun init helps you get started with a minimal project and tries to
|
||||
guess sensible defaults. Press ^C anytime to quit.
|
||||
|
||||
package name (quickstart):
|
||||
entry point (index.ts):
|
||||
|
||||
Done! A package.json file was saved in the current directory.
|
||||
+ index.ts
|
||||
+ .gitignore
|
||||
+ tsconfig.json (for editor auto-complete)
|
||||
+ README.md
|
||||
|
||||
To get started, run:
|
||||
bun run index.ts
|
||||
```
|
||||
|
||||
Press `enter` to accept the default answer for each prompt, or pass the `-y` flag to auto-accept the defaults.
|
||||
|
||||
## `bun create`
|
||||
|
||||
Template a new Bun project with `bun create`.
|
||||
|
||||
```bash
|
||||
$ bun create <template> <destination>
|
||||
```
|
||||
|
||||
{% callout %}
|
||||
**Note** — You don’t need `bun create` to use Bun. You don’t need any configuration at all. This command exists to make getting started a bit quicker and easier.
|
||||
{% /callout %}
|
||||
|
||||
A template can take a number of forms:
|
||||
|
||||
```bash
|
||||
$ bun create <template> # an official template (remote)
|
||||
$ bun create <username>/<repo> # a GitHub repo (remote)
|
||||
$ bun create <local-template> # a custom template (local)
|
||||
```
|
||||
|
||||
Running `bun create` performs the following steps:
|
||||
|
||||
- Download the template (remote templates only)
|
||||
- Copy all template files into the destination folder. By default Bun will _not overwrite_ any existing files. Use the `--force` flag to overwrite existing files.
|
||||
- Install dependencies with `bun install`.
|
||||
- Initialize a fresh Git repo. Opt out with the `--no-git` flag.
|
||||
- Run the template's configured `start` script, if defined.
|
||||
|
||||
## Official templates
|
||||
|
||||
The following official templates are available.
|
||||
|
||||
```bash
|
||||
bun create next ./myapp
|
||||
bun create react ./myapp
|
||||
bun create svelte-kit ./myapp
|
||||
bun create elysia ./myapp
|
||||
bun create hono ./myapp
|
||||
bun create kingworld ./myapp
|
||||
```
|
||||
|
||||
Each of these corresponds to a directory in the [bun-community/create-templates](https://github.com/bun-community/create-templates) repo. If you think a major framework is missing, please open a PR there. This list will change over time as additional examples are added. To see an up-to-date list, run `bun create` with no arguments.
|
||||
|
||||
```bash
|
||||
$ bun create
|
||||
Welcome to bun! Create a new project by pasting any of the following:
|
||||
<list of templates>
|
||||
```
|
||||
|
||||
{% 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 %}
|
||||
|
||||
## GitHub repos
|
||||
|
||||
A template of the form `<username>/<repo>` will be downloaded from GitHub.
|
||||
|
||||
```bash
|
||||
$ bun create ahfarmer/calculator ./myapp
|
||||
```
|
||||
|
||||
Complete GitHub URLs will also work:
|
||||
|
||||
```bash
|
||||
$ bun create github.com/ahfarmer/calculator ./myapp
|
||||
$ bun create https://github.com/ahfarmer/calculator ./myapp
|
||||
```
|
||||
|
||||
Bun installs the files as they currently exist current default branch (usually `main`). Unlike `git clone` it doesn't download the commit history or configure a remote.
|
||||
|
||||
## Local templates
|
||||
|
||||
{% callout %}
|
||||
**⚠️ Warning** — Unlike remote templates, running `bun create` with a local template will delete the entire destination folder if it already exists! Be careful.
|
||||
{% /callout %}
|
||||
Bun's templater can be extended to support custom templates defined on your local file system. These templates should live in one of the following directories:
|
||||
|
||||
- `$HOME/.bun-create/<name>`: global templates
|
||||
- `<project root>/.bun-create/<name>`: project-specific templates
|
||||
|
||||
{% callout %}
|
||||
**Note** — You can customize the global template path by setting the `BUN_CREATE_DIR` environment variable.
|
||||
{% /callout %}
|
||||
|
||||
To create a local template, navigate to `$HOME/.bun-create` and create a new directory with the desired name of your template.
|
||||
|
||||
```bash
|
||||
$ cd $HOME/.bun-create
|
||||
$ mkdir foo
|
||||
$ cd foo
|
||||
```
|
||||
|
||||
Then, create a `package.json` file in that directory with the following contents:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "foo"
|
||||
}
|
||||
```
|
||||
|
||||
You can run `bun create foo` elsewhere on your file system to verify that Bun is correctly finding your local template.
|
||||
|
||||
{% table %}
|
||||
|
||||
---
|
||||
|
||||
- `postinstall`
|
||||
- runs after installing dependencies
|
||||
|
||||
---
|
||||
|
||||
- `preinstall`
|
||||
- runs before installing dependencies
|
||||
|
||||
<!-- ---
|
||||
|
||||
- `start`
|
||||
- a command to auto-start the application -->
|
||||
|
||||
{% /table %}
|
||||
|
||||
Each of these can correspond to a string or array of strings. An array of commands will be executed in order. Here is an example:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "@bun-examples/simplereact",
|
||||
"version": "0.0.1",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2"
|
||||
},
|
||||
"bun-create": {
|
||||
"preinstall": "echo 'Installing...'", // a single command
|
||||
"postinstall": ["echo 'Done!'"], // an array of commands
|
||||
"start": "bun run echo 'Hello world!'"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
When cloning a template, `bun create` will automatically remove the `"bun-create"` section from `package.json` before writing it to the destination folder.
|
||||
|
||||
## Reference
|
||||
|
||||
### CLI flags
|
||||
|
||||
{% table %}
|
||||
|
||||
- Flag
|
||||
- Description
|
||||
|
||||
---
|
||||
|
||||
- `--force`
|
||||
- Overwrite existing files
|
||||
|
||||
---
|
||||
|
||||
- `--no-install`
|
||||
- Skip installing `node_modules` & tasks
|
||||
|
||||
---
|
||||
|
||||
- `--no-git`
|
||||
- Don’t initialize a git repository
|
||||
|
||||
---
|
||||
|
||||
- `--open`
|
||||
- Start & open in-browser after finish
|
||||
|
||||
{% /table %}
|
||||
|
||||
### Environment variables
|
||||
|
||||
{% table %}
|
||||
|
||||
- Name
|
||||
- Description
|
||||
|
||||
---
|
||||
|
||||
- `GITHUB_API_DOMAIN`
|
||||
- If you’re using a GitHub enterprise or a proxy, you can customize the GitHub domain Bun pings for downloads
|
||||
|
||||
---
|
||||
|
||||
- `GITHUB_API_TOKEN`
|
||||
- This lets `bun create` work with private repositories or if you get rate-limited
|
||||
|
||||
{% /table %}
|
||||
|
||||
{% details summary="How `bun create` works" %}
|
||||
|
||||
When you run `bun create ${template} ${destination}`, here’s what happens:
|
||||
|
||||
IF remote template
|
||||
|
||||
1. GET `registry.npmjs.org/@bun-examples/${template}/latest` and parse it
|
||||
2. GET `registry.npmjs.org/@bun-examples/${template}/-/${template}-${latestVersion}.tgz`
|
||||
3. Decompress & extract `${template}-${latestVersion}.tgz` into `${destination}`
|
||||
|
||||
- If there are files that would overwrite, warn and exit unless `--force` is passed
|
||||
|
||||
IF GitHub repo
|
||||
|
||||
1. Download the tarball from GitHub’s API
|
||||
2. Decompress & extract into `${destination}`
|
||||
|
||||
- If there are files that would overwrite, warn and exit unless `--force` is passed
|
||||
|
||||
ELSE IF local template
|
||||
|
||||
1. Open local template folder
|
||||
2. Delete destination directory recursively
|
||||
3. Copy files recursively using the fastest system calls available (on macOS `fcopyfile` and Linux, `copy_file_range`). Do not copy or traverse into `node_modules` folder if exists (this alone makes it faster than `cp`)
|
||||
|
||||
4. Parse the `package.json` (again!), update `name` to be `${basename(destination)}`, remove the `bun-create` section from the `package.json` and save the updated `package.json` to disk.
|
||||
- IF Next.js is detected, add `bun-framework-next` to the list of dependencies
|
||||
- IF Create React App is detected, add the entry point in /src/index.{js,jsx,ts,tsx} to `public/index.html`
|
||||
- IF Relay is detected, add `bun-macro-relay` so that Relay works
|
||||
5. Auto-detect the npm client, preferring `pnpm`, `yarn` (v1), and lastly `npm`
|
||||
6. Run any tasks defined in `"bun-create": { "preinstall" }` with the npm client
|
||||
7. Run `${npmClient} install` unless `--no-install` is passed OR no dependencies are in package.json
|
||||
8. Run any tasks defined in `"bun-create": { "preinstall" }` with the npm client
|
||||
9. Run `git init; git add -A .; git commit -am "Initial Commit";`
|
||||
|
||||
- Rename `gitignore` to `.gitignore`. NPM automatically removes `.gitignore` files from appearing in packages.
|
||||
- If there are dependencies, this runs in a separate thread concurrently while node_modules are being installed
|
||||
- Using libgit2 if available was tested and performed 3x slower in microbenchmarks
|
||||
|
||||
{% /details %}
|
||||
@@ -1,3 +1,27 @@
|
||||
Scaffold an empty Bun project with the interactive `bun init` command.
|
||||
|
||||
```bash
|
||||
$ bun init
|
||||
bun init helps you get started with a minimal project and tries to
|
||||
guess sensible defaults. Press ^C anytime to quit.
|
||||
|
||||
package name (quickstart):
|
||||
entry point (index.ts):
|
||||
|
||||
Done! A package.json file was saved in the current directory.
|
||||
+ index.ts
|
||||
+ .gitignore
|
||||
+ tsconfig.json (for editor auto-complete)
|
||||
+ README.md
|
||||
|
||||
To get started, run:
|
||||
bun run index.ts
|
||||
```
|
||||
|
||||
Press `enter` to accept the default answer for each prompt, or pass the `-y` flag to auto-accept the defaults.
|
||||
|
||||
{% details summary="How `bun init` works" %}
|
||||
|
||||
`bun init` is a quick way to start a blank project with Bun. It guesses with sane defaults and is non-destructive when run multiple times.
|
||||
|
||||

|
||||
@@ -13,8 +37,4 @@ 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.
|
||||
{% /details %}
|
||||
@@ -9,7 +9,7 @@ The `bun` CLI contains a Node.js-compatible package manager designed to be a dra
|
||||
{% /callout %}
|
||||
|
||||
{% details summary="For Linux users" %}
|
||||
The minimum Linux Kernel version is 5.1. If you're on Linux kernel 5.1 - 5.5, `bun install` should still work, but HTTP requests will be slow due to a lack of support for io_uring's `connect()` operation.
|
||||
The recommended minimum Linux Kernel version is 5.6. If you're on Linux kernel 5.1 - 5.5, `bun install` will work, but HTTP requests will be slow due to a lack of support for io_uring's `connect()` operation.
|
||||
|
||||
If you're using Ubuntu 20.04, here's how to install a [newer kernel](https://wiki.ubuntu.com/Kernel/LTSEnablementStack):
|
||||
|
||||
@@ -23,43 +23,19 @@ sudo apt install --install-recommends linux-generic-hwe-20.04
|
||||
|
||||
{% /details %}
|
||||
|
||||
## Manage dependencies
|
||||
|
||||
### `bun install`
|
||||
|
||||
To install all dependencies of a project:
|
||||
|
||||
```bash
|
||||
$ bun install
|
||||
```
|
||||
|
||||
On Linux, `bun install` tends to install packages 20-100x faster than `npm install`. On macOS, it's more like 4-80x.
|
||||
|
||||

|
||||
|
||||
Running `bun install` will:
|
||||
|
||||
- **Install** all `dependencies`, `devDependencies`, and `optionalDependencies`. Bun does not install `peerDependencies` by default.
|
||||
- **Install** all `dependencies`, `devDependencies`, and `optionalDependencies`. Bun will install `peerDependencies` by default.
|
||||
- **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`):
|
||||
|
||||
```bash
|
||||
$ bun install --production
|
||||
```
|
||||
|
||||
To install with reproducible dependencies, use `--frozen-lockfile`. If your `package.json` disagrees with `bun.lockb`, Bun will exit with an error. This is useful for production builds and CI environments.
|
||||
|
||||
```bash
|
||||
$ bun install --frozen-lockfile
|
||||
```
|
||||
|
||||
To perform a dry run (i.e. don't actually install anything):
|
||||
|
||||
```bash
|
||||
$ bun install --dry-run
|
||||
```
|
||||
## Logging
|
||||
|
||||
To modify logging verbosity:
|
||||
|
||||
@@ -68,86 +44,59 @@ $ bun install --verbose # debug logging
|
||||
$ bun install --silent # no logging
|
||||
```
|
||||
|
||||
{% details summary="Configuring behavior" %}
|
||||
The default behavior of `bun install` can be configured in `bun.toml`:
|
||||
## Lifecycle scripts
|
||||
|
||||
```toml
|
||||
[install]
|
||||
Unlike other npm clients, Bun does not execute arbitrary lifecycle scripts like `postinstall` for installed dependencies. Executing arbitrary scripts represents a potential security risk.
|
||||
|
||||
# whether to install optionalDependencies
|
||||
optional = true
|
||||
To tell Bun to allow lifecycle scripts for a particular package, add the package to `trustedDependencies` in your package.json.
|
||||
|
||||
# whether to install devDependencies
|
||||
dev = true
|
||||
|
||||
# whether to install peerDependencies
|
||||
peer = false
|
||||
|
||||
# equivalent to `--production` flag
|
||||
production = false
|
||||
|
||||
# equivalent to `--frozen-lockfile` flag
|
||||
frozenLockfile = false
|
||||
|
||||
# equivalent to `--dry-run` flag
|
||||
dryRun = false
|
||||
```json-diff
|
||||
{
|
||||
"name": "my-app",
|
||||
"version": "1.0.0",
|
||||
+ "trustedDependencies": ["my-trusted-package"]
|
||||
}
|
||||
```
|
||||
|
||||
{% /details %}
|
||||
Then re-install the package. Bun will read this field and run lifecycle scripts for `my-trusted-package`.
|
||||
|
||||
### `bun add`
|
||||
## Workspaces
|
||||
|
||||
To add a particular package:
|
||||
Bun supports `"workspaces"` in package.json. For complete documentation refer to [Package manager > Workspaces](/docs/install/workspaces).
|
||||
|
||||
```bash
|
||||
$ bun add preact
|
||||
```
|
||||
|
||||
To specify a version, version range, or tag:
|
||||
|
||||
```bash
|
||||
$ bun add zod@3.20.0
|
||||
$ bun add zod@^3.0.0
|
||||
$ bun add zod@latest
|
||||
```
|
||||
|
||||
To add a package as a dev dependency (`"devDependencies"`):
|
||||
|
||||
```bash
|
||||
$ bun add --dev @types/react
|
||||
$ bun add -d @types/react
|
||||
```
|
||||
|
||||
To add a package as an optional dependency (`"optionalDependencies"`):
|
||||
|
||||
```bash
|
||||
$ bun add --optional lodash
|
||||
```
|
||||
|
||||
To add a package and pin to the resolved version, use `--exact`. This will resolve the version of the package and add it to your `package.json` with an exact version number instead of a version range.
|
||||
|
||||
```bash
|
||||
$ bun add react --exact
|
||||
```
|
||||
|
||||
This will add the following to your `package.json`:
|
||||
|
||||
```jsonc
|
||||
```json#package.json
|
||||
{
|
||||
"name": "my-app",
|
||||
"version": "1.0.0",
|
||||
"workspaces": ["packages/*"],
|
||||
"dependencies": {
|
||||
// without --exact
|
||||
"react": "^18.2.0", // this matches >= 18.2.0 < 19.0.0
|
||||
|
||||
// with --exact
|
||||
"react": "18.2.0" // this matches only 18.2.0 exactly
|
||||
"preact": "^10.5.13"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
To install a package globally:
|
||||
## Overrides and resolutions
|
||||
|
||||
Bun supports npm's `"overrides"` and Yarn's `"resolutions"` in `package.json`. These are mechanisms for specifying a version range for _metadependencies_—the dependencies of your dependencies. Refer to [Package manager > Overrides and resolutions](/docs/install/overrides) for complete documentation.
|
||||
|
||||
```json-diff#package.json
|
||||
{
|
||||
"name": "my-app",
|
||||
"dependencies": {
|
||||
"foo": "^2.0.0"
|
||||
},
|
||||
+ "overrides": {
|
||||
+ "bar": "~4.4.0"
|
||||
+ }
|
||||
}
|
||||
```
|
||||
|
||||
## Global packages
|
||||
|
||||
To install a package globally, use the `-g`/`--global` flag. Typically this is used for installing command-line tools.
|
||||
|
||||
```bash
|
||||
$ bun add --global cowsay # or `bun add -g cowsay`
|
||||
$ bun install --global cowsay # or `bun install -g cowsay`
|
||||
$ cowsay "Bun!"
|
||||
______
|
||||
< Bun! >
|
||||
@@ -159,149 +108,75 @@ $ cowsay "Bun!"
|
||||
|| ||
|
||||
```
|
||||
|
||||
{% details summary="Configuring global installation behavior" %}
|
||||
## Production mode
|
||||
|
||||
```toml
|
||||
[install]
|
||||
# where `bun install --global` installs packages
|
||||
globalDir = "~/.bun/install/global"
|
||||
|
||||
# where globally-installed package bins are linked
|
||||
globalBinDir = "~/.bun/bin"
|
||||
```
|
||||
|
||||
{% /details %}
|
||||
To view a complete list of options for a given command:
|
||||
To install in production mode (i.e. without `devDependencies` or `optionalDependencies`):
|
||||
|
||||
```bash
|
||||
$ bun add --help
|
||||
$ bun install --production
|
||||
```
|
||||
|
||||
### `bun remove`
|
||||
|
||||
To remove a dependency:
|
||||
For reproducible installs, use `--frozen-lockfile`. This will install the exact versions of each package specified in the lockfile. If your `package.json` disagrees with `bun.lockb`, Bun will exit with an error. The lockfile will not be updated.
|
||||
|
||||
```bash
|
||||
$ bun remove preact
|
||||
$ bun install --frozen-lockfile
|
||||
```
|
||||
|
||||
## Local packages (`bun link`)
|
||||
For more information on Bun's binary lockfile `bun.lockb`, refer to [Package manager > Lockfile](/docs/install/lockfile).
|
||||
|
||||
Use `bun link` in a local directory to register the current package as a "linkable" package.
|
||||
## Dry run
|
||||
|
||||
To perform a dry run (i.e. don't actually install anything):
|
||||
|
||||
```bash
|
||||
$ cd /path/to/cool-pkg
|
||||
$ cat package.json
|
||||
{
|
||||
"name": "cool-pkg",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
$ bun link
|
||||
bun link v0.5.7 (7416672e)
|
||||
Success! Registered "cool-pkg"
|
||||
|
||||
To use cool-pkg in a project, run:
|
||||
bun link cool-pkg
|
||||
|
||||
Or add it in dependencies in your package.json file:
|
||||
"cool-pkg": "link:cool-pkg"
|
||||
$ bun install --dry-run
|
||||
```
|
||||
|
||||
This package can now be "linked" into other projects using `bun link cool-pkg`. This will create a symlink in the `node_modules` directory of the target project, pointing to the local directory.
|
||||
## Non-npm dependencies
|
||||
|
||||
```bash
|
||||
$ cd /path/to/my-app
|
||||
$ bun link cool-pkg
|
||||
```
|
||||
Bun supports installing dependencies from Git, GitHub, and local or remotely-hosted tarballs. For complete documentation refer to [Package manager > Git, GitHub, and tarball dependencies](/docs/cli/add).
|
||||
|
||||
In addition, the `--save` flag can be used to add `cool-pkg` to the `dependencies` field of your app's package.json with a special version specifier that tells Bun to load from the registered local directory instead of installing from `npm`:
|
||||
|
||||
```json-diff
|
||||
{
|
||||
"name": "my-app",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
+ "cool-pkg": "link:cool-pkg"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Trusted dependencies
|
||||
|
||||
Unlike other npm clients, Bun does not execute arbitrary lifecycle scripts for installed dependencies, such as `postinstall`. These scripts represent a potential security risk, as they can execute arbitrary code on your machine.
|
||||
|
||||
<!-- 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. -->
|
||||
|
||||
To tell Bun to allow lifecycle scripts for a particular package, add the package to `trustedDependencies` in your package.json.
|
||||
|
||||
<!-- ```json-diff
|
||||
{
|
||||
"name": "my-app",
|
||||
"version": "1.0.0",
|
||||
+ "trustedDependencies": {
|
||||
+ "my-trusted-package": "*"
|
||||
+ }
|
||||
}
|
||||
``` -->
|
||||
|
||||
```json-diff
|
||||
{
|
||||
"name": "my-app",
|
||||
"version": "1.0.0",
|
||||
+ "trustedDependencies": ["my-trusted-package"]
|
||||
}
|
||||
```
|
||||
|
||||
Bun reads this field and will run lifecycle scripts for `my-trusted-package`.
|
||||
|
||||
<!-- If you specify a version range, Bun will only execute lifecycle scripts if the resolved package version matches the range. -->
|
||||
<!--
|
||||
```json
|
||||
{
|
||||
"name": "my-app",
|
||||
"version": "1.0.0",
|
||||
"trustedDependencies": {
|
||||
"my-trusted-package": "^1.0.0"
|
||||
}
|
||||
}
|
||||
``` -->
|
||||
|
||||
## Git dependencies
|
||||
|
||||
To add a dependency from a git repository:
|
||||
|
||||
```bash
|
||||
$ bun install git@github.com:moment/moment.git
|
||||
```
|
||||
|
||||
Bun supports a variety of protocols, including [`github`](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#github-urls), [`git`](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#git-urls-as-dependencies), `git+ssh`, `git+https`, and many more.
|
||||
|
||||
```json
|
||||
```json#package.json
|
||||
{
|
||||
"dependencies": {
|
||||
"dayjs": "git+https://github.com/iamkun/dayjs.git",
|
||||
"lodash": "git+ssh://github.com/lodash/lodash.git#4.17.21",
|
||||
"moment": "git@github.com:moment/moment.git",
|
||||
"zod": "github:colinhacks/zod"
|
||||
"zod": "github:colinhacks/zod",
|
||||
"react": "https://registry.npmjs.org/react/-/react-18.2.0.tgz"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Tarball dependencies
|
||||
## Configuration
|
||||
|
||||
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.
|
||||
The default behavior of `bun install` can be configured in `bunfig.toml`. The default values are shown below.
|
||||
|
||||
```json#package.json
|
||||
{
|
||||
"dependencies": {
|
||||
"zod": "https://registry.npmjs.org/zod/-/zod-3.21.4.tgz"
|
||||
}
|
||||
}
|
||||
```toml
|
||||
[install]
|
||||
|
||||
# whether to install optionalDependencies
|
||||
optional = true
|
||||
|
||||
# whether to install devDependencies
|
||||
dev = true
|
||||
|
||||
# whether to install peerDependencies
|
||||
peer = true
|
||||
|
||||
# equivalent to `--production` flag
|
||||
production = false
|
||||
|
||||
# equivalent to `--frozen-lockfile` flag
|
||||
frozenLockfile = false
|
||||
|
||||
# equivalent to `--dry-run` flag
|
||||
dryRun = false
|
||||
```
|
||||
|
||||
## CI/CD
|
||||
|
||||
Looking to speed up your CI? Use the official `oven-sh/setup-bun` action to install `bun` in a GitHub Actions pipeline.
|
||||
Looking to speed up your CI? Use the official [`oven-sh/setup-bun`](https://github.com/oven-sh/setup-bun) action to install `bun` in a GitHub Actions pipeline.
|
||||
|
||||
```yaml#.github/workflows/release.yml
|
||||
name: bun-types
|
||||
|
||||
46
docs/cli/link.md
Normal file
46
docs/cli/link.md
Normal file
@@ -0,0 +1,46 @@
|
||||
Use `bun link` in a local directory to register the current package as a "linkable" package.
|
||||
|
||||
```bash
|
||||
$ cd /path/to/cool-pkg
|
||||
$ cat package.json
|
||||
{
|
||||
"name": "cool-pkg",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
$ bun link
|
||||
bun link v1.x (7416672e)
|
||||
Success! Registered "cool-pkg"
|
||||
|
||||
To use cool-pkg in a project, run:
|
||||
bun link cool-pkg
|
||||
|
||||
Or add it in dependencies in your package.json file:
|
||||
"cool-pkg": "link:cool-pkg"
|
||||
```
|
||||
|
||||
This package can now be "linked" into other projects using `bun link cool-pkg`. This will create a symlink in the `node_modules` directory of the target project, pointing to the local directory.
|
||||
|
||||
```bash
|
||||
$ cd /path/to/my-app
|
||||
$ bun link cool-pkg
|
||||
```
|
||||
|
||||
In addition, the `--save` flag can be used to add `cool-pkg` to the `dependencies` field of your app's package.json with a special version specifier that tells Bun to load from the registered local directory instead of installing from `npm`:
|
||||
|
||||
```json-diff
|
||||
{
|
||||
"name": "my-app",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
+ "cool-pkg": "link:cool-pkg"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
To _unregister_ a local package, navigate to the package's root directory and run `bun unlink`.
|
||||
|
||||
```bash
|
||||
$ cd /path/to/cool-pkg
|
||||
$ bun unlink
|
||||
bun unlink v1.x (7416672e)
|
||||
```
|
||||
5
docs/cli/remove.md
Normal file
5
docs/cli/remove.md
Normal file
@@ -0,0 +1,5 @@
|
||||
To remove a dependency:
|
||||
|
||||
```bash
|
||||
$ bun remove ts-node
|
||||
```
|
||||
@@ -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
|
||||
|
||||
|
||||
17
docs/cli/update.md
Normal file
17
docs/cli/update.md
Normal file
@@ -0,0 +1,17 @@
|
||||
To update all dependencies to the latest version _that's compatible with the version range specified in your `package.json`_:
|
||||
|
||||
```sh
|
||||
$ bun update
|
||||
```
|
||||
|
||||
## `--force`
|
||||
|
||||
{% callout %}
|
||||
**Alias** — `-f`
|
||||
{% /callout %}
|
||||
|
||||
Bun by default respect the version rages defined in your package.json, to ignore this and update to the latest version you can pass in the `force` flag.
|
||||
|
||||
```sh
|
||||
$ bun update --force
|
||||
```
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user