Compare commits

...

314 Commits

Author SHA1 Message Date
Jarred Sumner
c2ebd014fb Uncomment some of the tests 2023-10-23 02:32:08 -07:00
Jarred Sumner
1a0974693b Merge branch 'main' into jarred/postgresql 2023-10-22 19:29:54 -07:00
Ai Hoshino
8e1eae7dae fix(node:buffer): fix Buffer.write stuck (#6651) 2023-10-22 19:28:52 -07:00
Jarred Sumner
d92f3b6610 Dump as json 2023-10-22 19:28:52 -07:00
Jarred Sumner
e523dd1fc0 Add require builtins snippet 2023-10-22 19:28:52 -07:00
Dylan Conway
7dbe01b822 fix bun link in workspace package (#6631)
* link workspace package

* add test

* more complete test
2023-10-22 19:28:52 -07:00
Jarred Sumner
fafd9368f5 Backport uWS & usockets changes (#6649)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-10-22 13:44:08 -07:00
Ai Hoshino
1836ecd2ed fix(node:buffer): fix Buffer.write stuck (#6651) 2023-10-22 13:42:05 -07:00
Jarred Sumner
c900d08bea Add log 2023-10-22 00:29:51 -07:00
Jarred Sumner
ff7881f2ea Don't rely on argument count 2023-10-22 00:29:38 -07:00
Jarred Sumner
d2899f1367 Backport uWS & usockets changes 2023-10-22 00:28:19 -07:00
Jarred Sumner
d1a7feef0a Fix issue with postgres in large query response and fix crash 2023-10-21 21:00:41 -07:00
Jarred Sumner
4cdaabd433 Dump as json 2023-10-21 16:27:11 -07:00
Jarred Sumner
4a74a46780 Add require builtins snippet 2023-10-21 16:18:18 -07:00
Jarred Sumner
8f1606adf0 Merge branch 'main' into jarred/postgresql 2023-10-21 15:22:52 -07:00
Dylan Conway
b62c010e95 fix bun link in workspace package (#6631)
* link workspace package

* add test

* more complete test
2023-10-20 22:38:46 -07:00
Pedro Nogueira
074534b292 revert: back the test/README.md file (#6626)
Co-authored-by: pedromdsn <pedromdsn@hotmail.com>
2023-10-20 16:38:06 -07:00
Dylan Conway
b0393fba62 Update InternalModuleRegistryConstants.h 2023-10-20 14:15:05 -07:00
Dmitry Nourell
7166fe10b5 Fixes IV calculation for AES-GCM mode (#6590)
* fix(crypto): fix the error in IV calculation for AES-GCM mode

* chore(crypto): add basic unit tests for Cipher & Decipher
2023-10-20 14:01:58 -07:00
chandi Langecker
2890ad53c4 fix(napi): incorrect refCount with napi_wrap() (#6598)
while trying to get [`node-usb`](https://github.com/node-usb/node-usb) running with bun, it always failed because close() is only allowed when there are no open references.

7e0182df8c/src/node_usb.h (L39-L41)
```c++
    inline void ref(){ refs_ = Ref();}
    inline void unref(){ refs_ = Unref();}
    inline bool canClose(){return refs_ == 0;}
```

`Ref()` and `Unref()` are both called once, with node.js resulting in `refs_ == 0` (which is expected), but with bun `refs_ == 1`.

I've made this small script to reproduce the bug:
https://github.com/alangecker/bun-ref-bug/blob/main/binding.cc
```
run with bun 1.0.6:
 - refcount: 2 (expected: 1)
run with node 20.8.1:
 - refcount: 1 (expected: 1)
```

during a long debugging journey I found out, that buns `NapiRef::ref()` is also just called once (as expected), but within `napi_wrap()` the `NapiRef` gets initialized already with the refCount set to 1

378385ba60/src/bun.js/bindings/napi.cpp (L669)
```c++
extern "C" napi_status napi_wrap(napi_env env,
    napi_value js_object,
    void* native_object,
    napi_finalize finalize_cb,
    void* finalize_hint,
    napi_ref* result)
{
    // [...]
    auto* ref = new NapiRef(globalObject, 1);
    // [...]
}
```

After changing it to `new NapiRef(globalObject, 0)` it got the expected behavior / same as with node.js and node-usb works.
as far as I understand it, a `NapiRef`` with refCount=0 should then be weak instead of strong, which is why I have changed this too.
2023-10-20 13:02:35 -07:00
Paula Burghelea
01e3474600 Update quickstart.md - removed the part for editing compilerOptions… (#6620)
* Update quickstart.md - removed the part for editing `compilerOptions` in `tsconfig.json`

The line is already added to `compilerOptions` in `tsconfig.json` so there is no need to edit the file.

    "types": [
      "bun-types" // add Bun global
    ]

This was already added when the project initialized it seems.

* Typescript section

---------

Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-10-20 11:26:19 -07:00
Jarred Sumner
756eee087a Sort list of dependencies and fix test (#6616)
* fix findBestMatch so it finds the best match and not the first match

* update complex-workspaces to include lines-and-columns ^1.1.6

* PR feedback

* PR feedback

* This test doesn't reproduce the original issue

* Support pre release versions the same way

* Add a test that reproduces the original issue

* Sort the list of package versions before serializing to disk

* Remove test that didnt reproduce it

* Fix the count

* Fix 0 and 1 and sorting order

* Fix assertions and ordering

---------

Co-authored-by: Dylan Greene <dgreene@medallia.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-10-20 03:55:40 -07:00
Dylan Conway
4b2cdc4fc1 respect optional peer dependencies and update docs (#6615)
* update docs

* optional peer dependencies

* rename offset variable name, cache invalidation time

* Update install.zig

* install more peer dependencies
2023-10-20 03:27:10 -07:00
Dylan Greene
184528e4eb fix findBestMatch so it finds the best match and not the first match (#6611)
* fix findBestMatch so it finds the best match and not the first match

* update complex-workspaces to include lines-and-columns ^1.1.6

* PR feedback

* PR feedback
2023-10-20 02:18:37 -07:00
Jarred Sumner
8cf7d6157a Fix missing function names in console.log and Bun.inspect (#6612)
* Fix missing function names in Bun.inspect

* Fix failing tests

* Handle @@toStringTag

* Update bindings.cpp

* Revert breaking changes to snapshots until a minor version

* Fix test

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-10-19 22:38:05 -07:00
Vladimir Vlach
68324daf78 String response for lambda function - no need to strinfigy string (#6208) 2023-10-19 22:27:36 -07:00
Liz
66debb1ce4 fix: support custom file type in Bun.file (#6512)
* fix: support custom file type in Bun.file

In the docs it seamed to suggest this is something supported,
it seamed to be only supported in JSDOMFiles or blob.
This Adds the 2 properties `type` and `lastModified` to be supported on `Bun.file`

Fixes: https://github.com/oven-sh/bun/issues/6507

* fix: implement changes requested in review

Add changes requested in the review and add a test for a non standard
mimetype
2023-10-19 22:26:27 -07:00
Ashcon Partovi
d5d9fc4684 Fix websocket upgrade (#6564)
* Remove ancient changelog

* Fix `Host` header excluding port in WebSocket upgrade

* `byteSlice()`

* Revert `byteSlice()`
2023-10-19 22:24:45 -07:00
Liz
f6b694ee2c fix(install): dont replace git urls when already present (#6607)
* fix: dont replace git urls when already present

* fix: set request e_string

* test: add test for git url duplication
2023-10-19 21:28:59 -07:00
Dylan Conway
bb623196a3 fix install add (#6609)
* fix add package

* update test

* initWithCLI once

* skip searching for workspaces if package json was created
2023-10-19 19:17:38 -07:00
nygma
e9948f1291 Add append content to a file guide (#6581)
* Add append content guide

Resolve #6559

* Update guide

---------

Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-10-19 17:29:31 -07:00
Jarred Sumner
378385ba60 Bump Zig 2023-10-19 00:19:21 -07:00
Jarred Sumner
8d0ebfbc95 doesnt fix it 2023-10-18 23:50:11 -07:00
Jarred Sumner
e2198b95ef try some things 2023-10-18 21:23:29 -07:00
Jarred Sumner
0cb4e9919b Merge branch 'main' into jarred/postgresql 2023-10-18 17:51:05 -07:00
Jarred Sumner
84336eef30 wip 2023-10-18 17:48:03 -07:00
Ai Hoshino
ef5930e8bc fix(serve): When IPv6 is not enabled, attempt to bind to IPv4 address under the same hostname. (#6533)
* fix(serve): When IPv6 configuration is incorrect, attempt to bind to IPv4 address under the same hostname.
Close: #5315

* fix review

* fix review again

---------

Co-authored-by: Ashcon Partovi <ashcon@partovi.net>
Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
2023-10-18 17:40:26 -07:00
Jarred Sumner
b7b773398a wip 2023-10-18 15:03:24 -07:00
Ai Hoshino
0173571b19 fix(node:buffer): fix the behavior of totalLength in Buffer.concat (#6574)
* fix(node:buffer): fix the behavior of `totalLength` in `Buffer.concat`
Close: #6570
Close: #3639

* fix buffer totalLength type

---------

Co-authored-by: Ashcon Partovi <ashcon@partovi.net>
2023-10-18 14:30:53 -07:00
Dawid Sowa
35259c0c1d fix: change --no-scripts to --ignore-scripts (#6587) 2023-10-18 14:00:04 -07:00
Mountain/\Ash
e7cba822e4 fix: online docs moved (#6579) 2023-10-18 12:57:46 -07:00
Kevin Latka
0d34e7a141 Fix minimum kernel version in docs (#6153)
* Fix minimum kernel version in docs

* Update install.md

* Update install.md

* Update install.md

---------

Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-10-18 11:49:09 -07:00
Dylan Conway
aedc8c0ead build-id++ 2023-10-18 11:02:44 -07:00
Liz
9c0cd5c030 fix(web): stub performance.getEntriesByName (#6542) 2023-10-18 10:04:45 -07:00
Dylan Conway
2f10398c74 update root package variable 2023-10-17 23:10:10 -07:00
Jarred Sumner
83c5461461 JSC.Weak 2023-10-17 21:24:32 -07:00
Jarred Sumner
55fb29667a Add JSC.Weak 2023-10-17 21:24:20 -07:00
Ashcon Partovi
49ef5bccec Fix missing {port: 0} causing flaky test 2023-10-17 21:23:13 -07:00
Dylan Conway
dcbcf9803a test changes in usockets in ci 2023-10-17 19:38:13 -07:00
Pierre CM
e731eff382 fix #4766 (#6563) 2023-10-17 16:56:27 -07:00
Dylan Conway
a57d7ecb5b Update ZigGeneratedClasses.cpp 2023-10-17 16:46:31 -07:00
Dylan Conway
d187563d36 use npm alias in dependencies (#6545)
* aliased package in dependencies

* other buf

* make sure version works

* make sure overrides don't override alias

* tests

* update

* comments
2023-10-17 16:34:03 -07:00
Ai Hoshino
e91436e524 fix(node:http): fix server.address() (#6442)
Closes #6413, #5850
2023-10-17 13:18:14 -07:00
Aral Roca Gomez
bbc2e96090 docs: fix ws.publish (#6558)
In this example there is no server variable in the context, and here it makes more sense to use ws.publish. It is explained below that once the serve is done, the server.publish can be used.
2023-10-17 09:23:10 -07:00
Mikhail
f53eb7cd59 perf(bun-types): remove needless some call (#6550) 2023-10-17 08:59:05 -07:00
dave caruso
98d19fa624 fix(runtime): make some things more stable (partial jsc debug build) (#5881)
* make our debug assertions work

* install bun-webkit-debug

* more progress

* ok

* progress...

* more debug build stuff

* ok

* a

* asdfghjkl

* fix(runtime): fix bad assertion failure in JSBufferList

* ok

* stuff

* upgrade webkit

* Update src/bun.js/bindings/JSDOMWrapperCache.h

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>

* fix message for colin's changes

* okay

* fix cjs prototype

* implement mainModule

* i think this fixes it all

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-10-16 21:22:43 -07:00
dave caruso
a3958190e8 fix(runtime): improve IPC reliability + organization pass on that code (#6475)
* dfghj

* Handle messages that did not finish

* tidy

* ok

* a

* Merge remote-tracking branch 'origin/main' into dave/ipc-fixes

* test failures

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-10-16 20:01:24 -07:00
Mikhail
6504bfef74 Simplify getting Set of extentions (#4975) 2023-10-16 17:16:10 -07:00
Ashcon Partovi
220cb0eb94 Fix formatting 2023-10-16 17:11:04 -07:00
Igor Shapiro
01e04e3341 fix(test): when tests run with --only the nested describe blocks `.on… (#5616) 2023-10-16 16:33:02 -07:00
Yannik Schröder
0853e19f53 perf(node:events): optimize emit(...) function (#5485) 2023-10-16 16:18:40 -07:00
Liz
a9b8e3ecc8 fix: don't remove content-encoding header from header table (#5743)
Closes #5668
2023-10-16 16:11:44 -07:00
Hugo Galan
bec6161dce fix(sqlite) Insert .all() does not return an array #5872 (#5946)
* fixing #5872

* removing useless comment
2023-10-16 16:08:58 -07:00
Ashcon Partovi
8c580e6764 Fix formatting 2023-10-16 16:02:11 -07:00
Chris Toshok
c5354951ba Fix Response.statusText (#6151) 2023-10-16 15:57:16 -07:00
Nicolae-Rares Ailincai
f1658e2e58 fix-subprocess-argument-missing (#6407)
* fix-subprocess-argument-missing

* fix-tests

* nitpick, these should === not just be undefined

---------

Co-authored-by: dave caruso <me@paperdave.net>
2023-10-16 15:31:14 -07:00
Voldemat
90d7f33522 Add type parameter to expect (#6128) 2023-10-16 15:24:56 -07:00
Jérôme Benoit
d9c0273421 fix(node:worker_threads): ensure threadId property is exposed on worker_threads instance (#6521)
* fix: ensure threadId property is exposed on worker_threads instance

Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>

* fix: rename lazy worker_threads module properties

Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>

* fix: add getter for threadId

Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>

* test: improve worker_threads UTs

Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>

* test: fix lazy loading

Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>

* test: fix worker_threads test

Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>

* fix: return the worker threadId

Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>

* test: refine worker_threads expectation on threadId

Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>

---------

Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
2023-10-16 15:19:38 -07:00
Ashcon Partovi
d65b1fd80b Fix use before define bug in sqlite
Fixes #6481
2023-10-16 15:14:15 -07:00
João Alisson
7becb5ec74 fix(jest): fix toStrictEqual on same URLs (#6528)
Fixes #6492
2023-10-16 15:14:15 -07:00
Ashcon Partovi
c3f5baa091 Fix toHaveBeenCalled having wrong error signature
Fixes #6527
2023-10-16 15:14:15 -07:00
Ashcon Partovi
800ad150ff Fix formatting 2023-10-16 15:14:15 -07:00
Ashcon Partovi
5608e59270 Add reusePort to Bun.serve types 2023-10-16 15:14:15 -07:00
Ashcon Partovi
e31ed84b1b Fix request.url having incorrect port
Fixes #6443
2023-10-16 15:14:15 -07:00
Ashcon Partovi
548b1d02f2 Remove uWebSockets header from Bun.serve responses 2023-10-16 15:14:15 -07:00
Ashcon Partovi
f63955a01f Rename some tests 2023-10-16 15:14:15 -07:00
Ashcon Partovi
2996ef7156 Fix #6467 2023-10-16 15:14:15 -07:00
Dylan Conway
2b1f3438e6 Update InternalModuleRegistryConstants.h 2023-10-16 14:21:39 -07:00
Colin McDonnell
2a8f3a3b4e Development -> Contributing (#6538)
Co-authored-by: Colin McDonnell <colin@KennyM1.local>
2023-10-16 16:11:03 -04:00
Jarred Sumner
b8175ac13d more microtasks 2023-10-15 20:41:26 -07:00
Jarred Sumner
9b6c84ef1e It's starting to work 2023-10-15 19:41:54 -07:00
Jarred Sumner
d26756e153 Things can happen 2023-10-15 17:52:46 -07:00
Jarred Sumner
ab035d6e82 Further 2023-10-15 04:56:05 -07:00
Jarred Sumner
ad7e90ae1b The startup message sends successfully 2023-10-15 04:23:19 -07:00
Jarred Sumner
c508640e2c it compiled 2023-10-15 03:13:30 -07:00
Jarred Sumner
0a149bdbbb okay we are starting to try it 2023-10-15 02:05:35 -07:00
Jarred Sumner
93a7c97e94 Okay most of the code is written 2023-10-15 01:48:55 -07:00
Jarred Sumner
ae881b14e9 More 2023-10-14 19:19:50 -07:00
Jarred Sumner
802a6731d5 wip 2023-10-14 16:24:59 -07:00
Ciro Spaciari
a87aa2fafe fix(net/tls) fix pg hang on end + hanging on query (#6487)
* fix pg hang on end + hanging on query

* remove dummy function

* fix node-stream

* add test

* fix test

* return error in test

* fix test use once instead of on

* fix OOM

* generated

* 💅

* 💅
2023-10-14 16:16:49 -07:00
Jarred Sumner
7f5eddc096 More progress 2023-10-14 03:06:21 -07:00
Dylan Conway
9b5e66453b fix installing dependencies that match workspace versions (#6494)
* check if dependency matches workspace version

* test

* Update lockfile.zig

* set resolution to workspace package id
2023-10-13 20:37:48 -07:00
Dylan Conway
46f978838d fix lockfile struct padding (#6495)
* integrity padding

* error message for bytes at end of struct
2023-10-13 20:37:06 -07:00
Jarred Sumner
9bc76f6628 wip 2023-10-13 18:08:24 -07:00
Jarred Sumner
0a6ef179f8 Create postgres.classes.ts 2023-10-13 18:08:23 -07:00
Jarred Sumner
71ddfcf7c1 Introduce bun:sql 2023-10-13 18:08:23 -07:00
Jarred Sumner
3809d8f5a0 Rename more 2023-10-13 18:08:03 -07:00
Jarred Sumner
d1855492de Rename JSSQLStatement to JSSQLiteStatement 2023-10-13 18:08:03 -07:00
Jarred Sumner
40579bb3af Add way to parse dates 2023-10-13 18:08:03 -07:00
Jarred Sumner
847fc70a42 Add abstraction for usockets 2023-10-13 18:08:03 -07:00
Jarred Sumner
de0ff15ef4 Implement much of the PostgresSQL wire protocol 2023-10-13 18:08:03 -07:00
Nicolae-Rares Ailincai
21576589c6 Guide to containerize a bun application using Docker (#6478)
* docker.md

* use-debian

* Updates

---------

Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-10-13 18:03:32 -07:00
Jarred Sumner
d7062eb367 [node:dns] Fix unnecessary array creation + prettier 2023-10-13 17:57:43 -07:00
João Alisson
851dc9aadc fix(node): dns lookup deprecated behavior (#6391)
Co-authored-by: alisson <alisson@Ubuntu.myguest.virtualbox.org>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-10-13 17:52:57 -07:00
Ai Hoshino
d08e112d41 fix(error): correct the path field in syscall error message. (#6370)
* fix(error): correct the `path` field in syscall error message.
Close: #6336

* fix pathlike union case
2023-10-13 17:51:36 -07:00
Ashcon Partovi
77d7e47019 Fix dns.lookup returning wrong address for family (#6474)
* Fix #6452

* Fix formatting
2023-10-13 17:47:05 -07:00
Dylan Conway
1bad64bc5e Update settings.json 2023-10-13 16:29:06 -07:00
Nicolae-Rares Ailincai
0794767291 Adds systemd guide to run a bun application as a daemon (#6451)
* systemd-guide

* remove-root-from-example

* add-more-description

* Updates

* Updates

* Updates

* Update

---------

Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-10-13 11:14:57 -07:00
Clay Curry
d7c8a58453 fix obvious typo in CONTRIBUTING.md (#6479)
Co-authored-by: Clay Curry <me@claycurry.com>
2023-10-13 09:33:44 -07:00
Colin McDonnell
4fab8fee21 Update descriptions 2023-10-12 23:19:53 -07:00
Colin McDonnell
3f2df4526e Fix links 2023-10-12 23:17:51 -07:00
Colin McDonnell
d6d4ead438 Tweaks to pm docs 2023-10-12 23:08:52 -07:00
Colin McDonnell
4e67862753 Add overrides/resolutions docs (#6476) 2023-10-12 23:05:20 -07:00
dave caruso
584e6dd1c2 Upgrade zig to 0.12.0-dev.888+130227491 (#6471)
* update build.zig

* save

* works?

* better workaround

* fix install

* Fix compiler crash
2023-10-12 19:38:33 -07:00
Dylan Conway
4bb753295d use a different package 2023-10-12 19:35:00 -07:00
Dylan Conway
892593c73b fix install test 2023-10-12 15:17:03 -07:00
Dylan Conway
691cf338c2 fix editing package json when adding github dependency (#6432)
* fix package name added to package json

* check for github tag

* remove alloc

* some tests

* fix test
2023-10-12 15:02:05 -07:00
Colin McDonnell
beb746e5ea Update installation.md 2023-10-12 14:12:53 -07:00
Colin McDonnell
89faee2522 Update installation.md 2023-10-12 13:43:45 -07:00
dave caruso
969da088f5 fix(install): re-evaluate overrides when removed 2023-10-12 02:03:02 -07:00
Luna
c50be68790 chore: add missing ending quote (#6436) 2023-10-12 01:00:27 -07:00
dave caruso
2fbb95142a feat(install): support npm overrides/yarn resolutions, one level deep only (#6435)
* disable zig fmt on generated ResolvedSourceTag.zig

* overrides

* it works

* ok

* a

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-10-12 00:44:15 -07:00
Dylan Conway
755e16d962 fix #6416 (#6430)
* make sure latest is checked after prerelease

* test and fix

* test for when latest matches prerelease
2023-10-11 20:41:12 -07:00
Jarred Sumner
b1063edf3e Bump WebKit 2023-10-11 20:04:15 -07:00
Jarred Sumner
edb4cbac2b Bump! 2023-10-11 19:05:52 -07:00
Dylan Conway
a59a69e21b Update JSCUSocketsLoopIntegration.cpp 2023-10-11 15:26:55 -07:00
Colin McDonnell
4c9e009971 Update installation.md 2023-10-11 14:31:39 -07:00
h2210316651
4531cf18c2 Docs : Added instructions to run bun apps in daemon (PM2) to address … (#5931)
* Docs : Added instructions to run bun apps in daemon (PM2) to address issue #4734

Added instructions to set bun as pm2 interpreter to extend same functionality as node.js apps.

* Add pm2 guide

* Add pm2 file

---------

Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-10-11 14:22:43 -07:00
Ashcon Partovi
31bda68f24 Update bun-release.yml 2023-10-11 12:05:16 -07:00
dave caruso
1bf28e0d77 feat(install): automatically migrate package-lock.json to bun.lockb (#6352)
* work so far

* stuff

* a

* basics work

* stuff

* yoo

* build lockfile

* correct

* f

* a

* install fixture havent tested

* i made it worse

* lol

* be more reasonable

* make the test easier to pass because bun install doesn't handle obscure lockfile edge cases :/

* a

* works now

* ok

* a

* a

* cool

* nah

* fix stuff

* l

* a

* idfk

* LAME

* prettier errors

* does this fix tests?

* Add more safety checks to Integrity

* Add another check

* More careful lifetime handling

* Fix linux debugger issue

* a

* tmp dir and snapshot test

---------

Co-authored-by: Jarred SUmner <jarred@jarredsumner.com>
2023-10-11 02:27:07 -07:00
Jarred Sumner
6a17ebe669 Update nodejs-apis.md 2023-10-11 01:59:56 -07:00
Arden Sinclair
39446ebdb8 Fix lifecycle scripts not running on reinstallation (#6376)
* Include trusted dependencies in lockfile

* Add a remote dependency to lifecycle script test
2023-10-10 21:13:42 -07:00
Elad Bezalel
c2c3b0d4a9 feat(test): implement toEqualIgnoringWhitespace (#6293)
* feat(test): implement `toEqualIgnoringWhitespace`

* equality check in matcher & incorrect arg error
2023-10-10 20:27:19 -07:00
saurabh
9a90d90966 fix: form data content type (#6380)
* fix: form data content type

* fix: condition if no extension for file
2023-10-10 20:08:32 -07:00
Dylan Conway
05781dd91e make peer dependencies install by default (#6396)
* peer dependencies

* default true

* add test

* cleanup

* some tests

* skip peer deps if they are non optional

* remove debug print, fix build

* iterate peer dependencies
2023-10-10 20:05:58 -07:00
Aaron Dewes
a6a474a83f Add File to binary data TOC (#6025) 2023-10-10 16:47:35 -07:00
cyfung1031
44dd744f0a docs: rearranged cli/runtime related sections (#6275)
* docs: rearranged cli/runtime related sections

* docs: update README.md for the updated docs path

* Updates

* Rearrange

* Rearrange

* Add files

* readme

---------

Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-10-10 16:34:35 -07:00
Ashcon Partovi
df4ec8aaad Update inspector-protocol 2023-10-10 16:14:46 -07:00
Ashcon Partovi
0348b169d6 Update debug-adapter-protocol 2023-10-10 16:14:46 -07:00
Vasilis Themelis
54dbf3ba21 Add missing ws declarations (#6307) 2023-10-10 15:39:20 -07:00
Clément P
5f09a4dd0a Update vite.md (#6399)
remove outdated information
2023-10-10 15:36:28 -07:00
Nicolae-Rares Ailincai
e58e85cd5c Documentation for the IPC of Bun.spawn (#6400)
* doc/ipc.md

* update/spawn.md

* improved-documentation-and-added-send-type

* Updates

* Updates

---------

Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-10-10 15:35:05 -07:00
Ciro Spaciari
6301778a58 fix(AbortSignal/fetch) fix AbortSignal.timeout, fetch lock behavior and fetch errors (#6390)
* fix abort signal and fetch error

* fix fetch error and lock behavior
2023-10-09 19:56:48 -07:00
Ashcon Partovi
3667b93871 Fix npm tag for canary bun-types, again 2023-10-09 12:14:26 -07:00
otterDeveloper
0a8aab6b23 Add Fedora build instructions to development.md (#6359) 2023-10-09 11:52:16 -07:00
babar
6a73f2b1e7 added commands (#6314)
added commands to install unzip package and to check Linux kernel version
2023-10-09 11:51:41 -07:00
TPLJ
99a78f8540 Update README.md (#6291)
fixed some minor documentation.
2023-10-09 11:50:08 -07:00
Michael Di Prisco
8d4b296bd2 docs: fixing a couple typos (#6331) 2023-10-09 11:48:07 -07:00
Liz
a9e1792607 fix: support uint8 exit code range (#6303)
The exit code support is between 0-255 and not only in the signed positive range
(0-127).
Node.js does not seam to throw on a bigger integer and just wraps around,
but throwing a error is a good approach and makes the behaviour more defined.

This allows the range to be 0-255

Fixes: https://github.com/oven-sh/bun/issues/6284
2023-10-09 11:47:38 -07:00
2hu
0965e6ddfd Fix array variables preview in debugger (#6379) 2023-10-09 11:47:00 -07:00
Ciro Spaciari
35109160ca feat(KeyObject) (#5940)
* oops

* createSecretKey but weird error

* use the right prototype, do not add a function called export lol

* HMAC JWT export + base64 fix

* Fix Equals, Fix Get KeySize, add complete export RSA

* fix RSA export

* add EC exports

* X25519 and ED25519 export + fixes

* fix default exports

* better asymmetricKeyType

* fix private exports

* fix symmetricKeySize

* createPublicKey validations + refactor

* jwt + der fixes

* oopsies

* add PEM into createPublicKey

* cleanup

* WIP

* bunch of fixes

* public from private + private OKP

* encrypted keys fixes

* oops

* fix clear tls error, add some support to jwk and other formats on publicEncrypt/publicDecrypt

* more fixes and tests working

* more fixes more tests

* more clear hmac errors

* more tests and fixes

* add generateKeyPair

* more tests passing, some skips

* fix EC key from private

* fix OKP JWK

* nodejs ignores ext and key_ops on KeyObject.exports

* add EC sign verify test

* some fixes

* add crypto.generateKeyPairSync(type, options)

* more fixes and more tests

* fix hmac tests

* jsonwebtoken tests

* oops

* oops2

* generated files

* revert package.json

* vm tests

* todos instead of failues

* toBunString -> toString

* undo simdutf

* improvements

* unlikely

* cleanup

* cleanup 2

* oops

* move _generateKeyPairSync checks to native
2023-10-07 15:22:45 -07:00
Jarred Sumner
bb9933fa7e Exclude more files 2023-10-07 14:15:53 -07:00
Jarred Sumner
673f6fc634 Exclude more files 2023-10-07 14:14:42 -07:00
Jarred Sumner
09663a5558 Update settings.json 2023-10-07 14:11:39 -07:00
Jarred Sumner
66b15a8df6 Update settings.json 2023-10-07 14:10:54 -07:00
Dylan Conway
96aa9c0a38 fix a couple install tests 2023-10-06 22:06:28 -07:00
Dylan Conway
46736d5ecb format 2023-10-06 22:02:55 -07:00
Jarred Sumner
25cf4016d3 Fix memory leak in fetch() (#6350)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-10-06 20:14:44 -07:00
Silver
48635fd910 [types] allow onLoad plugin callbacks to return undefined (#6346)
Returning undefined simply falls through to the next plugin, or to the default loader.
This is defined by esbuild, and supported by Bun, but the types don't reflect it properly.
2023-10-06 19:22:38 -07:00
Paul Nodet
456d6be022 docs: file.stream() is not a promise (#6337) 2023-10-06 03:26:42 -07:00
Colin McDonnell
16cf1fe5f3 Generate compat docs (wip) 2023-10-05 17:19:33 -07:00
Ai Hoshino
e0e9bc16bf fix(serve): fix close_connection behaviour in endWithoutBody (#6315)
Close: #6031
2023-10-05 20:43:58 -03:00
Filip Skokan
30b8993edd WebCryptoAPI: remove JWK "EdDSA" alg checks (#6294) 2023-10-05 20:43:42 -03:00
Justin "J.R." Hill
5c37d5293c test(bun install): cover http(s) non-github case (#6190) 2023-10-05 16:12:07 -07:00
Colin McDonnell
323ae0f2a3 Update Node.js compat docs (#6282)
* Update nodejs-apis

* No commas

* Updates
2023-10-05 16:03:21 -07:00
Jake Boone
7ef4cd26ac Use singular nouns when appropriate on install messages (#2543)
* Use singular nouns when appropriate on install messages

* Fix one more pluralization

* Fix bun-add tests for "1 package installed"

* Fix bun install/remove/update tests for "1 package installed"
2023-10-05 15:59:02 -07:00
Dylan Conway
df1b0c4332 fix printing latest available version 2023-10-05 11:30:52 -07:00
Dylan Conway
4a2e1574e4 fix semver and repository host bugs (#6312)
* releases before prereleases

* handle different repo hosts

* remove log

* Update bun-install.test.ts

* test for `bun add`

* gitlab test

* use comptime hash map, another test case

* don't need length

* bump timeout, use tld

* infer git dependencies for https and ssh
2023-10-04 22:46:21 -07:00
Dylan Conway
5a315f4df0 fix another os test failure 2023-10-04 22:45:11 -07:00
Dylan Conway
f0a914ea8d fix os test failure 2023-10-04 22:27:28 -07:00
Dylan Conway
d4a458a95b generated 2023-10-04 21:40:02 -07:00
Jarred Sumner
5c8233515a Fix query property of url object (#6274)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-10-04 21:31:29 -07:00
Gavin John
c5c7934ebc Update preload documentation to make applicability to plugins more obvious (#6298) 2023-10-04 21:29:54 -07:00
Jarred Sumner
b0ffe68675 Create AbortSignal without JS (#6278)
* Create `AbortSignal` without JS

* Don't leak

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-10-04 21:29:35 -07:00
Colin McDonnell
5da79a8366 Closes #6309 (#6310) 2023-10-04 21:28:23 -07:00
Jarred Sumner
ff88510e5f Bump! 2023-10-04 21:19:33 -07:00
Colin McDonnell
df9461ecc5 Update tsconfigs 2023-10-03 23:16:55 -07:00
Dylan Conway
98e9e9b112 Upgrade webkit (#6277)
* `reportExtraMemoryAllocated` parameters changed

* bump webkit

* Update Dockerfile

* format
2023-10-03 19:56:33 -07:00
Ashcon Partovi
9308e1bf09 Support bun run --if-present (#6248)
* Support --if-present
Closes #5670

* More robust tests, handle more cases
2023-10-03 17:39:45 -07:00
Andrey Smirnov
aa8ccce952 compat: Buffer: allow optional positional arguments to be undefined (#4911)
* fix `Buffer` compat with Node.js: compare

* fix `Buffer` compat with Node.js: copy
2023-10-03 15:30:04 -07:00
Dylan Conway
ffe6bb0b7f fix decorator tests 2023-10-03 13:50:36 -07:00
Ai Hoshino
b7982ac131 fix(blob): Add the current offset to the new blob. (#6259)
Close: #6252
2023-10-03 12:03:57 -07:00
Ashcon Partovi
60e7ae9aee Remove old package 2023-10-03 12:02:28 -07:00
Ashcon Partovi
86e4f72f00 Fix permissions for Github Actions 2023-10-03 12:02:15 -07:00
axel escalada
0ca9a7889a Fix bunx command for github package #5974 (#6042)
* fix bunx command for github package

* refactor fmt package to use it when the path is seted

* use labeled block to assign const instead of use 'undefined'
2023-10-03 11:49:24 -07:00
WingLim
476fa4deda feat(encoding): support BOM detection with test passed (#6074) 2023-10-03 10:28:59 -07:00
JS Park
4f1710d2d6 docs: update typescript.md (#6222)
Fix inconsistent results from `bun init`.
2023-10-03 09:12:37 -07:00
John Beene
1acc8191f5 Docs: Update context.md (#6256)
Use token from cookies, not from ws.data
2023-10-03 09:11:52 -07:00
Mathias Wulff
0ee04261b9 Add license information to package.json (#6255) 2023-10-03 09:11:02 -07:00
Dylan Conway
745b6b94ee Store workspace package versions (#6258)
* Store workspace package versions in the lockfile

* more logging

* wip

* keep information from workspace name array and cache

* hash key

* remove cache, compare workspaces with initially loaded

* uncomment sort

* remove comments

* remove allocation

* package json

* test `bun add <package>` without workspace prefix

* Update test/cli/install/bun-install.test.ts

Co-authored-by: Markus Staab <maggus.staab@googlemail.com>

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Markus Staab <maggus.staab@googlemail.com>
2023-10-03 02:17:21 -07:00
Colin McDonnell
47651f321a Update ws example 2023-10-02 19:02:27 -07:00
Jarred Sumner
b444c0b98d Set fetch timeout to 5 minutes (#6217)
* Increase timeouts

* Update uws.zig

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-10-02 18:01:59 -07:00
Ashcon Partovi
15880308b7 Fix bun install reading Github API from wrong environment variable (#6247)
* Fix `bun install` reading Github API from wrong environment variable

* Update src/install/install.zig

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-10-02 18:00:17 -07:00
Jarred Sumner
89bb526e14 Warn at start when using AVX build of Bun without AVX support (#6242)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-10-02 17:59:38 -07:00
Colin McDonnell
63a00791fa Update development and document env var expansion 2023-10-02 17:52:29 -07:00
Cícero Santos
a6af1c89b9 Update development.md (#6221) 2023-10-02 15:18:55 -07:00
Colin McDonnell
08bf8b8ad1 Add Bun.TOML to types (#6161) 2023-10-02 15:18:29 -07:00
Colin McDonnell
0c3c57cc35 Add dns.reverse and dns.getServers to types 2023-10-02 14:11:55 -07:00
Ashcon Partovi
237a5ada47 Fix npm tag for canary bun-types 2023-10-02 13:56:14 -07:00
Corné Dorrestijn
0a2d490bf8 Added the fileExtensions field to file-system-router.md (#6231) 2023-10-02 02:42:17 -07:00
Jarred Sumner
ea956e58e9 more logging 2023-10-02 02:38:47 -07:00
Jarred Sumner
46b5069c40 Slightly reduce number of open file descriptors in bun install (#6219)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-10-01 16:55:05 -07:00
Ai Hoshino
f7618aba20 fix(node:process): fix return value of process.kill (#6207) 2023-10-01 12:55:38 -07:00
Jarred Sumner
e020ecec15 Fix bug causing "Connection Refused" errors (#6206)
* Loop through the return values of getaddrinfo

* Remove incorrect assertion

* Remove extra check

* Remove extra check

* Update bsd.c

* More consistent

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-30 22:59:42 -07:00
Jarred Sumner
8775d37559 Fix regression 2023-09-30 17:16:06 -07:00
Jarred Sumner
54d25b8f6b Update cp.test.ts 2023-09-30 17:09:27 -07:00
Jarred Sumner
960922bba9 Add title 2023-09-30 17:09:12 -07:00
Jarred Sumner
c21be13be4 tweak github actions (#6195)
* Discord comments

* better

* better

* actions

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-30 02:50:38 -07:00
Jarred Sumner
c0b758ad45 Bump 2023-09-29 23:44:57 -07:00
Jarred Sumner
d65fdb6035 Fix hang in bun install (#6192)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-29 20:45:51 -07:00
Jarred Sumner
a97847a494 Implement virtual module support in Bun.plugin (#6167)
* Add support for `build.module` in `Bun.plugin`

* Another test

* Update docs

* Update isBuiltinModule.cpp

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
2023-09-29 16:34:20 -07:00
dave caruso
eddb0078b5 fix(runtime): followup for server.requestIP (#6185)
* fix(runtime): followup for `server.requestIP`

* oops

* yeah

* sure

* Update src/deps/libuwsockets.cpp

* Update Dockerfile

* lol

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-29 16:17:54 -07:00
Liz
fa7d7bd1e4 fix: don't set default request method when creating a Request (#6154)
In the case of creating a Request with the parameters `(Request, object)`,
there was a bug that method and headers are set from the default created by
the init rather then the already present value from the request param.
This is because for a to me unknown reason the order in which the parameters
are processed is reversed.

This fixes that by adding a check which stops the defaults from being set,
unless they are explicitly passed.

Fixes: https://github.com/oven-sh/bun/issues/6144
2023-09-29 16:13:49 -07:00
dave caruso
72bdd380af add Socket.prototype; lol (#5945) 2023-09-29 15:42:06 -07:00
dave caruso
10bee33909 fix(resolver): support encoded file urls (#5766)
* start working on this

* it works now

* better implementation imo

* yippee

* more tests and better unrefing

* fix leak?
2023-09-29 14:58:39 -07:00
dave caruso
6afa78120a feat(runtime): implement server.requestIp + node:http socket.address() (#6165)
* [server] requestIp and AnyRequestContext
Changed Request.uws_request to the new AnyRequestContext. This
allows grabbing the IP from a Request. Unfinished.

* [server] basic `requestIp` implementation

Currently using uws's requestIpAsText, which always returns a ipv6
string. We should return a `SocketAddress` object to the user instead,
which will contain the formatted address string and what type it is.
We'll have to use requestIpAsBinary and parse that ourselves.

* TypeScript docs, use `bun.String`, return `undefined` instead of `null`
if we can't get the ip.

* binary address formatting

* uws getRemoteAddress binding

* remove dead code

* working

* final touches

* I will abide by the results of this poll.

---------

Co-authored-by: Parzival-3141 <29632054+Parzival-3141@users.noreply.github.com>
2023-09-29 03:39:26 -07:00
Jarred Sumner
6514dcf4cb Fixes #6053 (#6162)
Fixes #6053

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-29 00:03:58 -07:00
Jarred Sumner
d3caf37b49 Upgrade to latest Node.js version (#6158)
* Upgrade to latest reported Node.js version

* Upgrade

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-28 23:20:26 -07:00
Devin Johw
315125c43a docs (runtime): the order of checking files when using bare impoort (#5919) 2023-09-28 22:13:52 -07:00
Dylan Conway
f6fbf86910 fix decorator tests 2023-09-28 19:18:36 -07:00
axel escalada
e1117c6ae5 Add local tarball install #5812 (#6118)
* check if the value passed for add command is a local tarball and install it, test for local tarball

* use bunExe()

* use absolute path to copy tarball

* fmt ts
2023-09-28 19:07:51 -07:00
Jarred Sumner
4bdec01619 Reduce memory usage of HTTP server (#6135)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-28 19:06:04 -07:00
dave caruso
2e8d9d4607 Revert WebKit submodule to where it should be 2023-09-28 18:01:14 -07:00
Colin McDonnell
640b0b4df9 Improve docs 2023-09-28 14:14:44 -07:00
Alba Silvente Fuentes
16be721d8a docs: update image astro.md (#6149) 2023-09-28 12:52:00 -07:00
Colin McDonnell
26794680dd Update prisma 2023-09-28 11:32:46 -07:00
Colin McDonnell
5fedc8bd6c Revert "Update prisma guide"
This reverts commit e62fef6765.
2023-09-28 11:31:47 -07:00
Colin McDonnell
e62fef6765 Update prisma guide 2023-09-28 11:27:08 -07:00
dave caruso
387f1260c9 Get Next.js Pages Router to work (#6095)
* hell

* make it so bun-debug-src

* teag

* wild

* yippee

* fas

* fix async hooks assertions

* yap

* yeah that's wild

* aa

* a

* increase time allowed

* so trivial
2023-09-28 03:53:24 -07:00
jhmaster
e60b3607c1 Complete rework of the majority of node:util, primarily util.inspect (#4493)
* 1st revision of new util.inspect impl. (not done)

* fix util.types.isArrayBuffer

* fix some utl tests and bugs

* fix node:tty missing primordials

* fix utl stackoverflow handling & some tests

* narrow down diff. context test

* util.inspect indirect circulars optimization

* temp workaround for buggy is...Function checks

* impl. Map/Set/Iterator entries inspection

* fix bigint & symbol objects inspection

* error inspection fixes

* misc util tests stuff

* inline getExternalValue stub

* leftovers

* util.inspect promise internals

* run bun fmt

* commit make js changes

* cut out unnecessary utl files

* reorganize utl folder structure

* remove browserify buffer check

* Try to revert git messing up uws somehow

This reverts commit 2c27e16e7d.

* commit src/js/out files again

* redo this edit too

* refresh js/out files

* Removed uws submodule

* tidy up

* unused primordials

* run fmt

---------

Co-authored-by: dave caruso <me@paperdave.net>
2023-09-27 23:51:49 -07:00
Dylan Conway
31d96a1b7f fix typescript metadata for import identifiers (#6130)
* handle import identifiers

* a test

* handle dot case
2023-09-27 23:37:53 -07:00
Dylan Conway
3ee09bfe79 update snapshots 2023-09-27 22:35:06 -07:00
jhmaster
3d37684253 deadCodeElimination toggle for Bun.Transpiler (#5932)
* add Bun.Transpiler DCE option

* mark DCE toggle experimental + tests

* full (hopefully) DCE toggle

* update DCE toggle tests

* add DCE option to types

* run fmt

* Removed uws submodule
2023-09-27 19:26:03 -07:00
Dylan Conway
06a82b7725 real fix was #5679 (#6123) 2023-09-27 19:23:28 -07:00
Justin "J.R." Hill
1d6d639352 fix(bun install): Handle vercel and github tarball path dependencies (#6122)
* fix(bun install): Handle vercel and github tarball path dependencies

* test(bun install): test tarball path with when

* Simplify github tarball detection

---------

Co-authored-by: bun <noreply@oven.sh>
2023-09-27 19:22:50 -07:00
Daniel Amemba
7cd1dc2817 Update run.md (#6099)
Changed the verb form from ignores to ignored.
2023-09-27 17:44:38 -07:00
Justin "J.R." Hill
57d1ae234c Update developer arch install steps for llvm and clang (#6120)
`llvm` and `clang` are both at v16

`llvm16` and `clang16` are AUR packages https://aur.archlinux.org/packages/llvm16 https://aur.archlinux.org/packages/clang16 and need extra steps to setup
2023-09-27 17:41:06 -07:00
Liz
8608b5286a fix: implement correct behaviour for urls with blob: scheme (#5825)
* fix: implement correct behaviour for urls with blob: scheme

Urls using the blob scheme can have special behaviour if their origin itself
is a url.
This fixes that by parsing the subdomain and if valid and the schemes(protocols)
are valid returns its origin.
Ive used node.js here a lot to make sure its behaviour is copied 1:1 and enabled
the automated tests for it.

Fixes https://github.com/oven-sh/bun/issues/5805

* fix: subUrl can be const, we are not modifying it

* style: add spaces after `if` keyword
2023-09-27 16:15:45 -07:00
Brennan Kinney
a5f76e690a fix: Docker - Apply workaround with RUN to symlink bunx (#6100)
Using `RUN --mount`, we can run the command with the build stage files overlayed for the `ln` and `which` commands.

`/bin` is a symlink to `/usr/bin`, both seem required to work correctly.
2023-09-27 09:49:33 -07:00
Ai Hoshino
a0081f9e29 fix(node:fs): fix fs.exists callback parameters (#6097)
Close: #6073
2023-09-27 03:40:45 -07:00
Dylan Conway
4d2b442a33 Update bun-install.test.ts 2023-09-26 22:19:33 -07:00
Dylan Conway
0268807be2 fix workspace dependency install (#6092)
* handle `*`

* test

* always use the package name

* more tests

* install dependency in each
2023-09-26 21:53:14 -07:00
Ashcon Partovi
f354a29683 Remove one of the tags 2023-09-26 20:07:27 -07:00
Ashcon Partovi
e5b62bf074 Fix docker tags 2023-09-26 20:01:39 -07:00
Ashcon Partovi
e05d190e6a Fix plain tag not releasing 2023-09-26 19:50:12 -07:00
Liz
d7b43f8ea1 fix: support console.dir options object correctly (#6059)
* fix: support console,dir options object correctly

`console.dir` can be passed a second argument which is a object of options.
This implements that logic with the currently supported properties: `depth`
and `colors`.
I used node as a reference for implementation details.

Fixes: https://github.com/oven-sh/bun/issues/6039

* style: format zig file

* fix: implement changes from review

Implements changes requested from review, like adding
more test cases and refactoring code style.
2023-09-26 19:47:37 -07:00
Ciro Spaciari
648d5aecf3 fix server end of stream, fix fetch not streaming without content-length or chunked encoding, fix case when stream do not return a promise on pull (#6086) 2023-09-26 19:31:20 -07:00
Ashcon Partovi
dc55492698 Add Docker section to docs 2023-09-26 19:30:00 -07:00
Ashcon Partovi
2b2927dedc Fix latest tag 2023-09-26 19:22:38 -07:00
Ashcon Partovi
500c52af62 Add is-latest flag to manual release 2023-09-26 19:18:24 -07:00
Ashcon Partovi
c1deec3c16 Use ln -s instead of ln due to image size 2023-09-26 19:05:39 -07:00
Ashcon Partovi
fbbf184b1d Fix homebrew 2023-09-26 18:57:32 -07:00
Ashcon Partovi
e127c520a9 Better bun-release workflow 2023-09-26 18:51:57 -07:00
Ashcon Partovi
80195557c9 Fix alpine image for arm64 2023-09-26 17:59:38 -07:00
Ashcon Partovi
9e26485b04 Fix docker release tag 2023-09-26 17:40:17 -07:00
Ashcon Partovi
5cf29df066 Fix debian-slim docker workflow 2023-09-26 17:12:26 -07:00
Ashcon Partovi
1bf36cf123 Fix github workflow permissions 2023-09-26 17:08:11 -07:00
Brennan Kinney
d060474f3a fix: Docker - Include bunx symlink in distroless variant (#6090) 2023-09-26 17:06:44 -07:00
Ashcon Partovi
fae646da3b Remove latest tag from canary Docker workflow 2023-09-26 16:38:44 -07:00
Ashcon Partovi
298515c368 Improve Docker images (#5771)
* Improve Docker images

* Add alpine and distroless images

* Update docker workflow
2023-09-26 16:35:12 -07:00
Alba Silvente Fuentes
2a14d9e5c9 Update astro.md to v3 (#6070) 2023-09-26 16:13:59 -07:00
0xflotus
549d01a4d6 docs: fixed small error (#6077) 2023-09-26 16:13:27 -07:00
Dylan Conway
aec0d35f9b no this value (#6063) 2023-09-25 23:27:55 -07:00
Colin McDonnell
b5c80d9476 Better typings for test.each() 2023-09-25 20:01:34 -07:00
Jarred Sumner
17fa9378e9 Drain microtasks at end of abort() if called into JS (#6036)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-25 16:09:37 -07:00
Jarred Sumner
6cde1d3b89 Add Module._extensions (#5998)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-25 16:09:09 -07:00
Jarred Sumner
6d842e7dcb Make error message for new URL(invalid) better (#6032)
* Make error message for `new URL(invalid)` better

Thanks to @karlcow https://github.com/WebKit/WebKit/pull/13802

* redact

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-25 16:07:33 -07:00
Colin McDonnell
9d9fcbbdeb Update docs 2023-09-25 15:22:12 -07:00
Vlad
cd09bb0e9b Add fs.statfs{Sync} to missing fs apis (#6030) 2023-09-25 10:55:55 -07:00
axel escalada
bbc70d2b73 Fix create command with template prefixed with @ char #6007 (#6013)
* fix create command with template prefixed with @ char

* add typescript test for create command

* format test
2023-09-25 05:22:47 -07:00
Ai Hoshino
3eca2c7fee fix c-string sentinel (#6026) 2023-09-25 05:19:33 -07:00
Jarred Sumner
af0cb893b5 Add microbenchmark for symbol-based private variables 2023-09-25 03:27:38 -07:00
Jarred Sumner
7027493196 Update nodejs-apis.md 2023-09-25 00:39:53 -07:00
Jarred Sumner
bd4523798f Clarify 2023-09-24 23:47:20 -07:00
Jarred Sumner
6326eb4246 Add buggy note 2023-09-24 21:28:33 -07:00
Jarred Sumner
96411580c1 Do not use removefileat() (#6001)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-24 18:27:55 -07:00
Jarred Sumner
3f463786a5 Correctly fix #5888 (#6000)
* Update our MultiArrayList

* More consistent CI

* Fix serialization issue

* Update bun.lockb

* Update bun.lockb

* fixup

* Fix `Bin{}`

* `bun update` should not cache the manifest

* Make bun install tests more consistent

* This differs by platform evidently

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-24 17:43:59 -07:00
Jeroen van Rensen
43f092807b Update writing.md - Remove duplicate code snippet (#5966) 2023-09-24 08:50:18 -07:00
cyfung1031
b8817ab188 Update README.md (#5989) 2023-09-24 08:49:57 -07:00
asrar
ef7f679edf Fix link to vitejs (#5959) 2023-09-24 08:49:14 -07:00
Jarred Sumner
57010cc448 Avoid using std.net.Address.parse (#5950)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-24 03:17:19 -07:00
Jarred Sumner
b6a4161cc5 Fixes #5985 (#5986)
* Fixes #5985

* Update confirm-fixture.js

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-24 03:16:51 -07:00
Ai Hoshino
a5908e9f27 fix(lockfile): ensure all bytes of union are initialized before serialization. (#5957) 2023-09-23 20:09:45 -07:00
Moritz Eck
72f9017b21 docs: update link to templates in remix guide (#5965) 2023-09-23 09:56:37 -07:00
Sony AK
93f1d91083 Update installation.md (#5968)
* Update installation.md

Adding notes for users that currently use canary version and want to  switch back to stable version.

* Upadte

---------

Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-09-23 09:56:03 -07:00
Jarred Sumner
ec0e931e9f Bump! 2023-09-22 21:26:59 -07:00
Jarred Sumner
a229cfd3c6 Make this function inline 2023-09-22 21:26:35 -07:00
Dylan Conway
966b636e5d isBinary (#5944) 2023-09-22 19:48:36 -07:00
Dylan Conway
ee93f1b88c [install] fix GitHub dependency bugs (#5941)
* handle branches with slashes

* handle empty repo string
2023-09-22 18:41:55 -07:00
Colin McDonnell
ffd21e98e7 Remove bun dev stuff from create_command (#5939) 2023-09-22 18:41:05 -07:00
Kilian von Pflugk
a3db02832e use the correct channel name for feedback (#5899) 2023-09-22 18:40:37 -07:00
Ai Hoshino
1445775d64 fix(runtime): exclude unevaluated module in require.cache (#5903)
Close: #5898
2023-09-22 18:40:06 -07:00
Colin McDonnell
feefaf00d7 Update workspaces.md 2023-09-22 16:42:23 -07:00
dave caruso
25e69c71e7 Implement module.parent (#5889)
* Make module.parent work

* yay

* oops

* yay
2023-09-21 22:09:55 -07:00
Dylan Conway
9d5459221f fix #5865 (#5890)
* make sure types are the same

* tests
2023-09-21 21:02:34 -07:00
dave caruso
341c1c1804 disable child_process execArgv + fix crash in cli parsing (#5843)
* stuff

* stuff

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-21 20:37:32 -07:00
Colin McDonnell
b218c40a5d Hide env elapsed time when loglevel=info (#5882)
* Hide env elapsed time when loglevel=info

* Updates

* Update

* Fix test
2023-09-21 20:07:25 -07:00
Dylan Conway
09d6e8553b ref and deinit (#5883)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-09-21 20:02:51 -07:00
Imamuzzaki Abu Salam
0502c134e8 docs: add await to all Bun.build() call (#5885) 2023-09-21 19:08:57 -07:00
Jarred Sumner
e34ff61339 Don't use arena in node:fs (#5863)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-21 18:59:01 -07:00
Igor Shapiro
8684a59029 chore(git): ignore .envrc file (#5873) 2023-09-21 18:44:59 -07:00
Liz
b297fabd17 fix: correctly pass the encrypted(bool) property on "Socket" for express.js (#5878)
* fix: correctly pass the encrypted property on "Socket" for express.js

Express relies on this for setting the requests protocol.
Since this is on a dummy object, a property is simply set with the actual value.
Which seams okay as a workaround.

* chore: add generated files

* chore: add test

* refactor: set property directly rather then through a getter
2023-09-21 18:44:05 -07:00
dave caruso
b05e10cd8b fix(node:fs): use the right copyFile constants (#5874) 2023-09-21 18:42:49 -07:00
Ai Hoshino
92a5d845ae chore: Update ZSH completions (#4428) 2023-09-21 17:43:01 -07:00
Colin McDonnell
030407c52e Update completions list 2023-09-21 17:32:19 -07:00
Colin McDonnell
cfc56dafeb Update install docs 2023-09-21 15:17:16 -07:00
Colin McDonnell
b011f94250 Update test script 2023-09-21 12:55:27 -07:00
Colin McDonnell
66cdb077ad Add docs for extending process.env 2023-09-21 12:35:41 -07:00
Dylan Conway
4a1573e007 decorator metadata defaults and rest args 2023-09-21 12:20:53 -07:00
Jarred Sumner
0b4a34bbd6 Fix test failures (#5862)
* Fix test failures

* Fixes #5851

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-21 07:56:44 -07:00
Jarred Sumner
d1e9b33cac On Linux, respect memory limit from cgroups (#5849)
* Implement `process.constrainedMemory()`

* Add a comment

* Handle max

* Missing header

* We can use WTF::ramSize now

* Update WebKit

* Update ZigGlobalObject.cpp

* WebKit

* ✂️

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-21 07:25:18 -07:00
Jarred Sumner
abfc10afeb Revert "feat(encoding): support BOM detection (#5550)"
This reverts commit 5f66b4e729.

This caused test failures in text-encoder. cc @WingLim
2023-09-21 07:10:07 -07:00
Jarred Sumner
a18ef053a4 Don't await plugins 2023-09-21 06:16:31 -07:00
Jarred Sumner
6abc9af472 Add another test 2023-09-21 06:04:58 -07:00
636 changed files with 93639 additions and 16131 deletions

View File

@@ -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?

View File

@@ -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

View File

@@ -16,6 +16,7 @@ on:
paths:
- "src/**/*"
- "test/**/*"
- "packages/bun-usockets/src/**/*"
- "build.zig"
- "Makefile"
- "Dockerfile"
@@ -37,7 +38,7 @@ jobs:
arch: aarch64
build_arch: arm64
runner: linux-arm64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-linux-arm64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-2/bun-webkit-linux-arm64-lto.tar.gz"
webkit_basename: "bun-webkit-linux-arm64-lto"
build_machine_arch: aarch64

View File

@@ -16,6 +16,7 @@ on:
paths:
- "src/**/*"
- "test/**/*"
- "packages/bun-usockets/src/**/*"
- "build.zig"
- "Makefile"
- "Dockerfile"
@@ -25,6 +26,7 @@ on:
paths:
- "src/**/*"
- "test/**/*"
- "packages/bun-usockets/src/**/*"
- "build.zig"
- "Makefile"
- "Dockerfile"
@@ -47,7 +49,7 @@ jobs:
arch: x86_64
build_arch: amd64
runner: big-ubuntu
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-linux-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-2/bun-webkit-linux-amd64-lto.tar.gz"
webkit_basename: "bun-webkit-linux-amd64-lto"
build_machine_arch: x86_64
- cpu: nehalem
@@ -55,7 +57,7 @@ jobs:
arch: x86_64
build_arch: amd64
runner: big-ubuntu
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-linux-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-2/bun-webkit-linux-amd64-lto.tar.gz"
webkit_basename: "bun-webkit-linux-amd64-lto"
build_machine_arch: x86_64
@@ -153,13 +155,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 }}
@@ -181,8 +203,8 @@ jobs:
with:
name: bun-${{matrix.tag}}
path: ${{runner.temp}}/release
- id: install
name: Install
- id: install-bun
name: Install Bun
run: |
cd ${{runner.temp}}/release
unzip bun-${{matrix.tag}}.zip
@@ -190,6 +212,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:
@@ -198,11 +227,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

View File

@@ -15,6 +15,7 @@ on:
paths:
- "src/**/*"
- "test/**/*"
- "packages/bun-usockets/src/**/*"
- "build.zig"
- "Makefile"
- "Dockerfile"
@@ -23,6 +24,7 @@ on:
paths:
- "src/**/*"
- "test/**/*"
- "packages/bun-usockets/src/**/*"
- "build.zig"
- "Makefile"
- "Dockerfile"
@@ -117,7 +119,7 @@ jobs:
# obj: bun-obj-darwin-x64-baseline
# runner: macos-12
# artifact: bun-obj-darwin-x64-baseline
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-2/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: true
# compile_obj: false
# - cpu: haswell
@@ -126,7 +128,7 @@ jobs:
# obj: bun-obj-darwin-x64
# runner: macos-12
# artifact: bun-obj-darwin-x64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-2/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: true
# compile_obj: false
# - cpu: nehalem
@@ -135,7 +137,7 @@ jobs:
# obj: bun-obj-darwin-x64-baseline
# runner: macos-12
# artifact: bun-obj-darwin-x64-baseline
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-2/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: false
# compile_obj: true
# - cpu: haswell
@@ -144,7 +146,7 @@ jobs:
# obj: bun-obj-darwin-x64
# runner: macos-12
# artifact: bun-obj-darwin-x64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-2/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: false
# compile_obj: true
- cpu: native
@@ -152,7 +154,7 @@ jobs:
tag: bun-darwin-aarch64
obj: bun-obj-darwin-aarch64
artifact: bun-obj-darwin-aarch64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-arm64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-2/bun-webkit-macos-arm64-lto.tar.gz"
runner: macos-arm64
dependencies: true
compile_obj: true
@@ -258,7 +260,7 @@ jobs:
# package: bun-darwin-x64
# runner: macos-12
# artifact: bun-obj-darwin-x64-baseline
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-2/bun-webkit-macos-amd64-lto.tar.gz"
# - cpu: haswell
# arch: x86_64
# tag: bun-darwin-x64
@@ -266,14 +268,14 @@ jobs:
# package: bun-darwin-x64
# runner: macos-12
# artifact: bun-obj-darwin-x64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-2/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-sept15-1/bun-webkit-macos-arm64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-2/bun-webkit-macos-arm64-lto.tar.gz"
runner: macos-arm64
steps:
- uses: actions/checkout@v3
@@ -393,11 +395,32 @@ jobs:
name: "Canary (${{github.sha}})"
tag: "canary"
artifacts: "${{runner.temp}}/release/${{matrix.tag}}.zip,${{runner.temp}}/release/${{matrix.tag}}-profile.zip"
- uses: sarisia/actions-status-discord@v1
if: failure() && github.repository_owner == 'oven-sh' && github.event_name == 'pull_request'
with:
title: ""
webhook: ${{ secrets.DISCORD_WEBHOOK }}
status: ${{ job.status }}
noprefix: true
nocontext: true
description: |
Pull Request
### [${{github.event.pull_request.title}}](https://github.com/oven-sh/bun/pull/${{github.event.number}})
@${{ github.actor }}
Build failed on ${{ matrix.tag }}:
**[View build output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})**
[Commit ${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})
macOS-test:
name: Tests ${{matrix.tag}}
runs-on: ${{ matrix.runner }}
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 }}
@@ -420,8 +443,8 @@ jobs:
with:
name: ${{matrix.tag}}
path: ${{runner.temp}}/release
- id: install
name: Install
- id: install-bun
name: Install Bun
run: |
cd ${{runner.temp}}/release
unzip ${{matrix.tag}}.zip
@@ -429,6 +452,12 @@ jobs:
chmod +x bun
pwd >> $GITHUB_PATH
./bun --version
- id: install
name: Install dependencies
run: |
bun install --verbose
bun install --cwd=test --verbose
bun install --cwd=packages/bun-internal-test --verbose
- id: test
name: Test (node runner)
env:
@@ -437,10 +466,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

View File

@@ -15,6 +15,7 @@ on:
paths:
- "src/**/*"
- "test/**/*"
- "packages/bun-usockets/src/**/*"
- "build.zig"
- "Makefile"
- "Dockerfile"
@@ -23,6 +24,7 @@ on:
paths:
- "src/**/*"
- "test/**/*"
- "packages/bun-usockets/src/**/*"
- "build.zig"
- "Makefile"
- "Dockerfile"
@@ -117,7 +119,7 @@ jobs:
obj: bun-obj-darwin-x64-baseline
runner: macos-12
artifact: bun-obj-darwin-x64-baseline
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-2/bun-webkit-macos-amd64-lto.tar.gz"
dependencies: true
compile_obj: false
# - cpu: haswell
@@ -126,7 +128,7 @@ jobs:
# obj: bun-obj-darwin-x64
# runner: macos-12
# artifact: bun-obj-darwin-x64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-2/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: true
# compile_obj: false
- cpu: nehalem
@@ -135,7 +137,7 @@ jobs:
obj: bun-obj-darwin-x64-baseline
runner: macos-12
artifact: bun-obj-darwin-x64-baseline
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-2/bun-webkit-macos-amd64-lto.tar.gz"
dependencies: false
compile_obj: true
# - cpu: haswell
@@ -144,7 +146,7 @@ jobs:
# obj: bun-obj-darwin-x64
# runner: macos-12
# artifact: bun-obj-darwin-x64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-2/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: false
# compile_obj: true
# - cpu: native
@@ -152,7 +154,7 @@ jobs:
# tag: bun-darwin-aarch64
# obj: bun-obj-darwin-aarch64
# artifact: bun-obj-darwin-aarch64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-2/bun-webkit-macos-amd64-lto.tar.gz"
# runner: macos-arm64
# dependencies: true
# compile_obj: true
@@ -259,7 +261,7 @@ jobs:
package: bun-darwin-x64
runner: macos-12
artifact: bun-obj-darwin-x64-baseline
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-2/bun-webkit-macos-amd64-lto.tar.gz"
# - cpu: haswell
# arch: x86_64
# tag: bun-darwin-x64
@@ -267,14 +269,14 @@ jobs:
# package: bun-darwin-x64
# runner: macos-12
# artifact: bun-obj-darwin-x64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-2/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-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-2/bun-webkit-macos-amd64-lto.tar.gz"
# runner: macos-arm64
steps:
- uses: actions/checkout@v3
@@ -397,11 +399,32 @@ jobs:
name: "Canary (${{github.sha}})"
tag: "canary"
artifacts: "${{runner.temp}}/release/${{matrix.tag}}.zip,${{runner.temp}}/release/${{matrix.tag}}-profile.zip"
- uses: sarisia/actions-status-discord@v1
if: failure() && github.repository_owner == 'oven-sh' && github.event_name == 'pull_request'
with:
title: ""
webhook: ${{ secrets.DISCORD_WEBHOOK }}
status: ${{ job.status }}
noprefix: true
nocontext: true
description: |
Pull Request
### [${{github.event.pull_request.title}}](https://github.com/oven-sh/bun/pull/${{github.event.number}})
@${{ github.actor }}
Build failed on ${{ matrix.tag }}:
**[View build output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})**
[Commit ${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})
macOS-test:
name: Tests ${{matrix.tag}}
runs-on: ${{ matrix.runner }}
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 }}
@@ -424,8 +447,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
@@ -433,6 +456,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:
@@ -441,10 +470,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

View File

@@ -15,6 +15,7 @@ on:
paths:
- "src/**/*"
- "test/**/*"
- "packages/bun-usockets/src/**/*"
- "build.zig"
- "Makefile"
- "Dockerfile"
@@ -23,6 +24,7 @@ on:
paths:
- "src/**/*"
- "test/**/*"
- "packages/bun-usockets/src/**/*"
- "build.zig"
- "Makefile"
- "Dockerfile"
@@ -117,7 +119,7 @@ jobs:
# obj: bun-obj-darwin-x64-baseline
# runner: macos-12
# artifact: bun-obj-darwin-x64-baseline
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-2/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: true
# compile_obj: false
- cpu: haswell
@@ -126,7 +128,7 @@ jobs:
obj: bun-obj-darwin-x64
runner: macos-12
artifact: bun-obj-darwin-x64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-2/bun-webkit-macos-amd64-lto.tar.gz"
dependencies: true
compile_obj: false
# - cpu: nehalem
@@ -135,7 +137,7 @@ jobs:
# obj: bun-obj-darwin-x64-baseline
# runner: macos-12
# artifact: bun-obj-darwin-x64-baseline
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-2/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: false
# compile_obj: true
- cpu: haswell
@@ -144,7 +146,7 @@ jobs:
obj: bun-obj-darwin-x64
runner: macos-12
artifact: bun-obj-darwin-x64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-2/bun-webkit-macos-amd64-lto.tar.gz"
dependencies: false
compile_obj: true
# - cpu: native
@@ -152,7 +154,7 @@ jobs:
# tag: bun-darwin-aarch64
# obj: bun-obj-darwin-aarch64
# artifact: bun-obj-darwin-aarch64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-arm64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-2/bun-webkit-macos-arm64-lto.tar.gz"
# runner: macos-arm64
# dependencies: true
# compile_obj: true
@@ -261,7 +263,7 @@ jobs:
# package: bun-darwin-x64
# runner: macos-12
# artifact: bun-obj-darwin-x64-baseline
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-2/bun-webkit-macos-amd64-lto.tar.gz"
- cpu: haswell
arch: x86_64
tag: bun-darwin-x64
@@ -269,14 +271,14 @@ jobs:
package: bun-darwin-x64
runner: macos-12
artifact: bun-obj-darwin-x64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-sept15-1/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-2/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-sept15-1/bun-webkit-macos-arm64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-2/bun-webkit-macos-arm64-lto.tar.gz"
# runner: macos-arm64
steps:
- uses: actions/checkout@v3
@@ -399,11 +401,32 @@ jobs:
name: "Canary (${{github.sha}})"
tag: "canary"
artifacts: "${{runner.temp}}/release/${{matrix.tag}}.zip,${{runner.temp}}/release/${{matrix.tag}}-profile.zip"
- uses: sarisia/actions-status-discord@v1
if: failure() && github.repository_owner == 'oven-sh' && github.event_name == 'pull_request'
with:
title: ""
webhook: ${{ secrets.DISCORD_WEBHOOK }}
status: ${{ job.status }}
noprefix: true
nocontext: true
description: |
Pull Request
### [${{github.event.pull_request.title}}](https://github.com/oven-sh/bun/pull/${{github.event.number}})
@${{ github.actor }}
Build failed on ${{ matrix.tag }}:
**[View build output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})**
[Commit ${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})
macOS-test:
name: Tests ${{matrix.tag}}
runs-on: ${{ matrix.runner }}
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 }}
@@ -426,8 +449,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
@@ -435,6 +458,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:
@@ -443,10 +472,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

View File

@@ -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

View File

@@ -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

View File

@@ -1,87 +1,95 @@
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
permissions: write-all
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 }}
npm:
name: Release to NPM
runs-on: ubuntu-latest
permissions: write-all
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 }}
@@ -89,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
@@ -132,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
@@ -157,102 +177,84 @@ 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
permissions: write-all
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>
s3:
name: Upload to S3
runs-on: ubuntu-latest
permissions: write-all
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 }}

View File

@@ -12,6 +12,8 @@ jobs:
prettier-fmt:
name: prettier
runs-on: ubuntu-latest
permissions:
pull-requests: write
outputs:
prettier_fmt_errs: ${{ steps.fmt.outputs.prettier_fmt_errs }}
steps:

View File

@@ -1,7 +1,7 @@
name: zig-fmt
env:
ZIG_VERSION: 0.12.0-dev.163+6780a6bbf
ZIG_VERSION: 0.12.0-dev.899+027aabf49
on:
pull_request:
@@ -18,6 +18,8 @@ jobs:
zig-fmt:
name: zig fmt
runs-on: ubuntu-latest
permissions:
pull-requests: write
outputs:
zig_fmt_errs: ${{ steps.fmt.outputs.zig_fmt_errs }}
steps:

3
.gitignore vendored
View File

@@ -6,6 +6,7 @@ packages/*/*.wasm
profile.json
node_modules
.envrc
.swcrc
yarn.lock
dist
@@ -133,4 +134,4 @@ src/js/out/DebugPath.h
make-dev-stats.csv
.uuid
tsconfig.tsbuildinfo
tsconfig.tsbuildinfo

View File

@@ -2,10 +2,10 @@
set -euxo pipefail
# if bun-webkit node_modules directory exists
if [ -d ./node_modules/bun-webkit ]; then
if [ -d ./node_modules/bun-webkit ] || [ -d ./node_modules/bun-webkit-debug ]; 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
ln -s ./node_modules/$(ls ./node_modules | grep bun-webkit- | grep -v bun-webkit-debug | head -n 1) ./bun-webkit
fi
# sets up vscode C++ intellisense

View File

@@ -6,11 +6,11 @@
"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}/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/",
@@ -28,11 +28,11 @@
"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/*",
@@ -59,7 +59,70 @@
"ENABLE_INSPECTOR_ALTERNATE_DISPATCHERS=0",
"BUILDING_JSCONLY__",
"USE_FOUNDATION=1",
"ASSERT_ENABLED=0",
"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/",
"${workspaceFolder}/src/bun.js/bindings/webcrypto/",
"${workspaceFolder}/src/bun.js/modules/",
"${workspaceFolder}/src/js/builtins/",
"${workspaceFolder}/src/js/out",
"${workspaceFolder}/src/deps/boringssl/include/",
"${workspaceFolder}/src/deps",
"${workspaceFolder}/src/napi/*",
"${workspaceFolder}/packages/bun-usockets/src",
"${workspaceFolder}/packages/"
],
"browse": {
"path": [
"${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/*",
"${workspaceFolder}/src/bun.js/bindings/sqlite/",
"${workspaceFolder}/src/bun.js/bindings/webcrypto/",
"${workspaceFolder}/src/bun.js/bindings/webcore/",
"${workspaceFolder}/src/js/builtins/*",
"${workspaceFolder}/src/js/out/*",
"${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_debug"
},
"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": [],

7
.vscode/launch.json generated vendored
View File

@@ -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": {
@@ -310,10 +310,9 @@
"cwd": "${fileDirname}",
"console": "internalConsole",
"env": {
"BUN_DEBUG_QUIET_LOGS": "1"
"BUN_DEBUG_ALL": "1"
}
},
{
"type": "lldb",
"request": "launch",

11
.vscode/settings.json vendored
View File

@@ -7,8 +7,7 @@
"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.formattingProvider": "zls",
"zig.buildArgs": ["obj", "-Dfor-editor"],
"zig.buildOption": "build",
"zig.buildFilePath": "${workspaceFolder}/build.zig",
@@ -27,7 +26,8 @@
"editor.formatOnSave": true
},
"zig.zls.enableInlayHints": false,
"zig.zls.enabled": true,
"git.ignoreSubmodules": true,
"[jsx]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
@@ -80,7 +80,9 @@
"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
"packages/bun-uws/fuzzing/seed-corpus/": true,
"**/*.dep": true,
"**/CMakeFiles": true
},
"C_Cpp.files.exclude": {
"**/.vscode": true,
@@ -220,7 +222,6 @@
"valarray": "cpp",
"codecvt": "cpp"
},
"cmake.configureOnOpen": false,
"C_Cpp.errorSquiggles": "enabled",
"eslint.workingDirectories": ["packages/bun-types"],
"typescript.tsdk": "node_modules/typescript/lib"

View File

@@ -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))

View File

@@ -10,9 +10,9 @@ ARG ARCH=x86_64
ARG BUILD_MACHINE_ARCH=x86_64
ARG TRIPLET=${ARCH}-linux-gnu
ARG BUILDARCH=amd64
ARG WEBKIT_TAG=2023-sept15
ARG WEBKIT_TAG=2023-oct3-2
ARG ZIG_TAG=jul1
ARG ZIG_VERSION="0.12.0-dev.163+6780a6bbf"
ARG ZIG_VERSION="0.12.0-dev.899+027aabf49"
ARG WEBKIT_BASENAME="bun-webkit-linux-$BUILDARCH"
ARG ZIG_FOLDERNAME=zig-linux-${BUILD_MACHINE_ARCH}-${ZIG_VERSION}
@@ -286,6 +286,7 @@ COPY packages/bun-uws ${BUN_DIR}/packages/bun-uws
COPY packages/bun-usockets ${BUN_DIR}/packages/bun-usockets
COPY src/deps/zlib ${BUN_DIR}/src/deps/zlib
COPY src/deps/boringssl/include ${BUN_DIR}/src/deps/boringssl/include
COPY src/deps/c-ares/include ${BUN_DIR}/src/deps/c-ares/include
COPY src/deps/libuwsockets.cpp ${BUN_DIR}/src/deps/libuwsockets.cpp
COPY src/deps/_libusockets.h ${BUN_DIR}/src/deps/_libusockets.h

View File

@@ -1954,5 +1954,5 @@ setup: vendor-dev identifier-cache clean-bindings
.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)
@echo "For detailed build instructions, see https://bun.sh/docs/project/contributing"
@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)

View File

@@ -31,7 +31,7 @@ Bun is an all-in-one toolkit for JavaScript and TypeScript apps. It ships as a s
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)

View File

@@ -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();

View 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
View 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`);
}
}

View File

@@ -1,3 +1,5 @@
const required_zig_version = "0.12.0-dev.899+027aabf49";
const std = @import("std");
const pathRel = std.fs.path.relative;
const Wyhash = @import("./src/wyhash.zig").Wyhash;
@@ -146,6 +148,20 @@ pub fn build(b: *Build) !void {
}
pub fn build_(b: *Build) !void {
if (!std.mem.eql(u8, @import("builtin").zig_version_string, required_zig_version)) {
const colors = std.io.getStdErr().supportsAnsiEscapeCodes();
std.debug.print(
"{s}WARNING:\nBun requires zig version '{s}', but found '{s}', build may fail...\nMake sure you installed the right version as per https://bun.sh/docs/project/development#install-zig\n{s}You can update to the right version using 'zigup {s}'\n\n",
.{
if (colors) "\x1b[1;33m" else "",
required_zig_version,
@import("builtin").zig_version_string,
if (colors) "\x1b[0m" else "",
required_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
@@ -217,7 +233,7 @@ 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;
@@ -331,7 +347,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 +364,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 +383,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 +397,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 +411,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 +425,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 +439,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 +453,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 +467,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);
@@ -468,7 +484,7 @@ pub fn build_(b: *Build) !void {
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| {

BIN
bun.lockb

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -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

View File

@@ -1,77 +0,0 @@
FROM debian:bullseye-slim AS build
# https://github.com/oven-sh/bun/releases
ARG BUN_VERSION=latest
RUN apt-get update -qq \
&& apt-get install -qq --no-install-recommends \
ca-certificates \
curl \
dirmngr \
gpg \
gpg-agent \
unzip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& arch="$(dpkg --print-architecture)" \
&& case "${arch##*-}" in \
amd64) build="x64-baseline";; \
arm64) build="aarch64";; \
*) echo "error: unsupported architecture: ($arch)"; exit 1 ;; \
esac \
&& version="$BUN_VERSION" \
&& case "$version" in \
latest | canary | bun-v*) tag="$version"; ;; \
v*) tag="bun-$version"; ;; \
*) tag="bun-v$version"; ;; \
esac \
&& case "$tag" in \
latest) release="latest/download"; ;; \
*) release="download/$tag"; ;; \
esac \
&& curl "https://github.com/oven-sh/bun/releases/$release/bun-linux-$build.zip" \
-fsSLO \
--compressed \
--retry 5 \
|| (echo "error: unknown release: ($tag)" && exit 1) \
&& for key in \
"F3DCC08A8572C0749B3E18888EAB4D40A7B22B59" \
; do \
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" \
|| gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \
done \
&& gpg --update-trustdb \
&& curl "https://github.com/oven-sh/bun/releases/$release/SHASUMS256.txt.asc" \
-fsSLO \
--compressed \
--retry 5 \
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
|| (echo "error: failed to verify release: ($tag)" && exit 1) \
&& grep " bun-linux-$build.zip\$" SHASUMS256.txt | sha256sum -c - \
|| (echo "error: failed to verify release: ($tag)" && exit 1) \
&& unzip "bun-linux-$build.zip" \
&& mv "bun-linux-$build/bun" /usr/local/bin/bun \
&& rm -f "bun-linux-$build.zip" SHASUMS256.txt.asc SHASUMS256.txt \
&& chmod +x /usr/local/bin/bun \
&& ln -s /usr/local/bin/bun /usr/local/bin/bunx \
&& which bun \
&& which bunx \
&& bun --version
FROM debian:bullseye-slim
RUN groupadd bun \
--gid 1000 \
&& useradd bun \
--uid 1000 \
--gid bun \
--shell /bin/sh \
--create-home
COPY docker-entrypoint.sh /usr/local/bin
COPY --from=build /usr/local/bin/bun /usr/local/bin
COPY --from=build /usr/local/bin/bunx /usr/local/bin
WORKDIR /home/bun/app
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["/usr/local/bin/bun"]

113
dockerhub/alpine/Dockerfile Normal file
View File

@@ -0,0 +1,113 @@
FROM alpine:3.18 AS build
# https://github.com/oven-sh/bun/releases
ARG BUN_VERSION=latest
# TODO: Instead of downloading glibc from a third-party source, we should
# build it from source. This is a temporary solution.
# See: https://github.com/sgerrand/alpine-pkg-glibc
# https://github.com/sgerrand/alpine-pkg-glibc/releases
# https://github.com/sgerrand/alpine-pkg-glibc/issues/176
ARG GLIBC_VERSION=2.34-r0
# https://github.com/oven-sh/bun/issues/5545#issuecomment-1722461083
ARG GLIBC_VERSION_AARCH64=2.26-r1
RUN apk --no-cache add \
ca-certificates \
curl \
dirmngr \
gpg \
gpg-agent \
unzip \
&& arch="$(apk --print-arch)" \
&& case "${arch##*-}" in \
x86_64) build="x64-baseline";; \
aarch64) build="aarch64";; \
*) echo "error: unsupported architecture: $arch"; exit 1 ;; \
esac \
&& version="$BUN_VERSION" \
&& case "$version" in \
latest | canary | bun-v*) tag="$version"; ;; \
v*) tag="bun-$version"; ;; \
*) tag="bun-v$version"; ;; \
esac \
&& case "$tag" in \
latest) release="latest/download"; ;; \
*) release="download/$tag"; ;; \
esac \
&& curl "https://github.com/oven-sh/bun/releases/$release/bun-linux-$build.zip" \
-fsSLO \
--compressed \
--retry 5 \
|| (echo "error: failed to download: $tag" && exit 1) \
&& for key in \
"F3DCC08A8572C0749B3E18888EAB4D40A7B22B59" \
; do \
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" \
|| gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \
done \
&& curl "https://github.com/oven-sh/bun/releases/$release/SHASUMS256.txt.asc" \
-fsSLO \
--compressed \
--retry 5 \
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
|| (echo "error: failed to verify: $tag" && exit 1) \
&& grep " bun-linux-$build.zip\$" SHASUMS256.txt | sha256sum -c - \
|| (echo "error: failed to verify: $tag" && exit 1) \
&& unzip "bun-linux-$build.zip" \
&& mv "bun-linux-$build/bun" /usr/local/bin/bun \
&& rm -f "bun-linux-$build.zip" SHASUMS256.txt.asc SHASUMS256.txt \
&& chmod +x /usr/local/bin/bun \
&& cd /tmp \
&& case "${arch##*-}" in \
x86_64) curl "https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk" \
-fsSLO \
--compressed \
--retry 5 \
|| (echo "error: failed to download: glibc v${GLIBC_VERSION}" && exit 1) \
&& mv "glibc-${GLIBC_VERSION}.apk" glibc.apk \
&& curl "https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-bin-${GLIBC_VERSION}.apk" \
-fsSLO \
--compressed \
--retry 5 \
|| (echo "error: failed to download: glibc-bin v${GLIBC_VERSION}" && exit 1) \
&& mv "glibc-bin-${GLIBC_VERSION}.apk" glibc-bin.apk ;; \
aarch64) curl "https://raw.githubusercontent.com/squishyu/alpine-pkg-glibc-aarch64-bin/master/glibc-${GLIBC_VERSION_AARCH64}.apk" \
-fsSLO \
--compressed \
--retry 5 \
|| (echo "error: failed to download: glibc v${GLIBC_VERSION_AARCH64}" && exit 1) \
&& mv "glibc-${GLIBC_VERSION_AARCH64}.apk" glibc.apk \
&& curl "https://raw.githubusercontent.com/squishyu/alpine-pkg-glibc-aarch64-bin/master/glibc-bin-${GLIBC_VERSION_AARCH64}.apk" \
-fsSLO \
--compressed \
--retry 5 \
|| (echo "error: failed to download: glibc-bin v${GLIBC_VERSION_AARCH64}" && exit 1) \
&& mv "glibc-bin-${GLIBC_VERSION_AARCH64}.apk" glibc-bin.apk ;; \
*) echo "error: unsupported architecture '$arch'"; exit 1 ;; \
esac
FROM alpine:3.18
COPY --from=build /tmp/glibc.apk /tmp/
COPY --from=build /tmp/glibc-bin.apk /tmp/
COPY --from=build /usr/local/bin/bun /usr/local/bin/
COPY docker-entrypoint.sh /usr/local/bin/
RUN addgroup -g 1000 bun \
&& adduser -u 1000 -G bun -s /bin/sh -D bun \
&& apk --no-cache --force-overwrite --allow-untrusted add \
/tmp/glibc.apk \
/tmp/glibc-bin.apk \
&& rm /tmp/glibc.apk \
&& rm /tmp/glibc-bin.apk \
&& ln -s /usr/local/bin/bun /usr/local/bin/bunx \
&& which bun \
&& which bunx \
&& bun --version
WORKDIR /home/bun/app
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["/usr/local/bin/bun"]

View File

@@ -1,7 +1,7 @@
FROM debian:bullseye-slim AS build
# https://github.com/oven-sh/bun/releases
ARG BUN_VERSION=0.5.7
ARG BUN_VERSION=latest
RUN apt-get update -qq \
&& apt-get install -qq --no-install-recommends \
@@ -17,7 +17,7 @@ RUN apt-get update -qq \
&& case "${arch##*-}" in \
amd64) build="x64-baseline";; \
arm64) build="aarch64";; \
*) echo "error: unsupported architecture: ($arch)"; exit 1 ;; \
*) echo "error: unsupported architecture: $arch"; exit 1 ;; \
esac \
&& version="$BUN_VERSION" \
&& case "$version" in \
@@ -33,44 +33,44 @@ RUN apt-get update -qq \
-fsSLO \
--compressed \
--retry 5 \
|| (echo "error: unknown release: ($tag)" && exit 1) \
|| (echo "error: failed to download: $tag" && exit 1) \
&& for key in \
"F3DCC08A8572C0749B3E18888EAB4D40A7B22B59" \
; do \
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" \
|| gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \
done \
&& gpg --update-trustdb \
&& curl "https://github.com/oven-sh/bun/releases/$release/SHASUMS256.txt.asc" \
-fsSLO \
--compressed \
--retry 5 \
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
|| (echo "error: failed to verify release: ($tag)" && exit 1) \
|| (echo "error: failed to verify: $tag" && exit 1) \
&& grep " bun-linux-$build.zip\$" SHASUMS256.txt | sha256sum -c - \
|| (echo "error: failed to verify release: ($tag)" && exit 1) \
|| (echo "error: failed to verify: $tag" && exit 1) \
&& unzip "bun-linux-$build.zip" \
&& mv "bun-linux-$build/bun" /usr/local/bin/bun \
&& rm -f "bun-linux-$build.zip" SHASUMS256.txt.asc SHASUMS256.txt \
&& chmod +x /usr/local/bin/bun \
&& ln -s /usr/local/bin/bun /usr/local/bin/bunx \
&& which bun \
&& which bunx \
&& bun --version
FROM debian:bullseye-slim
COPY docker-entrypoint.sh /usr/local/bin
COPY --from=build /usr/local/bin/bun /usr/local/bin/bun
RUN groupadd bun \
--gid 1000 \
&& useradd bun \
--uid 1000 \
--gid bun \
--shell /bin/sh \
--create-home
COPY docker-entrypoint.sh /usr/local/bin
COPY --from=build /usr/local/bin/bun /usr/local/bin
COPY --from=build /usr/local/bin/bunx /usr/local/bin
--create-home \
&& ln -s /usr/local/bin/bun /usr/local/bin/bunx \
&& which bun \
&& which bunx \
&& bun --version
WORKDIR /home/bun/app
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]

View File

@@ -1,7 +1,7 @@
FROM debian:bullseye-slim AS build
# https://github.com/oven-sh/bun/releases
ARG BUN_VERSION=0.5.7
ARG BUN_VERSION=latest
RUN apt-get update -qq \
&& apt-get install -qq --no-install-recommends \
@@ -17,7 +17,7 @@ RUN apt-get update -qq \
&& case "${arch##*-}" in \
amd64) build="x64-baseline";; \
arm64) build="aarch64";; \
*) echo "error: unsupported architecture: ($arch)"; exit 1 ;; \
*) echo "error: unsupported architecture: $arch"; exit 1 ;; \
esac \
&& version="$BUN_VERSION" \
&& case "$version" in \
@@ -33,44 +33,42 @@ RUN apt-get update -qq \
-fsSLO \
--compressed \
--retry 5 \
|| (echo "error: unknown release: ($tag)" && exit 1) \
|| (echo "error: failed to download: $tag" && exit 1) \
&& for key in \
"F3DCC08A8572C0749B3E18888EAB4D40A7B22B59" \
; do \
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" \
|| gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \
done \
&& gpg --update-trustdb \
&& curl "https://github.com/oven-sh/bun/releases/$release/SHASUMS256.txt.asc" \
-fsSLO \
--compressed \
--retry 5 \
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
|| (echo "error: failed to verify release: ($tag)" && exit 1) \
|| (echo "error: failed to verify: $tag" && exit 1) \
&& grep " bun-linux-$build.zip\$" SHASUMS256.txt | sha256sum -c - \
|| (echo "error: failed to verify release: ($tag)" && exit 1) \
|| (echo "error: failed to verify: $tag" && exit 1) \
&& unzip "bun-linux-$build.zip" \
&& mv "bun-linux-$build/bun" /usr/local/bin/bun \
&& rm -f "bun-linux-$build.zip" SHASUMS256.txt.asc SHASUMS256.txt \
&& chmod +x /usr/local/bin/bun \
&& ln -s /usr/local/bin/bun /usr/local/bin/bunx \
&& which bun \
&& which bunx \
&& bun --version
&& chmod +x /usr/local/bin/bun
FROM debian:bullseye
COPY docker-entrypoint.sh /usr/local/bin
COPY --from=build /usr/local/bin/bun /usr/local/bin/bun
RUN groupadd bun \
--gid 1000 \
&& useradd bun \
--uid 1000 \
--gid bun \
--shell /bin/sh \
--create-home
COPY docker-entrypoint.sh /usr/local/bin
COPY --from=build /usr/local/bin/bun /usr/local/bin
COPY --from=build /usr/local/bin/bunx /usr/local/bin
--create-home \
&& ln -s /usr/local/bin/bun /usr/local/bin/bunx \
&& which bun \
&& which bunx \
&& bun --version
WORKDIR /home/bun/app
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]

View File

@@ -1,5 +1,4 @@
FROM debian:bullseye-slim AS build
# Not officially supported (yet)
# https://github.com/oven-sh/bun/releases
ARG BUN_VERSION=latest
@@ -18,7 +17,7 @@ RUN apt-get update -qq \
&& case "${arch##*-}" in \
amd64) build="x64-baseline";; \
arm64) build="aarch64";; \
*) echo "error: unsupported architecture: ($arch)"; exit 1 ;; \
*) echo "error: unsupported architecture: $arch"; exit 1 ;; \
esac \
&& version="$BUN_VERSION" \
&& case "$version" in \
@@ -34,36 +33,37 @@ RUN apt-get update -qq \
-fsSLO \
--compressed \
--retry 5 \
|| (echo "error: unknown release: ($tag)" && exit 1) \
|| (echo "error: failed to download: $tag" && exit 1) \
&& for key in \
"F3DCC08A8572C0749B3E18888EAB4D40A7B22B59" \
; do \
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" \
|| gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \
done \
&& gpg --update-trustdb \
&& curl "https://github.com/oven-sh/bun/releases/$release/SHASUMS256.txt.asc" \
-fsSLO \
--compressed \
--retry 5 \
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
|| (echo "error: failed to verify release: ($tag)" && exit 1) \
|| (echo "error: failed to verify: $tag" && exit 1) \
&& grep " bun-linux-$build.zip\$" SHASUMS256.txt | sha256sum -c - \
|| (echo "error: failed to verify release: ($tag)" && exit 1) \
|| (echo "error: failed to verify: $tag" && exit 1) \
&& unzip "bun-linux-$build.zip" \
&& mv "bun-linux-$build/bun" /usr/local/bin/bun \
&& rm -f "bun-linux-$build.zip" SHASUMS256.txt.asc SHASUMS256.txt \
&& chmod +x /usr/local/bin/bun \
&& ln -s /usr/local/bin/bun /usr/local/bin/bunx \
&& which bun \
&& which bunx \
&& bun --version
FROM gcr.io/distroless/base-nossl-debian11
COPY --from=build /usr/local/bin/bun /usr/local/bin
COPY --from=build /usr/local/bin/bunx /usr/local/bin
COPY --from=build /usr/local/bin/bun /usr/local/bin/
# Temporarily use the `build`-stage image binaries to create a symlink:
RUN --mount=type=bind,from=build,source=/usr/bin,target=/usr/bin \
--mount=type=bind,from=build,source=/bin,target=/bin <<EOF
ln -s /usr/local/bin/bun /usr/local/bin/bunx
which bunx
EOF
WORKDIR /app
ENTRYPOINT ["/usr/local/bin/bun"]
CMD ["/usr/local/bin/bun"]

View File

@@ -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)`.

View File

@@ -93,6 +93,7 @@ interface Bun {
style: "nextjs";
origin?: string;
assetPrefix?: string;
fileExtensions?: string[];
});
reload(): void;

View File

@@ -183,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.

View File

@@ -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.

View File

@@ -161,7 +161,7 @@ socket.addEventListener("message", event => {
### Pub/Sub
Bun's `ServerWebSocket` implementation implements a native publish-subscribe API for topic-based broadcasting. Individual sockets can `.subscribe()` to a topic (specified with a string identifier) and `.publish()` messages to all other subscribers to that topic. This topic-based broadcast API is similar to [MQTT](https://en.wikipedia.org/wiki/MQTT) and [Redis Pub/Sub](https://redis.io/topics/pubsub).
Bun's `ServerWebSocket` implementation implements a native publish-subscribe API for topic-based broadcasting. Individual sockets can `.subscribe()` to a topic (specified with a string identifier) and `.publish()` messages to all other subscribers to that topic (excluding itself). This topic-based broadcast API is similar to [MQTT](https://en.wikipedia.org/wiki/MQTT) and [Redis Pub/Sub](https://redis.io/topics/pubsub).
```ts
const server = Bun.serve<{ username: string }>({
@@ -200,7 +200,18 @@ const server = Bun.serve<{ username: string }>({
console.log(`Listening on ${server.hostname}:${server.port}`);
```
Calling `.publish(data)` will send the message to all subscribers of a topic _except_ the socket that called `.publish()`.
Calling `.publish(data)` will send the message to all subscribers of a topic _except_ the socket that called `.publish()`. To send a message to all subscribers of a topic, use the `.publish()` method on the `Server` instance.
```ts
const server = Bun.serve({
websocket: {
// ...
},
});
// listen for some external event
server.publish("the-group-chat", "Hello world");
```
### Compression

View File

@@ -328,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"`.
---
@@ -1096,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({
/* */
});
@@ -1140,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({
/* */
});
@@ -1156,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);

155
docs/cli/add.md Normal file
View 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"
}
}
```

View File

@@ -1,36 +1,12 @@
## `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`
{% callout %}
**Note** — You dont need `bun create` to use Bun. You dont need any configuration at all. This command exists to make getting started a bit quicker and easier.
{% /callout %}
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.
### From `npm`
If you're looking to create a brand new empty project, use [`bun init`](/docs/cli/init).
## From `npm`
```sh
$ bun create <template> [<destination>]
@@ -45,7 +21,7 @@ $ bunx create-remix
Refer to the documentation of the associated `create-<template>` package for complete documentation and usage instructions.
### From GitHub
## From GitHub
This will download the contents of the GitHub repo to disk.
@@ -115,7 +91,7 @@ $ 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. -->
### From a local template
## 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.

View File

@@ -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" }
@@ -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"
@@ -170,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

View File

@@ -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 dont need `bun create` to use Bun. You dont 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`
- Dont initialize a git repository
---
- `--open`
- Start & open in-browser after finish
{% /table %}
### Environment variables
{% table %}
- Name
- Description
---
- `GITHUB_API_DOMAIN`
- If youre 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}`, heres 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 GitHubs 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 %}

View File

@@ -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.
![Demo](https://user-images.githubusercontent.com/709451/183006613-271960a3-ff22-4f7c-83f5-5e18f684c836.gif)
@@ -13,6 +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`.
#### How is `bun init` different than `bun create`?
`bun init` is for blank projects. `bun create` applies templates.
{% /details %}

View File

@@ -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.
![package install benchmark](https://user-images.githubusercontent.com/709451/147004342-571b6123-17a9-49a2-8bfd-dcfc5204047e.png)
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` or `optionalDependencies`):
```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 `bunfig.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 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"
$ 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 publicly hosted `.tgz` file. During `bun install`, Bun will download and install the package from the specified tarball URL, rather than from the package registry.
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
View 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
View File

@@ -0,0 +1,5 @@
To remove a dependency:
```bash
$ bun remove ts-node
```

View File

@@ -72,7 +72,7 @@ $ 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 ignores and passed through to the `"dev"` script itself.
Flags that occur at the end of the command will be ignored and passed through to the `"dev"` script itself.
{% /callout %}
### `--smol`
@@ -89,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
@@ -101,10 +105,10 @@ Your `package.json` can define a number of named `"scripts"` that correspond to
}
```
Use `bun <script>` or `bun run <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.

7
docs/cli/update.md Normal file
View File

@@ -0,0 +1,7 @@
To update all dependencies to the latest version _that's compatible with the version range specified in your `package.json`_:
```sh
$ bun update
```
This will not edit your `package.json`. There's currently no command to force-update all dependencies to the latest version regardless version ranges.

View File

@@ -49,7 +49,7 @@ This is useful for preventing flash of unstyled content.
## With `bun bun`
Bun bundles `.css` files imported via `@import` into a single file. It doesnt autoprefix or minify CSS today. Multiple `.css` files imported in one JavaScript file will _not_ be bundled into one file. Youll have to import those from a `.css` file.
Bun bundles `.css` files imported via `@import` into a single file. It doesnt auto-prefix or minify CSS today. Multiple `.css` files imported in one JavaScript file will _not_ be bundled into one file. Youll have to import those from a `.css` file.
This input:

View File

@@ -10,7 +10,7 @@ $ bun create astro
│ ◠ ◡ ◠ We're glad to have you on board.
╰─────╯
astro v2.10.5 Launch sequence initiated.
astro v3.1.4 Launch sequence initiated.
dir Where should we create your new project?
./fumbling-field
@@ -55,21 +55,17 @@ By default, Bun will run the dev server with Node.js. To use the Bun runtime ins
```sh
$ bunx --bun astro dev
🚀 astro v2.10.5 started in 200ms
🚀 astro v3.1.4 started in 200ms
┃ Local http://localhost:3000/
┃ Local http://localhost:4321/
┃ Network use --host to expose
01:48:34 PM [content] Watching src/content/ for changes
01:48:34 PM [content] Types generated
01:48:34 PM [astro] update /.astro/types.d.ts
```
---
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. Astro will hot-reload your app as you edit your source files.
Open [http://localhost:4321](http://localhost:4321) with your browser to see the result. Astro will hot-reload your app as you edit your source files.
{% image src="https://github.com/vitejs/vite/assets/3084745/bb1d5063-32f4-4598-b33e-50b44a1c4e8a" caption="An Astro starter app running on Bun" %}
{% image src="https://i.imgur.com/Dswiu6w.png" caption="An Astro v3 starter app running on Bun" %}
---

View File

@@ -0,0 +1,140 @@
---
name: Containerize a Bun application with Docker
---
{% callout %}
This guide assumes you already have [Docker Desktop](https://www.docker.com/products/docker-desktop/) installed.
{% /callout %}
[Docker](https://www.docker.com) is a platform for packaging and running an application as a lightweight, portable _container_ that encapsulates all the necessary dependencies.
---
To _containerize_ our application, we define a `Dockerfile`. This file contains a list of instructions to initialize the container, copy our local project files into it, install dependencies, and starts the application.
```docker#Dockerfile
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1 as base
WORKDIR /usr/src/app
# install dependencies into temp directory
# this will cache them and speed up future builds
FROM base AS install
RUN mkdir -p /temp/dev
COPY package.json bun.lockb /temp/dev/
RUN cd /temp/dev && bun install --frozen-lockfile
# install with --production (exclude devDependencies)
RUN mkdir -p /temp/prod
COPY package.json bun.lockb /temp/prod/
RUN cd /temp/prod && bun install --frozen-lockfile --production
# copy node_modules from temp directory
# then copy all (non-ignored) project files into the image
FROM install AS prerelease
COPY --from=install /temp/dev/node_modules node_modules
COPY . .
# [optional] tests & build
ENV NODE_ENV=production
RUN bun test
RUN bun run build
# copy production dependencies and source code into final image
FROM base AS release
COPY --from=install /temp/prod/node_modules node_modules
COPY --from=prerelease /usr/src/app/index.ts .
COPY --from=prerelease /usr/src/app/package.json .
# run the app
USER bun
EXPOSE 3000/tcp
ENTRYPOINT [ "bun", "run", "index.ts" ]
```
---
Now that you have your docker image, let's look at `.dockerignore` which has the same syntax as `.gitignore`, here you need to specify the files/directories that must not go in any stage of the docker build. An example for a ignore file is
```txt#.dockerignore
node_modules
Dockerfile*
docker-compose*
.dockerignore
.git
.gitignore
README.md
LICENSE
.vscode
Makefile
helm-charts
.env
.editorconfig
.idea
coverage*
```
---
We'll now use `docker build` to convert this `Dockerfile` into a _Docker image_, is a self-contained template containing all the dependencies and configuration required to run the application.
The `-t` flag lets us specify a name for the image, and `--pull` tells Docker to automatically download the latest version of the base image (`oven/bun`). The initial build will take longer, as Docker will download all the base images and dependencies.
```bash
$ docker build --pull -t bun-hello-world .
[+] Building 0.9s (21/21) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 37B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 35B 0.0s
=> [internal] load metadata for docker.io/oven/bun:1 0.8s
=> [auth] oven/bun:pull token for registry-1.docker.io 0.0s
=> [base 1/2] FROM docker.io/oven/bun:1@sha256:373265748d3cd3624cb3f3ee6004f45b1fc3edbd07a622aeeec17566d2756997 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 155B 0.0s
# ...lots of commands...
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:360663f7fdcd6f11e8e94761d5592e2e4dfc8d167f034f15cd5a863d5dc093c4 0.0s
=> => naming to docker.io/library/bun-hello-world 0.0s
```
---
We've built a new _Docker image_. Now let's use that image to spin up an actual, running _container_.
We'll use `docker run` to start a new container using the `bun-hello-world` image. It will be run in _detached_ mode (`-d`) and we'll map the container's port 3000 to our local machine's port 3000 (`-p 3000:3000`).
The `run` command prints a string representing the _container ID_.
```sh
$ docker run -d -p 3000:3000 bun-hello-world
7f03e212a15ede8644379bce11a13589f563d3909a9640446c5bbefce993678d
```
---
The container is now running in the background. Visit [localhost:3000](http://localhost:3000). You should see a `Hello, World!` message.
---
To stop the container, we'll use `docker stop <container-id>`.
```sh
$ docker stop 7f03e212a15ede8644379bce11a13589f563d3909a9640446c5bbefce993678d
```
---
If you can't find the container ID, you can use `docker ps` to list all running containers.
```sh
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7f03e212a15e bun-hello-world "bun run index.ts" 2 minutes ago Up 2 minutes 0.0.0.0:3000->3000/tcp flamboyant_cerf
```
---
That's it! Refer to the [Docker documentation](https://docs.docker.com/) for more advanced usage.

View File

@@ -0,0 +1,54 @@
---
name: Run Bun as a daemon with PM2
---
[PM2](https://pm2.keymetrics.io/) is a popular process manager that manages and runs your applications as daemons (background processes).
It offers features like process monitoring, automatic restarts, and easy scaling. Using a process manager is common when deploying a Bun application on a cloud-hosted virtual private server (VPS), as it:
- Keeps your Node.js application running continuously.
- Ensure high availability and reliability of your application.
- Monitor and manage multiple processes with ease.
- Simplify the deployment process.
---
You can use PM2 with Bun in two ways: as a CLI option or in a configuration file.
### With `--interpreter`
---
To start your application with PM2 and Bun as the interpreter, open your terminal and run the following command:
```bash
pm2 start --interpreter ~/.bun/bin/bun index.ts
```
---
### With a configuration file
---
Alternatively, you can create a PM2 configuration file. Create a file named `pm2.config.js` in your project directory and add the following content.
```javascript
module.exports = {
name: "app", // Name of your application
script: "index.ts", // Entry point of your application
interpreter: "~/.bun/bin/bun", // Path to the Bun interpreter
};
```
---
After saving the file, you can start your application with PM2
```bash
pm2 start pm2.config.js
```
---
Thats it! Your JavaScript/TypeScript web server is now running as a daemon with PM2 using Bun as the interpreter.

View File

@@ -11,17 +11,17 @@ name: Get started using Prisma
Prisma works out of the box with Bun. First, create a directory and initialize it with `bun init`.
```bash
mkdir prisma-app
cd prisma-app
bun init
$ mkdir prisma-app
$ cd prisma-app
$ bun init
```
---
Then add Prisma as a dependency.
Then install the Prisma CLI (`prisma`) and Prisma Client (`@prisma/client`) as dependencies.
```bash
bun add prisma
$ bun add prisma @prisma/client
```
---
@@ -29,7 +29,7 @@ bun add prisma
We'll use the Prisma CLI with `bunx` to initialize our schema and migration directory. For simplicity we'll be using an in-memory SQLite database.
```bash
bunx prisma init --datasource-provider sqlite
$ bunx prisma init --datasource-provider sqlite
```
---
@@ -60,14 +60,37 @@ Then generate and run initial migration.
This will generate a `.sql` migration file in `prisma/migrations`, create a new SQLite instance, and execute the migration against the new instance.
```bash
bunx prisma migrate dev --name init
$ bunx prisma migrate dev --name init
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Datasource "db": SQLite database "dev.db" at "file:./dev.db"
SQLite database dev.db created at file:./dev.db
Applying migration `20230928182242_init`
The following migration(s) have been created and applied from new schema changes:
migrations/
└─ 20230928182242_init/
└─ migration.sql
Your database is now in sync with your schema.
✔ Generated Prisma Client (v5.3.1) to ./node_modules/@prisma/client in 41ms
```
---
Prisma automatically generates our _Prisma client_ whenever we execute a new migration. The client provides a fully typed API for reading and writing from our database.
As indicated in the output, Prisma re-generates our _Prisma client_ whenever we execute a new migration. The client provides a fully typed API for reading and writing from our database. You can manually re-generate the client with the Prisma CLI.
It can be imported from `@prisma/client`.
```sh
$ bunx prisma generate
```
---
We can import the generated client from `@prisma/client`.
```ts#src/index.ts
import {PrismaClient} from "@prisma/client";

View File

@@ -18,7 +18,7 @@ $ bun create remix
dir Where should we create your new project?
./my-app
◼ Using basic template See https://remix.run/docs/pages/templates for more
◼ Using basic template See https://remix.run/docs/en/main/guides/templates#templates for more
✔ Template copied
git Initialize a new git repository?

View File

@@ -0,0 +1,113 @@
---
name: Run Bun as a daemon with systemd
---
[systemd](https://systemd.io) is an init system and service manager for Linux operating systems that manages the startup and control of system processes and services.
<!-- systemd provides aggressive parallelization capabilities, uses socket and D-Bus activation for starting services, offers on-demand starting of daemons, keeps track of processes using Linux control groups, maintains mount and auto mount points, and implements an elaborate transactional dependency-based service control logic. systemd supports SysV and LSB init scripts and works as a replacement for sysvinit. -->
<!-- Other parts include a logging daemon, utilities to control basic system configuration like the hostname, date, locale, maintain a list of logged-in users and running containers and virtual machines, system accounts, runtime directories and settings, and daemons to manage simple network configuration, network time synchronization, log forwarding, and name resolution. -->
---
To run a Bun application as a daemon using **systemd** you'll need to create a _service file_ in `/lib/systemd/system/`.
```sh
$ cd /lib/systemd/system
$ touch my-app.service
```
---
Here is a typical service file that runs an application on system start. You can use this as a template for your own service. Replace `YOUR_USER` with the name of the user you want to run the application as. To run as `root`, replace `YOUR_USER` with `root`, though this is generally not recommended for security reasons.
Refer to the [systemd documentation](https://www.freedesktop.org/software/systemd/man/systemd.service.html) for more information on each setting.
```ini#my-app.service
[Unit]
# describe the app
Description=My App
# start the app after the network is available
After=network.target
[Service]
# usually you'll use 'simple'
# one of https://www.freedesktop.org/software/systemd/man/systemd.service.html#Type=
Type=simple
# which user to use when starting the app
User=YOUR_USER
# path to your application's root directory
WorkingDirectory=/home/YOUR_USER/path/to/my-app
# the command to start the app
# requires absolute paths
ExecStart=/home/YOUR_USER/.bun/bin/bun run index.ts
# restart policy
# one of {no|on-success|on-failure|on-abnormal|on-watchdog|on-abort|always}
Restart=always
[Install]
# start the app automatically
WantedBy=multi-user.target
```
---
If your application starts a webserver, note that non-`root` users are not able to listen on ports 80 or 443 by default. To permanently allow Bun to listen on these ports when executed by a non-`root` user, use the following command. This step isn't necessary when running as `root`.
```bash
$ sudo setcap CAP_NET_BIND_SERVICE=+eip ~/.bun/bin/bun
```
---
With the service file configured, you can now _enable_ the service. Once enabled, it will start automatically on reboot. This requires `sudo` permissions.
```bash
$ sudo systemctl enable my-app
```
---
To start the service without rebooting, you can manually _start_ it.
```bash
$ sudo systemctl start my-app
```
---
Check the status of your application with `systemctl status`. If you've started your app successfully, you should see something like this:
```bash
$ sudo systemctl status my-app
● my-app.service - My App
Loaded: loaded (/lib/systemd/system/my-app.service; enabled; preset: enabled)
Active: active (running) since Thu 2023-10-12 11:34:08 UTC; 1h 8min ago
Main PID: 309641 (bun)
Tasks: 3 (limit: 503)
Memory: 40.9M
CPU: 1.093s
CGroup: /system.slice/my-app.service
└─309641 /home/YOUR_USER/.bun/bin/bun run /home/YOUR_USER/application/index.ts
```
---
To update the service, edit the contents of the service file, then reload the daemon.
```bash
$ sudo systemctl daemon-reload
```
---
For a complete guide on the service unit configuration, you can check [this page](https://www.freedesktop.org/software/systemd/man/systemd.service.html). Or refer to this cheatsheet of common commands:
```bash
$ sudo systemctl daemon-reload # tell systemd that some files got changed
$ sudo systemctl enable my-app # enable the app (to allow auto-start)
$ sudo systemctl disable my-app # disable the app (turns off auto-start)
$ sudo systemctl start my-app # start the app if is stopped
$ sudo systemctl stop my-app # stop the app
$ sudo systemctl restart my-app # restart the app
```

View File

@@ -30,8 +30,7 @@ bun install
Start the development server with the `vite` CLI using `bunx`.
The `--bun` flag tells Bun to run Vite's CLI using `bun` instead of `node`; by default Bun respects Vite's `#!/usr/bin/env node` [shebang line](<https://en.wikipedia.org/wiki/Shebang_(Unix)>). After Bun 1.0 this flag will no longer be necessary.
The `--bun` flag tells Bun to run Vite's CLI using `bun` instead of `node`; by default Bun respects Vite's `#!/usr/bin/env node` [shebang line](<https://en.wikipedia.org/wiki/Shebang_(Unix)>).
```bash
bunx --bun vite
```

View File

@@ -2,7 +2,7 @@
name: Add a peer dependency
---
To add an npm package as a peer dependency, directly modify the `peerDependencies` object in your package.json. Running `bun install` will not install peer dependencies.
To add an npm package as a peer dependency, directly modify the `peerDependencies` object in your package.json. Running `bun install` will install peer dependencies by default, unless marked optional in `peerDependenciesMeta`.
```json-diff
{

View File

@@ -47,4 +47,4 @@ Note that this only allows lifecycle scripts for the specific package listed in
---
See [Docs > Package manager > Trusted dependencies](/docs/cli/install#trusted-dependencies) for complete documentation of trusted dependencies.
See [Docs > Package manager > Trusted dependencies](/docs/install/lifecycle) for complete documentation of trusted dependencies.

View File

@@ -0,0 +1,66 @@
---
name: Spawn a child process and communicate using IPC
---
Use [`Bun.spawn()`](/docs/api/spawn) to spawn a child process. When spawning a second `bun` process, you can open a direct inter-process communication (IPC) channel between the two processes.
{%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" });
```
---
See [Docs > API > Child processes](/docs/api/spawn) for complete documentation.

View File

@@ -8,7 +8,7 @@ The `Bun.file()` function accepts a path and returns a `BunFile` instance. The `
const path = "/path/to/package.json";
const file = Bun.file(path);
const stream = await file.stream();
const stream = file.stream();
```
---

View File

@@ -2,6 +2,12 @@
name: Debugging Bun with the VS Code extension
---
{% note %}
VSCode extension support is currently buggy. We recommend the [Web Debugger](https://bun.sh/guides/runtime/web-debugger) for now.
{% /note %}
Bun speaks the [WebKit Inspector Protocol](https://github.com/oven-sh/bun/blob/main/packages/bun-vscode/types/jsc.d.ts) so you can debug your code with an interactive debugger.
---

View File

@@ -47,7 +47,7 @@ Bun.serve<WebSocketData>({
// use a library to parse cookies
const cookies = parseCookies(req.headers.get("Cookie"));
const token = cookies["X-Token"];
const user = await getUserFromToken(ws.data.authToken);
const user = await getUserFromToken(token);
const upgraded = server.upgrade(req, {
data: {

View File

@@ -0,0 +1,52 @@
---
name: Append content to a file
---
Bun implements the `node:fs` module, which includes the `fs.appendFile` and `fs.appendFileSync` functions for appending content to files.
---
You can use `fs.appendFile` to asynchronously append data to a file, creating the file if it does not yet exist. The content can be a string or a `Buffer`.
```ts
import { appendFile } from "node:fs/promises";
await appendFile("message.txt", "data to append");
```
---
To use the non-`Promise` API:
```ts
import { appendFile } from "node:fs";
appendFile("message.txt", "data to append", err => {
if (err) throw err;
console.log('The "data to append" was appended to file!');
});
```
---
To specify the encoding of the content:
```js
import { appendFile } from "node:fs";
appendFile("message.txt", "data to append", "utf8", callback);
```
---
To append the data synchronously, use `fs.appendFileSync`:
```ts
import { appendFileSync } from "node:fs";
appendFileSync("message.txt", "data to append", "utf8");
```
---
See the [Node.js documentation](https://nodejs.org/api/fs.html#fspromisesappendfilepath-data-options) for more information.

View File

@@ -26,7 +26,7 @@ Get started with one of the quick links below, or read on to learn more about Bu
{% arrowbutton href="/docs/installation" text="Install Bun" /%}
{% arrowbutton href="/docs/quickstart" text="Do the quickstart" /%}
{% arrowbutton href="/docs/cli/install" text="Install a package" /%}
{% arrowbutton href="/docs/templates" text="Use a project template" /%}
{% arrowbutton href="/docs/cli/bun-create" text="Use a project template" /%}
{% arrowbutton href="/docs/bundler" text="Bundle code for production" /%}
{% arrowbutton href="/docs/api/http" text="Build an HTTP server" /%}
{% arrowbutton href="/docs/api/websockets" text="Build a Websocket server" /%}
@@ -37,11 +37,14 @@ Get started with one of the quick links below, or read on to learn more about Bu
## What is a runtime?
JavaScript (or, more formally, ECMAScript) is just a _specification_ for a programming language. Anyone can write a JavaScript _engine_ that ingests a valid JavaScript program and executes it. The two most popular engines in use today are V8 (developed by Google) and JavaScriptCore (developed by Apple). Both are open source.
JavaScript (or, more formally, ECMAScript) is just a _specification_ for a programming language. Anyone can write a JavaScript _engine_ that ingests a valid JavaScript program and executes it. The two most popular engines in use today are V8 (developed by Google)
and JavaScriptCore (developed by Apple). Both are open source.
But most JavaScript programs don't run in a vacuum. They need a way to access the outside world to perform useful tasks. This is where _runtimes_ come in. They implement additional APIs that are then made available to the JavaScript programs they execute.
### Browsers
But most JavaScript programs don't run in a vacuum. They need a way to access the outside world to perform useful tasks. This is where _runtimes_ come in. They implement additional APIs that are then made available to the JavaScript programs they execute. Notably, browsers ship with JavaScript runtimes that implement a set of Web-specific APIs that are exposed via the global `window` object. Any JavaScript code executed by the browser can use these APIs to implement interactive or dynamic behavior in the context of the current webpage.
Notably, browsers ship with JavaScript runtimes that implement a set of Web-specific APIs that are exposed via the global `window` object. Any JavaScript code executed by the browser can use these APIs to implement interactive or dynamic behavior in the context of the current webpage.
<!-- JavaScript runtime that exposes JavaScript engines are designed to run "vanilla" JavaScript programs, but it's often JavaScript _runtimes_ use an engine internally to execute the code and implement additional APIs that are then made available to executed programs.
JavaScript was [initially designed](https://en.wikipedia.org/wiki/JavaScript) as a language to run in web browsers to implement interactivity and dynamic behavior in web pages. Browsers are the first JavaScript runtimes. JavaScript programs that are executed in browsers have access to a set of Web-specific global APIs on the `window` object. -->

View File

@@ -39,7 +39,7 @@ On Linux, `bun install` tends to install packages 20-100x faster than `npm insta
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` 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.
@@ -81,7 +81,7 @@ optional = true
dev = true
# whether to install peerDependencies
peer = false
peer = true
# equivalent to `--production` flag
production = false

44
docs/install/lifecycle.md Normal file
View File

@@ -0,0 +1,44 @@
Packages on `npm` can define _lifecycle scripts_ in their `package.json`. Some of the most common are below, but there are [many others](https://docs.npmjs.com/cli/v10/using-npm/scripts).
- `preinstall`: Runs before the package is installed
- `postinstall`: Runs after the package is installed
- `preuninstall`: Runs before the package is uninstalled
- `prepublishOnly`: Runs before the package is published
These scripts are arbitrary shell commands that the package manager is expected to read and execute at the appropriate time. But executing arbitrary scripts represents a potential security risk, so—unlike other `npm` clients—Bun does not execute arbitrary lifecycle scripts by default.
## `postinstall`
The `postinstall` script is particularly important. It's widely used to build or install platform-specific binaries for packages that are implemented as [native Node.js add-ons](https://nodejs.org/api/addons.html). For example, `node-sass` is a popular package that uses `postinstall` to build a native binary for Sass.
```json
{
"name": "my-app",
"version": "1.0.0",
"dependencies": {
"node-sass": "^6.0.1"
}
}
```
## `trustedDependencies`
Instead of executing arbitrary scripts, Bun uses a "default-secure" approach. You can add certain packages to an allow list, and Bun will execute lifecycle scripts for those packages. To tell Bun to allow lifecycle scripts for a particular package, add the package name to `trustedDependencies` array in your `package.json`.
```json-diff
{
"name": "my-app",
"version": "1.0.0",
+ "trustedDependencies": ["node-sass"]
}
```
Once added to `trustedDependencies`, install/re-install the package. Bun will read this field and run lifecycle scripts for `my-trusted-package`.
## `--ignore-scripts`
To disable lifecycle scripts for all packages, use the `--ignore-scripts` flag.
```bash
$ bun install --ignore-scripts
```

73
docs/install/overrides.md Normal file
View File

@@ -0,0 +1,73 @@
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"
+ }
}
```
By default, Bun will install the latest version of all dependencies and metadependencies, according to the ranges specified in each package's `package.json`. Let's say you have a project with one dependency, `foo`, which in turn has a dependency on `bar`. This means `bar` is a _metadependency_ of our project.
```json#package.json
{
"name": "my-app",
"dependencies": {
"foo": "^2.0.0"
}
}
```
When you run `bun install`, Bun will install the latest versions of each package.
```
# tree layout of node_modules
node_modules
├── foo@1.2.3
└── bar@4.5.6
```
But what if a security vulnerability was introduced in `bar@4.5.6`? We may want a way to pin `bar` to an older version that doesn't have the vulerability. This is where `"overrides"`/`"resolutions"` come in.
## `"overrides"`
Add `bar` to the `"overrides"` field in `package.json`. Bun will defer to the specified version range when determining which version of `bar` to install, whether it's a dependency or a metadependency.
{% callout %}
**Note** — Bun currently only supports top-level `"overrides"`. [Nested overrides](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#overrides) are not supported.
{% /callout %}
```json-diff#package.json
{
"name": "my-app",
"dependencies": {
"foo": "^2.0.0"
},
+ "overrides": {
+ "bar": "~4.4.0"
+ }
}
```
## `"resolutions"`
The syntax is similar for `"resolutions"`, which is Yarn's alternative to `"overrides"`. Bun supports this feature to make migration from Yarn easier.
As with `"overrides"`, _nested resolutions_ are not currently supported.
```json-diff#package.json
{
"name": "my-app",
"dependencies": {
"foo": "^2.0.0"
},
+ "resolutions": {
+ "bar": "~4.4.0"
+ }
}
```

View File

@@ -1,6 +1,30 @@
Bun supports [`workspaces`](https://docs.npmjs.com/cli/v9/using-npm/workspaces?v=true#description) in `package.json`. Workspaces make it easy to develop complex software as a _monorepo_ consisting of several independent packages.
To try it, specify a list of sub-packages in the `workspaces` field of your `package.json`; it's conventional to place these sub-packages in a directory called `packages`.
It's common for a monorepo to have the following structure:
```
tree
<root>
├── README.md
├── bun.lockb
├── package.json
├── tsconfig.json
└── packages
   ├── pkg-a
   │   ├── index.ts
   │   ├── package.json
   │   └── tsconfig.json
   ├── pkg-b
   │   ├── index.ts
   │   ├── package.json
   │   └── tsconfig.json
   └── pkg-c
   ├── index.ts
   ├── package.json
   └── tsconfig.json
```
In the root `package.json`, the `"workspaces"` key is used to indicate which subdirectories should be considered packages/workspaces within the monorepo. It conventional to place all the workspace in a directory called `packages`.
```json
{
@@ -17,7 +41,7 @@ To try it, specify a list of sub-packages in the `workspaces` field of your `pac
**Glob support** — Bun supports simple `<directory>/*` globs in `"workspaces"`. Full glob syntax (e.g. `**` and `?`) is not yet supported.
{% /callout %}
When referencing other packages in the monorepo, use `"workspace:*"` as the version field in your `package.json`.
Each workspace has it's own `package.json` When referencing other packages in the monorepo, use `"workspace:*"` as the version field in your `package.json`.
```json
{
@@ -35,7 +59,7 @@ When referencing other packages in the monorepo, use `"workspace:*"` as the vers
Workspaces have a couple major benefits.
- **Code can be split into logical parts.** If one package relies on another, you can simply add it as a dependency with `bun add`. If package `b` depends on `a`, `bun install` will symlink your local `packages/a` directory into the `node_modules` folder of `b`, instead of trying to download it from the npm registry.
- **Code can be split into logical parts.** If one package relies on another, you can simply add it as a dependency in `package.json`. If package `b` depends on `a`, `bun install` will install your local `packages/a` directory into `node_modules` instead of downloading it from the npm registry.
- **Dependencies can be de-duplicated.** If `a` and `b` share a common dependency, it will be _hoisted_ to the root `node_modules` directory. This reduces redundant disk usage and minimizes "dependency hell" issues associated with having multiple versions of a package installed simultaneously.
{% callout %}

View File

@@ -1,9 +1,12 @@
Bun ships as a single executable that can be installed a few different ways.
## macOS and Linux
## Installing
### macOS and Linux
{% callout %}
**Linux users** — The `unzip` package is required to install Bun. Kernel version 5.6 or higher is strongly recommended, but the minimum is 5.1.
**Linux users** — The `unzip` package is required to install Bun. Use `sudo apt install unzip` to install `unzip` package.
Kernel version 5.6 or higher is strongly recommended, but the minimum is 5.1. Use `uname -r` to check Kernel version.
{% /callout %}
{% codetabs %}
@@ -34,7 +37,7 @@ $ proto install bun
{% /codetabs %}
## Windows
### Windows
Bun provides a _limited, experimental_ native build for Windows. At the moment, only the Bun runtime is supported.
@@ -48,6 +51,77 @@ The test runner, package manager, and bundler are still under development. The f
- `bun link/unlink`
- `bun build`
## Docker
Bun provides a [Docker image](https://hub.docker.com/r/oven/bun/tags) that supports both Linux x64 and arm64.
```bash
$ docker pull oven/bun
$ docker run --rm --init --ulimit memlock=-1:-1 oven/bun
```
There are also image variants for different operating systems.
```bash
$ docker pull oven/bun:debian
$ docker pull oven/bun:slim
$ docker pull oven/bun:alpine
$ docker pull oven/bun:distroless
```
## Checking installation
To check that Bun was installed successfully, open a new terminal window and run `bun --version`.
```sh
$ bun --version
1.x.y
```
To see the precise commit of [oven-sh/bun](https://github.com/oven-sh/bun) that you're using, run `bun --revision`.
```sh
$ bun --revision
1.x.y+b7982ac1318937560f38e0f8eb18f45eaa43480f
```
If you've installed Bun but are seeing a `command not found` error, you may have to manually add the installation directory (`~/.bun/bin`) to your `PATH`.
{% details summary="How to add to your `PATH`" %}
First, determine what shell you're using:
```sh
$ echo $SHELL
/bin/zsh # or /bin/bash or /bin/fish
```
Then add these lines below to bottom of your shell's configuration file.
{% codetabs %}
```bash#~/.zshrc
# add to ~/.zshrc
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
```
```bash#~/.bashrc
# add to ~/.bashrc
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
```
```sh#~/.config/fish/config.fish
# add to ~/.config/fish/config.fish
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
```
{% /codetabs %}
Save the file. You'll need to open a new shell/terminal window for the changes to take effect.
{% /details %}
## Upgrading
Once installed, the binary can upgrade itself.
@@ -70,6 +144,10 @@ $ bun upgrade --canary
[View canary build](https://github.com/oven-sh/bun/releases/tag/canary)
{% callout %}
**Note** — To switch back to a stable release from canary, run `bun upgrade` again with no flags.
{% /callout %}
<!--
## Native

View File

@@ -38,12 +38,13 @@ export default {
page("typescript", "TypeScript", {
description: "Install and configure type declarations for Bun's APIs",
}),
page("templates", "Templates", {
description: "Hit the ground running with one of Bun's official templates, or download a template from GitHub.",
divider("Templating"),
page("cli/init", "`bun init`", {
description: "Scaffold an empty Bun project.",
}),
page("guides", "Guides", {
description: "A set of walkthrough guides and code snippets for performing common tasks with Bun",
href: "/guides",
page("cli/bun-create", "`bun create`", {
description: "Scaffold a new Bun project from an official template or GitHub repo.",
}),
// page("typescript", "TypeScript"),
@@ -81,7 +82,6 @@ export default {
// page("bundev", "Dev server"),
// page("benchmarks", "Benchmarks"),
// divider("Runtime"),
divider("Runtime"),
page("cli/run", "`bun run`", {
description: "Use `bun run` to execute JavaScript/TypeScript files and package.json scripts.",
@@ -152,6 +152,21 @@ export default {
description:
"Install all dependencies with `bun install`, or manage dependencies with `bun add` and `bun remove`.",
}),
page("cli/add", "`bun add`", {
description: "Add dependencies to your project.",
}),
page("cli/remove", "`bun remove`", {
description: "Remove dependencies from your project.",
}),
page("cli/update", "`bun update`", {
description: "Update your project's dependencies.",
}),
page("cli/link", "`bun link`", {
description: "Install local packages as dependencies in your project.",
}),
page("cli/pm", "`bun pm`", {
description: "Utilities relating to package management with Bun.",
}),
page("install/cache", "Global cache", {
description:
"Bun's package manager installs all packages into a shared global cache to avoid redundant re-downloads.",
@@ -159,6 +174,9 @@ export default {
page("install/workspaces", "Workspaces", {
description: "Bun's package manager supports workspaces and mono-repo development workflows.",
}),
page("install/lifecycle", "Lifecycle scripts", {
description: "How Bun handles package lifecycle scripts with trustedDependencies",
}),
page("install/lockfile", "Lockfile", {
description:
"Bun's binary lockfile `bun.lockb` tracks your resolved dependency tree, making future installs fast and repeatable.",
@@ -166,9 +184,12 @@ export default {
page("install/registries", "Scopes and registries", {
description: "How to configure private scopes and custom package registries.",
}),
page("install/utilities", "Utilities", {
description: "Use `bun pm` to introspect your global module cache or project dependency tree.",
page("install/overrides", "Overrides and resolutions", {
description: "Specify version ranges for nested dependencies",
}),
// page("install/utilities", "Utilities", {
// description: "Use `bun pm` to introspect your global module cache or project dependency tree.",
// }),
divider("Bundler"),
page("bundler", "`Bun.build`", {
@@ -334,7 +355,7 @@ export default {
page("project/benchmarking", "Benchmarking", {
description: `Bun is designed for performance. Learn how to benchmark Bun yourself.`,
}),
page("project/development", "Development", {
page("project/contributing", "Contributing", {
description: "Learn how to contribute to Bun and get your local development environment up and running.",
}),
page("project/licensing", "License", {

View File

@@ -46,8 +46,13 @@ $ wget https://apt.llvm.org/llvm.sh -O - | sudo bash -s -- 16 all
```
```bash#Arch
$ sudo pacman -S llvm16 clang16 lld
$ sudo pacman -S llvm clang lld
```
```bash#Fedora
$ sudo dnf install 'dnf-command(copr)'
$ sudo dnf copr enable -y @fedora-llvm-team/llvm-snapshots
$ sudo dnf install llvm clang lld
```
{% /codetabs %}
@@ -99,6 +104,10 @@ $ sudo apt install cargo ccache cmake git golang libtool ninja-build pkg-config
$ sudo pacman -S base-devel ccache cmake esbuild git go libiconv libtool make ninja pkg-config python rust sed unzip
```
```bash#Fedora
$ sudo dnf install cargo ccache cmake git golang libtool ninja-build pkg-config rustc golang-github-evanw-esbuild libatomic-static libstdc++-static sed unzip
```
{% /codetabs %}
{% details summary="Ubuntu — Unable to locate package esbuild" %}
@@ -121,11 +130,11 @@ Zig can be installed either with our npm package [`@oven/zig`](https://www.npmjs
```bash
$ bun install -g @oven/zig
$ zigup 0.12.0-dev.163+6780a6bbf
$ zigup 0.12.0-dev.899+027aabf49
```
{% callout %}
We last updated Zig on **July 18th, 2023**
We last updated Zig on **October 12th, 2023**
{% /callout %}
## First Build
@@ -376,34 +385,32 @@ $ valgrind --fair-sched=try --track-origins=yes bun-debug <args>
## Updating `WebKit`
The Bun team will occasionally bump the version of WebKit used in Bun. When this happens, you may see something like this with you run `git status`.
```bash
$ git status
On branch my-branch
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: src/bun.js/WebKit (new commits)
```
For performance reasons, `make submodule` does not automatically update the WebKit submodule. To update, run the following commands from the root of the Bun repo:
The Bun team will occasionally bump the version of WebKit used in Bun. When this happens, you may see errors in `src/bun.js/bindings` during builds. When you see this, install the latest version of `bun-webkit` and re-compile.
```bash
$ bun install
$ make cpp
```
<!-- Check the [Bun repo](https://github.com/oven-sh/bun/tree/main/src/bun.js) to get the hash of the commit of WebKit is currently being used.
## Building WebKit locally + Debug mode of JSC
{% image width="270" src="https://github.com/oven-sh/bun/assets/3084745/51730b73-89ef-4358-9a41-9563a60a54be" /%} -->
WebKit is not cloned by default (to save time and disk space). To clone and build WebKit locally, run:
<!--
```bash
$ cd src/bun.js/WebKit
$ git fetch
$ git checkout <hash>
``` -->
# once you run this, `make submodule` can be used to automatically
# update WebKit and the other submodules
$ git submodule update --init --depth 1 --checkout src/bun.js/WebKit
# to make a jsc release build
$ make jsc
# JSC debug build does not work perfectly with Bun yet, this is actively being
# worked on and will eventually become the default.
$ make jsc-build-linux-compile-debug cpp
$ make jsc-build-mac-compile-debug cpp
```
Note that the WebKit folder, including build artifacts, is 8GB+ in size.
If you are using a JSC debug build and using VScode, make sure to run the `C/C++: Select a Configuration` command to configure intellisense to find the debug headers.
## Troubleshooting
@@ -464,7 +471,7 @@ If you see an error about `cmakeconfig.h` not being found, this is because the p
$ bun install
```
Check to see the command installed webkit, and you can manully look for `node_modules/bun-webkit-{platform}-{arch}`:
Check to see the command installed webkit, and you can manually look for `node_modules/bun-webkit-{platform}-{arch}`:
```bash
# this should reveal two directories. if not, something went wrong

View File

@@ -42,10 +42,10 @@ const server = Bun.serve({
console.log(`Listening on http://localhost:${server.port} ...`);
```
<!--
### TypeScript
{% details summary="Seeing TypeScript errors on `Bun`?" %}
If you used `bun init`, Bun will have automatically installed Bun's TypeScript declarations and configured your `tsconfig.json`. If you're trying out Bun in an existing project, you may see a type error on the `Bun` global.
If you're using TypeScript, you may see a type error on the `Bun` global. To fix this, install `bun-types`.
To fix this, first install `bun-types` as a dev dependency.
```sh
$ bun add -d bun-types
@@ -59,7 +59,9 @@ Then add the following line to your `compilerOptions` in `tsconfig.json`.
+ "types": ["bun-types"]
}
}
``` -->
```
{% /details %}
Run the file from your shell.

View File

@@ -19,11 +19,11 @@ Bun's runtime behavior is configured using top-level fields in the `bunfig.toml`
### `preload`
An array of scripts to execute before running a file or script. This is useful for registering plugins.
An array of scripts/plugins to execute before running a file or script.
```toml
# scripts to run before `bun run`ning a file or script
# useful for registering plugins
# scripts to run before `bun run`-ing a file or script
# register plugins by adding them to this list
preload = ["./preload.ts"]
```
@@ -209,11 +209,11 @@ dev = true
### `install.peer`
Whether to install peer dependencies. Default `false`.
Whether to install peer dependencies. Default `true`.
```toml
[install]
peer = false
peer = true
```
### `install.production`

View File

@@ -25,9 +25,47 @@ Or programmatically by assigning a property to `process.env`.
process.env.FOO = "hello";
```
### Quotation marks
Bun supports double quotes, single quotes, and
### Expansion
Environment variables are automatically _expanded_. This means you can reference previously-defined variables in your environment variables.
```txt#.env
FOO=world
BAR=hello$FOO
```
```ts
process.env.BAR; // => "helloworld"
```
This is useful for constructing connection strings or other compound values.
```txt#.env
DB_USER=postgres
DB_PASSWORD=secret
DB_HOST=localhost
DB_PORT=5432
DB_URL=postgres://$DB_USER:$DB_PASSWORD@$DB_HOST:$DB_PORT/$DB_NAME
```
This can be disabled by escaping the `$` with a backslash.
```txt#.env
FOO=world
BAR=hello\$FOO
```
```ts
process.env.BAR; // => "hello$FOO"
```
### `dotenv`
Generally speaking, you won't need `dotenv` anymore, because Bun reads `.env` files automatically.
Generally speaking, you won't need `dotenv` or `dotenv-expand` anymore, because Bun reads `.env` files automatically.
## Reading environment variables
@@ -52,6 +90,31 @@ FOOBAR=aaaaaa
<lots more lines>
```
## TypeScript
In TypeScript, all properties of `process.env` are typed as `string | undefined`.
```ts
Bun.env.whatever;
// string | undefined
```
To get autocompletion and tell TypeScript to treat a variable as a non-optional string, we'll use [interface merging](https://www.typescriptlang.org/docs/handbook/declaration-merging.html#merging-interfaces).
```ts
declare module "bun" {
interface Env {
AWESOME: string;
}
}
```
Add this line to any file in your project. It will globally add the `AWESOME` property to `process.env` and `Bun.env`.
```ts
process.env.AWESOME; // => string
```
## Configuring Bun
These environment variables are read by Bun and configure aspects of its behavior.

View File

@@ -67,7 +67,7 @@ $ bun --watch test
Use `bun --hot` to enable hot reloading when executing code with Bun. This is distinct from `--watch` mode in that Bun does not hard-restart the entire process. Instead, it detects code changes and updates its internal module cache with the new code.
**Note** — This is not the same as hot reloading in the browser! Many frameworks provide a "hot reloading" experience, where you can edit & save your frontend code (say, a React component) and see the changes reflected in the browser without refreshing the page. Bun's `--hot` is the server-side equivalent of this experience. To get hot reloading in the browser, use a framework like [Vite](https://vite.dev).
**Note** — This is not the same as hot reloading in the browser! Many frameworks provide a "hot reloading" experience, where you can edit & save your frontend code (say, a React component) and see the changes reflected in the browser without refreshing the page. Bun's `--hot` is the server-side equivalent of this experience. To get hot reloading in the browser, use a framework like [Vite](https://vitejs.dev).
```bash
$ bun --hot server.ts

View File

@@ -33,15 +33,20 @@ Hello world!
In this case, we are importing from `./hello`, a relative path with no extension. **Extensioned imports are optional but supported.** To resolve this import, Bun will check for the following files in order:
- `./hello.ts`
- `./hello.tsx`
- `./hello.js`
- `./hello.jsx`
- `./hello.ts`
- `./hello.mjs`
- `./hello.js`
- `./hello.cjs`
- `./hello.json`
- `./hello/index.tsx`
- `./hello/index.jsx`
- `./hello/index.ts`
- `./hello/index.js`
- `./hello/index.json`
- `./hello/index.mjs`
- `./hello/index.js`
- `./hello/index.cjs`
- `./hello/index.json`
Import paths are case-insensitive, meaning these are all valid imports:

View File

@@ -1,16 +1,16 @@
Bun aims for complete Node.js API compatibility. Most `npm` packages intended for `Node.js` environments will work with Bun out of the box; the best way to know for certain is to try it.
This page is updated regularly to reflect compatibility status of the latest version of Bun. If you run into any bugs with a particular package, please [open an issue](https://bun.sh/issues). Opening issues for compatibility bugs helps us prioritize what to work on next.
This page is updated regularly to reflect compatibility status of the latest version of Bun. The information below reflects Bun's compatibility with _Node.js v20_. If you run into any bugs with a particular package, please [open an issue](https://bun.sh/issues). Opening issues for compatibility bugs helps us prioritize what to work on next.
## Built-in modules
### [`node:assert`](https://nodejs.org/api/assert.html)
🟢 Fully implemented.
🟡 Missing `doesNotMatch`
### [`node:async_hooks`](https://nodejs.org/api/async_hooks.html)
🟡 Only `AsyncLocalStorage`, and `AsyncResource` are implemented.
🟡 Only `AsyncLocalStorage`, and `AsyncResource` are implemented. `AsyncResource` is missing `bind`.
### [`node:buffer`](https://nodejs.org/api/buffer.html)
@@ -18,7 +18,7 @@ This page is updated regularly to reflect compatibility status of the latest ver
### [`node:child_process`](https://nodejs.org/api/child_process.html)
🟡 Missing `Stream` stdio, `proc.gid`, `proc.uid`. IPC has partial support and only current only works with other `bun` processes.
🟡 Missing `Stream` stdio, `proc.gid` `proc.uid`. IPC has partial support and only current only works with other `bun` processes.
### [`node:cluster`](https://nodejs.org/api/cluster.html)
@@ -26,11 +26,13 @@ This page is updated regularly to reflect compatibility status of the latest ver
### [`node:console`](https://nodejs.org/api/console.html)
🟡 Missing `Console` constructor.
🟢 Fully implemented.
### [`node:crypto`](https://nodejs.org/api/crypto.html)
🟡 Missing `crypto.Certificate` `crypto.ECDH` `crypto.KeyObject` `crypto.X509Certificate` `crypto.checkPrime{Sync}` `crypto.createPrivateKey` `crypto.createPublicKey` `crypto.createSecretKey` `crypto.diffieHellman` `crypto.generateKey{Sync}` `crypto.generateKeyPair{Sync}` `crypto.generatePrime{Sync}` `crypto.getCipherInfo` `crypto.{get|set}Fips` `crypto.hkdf` `crypto.hkdfSync` `crypto.secureHeapUsed` `crypto.setEngine` `crypto.sign` `crypto.verify`. Some methods are not optimized yet.
🟡 Missing `Certificate` `ECDH` `X509Certificate` `checkPrime` `checkPrimeSync` `diffieHellman` `generatePrime` `generatePrimeSync` `getCipherInfo` `getFips` `hkdf` `hkdfSync` `secureHeapUsed` `setEngine` `setFips`
Some methods are not optimized yet.
### [`node:dgram`](https://nodejs.org/api/dgram.html)
@@ -42,19 +44,19 @@ This page is updated regularly to reflect compatibility status of the latest ver
### [`node:dns`](https://nodejs.org/api/dns.html)
🟢 Fully implemented.
🟡 Missing `cancel` `setServers` `getDefaultResultOrder`
### [`node:domain`](https://nodejs.org/api/domain.html)
🟢 Fully implemented.
🟡 Missing `Domain` `active`
### [`node:events`](https://nodejs.org/api/events.html)
🟡 Missing `on`.
🟡 Missing `on` `addAbortListener` `getMaxListeners`
### [`node:fs`](https://nodejs.org/api/fs.html)
🟡 Missing `fs.fdatasync{Sync}` `fs.opendir{Sync}`. `fs.promises.open` incorrectly returns a file descriptor instead of a `FileHandle`.
🟡 Missing `Dir` `fdatasync` `fdatasyncSync` `openAsBlob` `opendir` `opendirSync` `statfs` `statfsSync`. `fs.promises.open` incorrectly returns a file descriptor instead of a `FileHandle`.
### [`node:http`](https://nodejs.org/api/http.html)
@@ -74,11 +76,11 @@ This page is updated regularly to reflect compatibility status of the latest ver
### [`node:module`](https://nodejs.org/api/module.html)
🟢 Fully implemented.
🟢 Missing `runMain` `syncBuiltinESMExports`, `Module#load()`. Attempts to override or patch the module cache will fail.
### [`node:net`](https://nodejs.org/api/net.html)
🟡 Missing `net.{get|set}DefaultAutoSelectFamily` `net.SocketAddress` `net.BlockList` `net.Server.ref()` `net.Server.unref()` `net.Socket.ref()` `net.Socket.unref()`.
🟡 Missing `BlockList` `SocketAddress` `Stream` `getDefaultAutoSelectFamily` `getDefaultAutoSelectFamilyAttemptTimeout` `setDefaultAutoSelectFamily` `setDefaultAutoSelectFamilyAttemptTimeout` `Server#ref()` `Server#unref()` `Socket#ref()` `Socket#unref()`.
### [`node:os`](https://nodejs.org/api/os.html)
@@ -90,7 +92,7 @@ This page is updated regularly to reflect compatibility status of the latest ver
### [`node:perf_hooks`](https://nodejs.org/api/perf_hooks.html)
🟡 Only `perf_hooks.performance.now()` and `perf_hooks.performance.timeOrigin` are implemented. Recommended to use `performance` global instead of `perf_hooks.performance`.
🟡 Only `perf_hooks.performance.now()` and `perf_hooks.performance.timeOrigin` are implemented. Missing `Performance` `PerformanceMark` `PerformanceMeasure` `PerformanceObserverEntryList` `PerformanceResourceTiming` `createHistogram` `monitorEventLoopDelay`. It's recommended to use `performance` global instead of `perf_hooks.performance`.
### [`node:process`](https://nodejs.org/api/process.html)
@@ -114,7 +116,7 @@ This page is updated regularly to reflect compatibility status of the latest ver
### [`node:stream`](https://nodejs.org/api/stream.html)
🟢 Fully implemented.
🟡 Missing `getDefaultHighWaterMark` `setDefaultHighWaterMark`
### [`node:string_decoder`](https://nodejs.org/api/string_decoder.html)
@@ -142,11 +144,11 @@ This page is updated regularly to reflect compatibility status of the latest ver
### [`node:url`](https://nodejs.org/api/url.html)
🟡 Missing `url.domainTo{ASCII|Unicode}`. Recommended to use `URL` and `URLSearchParams` globals instead.
🟡 Missing `domainToASCII` `domainToUnicode`. It's recommended to use `URL` and `URLSearchParams` globals instead.
### [`node:util`](https://nodejs.org/api/util.html)
🟡 Missing `util.MIMEParams` `util.MIMEType` `util.getSystemErrorMap()` `util.getSystemErrorName()` `util.parseArgs()` `util.stripVTControlCharacters()` `util.transferableAbortController()` `util.transferableAbortSignal()`.
🟡 Missing `MIMEParams` `MIMEType` `aborted` `debug` `getSystemErrorMap` `getSystemErrorName` `parseArgs` `transferableAbortController` `transferableAbortSignal` `stripVTControlCharacters`
### [`node:v8`](https://nodejs.org/api/v8.html)
@@ -154,7 +156,7 @@ This page is updated regularly to reflect compatibility status of the latest ver
### [`node:vm`](https://nodejs.org/api/vm.html)
🟡 Core functionality works, but VM modules are not implemented. `ShadowRealm` can be used.
🟡 Core functionality works, but VM modules are not implemented. Missing `createScript`. `ShadowRealm` can be used.
### [`node:wasi`](https://nodejs.org/api/wasi.html)
@@ -162,266 +164,11 @@ This page is updated regularly to reflect compatibility status of the latest ver
### [`node:worker_threads`](https://nodejs.org/api/worker_threads.html)
🟡 `Worker` doesn't support the following options: `eval`, `argv`, `execArgv`, `stdin`, `stdout`, `stderr`, `trackedUnmanagedFds`, `resourceLimits`. Missing `markAsUntransferable`, `moveMessagePortToContext`, `getHeapSnapshot`.
🟡 `Worker` doesn't support the following options: `eval` `argv` `execArgv` `stdin` `stdout` `stderr` `trackedUnmanagedFds` `resourceLimits`. Missing `markAsUntransferable` `moveMessagePortToContext` `getHeapSnapshot`.
### [`node:zlib`](https://nodejs.org/api/zlib.html)
🟡 Missing `zlib.brotli*`. Has not been optimized.
<!-- {% block className="ScrollFrame" %}
{% table %}
- Module
- Status
- Notes
---
- {% anchor id="node_assert" %} [`node:assert`](https://nodejs.org/api/assert.html) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_async_hooks" %} [`node:async_hooks`](https://nodejs.org/api/async_hooks.html) {% /anchor %}
- 🔴
- Not implemented.
---
- {% anchor id="node_buffer" %} [`node:buffer`](https://nodejs.org/api/buffer.html) {% /anchor %}
- 🟢
---
- {% anchor id="node_child_process" %} [`node:child_process`](https://nodejs.org/api/child_process.html) {% /anchor %}
- 🟡
- Missing IPC, `Stream` stdio, `proc.gid`, `proc.uid`, advanced serialization.
---
- {% anchor id="node_cluster" %} [`node:cluster`](https://nodejs.org/api/cluster.html) {% /anchor %}
- 🔴
- Not implemented.
---
- {% anchor id="node_console" %} [`node:console`](https://nodejs.org/api/console.html) {% /anchor %}
- 🟢
- Recommended to use `console` global instead
---
- {% anchor id="node_crypto" %} [`node:crypto`](https://nodejs.org/api/crypto.html) {% /anchor %}
- 🟡
- Missing `crypto.Certificate` `crypto.ECDH` `crypto.KeyObject` `crypto.X509Certificate` `crypto.checkPrime{Sync}` `crypto.createPrivateKey` `crypto.createPublicKey` `crypto.createSecretKey` `crypto.diffieHellman` `crypto.generateKey{Sync}` `crypto.generateKeyPair{Sync}` `crypto.generatePrime{Sync}` `crypto.getCipherInfo` `crypto.{get|set}Fips` `crypto.hkdf` `crypto.hkdfSync` `crypto.secureHeapUsed` `crypto.setEngine` `crypto.sign` `crypto.verify`. Some methods are not optimized yet.
---
- {% anchor id="node_dgram" %} [`node:dgram`](https://nodejs.org/api/dgram.html) {% /anchor %}
- 🔴
- Not implemented.
---
- {% anchor id="node_diagnostics_channel" %} [`node:diagnostics_channel`](https://nodejs.org/api/diagnostics_channel.html) {% /anchor %}
- 🔴
- Not implemented.
---
- {% anchor id="node_dns" %} [`node:dns`](https://nodejs.org/api/dns.html) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_domain" %} [`node:domain`](https://nodejs.org/api/domain.html) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_events" %} [`node:events`](https://nodejs.org/api/events.html) {% /anchor %}
- 🟡
- Missing `EventEmitterAsyncResource` `events.on`.
---
- {% anchor id="node_fs" %} [`node:fs`](https://nodejs.org/api/fs.html) {% /anchor %}
- 🟡
- Missing `fs.fdatasync{Sync}` `fs.opendir{Sync}`. `fs.promises.open` incorrectly returns a file descriptor instead of a `FileHandle`.
---
- {% anchor id="node_http" %} [`node:http`](https://nodejs.org/api/http.html) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_http2" %} [`node:http2`](https://nodejs.org/api/http2.html) {% /anchor %}
- 🔴
- Not implemented.
---
- {% anchor id="node_https" %} [`node:https`](https://nodejs.org/api/https.html) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_inspector" %} [`node:inspector`](https://nodejs.org/api/inspector.html) {% /anchor %}
- 🔴
- Not implemented.
---
- {% anchor id="node_module" %} [`node:module`](https://nodejs.org/api/module.html) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_net" %} [`node:net`](https://nodejs.org/api/net.html) {% /anchor %}
- 🟡
- Missing `net.{get|set}DefaultAutoSelectFamily` `net.SocketAddress` `net.BlockList`.
---
- {% anchor id="node_os" %} [`node:os`](https://nodejs.org/api/os.html) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_path" %} [`node:path`](https://nodejs.org/api/path.html) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_perf_hooks" %} [`node:perf_hooks`](https://nodejs.org/api/perf_hooks.html) {% /anchor %}
- 🟡
- Only `perf_hooks.performance.now()` and `perf_hooks.performance.timeOrigin` are implemented. Recommended to use `performance` global instead of `perf_hooks.performance`.
---
- {% anchor id="node_process" %} [`node:process`](https://nodejs.org/api/process.html) {% /anchor %}
- 🟡
- See `Globals > process`.
---
- {% anchor id="node_punycode" %} [`node:punycode`](https://nodejs.org/api/punycode.html) {% /anchor %}
- 🟢
- Fully implemented. _Deprecated by Node.js._
---
- {% anchor id="node_querystring" %} [`node:querystring`](https://nodejs.org/api/querystring.html) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_readline" %} [`node:readline`](https://nodejs.org/api/readline.html) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_repl" %} [`node:repl`](https://nodejs.org/api/repl.html) {% /anchor %}
- 🔴
- Not implemented.
---
- {% anchor id="node_stream" %} [`node:stream`](https://nodejs.org/api/stream.html) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_string_decoder" %} [`node:string_decoder`](https://nodejs.org/api/string_decoder.html) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_sys" %} [`node:sys`](https://nodejs.org/api/util.html) {% /anchor %}
- 🟡
- See `node:util`.
---
- {% anchor id="node_timers" %} [`node:timers`](https://nodejs.org/api/timers.html) {% /anchor %}
- 🟢
- Recommended to use global `setTimeout`, et. al. instead.
---
- {% anchor id="node_tls" %} [`node:tls`](https://nodejs.org/api/tls.html) {% /anchor %}
- 🟡
- Missing `tls.createSecurePair`.
---
- {% anchor id="node_trace_events" %} [`node:trace_events`](https://nodejs.org/api/tracing.html) {% /anchor %}
- 🔴
- Not implemented.
---
- {% anchor id="node_tty" %} [`node:tty`](https://nodejs.org/api/tty.html) {% /anchor %}
- 🟡
- Missing `tty.ReadStream` and `tty.WriteStream`.
---
- {% anchor id="node_url" %} [`node:url`](https://nodejs.org/api/url.html) {% /anchor %}
- 🟡
- Missing `url.domainTo{ASCII|Unicode}`. Recommended to use `URL` and `URLSearchParams` globals instead.
---
- {% anchor id="node_util" %} [`node:util`](https://nodejs.org/api/util.html) {% /anchor %}
- 🟡
- Missing `util.MIMEParams` `util.MIMEType` `util.formatWithOptions()` `util.getSystemErrorMap()` `util.getSystemErrorName()` `util.parseArgs()` `util.stripVTControlCharacters()` `util.transferableAbortController()` `util.transferableAbortSignal()`.
---
- {% anchor id="node_v8" %} [`node:v8`](https://nodejs.org/api/v8.html) {% /anchor %}
- 🔴
- `serialize` and `deserialize` use JavaScriptCore's wire format instead of V8's. Otherwise, not implemented. For profiling, use [`bun:jsc`](/docs/project/benchmarking#bunjsc) instead.
---
- {% anchor id="node_vm" %} [`node:vm`](https://nodejs.org/api/vm.html) {% /anchor %}
- 🟡
- Core functionality works, but VM modules are not implemented. `ShadowRealm` can be used.
---
- {% anchor id="node_wasi" %} [`node:wasi`](https://nodejs.org/api/wasi.html) {% /anchor %}
- 🟡
- Partially implemented.
---
- {% anchor id="node_worker_threads" %} [`node:worker_threads`](https://nodejs.org/api/worker_threads.html) {% /anchor %}
- 🔴
- Not implemented, but coming soon.
---
- {% anchor id="node_zlib" %} [`node:zlib`](https://nodejs.org/api/zlib.html) {% /anchor %}
- 🟡
- Missing `zlib.brotli*`.
{% /table %}
{% /block %} -->
🟡 Missing `BrotliCompress` `BrotliDecompress` `brotliCompressSync` `brotliDecompress` `brotliDecompressSync` `createBrotliCompress` `createBrotliDecompress`. Unoptimized.
## Globals
@@ -485,7 +232,7 @@ The table below lists all globals implemented by Node.js and Bun's current compa
### [`console`](https://developer.mozilla.org/en-US/docs/Web/API/console)
🟡 Missing `Console` constructor.
🟢 Fully implemented.
### [`CountQueuingStrategy`](https://developer.mozilla.org/en-US/docs/Web/API/CountQueuingStrategy)
@@ -589,7 +336,7 @@ The table below lists all globals implemented by Node.js and Bun's current compa
### [`process`](https://nodejs.org/api/process.html)
🟡 Missing `process.allowedNodeEnvironmentFlags` `process.channel` `process.constrainedMemory()` `process.getActiveResourcesInfo/setActiveResourcesInfo()` `process.setuid/setgid/setegid/seteuid/setgroups()` `process.hasUncaughtExceptionCaptureCallback` `process.initGroups()` `process.report` `process.resourceUsage()`. `process.binding` is partially implemented.
🟡 Missing `domain` `hasUncaughtExceptionCaptureCallback` `initgroups` `report` `resourceUsage` `setUncaughtExceptionCaptureCallback` `setegid` `seteuid` `setgid` `setgroups` `setuid` `allowedNodeEnvironmentFlags` `getActiveResourcesInfo` `setActiveResourcesInfo` `moduleLoadList` `setSourceMapsEnabled` `channel`. `process.binding` is partially implemented.
### [`queueMicrotask()`](https://developer.mozilla.org/en-US/docs/Web/API/queueMicrotask)
@@ -621,7 +368,7 @@ The table below lists all globals implemented by Node.js and Bun's current compa
### [`require()`](https://nodejs.org/api/globals.html#require)
🟢 Fully implemented, as well as [`require.main`](https://nodejs.org/api/modules.html#requiremain), [`require.cache`](https://nodejs.org/api/modules.html#requirecache), and [`require.resolve`](https://nodejs.org/api/modules.html#requireresolverequest-options).
🟢 Fully implemented, including [`require.main`](https://nodejs.org/api/modules.html#requiremain), [`require.cache`](https://nodejs.org/api/modules.html#requirecache), [`require.resolve`](https://nodejs.org/api/modules.html#requireresolverequest-options)
### [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
@@ -702,421 +449,3 @@ The table below lists all globals implemented by Node.js and Bun's current compa
### [`WritableStreamDefaultWriter`](https://developer.mozilla.org/en-US/docs/Web/API/WritableStreamDefaultWriter)
🟢 Fully implemented.
<!-- {% table %}
---
- {% anchor id="node_abortcontroller" %} [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_abortsignal" %} [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_blob" %} [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_buffer" %} [`Buffer`](https://nodejs.org/api/buffer.html#class-buffer) {% /anchor %}
- 🟡
- Incomplete implementation of `base64` and `base64url` encodings.
---
- {% anchor id="node_bytelengthqueuingstrategy" %} [`ByteLengthQueuingStrategy`](https://developer.mozilla.org/en-US/docs/Web/API/ByteLengthQueuingStrategy) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_dirname" %} [`__dirname`](https://nodejs.org/api/globals.html#__dirname) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_filename" %} [`__filename`](https://nodejs.org/api/globals.html#__filename) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_atob" %} [`atob()`](https://developer.mozilla.org/en-US/docs/Web/API/atob) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_broadcastchannel" %} [`BroadcastChannel`](https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel) {% /anchor %}
- 🔴
- Not implemented.
---
- {% anchor id="node_btoa" %} [`btoa()`](https://developer.mozilla.org/en-US/docs/Web/API/btoa) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_clearimmediate" %} [`clearImmediate()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/clearImmediate) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_clearinterval" %} [`clearInterval()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/clearInterval) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_cleartimeout" %} [`clearTimeout()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/clearTimeout) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_compressionstream" %} [`CompressionStream`](https://developer.mozilla.org/en-US/docs/Web/API/CompressionStream) {% /anchor %}
- 🔴
- Not implemented.
---
- {% anchor id="node_console" %} [`console`](https://developer.mozilla.org/en-US/docs/Web/API/console) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_countqueuingstrategy" %} [`CountQueuingStrategy`](https://developer.mozilla.org/en-US/docs/Web/API/CountQueuingStrategy) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_crypto" %} [`Crypto`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_crypto" %} [`SubtleCrypto (crypto)`](https://developer.mozilla.org/en-US/docs/Web/API/crypto) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_cryptokey" %} [`CryptoKey`](https://developer.mozilla.org/en-US/docs/Web/API/CryptoKey) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_customevent" %} [`CustomEvent`](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_decompressionstream" %} [`DecompressionStream`](https://developer.mozilla.org/en-US/docs/Web/API/DecompressionStream) {% /anchor %}
- 🔴
- Not implemented.
---
- {% anchor id="node_event" %} [`Event`](https://developer.mozilla.org/en-US/docs/Web/API/Event) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_eventtarget" %} [`EventTarget`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_exports" %} [`exports`](https://nodejs.org/api/globals.html#exports) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_fetch" %} [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/fetch) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_formdata" %} [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_global" %} [`global`](https://nodejs.org/api/globals.html#global) {% /anchor %}
- 🟢
- Implemented. This is an object containing all objects in the global namespace. It's rarely referenced directly, as its contents are available without an additional prefix, e.g. `__dirname` instead of `global.__dirname`.
---
- {% anchor id="node_globalthis" %} [`globalThis`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis) {% /anchor %}
- 🟢
- Aliases to `global`.
---
- {% anchor id="node_headers" %} [`Headers`](https://developer.mozilla.org/en-US/docs/Web/API/Headers) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_messagechannel" %} [`MessageChannel`](https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_messageevent" %} [`MessageEvent`](https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_messageport" %} [`MessagePort`](https://developer.mozilla.org/en-US/docs/Web/API/MessagePort) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_module" %} [`module`](https://nodejs.org/api/globals.html#module) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_performanceentry" %} [`PerformanceEntry`](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceEntry) {% /anchor %}
- 🔴
- Not implemented.
---
- {% anchor id="node_performancemark" %} [`PerformanceMark`](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceMark) {% /anchor %}
- 🔴
- Not implemented.
---
- {% anchor id="node_performancemeasure" %} [`PerformanceMeasure`](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceMeasure) {% /anchor %}
- 🔴
- Not implemented.
---
- {% anchor id="node_performanceobserver" %} [`PerformanceObserver`](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceObserver) {% /anchor %}
- 🔴
- Not implemented.
---
- {% anchor id="node_performanceobserverentrylist" %} [`PerformanceObserverEntryList`](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceObserverEntryList) {% /anchor %}
- 🔴
- Not implemented.
---
- {% anchor id="node_performanceresourcetiming" %} [`PerformanceResourceTiming`](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming) {% /anchor %}
- 🔴
- Not implemented.
---
- {% anchor id="node_performance" %} [`performance`](https://developer.mozilla.org/en-US/docs/Web/API/performance) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_process" %} [`process`](https://nodejs.org/api/process.html) {% /anchor %}
- 🟡
- Missing `process.allowedNodeEnvironmentFlags` `process.channel()` `process.connected` `process.constrainedMemory()` `process.disconnect()` `process.getActiveResourcesInfo/setActiveResourcesInfo()` `process.setuid/setgid/setegid/seteuid/setgroups()` `process.hasUncaughtExceptionCaptureCallback` `process.initGroups()` `process.report` `process.resourceUsage()` `process.send()`.
---
- {% anchor id="node_queuemicrotask" %} [`queueMicrotask()`](https://developer.mozilla.org/en-US/docs/Web/API/queueMicrotask) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_readablebytestreamcontroller" %} [`ReadableByteStreamController`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableByteStreamController) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_readablestream" %} [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_readablestreambyobreader" %} [`ReadableStreamBYOBReader`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamBYOBReader) {% /anchor %}
- 🔴
- Not implemented.
---
- {% anchor id="node_readablestreambyobrequest" %} [`ReadableStreamBYOBRequest`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamBYOBRequest) {% /anchor %}
- 🔴
- Not implemented.
---
- {% anchor id="node_readablestreamdefaultcontroller" %} [`ReadableStreamDefaultController`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamDefaultController) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_readablestreamdefaultreader" %} [`ReadableStreamDefaultReader`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamDefaultReader) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_require" %} [`require()`](https://nodejs.org/api/globals.html#require) {% /anchor %}
- 🟢
- Fully implemented, as well as [`require.main`](https://nodejs.org/api/modules.html#requiremain), [`require.cache`](https://nodejs.org/api/modules.html#requirecache), and [`require.resolve`](https://nodejs.org/api/modules.html#requireresolverequest-options)
---
- {% anchor id="node_response" %} [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_request" %} [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_setimmediate" %} [`setImmediate()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/setImmediate) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_setinterval" %} [`setInterval()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/setInterval) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_settimeout" %} [`setTimeout()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/setTimeout) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_structuredclone" %} [`structuredClone()`](https://developer.mozilla.org/en-US/docs/Web/API/structuredClone) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_subtlecrypto" %} [`SubtleCrypto`](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_domexception" %} [`DOMException`](https://developer.mozilla.org/en-US/docs/Web/API/DOMException) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_textdecoder" %} [`TextDecoder`](https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_textdecoderstream" %} [`TextDecoderStream`](https://developer.mozilla.org/en-US/docs/Web/API/TextDecoderStream) {% /anchor %}
- 🔴
- Not implemented.
---
- {% anchor id="node_textencoder" %} [`TextEncoder`](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_textencoderstream" %} [`TextEncoderStream`](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoderStream) {% /anchor %}
- 🔴
- Not implemented.
---
- {% anchor id="node_transformstream" %} [`TransformStream`](https://developer.mozilla.org/en-US/docs/Web/API/TransformStream) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_transformstreamdefaultcontroller" %} [`TransformStreamDefaultController`](https://developer.mozilla.org/en-US/docs/Web/API/TransformStreamDefaultController) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_url" %} [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_urlsearchparams" %} [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_webassembly" %} [`WebAssembly`](https://nodejs.org/api/globals.html#webassembly) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_writablestream" %} [`WritableStream`](https://developer.mozilla.org/en-US/docs/Web/API/WritableStream) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_writablestreamdefaultcontroller" %} [`WritableStreamDefaultController`](https://developer.mozilla.org/en-US/docs/Web/API/WritableStreamDefaultController) {% /anchor %}
- 🟢
- Fully implemented.
---
- {% anchor id="node_writablestreamdefaultwriter" %} [`WritableStreamDefaultWriter`](https://developer.mozilla.org/en-US/docs/Web/API/WritableStreamDefaultWriter) {% /anchor %}
- 🟢
- Fully implemented.
{% /table %} -->

View File

@@ -45,7 +45,7 @@ plugin(
);
```
Bun's plugin API is based on [esbuild](https://esbuild.github.io/plugins). Only [a subset](/docs/bundler/vs-esbuild#plugin-api) of the esbuild API is implemented, but some esbuild plugins "just work" in Bun, like the official [MDX loader](https://mdxjs.com/packages/esbuild/):
Bun's plugin API is loosely based on [esbuild](https://esbuild.github.io/plugins). Only [a subset](/docs/bundler/vs-esbuild#plugin-api) of the esbuild API is implemented, but some esbuild plugins "just work" in Bun, like the official [MDX loader](https://mdxjs.com/packages/esbuild/):
```jsx
import { plugin } from "bun";
@@ -61,7 +61,7 @@ Plugins are primarily used to extend Bun with loaders for additional file types.
```ts#yamlPlugin.ts
import { plugin } from "bun";
await plugin({
plugin({
name: "YAML",
async setup(build) {
const { load } = await import("js-yaml");
@@ -90,7 +90,7 @@ Register this file in `preload`:
preload = ["./yamlPlugin.ts"]
```
Once the plugin is registed, `.yaml` and `.yml` files can be directly imported.
Once the plugin is registered, `.yaml` and `.yml` files can be directly imported.
{% codetabs %}
@@ -217,6 +217,91 @@ import MySvelteComponent from "./component.svelte";
console.log(mySvelteComponent.render());
```
## Virtual Modules
{% note %}
This feature is currently only available at runtime with `Bun.plugin` and not yet supported in the bundler, but you can mimick the behavior using `onResolve` and `onLoad`.
{% /note %}
To create virtual modules at runtime, use `builder.module(specifier, callback)` in the `setup` function of a `Bun.plugin`.
For example:
```js
import { plugin } from "bun";
plugin({
name: "my-virtual-module",
setup(build) {
build.module(
// The specifier, which can be any string
"my-transpiled-virtual-module",
// The callback to run when the module is imported or required for the first time
() => {
return {
contents: "console.log('hello world!')",
loader: "js",
};
},
);
build.module("my-object-virtual-module", () => {
return {
exports: {
foo: "bar",
},
loader: "object",
};
});
},
});
// Sometime later
// All of these work
import "my-transpiled-virtual-module";
require("my-transpiled-virtual-module");
await import("my-transpiled-virtual-module");
require.resolve("my-transpiled-virtual-module");
import { foo } from "my-object-virtual-module";
const object = require("my-object-virtual-module");
await import("my-object-virtual-module");
require.resolve("my-object-virtual-module");
```
### Overriding existing modules
You can also override existing modules with `build.module`.
```js
import { plugin } from "bun";
build.module("my-object-virtual-module", () => {
return {
exports: {
foo: "bar",
},
loader: "object",
};
});
require("my-object-virtual-module"); // { foo: "bar" }
await import("my-object-virtual-module"); // { foo: "bar" }
build.module("my-object-virtual-module", () => {
return {
exports: {
baz: "quix",
},
loader: "object",
};
});
require("my-object-virtual-module"); // { baz: "quix" }
await import("my-object-virtual-module"); // { baz: "quix" }
```
## Reading the config
Plugins can read and write to the [build config](/docs/bundler#api) with `build.config`.

View File

@@ -139,12 +139,6 @@ $ bun test --only
To run a test conditionally, use `test.if()`. The test will run if the condition is truthy. This is particularly useful for tests that should only run on specific architectures or operating systems.
```ts
test.if(Math.random() > 0.5)("runs half the time", () => {
// ...
});
```
```ts
test.if(Math.random() > 0.5)("runs half the time", () => {
// ...
@@ -174,252 +168,252 @@ Bun implements the following matchers. Full Jest compatibility is on the roadmap
---
- ✔️
-
- [`.not`](https://jestjs.io/docs/expect#not)
---
- ✔️
-
- [`.toBe()`](https://jestjs.io/docs/expect#tobevalue)
---
- ✔️
-
- [`.toEqual()`](https://jestjs.io/docs/expect#toequalvalue)
---
- ✔️
-
- [`.toBeNull()`](https://jestjs.io/docs/expect#tobenull)
---
- ✔️
-
- [`.toBeUndefined()`](https://jestjs.io/docs/expect#tobeundefined)
---
- ✔️
-
- [`.toBeNaN()`](https://jestjs.io/docs/expect#tobenan)
---
- ✔️
-
- [`.toBeDefined()`](https://jestjs.io/docs/expect#tobedefined)
---
- ✔️
-
- [`.toBeFalsy()`](https://jestjs.io/docs/expect#tobefalsy)
---
- ✔️
-
- [`.toBeTruthy()`](https://jestjs.io/docs/expect#tobetruthy)
---
- ✔️
-
- [`.toContain()`](https://jestjs.io/docs/expect#tocontainitem)
---
- ✔️
-
- [`.toStrictEqual()`](https://jestjs.io/docs/expect#tostrictequalvalue)
---
- ✔️
-
- [`.toThrow()`](https://jestjs.io/docs/expect#tothrowerror)
---
- ✔️
-
- [`.toHaveLength()`](https://jestjs.io/docs/expect#tohavelengthnumber)
---
- ✔️
-
- [`.toHaveProperty()`](https://jestjs.io/docs/expect#tohavepropertykeypath-value)
---
- ✖️
-
- [`.extend`](https://jestjs.io/docs/expect#expectextendmatchers)
---
- ✔️
-
- [`.anything()`](https://jestjs.io/docs/expect#expectanything)
---
- ✔️
-
- [`.any()`](https://jestjs.io/docs/expect#expectanyconstructor)
---
- ✖️
-
- [`.arrayContaining()`](https://jestjs.io/docs/expect#expectarraycontainingarray)
---
- ✖️
-
- [`.assertions()`](https://jestjs.io/docs/expect#expectassertionsnumber)
---
- ✖️
-
- [`.closeTo()`](https://jestjs.io/docs/expect#expectclosetonumber-numdigits)
---
- ✖️
-
- [`.hasAssertions()`](https://jestjs.io/docs/expect#expecthasassertions)
---
- ✖️
-
- [`.objectContaining()`](https://jestjs.io/docs/expect#expectobjectcontainingobject)
---
- ✔️
-
- [`.stringContaining()`](https://jestjs.io/docs/expect#expectstringcontainingstring)
---
- ✔️
-
- [`.stringMatching()`](https://jestjs.io/docs/expect#expectstringmatchingstring--regexp)
---
- ✖️
-
- [`.addSnapshotSerializer()`](https://jestjs.io/docs/expect#expectaddsnapshotserializerserializer)
---
- ✔️
-
- [`.resolves()`](https://jestjs.io/docs/expect#resolves)
---
- ✔️
-
- [`.rejects()`](https://jestjs.io/docs/expect#rejects)
---
- ✔️
-
- [`.toHaveBeenCalled()`](https://jestjs.io/docs/expect#tohavebeencalled)
---
- ✔️
-
- [`.toHaveBeenCalledTimes()`](https://jestjs.io/docs/expect#tohavebeencalledtimesnumber)
---
- ✖️
-
- [`.toHaveBeenCalledWith()`](https://jestjs.io/docs/expect#tohavebeencalledwitharg1-arg2-)
---
- ✖️
-
- [`.toHaveBeenLastCalledWith()`](https://jestjs.io/docs/expect#tohavebeenlastcalledwitharg1-arg2-)
---
- ✖️
-
- [`.toHaveBeenNthCalledWith()`](https://jestjs.io/docs/expect#tohavebeennthcalledwithnthcall-arg1-arg2-)
---
- ✖️
-
- [`.toHaveReturned()`](https://jestjs.io/docs/expect#tohavereturned)
---
- ✖️
-
- [`.toHaveReturnedTimes()`](https://jestjs.io/docs/expect#tohavereturnedtimesnumber)
---
- ✖️
-
- [`.toHaveReturnedWith()`](https://jestjs.io/docs/expect#tohavereturnedwithvalue)
---
- ✖️
-
- [`.toHaveLastReturnedWith()`](https://jestjs.io/docs/expect#tohavelastreturnedwithvalue)
---
- ✖️
-
- [`.toHaveNthReturnedWith()`](https://jestjs.io/docs/expect#tohaventhreturnedwithnthcall-value)
---
- ✔️
-
- [`.toBeCloseTo()`](https://jestjs.io/docs/expect#tobeclosetonumber-numdigits)
---
- ✔️
-
- [`.toBeGreaterThan()`](https://jestjs.io/docs/expect#tobegreaterthannumber--bigint)
---
- ✔️
-
- [`.toBeGreaterThanOrEqual()`](https://jestjs.io/docs/expect#tobegreaterthanorequalnumber--bigint)
---
- ✔️
-
- [`.toBeLessThan()`](https://jestjs.io/docs/expect#tobelessthannumber--bigint)
---
- ✔️
-
- [`.toBeLessThanOrEqual()`](https://jestjs.io/docs/expect#tobelessthanorequalnumber--bigint)
---
- ✔️
-
- [`.toBeInstanceOf()`](https://jestjs.io/docs/expect#tobeinstanceofclass)
---
- ✖️
-
- [`.toContainEqual()`](https://jestjs.io/docs/expect#tocontainequalitem)
---
- ✔️
-
- [`.toMatch()`](https://jestjs.io/docs/expect#tomatchregexp--string)
---
- ✔️
-
- [`.toMatchObject()`](https://jestjs.io/docs/expect#tomatchobjectobject)
---
- ✔️
-
- [`.toMatchSnapshot()`](https://jestjs.io/docs/expect#tomatchsnapshotpropertymatchers-hint)
---
- ✖️
-
- [`.toMatchInlineSnapshot()`](https://jestjs.io/docs/expect#tomatchinlinesnapshotpropertymatchers-inlinesnapshot)
---
- ✖️
-
- [`.toThrowErrorMatchingSnapshot()`](https://jestjs.io/docs/expect#tothrowerrormatchingsnapshothint)
---
- ✖️
-
- [`.toThrowErrorMatchingInlineSnapshot()`](https://jestjs.io/docs/expect#tothrowerrormatchinginlinesnapshotinlinesnapshot)
{% /table %}

View File

@@ -31,7 +31,7 @@ Bun supports things like top-level await, JSX, and extensioned `.ts` imports, wh
"types": ["bun-types"],
// enable latest features
"lib": ["esnext"],
"lib": ["ESNext"],
"module": "esnext",
"target": "esnext",
@@ -45,7 +45,6 @@ Bun supports things like top-level await, JSX, and extensioned `.ts` imports, wh
"jsx": "react-jsx", // support JSX
"allowJs": true, // allow importing `.js` from `.ts`
"esModuleInterop": true, // allow default imports for CommonJS modules
// best practices
"strict": true,

View File

@@ -15,8 +15,8 @@ for (let key of Object.keys(json).sort()) {
}
const withExtensions = [
...new Set([
...Object.keys(json)
...new Set(
Object.keys(json)
.filter(key => {
return !!json[key]?.extensions?.length;
})
@@ -26,7 +26,7 @@ const withExtensions = [
});
})
.sort(),
]),
),
];
all += "\n";

210
misctools/nodejs-compat.ts Normal file
View File

@@ -0,0 +1,210 @@
const nodejsBuiltinModules = [
"assert",
"async_hooks",
"buffer",
"child_process",
"cluster",
"console",
"constants",
"crypto",
"dgram",
"diagnostics_channel",
"dns",
"domain",
"events",
"fs",
"http",
"http2",
"https",
"inspector",
"module",
"net",
"os",
"path",
"perf_hooks",
"process",
"punycode",
"querystring",
"readline",
"repl",
"stream",
"string_decoder",
"timers",
"tls",
"trace_events",
"tty",
"url",
"util",
"v8",
"vm",
"wasi",
"worker_threads",
"zlib",
];
function getModuleKeys(moduleName: string): string[] {
const script = `import('${moduleName}').then(mod=>console.log(JSON.stringify(Object.keys(mod))))`;
const nodeProc = Bun.spawnSync(["node", "-e", script], {
stderr: "ignore",
});
const nodeKeys: string[] = JSON.parse(nodeProc.stdout.toString());
return nodeKeys;
}
function getAllProperties(obj = {}) {
const allKeys = new Set();
do {
Reflect.ownKeys(obj).forEach(key => allKeys.add(key));
} while ((obj = Object.getPrototypeOf(obj)));
return [...allKeys];
}
function getPrototypeKeys(moduleName: string, className: string): string[] {
// const script = `import('${moduleName}').then(mod=>console.log(JSON.stringify(Object.keys(mod.${className}.prototype))))`;
const script = `
import("${moduleName}").then((mod) => {
const lines = new Set();
let obj = mod.${className}.prototype;
do {
Reflect.ownKeys(obj).forEach((key) => lines.add(key));
} while ((obj = Object.getPrototypeOf(obj)));
console.log("[", [...lines].map(k => \`"\${String(k)}"\`).join(","), "]");
});`.replace(/\n/g, "");
// remove whitespace
// .replace(/\s+/g, "");
// console.log(script);
const nodeProc = Bun.spawnSync(["node", "-e", script], {
// stderr: "inherit",
// stdout: "inherit",
});
// console.log(nodeProc.stdout.toString());
const nodeKeys: string[] = JSON.parse(nodeProc.stdout.toString());
return nodeKeys;
}
const SKIP: Record<string, boolean> = {
"buffer.File": true,
"process.abort": true,
"process.exit": true,
"process.kill": true,
"process.reallyExit": true,
"vm.Script": true,
"zlib.deflate": true,
"zlib.inflate": true,
"zlib.unzip": true,
"zlib.deflateRaw": true,
"zlib.gunzip": true,
"zlib.gzip": true,
"zlib.inflateRaw": true,
"console.assert": true,
"console.count": true,
// "fs.mkdtempSync": true,
// "fs.read": true,
// "fs.readv": true,
// "fs.writev": true,
// "fs.writeSync": true,
// "fs.writeFileSync": true,
// "fs.writeFile": true,
// "fs.write": true,
// "fs.writevSync": true,
// "fs.watchFile": true,
// "fs.watch": true,
// "fs.utimesSync": true,
// "fs.utimes": true,
// "fs.unwatchFile": true,
// "fs.unlinkSync": true,
// "fs.unlink": true,
// "fs.truncateSync": true,
// "fs.truncate": true,
// "fs.symlinkSync": true,
};
for (const moduleName of nodejsBuiltinModules) {
const heading = `======== ${moduleName} ========`;
// print equals sign to match the length of heading
console.log("\n\n" + "=".repeat(heading.length));
console.log(heading);
console.log("=".repeat(heading.length));
const mod = await import(moduleName);
const bunKeys: string[] = Object.keys(mod);
const nodeKeys = getModuleKeys(moduleName);
// print top-level elements that are missing
// const missingKeys = nodeKeys
// .filter((key) => !bunKeys.includes(key))
// .filter((k) => !k.startsWith("_"));
// const notMissing = nodeKeys.filter((key) => bunKeys.includes(key));
// if (missingKeys.length === 0) {
// console.log(`Fully implemented.`);
// } else {
// console.log(`Missing ${missingKeys.map((k) => `\`${k}\``).join(" ")}`);
// }
console.log();
// check for prototype compatibility
let missing = false;
for (const k of nodeKeys) {
if (k.startsWith("_")) continue;
if (!bunKeys.includes(k)) {
missing = true;
console.log(` [${moduleName}.${k}] Not implemented.`);
continue;
}
if (mod[k] && typeof mod[k] === "function") {
if (!!mod[k].prototype) {
const className = `${moduleName}.${k}`;
const bunProtoKeys = getAllProperties(mod[k].prototype);
// console.log(mod[k].prototype);
// getAllProperties;
// for (const l in mod[k].prototype) {
// bunProtoKeys.push(l);
// }
const nodeProtoKeys = getPrototypeKeys(moduleName, k);
// console.log("nodeProtoKeys", nodeProtoKeys);
// console.log("bunProtoKeys", bunProtoKeys);
// console.log("nodeProtoKeys", nodeProtoKeys);
// console.log("bunProtoKeys", bunProtoKeys);
const missingProtoKeys = nodeProtoKeys.filter(key => !bunProtoKeys.includes(key));
// const notMissingProtoKeys = nodeProtoKeys.filter((key) =>
// bunProtoKeys.includes(key)
// );
if (missingProtoKeys.length === 0) {
console.log(` [${className}] Fully implemented.`);
} else {
missing = true;
console.log(
` [${className}] Missing ${missingProtoKeys
.filter(k => !k.startsWith("_"))
.map(k => `\`${k}\``)
.join(" ")}`,
);
}
} else {
if (moduleName === "console") continue;
if (moduleName === "fs") continue;
if (SKIP[`${moduleName}.${k}`]) continue;
try {
// console.log(`trying ${moduleName}.${k}...`);
await mod[k]();
await Bun.sleep(1);
} catch (err: any) {
if ((err?.message as string).includes("not yet implemented")) {
missing = true;
console.log(` [${moduleName}.${k}] Not implemented.`);
}
}
}
}
}
if (!missing) {
console.log(`[${moduleName}] Fully implemented.`);
}
}
console.log("\n\n================\nDONE.");
process.exit();

View File

@@ -1,4 +1,5 @@
{
"name": "bun",
"dependencies": {
"@vscode/debugadapter": "^1.61.0",
"esbuild": "^0.17.15",
@@ -26,7 +27,7 @@
"@types/react": "^18.0.25",
"@typescript-eslint/eslint-plugin": "^5.31.0",
"@typescript-eslint/parser": "^5.31.0",
"bun-webkit": "0.0.1-4d995edbc44062b251be638818edcd88d7d14dd7"
"bun-webkit": "0.0.1-1a49a1f94bf42ab4f8c6b11d7bbbb21e491d2d62"
},
"version": "0.0.0",
"prettier": "./.prettierrc.cjs"

View File

@@ -5,7 +5,7 @@ import { spawnSync } from "node:child_process";
run().catch(console.error);
async function run() {
const cwd = new URL("../protocol/", import.meta.url);
const cwd = new URL("../src/protocol/", import.meta.url);
const runner = "Bun" in globalThis ? "bunx" : "npx";
const write = (name: string, data: string) => {
const path = new URL(name, cwd);

View File

@@ -638,7 +638,7 @@ export namespace DAP {
*/
export type BreakpointLocationsRequest = {
/**
* The source location of the breakpoints; either `source.path` or `source.reference` must be specified.
* The source location of the breakpoints; either `source.path` or `source.sourceReference` must be specified.
*/
source: Source;
/**
@@ -1139,6 +1139,12 @@ export namespace DAP {
* The value should be less than or equal to 2147483647 (2^31-1).
*/
indexedVariables?: number;
/**
* A memory reference to a location appropriate for this result.
* For pointer type eval results, this is generally a reference to the memory address contained in the pointer.
* This attribute may be returned by a debug adapter if corresponding capability `supportsMemoryReferences` is true.
*/
memoryReference?: string;
};
/**
* Arguments for `source` request.
@@ -1286,7 +1292,7 @@ export namespace DAP {
/**
* A memory reference to a location appropriate for this result.
* For pointer type eval results, this is generally a reference to the memory address contained in the pointer.
* This attribute should be returned by a debug adapter if corresponding capability `supportsMemoryReferences` is true.
* This attribute may be returned by a debug adapter if corresponding capability `supportsMemoryReferences` is true.
*/
memoryReference?: string;
};
@@ -1344,6 +1350,12 @@ export namespace DAP {
* The value should be less than or equal to 2147483647 (2^31-1).
*/
indexedVariables?: number;
/**
* A memory reference to a location appropriate for this result.
* For pointer type eval results, this is generally a reference to the memory address contained in the pointer.
* This attribute may be returned by a debug adapter if corresponding capability `supportsMemoryReferences` is true.
*/
memoryReference?: string;
};
/**
* Arguments for `stepInTargets` request.
@@ -2064,8 +2076,10 @@ export namespace DAP {
*/
indexedVariables?: number;
/**
* The memory reference for the variable if the variable represents executable code, such as a function pointer.
* This attribute is only required if the corresponding capability `supportsMemoryReferences` is true.
* A memory reference associated with this variable.
* For pointer type variables, this is generally a reference to the memory address contained in the pointer.
* For executable data, this reference may later be used in a `disassemble` request.
* This attribute may be returned by a debug adapter if corresponding capability `supportsMemoryReferences` is true.
*/
memoryReference?: string;
};

View File

@@ -108,7 +108,7 @@
{ "$ref": "#/definitions/Request" },
{
"type": "object",
"description": "The `cancel` request is used by the client in two situations:\n- to indicate that it is no longer interested in the result produced by a specific request issued earlier\n- to cancel a progress sequence. Clients should only call this request if the corresponding capability `supportsCancelRequest` is true.\nThis request has a hint characteristic: a debug adapter can only be expected to make a 'best effort' in honoring this request but there are no guarantees.\nThe `cancel` request may return an error if it could not cancel an operation but a client should refrain from presenting this error to end users.\nThe request that got cancelled still needs to send a response back. This can either be a normal result (`success` attribute true) or an error response (`success` attribute false and the `message` set to `cancelled`).\nReturning partial results from a cancelled request is possible but please note that a client has no generic way for detecting that a response is partial or not.\nThe progress that got cancelled still needs to send a `progressEnd` event back.\n A client should not assume that progress just got cancelled after sending the `cancel` request.",
"description": "The `cancel` request is used by the client in two situations:\n- to indicate that it is no longer interested in the result produced by a specific request issued earlier\n- to cancel a progress sequence.\nClients should only call this request if the corresponding capability `supportsCancelRequest` is true.\nThis request has a hint characteristic: a debug adapter can only be expected to make a 'best effort' in honoring this request but there are no guarantees.\nThe `cancel` request may return an error if it could not cancel an operation but a client should refrain from presenting this error to end users.\nThe request that got cancelled still needs to send a response back. This can either be a normal result (`success` attribute true) or an error response (`success` attribute false and the `message` set to `cancelled`).\nReturning partial results from a cancelled request is possible but please note that a client has no generic way for detecting that a response is partial or not.\nThe progress that got cancelled still needs to send a `progressEnd` event back.\n A client should not assume that progress just got cancelled after sending the `cancel` request.",
"properties": {
"command": { "type": "string", "enum": ["cancel"] },
"arguments": { "$ref": "#/definitions/CancelArguments" }
@@ -1074,7 +1074,7 @@
"properties": {
"source": {
"$ref": "#/definitions/Source",
"description": "The source location of the breakpoints; either `source.path` or `source.reference` must be specified."
"description": "The source location of the breakpoints; either `source.path` or `source.sourceReference` must be specified."
},
"line": {
"type": "integer",
@@ -2035,6 +2035,10 @@
"indexedVariables": {
"type": "integer",
"description": "The number of indexed child variables.\nThe client can use this information to present the variables in a paged UI and fetch them in chunks.\nThe value should be less than or equal to 2147483647 (2^31-1)."
},
"memoryReference": {
"type": "string",
"description": "A memory reference to a location appropriate for this result.\nFor pointer type eval results, this is generally a reference to the memory address contained in the pointer.\nThis attribute may be returned by a debug adapter if corresponding capability `supportsMemoryReferences` is true."
}
},
"required": ["value"]
@@ -2326,7 +2330,7 @@
},
"memoryReference": {
"type": "string",
"description": "A memory reference to a location appropriate for this result.\nFor pointer type eval results, this is generally a reference to the memory address contained in the pointer.\nThis attribute should be returned by a debug adapter if corresponding capability `supportsMemoryReferences` is true."
"description": "A memory reference to a location appropriate for this result.\nFor pointer type eval results, this is generally a reference to the memory address contained in the pointer.\nThis attribute may be returned by a debug adapter if corresponding capability `supportsMemoryReferences` is true."
}
},
"required": ["result", "variablesReference"]
@@ -2397,6 +2401,10 @@
"indexedVariables": {
"type": "integer",
"description": "The number of indexed child variables.\nThe client can use this information to present the variables in a paged UI and fetch them in chunks.\nThe value should be less than or equal to 2147483647 (2^31-1)."
},
"memoryReference": {
"type": "string",
"description": "A memory reference to a location appropriate for this result.\nFor pointer type eval results, this is generally a reference to the memory address contained in the pointer.\nThis attribute may be returned by a debug adapter if corresponding capability `supportsMemoryReferences` is true."
}
},
"required": ["value"]
@@ -3240,7 +3248,7 @@
},
"memoryReference": {
"type": "string",
"description": "The memory reference for the variable if the variable represents executable code, such as a function pointer.\nThis attribute is only required if the corresponding capability `supportsMemoryReferences` is true."
"description": "A memory reference associated with this variable.\nFor pointer type variables, this is generally a reference to the memory address contained in the pointer.\nFor executable data, this reference may later be used in a `disassemble` request.\nThis attribute may be returned by a debug adapter if corresponding capability `supportsMemoryReferences` is true."
}
},
"required": ["name", "value", "variablesReference"]
@@ -3299,8 +3307,8 @@
"Indicates that the object is a constant.",
"Indicates that the object is read only.",
"Indicates that the object is a raw string.",
"Indicates that the object can have an Object ID created for it.",
"Indicates that the object has an Object ID associated with it.",
"Indicates that the object can have an Object ID created for it. This is a vestigial attribute that is used by some clients; 'Object ID's are not specified in the protocol.",
"Indicates that the object has an Object ID associated with it. This is a vestigial attribute that is used by some clients; 'Object ID's are not specified in the protocol.",
"Indicates that the evaluation had side effects.",
"Indicates that the object has its value tracked by a data breakpoint."
]

View File

@@ -1,3 +0,0 @@
.DS_Store
node_modules
tmp

View File

@@ -1,7 +0,0 @@
# bun-ecosystem
A registry to test `npm` packages using Bun. This can be used as a tool to find bugs in Bun by running the test suites of these packages. In the future, we will run theses tests to catch regressions between releases.
```sh
bun run test
```

Binary file not shown.

View File

@@ -1,15 +0,0 @@
{
"name": "bun-ecosystem-ci",
"private": true,
"dependencies": {
"globby": "^13.1.3"
},
"devDependencies": {
"bun-types": "canary",
"prettier": "^2.8.2"
},
"scripts": {
"format": "prettier --write src",
"test": "bun run src/runner.ts"
}
}

View File

@@ -1,69 +0,0 @@
export type Package = {
readonly name: string;
readonly repository: string;
readonly cwd?: string;
readonly tests?: {
readonly style: "jest" | "ava" | "tape" | "custom";
readonly include: string[];
readonly exclude?: string[];
readonly disabled?: boolean;
};
};
export const packages: Package[] = [
{
name: "lodash",
repository: github("lodash/lodash"),
tests: {
style: "jest",
include: ["test/*.js"],
exclude: [
"debounce.test.js", // hangs runner
"size.test.js", // require('vm').runInNewContext()
"merge.test.js", // failing
],
},
},
{
name: "chalk",
repository: github("chalk/chalk"),
tests: {
style: "ava",
include: ["test/*.js"],
},
},
{
name: "request",
repository: github("request/request"),
tests: {
style: "tape",
include: ["tests/*.js"],
},
},
{
name: "commander",
repository: github("tj/commander.js"),
tests: {
style: "jest",
include: ["tests/*.js"],
},
},
{
name: "express",
repository: github("expressjs/express"),
tests: {
style: "jest",
include: ["test/**/*.js"],
exclude: [
"test/res.sendStatus.js", // https://github.com/oven-sh/bun/issues/887
"test/Route.js", // https://github.com/oven-sh/bun/issues/2030
],
// Most tests fail due to lack of "http2"
disabled: true,
},
},
];
function github(repository: string): string {
return `git@github.com:${repository}.git`;
}

View File

@@ -1,92 +0,0 @@
import type { Package } from "./packages";
import { packages } from "./packages";
import { existsSync, copyFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { globby } from "globby";
for (const pkg of packages) {
try {
await loadPackage(pkg, "tmp");
} catch (error) {
console.error(pkg.name, error);
}
}
async function loadPackage(pkg: Package, cwd?: string): Promise<void> {
await gitClone({
cwd,
repository: pkg.repository,
name: pkg.name,
});
const dir = join(cwd ?? "", pkg.name, pkg.cwd ?? "");
await spawn({
cwd: dir,
cmd: ["bun", "install"],
});
if (!pkg.tests || pkg.tests.style !== "jest") {
return;
}
const files = await globby(pkg.tests.include, {
cwd: dir,
ignore: pkg.tests.exclude ?? [crypto.randomUUID()],
onlyFiles: true,
caseSensitiveMatch: false,
});
if (!files.length) {
throw new Error("No tests found");
}
for (const file of files) {
let path = file;
if (!file.includes(".test.")) {
const ext = path.lastIndexOf(".");
path = file.substring(0, ext) + ".test" + file.substring(ext);
copyFileSync(join(dir, file), join(dir, path));
}
await spawn({
cwd: dir,
cmd: ["bun", "test", path],
});
}
}
type GitCloneOptions = {
repository: string;
cwd?: string;
name?: string;
};
async function gitClone(options: GitCloneOptions): Promise<void> {
const name = options.name ?? dirname(options.repository);
const cwd = options.cwd ?? process.cwd();
const path = join(cwd, name);
if (existsSync(path)) {
await spawn({
cwd: path,
cmd: ["git", "pull"],
});
} else {
const url = `${options.repository}`;
await spawn({
cwd,
cmd: ["git", "clone", "--single-branch", "--depth", "1", url, name],
});
}
}
type SpawnOptions = {
cwd: string;
cmd: string[];
};
async function spawn({ cwd, cmd }: SpawnOptions) {
const { exited } = await Bun.spawn({
cwd,
cmd,
stdout: "inherit",
stderr: "inherit",
});
const exitCode = await exited;
if (exitCode !== 0) {
throw new Error(`"${cmd.join(" ")}" exited with ${exitCode}`);
}
}

View File

@@ -1,16 +0,0 @@
{
"compilerOptions": {
"lib": ["ESNext"],
"module": "ESNext",
"target": "ESNext",
"moduleResolution": "node",
"types": ["bun-types"],
"esModuleInterop": true,
"allowJs": true,
"strict": true,
"resolveJsonModule": true
},
"include": [
"src"
]
}

View File

@@ -5,7 +5,7 @@ import { spawnSync } from "node:child_process";
run().catch(console.error);
async function run() {
const cwd = new URL("../protocol/", import.meta.url);
const cwd = new URL("../src/protocol/", import.meta.url);
const runner = "Bun" in globalThis ? "bunx" : "npx";
const write = (name: string, data: string) => {
const path = new URL(name, cwd);

View File

@@ -1136,7 +1136,8 @@ export namespace V8 {
| "Canceled"
| "RpPageNotVisible"
| "SilentMediationFailure"
| "ThirdPartyCookiesBlocked";
| "ThirdPartyCookiesBlocked"
| "NotSignedInWithIdp";
export type FederatedAuthUserInfoRequestIssueDetails = {
federatedAuthUserInfoRequestIssueReason: FederatedAuthUserInfoRequestIssueReason;
};
@@ -1192,6 +1193,25 @@ export namespace V8 {
*/
failedRequestInfo?: FailedRequestInfo | undefined;
};
export type PropertyRuleIssueReason = "InvalidSyntax" | "InvalidInitialValue" | "InvalidInherits" | "InvalidName";
/**
* This issue warns about errors in property rules that lead to property
* registrations being ignored.
*/
export type PropertyRuleIssueDetails = {
/**
* Source code position of the property rule.
*/
sourceCodeLocation: SourceCodeLocation;
/**
* Reason why the property rule was discarded.
*/
propertyRuleIssueReason: PropertyRuleIssueReason;
/**
* The value of the property rule property that failed to parse
*/
propertyValue?: string | undefined;
};
/**
* A unique identifier for the type of issue. Each type may use one of the
* optional fields in InspectorIssueDetails to convey more specific
@@ -1215,7 +1235,8 @@ export namespace V8 {
| "FederatedAuthRequestIssue"
| "BounceTrackingIssue"
| "StylesheetLoadingIssue"
| "FederatedAuthUserInfoRequestIssue";
| "FederatedAuthUserInfoRequestIssue"
| "PropertyRuleIssue";
/**
* This struct holds a list of optional fields with additional information
* specific to the kind of issue. When adding a new issue code, please also
@@ -1239,6 +1260,7 @@ export namespace V8 {
federatedAuthRequestIssueDetails?: FederatedAuthRequestIssueDetails | undefined;
bounceTrackingIssueDetails?: BounceTrackingIssueDetails | undefined;
stylesheetLoadingIssueDetails?: StylesheetLoadingIssueDetails | undefined;
propertyRuleIssueDetails?: PropertyRuleIssueDetails | undefined;
federatedAuthUserInfoRequestIssueDetails?: FederatedAuthUserInfoRequestIssueDetails | undefined;
};
/**
@@ -1390,16 +1412,82 @@ export namespace V8 {
*/
name: string;
/**
* address field name, for example Jon Doe.
* address field value, for example Jon Doe.
*/
value: string;
};
/**
* A list of address fields.
*/
export type AddressFields = {
fields: AddressField[];
};
export type Address = {
/**
* fields and values defining a test address.
* fields and values defining an address.
*/
fields: AddressField[];
};
/**
* Defines how an address can be displayed like in chrome://settings/addresses.
* Address UI is a two dimensional array, each inner array is an "address information line", and when rendered in a UI surface should be displayed as such.
* The following address UI for instance:
* [[{name: "GIVE_NAME", value: "Jon"}, {name: "FAMILY_NAME", value: "Doe"}], [{name: "CITY", value: "Munich"}, {name: "ZIP", value: "81456"}]]
* should allow the receiver to render:
* Jon Doe
* Munich 81456
*/
export type AddressUI = {
/**
* A two dimension array containing the repesentation of values from an address profile.
*/
addressFields: AddressFields[];
};
/**
* Specified whether a filled field was done so by using the html autocomplete attribute or autofill heuristics.
*/
export type FillingStrategy = "autocompleteAttribute" | "autofillInferred";
export type FilledField = {
/**
* The type of the field, e.g text, password etc.
*/
htmlType: string;
/**
* the html id
*/
id: string;
/**
* the html name
*/
name: string;
/**
* the field value
*/
value: string;
/**
* The actual field type, e.g FAMILY_NAME
*/
autofillType: string;
/**
* The filling strategy
*/
fillingStrategy: FillingStrategy;
};
/**
* Emitted when an address form is filled.
* @event `Autofill.addressFormFilled`
*/
export type AddressFormFilledEvent = {
/**
* Information about the fields that were filled
*/
filledFields: FilledField[];
/**
* An UI representation of the address used to fill the form.
* Consists of a 2D array where each child represents an address/profile line.
*/
addressUi: AddressUI;
};
/**
* Trigger autofill on a form identified by the fieldId.
* If the field and related form cannot be autofilled, returns an error.
@@ -1437,6 +1525,26 @@ export namespace V8 {
* @response `Autofill.setAddresses`
*/
export type SetAddressesResponse = {};
/**
* Disables autofill domain notifications.
* @request `Autofill.disable`
*/
export type DisableRequest = {};
/**
* Disables autofill domain notifications.
* @response `Autofill.disable`
*/
export type DisableResponse = {};
/**
* Enables autofill domain notifications.
* @request `Autofill.enable`
*/
export type EnableRequest = {};
/**
* Enables autofill domain notifications.
* @response `Autofill.enable`
*/
export type EnableResponse = {};
}
export namespace BackgroundService {
/**
@@ -3573,6 +3681,25 @@ export namespace V8 {
* @response `CSS.setEffectivePropertyValueForNode`
*/
export type SetEffectivePropertyValueForNodeResponse = {};
/**
* Modifies the property rule property name.
* @request `CSS.setPropertyRulePropertyName`
*/
export type SetPropertyRulePropertyNameRequest = {
styleSheetId: StyleSheetId;
range: SourceRange;
propertyName: string;
};
/**
* Modifies the property rule property name.
* @response `CSS.setPropertyRulePropertyName`
*/
export type SetPropertyRulePropertyNameResponse = {
/**
* The resulting key text after modification.
*/
propertyName: Value;
};
/**
* Modifies the keyframe rule key text.
* @request `CSS.setKeyframeKey`
@@ -7168,6 +7295,16 @@ export namespace V8 {
* @response `EventBreakpoints.removeInstrumentationBreakpoint`
*/
export type RemoveInstrumentationBreakpointResponse = {};
/**
* Removes all breakpoints
* @request `EventBreakpoints.disable`
*/
export type DisableRequest = {};
/**
* Removes all breakpoints
* @response `EventBreakpoints.disable`
*/
export type DisableResponse = {};
}
export namespace FedCm {
/**
@@ -7178,7 +7315,7 @@ export namespace V8 {
/**
* Whether the dialog shown is an account chooser or an auto re-authentication dialog.
*/
export type DialogType = "AccountChooser" | "AutoReauthn" | "ConfirmIdpSignin";
export type DialogType = "AccountChooser" | "AutoReauthn" | "ConfirmIdpLogin";
/**
* Corresponds to IdentityRequestAccount
*/
@@ -7189,7 +7326,7 @@ export namespace V8 {
givenName: string;
pictureUrl: string;
idpConfigUrl: string;
idpSigninUrl: string;
idpLoginUrl: string;
loginState: LoginState;
/**
* These two are only set if the loginState is signUp
@@ -7252,6 +7389,20 @@ export namespace V8 {
* @response `FedCm.selectAccount`
*/
export type SelectAccountResponse = {};
/**
* Only valid if the dialog type is ConfirmIdpLogin. Acts as if the user had
* clicked the continue button.
* @request `FedCm.confirmIdpLogin`
*/
export type ConfirmIdpLoginRequest = {
dialogId: string;
};
/**
* Only valid if the dialog type is ConfirmIdpLogin. Acts as if the user had
* clicked the continue button.
* @response `FedCm.confirmIdpLogin`
*/
export type ConfirmIdpLoginResponse = {};
/**
* undefined
* @request `FedCm.dismissDialog`
@@ -10477,6 +10628,7 @@ export namespace V8 {
| "ch-ect"
| "ch-prefers-color-scheme"
| "ch-prefers-reduced-motion"
| "ch-prefers-reduced-transparency"
| "ch-rtt"
| "ch-save-data"
| "ch-ua"
@@ -13109,7 +13261,6 @@ export namespace V8 {
| "LowEndDevice"
| "InvalidSchemeRedirect"
| "InvalidSchemeNavigation"
| "InProgressNavigation"
| "NavigationRequestBlockedByCsp"
| "MainFrameNavigation"
| "MojoBinderPolicy"
@@ -13121,7 +13272,6 @@ export namespace V8 {
| "NavigationBadHttpStatus"
| "ClientCertRequested"
| "NavigationRequestNetworkError"
| "MaxNumOfRunningPrerendersExceeded"
| "CancelAllHostsForTesting"
| "DidFailLoad"
| "Stop"
@@ -13133,9 +13283,8 @@ export namespace V8 {
| "MixedContent"
| "TriggerBackgrounded"
| "MemoryLimitExceeded"
| "FailToGetMemoryUsage"
| "DataSaverEnabled"
| "HasEffectiveUrl"
| "TriggerUrlHasEffectiveUrl"
| "ActivatedBeforeStarted"
| "InactivePageRestriction"
| "StartFailed"
@@ -13166,7 +13315,13 @@ export namespace V8 {
| "PrerenderingDisabledByDevTools"
| "ResourceLoadBlockedByClient"
| "SpeculationRuleRemoved"
| "ActivatedWithAuxiliaryBrowsingContexts";
| "ActivatedWithAuxiliaryBrowsingContexts"
| "MaxNumOfRunningEagerPrerendersExceeded"
| "MaxNumOfRunningNonEagerPrerendersExceeded"
| "MaxNumOfRunningEmbedderPrerendersExceeded"
| "PrerenderingUrlHasEffectiveUrl"
| "RedirectedPrerenderingUrlHasEffectiveUrl"
| "ActivationUrlHasEffectiveUrl";
/**
* Preloading status values, see also PreloadingTriggeringOutcome. This
* status is shared by prefetchStatusUpdated and prerenderStatusUpdated.
@@ -13221,24 +13376,6 @@ export namespace V8 {
export type RuleSetRemovedEvent = {
id: RuleSetId;
};
/**
* Fired when a prerender attempt is completed.
* @event `Preload.prerenderAttemptCompleted`
*/
export type PrerenderAttemptCompletedEvent = {
key: PreloadingAttemptKey;
/**
* The frame id of the frame initiating prerendering.
*/
initiatingFrameId: Page.FrameId;
prerenderingUrl: string;
finalStatus: PrerenderFinalStatus;
/**
* This is used to give users more information about the name of the API call
* that is incompatible with prerender and has caused the cancellation of the attempt
*/
disallowedApiMethod?: string | undefined;
};
/**
* Fired when a preload enabled state is updated.
* @event `Preload.preloadEnabledStateUpdated`
@@ -13935,12 +14072,21 @@ export namespace V8 {
/**
* Enum of interest group access types.
*/
export type InterestGroupAccessType = "join" | "leave" | "update" | "loaded" | "bid" | "win";
export type InterestGroupAccessType =
| "join"
| "leave"
| "update"
| "loaded"
| "bid"
| "win"
| "additionalBid"
| "additionalBidWin"
| "clear";
/**
* Ad advertising element inside an interest group.
*/
export type InterestGroupAd = {
renderUrl: string;
renderURL: string;
metadata?: string | undefined;
};
/**
@@ -13951,10 +14097,10 @@ export namespace V8 {
name: string;
expirationTime: Network.TimeSinceEpoch;
joiningOrigin: string;
biddingUrl?: string | undefined;
biddingWasmHelperUrl?: string | undefined;
updateUrl?: string | undefined;
trustedBiddingSignalsUrl?: string | undefined;
biddingLogicURL?: string | undefined;
biddingWasmHelperURL?: string | undefined;
updateURL?: string | undefined;
trustedBiddingSignalsURL?: string | undefined;
trustedBiddingSignalsKeys: string[];
userBiddingSignals?: string | undefined;
ads: InterestGroupAd[];
@@ -14099,20 +14245,27 @@ export namespace V8 {
key: string;
value: UnsignedInt128AsBase16;
};
export type AttributionReportingEventReportWindows = {
/**
* duration in seconds
*/
start: number;
/**
* duration in seconds
*/
ends: number[];
};
export type AttributionReportingSourceRegistration = {
time: Network.TimeSinceEpoch;
/**
* duration in seconds
*/
expiry?: number | undefined;
expiry: number;
eventReportWindows: AttributionReportingEventReportWindows;
/**
* duration in seconds
*/
eventReportWindow?: number | undefined;
/**
* duration in seconds
*/
aggregatableReportWindow?: number | undefined;
aggregatableReportWindow: number;
type: AttributionReportingSourceType;
sourceOrigin: string;
reportingOrigin: string;
@@ -16381,6 +16534,7 @@ export namespace V8 {
"Animation.animationCreated": Animation.AnimationCreatedEvent;
"Animation.animationStarted": Animation.AnimationStartedEvent;
"Audits.issueAdded": Audits.IssueAddedEvent;
"Autofill.addressFormFilled": Autofill.AddressFormFilledEvent;
"BackgroundService.recordingStateChanged": BackgroundService.RecordingStateChangedEvent;
"BackgroundService.backgroundServiceEventReceived": BackgroundService.BackgroundServiceEventReceivedEvent;
"Browser.downloadWillBegin": Browser.DownloadWillBeginEvent;
@@ -16460,7 +16614,6 @@ export namespace V8 {
"PerformanceTimeline.timelineEventAdded": PerformanceTimeline.TimelineEventAddedEvent;
"Preload.ruleSetUpdated": Preload.RuleSetUpdatedEvent;
"Preload.ruleSetRemoved": Preload.RuleSetRemovedEvent;
"Preload.prerenderAttemptCompleted": Preload.PrerenderAttemptCompletedEvent;
"Preload.preloadEnabledStateUpdated": Preload.PreloadEnabledStateUpdatedEvent;
"Preload.prefetchStatusUpdated": Preload.PrefetchStatusUpdatedEvent;
"Preload.prerenderStatusUpdated": Preload.PrerenderStatusUpdatedEvent;
@@ -16533,6 +16686,8 @@ export namespace V8 {
"Audits.checkFormsIssues": Audits.CheckFormsIssuesRequest;
"Autofill.trigger": Autofill.TriggerRequest;
"Autofill.setAddresses": Autofill.SetAddressesRequest;
"Autofill.disable": Autofill.DisableRequest;
"Autofill.enable": Autofill.EnableRequest;
"BackgroundService.startObserving": BackgroundService.StartObservingRequest;
"BackgroundService.stopObserving": BackgroundService.StopObservingRequest;
"BackgroundService.setRecording": BackgroundService.SetRecordingRequest;
@@ -16583,6 +16738,7 @@ export namespace V8 {
"CSS.trackComputedStyleUpdates": CSS.TrackComputedStyleUpdatesRequest;
"CSS.takeComputedStyleUpdates": CSS.TakeComputedStyleUpdatesRequest;
"CSS.setEffectivePropertyValueForNode": CSS.SetEffectivePropertyValueForNodeRequest;
"CSS.setPropertyRulePropertyName": CSS.SetPropertyRulePropertyNameRequest;
"CSS.setKeyframeKey": CSS.SetKeyframeKeyRequest;
"CSS.setMediaText": CSS.SetMediaTextRequest;
"CSS.setContainerQueryText": CSS.SetContainerQueryTextRequest;
@@ -16705,9 +16861,11 @@ export namespace V8 {
"Emulation.setAutomationOverride": Emulation.SetAutomationOverrideRequest;
"EventBreakpoints.setInstrumentationBreakpoint": EventBreakpoints.SetInstrumentationBreakpointRequest;
"EventBreakpoints.removeInstrumentationBreakpoint": EventBreakpoints.RemoveInstrumentationBreakpointRequest;
"EventBreakpoints.disable": EventBreakpoints.DisableRequest;
"FedCm.enable": FedCm.EnableRequest;
"FedCm.disable": FedCm.DisableRequest;
"FedCm.selectAccount": FedCm.SelectAccountRequest;
"FedCm.confirmIdpLogin": FedCm.ConfirmIdpLoginRequest;
"FedCm.dismissDialog": FedCm.DismissDialogRequest;
"FedCm.resetCooldown": FedCm.ResetCooldownRequest;
"Fetch.disable": Fetch.DisableRequest;
@@ -16979,6 +17137,8 @@ export namespace V8 {
"Audits.checkFormsIssues": Audits.CheckFormsIssuesResponse;
"Autofill.trigger": Autofill.TriggerResponse;
"Autofill.setAddresses": Autofill.SetAddressesResponse;
"Autofill.disable": Autofill.DisableResponse;
"Autofill.enable": Autofill.EnableResponse;
"BackgroundService.startObserving": BackgroundService.StartObservingResponse;
"BackgroundService.stopObserving": BackgroundService.StopObservingResponse;
"BackgroundService.setRecording": BackgroundService.SetRecordingResponse;
@@ -17029,6 +17189,7 @@ export namespace V8 {
"CSS.trackComputedStyleUpdates": CSS.TrackComputedStyleUpdatesResponse;
"CSS.takeComputedStyleUpdates": CSS.TakeComputedStyleUpdatesResponse;
"CSS.setEffectivePropertyValueForNode": CSS.SetEffectivePropertyValueForNodeResponse;
"CSS.setPropertyRulePropertyName": CSS.SetPropertyRulePropertyNameResponse;
"CSS.setKeyframeKey": CSS.SetKeyframeKeyResponse;
"CSS.setMediaText": CSS.SetMediaTextResponse;
"CSS.setContainerQueryText": CSS.SetContainerQueryTextResponse;
@@ -17151,9 +17312,11 @@ export namespace V8 {
"Emulation.setAutomationOverride": Emulation.SetAutomationOverrideResponse;
"EventBreakpoints.setInstrumentationBreakpoint": EventBreakpoints.SetInstrumentationBreakpointResponse;
"EventBreakpoints.removeInstrumentationBreakpoint": EventBreakpoints.RemoveInstrumentationBreakpointResponse;
"EventBreakpoints.disable": EventBreakpoints.DisableResponse;
"FedCm.enable": FedCm.EnableResponse;
"FedCm.disable": FedCm.DisableResponse;
"FedCm.selectAccount": FedCm.SelectAccountResponse;
"FedCm.confirmIdpLogin": FedCm.ConfirmIdpLoginResponse;
"FedCm.dismissDialog": FedCm.DismissDialogResponse;
"FedCm.resetCooldown": FedCm.ResetCooldownResponse;
"Fetch.disable": Fetch.DisableResponse;

View File

@@ -1091,7 +1091,8 @@
"Canceled",
"RpPageNotVisible",
"SilentMediationFailure",
"ThirdPartyCookiesBlocked"
"ThirdPartyCookiesBlocked",
"NotSignedInWithIdp"
]
},
{
@@ -1163,6 +1164,34 @@
}
]
},
{
"id": "PropertyRuleIssueReason",
"type": "string",
"enum": ["InvalidSyntax", "InvalidInitialValue", "InvalidInherits", "InvalidName"]
},
{
"id": "PropertyRuleIssueDetails",
"description": "This issue warns about errors in property rules that lead to property\nregistrations being ignored.",
"type": "object",
"properties": [
{
"name": "sourceCodeLocation",
"description": "Source code position of the property rule.",
"$ref": "SourceCodeLocation"
},
{
"name": "propertyRuleIssueReason",
"description": "Reason why the property rule was discarded.",
"$ref": "PropertyRuleIssueReason"
},
{
"name": "propertyValue",
"description": "The value of the property rule property that failed to parse",
"optional": true,
"type": "string"
}
]
},
{
"id": "InspectorIssueCode",
"description": "A unique identifier for the type of issue. Each type may use one of the\noptional fields in InspectorIssueDetails to convey more specific\ninformation about the kind of issue.",
@@ -1185,7 +1214,8 @@
"FederatedAuthRequestIssue",
"BounceTrackingIssue",
"StylesheetLoadingIssue",
"FederatedAuthUserInfoRequestIssue"
"FederatedAuthUserInfoRequestIssue",
"PropertyRuleIssue"
]
},
{
@@ -1227,6 +1257,7 @@
},
{ "name": "bounceTrackingIssueDetails", "optional": true, "$ref": "BounceTrackingIssueDetails" },
{ "name": "stylesheetLoadingIssueDetails", "optional": true, "$ref": "StylesheetLoadingIssueDetails" },
{ "name": "propertyRuleIssueDetails", "optional": true, "$ref": "PropertyRuleIssueDetails" },
{
"name": "federatedAuthUserInfoRequestIssueDetails",
"optional": true,
@@ -1344,20 +1375,76 @@
"type": "object",
"properties": [
{ "name": "name", "description": "address field name, for example GIVEN_NAME.", "type": "string" },
{ "name": "value", "description": "address field name, for example Jon Doe.", "type": "string" }
{ "name": "value", "description": "address field value, for example Jon Doe.", "type": "string" }
]
},
{
"id": "AddressFields",
"description": "A list of address fields.",
"type": "object",
"properties": [{ "name": "fields", "type": "array", "items": { "$ref": "AddressField" } }]
},
{
"id": "Address",
"type": "object",
"properties": [
{
"name": "fields",
"description": "fields and values defining a test address.",
"description": "fields and values defining an address.",
"type": "array",
"items": { "$ref": "AddressField" }
}
]
},
{
"id": "AddressUI",
"description": "Defines how an address can be displayed like in chrome://settings/addresses.\nAddress UI is a two dimensional array, each inner array is an \"address information line\", and when rendered in a UI surface should be displayed as such.\nThe following address UI for instance:\n[[{name: \"GIVE_NAME\", value: \"Jon\"}, {name: \"FAMILY_NAME\", value: \"Doe\"}], [{name: \"CITY\", value: \"Munich\"}, {name: \"ZIP\", value: \"81456\"}]]\nshould allow the receiver to render:\nJon Doe\nMunich 81456",
"type": "object",
"properties": [
{
"name": "addressFields",
"description": "A two dimension array containing the repesentation of values from an address profile.",
"type": "array",
"items": { "$ref": "AddressFields" }
}
]
},
{
"id": "FillingStrategy",
"description": "Specified whether a filled field was done so by using the html autocomplete attribute or autofill heuristics.",
"type": "string",
"enum": ["autocompleteAttribute", "autofillInferred"]
},
{
"id": "FilledField",
"type": "object",
"properties": [
{ "name": "htmlType", "description": "The type of the field, e.g text, password etc.", "type": "string" },
{ "name": "id", "description": "the html id", "type": "string" },
{ "name": "name", "description": "the html name", "type": "string" },
{ "name": "value", "description": "the field value", "type": "string" },
{ "name": "autofillType", "description": "The actual field type, e.g FAMILY_NAME", "type": "string" },
{ "name": "fillingStrategy", "description": "The filling strategy", "$ref": "FillingStrategy" }
]
}
],
"events": [
{
"name": "addressFormFilled",
"description": "Emitted when an address form is filled.",
"parameters": [
{
"name": "filledFields",
"description": "Information about the fields that were filled",
"type": "array",
"items": { "$ref": "FilledField" }
},
{
"name": "addressUi",
"description": "An UI representation of the address used to fill the form.\nConsists of a 2D array where each child represents an address/profile line.",
"$ref": "AddressUI"
}
]
}
],
"commands": [
@@ -1387,7 +1474,9 @@
"name": "setAddresses",
"description": "Set addresses so that developers can verify their forms implementation.",
"parameters": [{ "name": "addresses", "type": "array", "items": { "$ref": "Address" } }]
}
},
{ "name": "disable", "description": "Disables autofill domain notifications." },
{ "name": "enable", "description": "Enables autofill domain notifications." }
]
},
{
@@ -3211,6 +3300,18 @@
{ "name": "value", "type": "string" }
]
},
{
"name": "setPropertyRulePropertyName",
"description": "Modifies the property rule property name.",
"parameters": [
{ "name": "styleSheetId", "$ref": "StyleSheetId" },
{ "name": "range", "$ref": "SourceRange" },
{ "name": "propertyName", "type": "string" }
],
"returns": [
{ "name": "propertyName", "description": "The resulting key text after modification.", "$ref": "Value" }
]
},
{
"name": "setKeyframeKey",
"description": "Modifies the keyframe rule key text.",
@@ -4628,7 +4729,7 @@
{
"domain": "DOMDebugger",
"description": "DOM debugging allows setting breakpoints on particular DOM operations and events. JavaScript\nexecution will stop on these operations as if there was a regular breakpoint set.",
"dependencies": ["DOM", "Debugger", "Runtime"],
"dependencies": ["DOM", "Runtime"],
"types": [
{
"id": "DOMBreakpointType",
@@ -4738,6 +4839,8 @@
"name": "removeInstrumentationBreakpoint",
"description": "Removes breakpoint on particular native event.",
"experimental": true,
"deprecated": true,
"redirect": "EventBreakpoints",
"parameters": [{ "name": "eventName", "description": "Instrumentation name to stop on.", "type": "string" }]
},
{
@@ -4788,6 +4891,8 @@
"name": "setInstrumentationBreakpoint",
"description": "Sets breakpoint on particular native event.",
"experimental": true,
"deprecated": true,
"redirect": "EventBreakpoints",
"parameters": [{ "name": "eventName", "description": "Instrumentation name to stop on.", "type": "string" }]
},
{
@@ -6069,7 +6174,7 @@
},
{
"domain": "EventBreakpoints",
"description": "EventBreakpoints permits setting breakpoints on particular operations and\nevents in targets that run JavaScript but do not have a DOM.\nJavaScript execution will stop on these operations as if there was a regular\nbreakpoint set.",
"description": "EventBreakpoints permits setting JavaScript breakpoints on operations and events\noccurring in native code invoked from JavaScript. Once breakpoint is hit, it is\nreported through Debugger domain, similarly to regular breakpoints being hit.",
"experimental": true,
"commands": [
{
@@ -6081,7 +6186,8 @@
"name": "removeInstrumentationBreakpoint",
"description": "Removes breakpoint on particular native event.",
"parameters": [{ "name": "eventName", "description": "Instrumentation name to stop on.", "type": "string" }]
}
},
{ "name": "disable", "description": "Removes all breakpoints" }
]
},
{
@@ -6099,7 +6205,7 @@
"id": "DialogType",
"description": "Whether the dialog shown is an account chooser or an auto re-authentication dialog.",
"type": "string",
"enum": ["AccountChooser", "AutoReauthn", "ConfirmIdpSignin"]
"enum": ["AccountChooser", "AutoReauthn", "ConfirmIdpLogin"]
},
{
"id": "Account",
@@ -6112,7 +6218,7 @@
{ "name": "givenName", "type": "string" },
{ "name": "pictureUrl", "type": "string" },
{ "name": "idpConfigUrl", "type": "string" },
{ "name": "idpSigninUrl", "type": "string" },
{ "name": "idpLoginUrl", "type": "string" },
{ "name": "loginState", "$ref": "LoginState" },
{
"name": "termsOfServiceUrl",
@@ -6160,6 +6266,11 @@
{ "name": "accountIndex", "type": "integer" }
]
},
{
"name": "confirmIdpLogin",
"description": "Only valid if the dialog type is ConfirmIdpLogin. Acts as if the user had\nclicked the continue button.",
"parameters": [{ "name": "dialogId", "type": "string" }]
},
{
"name": "dismissDialog",
"parameters": [
@@ -6987,16 +7098,14 @@
{
"name": "tiltX",
"description": "The plane angle between the Y-Z plane and the plane containing both the stylus axis and the Y axis, in degrees of the range [-90,90], a positive tiltX is to the right (default: 0)",
"experimental": true,
"optional": true,
"type": "integer"
"type": "number"
},
{
"name": "tiltY",
"description": "The plane angle between the X-Z plane and the plane containing both the stylus axis and the X axis, in degrees of the range [-90,90], a positive tiltY is towards the user (default: 0).",
"experimental": true,
"optional": true,
"type": "integer"
"type": "number"
},
{
"name": "twist",
@@ -7280,16 +7389,14 @@
{
"name": "tiltX",
"description": "The plane angle between the Y-Z plane and the plane containing both the stylus axis and the Y axis, in degrees of the range [-90,90], a positive tiltX is to the right (default: 0).",
"experimental": true,
"optional": true,
"type": "integer"
"type": "number"
},
{
"name": "tiltY",
"description": "The plane angle between the X-Z plane and the plane containing both the stylus axis and the X axis, in degrees of the range [-90,90], a positive tiltY is towards the user (default: 0).",
"experimental": true,
"optional": true,
"type": "integer"
"type": "number"
},
{
"name": "twist",
@@ -9158,6 +9265,7 @@
"ch-ect",
"ch-prefers-color-scheme",
"ch-prefers-reduced-motion",
"ch-prefers-reduced-transparency",
"ch-rtt",
"ch-save-data",
"ch-ua",
@@ -11403,7 +11511,6 @@
"LowEndDevice",
"InvalidSchemeRedirect",
"InvalidSchemeNavigation",
"InProgressNavigation",
"NavigationRequestBlockedByCsp",
"MainFrameNavigation",
"MojoBinderPolicy",
@@ -11415,7 +11522,6 @@
"NavigationBadHttpStatus",
"ClientCertRequested",
"NavigationRequestNetworkError",
"MaxNumOfRunningPrerendersExceeded",
"CancelAllHostsForTesting",
"DidFailLoad",
"Stop",
@@ -11427,9 +11533,8 @@
"MixedContent",
"TriggerBackgrounded",
"MemoryLimitExceeded",
"FailToGetMemoryUsage",
"DataSaverEnabled",
"HasEffectiveUrl",
"TriggerUrlHasEffectiveUrl",
"ActivatedBeforeStarted",
"InactivePageRestriction",
"StartFailed",
@@ -11460,7 +11565,13 @@
"PrerenderingDisabledByDevTools",
"ResourceLoadBlockedByClient",
"SpeculationRuleRemoved",
"ActivatedWithAuxiliaryBrowsingContexts"
"ActivatedWithAuxiliaryBrowsingContexts",
"MaxNumOfRunningEagerPrerendersExceeded",
"MaxNumOfRunningNonEagerPrerendersExceeded",
"MaxNumOfRunningEmbedderPrerendersExceeded",
"PrerenderingUrlHasEffectiveUrl",
"RedirectedPrerenderingUrlHasEffectiveUrl",
"ActivationUrlHasEffectiveUrl"
]
},
{
@@ -11515,26 +11626,6 @@
"parameters": [{ "name": "ruleSet", "$ref": "RuleSet" }]
},
{ "name": "ruleSetRemoved", "parameters": [{ "name": "id", "$ref": "RuleSetId" }] },
{
"name": "prerenderAttemptCompleted",
"description": "Fired when a prerender attempt is completed.",
"parameters": [
{ "name": "key", "$ref": "PreloadingAttemptKey" },
{
"name": "initiatingFrameId",
"description": "The frame id of the frame initiating prerendering.",
"$ref": "Page.FrameId"
},
{ "name": "prerenderingUrl", "type": "string" },
{ "name": "finalStatus", "$ref": "PrerenderFinalStatus" },
{
"name": "disallowedApiMethod",
"description": "This is used to give users more information about the name of the API call\nthat is incompatible with prerender and has caused the cancellation of the attempt",
"optional": true,
"type": "string"
}
]
},
{
"name": "preloadEnabledStateUpdated",
"description": "Fired when a preload enabled state is updated.",
@@ -12077,14 +12168,14 @@
"id": "InterestGroupAccessType",
"description": "Enum of interest group access types.",
"type": "string",
"enum": ["join", "leave", "update", "loaded", "bid", "win"]
"enum": ["join", "leave", "update", "loaded", "bid", "win", "additionalBid", "additionalBidWin", "clear"]
},
{
"id": "InterestGroupAd",
"description": "Ad advertising element inside an interest group.",
"type": "object",
"properties": [
{ "name": "renderUrl", "type": "string" },
{ "name": "renderURL", "type": "string" },
{ "name": "metadata", "optional": true, "type": "string" }
]
},
@@ -12097,10 +12188,10 @@
{ "name": "name", "type": "string" },
{ "name": "expirationTime", "$ref": "Network.TimeSinceEpoch" },
{ "name": "joiningOrigin", "type": "string" },
{ "name": "biddingUrl", "optional": true, "type": "string" },
{ "name": "biddingWasmHelperUrl", "optional": true, "type": "string" },
{ "name": "updateUrl", "optional": true, "type": "string" },
{ "name": "trustedBiddingSignalsUrl", "optional": true, "type": "string" },
{ "name": "biddingLogicURL", "optional": true, "type": "string" },
{ "name": "biddingWasmHelperURL", "optional": true, "type": "string" },
{ "name": "updateURL", "optional": true, "type": "string" },
{ "name": "trustedBiddingSignalsURL", "optional": true, "type": "string" },
{ "name": "trustedBiddingSignalsKeys", "type": "array", "items": { "type": "string" } },
{ "name": "userBiddingSignals", "optional": true, "type": "string" },
{ "name": "ads", "type": "array", "items": { "$ref": "InterestGroupAd" } },
@@ -12275,20 +12366,24 @@
{ "name": "value", "$ref": "UnsignedInt128AsBase16" }
]
},
{
"id": "AttributionReportingEventReportWindows",
"experimental": true,
"type": "object",
"properties": [
{ "name": "start", "description": "duration in seconds", "type": "integer" },
{ "name": "ends", "description": "duration in seconds", "type": "array", "items": { "type": "integer" } }
]
},
{
"id": "AttributionReportingSourceRegistration",
"experimental": true,
"type": "object",
"properties": [
{ "name": "time", "$ref": "Network.TimeSinceEpoch" },
{ "name": "expiry", "description": "duration in seconds", "optional": true, "type": "integer" },
{ "name": "eventReportWindow", "description": "duration in seconds", "optional": true, "type": "integer" },
{
"name": "aggregatableReportWindow",
"description": "duration in seconds",
"optional": true,
"type": "integer"
},
{ "name": "expiry", "description": "duration in seconds", "type": "integer" },
{ "name": "eventReportWindows", "$ref": "AttributionReportingEventReportWindows" },
{ "name": "aggregatableReportWindow", "description": "duration in seconds", "type": "integer" },
{ "name": "type", "$ref": "AttributionReportingSourceType" },
{ "name": "sourceOrigin", "type": "string" },
{ "name": "reportingOrigin", "type": "string" },

View File

@@ -46,7 +46,10 @@ export function objectPreviewToString(objectPreview: JSC.Runtime.ObjectPreview):
items = entries.map(entryPreviewToString).sort();
} else if (properties) {
if (isIndexed(subtype)) {
items = properties.map(indexedPropertyPreviewToString).sort();
items = properties.map(indexedPropertyPreviewToString);
if (subtype !== "array") {
items.sort();
}
} else {
items = properties.map(namedPropertyPreviewToString).sort();
}

Some files were not shown because too many files have changed in this diff Show More