Compare commits

...

366 Commits

Author SHA1 Message Date
John-David Dalton
8843060a24 feat: add support for remaining private methods and webkit upgrade 2024-04-08 13:50:55 -04:00
Jarred Sumner
5baa2fbb87 Use a different cache dir in each test file 2024-04-08 07:39:21 -07:00
Jarred Sumner
2615dc742e Partial fix for #10028 (#10030)
* Partial fix for #10028

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-04-08 07:32:43 -07:00
Jarred Sumner
a4e8534779 Use a separate cache dir for this test 2024-04-08 07:31:05 -07:00
Jarred Sumner
9380e99e2b Fixes #9952 (#10069)
* Fixes #9952

* Update CMakeLists.txt

* Update CMakeLists.txt

* linux

* isolate this test
2024-04-08 07:27:07 -07:00
Yoav Balasiano
9898e0a731 Improve bun shell docs examples (#10052) 2024-04-08 06:48:21 -07:00
Juan Pablo Rinaldi
ad6aadf7b2 Fix coverage documentation (#10059) 2024-04-08 06:47:43 -07:00
Jarred Sumner
ee05bae2be Make bun install 60% faster on Windows, improve reliability, reduce memory usage (#10037)
* [bundows] Make bun install 60% faster

* [autofix.ci] apply automated fixes

* Do not keep node_modules folder open between async tasks. Make sure we call runTasks on every event loop wakeup.

* Update install.zig

* Fix deadlock

* Make that deadlock impossible

* a little less repetitive

* Fix test failure with local tarball

* Get those tests to pass

* Normalize absolutely

* lets see how many times we call GetFinalPathNameByHandle

* Workaround https://github.com/ziglang/zig/issues/19586

https://github.com/ziglang/zig/issues/19586

* Is the dev-server-100 test failure a hash table collision?

* Give it its own cache dir

* We cannot change the git task ids

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-04-08 06:25:24 -07:00
Jarred Sumner
d615c11a57 Force non-zero exit code whenever bun install has any packages which failed to install (#10041)
* If any failed to install, always exit with non-zero

* [autofix.ci] apply automated fixes

* This test should fail

* Update bun-link.test.ts

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-04-07 16:12:16 -07:00
Jarred Sumner
3679f69b70 Disable assertion on Windows 2024-04-06 15:19:52 -07:00
Tomer Horowitz
0b0bf353fa docs: Updated Bun.nanoseconds documentation (#9986) 2024-04-06 02:47:47 -07:00
Giorgio Bellisario
c4847f464e fix typo: missing "v" prefix on installed Bun version (#9941) 2024-04-05 19:17:32 -07:00
Jarred Sumner
c8d072c2a9 Fixes #9978 (#9995) 2024-04-05 17:42:34 -07:00
dave caruso
f014f35531 fix(windows): use bun.spawnSync for bun upgrade + different check for bun (#10006)
* small changes

* [autofix.ci] apply automated fixes

* fxifsdahjfkdsahjk

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-04-05 17:30:32 -07:00
Meghan Denny
fd3cd05647 shell: more builtin commands (#9908)
* remove asString and improve fromString

* make writeNoIO return Maybe

* shell: add builtin command 'yes'

* shell: add builtin command 'seq'

* shell: yes+seq: fix usage string

* shell: add builtin command 'dirname'

* shell: add builtin command 'basename'

* add more tests

* update shell docs with list of commands

* add 'bun exec' launch configurations

* fix AsyncDeinitReader name

* fix 'yes' command IO

* shell: rewrite 'bun' to 'bun-debug' when self is bun-debug

* make the docs not lie about bun being a shell builtin

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-04-05 16:29:50 -07:00
Jarred Sumner
20085d8ddc Merge conflict fix 2024-04-05 15:41:45 -07:00
Jarred Sumner
5735feac5d Redo file watcher + Fix EBUSY when saving lockfile on Windows (#9972)
* Fix `EBUSY` when saving lockfile on Windows

* Redo file watcher wrapper on Windows

* Update lockfile.zig

* Update win_watcher.zig

* Update src/bun.js/node/node_fs.zig

Co-authored-by: Ciro Spaciari <ciro.spaciari@gmail.com>

* Add retry logic

* Comments

* more careful

* smaller

* Fix garbage

* Normalize the paths

* hmmm

* [autofix.ci] apply automated fixes

* try

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Ciro Spaciari <ciro.spaciari@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-04-05 15:40:05 -07:00
dave caruso
4ba993be7e fix(install.ps1): change cpu check (#9921) 2024-04-05 15:35:46 -07:00
sitiom
0b2bb1fdc1 docs: add scoop installation method (#9818)
* docs: add scoop installation method

* Update installation.md

* Add upgrade and uninstall instructions

* Update installation.md

* add ps prompt to code blocks

---------

Co-authored-by: dave caruso <me@paperdave.net>
2024-04-05 14:55:19 -07:00
Dylan Conway
b29cf75a24 fix(install): allow installing without lockfile with --production (#9923)
* check for not_found lockfile load result

* Fix tests

* update tests

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-04-05 14:54:57 -07:00
Eric L. Goldstein
05fb044577 Add types for node:util styleText() (#9945) 2024-04-05 13:31:50 -07:00
Jarred Sumner
8825b29529 bump webkit (#9997)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-04-05 12:09:27 -07:00
Dylan Conway
182b90896f fix(parser): handle empty type parameters and conditional union/intersection bugfix (#9964)
* tests

* allow_empty_type_parameters

* pass options through unions and intersections
2024-04-05 00:45:43 -07:00
Zack Radisic
40e33da4b4 Fixes (#9940) 2024-04-04 19:46:53 -07:00
Jarred Sumner
f393f8a065 bun install launch.json 2024-04-04 19:31:10 -07:00
Jarred Sumner
a09c421f2a ```sh-diff doesn't work 2024-04-04 08:48:51 -07:00
Jarred Sumner
ca1dbb4eb2 Revert "remove ENABLE_VIRTUAL_TERMINAL_INPUT (#9913)" (#9935)
This reverts commit 06ec233ebe.
2024-04-04 07:34:33 -07:00
Jarred Sumner
8a3b6f0439 Fixes #6730 (#9930)
* Fixes #6730

* Fix test

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-04-04 07:26:53 -07:00
Jarred Sumner
e7d8abb263 Don't recommend something that doesn't work on windows 2024-04-04 04:51:53 -07:00
Dylan Conway
013bc79f62 ignore EndOfStream error (#9926) 2024-04-04 04:31:47 -07:00
Jarred Sumner
8326235ecc Ask for fewer permissions when opening directories (#9928)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-04-04 04:18:15 -07:00
Jarred Sumner
7543bf936a Add missing HasStaticPropertyTable structure flag 2024-04-04 01:36:18 -07:00
Dylan Conway
06ec233ebe remove ENABLE_VIRTUAL_TERMINAL_INPUT (#9913) 2024-04-04 00:30:20 -07:00
dave caruso
0cdad4bebb fix(bun-release): support windows in npm package (#9873)
* fix npm install on windows

* try again

* again

* copy less file

* revert changes

* remove package.json from git

* okay

* now?
2024-04-03 23:16:48 -07:00
Ashcon Partovi
14c23cc429 Define BUN_INSTALL_BIN in Dockerfiles
Fixes #8753
2024-04-04 13:24:53 +09:00
Ashcon Partovi
0dfbdc711a Remove python3 from slim and alpine Dockerfiles to match Node.js 2024-04-04 13:22:41 +09:00
Ashcon Partovi
3cde2365ea Do not format Dockerfiles 2024-04-04 13:22:11 +09:00
dave caruso
3cfb2816ac docs 2024-04-03 21:11:15 -07:00
Jarred Sumner
c8f5c9f29c Fixes #9851 (#9886)
* Fixes #9851

* Fix

* Fix
2024-04-03 21:02:02 -07:00
Jarred Sumner
00f27fbeec Get bunx tests to pass on Windows (#9729)
* Get bunx tests to pass on Windows

* wip

* WIP

* wip

* wip

* ads

* asdf

* makeOpenPath

* almost revert

* fix build

* enoent

* fix bun install git repos

* cleanup

* use custom zig stdlib from submodule

* update dockerfile to copy zig stdlib sources

* fix dockerfile, update gitmodules

* fix dockerfile

* fix build

* fix build

* fix symlinkat

* fix build

* fix build

* Remove usages of unreachable

* Fixup

* Fixup

* wip

* fixup

* Fix one of the bugs

* asd

* Normalize BUN_INSTALL_CACHE_DIR var

* Set iterable to false when we're about to delete

* Update bun.zig

* I still can't repro this outside CI

* i think that fixes it?

* fix posix compile

* factor out directory creation

* update all install methods to use InstallDirState

* move walker creation to init function

* fix error cleanup

* fix posix compile

* all install tests pass locally

* cleanup

* [autofix.ci] apply automated fixes

* Fix posix regressions

---------

Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
Co-authored-by: Meghan Denny <hello@nektro.net>
Co-authored-by: Georgijs Vilums <georgijs.vilums@gmail.com>
Co-authored-by: Georgijs <48869301+gvilums@users.noreply.github.com>
Co-authored-by: Georgijs Vilums <georgijs@bun.sh>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-04-03 20:53:28 -07:00
Jarred Sumner
76795af695 Fixes https://github.com/oven-sh/bun/issues/9807 (#9875)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-04-03 20:27:50 -07:00
Zack Radisic
a4b151962a feat: Support subshells in Bun shell (#9905)
* fix #9823

* subshell

* Refactor a bit and add a lot of tests

* delete random code

* make tests pass on windows

* Cleanup

* add sharp test

* Resolve comments

---------

Co-authored-by: Georgijs Vilums <georgijs.vilums@gmail.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-04-03 20:27:20 -07:00
Ciro Spaciari
1cde9bcdac fix(server) fix body-stream (#9898)
* some fixes

* WIP

* wip wip

* more debug

* closer

* sending a really big payload at once is still broken

* now we need to avoid segfault happening inside onWritable after destroy

* opsie

* cleanup

* more cleanup

* more WIP, closer need to fix cork

* fix cork actually not writing non-optional data

* make onWritable return actually do something

* actually clean the on writable handler

* remove unreachable condition

* we are not looping anymore

* little revert

* fix possible fault

* inform backpressure on chunked encoding

* just queue when tryEnd

* remove unreachable code
2024-04-03 20:25:05 -07:00
Eric L. Goldstein
0bd7265e8f Remove documentation references to environment variable inlining because the bundler does not do so (#9901) 2024-04-03 18:14:20 -07:00
Dylan Conway
c831dd8db8 Upgrade webkit (#9885)
* span

* remove JSStringIsEqualToString

* bump webkit tag

* span literal

* undo

* fix windows build

* Update JSStringDecoder.cpp

* Update JSStringDecoder.cpp

* Update JSStringDecoder.cpp

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-04-03 17:10:39 -07:00
Jarred Sumner
390441327f Fixes #9778 (#9834)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-04-03 02:47:31 -07:00
Jarred Sumner
2e0e9f135b Fixes #9878 (#9883)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-04-03 02:47:13 -07:00
Jarred Sumner
36f1bd3694 Truncate source lines in error messages (#9832)
* Truncate source lines in error messages

* Update .prettierignore

* trim

* fix

* try

* fix

* 1 more time

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-04-03 02:46:10 -07:00
Ciro Spaciari
289d23b377 fix(uws) uWS uintmax_t > uint64_t (#9866)
* wip check this on Posix, probably better to used fixed types on uWS instead of uintmax_t here

* uintmax_t > u64
2024-04-03 01:57:33 -07:00
Meghan Denny
bb483e8479 shell: implement $0, $1, argv accessors (#9740)
* shell: organize imports

* shell: dont allocate when printing errors

* shell: implement $0, $1, argv accessors

* add more tests

* oops need this commit too

* make these logs listen to silencing logs

* expand switch else statements

* align behavior with bash

* this isnt referenced anywhere

* add missing test file

* add another test

* revert this change

* cache utf8 converted version of positionals

* rebase fixes

---------

Co-authored-by: Georgijs Vilums <georgijs.vilums@gmail.com>
2024-04-02 23:07:27 -07:00
Meghan Denny
268f13765c ci: windows: use bun install (#9730)
* ci: windows: use bun install

* run the workflow

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-04-02 17:57:44 -07:00
Georgijs Vilums
801e475c72 update readme again 2024-04-01 09:37:48 -07:00
Georgijs Vilums
a073c85fdb update readme to include windows install command 2024-04-01 09:35:03 -07:00
dave caruso
8cb9f59753 update installation docs 2024-04-01 09:30:47 -07:00
dave caruso
5903a61410 Bun 1.1 2024-04-01 08:57:05 -07:00
dave caruso
b4941cdb0c not canary 2024-04-01 08:55:21 -07:00
Jarred Sumner
58417217d6 Tweak cleanup code in PipeReader for files (#9746)
* WIP: some fixes and improvements

* cleanup

* WIP: some fixes and improvements

* cleanup

* dont pause

---------

Co-authored-by: cirospaciari <ciro.spaciari@gmail.com>
2024-04-01 08:53:39 -07:00
Jarred Sumner
2d57f25637 Bump 2024-04-01 08:52:24 -07:00
cirospaciari
83a99bf190 revert 2024-04-01 12:14:47 -03:00
cirospaciari
e2ffa66bf7 dont pause 2024-04-01 12:12:44 -03:00
Meghan Denny
8980dc026d shell: fix crash in 'ls' and other misc improvements (#9772)
* shell: ls: fix crash when passing argument

* shell: pwd: output was missing newline

* shell: exit: output was missing newline

* shell: pwd: make sure output goes to proper stdout/stderr

* add test ensuring all those work

* fix build error

* fix

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: dave caruso <me@paperdave.net>
2024-04-01 07:54:42 -07:00
Jarred Sumner
4192728592 fix build (#9773)
Co-authored-by: cirospaciari <ciro.spaciari@gmail.com>
2024-04-01 07:11:02 -07:00
Meghan Denny
bdfbcb1898 use bun shell for lifecycle scripts on windows [v3] (#9771)
* these comments were redundant

* better windows support here

* slightly better error message

* didnt realize this variable already existed

* fix node-gyp shim script

* move 'windows bin linking shim should work' to its own file

* run all lifecycle scripts on windows with bun shell

* tidy

* clean imports

* this seemed missing

* remove these comments

* fix the shim again

* fix posix release ensureTempNodeGypScript

* revert this change, it was correct before
2024-04-01 06:48:44 -07:00
Dylan Conway
6e07f9477c fix(streams): don't lose bytes on drain (#9768)
* fix

* clear

* update

* test

* fix test

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-04-01 05:23:47 -07:00
dave caruso
2dd2fc6ed0 install script 2024-04-01 04:02:26 -07:00
dave caruso
9e6e8b0234 feat(runtime): align import.meta.resolve with node.js's implementation (#5827)
* works

* works

* a

* fix zig compiler error

* fix things

* [autofix.ci] apply automated fixes

* a

* not done

* finish this

* [autofix.ci] apply automated fixes

* self check

* delete committed generated file (#9717)

* Fix bug with PipeWriter (#9714)

* fix!: do not lookup cwd in which (#9691)

* do not lookup cwd in which

* fix webkit submodule

* fix compilation on linux

* feedback

* default process.env.NODE_ENV to undefined (#9695)

* small changes

* [autofix.ci] apply automated fixes

* fix(windows) fix node-stream tests/ windows file reader/writer (#9718)

* fix canceled onFileRead

* report continue errors and fix closing

* also fix pipe writer

* avoid possible memory leaks

* Propagate errors in open

---------

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

* posix failures

* windows fixes

* avoid using c++ labels

* add a resolver

* fix compile test AGAIN

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Meghan Denny <hello@nektro.net>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Ciro Spaciari <ciro.spaciari@gmail.com>
2024-04-01 02:21:34 -07:00
Zack Radisic
d53e6d6323 feat: Shell if-else, conditional expressions, running commands in background (#9631)
* rename conditional -> binary

* Parse if clauses

* `if` works

* Conditional expressions

* Support If clause condition and branches multi-statements

* cond expr tests

* more

* Fix parse tests

* `&` commands

* clean up

* Make it compile for windows

* Fix test

* Remove If/Else/Elif/Then/Fi tokens

* Fix parsing ambiguities

* Resolve some comments

* More tests fix bugs

* Fix parsing and add more tests ported from GNU bash

* Fix `&`on left side of `&&` error message

* leak test fix hopefully

* todo some tests because `wait` is not implemented

* Disable background commands for now

* Resolve additional comments

* Fix merge conflicts

* Fix broken tests from merge

* Add `==` and `!=` and fix parsing bug

* wow

* fix 09401 test failing... forgot to update `this.inlined.len`

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-04-01 02:07:52 -07:00
Ashcon Partovi
1edacc6e49 Prepare npm i -g bun for Windows 2024-04-01 18:00:16 +09:00
dave caruso
81badbac4c fix(ipc): add json ipc type + buffer incoming messages until a listener is attached. (#8733)
* fix a few ipc issues

* a

* my own revisions

* remove none as a valid type

* a

* fix windows build

* remove comment

* make it work !!!!!!!!

* a

* formatter nonsense

* blah

* huge update refactor

* awa

* wow

* okay
2024-04-01 01:51:15 -07:00
Zack Radisic
7531bfbfe0 add bun exec (#9762)
* add `bun exec`

* Add tests for writing a lot of data for bun exec

* Resolve some comments

* fix on windows
2024-04-01 00:57:19 -07:00
Georgijs
1a989c9ad2 ref tls socket on upgrade (#9766)
Co-authored-by: Zack Radisic <zack@theradisic.com>
2024-03-31 21:32:25 -07:00
Chawye Hsu
ab7825cca5 windows: fix bun pm bin -g path not added complaining (#9763)
Signed-off-by: Chawye Hsu <su+git@chawyehsu.com>
2024-03-31 17:55:36 -07:00
dave caruso
f02752577b fix: which should use cwd if given a relative filepath (#9761)
* Revert "fix!: do not lookup cwd in which (#9691)"

This reverts commit 4869ebff24.

* fix which implementation to be more accurate

* t

* which tests windows

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-03-31 16:50:16 -07:00
dave caruso
c177e054f5 feat!: shell will now throw on error by default (#9720)
* make the shell throw by default

* make shell default to throws(true)

* ok

* mv tests

* a

* a

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-03-31 16:13:59 -07:00
dave caruso
a01b01ae72 chore!: enable 1.1's breaking changes (#9724)
* root scripts in foreground

* ignore if silent

* test for breaking changes

* move back to installPackages

* [autofix.ci] apply automated fixes

* boolean variable, comptime, 1_1_0

* flip the 1.1 flag

* add for the next batch of breakings

* make it buidl

* enable breaking changes tests

* fix version fmt

* silent node-gyp

* comment change

---------

Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
2024-03-31 16:12:59 -07:00
dave caruso
456a32344e windows: skip cleaning up old binary (#9696) 2024-03-31 16:12:21 -07:00
Jarred Sumner
6164fac256 Revert "pipe.signal.ptr == subprocess.stdin, not subprocess"
This reverts commit 4bbcc39d2f.
2024-03-30 22:55:28 -07:00
Jarred Sumner
4bbcc39d2f pipe.signal.ptr == subprocess.stdin, not subprocess 2024-03-30 22:10:26 -07:00
Meghan Denny
62c8c97e24 add test.todoIf and fix bun-install-registry.test.ts on windows (#9723)
* bun:test: implement test.todoIf and describe.todoIf

* fix bun-install-registry.test.ts and mark some as todo

* add even more tests

* remove todoIf from this file

* [autofix.ci] apply automated fixes

* fix regression

* this extra expect was incorrect

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-03-30 21:25:05 -07:00
Jarred Sumner
eb708d34ae Fixes #9748 (#9751)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-30 21:23:34 -07:00
Jarred Sumner
c3ba60eef5 Fixes #9739 (#9752)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-30 20:57:40 -07:00
Meghan Denny
7f71f10ad1 import-meta.test.js: isolate the query param test into separate cases for esm and cjs (#9750)
* import-meta.test.js: isolate the query param test into separate cases for esm and cos

* make name more accurate
2024-03-30 20:09:01 -07:00
Jarred Sumner
9939049b85 Fixes #5319 (#9745)
* Fixes #5319

* Make this test better

* another test

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-30 20:08:34 -07:00
Meghan Denny
a5c5b5dc61 console-iterator.test.ts: add a case that only uses latin1 characters (#9749) 2024-03-30 18:16:10 -07:00
Ciro Spaciari
a2835ef098 fix(websockets) fix socket/websockets (#9645)
* repro

* cleanup

* avoid shutdownRead on SSL

* still dont fix

* more

* some ssl

* cleanup

* handle shutdown

* make actually pass the tests

* fix STATUS_STACK_BUFFER_OVERRUN?

* revert some, cleanup fetch.tls.test

* make clear why we need on_handshake when closing

* more

* revert

* cleanup

* cleanup + less Bun.gc

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-03-30 16:32:19 -07:00
Jarred Sumner
31c4c59740 Make duplicate simultaneous bun install work better (#9738)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-30 14:06:37 -07:00
Jarred Sumner
0248e3c2b7 Add NODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT=1 (#9742)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-30 14:03:52 -07:00
Jarred Sumner
d869fcee21 Fixes #7896 (#9712)
* Fixes #7896

* Update ws.test.ts

* Delete the old one

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-30 04:27:00 -07:00
dave caruso
55f8ae5aea feat(windows): properly implement setRawMode (#9734)
* setRawMode rewrite for Windows

* work on posix using old approach

* [autofix.ci] apply automated fixes

* no print

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-03-30 04:06:23 -07:00
Meghan Denny
e414d107e6 ci: windows: show all failing files (#9736)
* ci: windows: show all failing files

* fix workflow variables

* fix workflow v2
2024-03-30 02:00:24 -07:00
Meghan Denny
0103e2df73 windows: pass bunshell.test.ts (#9733) 2024-03-30 01:58:28 -07:00
Jarred Sumner
02ad501f9e Add missing globs 2024-03-29 23:40:13 -07:00
saklani
d433a1ada0 fix: Define missing crypto.constants defined on Node (#9511)
* define crypto.constants

* requested changes

* fix: missing jsNumber wrap

---------

Co-authored-by: Georgijs <48869301+gvilums@users.noreply.github.com>
2024-03-29 21:53:52 -07:00
dave caruso
d712254128 internal: remove secret hidden internals and introduce new way to call native code from js (#8166)
* oooooh magic

* stuff

* run format

* ok

* yippee

* run the formatter back

* finish things up

* fix webkit

* more

* [autofix.ci] apply automated fixes

* fix compile

* fix compilation on windows, it seems to not work though :(

* update

* a

* v

* ok

* [autofix.ci] apply automated fixes

* OOPS

* bump bun to reduce ci bugs

* a

* js2native is done!

* improve array binding

* rebase

* some final stuff

* wasi fixes

* os

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-03-29 21:47:11 -07:00
Meghan Denny
a500c69728 shell: implement 'true' and 'false' builtin commands (#9728) 2024-03-29 21:36:13 -07:00
Dylan Conway
d30b53591f fix(napi): fix finalizer callback (#9732)
* fix finalize callback

* fix test
2024-03-29 21:33:48 -07:00
Meghan Denny
b8389f32ce shell: add 'exit' builtin command (#9705)
* shell: add 'exit' builtin command

* remove loop here

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-03-29 18:20:44 -07:00
Dylan Conway
7172013a72 fix(windows): use extended max path prefix for hardlinks during install (#9721)
* uncomment code

* use GetFinalPathNameByHandleW

* add packages with large names

* delete

* test large package name
2024-03-29 18:13:39 -07:00
Jarred Sumner
8ff7ee03d2 stdio tweaks (#9726) 2024-03-29 18:11:47 -07:00
dave caruso
5296c26dab fix bunx-bins verdaccio package (#9697)
* fix bunx-bins verdaccio package

* env suck

* [autofix.ci] apply automated fixes

* ugh

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-03-29 17:55:06 -07:00
Jarred Sumner
da6826e2b7 Unmark known failing 2024-03-29 17:49:29 -07:00
Jarred Sumner
a637b4c880 Unmark known failing 2024-03-29 17:49:03 -07:00
Ciro Spaciari
d9074dfa5d fix(windows) fix node-stream tests/ windows file reader/writer (#9718)
* fix canceled onFileRead

* report continue errors and fix closing

* also fix pipe writer

* avoid possible memory leaks

* Propagate errors in open

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-03-29 16:58:55 -07:00
dave caruso
ba9834d746 default process.env.NODE_ENV to undefined (#9695) 2024-03-29 16:42:50 -07:00
dave caruso
4869ebff24 fix!: do not lookup cwd in which (#9691)
* do not lookup cwd in which

* fix webkit submodule

* fix compilation on linux

* feedback
2024-03-29 16:42:17 -07:00
Jarred Sumner
a9804a3a11 Fix bug with PipeWriter (#9714) 2024-03-29 16:11:24 -07:00
Meghan Denny
6bedc23992 delete committed generated file (#9717) 2024-03-29 15:53:11 -07:00
dave caruso
093e9c2499 ci: does this fix the windows build (#9715)
* does this fix the windows build

* [autofix.ci] apply automated fixes

* a

* enable tar oop

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-03-29 15:20:13 -07:00
dave caruso
3047c9005e fix: add a better error message for fetch when it fails with an unknown code (#9663)
* add a better error message for fetch when it fails with an unknown code

* Update src/bun.js/webcore/response.zig

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

* [autofix.ci] apply automated fixes

* fix compilation

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-03-29 14:18:11 -07:00
Jarred Sumner
e80e61c9a3 Allow 0-length ArrayBuffer & Blob in Bun.spawn stdio (#9557)
Co-authored-by: Zack Radisic <zack@theradisic.com>
2024-03-29 13:51:45 -07:00
Meghan Denny
e3bf906127 memoize all calls to selfExePath (#9703)
* memoize all calls to selfExePath

* Fix threadsafety issue

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-29 13:29:42 -07:00
Walter
4e7ed173ef fix!: remove worker from default conditions (#9256)
Co-authored-by: Walter Blacke <walter.blacke@vegabyte.studio>
2024-03-29 13:22:42 -07:00
Jarred Sumner
31befad163 Workaround for #9041 (#9580)
* Workaround for #9041

* Fix crash with auto install

* Fixup this test

* Update 09041.test.ts

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-29 13:17:12 -07:00
Meghan Denny
94b01b2f45 test: pm: don't delete temporary directories (#9649) 2024-03-29 12:29:50 -07:00
PondWader
9ecb691380 Fix URL.canParse.length (#9710)
* Fix URL.canParse.length

* Add URL.canParse.length test

---------

Co-authored-by: John-David Dalton <john.david.dalton@gmail.com>
2024-03-29 12:21:49 -07:00
Meghan Denny
fb8a299765 shell: windows: make EnvMap case-insensitive (#9704)
* shell: windows: make EnvMap case-insensitive

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-03-29 12:21:09 -07:00
dave caruso
40f61ebb91 fix: EnvStr.initSlice handles zero length strings more reliably. (#9698)
* fix intcast on ptr value of zero-length strings

* Make this better

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-03-28 22:17:20 -07:00
Jarred Sumner
4512a04820 Add missing code to TextDecoder "Invalid byte sequence" error (#9700)
* Fix missing `ERR_ENCODING_INVALID_ENCODED_DATA` code in TextDecoder

* Update text-decoder.test.js

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-28 22:06:40 -07:00
Dylan Conway
1ad6a3dfb9 fix(http2): fix crash in http2 tests (#9676)
* add the settings

* dont crash on unsupported settings

* add missing property

* less flaky tests

* comment

* Update test/js/node/http2/node-echo-server.fixture.js

* Update test/js/node/http2/node-http2-memory-leak.js

* Update test/js/node/http2/node-http2-memory-leak.js

---------

Co-authored-by: cirospaciari <ciro.spaciari@gmail.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-03-28 21:39:40 -07:00
dave caruso
1ae9f998f4 alternate approach to env fix (#9689)
* alternate approach to env fix

* rename variable

* Revert "rename variable"

This reverts commit 2374bcd487.

* a

* we pass on window

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-03-28 21:30:49 -07:00
dave caruso
d113803777 add server ws.terminate (#9693)
* add server ws.terminate

* [autofix.ci] apply automated fixes

* it has to be blazing fast

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-03-28 18:17:55 -07:00
Jarred Sumner
aaef6d350a Fix unlikely edgecase in WebSocket client (#9694)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-28 17:45:39 -07:00
dave caruso
0751581e86 bump: Bun v1.0.36 2024-03-28 17:42:06 -07:00
Zack Radisic
c510daac55 Fix shell regressions part 2 (#9684)
* Fix undefined memory on subprocess exit immediately and fix crash when writing a lot of data

* format

* Test for #9458

* Document

* Lazily create iowriters (i think this solves fdleak tests?)

* Fix `big_data` test hanging

* I think this make leak tests more stable

* accidentally had deinit in another thread

* oops

* Fixes

* shell `big_data` test redirect to file

* stuff

* Fix windows /dev/null

* Increase timeout

* Resolve comments and better input test
2024-03-28 17:31:43 -07:00
Jarred Sumner
ec66b07720 Make bun meta more helpful (#9690)
* Make `bun meta` more helpful

* More tweaks

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-28 15:55:47 -07:00
dave caruso
b53147ad97 docs: update contributing page 2024-03-28 13:15:56 -07:00
Jarred Sumner
dea877f19b Revert "Fix some shell regressions (#9630)" (#9670)
This reverts commit aee8eeaf45.
2024-03-27 20:56:54 -07:00
Jarred Sumner
d66ace959d Use &= ~ instead of ^= 2024-03-27 20:27:16 -07:00
Jarred Sumner
db1283e982 Fixes #9669 2024-03-27 20:09:31 -07:00
Jarred Sumner
79ced2767a Let's try calling close_range CLOSE_RANGE_CLOEXEC starting on 4 instead of 0 2024-03-27 19:16:23 -07:00
Ashcon Partovi
081c7fff00 Add missing aliases to expect() types 2024-03-27 18:28:48 -07:00
Dylan Conway
8a12c2992b fix(windows): fix prompts.test.ts (#9650)
* remove comment

* fix prompt test

* more time like leaky case

* remove comments

* fixed

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-03-27 16:49:33 -07:00
Dylan Conway
306b87e929 fix(test): fix crash in expect.toHaveProperty (#9653)
* make sure string doesnt unref

* use String and assign to variable
2024-03-27 16:48:44 -07:00
Stefan Buhrmester
fcd7b01dba add await to Bun.plugin(...) (#9665) 2024-03-27 16:47:40 -07:00
Eduard
9f20d40678 Fix docs for dynamic linking of libatomic (#9646) 2024-03-27 15:01:41 -07:00
Ciro Spaciari
d030cce8bb fix(windows) socket and timers/performance tests (#9651)
* WIP missing keepalive

* cleanup

* is a Bun.sleep bug?

* no bun sleep

* fix exception

* revert

* fix setTimeout/Bun.sleep

* add Bun.sleep keepalive test

* fixes

* one more bonus fix

* fix early firing of timers

* use localhost and pass the server.hostname

* opsie
2024-03-27 10:31:12 -07:00
Zack Radisic
aee8eeaf45 Fix some shell regressions (#9630)
* Fix undefined memory on subprocess exit immediately and fix crash when writing a lot of data

* format

* Test for #9458

* Document

* Lazily create iowriters (i think this solves fdleak tests?)

* Fix `big_data` test hanging

* I think this make leak tests more stable

* accidentally had deinit in another thread

* oops

* Fixes

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-03-27 09:33:38 -07:00
Jarred Sumner
a9ad303fe2 Add test for fs.writev & fs.readv (#9632)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-27 09:00:39 -07:00
dave caruso
e808cdb725 windows: fix argument handling in bin shim (#9622)
* awa

* update v5

* a

* [autofix.ci] apply automated fixes

* tarball

* a

* a

* blah

* [autofix.ci] apply automated fixes

* bump

* wah

* [autofix.ci] apply automated fixes

* farther

* a

* [autofix.ci] apply automated fixes

* im confused

* [autofix.ci] apply automated fixes

* Fix typo (#9623)

* Fix crash in Bun.escapeHTML (#9619)

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>

* Fixes #9610

* Implement `fs.openAsBlob` (#9628)

* Implement `fs.openAsBlob`

* Use a function

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>

* Fix `bun install -g` not working on Docker
Closes #8753

* Revert "Fix `bun install -g` not working on Docker"

This reverts commit 20fce1a1be.

* what happens if nonblocking tty (#9608)

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>

* merge

* a

* blah

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: sequencerr <45060278+sequencerr@users.noreply.github.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Ashcon Partovi <ashcon@partovi.net>
2024-03-26 22:38:01 -07:00
Jarred Sumner
1675349667 what happens if nonblocking tty (#9608)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-26 13:53:58 -07:00
Ashcon Partovi
264b4be44a Revert "Fix bun install -g not working on Docker"
This reverts commit 20fce1a1be.
2024-03-26 10:41:28 -07:00
Ashcon Partovi
20fce1a1be Fix bun install -g not working on Docker
Closes #8753
2024-03-26 10:39:40 -07:00
Jarred Sumner
fa145b2218 Implement fs.openAsBlob (#9628)
* Implement `fs.openAsBlob`

* Use a function

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-25 17:21:11 -07:00
Jarred Sumner
c8cc134edb Fixes #9610 2024-03-25 15:17:45 -07:00
Jarred Sumner
d9b7b45080 Fix crash in Bun.escapeHTML (#9619)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-25 14:37:20 -07:00
sequencerr
43ab5313da Fix typo (#9623) 2024-03-25 14:26:47 -07:00
Dylan Conway
c7289b2cd6 fix(windows): fix a few more tests (#9550)
* fix napi tests

* only windows, update passing tests

* remove closing remainder

* fix child_process-node.test.js

* might fail in ci

* oops

* fix dns tests

* remove comment

* sometimes it is slow

* update test

* maybe fix timeout error

* one more try

* off by one, valid npm package name

* update test

* fix hot tests

* revert

* remove close
2024-03-25 13:34:08 -07:00
Dylan Conway
e39a7851c8 fix(install): package binary map bugfix (#9621) 2024-03-25 12:49:52 -07:00
Jarred Sumner
ccaacdc56c Fix incorrect GETFD and O_NONBLOCK setting (#9607)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-24 20:26:08 -07:00
Jarred Sumner
c57cd5b6cd Update shell.md 2024-03-24 18:44:06 -07:00
Jarred Sumner
c71325b52e Fix regression with console.log in --watch on linux (#9601)
* Fix regression with console.log in --watch on linux

* Unset CLOEXEC

* more

* Enable inheritance on windows

* Don't forget to close the handles...

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-24 18:38:41 -07:00
Jarred Sumner
2765347b65 Enable more C++ warnings (#9602)
* Enable more C++ warnings

* Only enable these ones in release builds

* Update MessagePortChannel.cpp

* Update BunProcess.cpp

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-24 17:28:58 -07:00
Jarred Sumner
39d1287f03 Port #9278 (#9596)
* Port #9278

Co-Authored-By: argosphil <argosphil@murena.io>

* Fix incorrect type

Co-Authored-By: argosphil <argosphil@murena.io>

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: argosphil <argosphil@murena.io>
2024-03-24 12:21:11 -07:00
Jarred Sumner
d8a09d8517 Remove known-failing-on-windows 2024-03-24 12:13:24 -07:00
Jarred Sumner
e8bb3389ef Tweak how we handle bun's process initialization (#9588)
* Tweak how we handle bun's process initialization

* Update panic_handler.zig

* Update output.zig

* Update __global.zig

* Update __global.zig

* Delete WindowsSpawnWorkaround, fix tests

* Fix bug in Bun.spawn on Linux when O_CLOEXEC is set on stdin stdout or stderr

* More errors

* tweak

* Bounds check

* Update install.zig

* Update dependency.zig

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Zack Radisic <zack@theradisic.com>
2024-03-24 12:09:16 -07:00
David Legrand
73fc225c4c docs: bun shell .sh loader fix (#9592)
`.sh` file loader is working with `.bun.sh` files, not `.sh` files as stated in the documentation
2024-03-24 11:17:00 -07:00
HT
0eb638c899 Update executables.md (#9593)
Bun build with `--compile` flag supports `--external` flag. Tested on bun `1.0.33` and it works
2024-03-24 11:15:19 -07:00
pfg
ee5fd51e88 Fix bundling for bun not using ascii_only (#9571)
* Fix bundling not using ascii_only

* add utf8 test to bundler_compile & make test source ascii

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-03-23 00:04:36 -07:00
dave caruso
73a55cf075 windows: make more windows tests pass (#9370)
* run-eval.test.ts

* transpiler-cache.test.ts

* node net

* some open things

* a

* a

* yikes

* incredible

* run it back

* a

* this code is what i like to call, incorrect

* ok its all worng

* remove an assertion that is wrong again

* update test things and rebase

* performance test

* mark filesink with mkfifo as todo. see #8166

* hehe

* not done

* awa

* fs test pass

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-03-22 23:40:45 -07:00
kunoka
32174a2a44 fix: added awaits in Bun.connect calls (#9574) 2024-03-22 20:46:50 -07:00
Xin Chen
71113182c2 fix(init): cannot find console in blank project (#9462)
* Fix cannot find console in default project

* Update src/cli/tsconfig-for-init.json

---------

Co-authored-by: dave caruso <me@paperdave.net>
2024-03-22 10:23:06 -07:00
Jarred Sumner
940448d6b6 add regression test 2024-03-22 07:58:27 -07:00
Jarred Sumner
be4b47d49d Fixes #9563 (#9566)
* Remove flag in a test

* Get this test file to run in jest again

* Fixes #9563

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-22 07:50:00 -07:00
Meghan Denny
f90bb7719b windows: test\js\bun\test\test-test.test.ts passes (#9554) 2024-03-22 00:34:53 -07:00
Jarred Sumner
7276ff9935 Make .decode(a, {stream :true}) slightly faster in TextDecoder 2024-03-22 00:30:50 -07:00
Jarred Sumner
2d61c865fc Replace some of std.ChildProcess with bun.spawnSync (#9513)
* Replace some of std.ChildProcess with bun.spawnSync

* Update process.zig

* Fix some build errors

* Fix linux build

* Keep error

* Don't print a mesasge in this case

* Update spawn.test.ts

* Make `bun install` faster on Linux

* Comments + edgecases

* Fix the tests

* Add bun install launch.json

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Zack Radisic <zack@theradisic.com>
2024-03-21 23:50:48 -07:00
Dylan Conway
7e3e7d2ed4 enable autoinstall, fixup tests (#9539) 2024-03-21 21:12:54 -07:00
Jarred Sumner
b24d3ba5be Fix build 2024-03-21 11:05:52 -07:00
Jarred Sumner
c6f22de360 Make the version number bigger 2024-03-21 10:44:18 -07:00
Jarred Sumner
e124f08caf A few fixes related to CommonJS module loading (#9540)
* Ensure we always deref the source code

* Move more work to concurrent transpiler

* Update NodeModuleModule.h

* Update string.zig

* Make `Bun.gc()` more effective

* Update text-loader-fixture-dynamic-import-stress.ts

* Update ZigSourceProvider.cpp

* Fixes #6946

* Update ModuleLoader.cpp

* Update ModuleLoader.cpp

* Fixes #8965

* Fixups

* Update ModuleLoader.cpp

* Update ModuleLoader.cpp

* Load it

* Update module_loader.zig

* Update module_loader.zig

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-21 10:42:57 -07:00
Jarred Sumner
0948727243 Fixes #9521 (#9530)
* Fixes #9521

* Another test

* Update load-file-loader-a-lot.test.ts

* Update module_loader.zig

* comments

* Rename variable

* Update module_loader.zig

* Update exports.zig

* small cleanup

* bundows

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-21 00:06:24 -07:00
Paul Eboselume
650dc552d4 fixed typo (#9535) 2024-03-20 20:04:05 -07:00
Dylan Conway
3e86b38f32 fix(windows): waiter thread tests (#9538)
* use Bun.sleepSync

* argv0
2024-03-20 20:03:17 -07:00
Ashcon Partovi
cc4479096a Update lockfiles 2024-03-20 09:16:01 -07:00
Ashcon Partovi
d14c99510c Change macOS version check to be a warning, instead of error 2024-03-20 09:09:29 -07:00
Paul Eboselume
e1e3e41e0f Fixed a typo (#9529) 2024-03-20 09:00:36 -07:00
Jarred Sumner
d9496c3802 update bench 2024-03-20 07:16:32 -07:00
Dylan Conway
931e04b019 fix(install): hoisting bug with devDependencies (#9519)
* fix with tests

* move to hoisting describe scope

* Update bun-install-registry.test.ts
2024-03-19 21:46:54 -07:00
Dylan Conway
cee6be12cc test for #9472 and bun pm trust waiter thread bugfix (#9498)
* test max concurrent scripts

* stress test, waiter thread bugfix

* different verbose

* escape

* Update src/install/lockfile.zig

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

* resource usage test

* fix invalid pointer

* another test

* update test

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-03-19 21:46:03 -07:00
Jarred Sumner
a54264177b Fix coercion edgecase with i32 and i64 (#9518)
* Fix coercsion edgecase

* Add sleep test

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-19 20:49:13 -07:00
Gabriel Nunes
5ed609f96b fix(docs): fix broken links in guides (#9512) 2024-03-19 17:59:19 -07:00
Dylan Conway
f15e7f733d Revert "fix invalid pointer"
This reverts commit 3df320d0ed.
2024-03-19 16:48:34 -07:00
Dylan Conway
3df320d0ed fix invalid pointer 2024-03-19 16:45:27 -07:00
Dylan Conway
bf0e5a82f7 fix(windows): install bugfixes for workspaces, tarballs, and relative paths (#8813)
* more tests

* update migration.zig

* fix up paths

* update tests

* update tests

* test

* test

* update registry tests

* comments

* early exit if stream is invalid

* dont pass invalid_fd to openFileAtWindows

* fix merge

* misc crash fix

* make this use optional pointers instead of 0xaa

* ensure absolute paths are propagated properly

* package.json expects forward slash

* this assert was invalid

* add panic checks

* pass bun-remove

* more panic checks

* test: pass bun-add

* querying these hangs outside bun too

* fix compile error from merge conflict resolution

* use compileError instead of comptime unreachable

* tidy

* bunx: check for the .exe bin extension

* bunx: another route to make cache path if it doesnt exist

* install: another case of FolderResolution.getOrPut expecting absolute path

* fix a bun install crash

* dont print zig stack trace if bun install fails

* test: pass bun-link

* test: bunx: add more expects

* test: bun-install-registry: pass

* test: bun-install: pass

* test: bun-pm: pass

* fix merge main error

* fix posix tests

* fix last failing test in bun-install.test.ts
symlink difference between platforms

* bun-install-registry.test.ts fix

* bun-run.test.ts: remove stray console log

---------

Co-authored-by: Meghan Denny <meghan@bun.sh>
Co-authored-by: Meghan Denny <hello@nektro.net>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-03-18 22:34:15 -07:00
Dylan Conway
06f04b584c fix(install): default trusted dependencies on windows (#9500)
* make sure source data is set too

* make default trusted dependencies work

* undo

* test

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-03-18 19:40:11 -07:00
Jarred Sumner
76ced7c6ed WIP Make process.stdout sync on windows (#9398)
* Make some things sync on windows

* WIP

* WIP

* remove uses to uv_default_loop

* remove a compiler warning on windows

* edfghjk

* Windows build fixes

* Fixup

* bundows

* Add quotes

* Fix --cwd arg on Windows

* comment

* move this up

* Fix some tests

* `mv` tests pass

* spawn.test passes again

* Allow .sh file extension for Windows

* Unmark failing tests

* env test pass

* windows

* Fix some tests

* Update ProcessBindingTTYWrap.cpp

* Update CMakeLists.txt

* Set tmpdir

* Make it 5s on windows

* Fixup

* Fixup

* Update ProcessBindingTTYWrap.cpp

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: dave caruso <me@paperdave.net>
2024-03-18 19:35:34 -07:00
Meghan Denny
e1593ce2e5 docs: api/ffi improvements (#9496) 2024-03-18 18:25:26 -07:00
Jarred Sumner
9e91e137f1 check is callable in util promisify timers (#9482)
* Update CMakeLists.txt

* Check is callable in util promisify

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-17 21:39:39 -07:00
Cezary Kupaj
4dd61bfd20 Fix crypto module to have proper id values for sign function (#9248)
* Fix crypto module to have proper id values for sign function

* Revert adding id hash to DSA sign functions - DSA algorithm doesnt use it

* Add tests for crypto.createSign() and crypto.verifySign()

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-03-17 21:13:43 -07:00
nellfs
ca97a757bb Development environment documentation for openSUSE Tumbleweed (#9479)
* Add openSUSE Tumbleweed to the list of supported Linux distributions in CMakeLists.txt

* openSUSE Tumbleweed setup

* Revert "Add openSUSE Tumbleweed to the list of supported Linux distributions in CMakeLists.txt"

This reverts commit 93faed88a1.

---------

Co-authored-by: nellfs <nellfs@localhost.localdomain>
2024-03-17 21:12:09 -07:00
Jarred Sumner
a74d6f5a20 Clean up a little after #9402 (#9454)
* Clean up after #9402

* More

* More cleanup

* Bring back `dead`

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Zack Radisic <56137411+zackradisic@users.noreply.github.com>
2024-03-17 21:09:25 -07:00
Zack Radisic
4a6cda8d80 Fixes #9459 (shell mv regression) (#9475)
* Fix `mv`

* Add `mv` tests
2024-03-17 21:08:16 -07:00
Jarred Sumner
5fec71bda4 Fixes #9430 (#9472)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-17 07:19:24 -07:00
Jarred Sumner
3d8c10c116 Fixes #7148 (#9467)
* Fixes #7148

* Fix failing tests

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-17 06:20:24 -07:00
Jarred Sumner
9e8bdaba93 Fixes #9433 (#9471)
* Fix assertion failure when package-lock.json is out of sync with package.json

* Fixes #9433

* Update bun.lockb

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-17 03:42:10 -07:00
Jarred Sumner
c8ec56ec1b Fix assertion failure when package-lock.json is out of sync with package.json (#9468)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-16 23:31:34 -07:00
Jarred Sumner
28d329893b Ensure some logs only generate in debug 2024-03-16 21:45:12 -07:00
Jarred Sumner
17631ce6a0 Fix subprocess.kill(undefined) (#9466)
* Fix subprocess.kill()

* Update spawn-kill-signal.test.ts

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-16 19:35:21 -07:00
Jarred Sumner
7c9f076385 Fixes #3202 (#9461)
* Fixes #3202

* Update ws.js

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-16 17:47:49 -07:00
Jarred Sumner
1879c499b1 Add shell hanging tests (#9463)
* Add shell hanging tests

* Fix shell hanging

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Zack Radisic <56137411+zackradisic@users.noreply.github.com>
2024-03-16 16:22:14 -07:00
Ciro Spaciari
83863c27b4 fix(windows) fix some test failures (#9417)
* fix ReadFile and fix isEligible for sendfile on windows

* give it a little more time

* actually test tls property

* Update src/bun.js/webcore/blob/ReadFile.zig

Co-authored-by: John-David Dalton <john.david.dalton@gmail.com>

* getServers test on windows

* retry

* check comptime first on isEligible

* wip body-stream

* oopsie

* opsie 2

* revert this

* test

---------

Co-authored-by: John-David Dalton <john.david.dalton@gmail.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-03-16 05:47:33 -07:00
Jarred Sumner
785d2251da Fix incorrect include order (#9457)
* Update ImportMetaObject.cpp

* Add header guard

* Enable `-Werror=uninitialized` and `-Werror`

* Update napi.cpp

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-16 02:50:38 -07:00
Jarred Sumner
a6633e554c Update bunfig.md 2024-03-15 23:38:28 -07:00
Jarred Sumner
324e4f5fff Update bunfig.md 2024-03-15 23:36:25 -07:00
Filip
c9a70f1686 Fixes shell mv with multiple files (#9341)
Co-authored-by: Zack Radisic <56137411+zackradisic@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-03-15 23:01:25 -07:00
Jarred Sumner
e89c8d2eaa Fix not using system shell on posix (#9449)
* Use system shell + add to bunfig

* Update CMakeLists.txt

* Fix tests + flags

* Use execPath

* windows

* Propagate exit code

* Add test for default shell in use

* Update bun-run-bunfig.test.ts

* Update bun-run-bunfig.test.ts

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-15 23:00:53 -07:00
Meghan Denny
b23eb60277 test: updated prisma schema (#9450)
* test: updated prisma schema

* test: fix prisma non-determinism

* fix postgres too
2024-03-15 22:55:42 -07:00
dave caruso
b1719f3a70 make import.meta behave better when query string is provided (#9399)
* make import.meta actually use a vali url

* a
2024-03-15 22:44:23 -07:00
Zack Radisic
bd3812df50 Shell fixes (#9402)
* wip

* Fix a bunch of stuff

* Fix cat

* Fix shell rm windows

* Fix glob scan test on windows

* Fix rm on windows

* stuff

* make it compile on windows

* [autofix.ci] apply automated fixes

* fix compile

* Wow

* Minor changes

* Ensure handle is closed

* Regular files are not pollable on linux

* dupe the blob son

* fix mem leak stuf

* dont use O_NONBLOCK

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-03-15 21:41:11 -07:00
Dylan Conway
9512f5240f bun pm trust bugfix (#9426)
* check error

* test missing packages

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

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-03-15 21:22:12 -07:00
Jarred Sumner
307cac5ecd await FileHandle functions (#9451)
* Await FileHandle functions

* Update fs.promises.ts

* use await using = await

* Make this more robust + fix tests

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-15 21:05:43 -07:00
Brian Donovan
8c5ac06113 fix: return object from FileHandle#read and FileHandle#readv (#9444)
See the NodeJS docs for `read`: https://nodejs.org/api/fs.html#filehandlereadoptions
2024-03-15 14:56:02 -07:00
Ciro Spaciari
eae0f0318a fix ref counting onReaderDone (#9443) 2024-03-15 13:00:19 -07:00
Jarred Sumner
e256751218 Don't link libicudata? (#9424)
* Don't link libicudata?

* Fixups

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-14 20:46:11 -07:00
Dylan Conway
1e090a78c1 improve --print with promises (#9407)
* `.then` on pending promises

* remove header
2024-03-14 19:26:44 -07:00
Jarred Sumner
8852f2a28d Lost in the merge (#9423) 2024-03-14 19:26:28 -07:00
Jarred Sumner
924647f8b9 Fixes #9404 (#9408)
* Fixes #9404

* Fixup

* Test it on macOS and windows too why not

* fixup

* Fix test

* ignore

* seems to work?

* Update Dockerfile
2024-03-14 18:47:22 -07:00
Ashcon Partovi
c72cf989f4 Fix 'xcrun: error: unable to lookup item' error when building on macOS 2024-03-14 12:23:00 -07:00
Ashcon Partovi
eac2e52783 Remove cp.js 2024-03-14 09:48:49 -07:00
Jarred Sumner
9573c6e2b7 Upgrade HTTPParser.h from uWS v20.6.0 to v20.62.0 (#9355)
* Upgrade HTTPParser.h from uWS v20.6.0 to v20.62.0

* Make MAX_FALLBACK_SIZE larger to allow for large redirect urls

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-13 21:22:15 -07:00
Dylan Conway
3375a158de fix(install): make sure trustedDependencies is updated after removing packages (#9400)
* if lockfile diff, transfer new trusted list over

* oops

* comment

* not only

* remove constCast
2024-03-13 19:17:42 -07:00
Jarred Sumner
570b3e567a Bump 2024-03-13 15:26:38 -07:00
Dylan Conway
cce6cfb2b3 fix integer overflow on subprocess deinit (#9388)
* avoid overflow

* closeWithoutReporting

* PipeWriter too

* remove comment
2024-03-13 14:50:31 -07:00
Jarred Sumner
9bda350406 Add a helpful error message when the xcode SDK is newer than the current platform (#9397)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-13 14:34:31 -07:00
Jarred Sumner
c5cc2a45a6 Speed up this test 2024-03-13 12:34:38 -07:00
Dylan Conway
c64e52c67f if cjs, dont set through esm eval 2024-03-12 22:59:31 -07:00
Jarred Sumner
648fd5d138 Always set the result if its an entry point 2024-03-12 22:51:16 -07:00
Jarred Sumner
7f16164b25 Unwrap promises in bun --print 2024-03-12 21:54:07 -07:00
Dylan Conway
e45ece05d9 improve bun pm trust output (#9371)
* fix recursion

* accurate count of blocked package scripts

* update

* fix merge

* reset pipereaders, set bin linker error correctly

* more pretty

* small changes

* e

* update tests

* this one too

* bun.start_time, iterate package_ids, remove put
2024-03-12 19:50:46 -07:00
Dylan Conway
3765032dec feat: bun --print (#9358)
* --print cli flag

* less code elimination

* handle cjs module eval results

* make node -p work

* better test

* more tests

* if

* delete commented code

* delete commented code

* EvalGlobalObject

* remove one constructor

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-03-12 18:15:50 -07:00
dave caruso
4b0eb47164 fix hot test on windows 2024-03-12 05:38:59 -07:00
Jarred Sumner
2d0cf1a78b [windows] Fix fetch.unix.test.ts (#9369)
* Fix fetch.unix.test

* Skip mmap
2024-03-11 18:01:57 -07:00
Jarred Sumner
574dec0919 Fix a couple windows test failures (#9361)
* Fix a couple test failures

* Another test

* Return a promise on flush
2024-03-11 16:27:08 -07:00
Brian Donovan
840f1b4006 fix typo in error message (#9350)
It should be "its" (possessive), not "it's" (contraction of "it is").

Co-authored-by: John-David Dalton <john.david.dalton@gmail.com>
2024-03-11 11:53:58 -04:00
Jarred Sumner
c9fe57fa63 wip use wrapper for managing process (#8456)
* WIP sync close (shows ref count bug in stream)

* fix closing on PipeWriter and PipeReader

* remove old todos

* join

* Some shell changes

at least it compiles

* fix some compile errors

* fix ref/unref server on windows

* actually use the ref count in this places

* make windows compile again

* more tests passing

* Make shell compile again

* Slowly remove some `@panic("TODO SHELL")`

* Eliminate `@panic("TODO SHELL")` for BufferedWriter

* Holy cleansing of `@panic("TODO SHELL")`

at least it compiles now

* Okay now the shell compiles, but segfaults

* Fix compiler errors

* more stable stream and now Content-Range pass

* make windows compile again

* revert stuff until the fix is actually ready

* revert onDone thing

* Fix buffered writer for shell

* Fix buffered writer + shell/subproc.zig and windows build

* Fix for #8982 got lost in the merge

* Actually buffer subproc output

* Fix some stuff shell

* oops

* fix context deinit

* fix renderMissing

* shell: Fix array buffer

* more stable streams (#9053)

fix stream ref counting

* wip

* Remove `@panic("TODO")` on shell event loop tasks and Redirect  open flags got lost in merge

* Support redirects

* fixes

cc @cirospaciari

* Update ReadableStreamInternals.ts

* Fix spurious error

* Update stream.js

* leak

* Fix UAF

cc @cirospaciari

* Fix memory leaks

* HOLY FUCK big refactor

* misc cleanup

* shell: Fix a bunch of tests

* clean up

* gitignore: fix ending newline

* get windows compiling again

* tidy

* hide linker warn with icu

* closeIfPossible

* Better leak test

* Fix forgetting to decrement reference count

* Update stdio.zig

* Fix shell windows build

* Stupid unreachable

* Woops

* basic echo hi works on windows

* Fix flaky test on Windows

* Fix windows regression in Bun.main (#9156)

* Fix windows regression in Bun.main

* Handle invalid handles

* Fix flaky test

* Better launch config

* Fixup

* Make this test less flaky on Windows

* Fixup

* Cygwin

* Support signal codes in subprocess.kill(), resolve file path

* Treat null as ignore

* Ignore carriage returns

* Fixup

* shell: Fix IOWriter bug

* shell: Use custom `open()`/`openat()`

* windows shell subproc works

* zack commit

* I think I understand WindowsStreamingWriter

* fix thing

* why were we doing this in tests

* shell: Fix rm

* shell: Add rm -rf node_modules/ test

* shell: use `.runAsTest()` in some places to make it easier to determine which test failed

* [autofix.ci] apply automated fixes

* woopsie

* Various changes

* Fix

* shell: abstract output task logic

* shell: mkdir builtin

* fixup

* stuff

* shell: Make writing length of 0 in IOWriter immediately resolve

* shell: Implement `touch`

* shell: basic `cat` working

* Make it compile on windows

* shell: Fix IOReader bug

* [autofix.ci] apply automated fixes

* fix windows kill on subprocess/process

* fix dns tests to match behavior on windows (same as nodejs)

* fix windows ci

* again

* move `close_handle` to flags in `PipeWriter` and fix shell hanging

* Fix `ls` not giving non-zero exit code on error

* Handle edgecase in is_atty

* Fix writer.flush() when there's no data

* Fix some tests

* Disable uv_unref on uv_process_t on Windows, for now.

* fix writer.end

* fix stdout.write

* fix child-process on win32

* Make this test less flaky on Windows

* Add assertion

* Make these the same

* Make it pass on windows

* Don't commit

* Log the test name

* Make this test less flaky on windows

* Make this test less flaky on windows

* Print which test is taking awhile in the runner

* fixups

* Fixups

* Add some assertions

* Bring back test concurrency

* shell: bring back redirect stdin

* make it compile again cc @zackradisic

* initialize env map with capacity

* some fixes

* cleanup

* oops

* fix leak, fix done

* fix unconsumedPromises on events

* always run expect

* Update child_process.test.ts

* fix reading special files

* Fix a test

* Deflake this test

* Make these comparisons easier

* Won't really fix it but slightly cleaner

* Update serve.test.ts

* Make the checks for if the body is already used more resilient

* Move this to the harness

* Make this test not hang in development

* Fix this test

* Make the logs better

* zero init some things

* Make this test better

* Fix readSocket

* Parallelize this test

* Handle EPipe and avoid big data

* This was a mistake

* Fix a bunch of things

* Fix memory leak

* Avoid sigpipe + optimize + delete dead code

* Make this take less time

* Make it bigger

* Remove some redundant code

* Update process.zig

* Merge and hopefully don't breka things along teh way

* Silence build warning

* Uncomment on posix

* Skip test on windows

* windows

* Cleanup test

* Update

* Deflake

* always

* less flaky test

* [autofix.ci] apply automated fixes

* logs

* fix uaf on shell IOReader

* stuff to make it work with mini event loop

* fix 2 double free scenarios, support redirections on windows

* shell: Make `1>&2` and `2>&1` work with libuv

* yoops

* Partial fix

* Partial fix

* fix build

* fix build

* ok

* Make a couple shell tests pass

* More logging

* fix

* fix

* Fix build issue

* more tests pass

* Deflake

* Deflake

* Use Output.panic instead of garbled text

* Formatting

* Introduce `bun.sys.File`, use it for `Output.Source.StreamType`, fix nested Output.scoped() calls, use Win32 `ReadFile` API for reading when it's not a libuv file descriptor.

This lets us avoid the subtle usages of `unreachable` in std.os when writing to stdout/stderr.

Previously, we were initializing the libuv loop immediately at launch due to checking for the existence of a bun build --compile'd executable. When the file descriptor is not from libuv, it's just overhead to use libuv

cc @paperdave, please tell me if Iany of that is incorrect or if you think this is a bad idea.

* Fix closing undefined memory file descriptors in spawn

cc @zackradisic

* pause instead of close

* Fix poorly-written test

* We don't need big numbers for this test

* sad workaround

* fixup

* Clearer error handling for this test

* Fix incorrect test

@electroid when ReadableStream isn't closed, hanging is the correct behavior when consuming buffered data. We cannot know if the buffered data is finished if the stream never closes.

* Fix build

* Remove known failing on windows

* Deflake

* Mark no longer failing

* show all the failing tests

* Sort the list of tests

* fix argument handling

* dont show "posix_spawn" as an error code on windows

* make bun-upgrade.test.ts pass on windows

* fix bunx and bun create again sorry

* a

* fix invalidexe because we should not be running javascript files as if they were exes

* Concurrency in test runner + better logging

* Revert "fix invalidexe because we should not be running javascript files as if they were exes"

This reverts commit da47cf8247.

* WIP: Unix fixes (#9322)

* wip

* [autofix.ci] apply automated fixes

* wip 2

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>

* Update runner.node.mjs

* Update runner.node.mjs

* Document some environment variables

* shell: Make `Response` work with builtins

* Make it compile

* make pwd test pass

* [autofix.ci] apply automated fixes

* Fix printing garbage for source code previews

* Update javascript.zig

* Fix posix test failures

* Fix signal dispatch

cc @paperdave. Signals can be run from any thread. This causes an assertion failure when the receiving thread happens to not be the main thread. Easiest to reproduce on linux when you spawn 100 short-lived processes at once.

* windows

---------

Co-authored-by: cirospaciari <ciro.spaciari@gmail.com>
Co-authored-by: Zack Radisic <56137411+zackradisic@users.noreply.github.com>
Co-authored-by: Zack Radisic <zackradisic@Zacks-MBP-2.attlocal.net>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Meghan Denny <meghan@bun.sh>
Co-authored-by: Zack Radisic <zack@theradisic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: dave caruso <me@paperdave.net>
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
2024-03-11 08:24:30 -07:00
sequencerr
21ec6669df Fix bun description (#9345) 2024-03-10 10:19:38 -07:00
Jarred Sumner
44959e6826 Make printing errors faster (#9328)
* Make printing errors faster

* Make Next.js tests less flaky

* Update dev-server.test.ts

* Copy over runner from process pr

* bump next version

* Update javascript.zig

* Set port to 0

* p-queue

* no dont use docker buildx

* Prevent runner from hanging

* Update dev-server.test.ts

* Really fix hanging this time

* Fix bounds check for unix domain socket, support abstract namespace sockets

* Various fixes

* [autofix.ci] apply automated fixes

* Update runner.node.mjs

* Update runner.node.mjs

* windows

* Only care about stdout

* increase concureency + clean up test

* Tweak puppeteer

* Update runner.node.mjs

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-03-09 09:48:46 -08:00
Jarred Sumner
79e77f13ab Revert "Bun.serve: error: pass Request parameter when available (#9310)" (#9332)
This reverts commit b92d98556b.
2024-03-09 08:44:03 -08:00
dave caruso
cd320835d1 chore: just a little bit of cleanup (#9319)
* just a little bit of cleanup

* oops
2024-03-09 07:28:54 -08:00
dave caruso
c3a9a7c147 fix #8868 (#9327) 2024-03-09 07:28:31 -08:00
Meghan Denny
b92d98556b Bun.serve: error: pass Request parameter when available (#9310)
* Bun.serve: error: pass Request parameter when available

* this will be null when not found not undefined

* add an assert here

* reorganize tests

* add another test

* add another test
2024-03-08 19:59:58 -08:00
Jarred Sumner
51ac00e965 Move these below package.json script 2024-03-08 19:26:00 -08:00
Jarred Sumner
402f7079df Add tests for file path redirection + tweak 2024-03-08 19:20:41 -08:00
Meghan Denny
709fbc2565 allow bun run to accept js from stdin (#9311)
* allow bun run to accept js from stdin

* document it

* fix window test

* cli/run: use printForLogLevel

---------

Co-authored-by: dave caruso <me@paperdave.net>
2024-03-08 18:43:53 -08:00
Meghan Denny
702cae51f6 test: Bun.stringWidth is enabled by default (#9321) 2024-03-08 17:54:51 -08:00
John-David Dalton
ad6a1b1a71 chore: remove unused zig-datetime dep (#9315) 2024-03-08 10:40:05 -08:00
Dylan Conway
d37fbbd4e0 fix(install): lifecycle script changes (#8943)
* empty trustedDependencies

* tests

* handle edgecases with default trusted dependencies

* could be zero length

* --trusted and skipped scripts

* resolver too

* second run --trusted

* --trust, better formatting

* more tests

* --trusted applies to dep deps, more tests

* progress

* fix build

* fix crash, make it look good, comments

* alphabetize, verbose log

* feature flag

* update lockfile

* update skipped text

* check update requests first

* be more careful with inline strings

* only with scripts

* fix tests, todo tests

* fix another test

* fix merge

* fix fix merge

* check binding.gyp for tarball and git resolutions

* remove dead code

* debug assert

* move newline printing

* use enum for `__has_install_script`

* oops

* clone packages

* Update src/install/install.zig

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

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-03-07 19:22:21 -08:00
dave caruso
a927340ce3 fix: bun.serve crash due to ExceptionRef (#9309)
* fix bun.serve crash due to ExceptionRef

* add test
2024-03-07 18:54:15 -08:00
Robert Burke
7fc97fcf9c Fix sqlite benchmark setup when sh isn't bash (#9303)
Prevent deno from making noisy output

Co-authored-by: Robert Burke <robert.burke@ltcm.lol>
2024-03-07 17:32:23 -08:00
Meghan Denny
ea5354fc85 handle invalid URL in Location header for fetch() (#9305) 2024-03-07 17:32:05 -08:00
dave caruso
3b13f7f998 fix: large bunx changes, mostly for better windows support (#9143)
* make bun-debug properly override `bun` in path

* windows path

* fix more issues with bunx

* sync

* stuff

* stuff

* f

* stuff

* further work

* a

* [autofix.ci] apply automated fixes

* okay

* fix building on posix systems

* ok

* make it so bun create cant crash + review

* docuemnt why return false is ok

* .

* cache bust

* merge

* yeah

* yea

* Update src/install/install.zig

* review results

* this will probably fix hardlink issue on windwo

* okay

* how did that work before

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-03-07 14:20:39 -08:00
Ashcon Partovi
806dec7a35 fix: child_process.spawn({ timeout }) exiting too early (#9280) 2024-03-07 09:36:54 -08:00
Meghan Denny
5a8830fdcc NODE_ENV=test should load .env.test even when .env.production exists (#9291) 2024-03-07 03:36:09 -08:00
dave caruso
e8374ebd82 feat: implement util.styleText (#9287)
* feat: implement util.styleText

* i forgot to test
2024-03-07 03:20:08 -08:00
John-David Dalton
9734f4cf6b Allow for smaller allocations in node:path methods (#8932)
Co-authored-by: Georgijs <48869301+gvilums@users.noreply.github.com>
2024-03-07 10:37:13 +01:00
Dylan Conway
ea6bf1257a fix(install): auto node-gyp script bugfix (#9289)
* preinstall and install

* comment
2024-03-06 23:05:23 -08:00
Meghan Denny
3f12d71fdd install: dont crash in debug mode when a semver has a build tag and multiple hyphens in the pre-release tag (#9288) 2024-03-06 20:38:49 -08:00
Jarred Sumner
27a504a45b Add microbenchmark for reading a file in chunks 2024-03-06 17:42:12 -08:00
Jarred Sumner
dd920dadb8 Shorten title 2024-03-06 15:34:18 -08:00
Jarred Sumner
f6d5325daa Support socketPath in node:http request (#9284)
* Support `socketPath` in node:http request

* fix dashes

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: dave caruso <me@paperdave.net>
2024-03-06 15:28:35 -08:00
Jarred Sumner
a66926243d Support unix domain sockets in fetch() (#9097)
* Support unix domain sockets in fetch()

* rename to 'socket' to 'unix', add test

* enable keepalive on unix socket fetch

* make ownership of unix_socket_path clear, refactor http.zig a bit

* [autofix.ci] apply automated fixes

* add fetch unix redirect test, fix crash

* [autofix.ci] apply automated fixes

* fix fetch redirect from unix to non-unix

* disable keepalive for unix sockets (for now) so we don't leak them

* Update test/js/web/fetch/fetch.unix.test.ts

Co-authored-by: Ciro Spaciari <ciro.spaciari@gmail.com>

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Georgijs Vilums <georgijs@bun.sh>
Co-authored-by: Georgijs <48869301+gvilums@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Ciro Spaciari <ciro.spaciari@gmail.com>
2024-03-06 14:12:03 -08:00
Kyle Scully
440cee1755 refactor: remove unnecessary spread (#9137) 2024-03-06 09:00:29 -08:00
マルコメ
9b4a74715b docs: update test matchers on jest compatibility (#9272) 2024-03-06 00:11:29 -08:00
Meghan Denny
8fc08752e5 node:http: emit 'socket' event after calling http.request() (#9270)
* node:http: emit 'socket' event after calling http.request()

* add reference links for why this is how it is

* add guards to not waste time

* add a regression test

* use test harness port number
2024-03-05 23:01:32 -08:00
Meghan Denny
bb3295ba84 node:url implement domainToASCII and domainToUnicode (#9257)
* node:url implement domainToASCII and domainToUnicode

* fix arg checks

* remove unneeded use of WTF::Vector

* tidy

* throw a js error if icu fails

* add a ton more tests, fix ascii guard, upconvert latin1

* even more tests

* add a comment for this guard

* use ASSERT_NOT_REACHED() instead of raise(SIGABRT)
2024-03-05 19:46:38 -08:00
Ashcon Partovi
c837903e4e Fix new Request("/") not working with node-fetch (#9246)
* Fix `new Request("/")` not working with `node-fetch`

* Address review

* Address review 2

* Fix bad test
2024-03-05 16:51:52 -08:00
Ryan Dsouza
b55e62b634 Update cache.md (#9260)
Specify `bunfig.toml` to make it easy to check where this option needs to be added.
2024-03-05 16:28:08 -08:00
Cameron Haley
2b8fc7a9a8 Running absolute/relative path shouldn't rely on the existence of package.json script (#9265) 2024-03-05 16:27:57 -08:00
Jarred Sumner
edeeffc74c Fixes #9263 (#9266)
* Fixes #9283

* Update URLSearchParams.test.ts

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-05 16:27:33 -08:00
Jarred Sumner
12c257a012 Fix out of bounds memcpy in crypto 2024-03-05 13:52:27 -08:00
Yash Singh
bd2176ffb0 fix: format specifier without characters in between (#9209)
* fix: format specifier without spaces in between, resolves #9208

* chore: test in console-log.test.ts
2024-03-04 17:46:19 -08:00
ErikOnBike
4f0a497660 Fix lost constructors in Node.js module classes (#9245) 2024-03-04 16:12:22 -08:00
dave caruso
472a0b482d feat: signal handling on windows (#9129)
* start some signal handling

* ok

* work on this from friday

* ok

* ref stuff

* threadsafety

* fix the buikld

* alright

* ok

* fix posix compilation error

* header fix

* revisions

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Zack Radisic <zack@theradisic.com>
2024-03-04 15:37:08 -08:00
Brook Jeynes [SSW]
fa08ac34c9 Fixes #7767: Updated bun upgrade to return error when used with cmd arguments (#7784)
* Updated `upgrade` to return error when used with cmd arguments
- Updated `upgrade` command to check for command-line arguments and return an error if so providing a suggested `update` command.

* added test

* updated condition to allow

* Upgrade argument check now only checks if all arguments contain `--`
- Added more tests

* Using `cpSync` in the following context results in an "Is a directory" error

* Update message displayed back to user

Co-authored-by: dave caruso <me@paperdave.net>

* moved args check to upgrade_command.zig

* fixed broken tests

* changing string interpolation to join() for paths

* [autofix.ci] apply automated fixes

* Fixed build errors
- Removed call to `std.mem.span`
- Added conditional to only run if there's more than 2 arguments (ignores the exec and `upgrade`)
- Added new test to ensure `upgrade` runs with 0 arguments passed

---------

Co-authored-by: dave caruso <me@paperdave.net>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-03-04 15:30:20 -08:00
Yash Singh
51466ff1a2 fix: sep state for assertions and hasAssertions (#9210) 2024-03-04 12:01:50 -08:00
cyfung1031
b14c7aa0b5 docs: Correct Incorrect Information (#9214)
`URL.createObjectURL` is not yet implemented.
See https://github.com/oven-sh/bun/issues/3925
2024-03-04 08:27:18 -08:00
Jarred Sumner
1424a196ff Support "conditions" in Bun.build (#9234)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-03 23:52:24 -08:00
Zack Radisic
05a7779880 shell: Improve ShellError stacktrace (#9233)
* Improve stacktrace

* woops
2024-03-03 21:46:42 -08:00
Jarred Sumner
95fc939d0b Fixes #9225 (#9232)
* Fixes #9225

* Pass all arguments along

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-03 20:50:35 -08:00
Jarred Sumner
6d52b3b62b Fixes #8794 (#9231)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-03 20:13:22 -08:00
Jarred Sumner
30fdfdb295 Fixes #9222 (#9230)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-03 19:26:27 -08:00
Jarred Sumner
a43a8a8cea Fixes #9226 (#9229)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-03 17:32:18 -08:00
argosphil
4257457c6a Allow relative paths in cpAsync again (#9184)
* allow relative paths in cpAsync again

* test for #9024

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-03-03 16:30:34 -08:00
Cameron Haley
b5cea9a20c Avoid manually destroying stream when IncomingMessage stream is done reading (#9219)
* Avoid manually destroying stream when IncomingMessage stream is done reading

* Add test

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-03-03 16:29:13 -08:00
Jarred Sumner
49ccad9367 Finish jest.clearAllMocks() implementation (#9217)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-03 03:48:13 -08:00
Jarred Sumner
71405ff4dc Fix regression from 648d5ae (#9215)
* Slightly reduce number of system calls on Linux

* Fix regression from 648d5aecf3

648d5aecf3 caused HTTP response bodies sent streamingly with a single chunk to include an extraneous 0\r\n\r\n chunk, leading valid clients to close the connection prematurely.

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-03 00:02:44 -08:00
Jarred Sumner
0017dbec4e Fixes #9180 (#9212)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-02 21:42:57 -08:00
Jarred Sumner
a3a5ed3870 Update shell.md 2024-03-02 01:39:34 -08:00
Jarred Sumner
dd111589b0 Update shell.md 2024-03-02 01:37:42 -08:00
Jarred Sumner
3c62580529 Add a couple guides 2024-03-02 01:24:40 -08:00
Dylan Conway
309b417009 add assertion for generated functions returning JSValue.zero without an exception (#9197)
* assert exception when JSValue.zero is returned

* Update generate-classes.ts
2024-03-01 20:18:40 -08:00
Yash Singh
b2794ad7cf feat: implement expect.assertions and expect.hasAssertions (#9190)
* chore: merge oven-sh/bun

* chore: merge oven-sh/bun

* chore: merge oven-sh/bun

* fix: comptime for compiling

* fix: error reporting

* chore: revert runner.node.mjs

* fix: dont construct err b4

* chore: rm force throw test

* chore: rerun

* chore: reset unrelated changes

* fix: return undefined

* fix: dont return undefined on invalid args

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-03-01 20:17:44 -08:00
Jarred Sumner
4489cda25b Bump (#9196)
* Bump

* Even more calloc

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-01 20:13:16 -08:00
Igor Wessel
dcf6f244a4 feat: add support --conditions flag (#9106)
* feat(options): add possibility to append a custom esm condition

* feat(cli): parse --conditions flag

* test: add case for custom conditions

* fix(cli): not get short-hand --conditions flag

* test: add case using cjs with custom condition

* fix(options): address possible memory issues for esm conditions

* refactor(cli): remove -c alias for --conditions flag

* test: add cases for multiple --conditions specified

* test(bundler): add support to test --conditions

* chore(cli): fix grammar mistakes in --conditions

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-03-01 18:57:45 -08:00
Meghan Denny
3134ae1ada ci: comment disabled actions/upload-artifact call (#9195) 2024-03-01 18:14:15 -08:00
Meghan Denny
4baad765ec windows: pass test/js/web/timers/setTimeout.test.js (#9176)
* windows: pass test/js/web/timers/setTimeout.test.js

* gotta go fast

* ci: windows: try reverting this line

reproducibly getting:
Error: Unable to download artifact(s): Artifact not found for name: bun-windows-x64-zig

* ci: switch back to namespace for zig build
2024-03-01 17:48:52 -08:00
Ashcon Partovi
714e04eeec Github actions changes (#9189)
* Test out custom oven-sh/setup-bun action

* Add files
2024-03-01 17:48:23 -08:00
Jarred Sumner
64bdf6a138 Zero initialize some things in usockets (#9191)
* Zero initialize some things in usockets

* Update epoll_kqueue.c

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-01 17:47:00 -08:00
Meghan Denny
141c2b52b1 ci: fail step if actions/upload-artifact fails (#9194)
* ci: fail step if actions/upload-artifact fails

* the arm64 workflow doesnt have these and they were failing on x86
2024-03-01 17:46:18 -08:00
Jarred Sumner
fd26c3fb55 Fixes #9153 (#9175)
* Fixes #9153

* Update napi.zig

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-03-01 14:42:20 -08:00
Lucas Garron
7909f0eff4 Fix typo: demonstates → demonstrates (#9179) 2024-03-01 05:44:44 -08:00
Jarred Sumner
1e217ce78f Fix path bug (#9173) 2024-02-29 22:35:52 -08:00
Jarred Sumner
08ef0e8e8e Use namespace on more machines 2024-02-29 22:16:47 -08:00
Ashcon Partovi
536919e783 Use namespace.so for faster CI (#9160)
* Use namespace.so for faster CI

* arm64 runners arent working

* deflake

* more

* Update bun-mac-x64-baseline.yml

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-29 16:14:12 -08:00
Meghan Denny
e45a4019c1 windows: pass test/transpiler/transpiler-stack-overflow.test.ts (#9164)
* windows: pass test/transpiler/transpiler-stack-overflow.test.ts

* remove regression silencing comment

* needed this too

* use proper drive letter detection

* oopsie
2024-02-29 15:21:39 -08:00
Alexander Mykolaichuk
0b5e83db97 fix: linux distro name match (#9075) 2024-02-29 13:17:31 -08:00
Meghan Denny
2fb6733eeb windows: pass test/js/node/process/process.test.js (#9161) 2024-02-28 20:25:05 -08:00
Meghan Denny
bcd604edc7 windows: pass test/js/bun/resolve/resolve.test.ts (#9158) 2024-02-28 19:58:42 -08:00
Cameron Haley
bfdad44460 Fix issue where process.stdin is ended too early (#9155)
* Fix issue wherein process.stdin is ended too early

* [autofix.ci] apply automated fixes

* test: Generate prisma client on 'big' schema

* Update test/js/third_party/prisma/helper.ts

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-02-28 19:03:08 -08:00
Jarred Sumner
27a0deab5f Make this test less flaky on Windows 2024-02-28 17:03:00 -08:00
Jarred Sumner
c7a0c3c5fd Merge branch 'main' of https://github.com/oven-sh/bun 2024-02-28 16:56:02 -08:00
Jarred Sumner
bba9b39ef8 Fix flaky test on Windows 2024-02-28 16:55:58 -08:00
Jarred Sumner
f34de31edb Fix windows regression in Bun.main (#9156)
* Fix windows regression in Bun.main

* Handle invalid handles

* Fix flaky test

* Better launch config

* Fixup
2024-02-28 16:49:37 -08:00
Jarred Sumner
53378227ca [windows] Fix regression from #9154 2024-02-28 15:16:40 -08:00
dave caruso
360bbb4dea fix(windows): fix directory cache regression "expected to end with a trailing slash" (#9144)
* okaaaaaaaay

* Revert "resolver: fix debug mode crash in test/bundler/bun-build-api.test.ts (#9140)"

This reverts commit 331d079dad.

* correctly fix the cache bust bug

this was introduced a couple of commits ago in my random fixes,
where i put the wrong fix to another directory caching bug.

i still stand by the assertion in place despite it causing many people
issues. it's precense will prevent subtle module resolutions failures.

* add an extra comment

* fix building a release build locally

* add a better test case for 3216

* staging

* fix mac issues

* ok

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-02-28 14:51:14 -08:00
Jarred Sumner
dc6af25b54 Fix ownKeys issue (#9154) 2024-02-28 14:22:25 -08:00
Meghan Denny
331d079dad resolver: fix debug mode crash in test/bundler/bun-build-api.test.ts (#9140) 2024-02-27 22:22:52 -08:00
dave caruso
c54844b30b windows: random things (#9046)
* random things

* fix reliability of loading napi stuff

* fix posix build

* a
2024-02-27 16:30:34 -08:00
Dylan Conway
c9b5191fc2 fix(bun:test): fix toContainKeys with undefined and null (#9125)
* fix 9118

* update

* RELEASE_AND_RETURN

* cache and coerce

* test for toContainKey throwing in hasOwnProperty

* fix test

* [autofix.ci] apply automated fixes

* fix non-truthy and more test

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-02-27 15:10:26 -08:00
dave caruso
4e2d00d052 windows: changes to install/upgrade/uninstallation process (#9025) 2024-02-27 03:11:43 -08:00
Jarred Sumner
fd6fd78f0f Fixes #9120 (#9128)
* Fixes #9120

* Update buffer.test.js

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-26 19:15:28 -08:00
Jarred Sumner
c4a9bdbb81 Silence not implemented warning (#9126)
* Silce not implemented warning

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-02-26 18:36:18 -08:00
Jarred Sumner
f1b8df29e8 Replace std.unicode.fmtUtf16le with bun.fmt.utf16 (#9127)
* Replace `std.unicode.fmtUtf16le` with `bun.fmt.utf16`

* Update fmt.zig

* Remove bun.fmt.fmtUTF16

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-26 18:35:18 -08:00
Marvin A. Ruder
675dad2fe8 Use bind mount for glibc APKs in Alpine Dockerfile (#9113)
* Fixes #9112

Signed-off-by: Marvin A. Ruder <signed@mruder.dev>
2024-02-26 14:22:30 -08:00
Jarred Sumner
57eb04f6f4 [internal] Switch back to prettier (#9109)
* Switch back to prettier

* wip

* Update .prettierignore

* Update .prettierignore

* ignores

* Update .prettierignore

* Rest

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-02-26 11:13:02 -08:00
Jarred Sumner
517aaad549 Update executables.md 2024-02-25 23:59:34 -08:00
Jarred Sumner
6e54787d4a Update executables.md 2024-02-25 23:51:36 -08:00
Jarred Sumner
dbb490f3bd Update executables.md 2024-02-25 23:47:49 -08:00
Jarred Sumner
e2ee5642e0 Update executables.md 2024-02-25 23:45:52 -08:00
Jarred Sumner
92dec0a871 Implement util.types.isKeyObject (#9091)
* Implement util.types.isKeyObject

* just use inherits

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-25 14:30:05 -08:00
Jarred Sumner
72d57464b9 Make Bun.main the resolved filesystem path (#9105)
* Make `Bun.main` the resolved filesystem path, but only Bun.main

* Fix flaky test

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-25 13:05:34 -08:00
Cameron Haley
2333c94f8e Fix prisma generate by emitting readable event on EoF (#9101)
* Add test for ensuring the 'readable' event is emitted on end

* Run emitReadable on nextTick instead of as microtask

* perf: Store intermediate variables

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

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-02-25 13:01:07 -08:00
Jarred Sumner
a3adb8bd10 Add a couple TODO comments 2024-02-24 19:36:56 -08:00
Jarred Sumner
e9d4ced41e Bump WebKit 2024-02-24 18:46:00 -08:00
Jarred Sumner
fdd42eb67e Fixes #9096 2024-02-24 16:06:34 -08:00
Jarred Sumner
4ba1d4d7c8 Add missing fdatasync (#9092)
* Add missing fdatasync

* don't use /tmp/ since it might not support fdatasync on linux

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-24 15:47:14 -08:00
Dylan Conway
b6f3405fa7 fix(windows): fix uv_loop and uv_pipe_t struct sizes (#9085)
* use CRITICAL_SECTION struct instead of pointer

* WIN32_FIND_DATAW too

* INPUT_RECORD too
2024-02-24 02:49:47 -08:00
Aron Homberg
29466b884e feat: implemented jest.clearAllMocks, fixes #9079 (#9081) 2024-02-24 01:06:29 -08:00
Meghan Denny
968065ca73 Bun.stringWidth ambiguousIsNarrow option defaults to true (#9064)
* Bun.stringWidth ambiguousIsNarrow option defaults to true

* number was backwards too
2024-02-23 20:27:10 -08:00
Meghan Denny
72b700205a vscode: highlight invisible and ambiguous characters (#9066) 2024-02-23 20:26:58 -08:00
Meghan Denny
8ed02f9567 fix debug crash in bun.strings.firstNonASCII16 when input is multiple of ascii_u16_vector_size (#9080) 2024-02-23 20:26:08 -08:00
Meghan Denny
109a8c2c37 fix crash in test/transpiler/transpiler.test.js when macro isn't found (#9068) 2024-02-23 18:14:45 -08:00
Lucas Michot
d0d5475953 Update installation.md (#9069)
Simplify homebrew installation instructions

Co-authored-by: John-David Dalton <john.david.dalton@gmail.com>
2024-02-23 11:02:33 -08:00
Meghan Denny
d0293edc59 remove hidden zero-width-space characters from our md files (#9067) 2024-02-23 11:01:11 -08:00
Jarred Sumner
094750cc9c Update utils.md 2024-02-22 21:59:00 -08:00
Jarred Sumner
b48e5bbebd Update utils.md 2024-02-22 21:58:02 -08:00
Jarred Sumner
460d64a086 Update utils.md 2024-02-22 21:57:27 -08:00
Jarred Sumner
f75306db0f Update utils.md 2024-02-22 21:52:13 -08:00
Jarred Sumner
5147c0ba73 Fix incorrect assertion 2024-02-22 21:51:44 -08:00
jrz
f6a0edc7de docs: fix for contributing using linux (#9050)
Both debian:bookworm and ubuntu:latest (jammy) do not have curl, wget, lsb_release and software-properties-common installed by default.
2024-02-22 20:58:22 -08:00
Jarred Sumner
a146856d11 Support coercing port number from integer (#9047)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-22 20:11:47 -08:00
Jarred Sumner
7e906c1cae Remove ignore min branch (#9061)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-22 20:04:50 -08:00
Jarred Sumner
2e7d77b3b0 Add bench 2024-02-22 19:18:09 -08:00
Meghan Denny
ed339b367d improve Bun.stringWidth's algorithm (#9022)
* improve Bun.stringWidth's algorithm

* add a bunch more tests from string-width package

* make typescript happy

* undo typescript changes

* use better #define check for debug mode

* properly handle latin1 width tests

* support grapheme clusters

* fix trailing newline

* visibleUTF16WidthFn- add fast path for leading ascii

* add firstNonASCII16IgnoreMin

* fix firstNonASCII16CheckMin

* vectorize visibleUTF16WidthFn

* support emoji variation selector

* expose stringWidth in release mode too

* vectorize visibleLatin1Width

* support ambiguousIsNarrow option

* add typescript definition for stringWidth
2024-02-22 19:16:17 -08:00
Meghan Denny
22c25fad92 bun.js: write to pointer instead of stack in bun.js/webcore/body (#9059) 2024-02-22 19:07:56 -08:00
Jarred Sumner
a18b44d01f Bump version 2024-02-22 12:59:59 -08:00
Jarred Sumner
ee791a839f add microbenchmark 2024-02-22 12:58:35 -08:00
Zack Radisic
2605722891 shell: Allow duplicating output fds (e.g. 2>&1) (#9004)
* Open with proper perms when redirecting file to stdin

* Add test for redirecting file to stdin

* Extract redirect flags -> bun.Mode logic to function

* Remove dead code

* Support duplicating output file descriptors

* Clean up

* fix merge fuck up

* Add comment documenting weird hack to get around ordering of posix spawn actions

* Update docs

* Delete dead code

* Update docs
2024-02-21 18:45:44 -08:00
argosphil
53739f8a53 fix: modify bcrypt to be able to verify passwords directly (#9010)
Fixes #9009.

This would make the "bcrypt" algorithm (actually a variation of it)
easier to use.
2024-02-21 18:34:18 -08:00
dave caruso
44f7ddd2ff fix: ConsoleObject handles proxy better (#9042)
* fix: ConsoleObject handles proxy better

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-02-21 18:33:54 -08:00
Zack Radisic
048ae7c7b8 shell: Fix latin-1 template literal strings (#9040)
* Fix latin-1

* Move utf8 check above 8bit check
2024-02-21 18:32:42 -08:00
Jarred Sumner
2c6cd24393 Implement expect().toBeOneOf(), fix small memory leaks in expect matchers (#9043)
* Add .toBeOneOf

* Fix memory leaks in .toContain(), .toInclude(), toContainKeys(), toBeTypeOf(), toEqualIgnoringWhitespace

* Handle exception

* Ignore non-bool

* Propagate errors when the message callback throws

* fixups

* Update preload.ts

* Update jest-extended.test.js

* Update expect.zig

* comments

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-21 18:31:14 -08:00
Dylan Conway
9ee39cac8b fix(install): semver prerelease bugfix (#9026)
* make sure prereleases match correctly

* add the file

* few more tests

* make sure pre is in query, not group
2024-02-21 14:47:43 -08:00
Kenta Iwasaki
20275aa040 fix(ws/client): handle short reads on payload frame length (#9027)
* fix(ws/client): handle short reads on payload frame length

In the WebSocket specification, control frames may not be fragmented.
However, the frame parser should handle fragmented control frames
nonetheless. Whether or not the frame parser is given a set of
fragmented bytes to parse is subject to the strategy in which the client
buffers received bytes.

All stages of the frame parser currently supports parsing frames
fragmented across multiple TCP segments except for the payload frame
length parsing stage.

This commit implements buffering the bytes of a frame's payload length
into a client instance so that the websocket client is able to properly
parse payload frame lengths despite there being a short read over
incoming TCP data.

A test is added to
test/js/web/websocket/websocket-client-short-read.test.ts which creates
a make-shift WebSocket server that performs short writes over a single
WebSocket frame. The test passes with this commit.

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-02-21 14:31:57 -08:00
Cameron Haley
bdb70d5bc2 Account for initial_thread_count in napi threadsafe_function logic (#9035) 2024-02-21 14:19:43 -08:00
Jarred Sumner
6184542682 Add BUN_DEBUG flag to control where debug logs go (#9019)
* Add `BUN_DEBUG` flag to control where debug logs go

* Update all the actions

* Configure temp

* use spawn instead of rm

* Use CLOSE_RANGE_CLOEXEC

* Make some tests more reproducible

* Update hot.test.ts

* Detect file descriptor leaks and wait for stdout

* Update runner.node.mjs

* Update preload.ts

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-21 14:13:43 -08:00
865 changed files with 110594 additions and 35131 deletions

50
.github/actions/setup-bun/action.yml vendored Normal file
View File

@@ -0,0 +1,50 @@
name: Setup Bun
description: An internal version of the 'oven-sh/setup-bun' action.
inputs:
bun-version:
type: string
description: "The version of bun to install: 'latest', 'canary', 'bun-v1.0.0', etc."
default: latest
required: false
baseline:
type: boolean
description: "Whether to use the baseline version of bun."
default: false
required: false
download-url:
type: string
description: "The base URL to download bun from."
default: "https://pub-5e11e972747a44bf9aaf9394f185a982.r2.dev/releases"
required: false
runs:
using: composite
steps:
- name: Setup Bun
shell: bash
run: |
case "$(uname -s)" in
Linux*) os=linux;;
Darwin*) os=darwin;;
*) os=windows;;
esac
case "$(uname -m)" in
arm64 | aarch64) arch=arm64;;
*) arch=x64;;
esac
case "${{ inputs.baseline }}" in
true | 1) target="bun-${os}-${arch}-baseline";;
*) target="bun-${os}-${arch}";;
esac
case "${{ inputs.bun-version }}" in
latest) release="latest";;
canary) release="canary";;
*) release="bun-v${{ inputs.bun-version }}";;
esac
curl -LO "${{ inputs.download-url }}/${release}/${target}.zip"
unzip ${target}.zip
mkdir -p ${{ runner.temp }}/.bun/bin
mv ${target}/bun* ${{ runner.temp }}/.bun/bin/
chmod +x ${{ runner.temp }}/.bun/bin/*
echo "${{ runner.temp }}/.bun/bin" >> ${GITHUB_PATH}

View File

@@ -9,6 +9,7 @@ on:
branches:
- main
paths:
- ".github/workflows/bun-linux-aarch64.yml"
- "src/**/*"
- "test/**/*"
- "packages/bun-usockets/src/**/*"
@@ -17,11 +18,11 @@ on:
- "build.zig"
- "Makefile"
- "Dockerfile"
- ".github/workflows/bun-linux-aarch64.yml"
pull_request:
branches:
- main
paths:
- ".github/workflows/bun-linux-aarch64.yml"
- "src/**/*"
- "test/**/*"
- "packages/bun-usockets/src/**/*"
@@ -30,7 +31,6 @@ on:
- "build.zig"
- "Makefile"
- "Dockerfile"
- ".github/workflows/bun-linux-aarch64.yml"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
@@ -51,14 +51,14 @@ jobs:
runner: linux-arm64
build_machine_arch: aarch64
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: false
ref: ${{github.sha}}
clean: true
- run: |
bash ./scripts/update-submodules.sh
- uses: docker/setup-buildx-action@v2
- uses: docker/setup-buildx-action@v3
id: buildx
with:
install: true
@@ -66,7 +66,7 @@ jobs:
run: |
rm -rf ${{runner.temp}}/release
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
@@ -74,7 +74,7 @@ jobs:
- run: |
mkdir -p /tmp/.buildx-cache-${{matrix.tag}}
- name: Build and push
uses: docker/build-push-action@v3
uses: docker/build-push-action@v5
with:
context: .
push: false
@@ -113,14 +113,16 @@ jobs:
zip -r bun-${{matrix.tag}}-profile.zip bun-${{matrix.tag}}-profile
zip -r bun-${{matrix.tag}}.zip bun-${{matrix.tag}}
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: bun-${{matrix.tag}}-profile
path: ${{runner.temp}}/release/bun-${{matrix.tag}}-profile.zip
- uses: actions/upload-artifact@v3
if-no-files-found: "error"
- uses: actions/upload-artifact@v4
with:
name: bun-${{matrix.tag}}
path: ${{runner.temp}}/release/bun-${{matrix.tag}}.zip
if-no-files-found: "error"
- name: Release
id: release
uses: ncipollo/release-action@v1

View File

@@ -9,6 +9,7 @@ on:
branches:
- main
paths:
- ".github/workflows/bun-linux-build.yml"
- "src/**/*"
- "test/**/*"
- "packages/bun-usockets/src/**/*"
@@ -21,6 +22,7 @@ on:
branches:
- main
paths:
- ".github/workflows/bun-linux-build.yml"
- "src/**/*"
- "test/**/*"
- "packages/bun-usockets/src/**/*"
@@ -47,7 +49,7 @@ jobs:
tag: linux-x64
arch: x86_64
build_arch: amd64
runner: big-ubuntu
runner: namespace-profile-bun-linux-x64
build_machine_arch: x86_64
assertions: "OFF"
zig_optimize: "ReleaseFast"
@@ -56,7 +58,7 @@ jobs:
tag: linux-x64-baseline
arch: x86_64
build_arch: amd64
runner: big-ubuntu
runner: namespace-profile-bun-linux-x64
build_machine_arch: x86_64
assertions: "OFF"
zig_optimize: "ReleaseFast"
@@ -86,28 +88,20 @@ jobs:
submodules: recursive
ref: ${{github.sha}}
clean: true
- uses: docker/setup-buildx-action@v2
id: buildx
with:
install: true
- name: Run
run: |
rm -rf ${{runner.temp}}/release
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: |
mkdir -p /tmp/.buildx-cache-${{matrix.tag}}
- name: Build and push
uses: docker/build-push-action@v3
uses: docker/build-push-action@v5
with:
context: .
push: false
cache-from: type=local,src=/tmp/.buildx-cache-${{matrix.tag}}
cache-to: type=local,dest=/tmp/.buildx-cache-${{matrix.tag}}
build-args: |
ARCH=${{matrix.arch}}
BUILDARCH=${{matrix.build_arch}}
@@ -116,12 +110,6 @@ jobs:
GIT_SHA=${{github.sha}}
ASSERTIONS=${{matrix.assertions}}
ZIG_OPTIMIZE=${{matrix.zig_optimize}}
SCCACHE_BUCKET=bun
SCCACHE_REGION=auto
SCCACHE_S3_USE_SSL=true
SCCACHE_ENDPOINT=${{ secrets.CACHE_S3_ENDPOINT }}
AWS_ACCESS_KEY_ID=${{ secrets.CACHE_S3_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }}
platforms: linux/${{matrix.build_arch}}
target: ${{matrix.target}}
outputs: type=local,dest=${{runner.temp}}/release
@@ -154,22 +142,16 @@ jobs:
zip -r bun-${{matrix.tag}}-profile.zip bun-${{matrix.tag}}-profile
zip -r bun-${{matrix.tag}}.zip bun-${{matrix.tag}}
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: bun-${{matrix.tag}}-profile
path: ${{runner.temp}}/release/bun-${{matrix.tag}}-profile.zip
- uses: actions/upload-artifact@v3
if-no-files-found: "error"
- uses: actions/upload-artifact@v4
with:
name: bun-${{matrix.tag}}
path: ${{runner.temp}}/release/bun-${{matrix.tag}}.zip
- uses: actions/upload-artifact@v3
with:
name: bun-obj-${{matrix.tag}}
path: ${{runner.temp}}/release/bun-obj
- uses: actions/upload-artifact@v3
with:
name: ${{matrix.tag}}-dependencies
path: ${{runner.temp}}/release/bun-dependencies
if-no-files-found: "error"
- name: Release
id: release
uses: ncipollo/release-action@v1
@@ -208,7 +190,7 @@ jobs:
[Commit ${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})
linux-test:
name: Tests ${{matrix.tag}}
runs-on: ubuntu-latest
runs-on: namespace-profile-bun-linux-x64
needs: [linux]
if: github.event_name == 'pull_request'
timeout-minutes: 20
@@ -234,7 +216,7 @@ jobs:
clean: true
- id: download
name: Download
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: bun-${{matrix.tag}}
path: ${{runner.temp}}/release
@@ -251,16 +233,18 @@ jobs:
run: |
# If this hangs, it means something is seriously wrong with the build
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
bun install --cwd=test/js/third_party/prisma --verbose
# Split these into multiple steps to make it clear which one fails
- name: Install dependencies (apt-get)
run: sudo apt-get update && sudo apt-get install -y openssl
- name: Install dependencies (root)
run: bun install --verbose
- name: Install dependencies (test)
run: bun install --cwd=test --verbose
- name: Install dependencies (runner)
run: bun install --cwd=packages/bun-internal-test --verbose
- name: Install dependencies (prisma)
run: bun install --cwd=test/js/third_party/prisma --verbose
# This is disabled because the cores are ~5.5gb each
# so it is easy to hit 50gb coredump downloads. Only enable if you need to retrive one
@@ -275,19 +259,19 @@ jobs:
name: Test (node runner)
env:
SMTP_SENDGRID_SENDER: ${{ secrets.SMTP_SENDGRID_SENDER }}
TMPDIR: ${{runner.temp}}
TLS_MONGODB_DATABASE_URL: ${{ secrets.TLS_MONGODB_DATABASE_URL }}
TLS_POSTGRES_DATABASE_URL: ${{ secrets.TLS_POSTGRES_DATABASE_URL }}
BUN_FEATURE_FLAG_INTERNAL_FOR_TESTING: "true"
# if: ${{github.event.inputs.use_bun == 'false'}}
run: |
ulimit -c unlimited
ulimit -c
node packages/bun-internal-test/src/runner.node.mjs || true
- uses: actions/upload-artifact@v3
if: steps.test.outputs.failing_tests != ''
with:
name: cores
path: /cores
# - uses: actions/upload-artifact@v4
# if: steps.test.outputs.failing_tests != ''
# with:
# name: cores
# path: /cores
# if-no-files-found: "error"
- uses: sarisia/actions-status-discord@v1
if: always() && steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request'
with:

View File

@@ -37,7 +37,7 @@ on:
jobs:
macOS-zig:
name: macOS Zig Object
runs-on: med-ubuntu
runs-on: namespace-profile-zig-build
if: github.repository_owner == 'oven-sh'
strategy:
matrix:
@@ -47,25 +47,18 @@ jobs:
tag: bun-obj-darwin-aarch64
steps:
- uses: actions/checkout@v4
# - name: Checkout submodules
# run: git submodule update --init --recursive --depth=1 --progress --force
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
id: buildx
with:
install: true
- name: Checkout submodules
run: git submodule update --init --recursive --depth=1 --progress --force
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Compile Zig Object
uses: docker/build-push-action@v3
if: runner.arch == 'X64'
uses: docker/build-push-action@v5
with:
context: .
push: false
@@ -84,10 +77,11 @@ jobs:
outputs: type=local,dest=${{runner.temp}}/release
- name: Upload Zig Object
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.tag }}
path: ${{runner.temp}}/release/bun-zig.o
if-no-files-found: "error"
macOS-dependencies:
name: macOS Dependencies
@@ -141,7 +135,7 @@ jobs:
- name: Cache submodule dependencies
id: cache-deps-restore
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
path: ${{runner.temp}}/bun-deps
key: bun-deps-${{ matrix.tag }}-${{ steps.submodule-versions.outputs.sha }}
@@ -159,16 +153,17 @@ jobs:
- name: Cache submodule dependencies
if: ${{ !steps.cache-deps-restore.outputs.cache-hit }}
id: cache-deps-save
uses: actions/cache/save@v3
uses: actions/cache/save@v4
with:
path: ${{runner.temp}}/bun-deps
key: ${{ steps.cache-deps-restore.outputs.cache-primary-key }}
- name: Upload submodule dependencies
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.tag }}-deps
path: ${{runner.temp}}/bun-deps
if-no-files-found: "error"
macOS-cpp:
name: macOS C++
@@ -228,6 +223,7 @@ jobs:
cmake -S $SOURCE_DIR -B $OBJ_DIR \
-G Ninja \
-DUSE_LTO=ON \
-DCMAKE_BUILD_TYPE=Release \
-DBUN_CPP_ONLY=1 \
-DNO_CONFIGURE_DEPENDS=1
@@ -235,10 +231,11 @@ jobs:
bash compile-cpp-only.sh -v
- name: Upload C++
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.tag }}-cpp
path: ${{ runner.temp }}/bun-cpp-obj/bun-cpp-objects.a
if-no-files-found: "error"
macOS-link:
name: macOS Link
runs-on: ${{ matrix.runner }}
@@ -285,19 +282,19 @@ jobs:
echo "${{ runner.temp }}/.bun/bin" >> $GITHUB_PATH
- name: Download C++
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{ matrix.tag }}-cpp
path: ${{ runner.temp }}/bun-cpp-obj
- name: Download Zig Object
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{ matrix.obj }}
path: ${{ runner.temp }}/release
- name: Downloaded submodule dependencies
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{ matrix.tag }}-deps
path: ${{runner.temp}}/bun-deps
@@ -312,6 +309,7 @@ jobs:
cmake $SRC_DIR \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_LTO=ON \
-DBUN_LINK_ONLY=1 \
-DBUN_ZIG_OBJ="${{ runner.temp }}/release/bun-zig.o" \
-DBUN_CPP_ARCHIVE="${{ runner.temp }}/bun-cpp-obj/bun-cpp-objects.a" \
@@ -330,14 +328,16 @@ jobs:
zip -r ${{matrix.tag}}-profile.zip ${{matrix.tag}}-profile
zip -r ${{matrix.tag}}.zip ${{matrix.tag}}
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{matrix.tag}}-profile
path: ${{runner.temp}}/link-build/${{matrix.tag}}-profile.zip
- uses: actions/upload-artifact@v3
if-no-files-found: "error"
- uses: actions/upload-artifact@v4
with:
name: ${{matrix.tag}}
path: ${{runner.temp}}/link-build/${{matrix.tag}}.zip
if-no-files-found: "error"
- name: Release
id: release
uses: ncipollo/release-action@v1
@@ -394,12 +394,12 @@ jobs:
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: false
- id: download
name: Download
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{matrix.tag}}
path: ${{runner.temp}}/release
@@ -416,18 +416,21 @@ jobs:
run: |
# If this hangs, it means something is seriously wrong with the build
bun --version
- id: install
name: Install dependencies
run: |
bun install --verbose
bun install --cwd=test --verbose
bun install --cwd=packages/bun-internal-test --verbose
# Split these into multiple steps to make it clear which one fails
- name: "Install dependencies (root)"
run: bun install --verbose
- name: "Install dependencies (test)"
run: bun install --cwd=test --verbose
- name: "Install dependencies (runner)"
run: bun install --cwd=packages/bun-internal-test --verbose
- id: test
name: Test (node runner)
env:
SMTP_SENDGRID_SENDER: ${{ secrets.SMTP_SENDGRID_SENDER }}
TMPDIR: ${{runner.temp}}
TLS_MONGODB_DATABASE_URL: ${{ secrets.TLS_MONGODB_DATABASE_URL }}
TLS_POSTGRES_DATABASE_URL: ${{ secrets.TLS_POSTGRES_DATABASE_URL }}
BUN_FEATURE_FLAG_INTERNAL_FOR_TESTING: "true"
# if: ${{github.event.inputs.use_bun == 'false'}}
run: |
node packages/bun-internal-test/src/runner.node.mjs || true

View File

@@ -37,7 +37,7 @@ on:
jobs:
macos-object-files:
name: macOS Object
runs-on: med-ubuntu
runs-on: namespace-profile-zig-build
if: github.repository_owner == 'oven-sh'
strategy:
matrix:
@@ -53,31 +53,19 @@ jobs:
# tag: bun-obj-darwin-aarch64
steps:
- uses: actions/checkout@v4
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
id: buildx
with:
install: true
- name: Checkout submodules
run: git submodule update --init --recursive --depth=1 --progress --force
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Compile Zig Object
uses: docker/build-push-action@v3
uses: docker/build-push-action@v5
with:
context: .
push: false
# This doesnt seem to work
# cache-from: type=s3,endpoint_url=${{ secrets.CACHE_S3_ENDPOINT }},blobs_prefix=docker_blobs/,manifests_prefix=docker_manifests/,access_key_id=${{ secrets.CACHE_S3_ACCESS_KEY_ID }},secret_access_key=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }},bucket=bun,region=auto
# cache-to: type=s3,endpoint_url=${{ secrets.CACHE_S3_ENDPOINT }},blobs_prefix=docker_blobs/,manifests_prefix=docker_manifests/,access_key_id=${{ secrets.CACHE_S3_ACCESS_KEY_ID }},secret_access_key=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }},bucket=bun,region=auto
# This was used before, but also does not really work
cache-from: type=local,src=/tmp/.buildx-cache-${{matrix.tag}}
cache-to: type=local,dest=/tmp/.buildx-cache-${{matrix.tag}}
build-args: |
BUILDARCH=${{ runner.arch == 'X64' && 'amd64' || 'arm64' }}
BUILD_MACHINE_ARCH=${{ runner.arch == 'X64' && 'x86_64' || 'aarch64' }}
@@ -85,22 +73,15 @@ jobs:
CPU_TARGET=${{ matrix.cpu }}
TRIPLET=${{ matrix.arch }}-macos-none
GIT_SHA=${{ github.sha }}
SCCACHE_BUCKET=bun
SCCACHE_REGION=auto
SCCACHE_S3_USE_SSL=true
SCCACHE_ENDPOINT=${{ secrets.CACHE_S3_ENDPOINT }}
AWS_ACCESS_KEY_ID=${{ secrets.CACHE_S3_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }}
platforms: linux/${{ runner.arch == 'X64' && 'amd64' || 'arm64' }}
target: build_release_obj
outputs: type=local,dest=${{runner.temp}}/release
- name: Upload Zig Object
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.tag }}
path: ${{runner.temp}}/release/bun-zig.o
if-no-files-found: "error"
macOS-dependencies:
name: macOS Dependencies
runs-on: ${{ matrix.runner }}
@@ -146,7 +127,7 @@ jobs:
- name: Cache submodule dependencies
id: cache-deps-restore
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
path: ${{runner.temp}}/bun-deps
key: bun-deps-${{ matrix.tag }}-${{ steps.submodule-versions.outputs.sha }}
@@ -164,16 +145,17 @@ jobs:
- name: Cache submodule dependencies
if: ${{ !steps.cache-deps-restore.outputs.cache-hit }}
id: cache-deps-save
uses: actions/cache/save@v3
uses: actions/cache/save@v4
with:
path: ${{runner.temp}}/bun-deps
key: ${{ steps.cache-deps-restore.outputs.cache-primary-key }}
- name: Upload submodule dependencies
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.tag }}-deps
path: ${{runner.temp}}/bun-deps
if-no-files-found: "error"
macOS-cpp:
name: macOS C++
@@ -233,6 +215,7 @@ jobs:
cmake -S $SOURCE_DIR -B $OBJ_DIR \
-G Ninja \
-DUSE_LTO=ON \
-DCMAKE_BUILD_TYPE=Release \
-DBUN_CPP_ONLY=1 \
-DNO_CONFIGURE_DEPENDS=1
@@ -240,10 +223,11 @@ jobs:
bash compile-cpp-only.sh -v
- name: Upload C++
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.tag }}-cpp
path: ${{ runner.temp }}/bun-cpp-obj/bun-cpp-objects.a
if-no-files-found: "error"
macOS:
name: macOS Link
runs-on: ${{ matrix.runner }}
@@ -262,7 +246,7 @@ jobs:
runner: macos-12-large
artifact: bun-obj-darwin-x64-baseline
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Checkout submodules
run: git submodule update --init --recursive --depth=1 --progress --force
@@ -286,19 +270,19 @@ jobs:
echo "${{ runner.temp }}/.bun/bin" >> $GITHUB_PATH
- name: Download C++
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{ matrix.tag }}-cpp
path: ${{ runner.temp }}/bun-cpp-obj
- name: Download Zig Object
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{ matrix.obj }}
path: ${{ runner.temp }}/release
- name: Downloaded submodule dependencies
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{ matrix.tag }}-deps
path: ${{runner.temp}}/bun-deps
@@ -312,6 +296,7 @@ jobs:
cd ${{runner.temp}}/link-build
cmake $SRC_DIR \
-G Ninja \
-DUSE_LTO=ON \
-DCMAKE_BUILD_TYPE=Release \
-DBUN_LINK_ONLY=1 \
-DBUN_ZIG_OBJ="${{ runner.temp }}/release/bun-zig.o" \
@@ -331,14 +316,16 @@ jobs:
zip -r ${{matrix.tag}}-profile.zip ${{matrix.tag}}-profile
zip -r ${{matrix.tag}}.zip ${{matrix.tag}}
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{matrix.tag}}-profile
path: ${{runner.temp}}/link-build/${{matrix.tag}}-profile.zip
- uses: actions/upload-artifact@v3
if-no-files-found: "error"
- uses: actions/upload-artifact@v4
with:
name: ${{matrix.tag}}
path: ${{runner.temp}}/link-build/${{matrix.tag}}.zip
if-no-files-found: "error"
- name: Release
id: release
uses: ncipollo/release-action@v1
@@ -396,12 +383,12 @@ jobs:
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: false
- id: download
name: Download
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{matrix.tag}}
path: ${{runner.temp}}/release
@@ -428,8 +415,10 @@ jobs:
name: Test (node runner)
env:
SMTP_SENDGRID_SENDER: ${{ secrets.SMTP_SENDGRID_SENDER }}
TMPDIR: ${{runner.temp}}
TLS_MONGODB_DATABASE_URL: ${{ secrets.TLS_MONGODB_DATABASE_URL }}
TLS_POSTGRES_DATABASE_URL: ${{ secrets.TLS_POSTGRES_DATABASE_URL }}
BUN_FEATURE_FLAG_INTERNAL_FOR_TESTING: "true"
# if: ${{github.event.inputs.use_bun == 'false'}}
run: |
node packages/bun-internal-test/src/runner.node.mjs || true

View File

@@ -37,7 +37,7 @@ on:
jobs:
macOS-zig:
name: macOS Zig Object
runs-on: med-ubuntu
runs-on: namespace-profile-zig-build
if: github.repository_owner == 'oven-sh'
strategy:
matrix:
@@ -50,31 +50,19 @@ jobs:
tag: bun-obj-darwin-x64
steps:
- uses: actions/checkout@v4
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
id: buildx
with:
install: true
- name: Checkout submodules
run: git submodule update --init --recursive --depth=1 --progress --force
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Compile Zig Object
uses: docker/build-push-action@v3
uses: docker/build-push-action@v5
with:
context: .
push: false
# This doesnt seem to work
# cache-from: type=s3,endpoint_url=${{ secrets.CACHE_S3_ENDPOINT }},blobs_prefix=docker_blobs/,manifests_prefix=docker_manifests/,access_key_id=${{ secrets.CACHE_S3_ACCESS_KEY_ID }},secret_access_key=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }},bucket=bun,region=auto
# cache-to: type=s3,endpoint_url=${{ secrets.CACHE_S3_ENDPOINT }},blobs_prefix=docker_blobs/,manifests_prefix=docker_manifests/,access_key_id=${{ secrets.CACHE_S3_ACCESS_KEY_ID }},secret_access_key=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }},bucket=bun,region=auto
# This was used before, but also does not really work
cache-from: type=local,src=/tmp/.buildx-cache-${{matrix.tag}}
cache-to: type=local,dest=/tmp/.buildx-cache-${{matrix.tag}}
build-args: |
BUILDARCH=${{ runner.arch == 'X64' && 'amd64' || 'arm64' }}
BUILD_MACHINE_ARCH=${{ runner.arch == 'X64' && 'x86_64' || 'aarch64' }}
@@ -82,22 +70,15 @@ jobs:
CPU_TARGET=${{ matrix.cpu }}
TRIPLET=${{ matrix.arch }}-macos-none
GIT_SHA=${{ github.sha }}
SCCACHE_BUCKET=bun
SCCACHE_REGION=auto
SCCACHE_S3_USE_SSL=true
SCCACHE_ENDPOINT=${{ secrets.CACHE_S3_ENDPOINT }}
AWS_ACCESS_KEY_ID=${{ secrets.CACHE_S3_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }}
platforms: linux/${{ runner.arch == 'X64' && 'amd64' || 'arm64' }}
target: build_release_obj
outputs: type=local,dest=${{runner.temp}}/release
- name: Upload Zig Object
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.tag }}
path: ${{runner.temp}}/release/bun-zig.o
if-no-files-found: "error"
macOS-dependencies:
name: macOS Dependencies
@@ -144,7 +125,7 @@ jobs:
- name: Cache submodule dependencies
id: cache-deps-restore
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
path: ${{runner.temp}}/bun-deps
key: bun-deps-${{ matrix.tag }}-${{ steps.submodule-versions.outputs.sha }}
@@ -162,16 +143,17 @@ jobs:
- name: Cache submodule dependencies
if: ${{ !steps.cache-deps-restore.outputs.cache-hit }}
id: cache-deps-save
uses: actions/cache/save@v3
uses: actions/cache/save@v4
with:
path: ${{runner.temp}}/bun-deps
key: ${{ steps.cache-deps-restore.outputs.cache-primary-key }}
- name: Upload submodule dependencies
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.tag }}-deps
path: ${{runner.temp}}/bun-deps
if-no-files-found: "error"
macOS-cpp:
name: macOS C++
@@ -232,16 +214,18 @@ jobs:
cmake -S $SOURCE_DIR -B $OBJ_DIR \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_LTO=ON \
-DBUN_CPP_ONLY=1 \
-DNO_CONFIGURE_DEPENDS=1
bash compile-cpp-only.sh -v
- name: Upload C++
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.tag }}-cpp
path: ${{ runner.temp }}/bun-cpp-obj/bun-cpp-objects.a
if-no-files-found: "error"
macOS:
name: macOS Link
runs-on: ${{ matrix.runner }}
@@ -260,7 +244,7 @@ jobs:
runner: macos-12-large
artifact: bun-obj-darwin-x64
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Checkout submodules
run: git submodule update --init --recursive --depth=1 --progress --force
@@ -284,19 +268,19 @@ jobs:
echo "${{ runner.temp }}/.bun/bin" >> $GITHUB_PATH
- name: Download C++
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{ matrix.tag }}-cpp
path: ${{ runner.temp }}/bun-cpp-obj
- name: Download Zig Object
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{ matrix.obj }}
path: ${{ runner.temp }}/release
- name: Downloaded submodule dependencies
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{ matrix.tag }}-deps
path: ${{runner.temp}}/bun-deps
@@ -311,6 +295,7 @@ jobs:
cmake $SRC_DIR \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_LTO=ON \
-DBUN_LINK_ONLY=1 \
-DBUN_ZIG_OBJ="${{ runner.temp }}/release/bun-zig.o" \
-DBUN_CPP_ARCHIVE="${{ runner.temp }}/bun-cpp-obj/bun-cpp-objects.a" \
@@ -329,14 +314,16 @@ jobs:
zip -r ${{matrix.tag}}-profile.zip ${{matrix.tag}}-profile
zip -r ${{matrix.tag}}.zip ${{matrix.tag}}
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{matrix.tag}}-profile
path: ${{runner.temp}}/link-build/${{matrix.tag}}-profile.zip
- uses: actions/upload-artifact@v3
if-no-files-found: "error"
- uses: actions/upload-artifact@v4
with:
name: ${{matrix.tag}}
path: ${{runner.temp}}/link-build/${{matrix.tag}}.zip
if-no-files-found: "error"
- name: Release
id: release
uses: ncipollo/release-action@v1
@@ -393,12 +380,12 @@ jobs:
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: false
- id: download
name: Download
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{matrix.tag}}
path: ${{runner.temp}}/release
@@ -415,18 +402,21 @@ jobs:
run: |
# If this hangs, it means something is seriously wrong with the build
bun --version
- id: install
name: Install dependencies
run: |
bun install --verbose
bun install --cwd=test --verbose
bun install --cwd=packages/bun-internal-test --verbose
# Split these into multiple steps to make it clear which one fails
- name: "Install dependencies (root)"
run: bun install --verbose
- name: "Install dependencies (test)"
run: bun install --cwd=test --verbose
- name: "Install dependencies (runner)"
run: bun install --cwd=packages/bun-internal-test --verbose
- id: test
name: Test (node runner)
env:
SMTP_SENDGRID_SENDER: ${{ secrets.SMTP_SENDGRID_SENDER }}
TLS_MONGODB_DATABASE_URL: ${{ secrets.TLS_MONGODB_DATABASE_URL }}
TMPDIR: ${{runner.temp}}
TLS_POSTGRES_DATABASE_URL: ${{ secrets.TLS_POSTGRES_DATABASE_URL }}
BUN_FEATURE_FLAG_INTERNAL_FOR_TESTING: "true"
# if: ${{github.event.inputs.use_bun == 'false'}}
run: |
node packages/bun-internal-test/src/runner.node.mjs || true

44
.github/workflows/bun-release-test.yml vendored Normal file
View File

@@ -0,0 +1,44 @@
# This workflow tests bun-release's code and the packages to ensure that npm,
# yarn, and pnpm can install bun on all platforms. This does not test that bun
# itself works as it hardcodes 1.1.0 as the version to package.
name: bun-release-test
concurrency: release-test
on:
pull_request:
paths:
- "packages/bun-release/**"
- ".github/workflows/bun-release-test.yml"
jobs:
test-release-script:
name: Test Release Script
strategy:
matrix:
machine: [namespace-profile-bun-linux-x64, linux-arm64, macos-arm64, macos-12-large, windows-latest]
fail-fast: false
runs-on: ${{ matrix.machine }}
permissions:
contents: read
defaults:
run:
working-directory: packages/bun-release
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: "1.1.0"
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Dependencies
run: bun install && npm i -g pnpm yarn npm
- name: Release
run: bun upload-npm -- 1.1.0 test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -51,7 +51,7 @@ jobs:
working-directory: packages/bun-release
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup GPG
uses: crazy-max/ghaction-import-gpg@v5
with:
@@ -81,7 +81,7 @@ jobs:
working-directory: packages/bun-release
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
@@ -105,7 +105,7 @@ jobs:
working-directory: packages/bun-types
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
with:
@@ -170,12 +170,12 @@ jobs:
suffix: -distroless
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Docker emulator
uses: docker/setup-qemu-action@v2
- id: buildx
name: Setup Docker buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64
- id: metadata
@@ -192,12 +192,12 @@ jobs:
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
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push to Docker
uses: docker/build-push-action@v3
uses: docker/build-push-action@v5
with:
context: ./dockerhub/${{ matrix.dir || matrix.variant }}
platforms: linux/amd64,linux/arm64
@@ -216,7 +216,7 @@ jobs:
if: ${{ github.event_name == 'release' || github.event.inputs.use-homebrew == 'true' }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: oven-sh/homebrew-bun
token: ${{ secrets.ROBOBUN_TOKEN }}
@@ -252,7 +252,7 @@ jobs:
working-directory: packages/bun-release
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:

View File

@@ -18,7 +18,7 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install bun
uses: oven-sh/setup-bun@v1

View File

@@ -18,6 +18,7 @@ on:
push:
branches: [main]
paths:
- ".github/workflows/*.yml"
- "src/**/*"
- "test/**/*"
- "packages/bun-usockets/src/**/*"
@@ -29,6 +30,7 @@ on:
pull_request:
branches: [main]
paths:
- ".github/workflows/*.yml"
- "src/**/*"
- "test/**/*"
- "packages/bun-usockets/src/**/*"
@@ -53,20 +55,17 @@ jobs:
cpu: [haswell, nehalem]
arch: [x86_64]
name: Zig Build
runs-on: med-ubuntu
runs-on: namespace-profile-zig-build
timeout-minutes: 60
if: github.repository_owner == 'oven-sh'
steps:
- run: git config --global core.autocrlf false && git config --global core.eol lf
- uses: actions/checkout@v4
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
id: buildx
with:
install: true
- name: Checkout submodules
run: git submodule update --init --recursive --depth=1 --progress --force
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
@@ -79,8 +78,7 @@ jobs:
echo "canary_revision=$(GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" bash ./scripts/calculate-canary-revision.sh --raw)" >> $GITHUB_OUTPUT
- name: Compile Zig Object
uses: docker/build-push-action@v3
if: runner.arch == 'X64'
uses: docker/build-push-action@v5
with:
context: .
push: false
@@ -94,7 +92,7 @@ jobs:
CPU_TARGET=${{ matrix.cpu }}
TRIPLET=${{ matrix.arch }}-windows-msvc
GIT_SHA=${{ github.sha }}
CANARY=${{ env.canary == 'true' && steps.canary.outputs.canary_revision || '0' }}
CANARY=0
ZIG_OPTIMIZE=ReleaseSafe
# TODO(@paperdave): enable ASSERTIONS=1
platforms: linux/${{ runner.arch == 'X64' && 'amd64' || 'arm64' }}
@@ -102,10 +100,11 @@ jobs:
outputs: type=local,dest=${{runner.temp}}/release
- name: Upload Zig Object
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}-zig${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}
path: ${{runner.temp}}/release/bun-zig.o
if-no-files-found: "error"
windows-dependencies:
name: Dependencies
@@ -138,7 +137,7 @@ jobs:
- name: Try fetch dependencies
id: cache-deps-restore
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
path: bun-deps
key: bun-deps-${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}-${{ steps.submodule-versions.outputs.sha }}
@@ -165,15 +164,16 @@ jobs:
.\scripts\all-dependencies.ps1
- name: Upload Dependencies
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}-deps${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}
path: bun-deps/
if-no-files-found: "error"
- name: Cache Dependencies
if: ${{ !steps.cache-deps-restore.outputs.cache-hit }}
id: cache-deps-save
uses: actions/cache/save@v3
uses: actions/cache/save@v4
with:
path: bun-deps
key: ${{ steps.cache-deps-restore.outputs.cache-primary-key }}
@@ -204,10 +204,11 @@ jobs:
if: ${{ env.canary == 'true' }}
run: |
echo "canary_revision=$(GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" bash ./scripts/calculate-canary-revision.sh --raw)" > build-codegen-win32-x64/.canary_revision
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}-codegen
path: build-codegen-win32-x64/
if-no-files-found: "error"
windows-cpp:
name: C++ Build
@@ -228,7 +229,7 @@ jobs:
version: ${{ env.LLVM_VERSION }}
- run: choco install -y ninja
- name: Download Codegen
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}-codegen
path: build
@@ -248,7 +249,8 @@ jobs:
# $env:AWS_SECRET_ACCESS_KEY="${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }}"
# $SCCACHE="$PWD/${sczip}/${sczip}/sccache.exe"
$CANARY_REVISION = if (Test-Path build/.canary_revision) { Get-Content build/.canary_revision } else { "0" }
# $CANARY_REVISION = if (Test-Path build/.canary_revision) { Get-Content build/.canary_revision } else { "0" }
$CANARY_REVISION = 0
.\scripts\env.ps1 ${{ matrix.cpu == 'nehalem' && '-Baseline' || '' }}
.\scripts\update-submodules.ps1
@@ -263,10 +265,11 @@ jobs:
if ($LASTEXITCODE -ne 0) { throw "CMake configuration failed" }
.\compile-cpp-only.ps1 -v
if ($LASTEXITCODE -ne 0) { throw "C++ compilation failed" }
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}-cpp${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}
path: build/bun-cpp-objects.a
if-no-files-found: "error"
windows-link:
strategy:
@@ -288,22 +291,22 @@ jobs:
version: ${{ env.LLVM_VERSION }}
- run: choco install -y ninja
- name: Download Codegen
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}-codegen
path: build
- name: Download Dependencies
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}-deps${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}
path: bun-deps
- name: Download Zig Object
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}-zig${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}
path: bun-zig
- name: Download C++ Objects
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}-cpp${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}
path: bun-cpp
@@ -312,7 +315,8 @@ jobs:
.\scripts\update-submodules.ps1
.\scripts\env.ps1 ${{ matrix.cpu == 'nehalem' && '-Baseline' || '' }}
Set-Location build
$CANARY_REVISION = if (Test-Path build/.canary_revision) { Get-Content build/.canary_revision } else { "0" }
# $CANARY_REVISION = if (Test-Path build/.canary_revision) { Get-Content build/.canary_revision } else { "0" }
$CANARY_REVISION = 0
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release `
-DNO_CODEGEN=1 `
-DNO_CONFIGURE_DEPENDS=1 `
@@ -336,14 +340,16 @@ jobs:
cp -r build\bun.pdb "$Dist\bun.pdb"
Compress-Archive "$Dist" "$Dist.zip"
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}
path: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}.zip
- uses: actions/upload-artifact@v3
if-no-files-found: "error"
- uses: actions/upload-artifact@v4
with:
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}-profile
path: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}-profile.zip
if-no-files-found: "error"
- name: Release
id: release
uses: ncipollo/release-action@v1
@@ -398,12 +404,12 @@ jobs:
- run: git config --global core.autocrlf false && git config --global core.eol lf
- id: checkout
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: false
- id: download
name: Download Release
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}-profile
path: ${{runner.temp}}/release
@@ -417,28 +423,30 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: |
# bun install --verbose
# bun install --cwd=test --verbose
# bun install --cwd=packages/bun-internal-test --verbose
npm install
cd test && npm install
cd ../packages/bun-internal-test && npm install
cd ../..
- uses: secondlife/setup-cygwin@v3
with:
packages: bash
# Split these into multiple steps to make it clear which one fails
- name: Install dependencies (root)
run: bun install --verbose
- name: Install dependencies (test)
run: bun install --cwd=test --verbose
- name: Install dependencies (runner)
run: bun install --cwd=packages/bun-internal-test --verbose
- id: test
name: Run tests
env:
SMTP_SENDGRID_SENDER: ${{ secrets.SMTP_SENDGRID_SENDER }}
TMPDIR: ${{runner.temp}}
TLS_MONGODB_DATABASE_URL: ${{ secrets.TLS_MONGODB_DATABASE_URL }}
TLS_POSTGRES_DATABASE_URL: ${{ secrets.TLS_POSTGRES_DATABASE_URL }}
BUN_FEATURE_FLAG_INTERNAL_FOR_TESTING: "true"
SHELLOPTS: igncr
BUN_PATH_BASE: ${{runner.temp}}
BUN_PATH: release/${{env.tag}}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}-profile/bun.exe
run: |
try {
$ErrorActionPreference = "SilentlyContinue"
$null = node packages/bun-internal-test/src/runner.node.mjs ${{runner.temp}}/release/${{env.tag}}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}-profile/bun.exe || $true
} catch {}
$ErrorActionPreference = "Stop"
node packages/bun-internal-test/src/runner.node.mjs || true
shell: bash
- uses: sarisia/actions-status-discord@v1
if: always() && steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request'
with:
@@ -456,7 +464,7 @@ jobs:
[Full Test Output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})
- uses: sarisia/actions-status-discord@v1
if: always() && steps.test.outputs.regressing_tests != '' && github.event_name == 'pull_request'
if: always() && steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request'
with:
title: ""
webhook: ${{ secrets.DISCORD_WEBHOOK }}
@@ -464,26 +472,29 @@ jobs:
noprefix: true
nocontext: true
description: |
### ❌🪟 [${{github.event.pull_request.title}}](https://github.com/oven-sh/bun/pull/${{github.event.number}})
Pull Request
### ❌ [${{github.event.pull_request.title}}](https://github.com/oven-sh/bun/pull/${{github.event.number}})
@${{ github.actor }}, there are **${{ steps.test.outputs.regressing_test_count }} test regressions** on Windows ${{ matrix.arch }}${{ matrix.cpu == 'nehalem' && ' Baseline' || '' }}
@${{ github.actor }}, there are ${{ steps.test.outputs.failing_tests_count }} files with test failures on bun-windows-${{ matrix.arch }}-${{ matrix.cpu }}
${{ steps.test.outputs.regressing_tests }}
${{ steps.test.outputs.failing_tests }}
[Full Test Output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})
**[View test output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})**
- name: Comment on PR
if: always() && steps.test.outputs.regressing_tests != '' && github.event_name == 'pull_request'
if: always() && steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request'
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: test-windows-${{ matrix.arch }}-${{ matrix.cpu }}
message: |
### ❌🪟 @${{ github.actor }}, there are **${{ steps.test.outputs.regressing_test_count }} test regressions** on Windows ${{ matrix.arch }}${{ matrix.cpu == 'nehalem' && ' Baseline' || '' }}
@${{ github.actor }} ${{ steps.test.outputs.failing_tests_count }} files with test failures on bun-windows-${{ matrix.arch }}-${{ matrix.cpu }}
${{ steps.test.outputs.regressing_tests }}
${{ steps.test.outputs.failing_tests }}
[Full Test Output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})
**[View test output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})**
<sup>[#${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})</sup>
- name: Uncomment on PR
if: steps.test.outputs.regressing_tests == '' && github.event_name == 'pull_request'
if: steps.test.outputs.failing_tests == '' && github.event_name == 'pull_request'
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: test-windows-${{ matrix.arch }}-${{ matrix.cpu }}
@@ -493,5 +504,5 @@ jobs:
✅🪟 Test regressions on Windows ${{ matrix.arch }}${{ matrix.cpu == 'nehalem' && ' Baseline' || '' }} have been resolved.
- id: fail
name: Fail the build
if: steps.test.outputs.regressing_tests != '' && github.event_name == 'pull_request'
if: steps.test.outputs.failing_tests != ''
run: exit 1

View File

@@ -1,5 +1,8 @@
name: autofix.ci # Must be named this for autofix.ci to work
permissions:
contents: read
on:
workflow_dispatch:
pull_request:
@@ -10,24 +13,22 @@ on:
env:
ZIG_VERSION: 0.12.0-dev.1828+225fe6ddb
permissions:
contents: read
jobs:
format:
name: format
runs-on: ubuntu-latest
runs-on: ${{ vars.RUNNER_LINUX_X64 || 'ubuntu-latest' }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
sparse-checkout: |
.github
src
packages
test
bench
- name: Setup Bun
uses: oven-sh/setup-bun@v1
uses: ./.github/actions/setup-bun
with:
bun-version: "1.0.21"
- name: Setup Zig

311
.gitignore vendored
View File

@@ -1,168 +1,143 @@
.DS_Store
zig-cache
packages/*/*.wasm
*.o
*.a
profile.json
.env
node_modules
.envrc
.swcrc
yarn.lock
dist
*.tmp
*.log
*.out.js
*.out.refresh.js
**/package-lock.json
build
*.wat
zig-out
pnpm-lock.yaml
README.md.template
src/deps/zig-clap/example
src/deps/zig-clap/README.md
src/deps/zig-clap/.github
src/deps/zig-clap/.gitattributes
out
outdir
.trace
cover
coverage
coverv
*.trace
github
out.*
out
.parcel-cache
esbuilddir
*.bun
parceldist
esbuilddir
outdir/
outcss
.next
txt.js
.idea
.vscode/cpp*
.vscode/clang*
node_modules_*
*.jsb
*.zip
bun-zigld
bun-singlehtreaded
bun-nomimalloc
bun-mimalloc
examples/lotta-modules/bun-yday
examples/lotta-modules/bun-old
examples/lotta-modules/bun-nofscache
src/node-fallbacks/out/*
src/node-fallbacks/node_modules
sign.json
release/
*.dmg
sign.*.json
packages/debug-*
packages/bun-cli/postinstall.js
packages/bun-*/bun
packages/bun-*/bun-profile
packages/bun-*/debug-bun
packages/bun-*/*.o
packages/bun-cli/postinstall.js
packages/bun-cli/bin/*
bun-test-scratch
misctools/fetch
src/deps/libiconv
src/deps/openssl
src/tests.zig
*.blob
src/deps/s2n-tls
.npm
.npm.gz
bun-binary
src/deps/PLCrashReporter/
*.dSYM
*.crash
misctools/sha
packages/bun-wasm/*.mjs
packages/bun-wasm/*.cjs
packages/bun-wasm/*.map
packages/bun-wasm/*.js
packages/bun-wasm/*.d.ts
packages/bun-wasm/*.d.cts
packages/bun-wasm/*.d.mts
*.bc
src/fallback.version
src/runtime.version
*.sqlite
*.database
*.db
misctools/machbench
*.big
.eslintcache
/bun-webkit
src/deps/c-ares/build
src/bun.js/bindings-obj
src/bun.js/debug-bindings-obj
failing-tests.txt
test.txt
myscript.sh
cold-jsc-start
cold-jsc-start.d
/testdir
/test.ts
/test.js
src/js/out/modules*
src/js/out/functions*
src/js/out/tmp
src/js/out/DebugPath.h
make-dev-stats.csv
.uuid
tsconfig.tsbuildinfo
test/js/bun/glob/fixtures
*.lib
*.pdb
CMakeFiles
build.ninja
.ninja_deps
.ninja_log
CMakeCache.txt
cmake_install.cmake
compile_commands.json
*.lib
x64
**/*.vcxproj*
**/*.sln*
**/*.dir
**/*.pdb
/.webkit-cache
/.cache
/src/deps/libuv
/build-*/
.vs
**/.verdaccio-db.json
/test-report.md
/test-report.json
.DS_Store
.env
.envrc
.eslintcache
.idea
.next
.ninja_deps
.ninja_log
.npm
.npm.gz
.parcel-cache
.swcrc
.trace
.uuid
.vs
.vscode/clang*
.vscode/cpp*
*.a
*.bc
*.big
*.blob
*.bun
*.crash
*.database
*.db
*.dmg
*.dSYM
*.jsb
*.lib
*.log
*.o
*.out.js
*.out.refresh.js
*.pdb
*.sqlite
*.tmp
*.trace
*.wat
*.zip
**/.verdaccio-db.json
**/*.dir
**/*.pdb
**/*.sln*
**/*.vcxproj*
**/package-lock.json
/.cache
/.webkit-cache
/build-*/
/bun-webkit
/kcov-out
/src/deps/libuv
/test-report.json
/test-report.md
/test.js
/test.ts
/testdir
build
build.ninja
bun-binary
bun-mimalloc
bun-nomimalloc
bun-singlehtreaded
bun-test-scratch
bun-zigld
cmake_install.cmake
CMakeCache.txt
CMakeFiles
cold-jsc-start
cold-jsc-start.d
compile_commands.json
cover
coverage
coverv
dist
esbuilddir
examples/lotta-modules/bun-nofscache
examples/lotta-modules/bun-old
examples/lotta-modules/bun-yday
failing-tests.txt
github
make-dev-stats.csv
misctools/fetch
misctools/machbench
misctools/sha
myscript.sh
node_modules
node_modules_*
out
out.*
outcss
outdir
outdir/
packages/*/*.wasm
packages/bun-*/*.o
packages/bun-*/bun
packages/bun-*/bun-profile
packages/bun-*/debug-bun
packages/bun-cli/bin/*
packages/bun-cli/postinstall.js
packages/bun-wasm/*.cjs
packages/bun-wasm/*.d.cts
packages/bun-wasm/*.d.mts
packages/bun-wasm/*.d.ts
packages/bun-wasm/*.js
packages/bun-wasm/*.map
packages/bun-wasm/*.mjs
packages/debug-*
parceldist
pnpm-lock.yaml
profile.json
README.md.template
release/
sign.*.json
sign.json
src/bun.js/bindings-obj
src/bun.js/bindings/GeneratedJS2Native.zig
src/bun.js/debug-bindings-obj
src/deps/c-ares/build
src/deps/libiconv
src/deps/openssl
src/deps/PLCrashReporter/
src/deps/s2n-tls
src/deps/zig-clap/.gitattributes
src/deps/zig-clap/.github
src/deps/zig-clap/example
src/deps/zig-clap/README.md
src/fallback.version
src/js/out/DebugPath.h
src/js/out/functions*
src/js/out/modules*
src/js/out/tmp
src/node-fallbacks/node_modules
src/node-fallbacks/out/*
src/runtime.version
src/tests.zig
test.txt
test/js/bun/glob/fixtures
tsconfig.tsbuildinfo
txt.js
x64
yarn.lock
zig-cache
zig-out

9
.gitmodules vendored
View File

@@ -82,4 +82,11 @@ url = https://github.com/litespeedtech/ls-hpack.git
ignore = dirty
depth = 1
shallow = true
fetchRecurseSubmodules = false
fetchRecurseSubmodules = false
[submodule "zig"]
path = src/deps/zig
url = https://github.com/oven-sh/zig
branch = bun
depth = 1
shallow = true
fetchRecurseSubmodules = false

6
.prettierignore Normal file
View File

@@ -0,0 +1,6 @@
src/bun.js/WebKit
src/deps
test/snapshots
test/js/deno
src/react-refresh.js
*.min.js

15
.prettierrc Normal file
View File

@@ -0,0 +1,15 @@
{
"arrowParens": "avoid",
"printWidth": 120,
"trailingComma": "all",
"useTabs": false,
"quoteProps": "preserve",
"overrides": [
{
"files": ["*.md"],
"options": {
"printWidth": 80
}
}
]
}

View File

@@ -55,6 +55,7 @@
"name": "BunWithJSCDebug",
"forcedInclude": ["${workspaceFolder}/src/bun.js/bindings/root.h"],
"includePath": [
"${workspaceFolder}/build/codegen",
"${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/",

View File

@@ -11,7 +11,7 @@
// JavaScript
"oven.bun-vscode",
"biomejs.biome",
"esbenp.prettier-vscode",
// TypeScript
"better-ts-errors.better-ts-errors",
@@ -28,6 +28,6 @@
"tamasfe.even-better-toml",
// Other
"bierner.comment-tagged-templates",
"bierner.comment-tagged-templates"
]
}

229
.vscode/launch.json generated vendored
View File

@@ -18,7 +18,22 @@
"env": {
"FORCE_COLOR": "1",
"BUN_DEBUG_QUIET_LOGS": "1",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2"
},
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "bun test [file] --only",
"program": "${workspaceFolder}/build/bun-debug",
"args": ["test", "--only", "${file}"],
"cwd": "${workspaceFolder}/test",
"env": {
"FORCE_COLOR": "1",
"BUN_DEBUG_QUIET_LOGS": "1",
"BUN_GARBAGE_COLLECTOR_LEVEL": "1",
"BUN_DEBUG_FileReader": "1"
},
"console": "internalConsole"
},
@@ -32,7 +47,7 @@
"env": {
"FORCE_COLOR": "1",
"BUN_DEBUG_QUIET_LOGS": "1",
"BUN_GARBAGE_COLLECTOR_LEVEL": "0",
"BUN_GARBAGE_COLLECTOR_LEVEL": "0"
},
"console": "internalConsole"
},
@@ -46,7 +61,7 @@
"env": {
"FORCE_COLOR": "1",
"BUN_DEBUG_QUIET_LOGS": "0",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2"
},
"console": "internalConsole"
},
@@ -60,7 +75,7 @@
"env": {
"FORCE_COLOR": "1",
"BUN_DEBUG_QUIET_LOGS": "1",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2"
},
"console": "internalConsole"
},
@@ -74,7 +89,7 @@
"env": {
"FORCE_COLOR": "1",
"BUN_DEBUG_QUIET_LOGS": "1",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2"
},
"console": "internalConsole"
},
@@ -93,7 +108,7 @@
},
"console": "internalConsole",
"serverReadyAction": {
"pattern": "https:\/\/debug.bun.sh\/#localhost:([0-9]+)/",
"pattern": "https://debug.bun.sh/#localhost:([0-9]+)/",
"uriFormat": "https://debug.bun.sh/#ws://localhost:%s/",
"action": "openExternally"
}
@@ -113,7 +128,7 @@
},
"console": "internalConsole",
"serverReadyAction": {
"pattern": "https:\/\/debug.bun.sh\/#localhost:([0-9]+)/",
"pattern": "https://debug.bun.sh/#localhost:([0-9]+)/",
"uriFormat": "https://debug.bun.sh/#ws://localhost:%s/",
"action": "openExternally"
}
@@ -129,9 +144,9 @@
"env": {
"FORCE_COLOR": "0",
"BUN_DEBUG_QUIET_LOGS": "1",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2"
},
"console": "internalConsole",
"console": "internalConsole"
},
{
"type": "lldb",
@@ -143,7 +158,7 @@
"env": {
"FORCE_COLOR": "1",
"BUN_DEBUG_QUIET_LOGS": "1",
"BUN_GARBAGE_COLLECTOR_LEVEL": "0",
"BUN_GARBAGE_COLLECTOR_LEVEL": "0"
},
"console": "internalConsole"
},
@@ -157,7 +172,7 @@
"env": {
"FORCE_COLOR": "1",
"BUN_DEBUG_QUIET_LOGS": "0",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2"
},
"console": "internalConsole"
},
@@ -171,7 +186,7 @@
"env": {
"FORCE_COLOR": "1",
"BUN_DEBUG_QUIET_LOGS": "1",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2"
},
"console": "internalConsole"
},
@@ -185,7 +200,7 @@
"env": {
"FORCE_COLOR": "1",
"BUN_DEBUG_QUIET_LOGS": "1",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2"
},
"console": "internalConsole"
},
@@ -204,10 +219,10 @@
},
"console": "internalConsole",
"serverReadyAction": {
"pattern": "https:\/\/debug.bun.sh\/#localhost:([0-9]+)/",
"pattern": "https://debug.bun.sh/#localhost:([0-9]+)/",
"uriFormat": "https://debug.bun.sh/#ws://localhost:%s/",
"action": "openExternally"
},
}
},
{
"type": "lldb",
@@ -224,10 +239,10 @@
},
"console": "internalConsole",
"serverReadyAction": {
"pattern": "https:\/\/debug.bun.sh\/#localhost:([0-9]+)/",
"pattern": "https://debug.bun.sh/#localhost:([0-9]+)/",
"uriFormat": "https://debug.bun.sh/#ws://localhost:%s/",
"action": "openExternally"
},
}
},
// bun test [...]
{
@@ -240,7 +255,7 @@
"env": {
"FORCE_COLOR": "1",
"BUN_DEBUG_QUIET_LOGS": "1",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2"
},
"console": "internalConsole"
},
@@ -254,7 +269,7 @@
"env": {
"FORCE_COLOR": "1",
"BUN_DEBUG_QUIET_LOGS": "1",
"BUN_GARBAGE_COLLECTOR_LEVEL": "0",
"BUN_GARBAGE_COLLECTOR_LEVEL": "0"
},
"console": "internalConsole"
},
@@ -268,7 +283,7 @@
"env": {
"FORCE_COLOR": "1",
"BUN_DEBUG_QUIET_LOGS": "0",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2"
},
"console": "internalConsole"
},
@@ -282,7 +297,7 @@
"env": {
"FORCE_COLOR": "1",
"BUN_DEBUG_QUIET_LOGS": "1",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2"
},
"console": "internalConsole"
},
@@ -296,7 +311,7 @@
"env": {
"FORCE_COLOR": "1",
"BUN_DEBUG_QUIET_LOGS": "1",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2"
},
"console": "internalConsole"
},
@@ -315,7 +330,7 @@
},
"console": "internalConsole",
"serverReadyAction": {
"pattern": "https:\/\/debug.bun.sh\/#localhost:([0-9]+)/",
"pattern": "https://debug.bun.sh/#localhost:([0-9]+)/",
"uriFormat": "https://debug.bun.sh/#ws://localhost:%s/",
"action": "openExternally"
}
@@ -335,11 +350,26 @@
},
"console": "internalConsole",
"serverReadyAction": {
"pattern": "https:\/\/debug.bun.sh\/#localhost:([0-9]+)/",
"pattern": "https://debug.bun.sh/#localhost:([0-9]+)/",
"uriFormat": "https://debug.bun.sh/#ws://localhost:%s/",
"action": "openExternally"
}
},
// bun exec [...]
{
"type": "lldb",
"request": "launch",
"name": "bun exec [...]",
"program": "${workspaceFolder}/build/bun-debug",
"args": ["exec", "${input:testName}"],
"cwd": "${workspaceFolder}",
"env": {
"FORCE_COLOR": "1",
"BUN_DEBUG_QUIET_LOGS": "1",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2"
},
"console": "internalConsole"
},
// bun test [*]
{
"type": "lldb",
@@ -365,7 +395,7 @@
"env": {
"FORCE_COLOR": "1",
"BUN_DEBUG_QUIET_LOGS": "1",
"BUN_GARBAGE_COLLECTOR_LEVEL": "0",
"BUN_GARBAGE_COLLECTOR_LEVEL": "0"
},
"console": "internalConsole"
},
@@ -384,11 +414,25 @@
},
"console": "internalConsole",
"serverReadyAction": {
"pattern": "https:\/\/debug.bun.sh\/#localhost:([0-9]+)/",
"pattern": "https://debug.bun.sh/#localhost:([0-9]+)/",
"uriFormat": "https://debug.bun.sh/#ws://localhost:%s/",
"action": "openExternally"
}
},
{
"type": "lldb",
"request": "launch",
"name": "bun install [folder]",
"program": "${workspaceFolder}/build/bun-debug",
"args": ["install"],
"cwd": "${fileDirname}",
"env": {
"FORCE_COLOR": "1",
"BUN_DEBUG_QUIET_LOGS": "1",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2"
},
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
@@ -415,11 +459,54 @@
"name": "BUN_DEBUG_QUIET_LOGS",
"value": "1"
},
{
"name": "BUN_DEBUG_jest",
"value": "1"
},
{
"name": "BUN_GARBAGE_COLLECTOR_LEVEL",
"value": "1"
}
]
},
{
"type": "cppvsdbg",
"request": "launch",
"name": "Windows: bun test --only [file]",
"program": "${workspaceFolder}/build/bun-debug.exe",
"args": ["test", "--only", "${file}"],
"cwd": "${workspaceFolder}/test",
"environment": [
{
"name": "FORCE_COLOR",
"value": "1"
},
{
"name": "BUN_DEBUG_QUIET_LOGS",
"value": "1"
},
{
"name": "BUN_DEBUG_EventLoop",
"value": "1"
},
{
"name": "BUN_DEBUG_uv",
"value": "1"
},
{
"name": "BUN_DEBUG_SYS",
"value": "1"
},
{
"name": "BUN_DEBUG_PipeWriter",
"value": "1"
},
{
"name": "BUN_GARBAGE_COLLECTOR_LEVEL",
"value": "2"
}
],
]
},
{
"type": "cppvsdbg",
@@ -441,7 +528,7 @@
"name": "BUN_GARBAGE_COLLECTOR_LEVEL",
"value": "0"
}
],
]
},
{
"type": "cppvsdbg",
@@ -463,7 +550,7 @@
"name": "BUN_GARBAGE_COLLECTOR_LEVEL",
"value": "2"
}
],
]
},
{
"type": "cppvsdbg",
@@ -491,10 +578,10 @@
}
],
"serverReadyAction": {
"pattern": "https:\/\/debug.bun.sh\/#localhost:([0-9]+)/",
"pattern": "https://debug.bun.sh/#localhost:([0-9]+)/",
"uriFormat": "https://debug.bun.sh/#ws://localhost:%s/",
"action": "openExternally"
},
}
},
{
"type": "cppvsdbg",
@@ -522,10 +609,10 @@
}
],
"serverReadyAction": {
"pattern": "https:\/\/debug.bun.sh\/#localhost:([0-9]+)/",
"pattern": "https://debug.bun.sh/#localhost:([0-9]+)/",
"uriFormat": "https://debug.bun.sh/#ws://localhost:%s/",
"action": "openExternally"
},
}
},
// Windows: bun run [file]
{
@@ -548,29 +635,26 @@
"name": "BUN_GARBAGE_COLLECTOR_LEVEL",
"value": "2"
}
],
]
},
{
"type": "cppvsdbg",
"request": "launch",
"name": "Windows: bun run [file] (fast)",
"name": "Windows: bun install",
"program": "${workspaceFolder}/build/bun-debug.exe",
"args": ["run", "${fileBasename}"],
"args": ["install"],
"cwd": "${fileDirname}",
"environment": [
{
"name": "FORCE_COLOR",
"value": "1"
},
{
"name": "BUN_DEBUG_QUIET_LOGS",
"value": "1"
},
{
"name": "BUN_GARBAGE_COLLECTOR_LEVEL",
"value": "0"
}
],
]
},
{
"type": "cppvsdbg",
@@ -592,7 +676,7 @@
"name": "BUN_GARBAGE_COLLECTOR_LEVEL",
"value": "2"
}
],
]
},
{
"type": "cppvsdbg",
@@ -620,10 +704,10 @@
}
],
"serverReadyAction": {
"pattern": "https:\/\/debug.bun.sh\/#localhost:([0-9]+)/",
"pattern": "https://debug.bun.sh/#localhost:([0-9]+)/",
"uriFormat": "https://debug.bun.sh/#ws://localhost:%s/",
"action": "openExternally"
},
}
},
{
"type": "cppvsdbg",
@@ -651,10 +735,10 @@
}
],
"serverReadyAction": {
"pattern": "https:\/\/debug.bun.sh\/#localhost:([0-9]+)/",
"pattern": "https://debug.bun.sh/#localhost:([0-9]+)/",
"uriFormat": "https://debug.bun.sh/#ws://localhost:%s/",
"action": "openExternally"
},
}
},
// Windows: bun test [...]
{
@@ -677,7 +761,7 @@
"name": "BUN_GARBAGE_COLLECTOR_LEVEL",
"value": "2"
}
],
]
},
{
"type": "cppvsdbg",
@@ -699,7 +783,7 @@
"name": "BUN_GARBAGE_COLLECTOR_LEVEL",
"value": "0"
}
],
]
},
{
"type": "cppvsdbg",
@@ -721,7 +805,7 @@
"name": "BUN_GARBAGE_COLLECTOR_LEVEL",
"value": "2"
}
],
]
},
{
"type": "cppvsdbg",
@@ -743,7 +827,7 @@
"name": "BUN_GARBAGE_COLLECTOR_LEVEL",
"value": "2"
}
],
]
},
{
"type": "cppvsdbg",
@@ -765,7 +849,7 @@
"name": "BUN_GARBAGE_COLLECTOR_LEVEL",
"value": "2"
}
],
]
},
{
"type": "cppvsdbg",
@@ -793,10 +877,10 @@
}
],
"serverReadyAction": {
"pattern": "https:\/\/debug.bun.sh\/#localhost:([0-9]+)/",
"pattern": "https://debug.bun.sh/#localhost:([0-9]+)/",
"uriFormat": "https://debug.bun.sh/#ws://localhost:%s/",
"action": "openExternally"
},
}
},
{
"type": "cppvsdbg",
@@ -824,10 +908,33 @@
}
],
"serverReadyAction": {
"pattern": "https:\/\/debug.bun.sh\/#localhost:([0-9]+)/",
"pattern": "https://debug.bun.sh/#localhost:([0-9]+)/",
"uriFormat": "https://debug.bun.sh/#ws://localhost:%s/",
"action": "openExternally"
},
}
},
// Windows: bun exec [...]
{
"type": "cppvsdbg",
"request": "launch",
"name": "Windows: bun exec [...]",
"program": "${workspaceFolder}/build/bun-debug.exe",
"args": ["exec", "${input:testName}"],
"cwd": "${workspaceFolder}",
"environment": [
{
"name": "FORCE_COLOR",
"value": "1"
},
{
"name": "BUN_DEBUG_QUIET_LOGS",
"value": "1"
},
{
"name": "BUN_GARBAGE_COLLECTOR_LEVEL",
"value": "2"
}
]
},
// Windows: bun test [*]
{
@@ -850,7 +957,7 @@
"name": "BUN_GARBAGE_COLLECTOR_LEVEL",
"value": "2"
}
],
]
},
{
"type": "cppvsdbg",
@@ -872,7 +979,7 @@
"name": "BUN_GARBAGE_COLLECTOR_LEVEL",
"value": "0"
}
],
]
},
{
"type": "cppvsdbg",
@@ -900,10 +1007,10 @@
}
],
"serverReadyAction": {
"pattern": "https:\/\/debug.bun.sh\/#localhost:([0-9]+)/",
"pattern": "https://debug.bun.sh/#localhost:([0-9]+)/",
"uriFormat": "https://debug.bun.sh/#ws://localhost:%s/",
"action": "openExternally"
},
}
},
{
"type": "cppvsdbg",
@@ -913,7 +1020,7 @@
"args": ["src/runner.node.mjs"],
"cwd": "${workspaceFolder}/packages/bun-internal-test",
"console": "internalConsole"
},
}
],
"inputs": [
{
@@ -925,6 +1032,6 @@
"id": "testName",
"type": "promptString",
"description": "Usage: bun test [...]"
},
}
]
}

35
.vscode/settings.json vendored
View File

@@ -40,7 +40,7 @@
// C++
"lldb.verboseLogging": false,
"cmake.configureOnOpen": false,
"C_Cpp.errorSquiggles": "enabled",
"C_Cpp.errorSquiggles": "enabled",
"[cpp]": {
"editor.defaultFormatter": "xaver.clang-format"
},
@@ -52,37 +52,37 @@
},
// JavaScript
"prettier.enable": false,
"prettier.enable": true,
"eslint.workingDirectories": ["${workspaceFolder}/packages/bun-types"],
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome",
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
// TypeScript
"typescript.tsdk": "${workspaceFolder}/node_modules/typescript/lib",
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
// JSON
"[json]": {
"editor.defaultFormatter": "biomejs.biome",
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "biomejs.biome",
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
// Markdown
"[markdown]": {
"editor.defaultFormatter": "biomejs.biome",
"editor.unicodeHighlight.ambiguousCharacters": false,
"editor.unicodeHighlight.invisibleCharacters": false,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.unicodeHighlight.ambiguousCharacters": true,
"editor.unicodeHighlight.invisibleCharacters": true,
"diffEditor.ignoreTrimWhitespace": false,
"editor.wordWrap": "on",
"editor.quickSuggestions": {
@@ -94,12 +94,17 @@
// TOML
"[toml]": {
"editor.defaultFormatter": "biomejs.biome",
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
// YAML
"[yaml]": {
"editor.defaultFormatter": "biomejs.biome",
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
// Docker
"[dockerfile]": {
"editor.formatOnSave": false
},
// Files
@@ -148,5 +153,5 @@
"WebKit/WebDriver": true,
"WebKit/WebKitBuild": true,
"WebKit/WebInspectorUI": true
},
}
}

View File

@@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.22)
cmake_policy(SET CMP0091 NEW)
cmake_policy(SET CMP0067 NEW)
set(Bun_VERSION "1.0.28")
set(WEBKIT_TAG c3712c13dcdc091cfe4c7cb8f2c1fd16472e6f92)
set(Bun_VERSION "1.1.3")
set(WEBKIT_TAG e3a2d89a0b1644cc8d5c245bd2ffee4d4bd6c1d5)
set(BUN_WORKDIR "${CMAKE_CURRENT_BINARY_DIR}")
message(STATUS "Configuring Bun ${Bun_VERSION} in ${BUN_WORKDIR}")
@@ -41,10 +41,53 @@ elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
# it is enabled for the time being to make sure to catch more bugs in the experimental windows builds
set(DEFAULT_ZIG_OPTIMIZE "ReleaseSafe")
else()
set(bun "bun-profile")
if(ZIG_OPTIMIZE STREQUAL "Debug")
set(bun "bun-debug")
else()
set(bun "bun-profile")
endif()
endif()
endif()
# --- MacOS SDK ---
if(APPLE AND DEFINED ENV{CI})
if(ARCH STREQUAL "x86_64")
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14")
else()
set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0")
endif()
endif()
if(APPLE AND NOT CMAKE_OSX_DEPLOYMENT_TARGET)
execute_process(COMMAND xcrun --show-sdk-path OUTPUT_VARIABLE SDKROOT)
string(STRIP ${SDKROOT} SDKROOT)
message(STATUS "MacOS SDK path: ${SDKROOT}")
SET(CMAKE_OSX_SYSROOT ${SDKROOT})
execute_process(COMMAND xcrun --sdk macosx --show-sdk-version OUTPUT_VARIABLE MACOSX_DEPLOYMENT_TARGET)
string(STRIP ${MACOSX_DEPLOYMENT_TARGET} MACOSX_DEPLOYMENT_TARGET)
set(CMAKE_OSX_DEPLOYMENT_TARGET ${MACOSX_DEPLOYMENT_TARGET})
# Check if current version of macOS is less than the deployment target and if so, raise an error
execute_process(COMMAND sw_vers -productVersion OUTPUT_VARIABLE MACOS_VERSION)
string(STRIP ${MACOS_VERSION} MACOS_VERSION)
if(MACOS_VERSION VERSION_LESS ${MACOSX_DEPLOYMENT_TARGET})
message(WARNING
"The current version of macOS (${MACOS_VERSION}) is less than the deployment target (${MACOSX_DEPLOYMENT_TARGET}).\n"
"The build will be incompatible with your current device due to mismatches in `icucore` versions.\n"
"To fix this, please either:\n"
" - Upgrade to at least macOS ${MACOSX_DEPLOYMENT_TARGET}\n"
" - Use `xcode-select` to switch to an SDK version <= ${MACOS_VERSION}\n"
" - Set CMAKE_OSX_DEPLOYMENT_TARGET=${MACOS_VERSION} (make sure to build all dependencies with this variable set too)"
)
endif()
endif()
if(APPLE)
message(STATUS "Building for macOS v${CMAKE_OSX_DEPLOYMENT_TARGET}")
endif()
# --- LLVM ---
# This detection is a little overkill, but it ensures that the set LLVM_VERSION matches under
# any case possible. Sorry for the complexity...
@@ -227,6 +270,13 @@ set(DEFAULT_USE_DEBUG_JSC, OFF)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(DEFAULT_USE_DEBUG_JSC ON)
set(DEFAULT_LTO OFF)
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
if(CI)
set(DEFAULT_LTO ON)
else()
set(DEFAULT_LTO OFF)
endif()
endif()
if(WIN32)
@@ -234,9 +284,9 @@ if(WIN32)
endif()
if(UNIX AND NOT APPLE)
execute_process(COMMAND cat /etc/os-release COMMAND head -n1 OUTPUT_VARIABLE LINUX_DISTRO)
execute_process(COMMAND grep -w "NAME" /etc/os-release OUTPUT_VARIABLE LINUX_DISTRO)
if(${LINUX_DISTRO} MATCHES "NAME=\"(Arch|Manjaro|Artix) Linux\"\n")
if(${LINUX_DISTRO} MATCHES "NAME=\"(Arch|Manjaro|Artix) Linux\"|NAME=\"openSUSE Tumbleweed\"\n")
set(DEFAULT_USE_STATIC_LIBATOMIC OFF)
endif()
endif()
@@ -263,6 +313,12 @@ option(USE_DEBUG_JSC "Enable assertions and use a debug build of JavaScriptCore"
option(USE_UNIFIED_SOURCES "Use unified sources to speed up the build" OFF)
option(USE_STATIC_LIBATOMIC "Statically link libatomic, requires the presence of libatomic.a" ${DEFAULT_USE_STATIC_LIBATOMIC})
option(USE_LTO "Enable Link-Time Optimization" ${DEFAULT_LTO})
if(NOT ZIG_LIB_DIR)
cmake_path(SET ZIG_LIB_DIR NORMALIZE "${CMAKE_CURRENT_SOURCE_DIR}/src/deps/zig/lib")
endif()
if(USE_VALGRIND)
# Disable SIMD
set(USE_BASELINE_BUILD ON)
@@ -285,9 +341,11 @@ endif()
set(ERROR_LIMIT 100 CACHE STRING "Maximum number of errors to show when compiling C++ code")
set(ARCH x86_64)
set(HOMEBREW_PREFIX "/usr/local")
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|arm64|arm")
set(ARCH aarch64)
set(HOMEBREW_PREFIX "/opt/homebrew")
endif()
if(NOT CPU_TARGET)
@@ -428,7 +486,13 @@ if(NOT WEBKIT_DIR)
set(BUN_WEBKIT_PACKAGE_NAME_SUFFIX "-debug")
set(ASSERT_ENABLED "1")
elseif(NOT DEBUG AND NOT WIN32)
set(BUN_WEBKIT_PACKAGE_NAME_SUFFIX "-lto")
# Avoid waiting for LTO in local release builds outside of CI
if(USE_LTO)
set(BUN_WEBKIT_PACKAGE_NAME_SUFFIX "-lto")
else()
set(BUN_WEBKIT_PACKAGE_NAME_SUFFIX "")
endif()
set(ASSERT_ENABLED "0")
endif()
@@ -463,6 +527,13 @@ if(NOT WEBKIT_DIR)
endif()
set(WEBKIT_INCLUDE_DIR "${BUN_WORKDIR}/bun-webkit/include")
if(APPLE)
set(ICU_INCLUDE_DIR "")
else()
set(ICU_INCLUDE_DIR "${BUN_WORKDIR}/bun-webkit/include/wtf/unicode")
endif()
set(WEBKIT_LIB_DIR "${BUN_WORKDIR}/bun-webkit/lib")
elseif(WEBKIT_DIR STREQUAL "omit")
message(STATUS "Not using WebKit. This is only valid if you are only trying to build Zig code")
@@ -484,6 +555,7 @@ else()
add_compile_definitions("BUN_DEBUG=1")
set(ASSERT_ENABLED "1")
endif()
message(STATUS "Using WebKit from ${WEBKIT_DIR}")
else()
if(NOT EXISTS "${WEBKIT_DIR}/lib/${libWTF}.${STATIC_LIB_EXT}" OR NOT EXISTS "${WEBKIT_DIR}/lib/${libJavaScriptCore}.${STATIC_LIB_EXT}")
if(WEBKIT_DIR MATCHES "src/bun.js/WebKit$")
@@ -678,19 +750,26 @@ if(NOT NO_CODEGEN)
file(GLOB BUN_TS_MODULES ${CONFIGURE_DEPENDS}
"${BUN_SRC}/js/node/*.ts"
"${BUN_SRC}/js/node/*.js"
"${BUN_SRC}/js/bun/*.js"
"${BUN_SRC}/js/bun/*.ts"
"${BUN_SRC}/js/bun/*.js"
"${BUN_SRC}/js/builtins/*.ts"
"${BUN_SRC}/js/builtins/*.js"
"${BUN_SRC}/js/thirdparty/*.js"
"${BUN_SRC}/js/thirdparty/*.ts"
"${BUN_SRC}/js/internal/*.js"
"${BUN_SRC}/js/internal/*.ts"
"${BUN_SRC}/js/node/*.js"
"${BUN_SRC}/js/node/*.ts"
"${BUN_SRC}/js/thirdparty/*.js"
"${BUN_SRC}/js/thirdparty/*.ts"
)
file(GLOB BUN_TS_FUNCTIONS ${CONFIGURE_DEPENDS} "${BUN_SRC}/js/builtins/*.ts")
file(GLOB CODEGEN_FILES ${CONFIGURE_DEPENDS} "${BUN_CODEGEN_SRC}/*.ts")
add_custom_command(
OUTPUT
"${BUN_WORKDIR}/codegen/WebCoreJSBuiltins.cpp"
"${BUN_WORKDIR}/codegen/WebCoreJSBuiltins.h"
"${BUN_WORKDIR}/codegen/InternalModuleRegistryConstants.h"
"${BUN_WORKDIR}/codegen/InternalModuleRegistry+createInternalModuleById.h"
"${BUN_WORKDIR}/codegen/InternalModuleRegistry+enum.h"
@@ -698,10 +777,12 @@ if(NOT NO_CODEGEN)
"${BUN_WORKDIR}/codegen/NativeModuleImpl.h"
"${BUN_WORKDIR}/codegen/ResolvedSourceTag.zig"
"${BUN_WORKDIR}/codegen/SyntheticModuleType.h"
"${BUN_WORKDIR}/codegen/GeneratedJS2Native.h"
"${BUN_SRC}/bun.js/bindings/GeneratedJS2Native.zig"
COMMAND ${BUN_EXECUTABLE} run "${BUN_SRC}/codegen/bundle-modules.ts" "--debug=${DEBUG}" "${BUN_WORKDIR}"
DEPENDS ${BUN_TS_MODULES} ${CODEGEN_FILES}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Bundling JS modules"
COMMENT "Bundling JS"
)
endif()
@@ -709,15 +790,6 @@ WEBKIT_ADD_SOURCE_DEPENDENCIES(
"${BUN_SRC}/bun.js/bindings/InternalModuleRegistry.cpp"
"${BUN_WORKDIR}/codegen/InternalModuleRegistryConstants.h"
)
add_custom_command(
OUTPUT "${BUN_WORKDIR}/codegen/WebCoreJSBuiltins.cpp"
"${BUN_WORKDIR}/codegen/WebCoreJSBuiltins.h"
COMMAND ${BUN_EXECUTABLE} run "${BUN_SRC}/codegen/bundle-functions.ts" "--debug=${DEBUG}" "${BUN_WORKDIR}"
DEPENDS ${BUN_TS_FUNCTIONS} ${CODEGEN_FILES}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Bundling JS builtin functions"
)
list(APPEND BUN_RAW_SOURCES "${BUN_WORKDIR}/codegen/WebCoreJSBuiltins.cpp")
# --- Peechy API ---
@@ -785,8 +857,10 @@ if(NOT BUN_LINK_ONLY AND NOT BUN_CPP_ONLY)
OUTPUT "${BUN_ZIG_OBJ}"
COMMAND
"${ZIG_COMPILER}" "build" "obj"
"--zig-lib-dir" "${ZIG_LIB_DIR}"
"-Doutput-file=${BUN_ZIG_OBJ}"
"-Dgenerated-code=${BUN_WORKDIR}/codegen"
"-freference-trace=10"
"-Dversion=${Bun_VERSION}"
"-Dcanary=${CANARY}"
"-Doptimize=${ZIG_OPTIMIZE}"
@@ -799,6 +873,7 @@ if(NOT BUN_LINK_ONLY AND NOT BUN_CPP_ONLY)
"${BUN_WORKDIR}/codegen/ResolvedSourceTag.zig"
"${BUN_IDENTIFIER_CACHE_OUT}"
"${BUN_SRC}/api/schema.zig"
"${BUN_SRC}/bun.js/bindings/GeneratedJS2Native.zig"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Building zig code"
VERBATIM
@@ -879,6 +954,10 @@ else()
add_compile_definitions("ASSERT_ENABLED=1")
endif()
if(ICU_INCLUDE_DIR)
include_directories(${ICU_INCLUDE_DIR})
endif()
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/packages/
${CMAKE_CURRENT_SOURCE_DIR}/packages/bun-usockets
@@ -938,6 +1017,14 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
-Werror=return-type
-Werror=return-stack-address
-Werror=implicit-function-declaration
-Werror=uninitialized
-Werror=conditional-uninitialized
-Werror=suspicious-memaccess
-Werror=move
-Werror=sometimes-uninitialized
-Werror=unused
-Wno-unused-function
-Werror
)
else()
target_compile_options(${bun} PUBLIC /Od /Z7)
@@ -945,15 +1032,36 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions("BUN_DEBUG=1")
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
set(LTO_FLAG "")
if(NOT WIN32)
target_compile_options(${bun} PUBLIC -O3 -flto=full -emit-llvm -g1
if(USE_LTO)
list(APPEND LTO_FLAG "-flto=full" "-emit-llvm")
endif()
# Leave -Werror=unused off in release builds so we avoid errors from being used in ASSERT
target_compile_options(${bun} PUBLIC -O3 ${LTO_FLAG} -g1
-Werror=return-type
-Werror=return-stack-address
-Werror=implicit-function-declaration
-Werror=uninitialized
-Werror=conditional-uninitialized
-Werror=suspicious-memaccess
-Werror=move
-Werror=sometimes-uninitialized
-Werror
)
else()
target_compile_options(${bun} PUBLIC /O2 -flto=full /DEBUG /Z7)
target_link_options(${bun} PUBLIC /LTCG /DEBUG)
set(LTO_LINK_FLAG "")
if(USE_LTO)
# -emit-llvm seems to not be supported or under a different name on Windows.
list(APPEND LTO_FLAG "-flto=full")
list(APPEND LTO_LINK_FLAG "/LTCG")
endif()
target_compile_options(${bun} PUBLIC /O2 ${LTO_FLAG} /DEBUG /Z7)
target_link_options(${bun} PUBLIC ${LTO_LINK_FLAG} /DEBUG)
endif()
endif()
@@ -1005,12 +1113,6 @@ else()
endif()
if(APPLE)
if(ARCH STREQUAL "x86_64")
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14")
else()
set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0")
endif()
target_link_options(${bun} PUBLIC "-dead_strip")
target_link_options(${bun} PUBLIC "-dead_strip_dylibs")
target_link_options(${bun} PUBLIC "-Wl,-stack_size,0x1200000")
@@ -1076,21 +1178,7 @@ endif()
# --- ICU ---
if(APPLE)
# TODO: a much better check can be done to find this path
find_path(
ICU4C_DIR NAMES lib/libicudata.a
PATHS ENV PATH /usr/local/opt/icu4c /opt/homebrew/opt/icu4c
)
find_path(
ICONV_DIR NAMES lib/libiconv.a
PATHS ENV PATH /usr/local/opt/libiconv /opt/homebrew/opt/libiconv
)
target_link_libraries(${bun} PRIVATE "icucore")
target_link_libraries(${bun} PRIVATE "${ICONV_DIR}/lib/libiconv.a")
target_link_libraries(${bun} PRIVATE "${ICU4C_DIR}/lib/libicudata.a")
target_link_libraries(${bun} PRIVATE "${ICU4C_DIR}/lib/libicui18n.a")
target_link_libraries(${bun} PRIVATE "${ICU4C_DIR}/lib/libicuuc.a")
endif()
# --- Stripped Binary "bun"

View File

@@ -16,7 +16,7 @@ ARG BUILD_MACHINE_ARCH=x86_64
ARG BUILDARCH=amd64
ARG TRIPLET=${ARCH}-linux-gnu
ARG GIT_SHA=""
ARG BUN_VERSION="bun-v1.0.7"
ARG BUN_VERSION="bun-v1.0.30"
ARG BUN_DOWNLOAD_URL_BASE="https://pub-5e11e972747a44bf9aaf9394f185a982.r2.dev/releases/${BUN_VERSION}"
ARG CANARY=0
ARG ASSERTIONS=OFF
@@ -116,7 +116,7 @@ RUN apt-get update -y \
&& case "${arch##*-}" in \
amd64) variant="x64";; \
arm64) variant="aarch64";; \
*) echo "error: unsupported architecture: $arch"; exit 1 ;; \
*) echo "unsupported architecture: $arch"; exit 1 ;; \
esac \
&& wget "${BUN_DOWNLOAD_URL_BASE}/bun-linux-${variant}.zip" \
&& unzip bun-linux-${variant}.zip \
@@ -372,7 +372,7 @@ ENV CCACHE_DIR=/ccache
RUN --mount=type=cache,target=/ccache mkdir ${BUN_DIR}/build \
&& cd ${BUN_DIR}/build \
&& mkdir -p tmp_modules tmp_functions js codegen \
&& cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release -DUSE_DEBUG_JSC=${ASSERTIONS} -DBUN_CPP_ONLY=1 -DWEBKIT_DIR=/build/bun/bun-webkit -DCANARY=${CANARY} -DZIG_COMPILER=system \
&& cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release -DUSE_LTO=ON -DUSE_DEBUG_JSC=${ASSERTIONS} -DBUN_CPP_ONLY=1 -DWEBKIT_DIR=/build/bun/bun-webkit -DCANARY=${CANARY} -DZIG_COMPILER=system \
&& bash compile-cpp-only.sh -v
FROM bun-base-with-zig as bun-codegen-for-zig
@@ -414,11 +414,12 @@ COPY --from=bun-codegen-for-zig ${BUN_DIR}/packages/bun-error/dist ${BUN_DIR}/pa
WORKDIR $BUN_DIR
RUN mkdir -p build \
&& bun run $BUN_DIR/src/codegen/bundle-modules-fast.ts $BUN_DIR/build \
&& bun run $BUN_DIR/src/codegen/bundle-modules.ts --debug=OFF $BUN_DIR/build \
&& cd build \
&& cmake .. \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_LTO=ON \
-DZIG_OPTIMIZE="${ZIG_OPTIMIZE}" \
-DCPU_TARGET="${CPU_TARGET}" \
-DZIG_TARGET="${TRIPLET}" \
@@ -428,6 +429,7 @@ RUN mkdir -p build \
-DBUN_ZIG_OBJ="/tmp/bun-zig.o" \
-DCANARY="${CANARY}" \
-DZIG_COMPILER=system \
-DZIG_LIB_DIR=$BUN_DIR/src/deps/zig/lib \
&& ONLY_ZIG=1 ninja "/tmp/bun-zig.o" -v
FROM scratch as build_release_obj
@@ -476,6 +478,7 @@ RUN cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DBUN_LINK_ONLY=1 \
-DBUN_ZIG_OBJ="${BUN_DIR}/build/bun-zig.o" \
-DUSE_LTO=ON \
-DUSE_DEBUG_JSC=${ASSERTIONS} \
-DBUN_CPP_ARCHIVE="${BUN_DIR}/build/bun-cpp-objects.a" \
-DWEBKIT_DIR="${BUN_DIR}/bun-webkit" \
@@ -540,6 +543,7 @@ RUN cmake .. \
-DNO_CONFIGURE_DEPENDS=1 \
-DCANARY="${CANARY}" \
-DZIG_COMPILER=system \
-DUSE_LTO=ON \
&& ninja -v \
&& ./bun --revision \
&& mkdir -p /build/out \

View File

@@ -24,9 +24,9 @@
## What is Bun?
> **Bun is under active development.** Use it to speed up your development workflows or run simpler production code in resource-constrained environments like serverless functions. We're working on more complete Node.js compatibility and integration with existing frameworks. Join the [Discord](https://bun.sh/discord) and watch the [GitHub repository](https://github.com/oven-sh/bun) to keep tabs on future releases.
> **Bun is under active development.** Use it to speed up your development workflows or run simpler production code in resource-constrained environments like serverless functions. We're working on more complete Node.js compatibility and integration with existing frameworks. Join the [Discord](https://bun.sh/discord) and watch the [GitHub repository](https://github.com/oven-sh/bun) to keep tabs on future releases.
Bun is an all-in-one toolkit for JavaScript and TypeScript apps. It ships as a single executable called `bun`.
Bun is an all-in-one toolkit for JavaScript and TypeScript apps. It ships as a single executable called `bun`.
At its core is the _Bun runtime_, a fast JavaScript runtime designed as a drop-in replacement for Node.js. It's written in Zig and powered by JavaScriptCore under the hood, dramatically reducing startup times and memory usage.
@@ -34,27 +34,28 @@ At its core is the _Bun runtime_, a fast JavaScript runtime designed as a drop-i
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.
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.
```bash
bun test # run tests
bun run start # run the `start` script in `package.json`
bun install <pkg> # install a package
bun install <pkg> # install a package
bunx cowsay 'Hello, world!' # execute a package
```
## Install
Bun supports Linux (x64 & arm64) and macOS (x64 & Apple Silicon).
Bun supports Linux (x64 & arm64), macOS (x64 & Apple Silicon) and Windows (x64).
> **Linux users** — Kernel version 5.6 or higher is strongly recommended, but the minimum is 5.1.
>
> **Windows users** — Bun does not currently provide a native Windows build. We're working on this; progress can be tracked at [this issue](https://github.com/oven-sh/bun/issues/43). In the meantime, use one of the installation methods below for Windows Subsystem for Linux.
```sh
# with install script (recommended)
curl -fsSL https://bun.sh/install | bash
# on windows
powershell -c "irm bun.sh/install.ps1 | iex"
# with npm
npm install -g bun

Binary file not shown.

View File

@@ -12,7 +12,7 @@
"fast-glob": "3.3.1",
"fdir": "^6.1.0",
"mitata": "^0.1.6",
"string-width": "^7.0.0",
"string-width": "7.1.0",
"zx": "^7.2.3"
},
"scripts": {

File diff suppressed because one or more lines are too long

View File

@@ -1,9 +1,10 @@
import { mkdirSync, writeFileSync } from "fs";
import { bench, run } from "./runner.mjs";
import { mkdirSync, rmSync, writeFileSync } from "fs";
import { cp } from "fs/promises";
import { join } from "path";
import { tmpdir } from "os";
import { join, resolve } from "path";
import { bench, run } from "./runner.mjs";
import { fileURLToPath } from "url";
const hugeDirectory = (() => {
const root = join(tmpdir(), "huge");
const base = join(root, "directory", "for", "benchmarks", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10");
@@ -18,14 +19,21 @@ const hugeDirectory = (() => {
const hugeFilePath = join(tmpdir(), "huge-file-0.txt");
const hugeText = "Hello, world!".repeat(1000000);
writeFileSync(hugeFilePath, hugeText);
let base = process.argv.at(-1);
if (resolve(base) === fileURLToPath(import.meta.url)) {
base = tmpdir();
} else {
rmSync(base, { recursive: true, force: true });
mkdirSync(base, { recursive: true });
}
var hugeCopyI = 0;
bench("cp -r (1000 files)", async b => {
await cp(hugeDirectory, join(tmpdir(), "huge-copy" + hugeCopyI++), { recursive: true });
await cp(hugeDirectory, join(base, "huge-copy" + hugeCopyI++), { recursive: true });
});
bench("cp 1 " + ((hugeText.length / 1024) | 0) + " KB file", async b => {
await cp(hugeFilePath, join(tmpdir(), "huge-file" + hugeCopyI++));
await cp(hugeFilePath, join(base, "huge-file" + hugeCopyI++));
});
await run();

View File

@@ -5,6 +5,11 @@ const lazy = globalThis[Symbol.for("Bun.lazy")];
const noop = lazy("noop");
const fn = noop.function;
const regular = noop.functionRegular;
const callback = noop.callback;
bench("C++ callback into JS", () => {
callback(() => {});
});
bench("C++ fn regular", () => {
regular();

View File

@@ -0,0 +1,73 @@
import { tmpdir } from "node:os";
import { bench, group, run } from "./runner.mjs";
import { createReadStream, writeFileSync } from "node:fs";
import { sep } from "node:path";
if (!Promise.withResolvers) {
Promise.withResolvers = function () {
let resolve, reject;
const promise = new Promise((res, rej) => {
resolve = res;
reject = rej;
});
return { promise, resolve, reject };
};
}
const ALLOW_BUN = typeof Bun !== "undefined";
const ALLOW_NODE = true;
const dir = tmpdir() + sep;
var short = (function () {
const text = "Hello World!";
const path = dir + "bun-bench-short.text";
writeFileSync(path, text, "utf8");
return { path, length: text.length };
})();
var shortUTF16 = (function () {
const text = "Hello World 💕💕💕";
const path = dir + "bun-bench-shortUTF16.text";
writeFileSync(path, text, "utf8");
return { path, length: text.length };
})();
var long = (function () {
const text = "Hello World!".repeat(1024);
const path = dir + "bun-bench-long.text";
writeFileSync(path, text, "utf8");
return { path, length: text.length };
})();
var longUTF16 = (function () {
const text = "Hello World 💕💕💕".repeat(15 * 70192);
const path = dir + "bun-bench-longUTF16.text";
writeFileSync(path, text, "utf8");
return { path, length: text.length };
})();
async function bun(path) {
for await (const chunk of Bun.file(path).stream()) {
chunk;
}
}
async function node(path) {
const { promise, resolve } = Promise.withResolvers();
const stream = createReadStream(path);
stream.on("data", chunk => {});
stream.on("end", () => resolve());
await promise;
}
ALLOW_BUN && bench("short - bun", () => bun(short.path));
ALLOW_NODE && bench("short - node", () => node(short.path));
ALLOW_BUN && bench("shortUTF16 - bun", () => bun(shortUTF16.path));
ALLOW_NODE && bench("shortUTF16 - node", () => node(shortUTF16.path));
ALLOW_BUN && bench("long - bun", () => bun(long.path));
ALLOW_NODE && bench("long - node", () => node(long.path));
ALLOW_BUN && bench("longUTF16 - bun", () => bun(longUTF16.path));
ALLOW_NODE && bench("longUTF16 - node", () => node(longUTF16.path));
await run();

View File

@@ -3,41 +3,38 @@ import npmStringWidth from "string-width";
const bunStringWidth = globalThis?.Bun?.stringWidth;
bench("npm/string-width (ansi + emoji + ascii)", () => {
npmStringWidth("hello there! 😀\u001b[31m😀😀");
});
const stringWidth = bunStringWidth || npmStringWidth;
const formatter = new Intl.NumberFormat();
const format = n => {
return formatter.format(n);
};
bench("npm/string-width (ansi + emoji)", () => {
npmStringWidth("😀\u001b[31m😀😀");
});
const inputs = [
["hello", "ascii"],
["[31mhello", "ascii+ansi"],
["hello😀", "ascii+emoji"],
["[31m😀😀", "ansi+emoji"],
["😀hello😀[31m😀😀😀", "ansi+emoji+ascii"],
];
bench("npm/string-width (ansi + ascii)", () => {
npmStringWidth("\u001b[31mhello there!");
});
const repeatCounts = [1, 10, 100, 1000, 5000];
if (bunStringWidth) {
bench("Bun.stringWidth (ansi + emoji + ascii)", () => {
bunStringWidth("hello there! 😀\u001b[31m😀😀");
});
const maxInputLength = Math.max(...inputs.map(([input]) => input.repeat(Math.max(...repeatCounts)).length));
bench("Bun.stringWidth (ansi + emoji)", () => {
bunStringWidth("😀\u001b[31m😀😀");
});
for (const [input, textLabel] of inputs) {
for (let repeatCount of repeatCounts) {
const label = bunStringWidth ? "Bun.stringWidth" : "npm/string-width";
bench("Bun.stringWidth (ansi + ascii)", () => {
bunStringWidth("\u001b[31mhello there!");
});
const str = input.repeat(repeatCount);
const name = `${label} ${format(str.length).padStart(format(maxInputLength).length, " ")} chars ${textLabel}`;
if (npmStringWidth("😀\u001b[31m😀😀") !== bunStringWidth("😀\u001b[31m😀😀")) {
console.error("string-width mismatch");
}
bench(name, () => {
stringWidth(str);
});
if (npmStringWidth("hello there! 😀\u001b[31m😀😀") !== bunStringWidth("hello there! 😀\u001b[31m😀😀")) {
console.error("string-width mismatch");
}
if (npmStringWidth("\u001b[31mhello there!") !== bunStringWidth("\u001b[31mhello there!")) {
console.error("string-width mismatch");
if (bunStringWidth && bunStringWidth(str) !== npmStringWidth(str)) {
throw new Error("string-width mismatch");
}
}
}

View File

@@ -1,4 +1,4 @@
import { Database } from "https://deno.land/x/sqlite3@0.9.1/mod.ts";
import { Database } from "https://deno.land/x/sqlite3@0.11.1/mod.ts";
import { run, bench } from "../node_modules/mitata/src/cli.mjs";
const db = new Database("./src/northwind.sqlite");

View File

@@ -7,8 +7,8 @@
"build": "exit 0",
"bench:bun": "$BUN bun.js",
"bench:node": "$NODE node.mjs",
"deps": "npm install && sh src/download.sh",
"bench:deno": "$DENO run -A --unstable deno.js",
"deps": "npm install && bash src/download.sh",
"bench:deno": "$DENO run -A --unstable-ffi deno.js",
"bench": "bun run bench:bun && bun run bench:node && bun run bench:deno"
}
}

View File

@@ -1,70 +0,0 @@
{
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": false
},
"javascript": {
"parser": {
"unsafeParameterDecoratorsEnabled": true
},
"formatter": {
"arrowParentheses": "asNeeded",
"quoteProperties": "preserve",
"semicolons": "always",
"trailingComma": "all",
"indentStyle": "space",
"quoteStyle": "double"
}
},
"json": {
"formatter": {
"indentStyle": "space"
},
"parser": {
"allowComments": true,
"allowTrailingCommas": true
}
},
"vcs": {
"clientKind": "git",
"enabled": false,
"root": "./"
},
"files": {
"maxSize": 9128312873
},
"formatter": {
"enabled": true,
"indentWidth": 2,
"lineEnding": "lf",
"formatWithErrors": true,
"lineWidth": 120,
"indentStyle": "space",
"ignore": [
"node_modules/**",
"test/snapshots",
"test/fixtures",
".next",
"test/js/deno",
"./src/deps",
"./src/bun.js/WebKit/**",
"packages/bun-polyfills",
"./build-*",
"./build",
".cache",
"out/",
"test/transpiler/property-non-ascii-fixture.js",
"test/transpiler/macro-test.test.ts",
"test/transpiler/decorator-metadata.test.ts",
"src/react-refresh.js",
"bindings-obj/*",
"src/deps/**",
"./bench/react-hello-world/react-hello-world.node.js",
"./test/cli/run/require-cache-bug-leak-fixture-large-ast.js",
"./test/cli/run/esm-leak-fixture-large-ast.mjs"
]
}
}

View File

@@ -1,7 +1,7 @@
const std = @import("std");
const pathRel = std.fs.path.relative;
const builtin = @import("builtin");
const Wyhash = @import("./src/wyhash.zig").Wyhash;
const Wyhash11 = @import("./src/wyhash.zig").Wyhash11;
const zig_version = builtin.zig_version;
@@ -84,7 +84,7 @@ const BunBuildOptions = struct {
pub fn updateRuntime(this: *BunBuildOptions) anyerror!void {
if (std.fs.cwd().openFile("src/runtime.out.js", .{ .mode = .read_only })) |file| {
defer file.close();
const runtime_hash = Wyhash.hash(
const runtime_hash = Wyhash11.hash(
0,
try file.readToEndAlloc(std.heap.page_allocator, try file.getEndPos()),
);
@@ -97,7 +97,7 @@ const BunBuildOptions = struct {
if (std.fs.cwd().openFile("src/fallback.out.js", .{ .mode = .read_only })) |file| {
defer file.close();
const fallback_hash = Wyhash.hash(
const fallback_hash = Wyhash11.hash(
0,
try file.readToEndAlloc(std.heap.page_allocator, try file.getEndPos()),
);
@@ -629,3 +629,5 @@ pub fn configureObjectStep(b: *std.build.Builder, obj: *CompileStep, obj_step: *
obj.link_function_sections = true;
}
}
// !

BIN
bun.lockb

Binary file not shown.

View File

@@ -6,3 +6,4 @@
#
# Instead, we can only scan the test directory for Bun's runtime tests
root = "test"
preload = "./test/preload.ts"

View File

@@ -2,7 +2,7 @@
name: bun
appspec: { version: "0.001" }
plugins: [-Meta]
title: A tool for installing and managing Python packages
title: A tool for installing and managing JavaScript packages
options:
- version|V --Show version and exit

View File

@@ -96,18 +96,20 @@ FROM alpine:3.18
ARG BUN_RUNTIME_TRANSPILER_CACHE_PATH=0
ENV BUN_RUNTIME_TRANSPILER_CACHE_PATH=${BUN_RUNTIME_TRANSPILER_CACHE_PATH}
COPY --from=build /tmp/glibc.apk /tmp/
COPY --from=build /tmp/glibc-bin.apk /tmp/
# Ensure `bun install -g` works
ARG BUN_INSTALL_BIN=/usr/local/bin
ENV BUN_INSTALL_BIN=${BUN_INSTALL_BIN}
COPY --from=build /usr/local/bin/bun /usr/local/bin/
COPY docker-entrypoint.sh /usr/local/bin/
RUN addgroup -g 1000 bun \
# Temporarily use the `build`-stage /tmp folder to access the glibc APKs:
RUN --mount=type=bind,from=build,source=/tmp,target=/tmp \
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 \

View File

@@ -62,6 +62,10 @@ FROM debian:bullseye-slim
ARG BUN_RUNTIME_TRANSPILER_CACHE_PATH=0
ENV BUN_RUNTIME_TRANSPILER_CACHE_PATH=${BUN_RUNTIME_TRANSPILER_CACHE_PATH}
# Ensure `bun install -g` works
ARG BUN_INSTALL_BIN=/usr/local/bin
ENV BUN_INSTALL_BIN=${BUN_INSTALL_BIN}
COPY docker-entrypoint.sh /usr/local/bin
COPY --from=build /usr/local/bin/bun /usr/local/bin/bun

View File

@@ -3,6 +3,8 @@ FROM debian:bullseye-slim AS build
# https://github.com/oven-sh/bun/releases
ARG BUN_VERSION=latest
# Node.js includes python3 for node-gyp, see https://github.com/oven-sh/bun/issues/9807
# Though, not on slim and alpine images.
RUN apt-get update -qq \
&& apt-get install -qq --no-install-recommends \
ca-certificates \
@@ -11,6 +13,7 @@ RUN apt-get update -qq \
gpg \
gpg-agent \
unzip \
python3 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& arch="$(dpkg --print-architecture)" \
@@ -63,6 +66,10 @@ COPY --from=build /usr/local/bin/bun /usr/local/bin/bun
ARG BUN_RUNTIME_TRANSPILER_CACHE_PATH=0
ENV BUN_RUNTIME_TRANSPILER_CACHE_PATH=${BUN_RUNTIME_TRANSPILER_CACHE_PATH}
# Ensure `bun install -g` works
ARG BUN_INSTALL_BIN=/usr/local/bin
ENV BUN_INSTALL_BIN=${BUN_INSTALL_BIN}
RUN groupadd bun \
--gid 1000 \
&& useradd bun \

View File

@@ -62,6 +62,10 @@ FROM gcr.io/distroless/base-nossl-debian11
ARG BUN_RUNTIME_TRANSPILER_CACHE_PATH=0
ENV BUN_RUNTIME_TRANSPILER_CACHE_PATH=${BUN_RUNTIME_TRANSPILER_CACHE_PATH}
# Ensure `bun install -g` works
ARG BUN_INSTALL_BIN=/usr/local/bin
ENV BUN_INSTALL_BIN=${BUN_INSTALL_BIN}
COPY --from=build /usr/local/bin/bun /usr/local/bin/
# Temporarily use the `build`-stage image binaries to create a symlink:

View File

@@ -58,17 +58,18 @@ Pass a path to the shared library and a map of symbols to import into `dlopen`:
```ts
import { dlopen, FFIType, suffix } from "bun:ffi";
const { i32 } = FFIType;
const path = `libadd.${suffix}`;
const lib = dlopen(path, {
add: {
args: [FFIType.i32, FFIType.i32],
returns: FFIType.i32,
args: [i32, i32],
returns: i32,
},
});
lib.symbols.add(1, 2);
console.log(lib.symbols.add(1, 2));
```
### Rust
@@ -76,7 +77,7 @@ lib.symbols.add(1, 2);
```rust
// add.rs
#[no_mangle]
pub extern "C" fn add(a: isize, b: isize) -> isize {
pub extern "C" fn add(a: i32, b: i32) -> i32 {
a + b
}
```
@@ -87,6 +88,22 @@ To compile:
$ rustc --crate-type cdylib add.rs
```
### C++
```c
#include <cstdint>
extern "C" int32_t add(int32_t a, int32_t b) {
return a + b;
}
```
To compile:
```bash
$ zig build-lib add.cpp -dynamic -lc -lc++
```
## FFI types
The following `FFIType` values are supported.

View File

@@ -6,12 +6,12 @@ Bun implements the following properties.
import.meta.dir; // => "/path/to/project"
import.meta.file; // => "file.ts"
import.meta.path; // => "/path/to/project/file.ts"
import.meta.url; // => "file:///path/to/project/file.ts"
import.meta.main; // `true` if this file is directly executed by `bun run`
// `false` otherwise
import.meta.resolveSync("zod")
// resolve an import specifier relative to the directory
import.meta.resolve("zod"); // => "file:///path/to/project/node_modules/zod/index.js"
```
{% table %}
@@ -28,13 +28,18 @@ import.meta.resolveSync("zod")
---
- `import.meta.env`
- An alias to `process.env`.
---
- `import.meta.file`
- The name of the current file, e.g. `index.tsx`
---
- `import.meta.path`
- Absolute path to the current file, e.g. `/path/to/project/index.tx`. Equivalent to `__filename` in CommonJS modules (and Node.js)
- Absolute path to the current file, e.g. `/path/to/project/index.ts`. Equivalent to `__filename` in CommonJS modules (and Node.js)
---
@@ -43,30 +48,22 @@ import.meta.resolveSync("zod")
---
- `import.meta.url`
- A string url to the current file, e.g. `file:///path/to/project/index.tx`
---
- `import.meta.main`
- `boolean` Indicates whether the current file is the entrypoint to the current `bun` process. Is the file being directly executed by `bun run` or is it being imported?
- Indicates whether the current file is the entrypoint to the current `bun` process. Is the file being directly executed by `bun run` or is it being imported?
---
- `import.meta.env`
- An alias to `process.env`.
---
- `import.meta.resolve{Sync}`
- Resolve a module specifier (e.g. `"zod"` or `"./file.tsx"`) to an absolute path. While file would be imported if the specifier were imported from this file?
- `import.meta.resolve`
- Resolve a module specifier (e.g. `"zod"` or `"./file.tsx"`) to a url. Equivalent to [`import.meta.resolve` in browsers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta#resolve)
```ts
import.meta.resolveSync("zod");
// => "/path/to/project/node_modules/zod/index.ts"
import.meta.resolveSync("./file.tsx");
// => "/path/to/project/file.tsx"
import.meta.resolve("zod");
// => "file:///path/to/project/node_modules/zod/index.ts"
```
---
- `import.meta.url`
- A `string` url to the current file, e.g. `file:///path/to/project/index.ts`. Equivalent to [`import.meta.url` in browsers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta#url)
{% /table %}

View File

@@ -186,6 +186,7 @@ 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%}
@@ -227,8 +228,6 @@ process.on("message", (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");
@@ -237,6 +236,11 @@ process.send("Hello from child as string");
process.send({ message: "Hello from child as object" });
```
The `ipcMode` option controls the underlying communication format between the two processes:
- `advanced`: (default) Messages are serialized using the JSC `serialize` API, which supports cloning [everything `structuredClone` supports](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm). This does not support transferring ownership of objects.
- `json`: Messages are serialized using `JSON.stringify` and `JSON.parse`, which does not support as many object types as `advanced` does.
## 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

@@ -115,7 +115,7 @@ Use `Bun.connect` to connect to a TCP server. Specify the server to connect to w
```ts
// The client
const socket = Bun.connect({
const socket = await Bun.connect({
hostname: "localhost",
port: 8080,
@@ -138,7 +138,7 @@ To require TLS, specify `tls: true`.
```ts
// The client
const socket = Bun.connect({
const socket = await Bun.connect({
// ... config
tls: true,
});
@@ -164,7 +164,7 @@ server.reload({
```
```ts#Client
const socket = Bun.connect({ /* config */ })
const socket = await Bun.connect({ /* config */ })
socket.reload({
data(){
// new 'data' handler

View File

@@ -261,13 +261,12 @@ This function is optimized for large input. On an M1X, it processes 480 MB/s -
20 GB/s, depending on how much data is being escaped and whether there is non-ascii
text. Non-string types will be converted to a string before escaping.
## `Bun.stringWidth()`
## `Bun.stringWidth()` ~6,756x faster `string-width` alternative
```ts
Bun.stringWidth(input: string, options?: { countAnsiEscapeCodes?: boolean = false }): number
```
Get the column count of a string as it would be displayed in a terminal.
Supports ANSI escape codes, emoji, and wide characters.
Returns the number of columns required to display a string. This is useful for aligning text in a terminal. By default, ANSI escape codes are removed before measuring the string. To include them, pass `{ countAnsiEscapeCodes: true }` as the second argument.
Example usage:
```ts
Bun.stringWidth("hello"); // => 5
@@ -275,8 +274,131 @@ Bun.stringWidth("\u001b[31mhello\u001b[0m"); // => 5
Bun.stringWidth("\u001b[31mhello\u001b[0m", { countAnsiEscapeCodes: true }); // => 12
```
Compared with the popular `string-width` npm package, `bun`'s implementation is > [100x faster](https://github.com/oven-sh/bun/blob/8abd1fb088bcf2e78bd5d0d65ba4526872d2ab61/bench/snippets/string-width.mjs#L22)
This is useful for:
- Aligning text in a terminal
- Quickly checking if a string contains ANSI escape codes
- Measuring the width of a string in a terminal
This API is designed to match the popular "string-width" package, so that
existing code can be easily ported to Bun and vice versa.
[In this benchmark](https://github.com/oven-sh/bun/blob/5147c0ba7379d85d4d1ed0714b84d6544af917eb/bench/snippets/string-width.mjs#L13), `Bun.stringWidth` is a ~6,756x faster than the `string-width` npm package for input larger than about 500 characters. Big thanks to [sindresorhus](https://github.com/sindresorhus) for their work on `string-width`!
```ts
bun string-width.mjs
cpu: 13th Gen Intel(R) Core(TM) i9-13900
runtime: bun 1.0.29 (x64-linux)
benchmark time (avg) (min … max) p75 p99 p995
------------------------------------------------------------------------------------- -----------------------------
Bun.stringWidth 500 chars ascii 37.09 ns/iter (36.77 ns … 41.11 ns) 37.07 ns 38.84 ns 38.99 ns
node string-width.mjs
benchmark time (avg) (min … max) p75 p99 p995
------------------------------------------------------------------------------------- -----------------------------
npm/string-width 500 chars ascii 249,710 ns/iter (239,970 ns … 293,180 ns) 250,930 ns 276,700 ns 281,450 ns
```
To make `Bun.stringWidth` fast, we've implemented it in Zig using optimized SIMD instructions, accounting for Latin1, UTF-16, and UTF-8 encodings. It passes `string-width`'s tests.
{% details summary="View full benchmark" %}
As a reminder, 1 nanosecond (ns) is 1 billionth of a second. Here's a quick reference for converting between units:
| Unit | 1 Millisecond |
| ---- | ------------- |
| ns | 1,000,000 |
| µs | 1,000 |
| ms | 1 |
```js
bun string-width.mjs
cpu: 13th Gen Intel(R) Core(TM) i9-13900
runtime: bun 1.0.29 (x64-linux)
benchmark time (avg) (min … max) p75 p99 p995
------------------------------------------------------------------------------------- -----------------------------
Bun.stringWidth 5 chars ascii 16.45 ns/iter (16.27 ns … 19.71 ns) 16.48 ns 16.93 ns 17.21 ns
Bun.stringWidth 50 chars ascii 19.42 ns/iter (18.61 ns … 27.85 ns) 19.35 ns 21.7 ns 22.31 ns
Bun.stringWidth 500 chars ascii 37.09 ns/iter (36.77 ns … 41.11 ns) 37.07 ns 38.84 ns 38.99 ns
Bun.stringWidth 5,000 chars ascii 216.9 ns/iter (215.8 ns … 228.54 ns) 216.23 ns 228.52 ns 228.53 ns
Bun.stringWidth 25,000 chars ascii 1.01 µs/iter (1.01 µs … 1.01 µs) 1.01 µs 1.01 µs 1.01 µs
Bun.stringWidth 7 chars ascii+emoji 54.2 ns/iter (53.36 ns … 58.19 ns) 54.23 ns 57.55 ns 57.94 ns
Bun.stringWidth 70 chars ascii+emoji 354.26 ns/iter (350.51 ns … 363.96 ns) 355.93 ns 363.11 ns 363.96 ns
Bun.stringWidth 700 chars ascii+emoji 3.3 µs/iter (3.27 µs … 3.4 µs) 3.3 µs 3.4 µs 3.4 µs
Bun.stringWidth 7,000 chars ascii+emoji 32.69 µs/iter (32.22 µs … 45.27 µs) 32.7 µs 34.57 µs 34.68 µs
Bun.stringWidth 35,000 chars ascii+emoji 163.35 µs/iter (161.17 µs … 170.79 µs) 163.82 µs 169.66 µs 169.93 µs
Bun.stringWidth 8 chars ansi+emoji 66.15 ns/iter (65.17 ns … 69.97 ns) 66.12 ns 69.8 ns 69.87 ns
Bun.stringWidth 80 chars ansi+emoji 492.95 ns/iter (488.05 ns … 499.5 ns) 494.8 ns 498.58 ns 499.5 ns
Bun.stringWidth 800 chars ansi+emoji 4.73 µs/iter (4.71 µs … 4.88 µs) 4.72 µs 4.88 µs 4.88 µs
Bun.stringWidth 8,000 chars ansi+emoji 47.02 µs/iter (46.37 µs … 67.44 µs) 46.96 µs 49.57 µs 49.63 µs
Bun.stringWidth 40,000 chars ansi+emoji 234.45 µs/iter (231.78 µs … 240.98 µs) 234.92 µs 236.34 µs 236.62 µs
Bun.stringWidth 19 chars ansi+emoji+ascii 135.46 ns/iter (133.67 ns … 143.26 ns) 135.32 ns 142.55 ns 142.77 ns
Bun.stringWidth 190 chars ansi+emoji+ascii 1.17 µs/iter (1.16 µs … 1.17 µs) 1.17 µs 1.17 µs 1.17 µs
Bun.stringWidth 1,900 chars ansi+emoji+ascii 11.45 µs/iter (11.26 µs … 20.41 µs) 11.45 µs 12.08 µs 12.11 µs
Bun.stringWidth 19,000 chars ansi+emoji+ascii 114.06 µs/iter (112.86 µs … 120.06 µs) 114.25 µs 115.86 µs 116.15 µs
Bun.stringWidth 95,000 chars ansi+emoji+ascii 572.69 µs/iter (565.52 µs … 607.22 µs) 572.45 µs 604.86 µs 605.21 µs
```
```ts
node string-width.mjs
cpu: 13th Gen Intel(R) Core(TM) i9-13900
runtime: node v21.4.0 (x64-linux)
benchmark time (avg) (min … max) p75 p99 p995
-------------------------------------------------------------------------------------- -----------------------------
npm/string-width 5 chars ascii 3.19 µs/iter (3.13 µs … 3.48 µs) 3.25 µs 3.48 µs 3.48 µs
npm/string-width 50 chars ascii 20.09 µs/iter (18.93 µs … 435.06 µs) 19.49 µs 21.89 µs 22.59 µs
npm/string-width 500 chars ascii 249.71 µs/iter (239.97 µs … 293.18 µs) 250.93 µs 276.7 µs 281.45 µs
npm/string-width 5,000 chars ascii 6.69 ms/iter (6.58 ms … 6.76 ms) 6.72 ms 6.76 ms 6.76 ms
npm/string-width 25,000 chars ascii 139.57 ms/iter (137.17 ms … 143.28 ms) 140.49 ms 143.28 ms 143.28 ms
npm/string-width 7 chars ascii+emoji 3.7 µs/iter (3.62 µs … 3.94 µs) 3.73 µs 3.94 µs 3.94 µs
npm/string-width 70 chars ascii+emoji 23.93 µs/iter (22.44 µs … 331.2 µs) 23.15 µs 25.98 µs 30.2 µs
npm/string-width 700 chars ascii+emoji 251.65 µs/iter (237.78 µs … 444.69 µs) 252.92 µs 325.89 µs 354.08 µs
npm/string-width 7,000 chars ascii+emoji 4.95 ms/iter (4.82 ms … 5.19 ms) 5 ms 5.04 ms 5.19 ms
npm/string-width 35,000 chars ascii+emoji 96.93 ms/iter (94.39 ms … 102.58 ms) 97.68 ms 102.58 ms 102.58 ms
npm/string-width 8 chars ansi+emoji 3.92 µs/iter (3.45 µs … 4.57 µs) 4.09 µs 4.57 µs 4.57 µs
npm/string-width 80 chars ansi+emoji 24.46 µs/iter (22.87 µs … 4.2 ms) 23.54 µs 25.89 µs 27.41 µs
npm/string-width 800 chars ansi+emoji 259.62 µs/iter (246.76 µs … 480.12 µs) 258.65 µs 349.84 µs 372.55 µs
npm/string-width 8,000 chars ansi+emoji 5.46 ms/iter (5.41 ms … 5.57 ms) 5.48 ms 5.55 ms 5.57 ms
npm/string-width 40,000 chars ansi+emoji 108.91 ms/iter (107.55 ms … 109.5 ms) 109.25 ms 109.5 ms 109.5 ms
npm/string-width 19 chars ansi+emoji+ascii 6.53 µs/iter (6.35 µs … 6.75 µs) 6.54 µs 6.75 µs 6.75 µs
npm/string-width 190 chars ansi+emoji+ascii 55.52 µs/iter (52.59 µs … 352.73 µs) 54.19 µs 80.77 µs 167.21 µs
npm/string-width 1,900 chars ansi+emoji+ascii 701.71 µs/iter (653.94 µs … 893.78 µs) 715.3 µs 855.37 µs 872.9 µs
npm/string-width 19,000 chars ansi+emoji+ascii 27.19 ms/iter (26.89 ms … 27.41 ms) 27.28 ms 27.41 ms 27.41 ms
npm/string-width 95,000 chars ansi+emoji+ascii 3.68 s/iter (3.66 s … 3.7 s) 3.69 s 3.7 s 3.7 s
```
{% /details %}
TypeScript definition:
```ts
namespace Bun {
export function stringWidth(
/**
* The string to measure
*/
input: string,
options?: {
/**
* If `true`, count ANSI escape codes as part of the string width. If `false`, ANSI escape codes are ignored when calculating the string width.
*
* @default false
*/
countAnsiEscapeCodes?: boolean;
/**
* When it's ambiugous and `true`, count emoji as 1 characters wide. If `false`, emoji are counted as 2 character wide.
*
* @default true
*/
ambiguousIsNarrow?: boolean;
},
): number;
}
```
<!-- ## `Bun.enableANSIColors()` -->
@@ -513,7 +635,7 @@ Bun.resolveSync("zod", "/path/to/project");
// => "/path/to/project/node_modules/zod/index.ts"
```
To resolve relative to the current working directory, pass `process.cwd` or `"."` as the root.
To resolve relative to the current working directory, pass `process.cwd()` or `"."` as the root.
```ts
Bun.resolveSync("./foo.ts", process.cwd());

View File

@@ -26,12 +26,31 @@ All imported files and packages are bundled into the executable, along with a co
**Note** — Currently, the `--compile` flag can only accept a single entrypoint at a time and does not support the following flags:
- `--outdir` — use `outfile` instead.
- `--external`
- `--splitting`
- `--public-path`
{% /callout %}
## Deploying to production
Compiled executables reduce memory usage and improve Bun's start time.
Normally, Bun reads and transpiles JavaScript and TypeScript files on `import` and `require`. This is part of what makes so much of Bun "just work", but it's not free. It costs time and memory to read files from disk, resolve file paths, parse, transpile, and print source code.
With compiled executables, you can move that cost from runtime to build-time.
When deploying to production, we recommend the following:
```sh
bun build --compile --minify --sourcemap ./path/to/my/app.ts --outfile myapp
```
**What do these flags do?**
The `--minify` argument optimizes the size of the transpiled output code. If you have a large application, this can save megabytes of space. For smaller applications, it might still improve start time a little.
The `--sourcemap` argument embeds a sourcemap compressed with zstd, so that errors & stacktraces point to their original locations instead of the transpiled location. Bun will automatically decompress & resolve the sourcemap when an error occurs.
## SQLite
You can use `bun:sqlite` imports with `bun build --compile`.

View File

@@ -156,7 +156,7 @@ Like the Bun runtime, the bundler supports an array of file types out of the box
---
- `.js` `.jsx`, `.cjs` `.mjs` `.mts` `.cts` `.ts` `.tsx`
- Uses Bun's built-in transpiler to parse the file and transpile TypeScript/JSX syntax to vanilla JavaScript. The bundler executes a set of default transforms, including dead code elimination, tree shaking, and environment variable inlining. At the moment Bun does not attempt to down-convert syntax; if you use recently ECMAScript syntax, that will be reflected in the bundled code.
- Uses Bun's built-in transpiler to parse the file and transpile TypeScript/JSX syntax to vanilla JavaScript. The bundler executes a set of default transforms including dead code elimination and tree shaking. At the moment Bun does not attempt to down-convert syntax; if you use recently ECMAScript syntax, that will be reflected in the bundled code.
---

View File

@@ -10,7 +10,7 @@ Bun uses the file extension to determine which built-in _loader_ should be used
**JavaScript**. Default for `.cjs` and `.mjs`.
Parses the code and applies a set of default transforms, like dead-code elimination, tree shaking, and environment variable inlining. Note that Bun does not attempt to down-convert syntax at the moment.
Parses the code and applies a set of default transforms like dead-code elimination and tree shaking. Note that Bun does not attempt to down-convert syntax at the moment.
### `jsx`
@@ -178,7 +178,7 @@ In the bundler, `.node` files are handled using the [`file`](#file) loader.
In the runtime and bundler, SQLite databases can be directly imported. This will load the database using [`bun:sqlite`](/docs/api/sqlite.md).
```ts
import db from "./my.db" with {type: "sqlite"};
import db from "./my.db" with { type: "sqlite" };
```
This is only supported when the `target` is `bun`.
@@ -189,21 +189,21 @@ You can change this behavior with the `"embed"` attribute:
```ts
// embed the database into the bundle
import db from "./my.db" with {type: "sqlite", embed: "true"};
import db from "./my.db" with { type: "sqlite", embed: "true" };
```
When using a [standalone executable](/docs/bundler/executables), the database is embedded into the single-file executable.
Otherwise, the database to embed is copied into the `outdir` with a hashed filename.
### `bunshell` loader
### `sh` loader
**Bun Shell loader**. Default for `.bun.sh` files
**Bun Shell loader**. Default for `.sh` files
This loader is used to parse [Bun Shell](/docs/runtime/shell) scripts. It's only supported when starting bun itself, so it's not available in the bundler or in the runtime.
This loader is used to parse [Bun Shell](/docs/runtime/shell) scripts. It's only supported when starting Bun itself, so it's not available in the bundler or in the runtime.
```sh
$ bun run ./script.bun.sh
$ bun run ./script.sh
```
### `file`

View File

@@ -7,7 +7,7 @@ There are a few behavioral differences to note.
## Performance
With an performance-minded API coupled with the extensively optimized Zig-based JS/TS parser, Bun's bundler is 1.75x faster than esbuild on esbuild's [three.js benchmark](https://github.com/oven-sh/bun/tree/main/bench/bundle).
With a performance-minded API coupled with the extensively optimized Zig-based JS/TS parser, Bun's bundler is 1.75x faster than esbuild on esbuild's [three.js benchmark](https://github.com/oven-sh/bun/tree/main/bench/bundle).
{% image src="/images/bundler-speed.png" caption="Bundling 10 copies of three.js from scratch, with sourcemaps and minification" /%}

View File

@@ -77,4 +77,4 @@ Bun automatically loads environment variables from `.env` files before running a
2. `NODE_ENV` === `"production"` ? `.env.production` : `.env.development`
3. `.env`
To debug environment variables, run `bun run env` to view a list of resolved environment variables. -->
To debug environment variables, run `bun --print process.env` to view a list of resolved environment variables. -->

View File

@@ -195,7 +195,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install bun
uses: oven-sh/setup-bun@v1
- name: Install dependencies

View File

@@ -75,14 +75,6 @@ $ bun run dev --watch # ❌ don't do this
Flags that occur at the end of the command will be ignored and passed through to the `"dev"` script itself.
{% /callout %}
### `--smol`
In memory-constrained environments, use the `--smol` flag to reduce memory usage at a cost to performance.
```bash
$ bun --smol run index.tsx
```
## Run a `package.json` script
{% note %}
@@ -95,7 +87,7 @@ $ bun [bun flags] run <script> [script flags]
Your `package.json` can define a number of named `"scripts"` that correspond to shell commands.
```jsonc
```json
{
// ... other fields
"scripts": {
@@ -158,3 +150,32 @@ By default, Bun respects this shebang and executes the script with `node`. Howev
```bash
$ bun run --bun vite
```
## `bun run -` to pipe code from stdin
`bun run -` lets you read JavaScript, TypeScript, TSX, or JSX from stdin and execute it without writing to a temporary file first.
```bash
$ echo "console.log('Hello')" | bun run -
Hello
```
You can also use `bun run -` to redirect files into Bun. For example, to run a `.js` file as if it were a `.ts` file:
```bash
$ echo "console.log!('This is TypeScript!' as any)" > secretly-typescript.js
$ bun run - < secretly-typescript.js
This is TypeScript!
```
For convenience, all code is treated as TypeScript with JSX support when using `bun run -`.
## `bun run --smol`
In memory-constrained environments, use the `--smol` flag to reduce memory usage at a cost to performance.
```bash
$ bun --smol run index.tsx
```
This causes the garbage collector to run more frequently, which can slow down execution. However, it can be useful in environments with limited memory. Bun automatically adjusts the garbage collector's heap size based on the available memory (accounting for cgroups and other memory limits) with and without the `--smol` flag, so this is mostly useful for cases where you want to make the heap size grow more slowly.

View File

@@ -0,0 +1,33 @@
---
name: fetch with unix domain sockets in Bun
---
In Bun, the `unix` option in `fetch()` lets you send HTTP requests over a [unix domain socket](https://en.wikipedia.org/wiki/Unix_domain_socket).
```ts
const unix = "/var/run/docker.sock";
const response = await fetch("http://localhost/info", { unix });
const body = await response.json();
console.log(body); // { ... }
```
---
The `unix` option is a string that specifies the local file path to a unix domain socket. The `fetch()` function will use the socket to send the request to the server instead of using a TCP network connection. `https` is also supported by using the `https://` protocol in the URL instead of `http://`.
To send a `POST` request to an API endpoint over a unix domain socket:
```ts
const response = await fetch("https://hostname/a/path", {
unix: "/var/run/path/to/unix.sock",
method: "POST",
body: JSON.stringify({ message: "Hello from Bun!" }),
headers: {
"Content-Type": "application/json",
},
});
const body = await response.json();
```

View File

@@ -2,7 +2,7 @@
name: Common HTTP server usage
---
This starts an HTTP server listening on port `3000`. It demonstates basic routing with a number of common responses and also handles POST data from standard forms or as JSON.
This starts an HTTP server listening on port `3000`. It demonstrates basic routing with a number of common responses and also handles POST data from standard forms or as JSON.
See [`Bun.serve`](/docs/api/http) for details.

View File

@@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
# ...
- uses: actions/checkout@v3
- uses: actions/checkout@v4
+ - uses: oven-sh/setup-bun@v1
# run any `bun` or `bunx` command

View File

@@ -18,10 +18,10 @@ Bun.env.API_TOKEN; // => "secret"
---
To print all currently-set environment variables to the command line, run `bun run env`. This is useful for debugging.
To print all currently-set environment variables to the command line, run `bun --print process.env`. This is useful for debugging.
```sh
$ bun run env
$ bun --print process.env
BAZ=stuff
FOOBAR=aaaaaa
<lots more lines>

View File

@@ -0,0 +1,40 @@
---
name: Run a Shell Command
---
Bun Shell is a cross-platform bash-like shell built in to Bun.
It provides a simple way to run shell commands in JavaScript and TypeScript. To get started, import the `$` function from the `bun` package and use it to run shell commands.
```ts#foo.ts
import { $ } from "bun";
await $`echo Hello, world!`; // => "Hello, world!"
```
---
The `$` function is a tagged template literal that runs the command and returns a promise that resolves with the command's output.
```ts#foo.ts
import { $ } from "bun";
const output = await $`ls -l`.text();
console.log(output);
```
---
To get each line of the output as an array, use the `lines` method.
```ts#foo.ts
import { $ } from "bun";
for await (const line of $`ls -l`.lines()) {
console.log(line);
}
```
---
See [Docs > API > Shell](/docs/runtime/shell) for complete documentation.

View File

@@ -16,7 +16,7 @@ Below is the full set of recommended `compilerOptions` for a Bun project. With t
{
"compilerOptions": {
// Enable latest features
"lib": ["ESNext"],
"lib": ["ESNext","DOM"],
"target": "ESNext",
"module": "ESNext",
"moduleDetection": "force",

View File

@@ -4,7 +4,7 @@ name: Migrate from Jest to Bun's test runner
In many cases, Bun's test runner can run Jest test suites with no code changes. Just run `bun test` instead of `npx jest`, `yarn test`, etc.
```sh-diff
```sh
- $ npx jest
- $ yarn test
+ $ bun test
@@ -57,7 +57,7 @@ Replace `bail` in your Jest config with the `--bail` CLI flag.
- };
``` -->
```sh-diff
```sh
$ bun test --bail 3
```

View File

@@ -0,0 +1,15 @@
---
name: Get the path to an executable bin file
---
`Bun.which` is a utility function to find the absolute path of an executable file. It is similar to the `which` command in Unix-like systems.
```ts#foo.ts
Bun.which("sh"); // => "/bin/sh"
Bun.which("notfound"); // => null
Bun.which("bun"); // => "/home/user/.bun/bin/bun"
```
---
See [Docs > API > Utils](/docs/api/utils#bun-which) for complete documentation.

View File

@@ -1,28 +0,0 @@
---
name: Upgrade an HTTP request to a WebSocket connection
---
Inside `fetch`, use the `server.upgrade()` function to upgrade an incoming `Request` to a WebSocket connection. Bun automatically returns a 101 Switching Protocols response if the upgrade succeeds.
Refer to the [WebSocket docs](/docs/api/websockets) for more information on building WebSocket servers.
```ts
const server = Bun.serve<{ authToken: string }>({
fetch(req, server) {
const success = server.upgrade(req);
if (success) {
// Bun automatically returns a 101 Switching Protocols
// if the upgrade succeeds
return undefined;
}
// handle HTTP request normally
return new Response("Hello world!");
},
websocket: {
// define websocket handlers
},
});
console.log(`Listening on localhost:\${server.port}`);
```

View File

@@ -1,4 +1,4 @@
Bun is an all-in-one toolkit for JavaScript and TypeScript apps. It ships as a single executable called `bun`.
Bun is an all-in-one toolkit for JavaScript and TypeScript apps. It ships as a single executable called `bun`.
At its core is the _Bun runtime_, a fast JavaScript runtime designed as a drop-in replacement for Node.js. It's written in Zig and powered by JavaScriptCore under the hood, dramatically reducing startup times and memory usage.
@@ -6,18 +6,18 @@ At its core is the _Bun runtime_, a fast JavaScript runtime designed as a drop-i
$ 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, all significantly faster than existing tools and usable in existing Node.js projects with little to no changes necessary.
The `bun` command-line tool also implements a test runner, script runner, and Node.js-compatible package manager, all significantly faster than existing tools and usable in existing Node.js projects with little to no changes necessary.
```bash
$ bun run start # run the `start` script
$ bun install <pkg> # install a package
$ bun install <pkg> # install a package
$ bun build ./index.tsx # bundle a project for browsers
$ bun test # run tests
$ bunx cowsay 'Hello, world!' # execute a package
```
{% callout type="note" %}
**Bun is still under development.** Use it to speed up your development workflows or run simpler production code in resource-constrained environments like serverless functions. We're working on more complete Node.js compatibility and integration with existing frameworks. Join the [Discord](https://bun.sh/discord) and watch the [GitHub repository](https://github.com/oven-sh/bun) to keep tabs on future releases.
**Bun is still under development.** Use it to speed up your development workflows or run simpler production code in resource-constrained environments like serverless functions. We're working on more complete Node.js compatibility and integration with existing frameworks. Join the [Discord](https://bun.sh/discord) and watch the [GitHub repository](https://github.com/oven-sh/bun) to keep tabs on future releases.
{% /callout %}
Get started with one of the quick links below, or read on to learn more about Bun.

View File

@@ -1,6 +1,6 @@
All packages downloaded from the registry are stored in a global cache at `~/.bun/install/cache`. They are stored in subdirectories named like `${name}@${version}`, so multiple versions of a package can be cached.
{% details summary="Configuring cache behavior" %}
{% details summary="Configuring cache behavior" (bunfig.toml) %}
```toml
[install.cache]

View File

@@ -22,8 +22,7 @@ $ npm install -g bun # the last `npm` command you'll ever need
```
```bash#Homebrew
$ brew tap oven-sh/bun # for macOS and Linux
$ brew install bun
$ brew install oven-sh/bun/bun # for macOS and Linux
```
```bash#Docker
@@ -43,21 +42,20 @@ $ proto install bun
Bun requires a minimum of Windows 10 version 1809
{% /callout %}
Bun provides a _limited, experimental_ native build for Windows. It is recommended to use Bun within [Windows Subsystem for Linux](https://learn.microsoft.com/en-us/windows/wsl/install) and follow the above instructions. To help catch bugs, the experimental build enables many debugging assertions, which will make the binary slower than what the stable version will be.
To install, paste this into a terminal:
{% codetabs %}
```powershell#PowerShell/cmd.exe
# WARNING: No stability is guaranteed on the experimental Windows builds
powershell -c "irm bun.sh/install.ps1|iex"
> powershell -c "irm bun.sh/install.ps1|iex"
```
```powershell#npm
> npm install -g bun # the last `npm` command you'll ever need
```
```powershell#Scoop
# WARNING: No stability is guaranteed on the experimental Windows builds
scoop bucket add versions
scoop install bun-canary
> scoop install bun
```
{% /codetabs %}
@@ -146,6 +144,8 @@ $ bun upgrade
{% callout %}
**Homebrew users** — To avoid conflicts with Homebrew, use `brew upgrade bun` instead.
**Scoop users** — To avoid conflicts with Scoop, use `scoop upgrade bun` instead.
**proto users** - Use `proto install bun --pin` instead.
{% /callout %}
@@ -233,11 +233,15 @@ If you need to remove Bun from your system, use the following commands.
$ rm -rf ~/.bun # for macOS, Linux, and WSL
```
```bash#Windows
$ Remove-Item ~\.bun -Recurse
```powershell#Windows
> powershell -c ~\.bun\uninstall.ps1
```
```bash#NPM
```powershell#Scoop
> scoop uninstall bun
```
```bash#npm
$ npm uninstall -g bun
```

View File

@@ -39,7 +39,7 @@ I recommend using VSCode through SSH instead of Tunnels or the Tailscale extensi
By default, running unverified scripts are blocked.
```ps1
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
> Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
```
### System Dependencies
@@ -47,7 +47,7 @@ Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
- Bun 1.1 or later. We use Bun to run it's own code generators.
```ps1
irm bun.sh/install.ps1 | iex
> irm bun.sh/install.ps1 | iex
```
- [Visual Studio](https://visualstudio.microsoft.com) with the "Desktop Development with C++" workload.
@@ -70,28 +70,28 @@ The Zig compiler is automatically downloaded, installed, and updated by the buil
[Scoop](https://scoop.sh) can be used to install these remaining tools easily:
```ps1
irm https://get.scoop.sh | iex
scoop install nodejs-lts go rust nasm ruby perl
scoop llvm@16.0.4 # scoop bug if you install llvm and the rest at the same time
> irm https://get.scoop.sh | iex
> scoop install nodejs-lts go rust nasm ruby perl
# scoop seems to be buggy if you install llvm and the rest at the same time
> scoop llvm@16.0.4
```
If you intend on building WebKit locally (optional), you should install these packages:
```ps1
scoop install make cygwin python
> scoop install make cygwin python
```
From here on out, it is **expected you use a PowerShell Terminal with `.\scripts\env.ps1` sourced**. This script is available in the Bun repository and can be loaded by executing it:
```ps1
.\scripts\env.ps1
> .\scripts\env.ps1
```
To verify, you can check for an MSVC-only command line such as `mt.exe`
```ps1
Get-Command mt
> Get-Command mt
```
{% callout %}
@@ -101,24 +101,24 @@ It is not recommended to install `ninja` / `cmake` into your global path, becaus
## Building
```ps1
bun install
> bun install
.\scripts\env.ps1
.\scripts\update-submodules.ps1 # this syncs git submodule state
.\scripts\all-dependencies.ps1 # this builds all dependencies
.\scripts\make-old-js.ps1 # runs some old code generators
> .\scripts\env.ps1
> .\scripts\update-submodules.ps1 # this syncs git submodule state
> .\scripts\all-dependencies.ps1 # this builds all dependencies
> .\scripts\make-old-js.ps1 # runs some old code generators
# Configure build environment
cmake -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Debug
> cmake -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Debug
# Build bun
ninja -Cbuild
> ninja -Cbuild
```
If this was successful, you should have a `bun-debug.exe` in the `build` folder.
```ps1
.\build\bun-debug.exe --revision
> .\build\bun-debug.exe --revision
```
You should add this to `$Env:PATH`. The simplest way to do so is to open the start menu, type "Path", and then navigate the environment variables menu to add `C:\.....\bun\build` to the user environment variable `PATH`. You should then restart your editor (if it does not update still, log out and log back in).
@@ -134,15 +134,15 @@ You can run the test suite either using `bun test`, or by using the wrapper scri
```ps1
# Setup
bun i --cwd packages\bun-internal-test
> bun i --cwd packages\bun-internal-test
# Run the entire test suite with reporter
# the package.json script "test" uses "build/bun-debug.exe" by default
bun run test
> bun run test
# Run an individual test file:
bun-debug test node\fs
bun-debug test "C:\bun\test\js\bun\resolve\import-meta.test.js"
> bun-debug test node\fs
> bun-debug test "C:\bun\test\js\bun\resolve\import-meta.test.js"
```
## Troubleshooting

View File

@@ -13,7 +13,7 @@ $ brew install automake ccache cmake coreutils gnu-sed go icu4c libiconv libtool
```
```bash#Ubuntu/Debian
$ sudo apt install cargo ccache cmake git golang libtool ninja-build pkg-config rustc ruby-full xz-utils
$ sudo apt install curl wget lsb-release software-properties-common cargo ccache cmake git golang libtool ninja-build pkg-config rustc ruby-full xz-utils
```
```bash#Arch
@@ -24,34 +24,31 @@ $ sudo pacman -S base-devel ccache cmake git go libiconv libtool make ninja pkg-
$ sudo dnf install cargo ccache cmake git golang libtool ninja-build pkg-config rustc ruby libatomic-static libstdc++-static sed unzip which libicu-devel 'perl(Math::BigInt)'
```
```bash#openSUSE Tumbleweed
$ sudo zypper install go cmake ninja automake git rustup && rustup toolchain install stable
```
{% /codetabs %}
> **Note**: The Zig compiler is automatically installed and updated by the build scripts. Manual installation is not required.
Before starting, you will need to already have a release build of Bun installed, as we use our bundler to transpile and minify our code, as well as for code generation scripts.
{% codetabs %}
```bash#Native
$ curl -fsSL https://bun.sh/install | bash # for macOS, Linux, and WSL
$ curl -fsSL https://bun.sh/install | bash
```
```bash#npm
$ npm install -g bun # the last `npm` command you'll ever need
$ npm install -g bun
```
```bash#Homebrew
$ brew tap oven-sh/bun # for macOS and Linux
$ brew tap oven-sh/bun
$ brew install bun
```
```bash#Docker
$ docker pull oven/bun
$ docker run --rm --init --ulimit memlock=-1:-1 oven/bun
```
```bash#proto
$ proto install bun
```
{% /codetabs %}
## Install LLVM
@@ -79,6 +76,10 @@ $ sudo dnf copr enable -y @fedora-llvm-team/llvm-snapshots
$ sudo dnf install llvm clang lld
```
```bash#openSUSE Tumbleweed
$ sudo zypper install clang16 lld16 llvm16
```
{% /codetabs %}
If none of the above solutions apply, you will have to install it [manually](https://github.com/llvm/llvm-project/releases/tag/llvmorg-16.0.6).
@@ -136,12 +137,14 @@ $ cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug
$ ninja -C build # 'bun run build' runs just this
```
Advanced uses can pass CMake flags to customize the build.
Advanced users can pass CMake flags to customize the build.
## VSCode
VSCode is the recommended IDE for working on Bun, as it has been configured. Once opening, you can run `Extensions: Show Recommended Extensions` to install the recommended extensions for Zig and C++. ZLS is automatically configured.
If you use a different editor, make sure that you tell ZLS to use the automatically installed Zig compiler, which is located at `./.cache/zig/zig` (`zig.exe` on Windows).
## Code generation scripts
{% callout %}
@@ -304,8 +307,7 @@ $ xcode-select --install
Bun defaults to linking `libatomic` statically, as not all systems have it. If you are building on a distro that does not have a static libatomic available, you can run the following command to enable dynamic linking:
```bash
$ cmake -Bbuild -GNinja -DUSE_STATIC_LIBATOMIC=ON
$ ninja -Cbuild
$ bun setup -DUSE_STATIC_LIBATOMIC=OFF
```
The built version of Bun may not work on other systems if compiled this way.

View File

@@ -30,17 +30,20 @@ Click the link in the right column to jump to the associated documentation.
---
- File I/O
- [`Bun.file`](/docs/api/file-io#reading-files-bun-file) [`Bun.write`](/docs/api/file-io#writing-files-bun-write)
- [`Bun.file`](/docs/api/file-io#reading-files-bun-file)
[`Bun.write`](/docs/api/file-io#writing-files-bun-write)
---
- Child processes
- [`Bun.spawn`](/docs/api/spawn#spawn-a-process-bun-spawn) [`Bun.spawnSync`](/docs/api/spawn#blocking-api-bun-spawnsync)
- [`Bun.spawn`](/docs/api/spawn#spawn-a-process-bun-spawn)
[`Bun.spawnSync`](/docs/api/spawn#blocking-api-bun-spawnsync)
---
- TCP
- [`Bun.listen`](/docs/api/tcp#start-a-server-bun-listen) [`Bun.connect`](/docs/api/tcp#start-a-server-bun-listen)
- [`Bun.listen`](/docs/api/tcp#start-a-server-bun-listen)
[`Bun.connect`](/docs/api/tcp#start-a-server-bun-listen)
---
@@ -60,7 +63,8 @@ Click the link in the right column to jump to the associated documentation.
---
- Hashing
- [`Bun.hash`](/docs/api/hashing#bun-hash) [`Bun.CryptoHasher`](/docs/api/hashing#bun-cryptohasher)
- [`Bun.hash`](/docs/api/hashing#bun-hash)
[`Bun.CryptoHasher`](/docs/api/hashing#bun-cryptohasher)
---
@@ -100,6 +104,26 @@ Click the link in the right column to jump to the associated documentation.
---
- Utilities
- [`Bun.version`](/docs/api/utils#bun-version) [`Bun.revision`](/docs/api/utils#bun-revision) [`Bun.env`](/docs/api/utils#bun-env) [`Bun.main`](/docs/api/utils#bun-main) [`Bun.sleep()`](/docs/api/utils#bun-sleep) [`Bun.sleepSync()`](/docs/api/utils#bun-sleepsync) [`Bun.which()`](/docs/api/utils#bun-which) [`Bun.peek()`](/docs/api/utils#bun-peek) [`Bun.openInEditor()`](/docs/api/utils#bun-openineditor) [`Bun.deepEquals()`](/docs/api/utils#bun-deepequals) [`Bun.escapeHTML()`](/docs/api/utils#bun-escapehtml) [`Bun.fileURLToPath()`](/docs/api/utils#bun-fileurltopath) [`Bun.pathToFileURL()`](/docs/api/utils#bun-pathtofileurl) [`Bun.gzipSync()`](/docs/api/utils#bun-gzipsync) [`Bun.gunzipSync()`](/docs/api/utils#bun-gunzipsync) [`Bun.deflateSync()`](/docs/api/utils#bun-deflatesync) [`Bun.inflateSync()`](/docs/api/utils#bun-inflatesync) [`Bun.inspect()`](/docs/api/utils#bun-inspect) [`Bun.nanoseconds()`](/docs/api/utils#bun-nanoseconds) [`Bun.readableStreamTo*()`](/docs/api/utils#bun-readablestreamto) [`Bun.resolveSync()`](/docs/api/utils#bun-resolvesync)
- [`Bun.version`](/docs/api/utils#bun-version)
[`Bun.revision`](/docs/api/utils#bun-revision)
[`Bun.env`](/docs/api/utils#bun-env)
[`Bun.main`](/docs/api/utils#bun-main)
[`Bun.sleep()`](/docs/api/utils#bun-sleep)
[`Bun.sleepSync()`](/docs/api/utils#bun-sleepsync)
[`Bun.which()`](/docs/api/utils#bun-which)
[`Bun.peek()`](/docs/api/utils#bun-peek)
[`Bun.openInEditor()`](/docs/api/utils#bun-openineditor)
[`Bun.deepEquals()`](/docs/api/utils#bun-deepequals)
[`Bun.escapeHTML()`](/docs/api/utils#bun-escapehtml)
[`Bun.fileURLToPath()`](/docs/api/utils#bun-fileurltopath)
[`Bun.pathToFileURL()`](/docs/api/utils#bun-pathtofileurl)
[`Bun.gzipSync()`](/docs/api/utils#bun-gzipsync)
[`Bun.gunzipSync()`](/docs/api/utils#bun-gunzipsync)
[`Bun.deflateSync()`](/docs/api/utils#bun-deflatesync)
[`Bun.inflateSync()`](/docs/api/utils#bun-inflatesync)
[`Bun.inspect()`](/docs/api/utils#bun-inspect)
[`Bun.nanoseconds()`](/docs/api/utils#bun-nanoseconds)
[`Bun.readableStreamTo*()`](/docs/api/utils#bun-readablestreamto)
[`Bun.resolveSync()`](/docs/api/utils#bun-resolvesync)
{% /table %}

View File

@@ -426,4 +426,94 @@ editor = "code"
# - "nvim", "neovim"
# - "vim","vi"
# - "emacs"
``` -->
```
-->
## `bun run`
The `bun run` command can be configured under the `[run]` section. These apply to the `bun run` command and the `bun` command when running a file or executable or script.
Currently, `bunfig.toml` isn't always automatically loaded for `bun run` in a local project (it does check for a global `bunfig.toml`), so you might still need to pass `-c` or `-c=bunfig.toml` to use these settings.
### `run.shell` - use the system shell or Bun's shell
The shell to use when running package.json scripts via `bun run` or `bun`. On Windows, this defaults to `"bun"` and on other platforms it defaults to `"system"`.
To always use the system shell instead of Bun's shell (default behavior unless Windows):
```toml
[run]
# default outside of Windows
shell = "system"
```
To always use Bun's shell instead of the system shell:
```toml
[run]
# default on Windows
shell = "bun"
```
### `run.bun` - auto alias `node` to `bun`
When `true`, this prepends `$PATH` with a `node` symlink that points to the `bun` binary for all scripts or executables invoked by `bun run` or `bun`.
This means that if you have a script that runs `node`, it will actually run `bun` instead, without needing to change your script. This works recursively, so if your script runs another script that runs `node`, it will also run `bun` instead. This applies to shebangs as well, so if you have a script with a shebang that points to `node`, it will actually run `bun` instead.
By default, this is enabled if `node` is not already in your `$PATH`.
```toml
[run]
# equivalent to `bun --bun` for all `bun run` commands
bun = true
```
You can test this by running:
```sh
$ bun --bun which node # /path/to/bun
$ bun which node # /path/to/node
```
This option is equivalent to prefixing all `bun run` commands with `--bun`:
```sh
bun --bun run dev
bun --bun dev
bun run --bun dev
```
If set to `false`, this will disable the `node` symlink.
### `run.silent` - suppress reporting the command being run
When `true`, suppresses the output of the command being run by `bun run` or `bun`.
```toml
[run]
silent = true
```
Without this option, the command being run will be printed to the console:
```sh
$ bun run dev
> $ echo "Running \"dev\"..."
Running "dev"...
```
With this option, the command being run will not be printed to the console:
```sh
$ bun run dev
Running "dev"...
```
This is equivalent to passing `--silent` to all `bun run` commands:
```sh
bun --silent run dev
bun --silent dev
bun run --silent dev
```

View File

@@ -98,10 +98,10 @@ Bun.env.API_TOKEN; // => "secret"
import.meta.env.API_TOKEN; // => "secret"
```
To print all currently-set environment variables to the command line, run `bun run env`. This is useful for debugging.
To print all currently-set environment variables to the command line, run `bun --print process.env`. This is useful for debugging.
```sh
$ bun run env
$ bun --print process.env
BAZ=stuff
FOOBAR=aaaaaa
<lots more lines>
@@ -163,6 +163,16 @@ These environment variables are read by Bun and configure aspects of its behavio
---
- `BUN_CONFIG_MAX_HTTP_REQUESTS`
- Control the maximum number of concurrent HTTP requests sent by fetch and `bun install`. Defaults to `256`. If you are running into rate limits or connection issues, you can reduce this number.
---
- `BUN_CONFIG_NO_CLEAR_TERMINAL_ON_RELOAD`
- If `BUN_CONFIG_NO_CLEAR_TERMINAL_ON_RELOAD=1`, then `bun --watch` will not clear the console on reload
---
- `DO_NOT_TRACK`
- Telemetry is not sent yet as of November 28th, 2023, but we are planning to add telemetry in the coming months. If `DO_NOT_TRACK=1`, then analytics are [disabled](https://do-not-track.dev/). Bun records bundle timings (so we can answer with data, "is Bun getting faster?") and feature usage (e.g., "are people actually using macros?"). The request body size is about 60 bytes, so it's not a lot of data. Equivalent of `telemetry=false` in bunfig.

View File

@@ -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 cannot send socket handles and only works with other `bun` processes.
### [`node:cluster`](https://nodejs.org/api/cluster.html)
@@ -56,7 +56,7 @@ Some methods are not optimized yet.
### [`node:fs`](https://nodejs.org/api/fs.html)
🟡 Missing `Dir` `openAsBlob` `opendir` `opendirSync` `statfs` `statfsSync`
🟡 Missing `statfs` `statfsSync`, `opendirSync`. `Dir` is partially implemented.
### [`node:http`](https://nodejs.org/api/http.html)
@@ -148,7 +148,7 @@ Some methods are not optimized yet.
### [`node:url`](https://nodejs.org/api/url.html)
🟡 Missing `domainToASCII` `domainToUnicode`. It's recommended to use `URL` and `URLSearchParams` globals instead.
🟢 Fully implemented.
### [`node:util`](https://nodejs.org/api/util.html)
@@ -432,7 +432,7 @@ The table below lists all globals implemented by Node.js and Bun's current compa
### [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL)
🟢 Fully implemented.
🟡 `URL.createObjectURL` is missing. See [Issue #3925](https://github.com/oven-sh/bun/issues/3925)
### [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams)

View File

@@ -63,7 +63,7 @@ Plugins are primarily used to extend Bun with loaders for additional file types.
```ts#yamlPlugin.ts
import { plugin } from "bun";
plugin({
await plugin({
name: "YAML",
async setup(build) {
const { load } = await import("js-yaml");
@@ -179,7 +179,7 @@ Loading a YAML file is useful, but plugins support more than just data loading.
```ts#sveltePlugin.ts
import { plugin } from "bun";
plugin({
await plugin({
name: "svelte loader",
async setup(build) {
const { compile } = await import("svelte/compiler");

View File

@@ -1,9 +1,5 @@
Bun Shell makes shell scripting with JavaScript & TypeScript fun. It's a cross-platform bash-like shell with seamless JavaScript interop.
{% callout type="note" %}
**Alpha-quality software**: Bun Shell is an unstable API still under development. If you have feature requests or run into bugs, please open an issue. There may be breaking changes in the future.
{% /callout %}
Quickstart:
```js
@@ -12,7 +8,7 @@ import { $ } from "bun";
const response = await fetch("https://example.com");
// Use Response as stdin.
await $`echo < ${response} > wc -c`; // 120
await $`cat < ${response} | wc -c`; // 1256
```
## Features:
@@ -23,6 +19,8 @@ await $`echo < ${response} > wc -c`; // 120
- **Template literals**: Template literals are used to execute shell commands. This allows for easy interpolation of variables and expressions.
- **Safety**: Bun Shell escapes all strings by default, preventing shell injection attacks.
- **JavaScript interop**: Use `Response`, `ArrayBuffer`, `Blob`, `Bun.file(path)` and other JavaScript objects as stdin, stdout, and stderr.
- **Shell scripting**: Bun Shell can be used to run shell scripts (`.bun.sh` files).
- **Custom interpreter**: Bun Shell is written in Zig, along with it's lexer, parser, and interpreter. Bun Shell is a small programming language.
## Getting started
@@ -53,23 +51,85 @@ const welcome = await $`echo "Hello World!"`.text();
console.log(welcome); // Hello World!\n
```
To get stdout, stderr, and the exit code, use await or `.run`:
By default, `await`ing will return stdout and stderr as `Buffer`s.
```js
import { $ } from "bun";
const { stdout, stderr, exitCode } = await $`echo "Hello World!"`.quiet();
const { stdout, stderr } = await $`echo "Hello World!"`.quiet();
console.log(stdout); // Buffer(6) [ 72, 101, 108, 108, 111, 32 ]
console.log(stderr); // Buffer(0) []
console.log(exitCode); // 0
```
## Error handling
By default, non-zero exit codes will throw an error. This `ShellError` contains information about the command run.
```js
import { $ } from "bun";
try {
const output = await $`something-that-may-fail`.text();
console.log(output);
} catch (err) {
console.log(`Failed with code ${err.exitCode}`);
console.log(output.stdout.toString());
console.log(output.stderr.toString());
}
```
Throwing can be disabled with `.nothrow()`. The result's `exitCode` will need to be checked manually.
```js
import { $ } from "bun";
const { stdout, stderr, exitCode } = await $`something-that-may-fail`
.nothrow()
.quiet();
if (exitCode !== 0) {
console.log(`Non-zero exit code ${exitCode}`);
}
console.log(stdout);
console.log(stderr);
```
The default handling of non-zero exit codes can be configured by calling `.nothrow()` or `.throws(boolean)` on the `$` function itself.
```js
import { $ } from "bun";
// shell promises will not throw, meaning you will have to
// check for `exitCode` manually on every shell command.
$.nothrow(); // equivilent to $.throws(false)
// default behavior, non-zero exit codes will throw an error
$.throws(true);
// alias for $.nothrow()
$.throws(false);
await $`something-that-may-fail`; // No exception thrown
```
## Redirection
Bun Shell supports redirection with `<`, `>`, and `|` operators.
A command's _input_ or _output_ may be _redirected_ using the typical Bash operators:
### To JavaScript objects (`>`)
- `<` redirect stdin
- `>` or `1>` redirect stdout
- `2>` redirect stderr
- `&>` redirect both stdout and stderr
- `>>` or `1>>` redirect stdout, _appending_ to the destination, instead of overwriting
- `2>>` redirect stderr, _appending_ to the destination, instead of overwriting
- `&>>` redirect both stdout and stderr, _appending_ to the destination, instead of overwriting
- `1>&2` redirect stdout to stderr (all writes to stdout will instead be in stderr)
- `2>&1` redirect stderr to stdout (all writes to stderr will instead be in stdout)
Bun Shell also supports redirecting from and to JavaScript objects.
### Example: Redirect output to JavaScript objects (`>`)
To redirect stdout to a JavaScript object, use the `>` operator:
@@ -77,9 +137,8 @@ To redirect stdout to a JavaScript object, use the `>` operator:
import { $ } from "bun";
const buffer = Buffer.alloc(100);
const result = await $`echo "Hello World!" > ${buffer}`;
await $`echo "Hello World!" > ${buffer}`;
console.log(result.exitCode); // 0
console.log(buffer.toString()); // Hello World!\n
```
@@ -88,12 +147,12 @@ The following JavaScript objects are supported for redirection to:
- `Buffer`, `Uint8Array`, `Uint16Array`, `Uint32Array`, `Int8Array`, `Int16Array`, `Int32Array`, `Float32Array`, `Float64Array`, `ArrayBuffer`, `SharedArrayBuffer` (writes to the underlying buffer)
- `Bun.file(path)`, `Bun.file(fd)` (writes to the file)
### From JavaScript objects (`<`)
### Example: Redirect input from JavaScript objects (`<`)
To redirect the output from JavaScript objects to stdin, use the `<` operator:
```js
import { $, file } from "bun";
import { $ } from "bun";
const response = new Response("hello i am a response body");
@@ -108,7 +167,51 @@ The following JavaScript objects are supported for redirection from:
- `Bun.file(path)`, `Bun.file(fd)` (reads from the file)
- `Response` (reads from the body)
### Piping (`|`)
### Example: Redirect stdin -> file
```js
import { $ } from "bun";
await $`cat < myfile.txt`;
```
### Example: Redirect stdout -> file
```js
import { $ } from "bun";
await $`echo bun! > greeting.txt`;
```
### Example: Redirect stderr -> file
```js
import { $ } from "bun";
await $`bun run index.ts 2> errors.txt`;
```
### Example: Redirect stdout -> stderr
```js
import { $ } from "bun";
// redirects stderr to stdout, so all output
// will be available on stdout
await $`bun run ./index.ts 2>&1`;
```
### Example: Redirect stderr -> stdout
```js
import { $ } from "bun";
// redirects stdout to stderr, so all output
// will be available on stderr
await $`bun run ./index.ts 1>&2`;
```
## Piping (`|`)
Like in bash, you can pipe the output of one command to another:
@@ -296,6 +399,18 @@ For cross-platform compatibility, Bun Shell implements a set of builtin commands
- `echo`: print text
- `pwd`: print the working directory
- `bun`: run bun in bun
- `cat`
- `touch`
- `mkdir`
- `which`
- `mv`
- `exit`
- `true`
- `false`
- `yes`
- `seq`
- `dirname`
- `basename`
**Partially** implemented:
@@ -303,9 +418,7 @@ For cross-platform compatibility, Bun Shell implements a set of builtin commands
**Not** implemented yet, but planned:
- `mkdir`: create directories
- `cp`: copy files and directories
- `cat`: concatenate files
- See https://github.com/oven-sh/bun/issues/9716 for the full list.
## Utilities
@@ -329,7 +442,7 @@ Exposes Bun Shell's escaping logic as a function:
```js
import { $ } from "bun";
console.log($.escape('$(foo) `bar` "baz"'))
console.log($.escape('$(foo) `bar` "baz"'));
// => \$(foo) \`bar\` \"baz\"
```
@@ -338,33 +451,38 @@ If you do not want your string to be escaped, wrap it in a `{ raw: 'str' }` obje
```js
import { $ } from "bun";
await $`echo ${{ raw: '$(foo) `bar` "baz"' }}`
await $`echo ${{ raw: '$(foo) `bar` "baz"' }}`;
// => bun: command not found: foo
// => bun: command not found: bar
// => baz
```
## .bun.sh file loader
## .sh file loader
For simple shell scripts, instead of `sh`, you can use Bun Shell to run shell scripts.
For simple shell scripts, instead of `/bin/sh`, you can use Bun Shell to run shell scripts.
To do that, run any file with bun that ends with `.bun.sh`:
To do so, just run the script with `bun` on a file with the `.sh` extension.
```sh
$ echo "echo Hello World!" > script.bun.sh
$ bun ./script.bun.sh
> Hello World!
```sh#script.sh
echo "Hello World! pwd=$(pwd)"
```
On Windows, Bun Shell is used automatically to run `.sh` files when using Bun:
```sh
$ echo "echo Hello World!" > script.sh
# On windows, .bun.sh is not needed, just .sh
$ bun ./script.sh
> Hello World!
Hello World! pwd=/home/demo
```
Scripts with Bun Shell are cross platform, which means they work on Windows:
```powershell
> bun .\script.sh
Hello World! pwd=C:\Users\Demo
```
## Implementation notes
Bun Shell is a small programming language in Bun that is implemented in Zig. It includes a handwritten lexer, parser, and interpreter. Unlike bash, zsh, and other shells, Bun Shell runs operations concurrently.
## Credits
Large parts of this API were inspired by [zx](https://github.com/google/zx), [dax](https://github.com/dsherret/dax), and [bnx](https://github.com/wobsoriano/bnx). Thank you to the authors of those projects.

View File

@@ -57,7 +57,7 @@ coverageThreshold = { lines = 0.9, functions = 0.9 }
### Sourcemaps
Internally, Bun transpiles all files by default, so Bun automatically generates an internal [source map](https://web.dev/source-maps/) that maps lines of your original source code onto Bun's internal representation. If for any reason you want to disable this, set `test.coverageIgnoreSourcemaps` to `false`; this will rarely be desirable outside of advanced use cases.
Internally, Bun transpiles all files by default, so Bun automatically generates an internal [source map](https://web.dev/source-maps/) that maps lines of your original source code onto Bun's internal representation. If for any reason you want to disable this, set `test.coverageIgnoreSourcemaps` to `true`; this will rarely be desirable outside of advanced use cases.
```toml
[test]

View File

@@ -156,6 +156,8 @@ test.if(macOS)("runs on macOS", () => {
});
```
## `test.skipIf`
To instead skip a test based on some condition, use `test.skipIf()` or `describe.skipIf()`.
```ts
@@ -166,16 +168,32 @@ test.skipIf(macOS)("runs on non-macOS", () => {
});
```
## `test.todoIf`
If instead you want to mark the test as TODO, use `test.todoIf()` or `describe.todoIf()`. Carefully choosing `skipIf` or `todoIf` can show a difference between, for example, intent of "invalid for this target" and "planned but not implemented yet."
```ts
const macOS = process.arch === "darwin";
// TODO: we've only implemented this for Linux so far.
test.todoIf(macOS)("runs on posix", () => {
// runs if *not* macOS
});
```
## `test.each`
To return a function for multiple cases in a table of tests, use `test.each`.
```ts
const cases = [[1, 2, 3], [3, 4, 5]];
const cases = [
[1, 2, 3],
[3, 4, 5],
];
test.each(cases)("%p + %p should be %p", (a, b, expected) => {
// runs once for each test case provided
})
// runs once for each test case provided
});
```
There are a number of options available for formatting the case label depending on its type.
@@ -327,7 +345,7 @@ Bun implements the following matchers. Full Jest compatibility is on the roadmap
---
-
-
- [`.assertions()`](https://jestjs.io/docs/expect#expectassertionsnumber)
---
@@ -337,7 +355,7 @@ Bun implements the following matchers. Full Jest compatibility is on the roadmap
---
-
-
- [`.hasAssertions()`](https://jestjs.io/docs/expect#expecthasassertions)
---

View File

@@ -21,7 +21,7 @@ const withExtensions = [
return !!json[key]?.extensions?.length;
})
.flatMap(mime => {
return [...new Set([...json[mime].extensions])].map(ext => {
return [...new Set(json[mime].extensions)].map(ext => {
return [`.{.@"${ext}", all.@"${mime}"}`];
});
})

View File

@@ -2,14 +2,13 @@
"private": true,
"name": "bun",
"dependencies": {
"@biomejs/biome": "1.5.3",
"@vscode/debugadapter": "^1.61.0",
"esbuild": "^0.17.15",
"eslint": "^8.20.0",
"eslint-config-prettier": "^8.5.0",
"mitata": "^0.1.3",
"peechy": "0.4.34",
"prettier": "3.2.2",
"prettier": "^3.2.5",
"react": "next",
"react-dom": "next",
"source-map-js": "^1.0.2",
@@ -25,14 +24,14 @@
"build": "if [ ! -e build ]; then bun setup; fi && ninja -C build",
"build:valgrind": "cmake . -DZIG_OPTIMIZE=Debug -DUSE_DEBUG_JSC=ON -DCMAKE_BUILD_TYPE=Debug -GNinja -Bbuild-valgrind && ninja -Cbuild-valgrind",
"build:release": "cmake . -DCMAKE_BUILD_TYPE=Release -GNinja -Bbuild-release && ninja -Cbuild-release",
"build:debug-zig-release": "cmake . -DCMAKE_BUILD_TYPE=Release -DZIG_OPTIMIZE=Debug -GNinja -Bbuild-debug-zig-release && ninja -Cbuild-debug-zig-release",
"build:safe": "cmake . -DZIG_OPTIMIZE=ReleaseSafe -DUSE_DEBUG_JSC=ON -DCMAKE_BUILD_TYPE=Release -GNinja -Bbuild-safe && ninja -Cbuild-safe",
"typecheck": "tsc --noEmit && cd test && bun run typecheck",
"fmt": "biome format --write {.vscode,src,test,bench,packages/{bun-types,bun-inspector-*,bun-vscode,bun-debug-adapter-protocol}}",
"fmt": "prettier --write --cache './{.vscode,src,test,bench,packages/{bun-types,bun-inspector-*,bun-vscode,bun-debug-adapter-protocol}}/**/*.{mjs,ts,tsx,js,jsx}'",
"fmt:zig": "zig fmt src/*.zig src/*/*.zig src/*/*/*.zig src/*/*/*/*.zig",
"lint": "eslint './**/*.d.ts' --cache",
"lint:fix": "eslint './**/*.d.ts' --cache --fix",
"test": "node packages/bun-internal-test/src/runner.node.mjs ./build/bun-debug",
"test:release": "node packages/bun-internal-test/src/runner.node.mjs ./build-release/bun",
"update-known-failures": "node packages/bun-internal-test/src/update-known-windows-failures.mjs"
"test:release": "node packages/bun-internal-test/src/runner.node.mjs ./build-release/bun"
}
}

Binary file not shown.

Binary file not shown.

View File

@@ -7,9 +7,11 @@
"runners/qunit"
],
"dependencies": {
"@actions/core": "latest"
"@actions/core": "latest",
"p-queue": "^8.0.1"
},
"devDependencies": {
"@types/p-queue": "^3.2.1",
"bun-types": "canary",
"prettier": "^2.8.2"
},

View File

@@ -1,49 +1,91 @@
import * as action from "@actions/core";
import { spawn, spawnSync } from "child_process";
import { rmSync, writeFileSync, readFileSync } from "fs";
import { readFile } from "fs/promises";
import { rmSync, writeFileSync, readFileSync, mkdirSync, openSync, close, closeSync } from "fs";
import { readFile, rm } from "fs/promises";
import { readdirSync } from "node:fs";
import { resolve, basename } from "node:path";
import { cpus, hostname, totalmem, userInfo } from "os";
import { constants, cpus, hostname, tmpdir, totalmem, userInfo } from "os";
import { join, normalize } from "path";
import { fileURLToPath } from "url";
import PQueue from "p-queue";
const run_start = new Date();
const TIMEOUT_DURATION = 1000 * 60 * 5;
const SHORT_TIMEOUT_DURATION = Math.ceil(TIMEOUT_DURATION / 5);
function defaultConcurrency() {
// This causes instability due to the number of open file descriptors / sockets in some tests
// Windows has higher limits
if (process.platform !== "win32") {
return 1;
}
return Math.min(Math.floor((cpus().length - 2) / 2), 2);
}
const windows = process.platform === "win32";
const KEEP_TMPDIR = process.env["BUN_KEEP_TMPDIR"] === "1";
const nativeMemory = totalmem();
const force_ram_size_input = parseInt(process.env["BUN_JSC_forceRAMSize"] || "0", 10);
let force_ram_size = Number(BigInt(nativeMemory) >> BigInt(2)) + "";
if (!(Number.isSafeInteger(force_ram_size_input) && force_ram_size_input > 0)) {
force_ram_size = force_ram_size_input + "";
}
function uncygwinTempDir() {
if (process.platform === "win32") {
for (let key of ["TMPDIR", "TEMP", "TEMPDIR", "TMP"]) {
let TMPDIR = process.env[key] || "";
if (!/^\/[a-zA-Z]\//.test(TMPDIR)) {
continue;
}
const driveLetter = TMPDIR[1];
TMPDIR = path.win32.normalize(`${driveLetter.toUpperCase()}:` + TMPDIR.substring(2));
process.env[key] = TMPDIR;
}
}
}
uncygwinTempDir();
const cwd = resolve(fileURLToPath(import.meta.url), "../../../../");
process.chdir(cwd);
const ci = !!process.env["GITHUB_ACTIONS"];
const enableProgressBar = !ci;
const enableProgressBar = false;
function defaultConcurrency() {
// Concurrency causes more flaky tests, only enable it by default on windows
// See https://github.com/oven-sh/bun/issues/8071
if (windows) {
return Math.floor((cpus().length - 2) / 2);
}
return 1;
const dirPrefix = "bun-test-tmp-" + ((Math.random() * 100_000_0) | 0).toString(36) + "_";
const run_concurrency = Math.max(Number(process.env["BUN_TEST_CONCURRENCY"] || defaultConcurrency(), 10), 1);
const queue = new PQueue({ concurrency: run_concurrency });
var prevTmpdir = "";
function maketemp() {
prevTmpdir = join(
tmpdir(),
dirPrefix + (Date.now() | 0).toString() + "_" + ((Math.random() * 100_000_0) | 0).toString(36),
);
mkdirSync(prevTmpdir, { recursive: true });
return prevTmpdir;
}
const run_concurrency = Math.max(Number(process.env["BUN_TEST_CONCURRENCY"] || defaultConcurrency(), 10), 1);
const extensions = [".js", ".ts", ".jsx", ".tsx"];
const extensions = [".js", ".ts", ".jsx", ".tsx", ".mjs", ".cjs", ".mts", ".cts", ".mjsx", ".cjsx", ".mtsx", ".ctsx"];
const git_sha =
process.env["GITHUB_SHA"] ?? spawnSync("git", ["rev-parse", "HEAD"], { encoding: "utf-8" }).stdout.trim();
const TEST_FILTER = process.env.BUN_TEST_FILTER;
function isTest(path) {
if (!basename(path).includes(".test.") || !extensions.some(ext => path.endsWith(ext))) {
return false;
}
if (TEST_FILTER) {
if (!path.includes(TEST_FILTER)) {
return false;
}
}
return true;
}
@@ -58,8 +100,15 @@ function* findTests(dir, query) {
}
}
// pick the last one, kind of a hack to allow 'bun run test bun-release' to test the release build
let bunExe = (process.argv.length > 2 ? process.argv[process.argv.length - 1] : null) ?? "bun";
let bunExe = "bun";
if (process.argv.length > 2) {
bunExe = resolve(process.argv.at(-1));
} else if (process.env.BUN_PATH) {
const { BUN_PATH_BASE, BUN_PATH } = process.env;
bunExe = resolve(normalize(BUN_PATH_BASE), normalize(BUN_PATH));
}
const { error, stdout: revision_stdout } = spawnSync(bunExe, ["--revision"], {
env: { ...process.env, BUN_DEBUG_QUIET_LOGS: 1 },
});
@@ -98,59 +147,176 @@ function lookupWindowsError(code) {
const failing_tests = [];
const passing_tests = [];
const fixes = [];
const regressions = [];
let maxFd = -1;
function getMaxFileDescriptor(path) {
if (process.platform === "win32") {
return -1;
}
hasInitialMaxFD = true;
if (process.platform === "linux") {
try {
readdirSync("/proc/self/fd").forEach(name => {
const fd = parseInt(name.trim(), 10);
if (Number.isSafeInteger(fd) && fd >= 0) {
maxFd = Math.max(maxFd, fd);
}
});
return maxFd;
} catch {}
}
const devnullfd = openSync("/dev/null", "r");
closeSync(devnullfd);
maxFd = devnullfd + 1;
return maxFd;
}
let hasInitialMaxFD = false;
const activeTests = new Map();
let slowTestCount = 0;
function checkSlowTests() {
const now = Date.now();
const prevSlowTestCount = slowTestCount;
slowTestCount = 0;
for (const [path, { start, proc }] of activeTests) {
if (proc && now - start >= TIMEOUT_DURATION) {
console.error(
`\x1b[31merror\x1b[0;2m:\x1b[0m Killing test ${JSON.stringify(path)} after ${Math.ceil((now - start) / 1000)}s`,
);
proc?.stdout?.destroy?.();
proc?.stderr?.destroy?.();
proc?.kill?.();
} else if (now - start > SHORT_TIMEOUT_DURATION) {
console.error(
`\x1b[33mwarning\x1b[0;2m:\x1b[0m Test ${JSON.stringify(path)} has been running for ${Math.ceil(
(now - start) / 1000,
)}s`,
);
slowTestCount++;
}
}
if (slowTestCount > prevSlowTestCount && queue.concurrency > 1) {
queue.concurrency += 1;
}
}
setInterval(checkSlowTests, SHORT_TIMEOUT_DURATION).unref();
var currentTestNumber = 0;
async function runTest(path) {
const thisTestNumber = currentTestNumber++;
const name = path.replace(cwd, "").slice(1);
let exitCode, signal, err, output;
const expected_crash_reason = windows
? await readFile(resolve(path), "utf-8").then(data => {
const match = data.match(/@known-failing-on-windows:(.*)\n/);
return match ? match[1].trim() : null;
})
: null;
const start = Date.now();
await new Promise((done, reject) => {
const proc = spawn(bunExe, ["test", resolve(path)], {
stdio: ["ignore", "pipe", "pipe"],
timeout: 1000 * 60 * 3,
env: {
...process.env,
FORCE_COLOR: "1",
BUN_GARBAGE_COLLECTOR_LEVEL: "1",
BUN_JSC_forceRAMSize: force_ram_size,
BUN_RUNTIME_TRANSPILER_CACHE_PATH: "0",
// reproduce CI results locally
GITHUB_ACTIONS: process.env.GITHUB_ACTIONS ?? "true",
BUN_DEBUG_QUIET_LOGS: "1",
},
});
const activeTestObject = { start, proc: undefined };
activeTests.set(path, activeTestObject);
const chunks = [];
proc.stdout.on("data", chunk => {
chunks.push(chunk);
if (run_concurrency === 1) process.stdout.write(chunk);
});
proc.stderr.on("data", chunk => {
chunks.push(chunk);
if (run_concurrency === 1) process.stderr.write(chunk);
});
try {
await new Promise((finish, reject) => {
const chunks = [];
process.stderr.write(
`
at ${((start - run_start.getTime()) / 1000).toFixed(2)}s, file ${thisTestNumber
.toString()
.padStart(total.toString().length, "0")}/${total}, ${failing_tests.length} failing files
Starting "${name}"
proc.on("exit", (code_, signal_) => {
exitCode = code_;
signal = signal_;
output = Buffer.concat(chunks).toString();
done();
`,
);
const TMPDIR = maketemp();
const proc = spawn(bunExe, ["test", resolve(path)], {
stdio: ["ignore", "pipe", "pipe"],
env: {
...process.env,
FORCE_COLOR: "1",
BUN_GARBAGE_COLLECTOR_LEVEL: "1",
BUN_JSC_forceRAMSize: force_ram_size,
BUN_RUNTIME_TRANSPILER_CACHE_PATH: "0",
GITHUB_ACTIONS: process.env.GITHUB_ACTIONS ?? "true",
BUN_DEBUG_QUIET_LOGS: "1",
BUN_INSTALL_CACHE_DIR: join(TMPDIR, ".bun-install-cache"),
[windows ? "TEMP" : "TMPDIR"]: TMPDIR,
},
});
activeTestObject.proc = proc;
proc.stdout.once("end", () => {
done();
});
let doneCalls = 0;
var done = () => {
// TODO: wait for stderr as well
// spawn.test currently causes it to hang
if (doneCalls++ === 1) {
actuallyDone();
}
};
var actuallyDone = function () {
actuallyDone = done = () => {};
proc?.stderr?.unref?.();
proc?.stdout?.unref?.();
proc?.unref?.();
output = Buffer.concat(chunks).toString();
finish();
};
// if (!KEEP_TMPDIR)
// proc.once("close", () => {
// rm(TMPDIR, { recursive: true, force: true }).catch(() => {});
// });
proc.stdout.on("data", chunk => {
chunks.push(chunk);
if (run_concurrency === 1) process.stdout.write(chunk);
});
proc.stderr.on("data", chunk => {
chunks.push(chunk);
if (run_concurrency === 1) process.stderr.write(chunk);
});
proc.once("close", () => {
activeTestObject.proc = undefined;
});
proc.once("exit", (code_, signal_) => {
activeTestObject.proc = undefined;
exitCode = code_;
signal = signal_;
if (signal || exitCode !== 0) {
actuallyDone();
} else {
done();
}
});
proc.once("error", err_ => {
activeTestObject.proc = undefined;
err = err_;
actuallyDone();
});
});
proc.on("error", err_ => {
err = err_;
done();
});
});
} finally {
activeTests.delete(path);
}
if (!hasInitialMaxFD) {
getMaxFileDescriptor();
} else if (maxFd > 0) {
const prevMaxFd = maxFd;
maxFd = getMaxFileDescriptor();
if (maxFd > prevMaxFd + queue.concurrency * 2) {
process.stderr.write(
`\n\x1b[31mewarn\x1b[0;2m:\x1b[0m file descriptor leak in ${name}, delta: ${
maxFd - prevMaxFd
}, current: ${maxFd}, previous: ${prevMaxFd}\n`,
);
}
}
const passed = exitCode === 0 && !err && !signal;
@@ -195,7 +361,8 @@ async function runTest(path) {
}
console.log(
`\x1b[2m${formatTime(duration).padStart(6, " ")}\x1b[0m ${passed ? "\x1b[32m✔" : expected_crash_reason ? "\x1b[33m⚠" : "\x1b[31m✖"
`\x1b[2m${formatTime(duration).padStart(6, " ")}\x1b[0m ${
passed ? "\x1b[32m✔" : "\x1b[31m✖"
} ${name}\x1b[0m${reason ? ` (${reason})` : ""}`,
);
@@ -210,28 +377,17 @@ async function runTest(path) {
}
if (!passed) {
if (reason) {
if (windows && !expected_crash_reason) {
regressions.push({ path: name, reason, output });
}
}
failing_tests.push({ path: name, reason, output, expected_crash_reason });
failing_tests.push({ path: name, reason, output });
process.exitCode = 1;
if (err) console.error(err);
} else {
if (windows && expected_crash_reason !== null) {
fixes.push({ path: name, output, expected_crash_reason });
}
passing_tests.push(name);
}
return passed;
}
const queue = [...findTests(resolve(cwd, "test"))];
let running = 0;
let total = queue.length;
let finished = 0;
let on_entry_finish = null;
var finished = 0;
function writeProgressBar() {
const barWidth = Math.min(process.stdout.columns || 40, 80) - 2;
@@ -241,34 +397,23 @@ function writeProgressBar() {
process.stdout.write(`\r${str1}${" ".repeat(barWidth - str1.length)}]`);
}
while (queue.length > 0) {
if (running >= run_concurrency) {
await new Promise(resolve => (on_entry_finish = resolve));
continue;
}
const path = queue.shift();
running++;
runTest(path)
.catch(e => {
console.error("Bug in bun-internal-test");
console.error(e);
process.exit(1);
})
.finally(() => {
running--;
if (on_entry_finish) {
on_entry_finish();
on_entry_finish = null;
}
});
}
while (running > 0) {
await Promise.race([
new Promise(resolve => (on_entry_finish = resolve)),
new Promise(resolve => setTimeout(resolve, 1000)),
]);
const allTests = [...findTests(resolve(cwd, "test"))];
console.log(`Starting ${allTests.length} tests with ${run_concurrency} concurrency...`);
let total = allTests.length;
for (const path of allTests) {
queue.add(
async () =>
await runTest(path).catch(e => {
console.error("Bug in bun-internal-test");
console.error(e);
process.exit(1);
}),
);
}
await queue.onIdle();
console.log(`
Completed ${total} tests with ${failing_tests.length} failing tests
`);
console.log("\n");
function linkToGH(linkTo) {
@@ -279,10 +424,13 @@ function sectionLink(linkTo) {
return "#" + linkTo.replace(/[^a-zA-Z0-9_-]/g, "").toLowerCase();
}
failing_tests.sort((a, b) => a.path.localeCompare(b.path));
passing_tests.sort((a, b) => a.localeCompare(b));
const failingTestDisplay = failing_tests
.filter(({ reason }) => !regressions.some(({ path }) => path === path))
.map(({ path, reason }) => `- [\`${path}\`](${sectionLink(path)})${reason ? ` ${reason}` : ""}`)
.join("\n");
// const passingTestDisplay = passing_tests.map(path => `- \`${path}\``).join("\n");
rmSync("report.md", { force: true });
@@ -319,9 +467,10 @@ console.log("\n" + "-".repeat(Math.min(process.stdout.columns || 40, 80)) + "\n"
console.log(header);
console.log("\n" + "-".repeat(Math.min(process.stdout.columns || 40, 80)) + "\n");
let report = `# bun test on ${process.env["GITHUB_REF"] ??
let report = `# bun test on ${
process.env["GITHUB_REF"] ??
spawnSync("git", ["rev-parse", "--abbrev-ref", "HEAD"], { encoding: "utf-8" }).stdout.trim()
}
}
\`\`\`
${header}
@@ -329,31 +478,8 @@ ${header}
`;
if (fixes.length > 0) {
report += `## Fixes\n\n`;
report += "The following tests had @known-failing-on-windows but now pass:\n\n";
report += fixes
.map(
({ path, expected_crash_reason }) => `- [\`${path}\`](${sectionLink(path)}) (before: ${expected_crash_reason})`,
)
.join("\n");
report += "\n\n";
}
if (regressions.length > 0) {
report += `## Regressions\n\n`;
report += regressions
.map(
({ path, reason, expected_crash_reason }) =>
`- [\`${path}\`](${sectionLink(path)}) ${reason}${expected_crash_reason ? ` (expected: ${expected_crash_reason})` : ""
}`,
)
.join("\n");
report += "\n\n";
}
if (failingTestDisplay.length > 0) {
report += `## ${windows ? "Known " : ""}Failing tests\n\n`;
report += `## Failing tests\n\n`;
report += failingTestDisplay;
report += "\n\n";
}
@@ -366,17 +492,10 @@ if (failingTestDisplay.length > 0) {
if (failing_tests.length) {
report += `## Failing tests log output\n\n`;
for (const { path, output, reason, expected_crash_reason } of failing_tests) {
for (const { path, output, reason } of failing_tests) {
report += `### ${path}\n\n`;
report += "[Link to file](" + linkToGH(path) + ")\n\n";
if (windows && reason !== expected_crash_reason) {
report += `To mark this as a known failing test, add this to the start of the file:\n`;
report += `\`\`\`ts\n`;
report += `// @known-failing-on-windows: ${reason}\n`;
report += `\`\`\`\n\n`;
} else {
report += `${reason}\n\n`;
}
report += `${reason}\n\n`;
report += "```\n";
report += output
.replace(/\x1b\[[0-9;]*m/g, "")
@@ -391,18 +510,12 @@ writeFileSync(
JSON.stringify({
failing_tests,
passing_tests,
fixes,
regressions,
}),
);
console.log("-> test-report.md, test-report.json");
if (ci) {
if (windows) {
action.setOutput("regressing_tests", regressions.map(({ path }) => `- \`${path}\``).join("\n"));
action.setOutput("regressing_test_count", regressions.length);
}
if (failing_tests.length > 0) {
action.setFailed(`${failing_tests.length} files with failing tests`);
}
@@ -414,12 +527,6 @@ if (ci) {
}
action.summary.addRaw(truncated_report);
await action.summary.write();
} else {
if (windows && (regressions.length > 0 || fixes.length > 0)) {
console.log(
"\n\x1b[34mnote\x1b[0;2m:\x1b[0m If you would like to update the @known-failing-on-windows annotations, run `bun update-known-failures`",
);
}
}
process.exit(failing_tests.length ? 1 : 0);
process.exit(failing_tests.length ? 1 : process.exitCode);

View File

@@ -1,49 +0,0 @@
import assert from "assert";
import { existsSync, readFileSync, writeFileSync } from "fs";
import { join } from "path";
import { fileURLToPath } from "url";
if (process.platform !== "win32") {
console.log("This script is only intended to be run on Windows.");
process.exit(1);
}
process.chdir(join(fileURLToPath(import.meta.url), "../../../../"));
if (!existsSync("test-report.json")) {
console.log("No test report found. Please run `bun run test` first.");
process.exit(1);
}
const test_report = JSON.parse(readFileSync("test-report.json", "utf8"));
assert(Array.isArray(test_report.failing_tests));
for (const { path, reason, expected_crash_reason } of test_report.failing_tests) {
assert(path);
assert(reason);
if (expected_crash_reason !== reason) {
const old_content = readFileSync(path, "utf8");
if (!old_content.includes("// @known-failing-on-windows")) {
let content = old_content.replace(/\/\/\s*@known-failing-on-windows:.*\n/, "");
if (reason) {
content = `// @known-failing-on-windows: ${reason}\n` + content;
}
writeFileSync(path, content, "utf8");
console.log(path);
}
}
}
for (const { path } of test_report.fixes) {
assert(path);
const old_content = readFileSync(path, "utf8");
let content = old_content.replace(/\/\/\s*@known-failing-on-windows:.*\n/, "");
if (content !== old_content) {
writeFileSync(path, content, "utf8");
console.log(path);
}
}

Binary file not shown.

View File

@@ -32,20 +32,20 @@ export class PublishCommand extends BuildCommand {
}
const { layer, region, arch, output, public: isPublic } = flags;
if (region.includes("*")) {
// biome-ignore: format ignore
// prettier-ignore
const result = this.#aws(["ec2", "describe-regions", "--query", "Regions[].RegionName", "--output", "json"]);
region.length = 0;
for (const name of JSON.parse(result)) {
region.push(name);
}
} else if (!region.length) {
// biome-ignore: format ignore
// prettier-ignore
region.push(this.#aws(["configure", "get", "region"]));
}
this.log("Publishing...");
for (const regionName of region) {
for (const layerName of layer) {
// biome-ignore: format ignore
// prettier-ignore
const result = this.#aws([
"lambda",
"publish-layer-version",
@@ -70,7 +70,7 @@ export class PublishCommand extends BuildCommand {
const { LayerVersionArn } = JSON.parse(result);
this.log("Published", LayerVersionArn);
if (isPublic) {
// biome-ignore: format ignore
// prettier-ignore
this.#aws([
"lambda",
"add-layer-version-permission",

Binary file not shown.

Binary file not shown.

View File

@@ -19,9 +19,7 @@ export default function polyfillImportMeta(metaIn: ImportMeta) {
dir: path.dirname(metapath),
file: path.basename(metapath),
require: require2,
async resolve(id: string, parent?: string) {
return this.resolveSync(id, parent);
},
resolve: metaIn.resolve,
resolveSync(id: string, parent?: string) {
return require2.resolve(id, {
paths: typeof parent === 'string' ? [

View File

@@ -1,6 +1,8 @@
.DS_Store
.env
node_modules
/npm/**/bin
/npm/**/*.js
/npm/**/.npmrc
.DS_Store
.env
node_modules
/npm/**/bin
/npm/**/*.js
/npm/**/package.json
/npm/**/.npmrc
*.tgz

Binary file not shown.

View File

@@ -1,16 +0,0 @@
{
"name": "@oven/bun-darwin-aarch64",
"version": "0.5.3",
"description": "This is the macOS arm64 binary for Bun, a fast all-in-one JavaScript runtime.",
"homepage": "https://bun.sh",
"bugs": "https://github.com/oven-sh/issues",
"license": "MIT",
"repository": "https://github.com/oven-sh/bun",
"preferUnplugged": true,
"os": [
"darwin"
],
"cpu": [
"arm64"
]
}

View File

@@ -1,16 +0,0 @@
{
"name": "@oven/bun-darwin-x64-baseline",
"version": "0.5.3",
"description": "This is the macOS x64 binary for Bun, a fast all-in-one JavaScript runtime.",
"homepage": "https://bun.sh",
"bugs": "https://github.com/oven-sh/issues",
"license": "MIT",
"repository": "https://github.com/oven-sh/bun",
"preferUnplugged": true,
"os": [
"darwin"
],
"cpu": [
"x64"
]
}

View File

@@ -1,16 +0,0 @@
{
"name": "@oven/bun-darwin-x64",
"version": "0.5.3",
"description": "This is the macOS x64 binary for Bun, a fast all-in-one JavaScript runtime.",
"homepage": "https://bun.sh",
"bugs": "https://github.com/oven-sh/issues",
"license": "MIT",
"repository": "https://github.com/oven-sh/bun",
"preferUnplugged": true,
"os": [
"darwin"
],
"cpu": [
"x64"
]
}

View File

@@ -1,16 +0,0 @@
{
"name": "@oven/bun-linux-aarch64",
"version": "0.5.3",
"description": "This is the Linux arm64 binary for Bun, a fast all-in-one JavaScript runtime.",
"homepage": "https://bun.sh",
"bugs": "https://github.com/oven-sh/issues",
"license": "MIT",
"repository": "https://github.com/oven-sh/bun",
"preferUnplugged": true,
"os": [
"linux"
],
"cpu": [
"arm64"
]
}

View File

@@ -1,16 +0,0 @@
{
"name": "@oven/bun-linux-x64-baseline",
"version": "0.5.3",
"description": "This is the Linux x64 binary for Bun, a fast all-in-one JavaScript runtime.",
"homepage": "https://bun.sh",
"bugs": "https://github.com/oven-sh/issues",
"license": "MIT",
"repository": "https://github.com/oven-sh/bun",
"preferUnplugged": true,
"os": [
"linux"
],
"cpu": [
"x64"
]
}

View File

@@ -1,16 +0,0 @@
{
"name": "@oven/bun-linux-x64",
"version": "0.5.3",
"description": "This is the Linux x64 binary for Bun, a fast all-in-one JavaScript runtime.",
"homepage": "https://bun.sh",
"bugs": "https://github.com/oven-sh/issues",
"license": "MIT",
"repository": "https://github.com/oven-sh/bun",
"preferUnplugged": true,
"os": [
"linux"
],
"cpu": [
"x64"
]
}

View File

@@ -0,0 +1,5 @@
# Bun
This is the Windows x64 binary for Bun, a fast all-in-one JavaScript runtime. https://bun.sh
_Note: "Baseline" builds are for machines that do not support [AVX2](https://en.wikipedia.org/wiki/Advanced_Vector_Extensions) instructions._

View File

@@ -0,0 +1,3 @@
# Bun
This is the Windows x64 binary for Bun, a fast all-in-one JavaScript runtime. https://bun.sh

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