Compare commits

..

1395 Commits
repl ... fmt

Author SHA1 Message Date
Zack Radisic
8a3154098c Run zig fmt 2024-02-12 17:41:31 -06:00
Georgijs
a80b3569b4 disable quiet logs when BUN_DEBUG_LOG is set to 0 (#8866) 2024-02-12 15:20:38 -08:00
argosphil
8b5cac1ea1 chore: use shell-independent globbing in bun run fmt:zig (#8861)
* fix: use shell-independent globbing in bun run fmt:zig

* Erase experimental creature escaped from @paperdave's lab.

See https://github.com/oven-sh/bun/pull/8861#discussion_r1485747297
2024-02-12 14:51:39 -08:00
John-David Dalton
96e7227087 feat: Add win32 path.toNamespacedPath and align rest of node:path with Node (#8469) 2024-02-12 14:27:26 -08:00
Dale Seo
f88855da4f docs: non-null assertion is needed on document.getElementById (#8540) 2024-02-11 20:10:17 -08:00
Ujjwal gupta
19cb3ab6ff fix: ws.publish() not working (#8855)
* fix: ws.publish() not working

* fixes
2024-02-11 13:56:06 -08:00
argosphil
862d35d832 fix: bun test -t (#8845) 2024-02-11 08:39:27 -08:00
argosphil
a0bcd0f946 Fix expect().toBeGreaterThan() not throwing when ANSI is disabled (#8838) 2024-02-10 14:00:16 -08:00
guest271314
2264bb3d04 Substitute js/ for test/js/ (404) (#8808) 2024-02-10 10:44:22 -08:00
Ciro Spaciari
3e1231deb4 fix(crypto) fix KeyObjectkey handling (#8824)
* ref/deref buffer

* Clean up this code

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-09 21:14:35 -08:00
dave caruso
dfcac563bc fix error message in bun.serve (#8828)
* fix error message in bun.serve

* ok
2024-02-09 17:24:46 -08:00
Ciro Spaciari
90fd322b5c fix timer tests (#8804) 2024-02-09 14:00:47 -08:00
Zack Radisic
f77b217abf Correct shell docs for $.escape() 2024-02-09 11:41:59 -06:00
Risu
7c2be6a877 Fix bun-types/index.d.ts (#8802) 2024-02-09 08:46:42 -08:00
Dylan Conway
a3c3dad351 wrap (#8812) 2024-02-09 03:42:03 -08:00
Travis Cooper
98b438d0a4 Update bunfig.md (#8807) 2024-02-09 01:54:00 -08:00
cirospaciari
58d22b063c Unmark tests that are now passing on Windows 2024-02-08 23:02:32 -03:00
Ciro Spaciari
8cd1db9cda [windows] fix crypto (#8797)
* fix password

* refactor

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-02-08 18:00:22 -08:00
dave caruso
2d7df726fd fix: get bun build working on window (#8712)
* work on bundler

* a

* YAAAAYYAYAYAYYAYA

* get some more bundler tests working

* Update src/bundler/bundle_v2.zig

* rev

* ok

* i converted the cmakelists into LF

* personal review

* we didnt win

* okey they pass

* revert :(

* a

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-02-08 17:56:26 -08:00
Ashcon Partovi
1ccf0c2e9c Fix some errors not showing up in GitHub annotations (#8799)
* Remove dead code now that `expect()` can be used outside of tests

* Fix some errors not being rendered to GitHub annotations

* [autofix.ci] apply automated fixes

* Update jest.zig

Try `execCallback`

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-02-08 17:52:58 -08:00
cirospaciari
db85e04ade Unmark tests that are now passing on Windows 2024-02-08 22:19:31 -03:00
Ciro Spaciari
c2936b205d [windows] fix(fetch) file:///, keepalive and tests on Windows (#8784)
* fix file:/// on windows

* skip fifo test

* fix keepalive

* fixes

* avoid std.os.getcwd on POSIX
2024-02-08 17:11:06 -08:00
dave caruso
8680641c23 make process.test.js pass (#8798) 2024-02-08 16:54:09 -08:00
Ciro Spaciari
e77db8ebac [windows] fix which (#8791)
* fix which

* [autofix.ci] apply automated fixes

* refactor

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-02-08 15:44:56 -08:00
Steven Roussey
dfbedd6a10 fix: flaky test (#8796)
This often fails in CI (and on my machine) non-deterministically.

The 1ms + the 5000 is likely setting up a race condition in tasks/microtasks. Just changing it to to +10ms instead of +1ms is enough.
2024-02-08 15:17:14 -08:00
Ashcon Partovi
8624a86eba Unmark tests that are now passing on Windows 2024-02-08 13:42:13 -08:00
Georgijs
bfc6091faf correctly unblock all signals (#8792) 2024-02-08 12:09:33 -08:00
Joe
9d0a88ab82 docs: quick note on dependencies for C++ (#8772)
* quick note on dependencies for C++

* note Ubuntu C++ standard lib issue and anchor link to troubleshooting

* clarify ubuntu distros
2024-02-08 11:18:37 -08:00
Jarred Sumner
2f8f77eeb7 Ignore panic in reload (#8778)
* Ignore panic in reload

* Use

* Update c-bindings.cpp

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-08 00:29:08 -08:00
Steven Roussey
7b6e0f7164 fix: Increase max depth of expect diffs (#8771)
Fix Issue #6519
2024-02-07 16:07:20 -08:00
Ciro Spaciari
5df59cb02b [windows] fix(fs.watch) (#8746)
* clean fixes

* [autofix.ci] apply automated fixes

* more tests passing

* EPERM instead of AccessDenied

* [autofix.ci] apply automated fixes

* fix test on windows

* cleanup

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-02-07 15:44:07 -08:00
Jarred Sumner
b61282e290 Fix async module mocking (#8769)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-07 15:40:10 -08:00
Dylan Conway
dd3227c436 fix: crash in release builds (#8773)
* zig

* unreachable

* more comment
2024-02-07 15:38:14 -08:00
Georgijs
a9a4bbcd24 remap 0.0.0.0 to localhost on windows (#8770) 2024-02-07 15:17:24 -08:00
Georgijs
55aa35ee35 Fix watch attempting to reuse ports that are not yet released by the old process (#8764)
* windows watcher start new process only after previous terminated

* simplify env setup in spawnWatcherChild
2024-02-07 15:11:28 -08:00
dave caruso
a99459ffdc fix: symlinked files as entry points do not show Bun.main (#8762) 2024-02-07 13:06:11 -08:00
Jake Gordon
08f957d33b fix glob example to be recursive as stated (#8755) 2024-02-07 12:53:28 -08:00
Georgijs
2bd4fe578e Make HTTP shutdowns more robust, speed up connection to localhost (#8730)
* http use arraylist to handle shutdowns

* on windows use wsaconnectbyname to speed up localhost connections

* use arbitrary port

* close socket on setsockopt error

* use null timeout in wsaconnectbyname

* Update src/http.zig

* fix zig compile

* update hostname on linux

* [autofix.ci] apply automated fixes

* fix getpeername failing after connecting with socket

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-02-07 12:19:41 -08:00
Georgijs
d672309547 c-ares dns on windows (#8737)
* c_ares dns on windows works

* handle errors

* fix invalid hostnames test
2024-02-07 16:26:53 -03:00
argosphil
e171f04ce6 Fix ref-counting of Bun.file(0) etc. (#8687) (#8741)
* Test for #8687

* Fix reference counting of Bun.file(0) etc. (#8687)

Fixes #8687.
2024-02-06 18:11:25 -08:00
Ciro Spaciari
651d5699a0 [windows] fix(fs.watchFile) (#8735)
* fix fs.watchFile

* oopsie

* fix bigint and persistent

* use repeat to make watchFile tests more reliable

* [autofix.ci] apply automated fixes

* follow the pattern

* add increment

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-02-06 18:10:28 -08:00
Meghan Denny
d0d4d8bf85 windows: enable more passing tests (#8711)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-02-06 16:08:49 -08:00
Ciro Spaciari
53814dda00 [windows] fix(http2) (#8734)
* fix win http2

* add includes

* cleanup

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-02-06 15:37:39 -08:00
Meghan Denny
d3d5c7a1d6 tidy: access env map through getter rather than direct field (#8716) 2024-02-06 11:25:45 -08:00
Jarred Sumner
972a7b7080 skip some tests 2024-02-05 19:51:08 -08:00
Jarred Sumner
e3759bbbfe Update bun-windows.yml 2024-02-05 18:46:18 -08:00
Jarred Sumner
f722236978 [windows] Make child_process.spawn not say "TODO: IPC" when IPC isn't used 2024-02-05 17:39:47 -08:00
dave caruso
e366921e90 fix(windows): make fs.symlink normalize forward slashes to backslashes (#8710)
* fix fs.symlink()

* update comment

* .

* add todo
2024-02-05 16:09:50 -08:00
Georgijs
bd2779b029 Fix --hot with empty file, make --hot faster on windows (#8708)
* reduce watcher timeout in windows, fix hot reload with empty files

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-02-05 14:40:18 -08:00
Ashcon Partovi
a05ef0aeb1 Remove unintentional commit
This reverts commit 23b292ac21.
2024-02-05 12:50:09 -08:00
Ashcon Partovi
264142e756 Add isWindows and related helpers to test harness 2024-02-05 12:47:52 -08:00
Ashcon Partovi
51def5f5d6 Use biome in bun-types 2024-02-05 12:22:39 -08:00
Ashcon Partovi
23b292ac21 T 2024-02-05 12:22:39 -08:00
dave caruso
48ed1dfb65 less (#8651)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-02-05 10:06:23 -08:00
Drake Semchyshyn
bd4d0d15db Update plugins.md (#8674)
Updated Custom Plugins section (Svelte) so that the import name, and the name that was used, matches each other.
2024-02-04 01:19:00 -08:00
Jarred Sumner
1f0c1c81e9 Fix test 2024-02-04 00:42:40 -08:00
Jarred Sumner
e93eb6c1ab Add event loop debug assertion for Promise.resolve() and Promise.reject() 2024-02-04 00:03:45 -08:00
Jarred Sumner
1009b07807 Implement server.unref() and server.ref() (#8675)
* Implement server.ref() and server.unref()

* Update dns_resolver.zig

* Update server.zig

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-03 23:57:34 -08:00
Georgijs
1a695f13bf Async file copying on windows (#8649)
* rework and simplify file opening in windows

* fix tests

* symlink tests pass

* update error handling

* remove outdated normalization check

* fix mac build

* apply suggested fixes

* fix path tests

* remove debug print

* fix windows compile
2024-02-03 22:33:35 -08:00
Jarred Sumner
c75e768a6c Assert we drained the microtask queue since the last time we called into JavaScript (#8646)
* Add checks that we drain the microtask queue whenever we call into JavaScript

* Drain microtasks in more places

* Tweak assertions for entering/exiting the event loop

* Drain more

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-03 07:40:15 -08:00
Dylan Conway
7d86f9e590 fix(test): strict equals and deleted properties (#8663)
* deleted properties size

* dont need count if structure id is eql

* more test

* fix slow path

* oops forgot this
2024-02-03 06:35:13 -08:00
Dylan Conway
a8600b0878 upgrade 2024-02-03 06:20:24 -08:00
Dylan Conway
5b228256f9 method and comment 2024-02-03 04:24:20 -08:00
Dylan Conway
ba4daee7e5 fix: statement joining and tmpdir on windows (#8659)
* drive letter

* joinwithcomma bundle

* tmpdir update

* same order as os.tmpdir
2024-02-03 04:17:12 -08:00
Jarred Sumner
2c0c562d1d Fixes #4746 (#8661)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-02-03 03:38:59 -08:00
Jarred Sumner
683a03d8c7 Set a default value for Error.prepareStackTrace to align with Node (#8657)
* Set a default value for `Error.prepareStackTrace` to align with Node

* Ensure we never set negative line/column numbers in error.stack (#8656)

* fix(windows): fix macros (#8653)

* fix macro tests

* path format options

* remove failing comment

* fix buffer toString memcpy length

* Ensure we never set negative line/column numbers in error.stack

---------

Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
2024-02-03 02:04:58 -08:00
Dylan Conway
e0c0fe235a fix(windows): fix macros (#8653)
* fix macro tests

* path format options

* remove failing comment

* fix buffer toString memcpy length
2024-02-03 00:35:25 -08:00
Jarred Sumner
d16ac87347 Export compile_commands.json 2024-02-02 23:25:07 -08:00
Dylan Conway
5934b17f00 fix(windows): fix a few more tests (#8644)
* fix regression tests

* fix fs.test.ts bigintstats

* enable transpiler cache lol

* remove failing

* fix filesystem router

* update

* fix run-unicode test

* update comment

* add updated snapshot

* fix remaining node-module-module tests

* fixup

* [autofix.ci] apply automated fixes

* fix tty tests

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-02-02 18:58:16 -08:00
Ashcon Partovi
eedf008c80 Fix formatting not always working 2024-02-02 14:25:53 -08:00
Meghan Denny
3a6318b67c windows: fix module.paths getter causing a crash (#8633)
* windows: fix module.paths getter causing a crash

* use the buffer that was there before
2024-02-02 01:29:50 -08:00
dave caruso
647b15e4f3 fix(windows): initialize uv allocators earlier (#8631)
* uv loop is thread local

* hi

* stuff so far

* [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-02-02 00:18:28 -08:00
ふかねこ
625b172a71 docs: Update binary-data.md (#8635)
Binary notation ("0b") is appropriate instead of hexadecimal notation ("0x").

Sorry for the omission of the correction in this [PR](https://github.com/oven-sh/bun/pull/8619).
2024-02-02 00:16:14 -08:00
Meghan Denny
4959c7d363 remove ZigString.Slice.from .init is the exact same thing (#8632)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-02-01 20:35:47 -08:00
Meghan Denny
8808437a02 meta: remove remaining references to prettierrc.cjs (#8634) 2024-02-01 19:24:17 -08:00
Tiramify (A.K. Daniel)
330a4744de chore: fix compiling fd.zig on linux (#8630) 2024-02-01 17:31:54 -08:00
Ashcon Partovi
3a1229d03d Add mysql2 integration test (#8075) 2024-02-01 15:04:49 -08:00
Ashcon Partovi
63a9a8b015 Improve .vscode extensions, tasks, and configuration (#8511) 2024-02-01 14:55:35 -08:00
dave caruso
f73bde79c7 fix(debug): get the result for fd debug message before we close it (#8626) 2024-02-01 14:26:20 -08:00
Meghan Denny
3a7df3f6c7 windows: add more passing test (#8615) 2024-02-01 13:45:47 -08:00
dave caruso
0037dc2537 chore: update webkit 2024-02-01 13:38:09 -08:00
ふかねこ
c0fe042102 Update binary-data.md (#8619)
Binary notation ("0b") is appropriate instead of hexadecimal notation ("0x").
2024-02-01 12:38:54 -08:00
Andres Guarneros
ce1eba1954 Update quickstart.md (#8622)
Update index.ts code snippet for consistency in quickstart.md.
2024-02-01 12:38:21 -08:00
Dylan Conway
8191fbd970 fix: id instead of path (#8617)
* use id

* another path
2024-02-01 02:19:18 -08:00
Dylan Conway
2af7cdedc2 path should be dirname 2024-02-01 00:34:34 -08:00
Dylan Conway
4f98336f86 fix(windows): fix installing non-ascii paths and make normalizeBuf generic (#8608)
* comptime type normalizeStringBuf

* delete

* revert

* revert revert

* revert

* remove unused

* remove unnecessary assert

* add comment

* remove normalize, need ../

* use Output.err

* update error message

* generic T suffix

* fix windows build

* more fix build

* more fix build

* mkdiratZ

* update test

* [autofix.ci] apply automated fixes

* update snapshot again

* fix merge

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-31 22:44:23 -08:00
dave caruso
91cfd614ca fix(window): some more bin things (#8612)
* allow linking bins that do not exist.

* fix some things
2024-01-31 22:37:03 -08:00
Meghan Denny
42e4cd8408 get more bundler tests passing on windows (#8560)
* get test/bundler/bundler_naming.test.ts passing on windows

* move platformToPosixInPlace to bun.path and use the vector'd version

* only resolve rel_path if it contains '/./', most of the time './' needs to be preserved

* fix another file too

* move kernel32 extern to better location

* [autofix.ci] apply automated fixes

* use bun.path.posixToPlatformInPlace here

* rewrite this whole section to stay in utf16 and handle errors

* remove dead comments

* fix a typo

* undo these relative changes

* preserve path.pretty from getting lost

* use bun's instead of zig's resolve here

* both side of this loop need the inplace normal

* use existing generic dirname function

* make path inplace functions generic

* we might need to modify this so copy on windows

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

* don't assume the prefix we get from this

* more robust path traversal

* don't mangle absolute paths

* do this bit in a loop

* this line is a u16

* dont forget to compile before pushing

* this was wrong

* look into this later

* check pointer math first since its faster

* posix syscalls support path traversal, don't do the work for them

* its already inside stable, no need to change

* used the online editor

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-31 22:29:33 -08:00
dave caruso
dbe0a4a978 do more assertions (#8610) 2024-01-31 22:14:03 -08:00
Georgijs
350cc1178a --watch and --hot on windows (#8607)
* draft impl of windows watcher

* synchronous watcher

* working standalone watcher

* in progress changes to watcher

* make watcher non-global

* prepare watcher for windows impl

* add windows watcher scaffold and clean up imports

* fix inotify

* make watch code more generic over platforms

* fix visibility

* watcher starts without error

* printing changes works

* basic windows watching works

* handle process exit from watcher

* cleanup in process cloning

* clean up logging and panic handling

* fix hot reload test on windows

* misc cleanup around watcher

* make watch test actually useful

* [autofix.ci] apply automated fixes

* remove old files

* clean up watchers

* update .gitignore

* rework windows watcher into single watcher instance watching top level project dir

* use non-strict utf16 conversion

* change to contains

* fix mac and linux compile

* add baseline in crash report (#8606)

* allow linking bins that do not exist. (#8605)

* fix linux compile

* fix linux compile (again)

* remove outdated todo

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: dave caruso <me@paperdave.net>
2024-01-31 22:06:33 -08:00
Jarred Sumner
dccabd9423 Make test work better on windows 2024-01-31 22:03:52 -08:00
dave caruso
345a061d3b fix(windows): make process.env case-insensitive (#8578)
* yay!!!!!!

* [autofix.ci] apply automated fixes

* ok

* do not use reflect here

* ok

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-31 21:52:50 -08:00
3λiȯ+
690346b30b docs: Fix typo in code example for Transpiler.transformSync (#8553)
* Docs: Fix typo in code example for transformSync

* Remove await since transformSync is synchronous

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

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-31 21:18:57 -08:00
huseeiin
16b7b94aea Update bun.d.ts (#8595)
Add `string | ArrayBuffer` to compressing/uncompression functions
2024-01-31 21:13:12 -08:00
Meghan Denny
fcf0047763 windows: pass ws.test.ts (#8611) 2024-01-31 21:08:19 -08:00
dave caruso
af1a124831 allow linking bins that do not exist. (#8605) 2024-01-31 19:08:50 -08:00
dave caruso
f5754e3c19 add baseline in crash report (#8606) 2024-01-31 18:13:39 -08:00
Joe
4e09f8ef8f Issue-6526 - clarify web docs for the use of .only() (#8600)
* Update writing.md

clarify the use of `.only()`

* Update test.d.ts

Small clarification in JSDoc
2024-01-31 14:12:26 -08:00
Luke Ingalls
1969204fa5 docs: remove outdated callout (#8584)
seems like this is already patched https://github.com/oven-sh/bun/issues/5394
2024-01-31 00:08:26 -08:00
dave caruso
2d9db9b28f fix napi-rs libraries on windows (#8583)
* yay

* a

* ok

* typo

* un-CRLFify these files
2024-01-30 20:21:52 -08:00
dave caruso
0333c7b0bf Fix "__dirname" on windows (#8579) 2024-01-30 16:17:32 -08:00
Dylan Conway
82829c5925 fix crash 2024-01-30 13:44:00 -08:00
dave caruso
8fdb46cb91 ok 2024-01-30 10:04:06 -08:00
vinnichase
0aba51230c dx: create symlink on every execution (#8568)
Symlink is not created on first setup.
2024-01-30 09:41:18 -08:00
Dylan Conway
ca801a35fe fix(windows): fix win32 errors (#8569)
* translate eexist

* use SystemErrno translation

* update
2024-01-30 06:49:59 -08:00
vinnichase
692fb220a4 Update launch.json to use ${workspaceFolder}/build/bun-debug (#8570) 2024-01-29 22:38:43 -08:00
dave caruso
cf1c849e4a fix(windows): more reliable extracting (#8567)
* finally

* a

* Update src/install/extract_tarball.zig

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

* fix compilation

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-29 20:03:02 -08:00
Jarred Sumner
2eede4f435 Fixes #8555 (#8566)
* Fixes #8555

* Make this closer to what npm does

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-29 17:52:08 -08:00
dave caruso
4989ef88b8 docs: mark PerformanceEntry and friends as implemented (#8466)
* docs: mark PerformanceEntry and friends as implemented

* Update docs/runtime/nodejs-apis.md

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-29 15:49:06 -08:00
Jarred Sumner
9fa26e6a09 Close more file descriptors in bun --watch (#8533)
* Close more file descriptors in `bun --watch`

* Reset signals

* Add comment

* Update bun.zig

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-29 15:48:26 -08:00
Jarred Sumner
413aaaff33 [bun:sqlite] Support multiple statements in db.run() (#8541)
* [bun:sqlite] Support multiple statements in db.run()

* Update sqlite.test.js

* Update JSSQLStatement.cpp

* Another test

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-29 15:17:51 -08:00
Dylan Conway
c538bf87d1 fix(windows): transpiler cache and other test fixes (#8471)
* umask

* process args

* update reportError.test.ts

* file exists

* transpiler cache

* back to const

* remove failing comments

* [autofix.ci] apply automated fixes

* update comment

* debug assert and remmove branch

* oops

* escape

* path sep

* seekTo

* disable

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-29 15:17:23 -08:00
dave caruso
1e9b44adda internal: report all failing tests to our internal feed (#8563)
* yeah

* oop

* yeahh
2024-01-29 15:17:14 -08:00
dave caruso
3046b0ee39 feat(windows): allow open and Bun.file() with /dev/null (#8499)
* DEV NULL

* oops

* ok
2024-01-29 11:08:09 -08:00
dave caruso
01d41838c5 fix(builtin-bundler): do not replace globals when extending classes (#8557)
* fix(builtin-bundler): do not replace globals when extending classes

* format
2024-01-29 11:07:39 -08:00
dave caruso
bc7e7027e4 windows: some random things (#8521)
* swaggin

* fix(bun_shim_impl): support exe names that are shorter than four characters

* hi

* a
2024-01-29 10:50:24 -08:00
João V. Farias
eaea6dea54 chore(build): adjust arch/manjaro linux auto detect to include artix (#8510) 2024-01-29 09:41:58 -08:00
Jarred Sumner
d0b759f784 Remove references to bun-types 2024-01-29 08:10:14 -08:00
Dale Seo
dbfc62e288 docs: include .jsx (#8542) 2024-01-28 10:00:54 -08:00
Yahya Jirari
34ae040d95 docs: remove unnecessary await in lines() example (#8537) 2024-01-28 06:36:29 -08:00
Ben Limmer
3caa846988 docs: expect.extend is implemented (#8525) 2024-01-27 20:39:46 -08:00
Dylan Conway
5a0ae3c256 not on windows 2024-01-27 07:32:06 -08:00
Dylan Conway
568f87eb8f fix(windows): bun link, unlink, and fix tests in test/cli/install (#8517)
* link and unlink

* valid git dependency cache path

* windows global link

* not git

* update some tests

* update more tests

* update

* update log

* fix snapshots

* more tests

* fix bun pm ls

* make it possible to delete cache dir

* normalize

* fix bun-create tests

* update bun-remove tests

* silent

* bun-run update

* update more tests

* update more

* update

* [autofix.ci] apply automated fixes

* update simdutf for getFdPath

* update test

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-27 04:22:04 -08:00
dave caruso
968c21d80a feat(windows): support bun build --compile (#8503)
* alright

* were winning

* WAOOOOOO
2024-01-26 20:56:08 -08:00
dave caruso
6faeef6dc2 Workaround https://github.com/microsoft/terminal/issues/16606 (#8506)
Fixes #8504
2024-01-26 20:55:48 -08:00
Georgijs
08c9511acc [windows] nodefs (#8509)
* 100 passing fs tests

* 111 fs tests passing

* 114 passing fs tests

* 115 passing (TODO: fix path normalization for windows ntCreateFile

* all fs tests passing

* [autofix.ci] apply automated fixes

* make windows path norm smarter, fix tests

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-26 20:07:33 -08:00
Meghan Denny
1644f341f9 windows: setInterval.test.js is passing now (#8508) 2024-01-26 14:11:03 -08:00
nullun
17fc1e7be1 chore: Remove trailing whitespace (#8502) 2024-01-26 07:25:45 -08:00
Jarred Sumner
7492b3a203 [windows] Remove no longer failing tests from being marked as failing 2024-01-25 21:59:11 -08:00
Jarred Sumner
681baedab2 Track hasInstallScript and libc in NPM registry api (#8495)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-25 20:38:20 -08:00
Jarred Sumner
c7c3ae381b Make this test less flaky on Windows 2024-01-25 20:37:41 -08:00
Jarred Sumner
7543da0bb3 Always normalize the carriage returns in the bundler tests 2024-01-25 20:27:58 -08:00
dave caruso
83ac4f0c33 windows: fix bun plugin (#8485)
* plugins work now

* real

* Update src/js/builtins/BundlerPlugin.ts

* [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-01-25 19:34:51 -08:00
Jarred Sumner
3c42dfd42b [internal] Tweak jsonc formatting 2024-01-25 19:19:32 -08:00
Jarred Sumner
e3188c918a use Biome to format Bun's codebase instead of Prettier (#8494)
* Ignore

* Create biome.json

* Ignore

* biome

* [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-01-25 19:15:26 -08:00
Jarred Sumner
045672cf67 Force \n instead of \r\n on Windows CI 2024-01-25 19:05:47 -08:00
Dale Seo
345ed18454 fix: mock() should work with no arguments (#8492) 2024-01-25 17:06:36 -08:00
Jarred Sumner
5462ca01fd Typo 2024-01-25 16:33:07 -08:00
Jarred Sumner
4bfd8a8cef Make this test less flaky on Windows 2024-01-25 16:30:25 -08:00
Jarred Sumner
a2a12b5802 Make this test less flaky on Windows 2024-01-25 15:09:32 -08:00
Jarred Sumner
b6c1dc1fa8 Use native AbortController & AbortSignal when abort-controller is loaded (#8489)
* Nationalize `abort-controller`

* [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-01-25 15:01:29 -08:00
Jarred Sumner
f4f8bb377a Make this test less flaky on Windows 2024-01-25 14:53:20 -08:00
Jarred Sumner
5c21695db6 Bump + ci autofix (#8490)
* Bump

* [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-01-25 13:58:59 -08:00
Adam Dimitry Enzo Ambrosino
2c16b204ff Fix type definition for Array.fromAsync (#8486) 2024-01-25 10:32:47 -07:00
dave caruso
20f7fd5b08 fix(windows): do not use GetTempPath2W (#8477) 2024-01-25 08:13:36 -08:00
dave caruso
c9a7d24538 windows(install): add bun_shim (support bin linking, bin shebangs, etc) (#8265)
* shim v1 TODO

* fix BunXShimData

* wip

* put a little bit of the sa u c e on it

* wow

* wat

* a

* swag

* swag

* allllllllllllright

* Update src/install/bin.zig

Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>

* [autofix.ci] apply automated fixes

* swag

* swag

* finis

* fix submodules

* ok

* omg it works again

* silly

* ok

* OK

* update laucnh jsn

* swaaaaaaaaaaaaag

* remove debug

---------

Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-25 07:38:55 -08:00
Jarred Sumner
108cae5189 Disable dead code elimination when code coverage is enabled (#8473)
This should hopefully make source mappings more accurate

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-25 05:31:44 -08:00
dave caruso
358be9e727 docs: update the windows build documentation and list it on the docs site 2024-01-25 04:15:41 -08:00
Jarred Sumner
2a6388d50b Silence log when ENOTCONN
When using sendfile() to stream, if the user aborted the request it may appear as `ENOTCONN`, which we were logging to the terminal. We really shouldn't be logging anything here, but it's a little unclear what kind of error to emit. It's not a fatal error.
2024-01-25 01:03:29 -08:00
Jarred Sumner
aa901a22c2 Update types.zig 2024-01-24 23:11:58 -08:00
Jarred Sumner
562495b878 [windows] Mark as known failing 2024-01-24 23:11:55 -08:00
Jarred Sumner
875728da83 [windows] Make more things panic 2024-01-24 22:47:40 -08:00
Jarred Sumner
47e7e004b1 Remove @known-failing-on-windows for tests which are no longer failing on windows 2024-01-24 21:03:32 -08:00
Georgijs
80bd3254cc fix argv parsing on windows (#8458)
* fix argv parsing on windows

* directly use zig stdlib

* remove debug comments, fix double deinit

* change bun.argv() to return slices, not null-terminated pointers

* fix test on windows to escape file paths correctly

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-24 20:54:01 -08:00
Jonathan Deiss
0bf8a25d50 Clarifies bun shebang in bunx documentation (#8437)
* Update bunx.md

* better phrasing of shebang
2024-01-24 19:59:56 -08:00
Meghan Denny
effb8f189b windows: fix some websocket tests (#8433)
* windows: fix some websocket tests

* this file should work now, report any errors

* make this change later

* add back running this with node

* add as const to these

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-24 19:40:59 -08:00
Johann
7eeefc1497 chore(password): fix sha256 typo (#8461) 2024-01-24 19:27:29 -08:00
Georgijs
025a5ba140 fix sys.dup on windows and make console-iterator work (#8463)
* fix sys.dup on windows and make console-iterator work

* fix(windows): fix console async iterator to not include the \r

* fix kill on windows again. and report the right errno

---------

Co-authored-by: dave caruso <me@paperdave.net>
2024-01-24 19:25:45 -08:00
Ashcon Partovi
885d705d55 Fix bun-types version being incorrect 2024-01-24 15:21:10 -07:00
dave caruso
3447bc2ed3 fixy 2024-01-24 03:16:23 -08:00
Jarred Sumner
f1f861fd74 [windows] Fix panic in server 2024-01-24 02:20:29 -08:00
dave caruso
58ba802ca6 ci(windows): install the profile build 2024-01-24 02:12:16 -08:00
Zachary Huang
73f3b92dc9 fix(ci): fix MacOS build when OpenSSL is also installed (#7759)
Co-authored-by: dave caruso <me@paperdave.net>
2024-01-24 01:44:04 -08:00
dave caruso
eeb10f3f7d fix(windows): fix node:url pathFromFileURL and fileURLFromPath and file url tests (#8442)
* yay for file urls

* swag

* oops

* merge conf

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-24 01:19:47 -08:00
dave caruso
8544f8ae68 ci(windows): debug info in the binaries + ship a version on github (#8443)
* debug info yaaaaaaaaaaaaaaaaaay

* fix the build
2024-01-24 01:16:17 -08:00
Jarred Sumner
9f5ce53544 Normalize another newline 2024-01-23 23:44:38 -08:00
Jarred Sumner
82b6a42a3c Normalize more paths 2024-01-23 20:48:48 -08:00
Jarred Sumner
0974479655 Normalize slashes 2024-01-23 20:47:37 -08:00
Jarred Sumner
918e1878a5 Normalize newlines 2024-01-23 20:45:37 -08:00
Jarred Sumner
17deafd05f Add TypeScript issue template 2024-01-23 20:39:08 -08:00
Dylan Conway
b7ae984ca1 fix(windows): update some bundler tests (#8440)
* replace invalid path character

* windows paths
2024-01-23 20:23:01 -08:00
Jarred Sumner
e848c3f226 Get Bun.write tests to pass on Windows and bun:sqlite tests to pass (#8393)
* Move ReadFile and WriteFile to separate file

* Use libuv for Bun.write()

* Update windows_event_loop.zig

* build

* Get bun-write tests to pass. Implement Bun.write with two files.

* UPdate

* Update

* Update failing test list

* update

* More

* More

* More

* More

* Mark the rest

* ok

* oops

* Update bun-write.test.js

* Update blob.zig

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Dave Caruso <me@paperdave.net>
Co-authored-by: Georgijs Vilums <georgijs.vilums@gmail.com>
2024-01-23 20:03:56 -08:00
Dylan Conway
cd3de9c788 fix(windows): fix text-decoder.test.js (#8436)
* use with_errors

* remove comment

* use correct index
2024-01-23 19:28:54 -08:00
dave caruso
945ad77bce window: fix runtime.js build process (#8438)
Co-authored-by: Georgijs Vilums <georgijs.vilums@gmail.com>
2024-01-23 19:27:57 -08:00
Chen Yufei
04a99deb0e copy_file: ioctl_ficlone EACCES, EPERM as not supported. (#8425)
ioctl_ficlone may return EPERM (in LXC container), EACCESS (in Android).
Those error should be taken as ficlone being not supported instead of
error.

Refer to this coreutils bug report https://bugs.gnu.org/62404
2024-01-23 18:24:54 -08:00
Ciro Spaciari
cff5dc0ee8 fix close on spawn and watch (#8426)
* fix close on spawn and watch

* add check closed, and fixes

* fix subprocess close
2024-01-23 18:09:13 -08:00
Dylan Conway
77ccf77e35 Revert "Revert "fix(windows): a bunch of install test fixes"" (#8431)
* keep cache dir path, use correct buffer

* make it work more better

* more working

* more fix

* more update

* more fix

* fix test

* update

* fix

* update pointers

---------

Co-authored-by: dave caruso <me@paperdave.net>
2024-01-23 18:00:18 -08:00
DidaS
864a726249 Improve bun-types (#8195) 2024-01-23 13:51:45 -07:00
Jarred Sumner
1407683f95 Revert "fix(windows): a bunch of install test fixes" (#8408) 2024-01-23 06:38:13 -08:00
dave caruso
1f928e9b6e goddamn (#8405) 2024-01-23 06:37:14 -08:00
Dylan Conway
e0cf77c660 fix(windows): a bunch of install test fixes (#8402)
* keep cache dir path, use correct buffer

* make it work more better

* more working

* more fix

* more update

* more fix

* fix test

* update tests

* comment and fix test

* one more fix

* fix build

---------

Co-authored-by: dave caruso <me@paperdave.net>
2024-01-23 06:36:53 -08:00
dave caruso
07a685bd3d feat(windows): implement the rest of node:os (#8399)
* feat(windows): implement os.networkInterfaces

* we are cooking (os tests almost pass)

* os

* fix version struct

* oops

* [autofix.ci] apply automated fixes

* fix the submodules

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-23 05:06:51 -08:00
dave caruso
80ad8d57f2 windows: fix a path resolution case (#8392)
* fix resolving certain filepaths

* extra

* swag

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-22 21:53:34 -08:00
Jarred Sumner
41b45599c6 Delete some dead code (#8391)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-22 21:06:13 -08:00
Ciro Spaciari
416e896c63 [windows] Implement fs.watch on Windows (#8379)
* implement fs watch

* fix unref

* fixes

* actually use bun.New

* fix destroy, use another buffer for joinPath, remove Win prefix

* oopsie
2024-01-22 20:29:46 -08:00
Dylan Conway
2d1e0dc240 trim correctly (#8388)
Co-authored-by: dave caruso <me@paperdave.net>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-22 19:57:20 -08:00
Meghan Denny
c52e7c57d2 add another launch config for windows bun test (#8389) 2024-01-22 19:45:39 -08:00
Georgijs
c4a60f9059 fix to enqueue bundler tasks in correct event loop (#8386)
* fix to enqueue bundler tasks in correct event loop

* fix posix build

---------

Co-authored-by: Georgijs Vilums <georgijs@bun.sh>
2024-01-22 19:45:24 -08:00
Dale Seo
15fe30ac41 docs: remove unncessary use of async in bun test examples (#8341) 2024-01-22 17:57:02 -08:00
Dale Seo
a014f1c566 docs: correct imports (#8380) 2024-01-22 17:14:55 -08:00
Jarred Sumner
73b0b35a42 Make the dev-server test more reliable 2024-01-22 17:09:47 -08:00
Georgijs
75524d0ae3 Fix eqlComptimeCheckLenWithKnownType (#8377)
* fix some env tests

* fix and simplify comptime string equality

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-22 16:41:30 -08:00
John-David Dalton
c21dc25a65 Change type for expect().toThrow(unknown) (#8373) 2024-01-22 13:27:25 -07:00
Georgijs Vilums
3bc0f90a7c skip invalid stringWidth test 2024-01-22 12:25:49 -08:00
Jarred Sumner
eaa1cd5553 Add shell-spawn microbenchmark 2024-01-22 03:23:47 -08:00
Jarred Sumner
6019665d4b Fixes #8276 (#8346)
* Fixes #8276

* [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-01-21 20:25:00 -08:00
Jarred Sumner
b7b0e28b10 Rename bun.zig to BunObject.zig (#8344)
* Rename `bun.zig` to `BunObject.zig`

* Rename `bun.classes.ts` to `BunObject.classes.ts`

* Update references to `bun.zig`

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-21 19:55:24 -08:00
moznion
c577c64aa7 docs: add description how to parse the CLI ARGV by the built-in parseArg (#8345)
Signed-off-by: moznion <moznion@mail.moznion.net>
2024-01-21 19:54:49 -08:00
Jarred Sumner
1560a866fe Skip stringWidth tests for now 2024-01-21 19:25:57 -08:00
Dale Seo
5b9e1e5708 docs: fix a typo (#8338) 2024-01-21 17:17:55 -08:00
Jarred Sumner
353f724a9c Update bun.d.ts 2024-01-21 06:11:49 -08:00
Jarred Sumner
a8ff7be642 Disable Bun.stringWidth until failing test case passes 2024-01-21 06:10:07 -08:00
Jarred Sumner
af67ee77a0 Bump 2024-01-21 04:48:55 -08:00
Jarred Sumner
b82656d9fc Introduce Bun.stringWidth (#8327)
* Introduce `Bun.stringWidth`

* [autofix.ci] apply automated fixes

* Update utils.md

---------

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-01-21 04:47:36 -08:00
Jarred Sumner
7b9201a0fc Fixup 2024-01-21 04:23:18 -08:00
Jarred Sumner
627d60c6c7 Fix crash in fs.readFile
We were default-initializing the vm pointer to undefined
2024-01-21 04:19:33 -08:00
Jarred Sumner
c00f0787f0 [types][bun:sqlite] Make SQLiteError a class instead of an interface 2024-01-21 03:57:38 -08:00
Jarred Sumner
3ca0fcb67a [node:vm] Add missing createScript function 2024-01-21 03:57:17 -08:00
Jarred Sumner
43107f48fa Add onLongTimeout callback for WebSocket (#8323)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-21 03:49:28 -08:00
Dylan Conway
b1273e53d8 windows(install): fix linking workspaces and file: dependencies (#8289)
* install workspaces with junctions

* fix #8272

* symlink auto type

* fix file: dependencies

* a better fix

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-20 23:00:29 -08:00
Jarred Sumner
10e57fdc1e windows pipes (#8230)
* spawn sync investigation, pipe closed before uv_read_start is called

* oopsie

* win rusage

* oopsie

* Fix some things

* readable stream now works without FIFO like solution

* blob, ArrayBuffer, Buffer stdin now works

* remove unused

* add UVStreamSink

* update headers.j

* more bindings

* now works yay

* fix rusage on windows

* oops

* fix rare data

* win getUserName

* [autofix.ci] apply automated fixes

* fix build

* oopsie

* fix linux/macos

* exit code fix

* fix kill for win

* disable Bun__crashReportDumpStackTrace on Windows

* remove windows stack dump in report.zig and increase windows test timeout

* condition instead of assertion

* remove IPC again

* fix blob writer when not using TTY

* bump windows tests time again

* bump time again so we see how much we need (this is probably too much)

---------

Co-authored-by: cirospaciari <ciro.spaciai@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: cirospaciari <ciro.spaciari@gmail.com>
2024-01-20 22:58:01 -08:00
Bjön Limell
fad3db84f0 (docs) Fixed color in node compat (#8299)
`node:module` was green, when it should be yellow.
2024-01-20 22:54:30 -08:00
Dylan Conway
fccab2f0da fix(node:child_process): fix crash with ipc (#8319)
* make sure `onLongTimeout` doesn't happen

* add `onLongTimeout` handler
2024-01-20 22:53:16 -08:00
Dylan Conway
885f9372f4 fix(transpiler): loose equality folding bugfix (#8317)
* fix #8311

* fix `bigint` comparison

* cleanup

* couple tests

* fix `"-0" == 0`

* Update transpiler.test.js

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-20 22:52:53 -08:00
Hanaasagi
509a2c5a69 fix: fix the invalid free pointer in toStringWithBytes. (#8322)
Close: #8264
2024-01-20 22:26:58 -08:00
Meghan Denny
b433beb016 8096 isnt 8kb, 8192 is (#8296)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-19 23:16:11 -08:00
Dylan Conway
c71bad205c Update shell.md 2024-01-19 22:15:23 -08:00
Dylan Conway
d4794bbac8 Update shell.md 2024-01-19 20:05:22 -08:00
Dylan Conway
6fa35839c3 remove .only, update shell.md 2024-01-19 19:59:06 -08:00
Jarred Sumner
35d551c174 Fix passing undefined to $().cwd() and $().env() 2024-01-19 19:55:26 -08:00
Jarred Sumner
4674ee16a1 Simplify $.escape 2024-01-19 19:55:26 -08:00
Jarred Sumner
ce2ef65122 Small docs tweaks for shell 2024-01-19 19:55:26 -08:00
Dylan Conway
0d88dcb0fa Update shell.md 2024-01-19 19:21:26 -08:00
Jarred Sumner
15f727dc2f Update shell.md 2024-01-19 19:05:54 -08:00
Jarred Sumner
dcfec52b11 Update nav.ts 2024-01-19 18:55:29 -08:00
Meghan Denny
7ca4ca8972 copy_file: this TODO is no longer a compiler bug (#8294)
* copy_file: this TODO is no longer a compiler bug

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-19 18:45:59 -08:00
Dylan Conway
76ed8d8086 fix(install): remove invalid bin symlinks (#8293)
* handle invalid bin symlink

* test
2024-01-19 18:37:03 -08:00
Jarred Sumner
1f126cd91a Fix benchmark in node 2024-01-19 18:36:00 -08:00
Jarred Sumner
5e520884cd Add to docs 2024-01-19 18:35:46 -08:00
Max Milton
1c5b318207 feat: Carry over node isIPv4/isIPv6 performance improvements (#8271)
Copy over the `isIPv4`/`isIPv6` performance improvements from
<https://github.com/nodejs/node/pull/49568>.
2024-01-19 17:31:52 -08:00
Zack Radisic
1b1760a9c9 feat: Bun shell (#7748)
* bring in shell impl

* add `$` to global bun scope

* Expose shell parse func on debug mode

* Expose lex tokens and add tests

* refactor parser to have better ast

* assigns and export

* pipeline kinda working

* Decouple Subprocess spawning code from JS stuff

* Subprocess works!

* Conditional execution

* Support JS objects in template expression

* More complete redirection

* Properly drain stdin/stdout/stderr and fix crash from deallocating JSC memory

* Return errors in parser

* Support command substitution

* wip brace expansion stuff

* Rearrange some files

* expansion wip

* Brace expansion working

* wip brace expansion

* refactor brace algorithm

* wip brace expansion on shell

* fix brace expansion

* Working nested brace expansion!

* brace expansion in shell variable assignment only set the last expanded

* stuff

* Small little perf things

* benchmark and test and stuff

* stuff

* fix nested braces but its also kinda broken

* attempt to fix complicated nested braces

* test

* Use fast tokenized algorithm for non nested braces, use parsed algorithm for nested braces

* fix nested braces one and for all

* small stuff

* Not sure if that made a difference

* revert that

* good speed optimization

* rip

* Environment variables, builtin/native shell cmds

* Fix tests

* Support `cd`, `pwd`, add boilerplate for glob expansion

* Support `which`

* Support `rm`

* wip

* wip

* escaping and abstract shell char iterator

* strpool unicode

* Brace expansion support unicode, disallow invalid surrogates in shell script

* shell choose ascii or unicode lexer depending on input

* fix bugs write tests

* kinda start async stuff

* HOLY SHIT big refactor of Subprocess

woops forget to commit this

...and this

* HOLY MOLY it works

* Refactor some stuff, start eval word expansion

* interpret all the nodes

* stuff

* stuff

* stuff

* kind of works but doesnt

* Buffered output works

* no need to heap allocate autosizer

* Fix bug

* Fix some stuff

* unprotect

* move out dummy shell thing

* Bring back assignments

* create expansion state so it can be non blocking for expansions that need IO (glob, cmd subst)

* glob back in action

* Setup builtin non blocking IO commands and implement export

big issue is control flow is really fcked up here need to fix that

* make Cmd state machine use a loop so control flow is a bit more clear

* rename stuff

* move that

* Implement the echo builtin again

* implement cd again but non blocking io

* Fix ls and use proper write function to prevent blockign writes

* Implement which

* holy moly big port std.fs.deleteTree

* fix compile errors

* Okay that works

* rm works thatsnice

* damn

* split it out

* rm async implementation

* fix rm bug for nested

* Work on files as well

* prevent root from being deleted

* rm error handling

* oops

* pwd and fix some script exec bug

* Implement `mv`

* stub out mv to work accross filesystems

* move it around

* woops

* boilerplate for ls and options

* more boilerplate

* stuff

* that got lost in merge

* upgrade shell stuff zig 0.12.0-dev.1828+225fe6ddb

* Implement basic ls

* smol cleanup

* Fix stream, response redirect stdin

* No longer need spawn to be abstract

* Custom promise

* move around some stuff

* shell promise returns shell output

* make tht work for builtins

* refactor IO abstractions to work with JS or mini event loop

* woops

* scaffolding for refactor

* refactor builtins to make event loop refactor easier

* Fix parsing edge case on assignments, fix expansion on cmd assignments

* change subproc to work with any event loop

* Finish refactoring subproc

* move global abstraction out

* big refactor boys

* holy moly: integrate into cli and fix allll the compile errors

* okay works in bun run now

* actually tick the event loop lol

* Fix more stuff

* Support comments

* Fix some tests

* delete that

* Properly report errors when failing to spawn command

* fix a whole bunch of tests

* fix a whole bunch of tests again

* .

* Fix rm

* Fix some exit code bugs, write force rm from deno, fix ls stderr

* fix `rm -d`

* fix `rm -d`

* Fix boolean logic

* error on subshells (e.g. `true && (echo hi && echo lol)`)

* Move out shell state from interpreter struct

* Cmd substitution supports arbitrary script, not just a single cmd

* Some escaping/quotation tests

* Fix stuff add more tests:

- cmd substitution quotations
- escape backticks in single quots

* ALOT of stuff:

- fix proper subshell inheritance of env for cmd subst
- fix: was wrong, assignments don't run in subshell in conditionals
- fix lexing chained vars `$VAR$VAR`
- more tests

* Fix subtle bugs

* Fix crazy redirect to arraybuffer bug

* more crazy echo edgecases

* Proper lexer errors instead of just panicking lol

* yoops

* Proper parsing errors

* Errors for bun run shell script

* Fix redirecting to file

* More test fix bugs yay

* Fix redirect on builtins

* Open redirection fds with O_TRUNC

* Fix lexing invalid variables and add ability to change cwd from JS api

* yoops

* Fix `.cwd()`

* `$PWD` and fix redirection bugs

* `$PWD` and fix redirection bugs

* Get rid of  some `FIXME`s

* throw errors in some places instead of panicking

* Print some errors to stderr

* Get rid of some more panics again

* Handle errors on glob

* pwd test

* `.env()`

* copy-on-write abstraction

* Reference counted env strings + fix some tests

* deinit cwd

* Put commands into a pipeline properly

* deinit Expansion and Assigns properly

* comments

* Comments

* Make it compile

* Update types

* [autofix.ci] apply automated fixes

* Only one WaiterThread

* Fix lifetimes and clean up interface

* Update shell.ts

* Add lazy test

* Remove some dead code

* Update shell.zig

* Fix memory leak

* Fix crash with empty braces

* [autofix.ci] apply automated fixes

* Linux build + bun.sh

* Update subproc.zig

* Update interpreter.zig

* Update interpreter.zig

* Fix some stuff that broke

* Fix Windows compile errors

* Fix some fd leaks

* Fix ls

* Fix a bunch of stuff

* Fix quiet

* Update leak tests fix rm bug

* More reproducible tests

* [autofix.ci] apply automated fixes

* more mem leak tests

* [autofix.ci] apply automated fixes

* Fix merge conflict

* Fix test not actually using temp directory

* Update bunshell.test.ts

* Shell instance

* Capture async context

* Increase test timeouts

* [autofix.ci] apply automated fixes

* Escape

* [autofix.ci] apply automated fixes

* Fix crash

* Add more methods

* [autofix.ci] apply automated fixes

* Fix leak

* Treat file(path) blobs as a file path string

* Create bunshell-file.test.ts

* Support Blob input

* Fix leak + organize imports

* doc

* Update shell.md

* Update shell.md

* Update shell.md

* Update shell.md

* Update CMakeLists.txt

* Fix segfault by cloning error path so it's not freed by arena

* deinit ShellErr

* Delete dead code

* fix really stupid segfault

* don't deinit shell ls task in event loop

* Fix ls bug

* Fix tests

* make truly lazy

* allow more things in the shell substitution and escape whitespace

* Fix newline and exit when finishing shell in `bun run`

---------

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-01-19 17:30:57 -08:00
Lukas Kastern
751ff68268 feat: Add async support to Bun.serve onError (#8233)
* WIP

* Support not immediately fullfilled promises

* Typo

* Add tests

* Fix test

* Rename test

* Remove file

* [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-01-19 16:01:09 -03:00
Jarred Sumner
3c785c88fb Fix issue with perf_hooks in canary (#8279)
* Update perf_hooks.ts

* Update perf_hooks.test.ts

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-19 05:22:06 -08:00
Dylan Conway
8efa01bd62 fix(bun:test): toContain and toContainEqual string fix (#8270)
* update toContain, toContainEqual, and tests

* fix build, use cursor

* `strings.indexOf` and `jsType` once
2024-01-18 20:13:57 -08:00
Ashcon Partovi
e17709a2d3 Fix bun --inspect with fully-qualified URL (#8267) 2024-01-18 18:32:51 -08:00
Alexandre Seo
c50400e186 Fix bug in string handling in toContain and return undefined in all matchers (#7692)
Co-authored-by: dave caruso <me@paperdave.net>
Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
Co-authored-by: John-David Dalton <john.david.dalton@gmail.com>
2024-01-18 14:14:16 -08:00
guest271314
ff965af067 Update comment to include "except a built-in" (#8251)
build.module() throws for "buffer"

 9 |   setup(build) {
10 |     build.module(
         ^
error: module() cannot be used to override builtin module "buffer"
2024-01-18 03:29:10 -08:00
Jarred Sumner
48d642e9e0 Add a note about timeouts and max payload size 2024-01-18 03:14:03 -08:00
Jarred Sumner
e197b7c3a0 Fix crash in socket (#8241)
* Fix crash in socket

* Fix Socket timeout issue

* Add test for socket timeout

* Update socket.test.ts

* Fix linux tests

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-18 02:19:58 -08:00
Jarred Sumner
95e466628b Add a note about reading directories 2024-01-17 22:16:34 -08:00
dave caruso
41dda11802 fix: upgrade_command compilation error 2024-01-17 22:08:02 -08:00
dave caruso
8ba332b43a fix(windows): Implement bun.sys.renameat on Windows and fix crash during bun upgrade (#8242)
* fix #7989

* doc

* oops
2024-01-17 22:01:53 -08:00
Michael H
52894121ea bun run: "package.json scripts" at bottom (#8224)
* `bun run`: put "package.json" scripts at bottom & better errors

* [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-01-17 18:18:40 -08:00
Jarred Sumner
a5e83189df Stub more of perf_hooks (#8239)
* Stub more of perf_hooks

* Update perf_hooks.ts

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-17 17:41:47 -08:00
dave caruso
405e2d1517 windows: implement os.hostname (#8223)
* windows: implement os.hostname

* oops

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-17 17:33:02 -08:00
Meghan Denny
483b73c4bf absorb bun.fdcast into FileDescriptor and remove (#8240) 2024-01-17 17:32:03 -08:00
Cena Kopahi
cb97baed22 Update docs for @types/bun (#8160)
Co-authored-by: Ashcon Partovi <ashcon@partovi.net>
2024-01-16 23:26:50 -07:00
Jarred Sumner
01df0e6ef0 Fix prettier 2024-01-16 20:20:30 -08:00
dave caruso
08aa40c570 fix windows CI (use -MD again) (#8220)
* chore: upgrade webkit again

* fix submodules
2024-01-16 19:26:32 -08:00
dave caruso
82fcb38005 fix(windows): support utf16-le files in the bundler and in Bun.file (#8219)
* support utf16-le files

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-16 17:15:16 -08:00
Jarred Sumner
fc80683256 In fs.ReadStream, use $isObject to check options (#8218)
* In fs.ReadStream, use `$isObject` to check if function or object rather than typeof options === "object"

* Update fs.js

* Add test

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-16 16:41:24 -08:00
Jarred Sumner
54be1d7705 Fix decimal -> integer conversion bug in process.exit & process.exitCode (#8216)
* Fix process.exit to allow numbers which were previously decimals

* [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-01-16 16:19:33 -08:00
Emre Cakiroglu
7eed9d893e fix: handle encoding deconstruction in node:fs (#8212) 2024-01-16 15:56:02 -08:00
Yusup Hambali
e77f9036e0 Fix title in dataview-to-string guide (#8209) 2024-01-16 15:27:38 -08:00
Lukas Kastern
5a6ef045aa fix: Hang when recursively logging via ConsoleObject.messageWithTypeAndLevel (#8213)
* Avoid deadlock in messageWithTypeAndLevel by adding a recursion counter

* Add test for recursive logs

* Do not rely on output of console-recursive.test.js

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-16 15:26:23 -08:00
Aarav Juneja
9350f6bc0b fix: match node's path.parse on dotfiles. (#8142)
* Fix #8090

* Fix bug from modification order.
2024-01-16 14:12:18 -08:00
dave caruso
4ccf6fb284 chore: fix building mimalloc debug with valgrind support (#8199)
* fix valgrind mimalloc

* thens
2024-01-16 00:06:10 -08:00
Jarred Sumner
83f2432da6 Update prettier (#8198)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-15 23:47:13 -08:00
Jarred Sumner
f673a84c75 Update nodejs-apis.md 2024-01-15 23:46:12 -08:00
Jarred Sumner
51680dbfdc Update nodejs-apis.md 2024-01-15 23:45:10 -08:00
Jarred Sumner
1aa36e27cb Update nodejs-apis.md 2024-01-15 23:44:09 -08:00
Jarred Sumner
e6285a1cc8 Update nodejs-apis.md 2024-01-15 23:43:52 -08:00
Meghan Denny
a064ae71ad make node:fs/promises.open return a FileHandle and expose fdatasync (#8141)
* make node:fs/promises.open return a FileHandle and expose fdatasync

* node_fs: add fn spacing

* fix this assert usage too

* move primordial preservation higher

* use expect().toBe() instead of assert

* ensure top level node:fs/promises functions always receive fd's as a number

* add needed fixture

* [autofix.ci] apply automated fixes

* this was the wrong fix for a different thing
will look into it later

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-15 23:20:20 -08:00
dave caruso
f9e78c419f feat: Implement using keyword (explicit resource management) (#8151)
* port 'initial support for using declarations'

1:1 port of this commit:

56a3e01244

* port 'initial support for await using declarations'

1:1 port of this commit:
1634a0b5ad

* fix cmake config for local jsc

* add global defines for symbols

* begin porting lowering implementation

based off of
https://github.com/evanw/esbuild/pull/3192

* [autofix.ci] apply automated fixes

* add some fun webkit scripts

* fix the minification bug

* refactor runtime_js, etc

* rename test file

* finished yapping

* silly silyl

* Update src/bundler.zig

* ok

* a

* Fix crash

---------

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: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-15 23:14:41 -08:00
Jarred Sumner
0fb864e0ca Bump WebKit 2024-01-15 20:28:05 -08:00
Jarred Sumner
a4da0acb0e Document additions to import.meta 2024-01-15 19:53:49 -08:00
Jarred Sumner
f47def8515 Update run_command.zig 2024-01-15 19:50:05 -08:00
Jarred Sumner
14398ae27e Upgrade to Node.js v21.6.0 2024-01-15 19:50:05 -08:00
Jarred Sumner
64d351b102 Upgrade to SQLite v3.45.0 (#8196)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-15 19:45:14 -08:00
Meghan Denny
6b577a3970 implement events.on (#8190)
* exit event loop if there's unhandled errors

* move FixedQueue to a special package

* require(events) is also EventEmitter

* implement events.on

* move fixed_queue to internal and make it lazy in node:events

* use better Promise intrinsics

* move $shared to internal/shared

* make test not dependent on cwd
2024-01-15 18:54:37 -08:00
Lukas Kastern
a159850cce fix: Bun.serve logging error when fetch returns rejected promise (#8169)
* Handle rejected promise returned from onResponse

* Add test

* [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-01-15 18:26:08 -08:00
Jarred Sumner
87eedc29d5 Move the standalone executable page 2024-01-15 18:13:28 -08:00
Lukas Kastern
124392ee98 fix: Report error and close event when creating WebSocket fails (#8186)
* Defer websocket error/close when websocket client is null

* Rename test

* [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-01-15 18:08:34 -08:00
Jarred Sumner
e5421c56b1 feat: Support import db from './my.db' with {type: "sqlite"} (#8178)
* Support SQLite imports

* Docs

* Update executables.md

* Update loaders.md

* Update js_parser.zig

* Update loaders.md

* Update CMakeLists.txt

* Update Module.ts

* JSC got rid of `$trunc`?

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-15 17:56:02 -08:00
Lukas Kastern
407f42718c Only integrate loop us_loop once (#8187) 2024-01-15 17:37:21 -08:00
Jarred Sumner
a36355cefb Some Windows tweaks (#8118)
* Some windows tweaks

* Make this pub

* Update bundle_v2.zig

* Fix woopsie

* Make this error better

* Add assertion for using allocator for HTTP client from another thread.

* Do fewer copies in readdir()

* Fix crash/failing tests

* Update tests

* Fix windows build

* Update loop.c

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-15 17:33:33 -08:00
Ashcon Partovi
2d21567271 Update debugger things (#8180)
* T

* Update Debug Adapter Protocol

* Update JSC and V8 debugger protocols

* Update inspector-frontend

* Fix empty keys not being printed in `console.log`

* Add `bun --inspect` tests and fix edge cases

* bun install --exact
2024-01-15 17:00:29 -08:00
Jarred Sumner
611b296a6a Fixes #8170 2024-01-14 21:01:51 -08:00
Jarred Sumner
317998fdd6 Make toBunString increment the reference count (#8146)
* Make `toBunString` increment the reference count

* Fix WASI

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-14 05:36:31 -08:00
Jarred Sumner
ab40b0e054 Fix file descriptor leak in ipc (#8165)
* Fix file descriptor leak in ipc

* Do not assume sequential file descriptors

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-14 02:57:44 -08:00
Jarred Sumner
2c3dc5176b Upgrade uWebSockets & usockets (#8164)
* Upgrade uWebSockets & usockets

* Update HttpRouter.h

* Defensively prevent sending to blocking sockets

* Add test for receiving large amounts of data

* Large data optimization

* Update loop.c

* Avoid extra system call before entering event loop

* Update internal.h

* 1 less pointer lookup

* Fix error

* Update socket-huge-fixture.js

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-14 02:04:30 -08:00
dave caruso
5fc4538477 windows: support bun:ffi (#8114)
* compile tcc

* initial linking

* ffi and stuff

* swag

* wala

* Update settings.json

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-13 19:14:29 -08:00
Meghan Denny
be0896e204 remove while loops where a for would be more efficient (#8131)
* remove while loops where a for would be more efficient

* this needs to be a stack copy

* this can use the better loop

* this was translated wrong

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-13 19:13:54 -08:00
Jarred Sumner
56f1e5a362 Hide some noisy stack frames (#8148)
* Hide some noisy stack frames

* Update javascript.zig

* Add `asyncModuleEvaluation` to the list

* Sort

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-13 19:11:01 -08:00
Jarred Sumner
702da52312 Fix rawMode regression (#8163)
* Fix rawMode regression

* arg0

* Update ProcessBindingTTYWrap.cpp

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-13 19:10:33 -08:00
Jarred Sumner
2a8956a268 Use one isosubspace for all generated constructors (#8162)
* Use one Isosubspace for constructors

* Update generate-classes.ts

* Update generate-classes.ts

* Update generate-classes.ts

* Update generate-classes.ts

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-13 18:50:09 -08:00
Jarred Sumner
86b1aa02b3 Update CMakeLists.txt 2024-01-13 00:57:45 -08:00
Meghan Denny
065eae5a95 tidy: use std.mem.zeroes instead of loop or memset (#8138)
* use std.mem.zeroes instead of loop or memset

* Update src/bun.js/api/bun.zig

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-12 23:56:51 -08:00
Meghan Denny
9fa13aec09 fix signalNumberToNameMap assignment for SIGINFO (#8132) 2024-01-12 23:53:35 -08:00
Jarred Sumner
3e703c4c76 For build scripts, symlink zig.exe to zig on posix (#8147)
* Add `zig.exe` as a symlink of `zig` on posix

* Update scripts/download-zig.sh

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

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: dave caruso <me@paperdave.net>
2024-01-12 23:52:07 -08:00
Jarred Sumner
01453be2d1 Move function from a header to a .cpp file 2024-01-12 23:48:14 -08:00
Jarred Sumner
9b32516bcb Implement tty_wrap in process.binding (#8130)
* Implement `tty_wrap` in process.binding

Fixes #4694

* [autofix.ci] apply automated fixes

* Rename some things

---------

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-01-12 23:31:18 -08:00
Jarred Sumner
7e787d2a5a Move console methods from exports.zig to ConsoleObject.zig (#8145)
* ZigConsoleClient -> ConsoleObject

* Rename more

* Rename more

* ZigConsoleClientFormatter -> ConsoleObject

* More renaming

* Wire up console.profile?

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-12 23:15:36 -08:00
dave caruso
b7a32b87ab fix(bundler): improve external require transpilation on all targets (#8057)
* fix(build): do not emit import.meta.require for browsers/node.js

* update test snapshots

* sweep

* prefer require ref instead of `import.meta.require`

* remove option i did not use

* stuff

* remove rewrite_require_resolve

* ok

* ok

* wooooo

* [autofix.ci] apply automated fixes

* fix bugs

* ok

* [autofix.ci] apply automated fixes

* OOOOOPPPPPPPPPPPPS

* fix Bun.Transpiler regressions

* fix(bundler): make --splitting ensure --outdir

* fix final

* oops

* [autofix.ci] apply automated fixes

* use require.resolve

* revert but ... it no longer crashes there

* ok

* [autofix.ci] apply automated fixes

* fix fetch test

---------

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-01-12 22:15:51 -08:00
Meghan Denny
0491ff4186 tidy: remove some redundant bun.toFD calls (#8136)
* remove some redundant bun.toFD calls

* windows fix
2024-01-12 19:46:56 -08:00
Meghan Denny
943c72c8a1 allow StringOrTinyString to hold 31 bytes (#8134) 2024-01-12 19:43:50 -08:00
Meghan Denny
cb6f4b9f4d tidy: remove if(false) dead block (#8129)
* remove if(false) dead block

* remove if (true) {...}

---------

Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
2024-01-12 18:18:19 -08:00
Meghan Denny
45bd2264e3 more small undefined fixes (#8133) 2024-01-12 18:17:53 -08:00
Meghan Denny
8733748eb6 remove bun.assertDefined, comparing against undefined is UB (#8137) 2024-01-12 18:16:04 -08:00
Kaio Duarte
66fa317390 fix(node:url): handle url with missing host on url.parse (#8126)
* fix(node:url): handle url with missing host on `url.parse`

* lazy load punycode module

* use URL class

* add comment and also extra sanity check tests

* extra test

---------

Co-authored-by: dave caruso <me@paperdave.net>
2024-01-12 18:11:10 -08:00
Dylan Conway
ef0e96a2b2 fix(install): add warning and skip patched packages (#8143)
* add warning and skip patched packages

* also overrides

* comment
2024-01-12 18:03:30 -08:00
Meghan Denny
b0d326dfb9 zig_backend stage1 doesnt exist anymore (#8140) 2024-01-12 17:44:03 -08:00
Meghan Denny
517d5ecde9 remove more big endian handling (#8139) 2024-01-12 17:43:30 -08:00
dave caruso
072f2f15ea ci: run windows tests and also run them concurrently (#7758) 2024-01-12 17:02:20 -08:00
Georgijs
0cd7fa1a63 fix(webkit:performance): correctly track size of measures map (#8128)
Co-authored-by: Georgijs Vilums <georgijs@bun.sh>
2024-01-12 14:58:05 -08:00
Ashcon Partovi
2fe0f90d36 Fix loose comparisons and incorrect tag length in semver (#8108) 2024-01-12 15:31:58 -07:00
Jarred Sumner
0783b4bf0e Implement import.meta.{dirname, filename} for Node.js compatibility (#8127)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-12 14:26:50 -08:00
Kaio Duarte
4f96bc416b fix(bun-install): gracefully handle missing package removal (#8091)
* fix(bun-install): gracefully handle missing package removal

* update bun remove test
2024-01-12 14:08:58 -08:00
hugo-syn
f43ecd8aa2 chore: Fix multiple typos (#8121) 2024-01-12 14:07:40 -08:00
Ashcon Partovi
31db26b054 Fix error when null/undefined is passed to stdio in spawn/spawnSync (#8110)
* Fix error when null/undefined is passed to stdio in spawn/spawnSync

* Change conditional
2024-01-12 14:05:55 -08:00
Aayush
f5675284c7 fix(docs): prisma not installed as dev dependency (#8119) 2024-01-12 03:23:47 -08:00
Dylan Conway
98d253d9bb fix(install): incremental support for windows (#7991)
* update for windows

* use correct sizes

* mode

* fchmod and correct error checking

* some progress

* walker_skippable.zig for windows

* no segfault

* comptime only

* normalize

* create files in .bin

* bun.sys.write

* string formatters in bun.fmt, diriterator enum

* isAllASCII comptime

* update more

* some cleanup

* fix 1

* fix 2

* simlink

* cast

* remove normalize

* to zig err

* update fchmod

* fixup

* fix running bin files

* --bun for running binaries

* --bun for scripts

* remove binary linking

* update

* remove todo

* todos

* fix

* simlink

* cast

* more cast
2024-01-11 22:00:47 -08:00
Meghan Denny
9846383b01 all: make bun.FileDescriptor a unique type (#8022)
* all: make bun.FileDescriptor a unique type

# Conflicts:
#	src/bun.js/api/bun/socket.zig
#	src/bun.js/api/bun/spawn.zig
#	src/deps/uws.zig

* need this change too

* convert another bun.FD.asDir call

* more fixes + linux

* fix this size

* accidentally flipped these fd numbers

* more fixes + windows

# Conflicts:
#	src/deps/uws.zig

* dont include type name in serialization

* add another TODO

* resolve review comments

* address more pr comments

* build fixes post-rebase

* another rebase fix

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-11 19:59:48 -08:00
Dylan Conway
fbe4ed206a More bun install hoisting tests (#8112)
* hoisting tests

* more comments on hoistDependency

* fix test
2024-01-11 16:57:24 -08:00
Erik
15263664b6 fix: #7932 (#8038)
* updating package with child peerDependency doesn't keep old version

* [autofix.ci] apply automated fixes

* fixed TODO test

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-11 16:38:39 -08:00
Ciro Spaciari
4611b84352 incremental(windows) add TransmitFile and some fixes for fetch, h2 and http (#8089)
* fix win header decoding zig issue

* fix libuv file read lifecycle

* upload working without sendfile (yet)

* undo

* oops uncoment expect

* add TransmitFile aka sendfile on windows

* cleanup

* [autofix.ci] apply automated fixes

---------

Co-authored-by: cirospaciari <ciro.spaciai@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-11 16:38:13 -08:00
hugo-syn
922ff08a80 chore: Fix multiple typos (#8105) 2024-01-11 16:37:36 -08:00
Jarred Sumner
4c933f733b Fixes #7001 (#7861)
* Fixes #7001

* One more test

* Use `disturbed`

* [autofix.ci] apply automated fixes

* Fix failing test

* Test is no longer todo!

* Make bodyUsed work too

---------

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-01-11 16:25:26 -08:00
Ciro Spaciari
f1c3e87a06 incremental(windows) setTimeout, setInterval and setImmediate should work (#8101)
* fix compilation and types for FD option using usockets

* comment

* clarify HOST_MAME_MAX on windows

* use libuv for timers on windows

* [autofix.ci] apply automated fixes

* fix linux build

---------

Co-authored-by: cirospaciari <ciro.spaciai@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-11 15:09:40 -08:00
Jarred Sumner
0bfe3760f6 Remove musl libraries from trusted dependencies because bun doesn't support musl yet 2024-01-10 21:13:20 -08:00
Ashcon Partovi
68bc548dce Fix 'Not a string or buffer' from zlibBufferSync (#8085)
* Fix 'Not a string or buffer' from zlibBufferSync

* Use `Buffer2`
2024-01-10 15:13:53 -08:00
Dylan Conway
7d4cef53a8 construct package paths without getFdPath for lifecycle scripts (#8056)
* use abs paths instead of getFdPath for lifecycle scripts

* fix aliased packages

* oops

* logs

* remove assert
2024-01-09 23:30:41 -08:00
Jarred Sumner
b400b36ca5 Bump! 2024-01-09 15:40:28 -08:00
Hanaasagi
36d4f09d28 fix(socket): fix 0.0.0.0 binding address (#7366)
* fix(socket): fix `0.0.0.0` binding address
Close: #7355

* test

* test

---------

Co-authored-by: dave caruso <me@paperdave.net>
2024-01-09 13:48:56 -08:00
Jarred Sumner
e77e1c1a58 perf: 5% - 10% faster new Headers(object) & new URLSearchParams(object) (#8028)
* 5%-10% faster `new Headers(object)`

* Add another test

* Remove extra parentheses

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-09 13:45:45 -08:00
Aarvin R
6e1ef49ad4 fix #8067 plugin fileapis (#8068)
- use Bun.file() instead of readFileSync
2024-01-09 13:00:31 -08:00
Jarred Sumner
2daade39a9 Don't close the file descriptor since close_range will get it anyway 2024-01-09 03:33:58 -08:00
Jarred Sumner
ae78441b25 Fixes #8010 (#8064)
* Don't use posix_spawn on Linux

* Make it work

* Avoid closing inherited file descriptors

* Hopefully fix test failures

* Reset close-on-exec flag

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-09 03:11:31 -08:00
Kainoa Kanter
fb8b47b2db chore: sort default-trusted-dependencies.txt (#7837)
* chore: sort default-trusted-dependencies.txt

* remove old trusted deps
2024-01-08 20:36:39 -08:00
Markus Ekholm
9a0dadad24 feat: implemented assert.doesNotMatch (#8008)
* implemented assert.doesNotMatch

* fixed assert.match and assert.doesNotMatch tests and ensure it throws when actual is not a string

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-08 17:31:54 -08:00
Archaeopteryx
f27fc77b3b docs: add missing comma in examples (#8018) 2024-01-08 16:21:44 -08:00
Lino Le Van
88fcfa4461 chore: fix typos in js_parser.zig (#7804)
* chore: fix typos in js_parser.zig

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Lino Le Van <linolevan@Linos-MacBook-Air.local>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-08 15:22:30 -08:00
John-David Dalton
9d56ea4880 Add icu4c to macOS install dependencies section (#8050) 2024-01-08 14:48:16 -08:00
karmabadger
b488734c50 docs: Update dev env instructions for Fedora (#8014)
* Update contributing.md

Added documentation for the installation of the perl Math::BigInt module

* Update contributing.md

merged the fedora perl math bigint module with the other dependencies
2024-01-08 14:42:06 -08:00
Jarred Sumner
8f975ec8ec Faster Buffer.concat, fixes #8034 (#8039)
* Faster, safer `Buffer.concat`

* Use wrappers when creating `Buffer` in C++

* Bun.concatArrayBuffers small optimization

* Add comment

* Add tests

* Ignore empty buffers

* Add assertion

* Update buffer-concat.mjs

* Update buffer-concat.mjs

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-08 14:37:18 -08:00
Pramit Sharma
1aee55524a Update hash-a-password.md (#8048)
Fixed a possible typo and improved grammar and conciseness throughout
2024-01-08 12:59:15 -07:00
Jake Gordon
8805e6150a Remove rogue word in doc (#8047) 2024-01-08 12:42:01 -07:00
huseeiin
237b5eded6 Update to-json.md (#8046)
better title
2024-01-08 11:56:30 -07:00
Jarred Sumner
437faa9444 Tweaks to lifecycle script enqueue (#8037)
* Tweaks to lifecycle script enqueue

* Use helper

* Use `bun.openDir`

* Fixup

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-07 21:05:11 -08:00
Jarred Sumner
e65bab75bc Fixes #8010 (#8025)
* Fixes #8010

* Update install.zig

* Copy the metahash when cleaning the lockfile

* Save more, but error less

* Change copy when there are no more dependencies

* Tweak some tests

* Update bun-add.test.ts

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-07 06:16:31 -08:00
Jarred Sumner
d985e4db65 Use SQLiteError in a test 2024-01-07 03:11:40 -08:00
Jarred Sumner
9a267db105 [bun:sqlite] Ban new SQLiteError() 2024-01-07 01:42:27 -08:00
Jarred Sumner
06c530ba2e Fix crash when exiting bun test (#8026)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-07 00:02:08 -08:00
Jarred Sumner
a1e742734a Fixes #5178 (#8023)
* Fixes #5178

* Update comment

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-06 18:47:13 -08:00
Jarred Sumner
0dc6108bd3 Make PerformanceEntry use 40% less memory (#8016)
* Make PerformanceEntry use 40% less memory

* slightly faster create array of elements

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-06 16:05:03 -08:00
Georgijs
ecdde88670 implement PerformanceObserver and friends (#8011)
* implement PerformanceObserver, PerformanceMeasure, PerformanceMark and friends

* add PerformanceObserver test, clean up other performance tests

* [autofix.ci] apply automated fixes

* Small cleanup

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-05 22:39:29 -08:00
Lucas Coratger
2fd85ef0e6 fix: params in help menu for commands update and install (#7998)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-05 22:27:16 -08:00
guest271314
a774f92757 Fix using two const result=... in same script (#8013)
const result = await ... 
for (const result of result.outputs) {... 

throws

const result = await Bun.build({
                         ^
ReferenceError: Cannot access uninitialized variable.
2024-01-05 22:26:33 -08:00
hborchardt
eb84ebf974 Fix multiple partial consume from BufferList (#8007)
* Add test for multiple partial consume from BufferList

This shows the problem indicated in #7385

* Fix multiple partial consume from BufferList

The JSUint8Array::possiblySharedBuffer() returns the backing array,
not taking into account the byteOffset that indicates the start of
the data in the backing array. This means that when creating an array
with the same backing array, the current byteOffset needs to be added
to the start of the new slice.

This led to consume() returning the same data when repeatedly consuming
small numbers of bytes from the BufferList.
2024-01-05 22:25:01 -08:00
Lucas Coratger
bfe8afd674 feat: add toContainAnyKeys (#7946)
* feat: add toContainAnyKeys

* [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-01-05 21:21:12 -08:00
dave caruso
e8179adcbb chore: clarify my comments (#8006) 2024-01-05 21:19:57 -08:00
karmabadger
515ce30a85 docs: Update contributing.md (#8012)
Adding ruby to dependencies installation for macOS and Fedora
2024-01-05 21:17:19 -08:00
Ciarán
97f8c92cf4 feat(build): adjust arch linux auto detect to include manjaro (#7912) 2024-01-05 17:26:10 -08:00
sitiom
d4d6ef9e89 docs: Add Scoop installation reference for Windows (#7882)
* Add Scoop installation for Windows

* Update installation.md

* update powershell/cmd

irm is used because on certain installs of Windows 10 iwr does not work because of something related to Internet Explorer. haha~

---------

Co-authored-by: dave caruso <me@paperdave.net>
2024-01-05 10:26:40 -08:00
Meghan Denny
fa7e4bce27 node:child_process: support defining extra pipes (#7958)
* node:child_process: support defining extra pipes

* unneeded

* lazily load node:fs

* use $isJSArray instead of ArrayIsArray

* remove std.log call

* don't close child fd we don't own

* close child fd's in parent

* add Subprocess.stdio getter that aligns with ChildProcess.stdio fd's

* [autofix.ci] apply automated fixes

* use ArrayList instead of BoundedArray for stdio_pipes

* fix stream primordials

* dont use unreachable for syscalls

* this file was testing Bun.spawn not child_process.spawn

* skip ipc for now

* ensure the socketpair is created non-blocking on non-mac posix

* allow creating a node:net.Socket from an fd via node:net.connect

* node:stream tidy

* node:child_process: use net.Socket for stdio instead of fs streams

* try again

* fix Socket eager loading

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-05 00:38:08 -08:00
Meghan Denny
89ec2fcb35 fix replacing node:module._resolveFilename not passing the parent module (#7993)
* fix replacing node:module._resolveFilename

* add a test
2024-01-05 00:36:07 -08:00
Meghan Denny
39ab26a663 node:readline: move up when decoder is instantiated (#7994) 2024-01-05 00:26:22 -08:00
Ciarán
e103b53c86 docs(test/writing.md): Add documentation for test.each (#7983) 2024-01-04 17:10:08 -08:00
Moris Kramer
ee85bbc0a3 Update simple.md (#7987)
* Update simple.md

* Update docs/guides/http/simple.md

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-04 16:59:01 -08:00
Jarred Sumner
0103dd56ab Update guide 2024-01-04 16:53:22 -08:00
Lucas Coratger
5d6c68122c feat: add toContainKeys (#7945)
* feat: add toContainKeys

* [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-01-04 15:16:07 -08:00
Jarred Sumner
47acee5d87 Fix webpack test, fix errors in Worker (#7980)
* Update subprocess.zig

* Fix logging errors in Worker

* Update webpack.test.ts

* Update webpack.test.ts

* 😪

* Fix `self` setter

* Set IsImmutablePrototypeExoticObject and make globalThis.self = work

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-04 02:57:43 -08:00
asomethings
54d762531a fix: properly transform http method to uppercase (#7982)
* fix: http method uppercase transformation using wrong length

* feat: add test case for method uppercase
2024-01-04 02:54:59 -08:00
Jarred Sumner
e5bd7fcb8f Add brotli test (#7976)
* Add brotli test

* Check if we can use brotli

* vendor brotli

* Update .gitattributes

* Brotli is now always available

* Update licensing.md

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-03 21:57:19 -08:00
Meghan Denny
f30689256d tidy: use Arguments.slice() (#7978)
* use Arguments.slice()

* slice should be *const

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-03 16:59:44 -08:00
Meghan Denny
50c1f37230 make the tracy callstack depth configurable (#7979) 2024-01-03 16:33:34 -08:00
Meghan Denny
80ebcbf3d8 no big endian (#7974) 2024-01-03 14:52:50 -08:00
Meghan Denny
6345add18a dont use custom DeclEnum impl (#7975) 2024-01-03 14:52:29 -08:00
Otger Rogla
2946bacbbd feat(worker_threads) support argv and execArgv options (#7962)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2024-01-03 14:23:39 -08:00
Otger Rogla
7fa2cf3f61 fix(console.table): fixes for character width breaking the layout (#7966) 2024-01-03 14:22:30 -08:00
Meghan Denny
aa388e6762 vscode: set zig path to local one (#7973) 2024-01-03 14:19:31 -08:00
Jarred Sumner
5a2ad792a0 Try larger runners (#7972)
* Try larger runners

* Update bun-mac-aarch64.yml

* Update bun-mac-aarch64.yml

* Update bun-mac-aarch64.yml

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-03 14:18:39 -08:00
Jarred Sumner
69c85dbe17 Hardcode bun version 2024-01-03 14:10:15 -08:00
Jarred Sumner
71d9199270 Try to make fs.watch tests less flaky (#7909)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-03 13:05:10 -03:00
Jarred Sumner
6b3e1af25d Fix linter warnings in bun:sqlite (#7960)
* [bun:sqlite] Don't call memcpy on a 0 length value or nullptr

* [bun:sqlite] Add missing flags argument

* Make this a reference I guess

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-02 23:27:53 -08:00
Lucas Coratger
9f8ee7c8f7 feat: add toBeEmptyObject (#7772)
* feat: add toBeEmptyObject

* fix: feedbacks

* fix: feedbacks

* fix: feedbacks

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-02 17:11:57 -08:00
Meghan Denny
233622d6bb node:child_process: remove require destructure (#7949) 2024-01-02 17:03:50 -08:00
Jarred Sumner
837cbd60d5 Fix crash in WebSocket client when handshaking fails or when the HTTP response is invalid (#7933)
* Fix double-free in websocket client

* Update test

* Fix null pointer dereference

* Fix missing protect() / unprotect() call

* More careful checks

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-01 18:08:08 -08:00
Jarred Sumner
9d6c0649a4 Fix potential uninitialized memory access when loading CommonJS modules 2024-01-01 17:37:07 -08:00
Jarred Sumner
693a00dc5b Make file uploads use less memory on Linux (#7938)
* Add Linux memfd file upload memory optimization

* various build fixes

* cleanup

* Update blob.zig

* Update base.zig

* Add COW test

* Update blob.zig

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2024-01-01 00:07:26 -08:00
Lucas Coratger
1f9ce68348 feat: add toContainKey (#7773)
* feat: add toContainKey

* feat: add hasOwnProperty to bindings

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2023-12-31 15:29:53 -08:00
Jarred Sumner
492b2d5b76 Implement Brotli support in fetch() (#7839)
* Implement Brotli support in fetch()

* Use @panic

* Update src/http.zig

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

* Update src/http.zig

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

* Fix redirect logic

* Allow extremely long redirect URLs

* Update fetch.test.ts

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Ciro Spaciari <ciro.spaciari@gmail.com>
2023-12-31 06:19:08 -08:00
Kaio Duarte
8eebfd8e22 fix: add ws properties to BunWebSocketMocked prototype (#7898)
* add ws properties to BunWebSocketMocked prototype

* add tests for Server class

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2023-12-31 02:42:58 -08:00
Jarred Sumner
1d684e0d4f Tweak formatting of console.table (#7927)
* Tweak alignment of console.table

* " " empty string instead of "#"

* Fix assertion failure

* Only get the length when necessary

* Avoid stale copies

* Add `asUTF8` helper to `bun.String`

* Cautiously handle recursion

* Further tweaks to output

* output

* Add native implementation of `getStringWidth`

* [autofix.ci] apply automated fixes

* If its not a string then quote it by default

* Add snapshot for headers

* Make it easier to debug when a builtin throws an exception

* This must be hoisted

* Fix bugs in `getStringWidth`

* Update getStringWidth.test.ts

* Eager load it

---------

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>
2023-12-31 02:38:52 -08:00
Jarred Sumner
14c60eca94 Fix crash that can occur due to invalid UTF-8 (#7926)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-30 17:52:52 -08:00
Jarred Sumner
6eab178790 Add OpenSSL v1.1.0 to process.versions.openssl (#7924)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-29 21:36:41 -08:00
Ciarán
32ca195f60 docs(test/writing.md): update matchers to indicate support for arrayContaining, closeTo, objectContaining (#7800) 2023-12-29 21:35:34 -08:00
Michael H
c381816c57 Clean Trusted Dependencies (#7857)
* clean

* add back node version ones
2023-12-29 20:46:56 -08:00
Jarred Sumner
ae8f2a3afb Windows Build Fixes (#7923)
* Windows Build Fixes

* windows

* Update event_loop.zig

* Update bindings.zig

* Update event_loop.zig

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-29 20:39:23 -08:00
Ciro Spaciari
25441ede20 fix(bun.serve) avoid double ending chunk (#7897)
* avoid double ending chunk

* re-format

* Ensure we run tests on bun-uws changes

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-29 20:35:32 -08:00
Jarred Sumner
a0c8ee31a1 Bump version number 2023-12-29 18:38:18 -08:00
Jarred Sumner
135039b137 Better errors for bun:sqlite (#7906)
* Better errors for bun:sqlite

* Add `byteOffset`

* Add `code` property

* Fix error

* Update test

* Add a couple more tests for errors

* Add file with sqlite error codes

* Report extra memory from `sqlite3_stmt`

* Add polyfills for macOS x64

* Use -1 when unavailable

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-29 18:37:16 -08:00
Jarred Sumner
05f14c8d6a Add setMayBePrototype where it should be added (#7922)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-29 18:26:33 -08:00
Otger Rogla
15755a0246 feat: implement console.table (#7866)
* feat: implement console.table

* console.table minor changes

* fix console.log for arrays after console.table changes
2023-12-29 18:04:49 -08:00
Jeroen
b6cadf387b docs(bundler): update CLI command in index.md for bun build with publicPath (#7916)
* docs(bundler): update CLI command in index.md for bun build with publicPath

* Update docs/bundler/index.md

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-12-29 15:26:35 -08:00
Jarred Sumner
b011fd2567 Fixes https://x.com/jeroendotdot/status/1740651288239460384?s=46&t=0Uhw6mmGT650_9M2pXUsCw (#7910)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-29 15:26:06 -08:00
Lucas Coratger
5e72a27a76 feat: add toBeObject (#7770)
* feat: add toBeObject

* fix: feedbacks

* [autofix.ci] apply automated fixes

* feat: add more information on error message

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2023-12-29 12:37:02 -08:00
Meghan Denny
9ef7b304d9 misc: use compileError instead of unreachable for comptime-known switches (#7905) 2023-12-29 02:07:17 -08:00
Meghan Denny
38d5a5fe9a tidy: bun.zig: remove switch on literal (#7907) 2023-12-29 02:06:56 -08:00
Jarred Sumner
43b99021f8 Fix flaky timeout test 2023-12-29 01:29:40 -08:00
Jarred Sumner
8a34b8f6f8 Add flags for Valgrind build 2023-12-29 00:25:02 -08:00
Jarred Sumner
70f344101b Revert " feat(server): add server backlog parameter (#7822)" (#7908)
This reverts commit 411094b82d.
2023-12-28 23:44:27 -08:00
Jarred Sumner
a3a6b894c5 [bun:sqlite] Cache the structure and call the destructor (#7904)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-28 21:33:55 -08:00
Meghan Denny
a5bf1216d1 cli: resolve TODO filing upstream issue (#7903) 2023-12-28 20:11:51 -08:00
Jarred Sumner
ae5f1b0168 Fix crash with latin1 supplemental characters in bun:sqlite query (#7902)
* Fix crash with latin1 supplemental characters in bun:sqlite queries

* Make it run from any dir

* Fix comment

* [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>
2023-12-28 20:00:58 -08:00
Jarred Sumner
20690403da Fixes #7868 (#7884)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-28 17:53:11 -08:00
Jarred Sumner
903a202473 Support Blob in CryptoHasher (#7878)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-28 16:33:18 -08:00
Kaio Duarte
14bc121dc8 Compare error name and message on Bun.deepEquals and assert.deepStrictEqual (#7867)
* check error name and message on Bun.deepEquals

* add tests

* add test with subclass of Error
2023-12-28 16:32:49 -08:00
Oleg Sevruk
eac3bda895 Update bun-create.md (#7889)
Typo. Correct the 8th item in the hidden section “How to create buns”
2023-12-28 16:30:29 -08:00
Aarvin R
0a7bbcb9a6 finish docs for env quotes (#7895)
- added template literal backticks to sentence
- added example of quotes in .env files
2023-12-28 16:17:16 -08:00
Aarvin R
107015fd48 fix example syntax for plugins (#7894)
- updated docs/runtime/plugins.md to use plugin()
- update docs/runtime/plugins.md to use "loaded" instead of "registered" for clarity
2023-12-28 16:14:56 -08:00
Malthe Borch
813afe6c53 Add 'listening' boolean property to 'net:Server' (#7658)
* Add 'listening' boolean property to 'net:Server'

* Convert to getter

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2023-12-28 14:20:41 -03:00
Hanaasagi
411094b82d feat(server): add server backlog parameter (#7822)
* feat(server): add server backlog parameter

* add some tests

* Apply suggestions from code review

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

* fix test

* chore: fix style

---------

Co-authored-by: Ciro Spaciari <ciro.spaciari@gmail.com>
2023-12-28 14:19:20 -03:00
Jarred Sumner
1f90608d66 Fixes #7827 (#7858)
* Fixes #7827

* Add some assertions and errors

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-27 20:22:44 -08:00
Xiliang Chen
2b09347dc6 fix toMatchSnapshot signature (#7880) 2023-12-27 20:16:05 -08:00
Meghan Denny
f02ef8fb35 script/setup.sh: don't hardcode search for pkg-config (#7871) 2023-12-27 18:35:09 -08:00
Meghan Denny
da13884295 inspect: print 'call' property in objects (#7874)
functions have separate code path now
2023-12-27 18:34:52 -08:00
Meghan Denny
8a39c02e7a bun.js bindings: tidy with inline range (#7875) 2023-12-27 18:34:18 -08:00
Meghan Denny
bfc065c5cc bun.js bindings: remove redundant as-bitcast-as (#7876) 2023-12-27 18:33:56 -08:00
Meghan Denny
93c081f351 scripts/setup.sh: don't check for zig since it installs zig later (#7870)
* scripts/setup.sh: don't check for zig since it installs zig later

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2023-12-27 16:26:46 -07:00
Ciarán
4a66091491 Fixes #7740: Change "Duplicate dependency" to warn instead of error (#7766)
* fix(#7740): change 'Duplicate dependency' to be warning instead of error

* chore(07740.test.ts): clean up test

* [autofix.ci] apply automated fixes

* fix(src/logger.zig): increment warnings instead of errors in addRangeWarningFmtWithNotes()

* chore(07740.test.ts): simplify package.json to avoid increasing test times

* chore(bun-install.test.ts): update test to expect 'warn' instead of 'error'

* chore(07740.test.ts): fix formatting

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2023-12-27 00:53:02 -08:00
johnpyp
d1dcf5ccf7 doc: improve Bun.Glob api docs (#7859)
* doc: improve Bun.Glob api docs

* Update docs/api/glob.md

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

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-12-26 22:20:25 -08:00
Ciro Spaciari
f8159f1b36 fix(fetch) Fix fetch redirect (#7847)
* clean socket instance before closing on redirect

* fetch redirect test

* fix flask test

* oops
2023-12-26 17:37:41 -08:00
cirospaciari
1a370eb483 revert 2023-12-26 11:33:30 -03:00
cirospaciari
f12ff9d1e5 clean client ref from socket before close 2023-12-26 11:22:12 -03:00
Jarred Sumner
4d6219eda4 Revert "whitelist nuxt (#7840)"
This reverts commit a3630dde2e.

`nuxt` does not list any scripts in their package.json
2023-12-25 23:39:57 -08:00
Larry Williamson
a3630dde2e whitelist nuxt (#7840) 2023-12-25 23:27:56 -08:00
Ryan
c6ba32b850 Add purescript and spago to default-trusted-dependencies.txt (#7838)
These are two important packages for purescript development, purescript is the language (including a binary file that must be installed), and spago is the purescript package manager (also including a binary file that must be installed).
2023-12-25 22:58:32 -08:00
Omar
05984d405f Whitelist Railway CLI (#7832)
https://railway.app

Railway CLI is used to deploy Railway services. The CLI npm package requires running postinstall scripts.

9de89415f0/package.json (L17)
2023-12-25 20:32:16 -05:00
thunfisch987
696a5a28c9 Update docs/typescript.md (#7825) 2023-12-25 09:22:29 -07:00
Jarred Sumner
b399deebdd 15% faster crypto.randomUUID (#7824)
* Fixes #7811

* [autofix.ci] apply automated fixes

* Update src/bun.js/webcore.zig

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

---------

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>
Co-authored-by: Markus Staab <maggus.staab@googlemail.com>
2023-12-25 01:25:35 -08:00
xxxhussein
39ea8cbfea Update installation.md (#7817)
npm states that their name should be written as "npm" in lowercase rather than "NPM" or "Npm" etc.
2023-12-24 19:52:38 -08:00
Jarred Sumner
09d51486e9 Enable forceConsistentCasingInFileNames in bun init 2023-12-24 06:18:25 -08:00
Jarred Sumner
ead3bdf947 Make the tsconfig.json used in bun init sloppier 2023-12-24 06:16:44 -08:00
Arnaud Barré
6077ace528 Update init template & TS documentation (#7813)
* Update init template & TS documentation

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2023-12-24 06:13:53 -08:00
Jarred Sumner
a119e8d636 fs.readFile & fs.writeFile encoding + simplify string handling + fix memory leak (#7797)
* Simplify string handling code

* add extra + external

* Update fs.test.ts

* Bump

* woopsie

* prettier

* Rename stats() to resourceUsage()

* Fix leak

* Fix more leaks

* Setup malloc heap breakdown

* Thread safety

* Fix bug when creating buffer from utf-16 string

cc @dylan-conway

* Use global allocator

* More new

* Update fs.test.ts

* Update setTimeout.test.js

* Fix UAF in HTMLRewriter

* More bun.new

* Remove logs

* Un-skip test which no longer is flaky

* Even more `bun.new`

* Fix memory leak in HTMLRewriter.

Fixes #2325

* Don't accept Buffer for now

* Fix issue with node-fetch polyfill

* Don't destruct the response value too soon

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-24 06:10:46 -08:00
vitalspace
72eb607e21 FIx "Inconsistent script not found error message" (#7799) 2023-12-23 01:37:58 -08:00
Ciro Spaciari
26325aca95 fix(setTimeout) fix high CPU usage (#7792)
* fix timers CPU usage

* add stats to subprocess

* fix issue number

* add ResourceUsage

* better names on ResourceUsage

* add wait4 for macOS

* better names 2

* add types

* change comments style

* BigInt
2023-12-22 16:59:00 -08:00
Risu
98242fa10d Add node:test to Node.js compatibility docs (#7779) 2023-12-22 09:21:35 -08:00
Dylan Conway
906f86d6fd always set name (#7783) 2023-12-21 23:46:32 -08:00
Omar
9fdd1068da whitelist lightningcss-cli (#7782)
lightningcss is a popular css library with over 0.5 million weekly downloads. It also offers a cli tool that requires postinstall script to run.

https://www.npmjs.com/package/lightningcss
https://www.npmjs.com/package/lightningcss-cli?activeTab=code
2023-12-21 23:42:57 -08:00
Jarred Sumner
7e59f287a1 Fix bug in bun upgrade --canary (#7777)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-21 20:18:02 -08:00
Jarred Sumner
56df6a9888 Bump! 2023-12-21 18:29:16 -08:00
Jarred Sumner
ada49eb96d Update setInterval-leak-fixture.js 2023-12-21 18:21:00 -08:00
Jarred Sumner
c5436c09ab Fix setInterval regression (#7776)
* Fix setInterval regression

* Add some comments

* Add another test

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-21 18:00:24 -08:00
Jarred Sumner
a93f467a74 NAPI fixes (#7765)
* napi fixes

* Make bcrypt work

* Always return this

* Fixes #7685

* [autofix.ci] apply automated fixes

* Update napi.cpp

* Make it clearer what this is doing

---------

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>
2023-12-21 15:55:58 -08:00
Ashcon Partovi
cd55401eba Fix flaky tests 2023-12-21 08:14:43 -08:00
SirHyperNova
0f8bcfdc53 Remove "not production ready" from WebSocket (#7760) 2023-12-20 23:31:48 -08:00
Jarred Sumner
2428da9354 Fix formatting error 2023-12-20 21:18:19 -08:00
Jarred Sumner
65e11c48b6 Fix hashing consistency issue (#7757)
* Fix color issue in `bun test`

* Fix hashing consistentcy issue

* Fix Windows build failure

* Update types.zig

* Fix build

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-20 20:57:20 -08:00
dave caruso
6b549ee592 fix: random improvements to bun.String (#7695)
* make bun.String.createUninitialized harder to mess up

* remove toJSConst

* Update src/bun.js/bindings/BunString.cpp

* ok

* aaaaaaaa

* fix ucs2 encoding oopsies

* a

* [autofix.ci] apply automated fixes

* fix baseline build

* hello

* remove commented code

* aaa

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2023-12-20 19:18:32 -08:00
Jarred Sumner
5b538fb076 Fix Windows build failure 2023-12-20 19:09:53 -08:00
Vlad Sirenko
7e511f55de 4415 es5 class http.Server (#7705) 2023-12-20 15:55:30 -08:00
Jarred Sumner
c271c6c38e perf: More efficient setTimeout and setInterval (#7715)
* Use timer heap for `setTimeout`

* Further efficiency improvement to timers

* Fix assertion

* Make this test less flaky?

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-20 15:13:23 -08:00
dave caruso
00955c712e fix: crash in bun init by renaming string function to be more consistant (#7746) 2023-12-20 13:44:53 -08:00
dave caruso
00e745ec2c fix(windows): use path normalizer in bun run index.ts (#7723)
* cleanup stuff

* hi

* fix building on posix

* a

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-12-20 13:42:09 -08:00
Alex Martin
6ee812d63d Handle holey arrays console log edge case (#7751)
", " was only being written when appropriate before "empty item", and not
"N x empty items".
2023-12-20 13:36:28 -08:00
Jarred Sumner
a623e7c702 Fixes #7736 (#7752)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-20 00:57:16 -08:00
Jarred Sumner
59a0e885d9 Make large stdio in Bun.spawnSync efficient on Linux (#7733)
* Use memfd in spawnSync when possible

* Make it work

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-19 20:25:31 -08:00
Dylan Conway
3f1c39ad0b fix(install): lifecycle script verbose logging and a couple bug fixes (#7726)
* trim trailing slash, always create temp node-gyp

* verbose lifecycle scripts

* move node_modules from other package managers to subdirectory

* fix merge

* remove for another branch

* Update bun-install-registry.test.ts

* Update bun-install-registry.test.ts

* inherit mac only

* Update src/install/lifecycle_script_runner.zig

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

* cache directory created when ensuring temp node-gyp

* fix merge

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-12-19 19:39:33 -08:00
dave caruso
39d062cf3c feat: print the longest postinstall if it took more than 500ms (#7719)
* print the longest postinstall if it took more than 500ms

* build error

* make newlines print right

* fix tests

* sdfafdsa

* i hope this is it
2023-12-19 17:51:39 -08:00
dave caruso
92901eb6e0 fix: change how exit codes and signals are printed (#7674)
* change how exit codes and signals are printed

* second iteration of this

* [autofix.ci] apply automated fixes

* dasfsa

* Fix Linux Build

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-12-19 16:55:15 -08:00
dave caruso
ab68aa5a8e dx(win): fix codegen.ps1 on 2023-12-19 13:29:31 -08:00
Supachai Kheawjuy
3f131c0411 docs(api): typo Diffie Hellman in http.md (#7744) 2023-12-19 11:17:11 -08:00
Supachai Kheawjuy
db60c92e25 docs(bundler): remove unused callout tag in index.md (#7742) 2023-12-19 10:20:14 -08:00
Bjön Limell
1730cfbbbf docs: fixed Bun.gunzip (#7738) 2023-12-19 09:14:47 -08:00
Supachai Kheawjuy
45a499912b docs(guides/process): change file extension from tsx to ts in stdin.md (#7737) 2023-12-19 08:44:34 -08:00
Jarred Sumner
61f92d9e5f fix(install): fix false positive "lockfile is frozen" when using bun install --production (#7713)
* More lkogs

Add more logs for `--verbose`

* Fixes #5792

This makes `--frozen-lockfile` use a hash of all the resolved package versions that were installed, instead of the more permissive logic used to decide whether or not to re-run the install

* Fix debug assertion failure in `bun install --production`

* Update src/install/install.zig

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-19 00:56:21 -08:00
Spencer Smith
3baaa28f93 Update index.md (#7727) 2023-12-18 22:23:31 -08:00
Dylan Conway
b88324db31 chore: upgrade webkit (#7720)
* update

* alwaysInline

* update webkit commit

* update webkit tag

* remove webkit_url

* check for exception and update webkit commit

* update webkit tag
2023-12-18 20:54:04 -08:00
Dylan Conway
dc19541719 update bun.zig 2023-12-18 20:15:02 -08:00
Jarred Sumner
2d2f3c4e50 fix: Tweaks to syntax highlighter (#7711)
* [syntax highlighter] Highlight `from` and `as` in `import`. Don't bold function calls or identifiers

* Update bun.zig

* Update bun.zig

* Update src/bun.zig

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

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: dave caruso <me@paperdave.net>
2023-12-18 18:32:45 -08:00
dave caruso
f3ce571a29 fix: parsing error from "a<b>" as typescript (#7722) 2023-12-18 18:24:04 -08:00
dave caruso
1a2643520b fix(bundler): handle direct eval better (#7693)
* fix(bundler): handle  direct eval better

* error message
2023-12-18 14:41:04 -08:00
Colin McDonnell
31c17a1bb3 Better types (#7670)
* Rewrite bun-types to include @types/node

* Incorporate new commits

* Update bun.lockb

* [autofix.ci] apply automated fixes

* Update readme, add back webkit

* Updates

* BunJS -> Bun

* Switch init to @types/bun

* [autofix.ci] apply automated fixes

* Tweaks

* Revert docs changes

* Fix bugs

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2023-12-18 13:27:48 -08:00
Jarred Sumner
a1a4178c3f Fix next build integration test 2023-12-18 01:21:00 -08:00
Jarred Sumner
7ac5bdc9dd Fix flaky test 2023-12-18 01:11:36 -08:00
Jarred Sumner
506c165860 Fix napi tests 2023-12-18 00:03:45 -08:00
Jarred Sumner
6fc29b6412 Recommend the .start() method 2023-12-17 23:18:41 -08:00
Jarred Sumner
b6f60680f6 Remove protobuf.js from default trusted dependencies list
The postinstall script will never print anything, since it does not exit with a non-zero exit code.

Therefore, this warning will never have an impact

Therefore, it should not be allowed to increase how long it takes to install your packages

4436cc748c/scripts/postinstall.js
2023-12-17 00:10:49 -08:00
Jarred Sumner
1f71ad5661 Fixes #7694
Verified it now calls the function the correct number of times
2023-12-16 23:47:57 -08:00
dave caruso
cbb477cbe2 perf: make Bun.peek 90x faster on pending promises, 1.5x on resolved (#7697)
* perf: make peek() 90x faster on pending promises, 1.5x faster on resolved promises

* more bench

* test edits
2023-12-16 17:36:08 -08:00
dave caruso
369e3022e4 chore: upgrade zig to 0.12.0-dev.1828+225fe6ddb (#7671)
* chore: upgrade zig to 0.12.0-dev.1828+225fe6ddb

* open as iterable

* fix building identifier cache

* fix windows build

* fix linux build

* fix linux build
2023-12-16 00:14:15 -08:00
Ciro Spaciari
925a94ffe6 test(grpc-js) update certs for macOS (#7678)
* update certs

* [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>
2023-12-15 20:40:04 -08:00
Jarred Sumner
ca89087684 feat: Make using await inside a non-async function have a helpful error message (#7690)
* Update fs.test.ts

* Make using `await` inside a non-async function have a good error

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-15 18:04:40 -08:00
dave caruso
9e47ceac87 ci: attempt to fix linux-aarch64 ci (#7691)
* experiment with this

* rerun on changed
2023-12-15 17:45:10 -08:00
dave caruso
4098dd0df5 chore: fix the commit of WebKit
bump to "657558d4d4c9c33f41b9670e72d96a5a39fe546e" which has some
windows-specific fixes, as well as fixes linux-arm64 debug build,
and adds the debug windows build.
2023-12-15 16:41:45 -08:00
dave caruso
c3b1333ae8 ci: fix windows release action 2023-12-15 16:41:45 -08:00
Vincent Lechemin
f88e5d128c Fix file descriptor leak in readdir (#7688) 2023-12-15 16:39:40 -08:00
Jarred Sumner
4d7c66066b fix: Resolve specifiers passed to mock.module (#7673)
* Mention module mocks in docs

* [autofix.ci] apply automated fixes

* Fix relative file paths that do not exist

* add test for file: URL

---------

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>
2023-12-15 14:41:56 -08:00
Scott Trinh
3872f7a5b7 Use EdgeQL for expression for bulk insert in seed.ts (#7686)
* Use EdgeQL `for` expression for bulk insert in seed.ts

Perhaps this was a JavaScript for loop before to make it a little easier to grok for non-EdgeDB users. However, hopefully this is easier enough to understand that people can still follow the example even if they do not know EdgeQL.

* Fix small typo in assignment
2023-12-15 14:13:02 -08:00
dave caruso
6443c26a4a fix node_env regression (#7666) 2023-12-15 16:51:26 -03:00
Jarred Sumner
c2cd7402a0 Upgrade from SQLite v3.38.5 to v3.44.2 (#7668)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-14 20:03:29 -08:00
Ashcon Partovi
fbcb622335 Implement expect().toContainEqual() (#6589)
* Support `expect().toBeValidDate()`

* Support `expect().toContainEqual()`

Also fixes a bug where `expect(new Set()).toContain()` would not work

* Update expect.zig

* docs

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2023-12-14 17:11:14 -08:00
Mathias Wulff
fc733fe89c Use stderr for info about how to open inspector (#7270)
* Use stderr for info about how to open inspector

* Write to stderr without red colors
2023-12-14 17:07:46 -08:00
dave caruso
441612917d windows: more windows stuff (#6938)
* fix(win/upgrade): do not show powershell expand-archive info while upgrading

* start working bun run

* experiment: `bun.new`

* you can now bun run

* Update src/install/install.zig

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

* Update src/install/install.zig

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

* stuff

* fix stuff

* fix this

* farther but not really

* sadfs

* path hell

not sure how much worse or better this makes things. its a mess. windows path handlign is a mess aaaaaaaaaaaaaaaa

* path.resolve bs

* remove old build system stuff from pr

* a

* fix some path.parse/join cases

* path closer not perfect

* normalize and join tests tests  done

* paths

* implement path.relative

* ,

* stuff

* assert

* fix compile

* hate

* the code isnt great

* stuff

* housekeeping for build system

* blah

* explain windows sitaution in docs

* some progress? not much though

* zig compiler crashes here

* fix

* yippee

* ok

* a

* ala wala

* fix builds on stuff

* clean

* the tests now run

* a

* aa

* dedupe uv event loop

* fix fs test accuracy

* stuff

* [autofix.ci] apply automated fixes

* huge updat e

* [autofix.ci] apply automated fixes

* url

* [autofix.ci] apply automated fixes

* start windows spawnSync

* [autofix.ci] apply automated fixes

* add --webkit for update submodules

* add better err message for `bun setup`

* fix unix platform build

* .

* [autofix.ci] apply automated fixes

* un-upgrade libarchive

* z

* asdfghj

* wrk

* todo -> panic

* ok

* a

* [autofix.ci] apply automated fixes

* fix build scripts l ol

* dfghj

* fa

* [autofix.ci] apply automated fixes

* aaaa

* a

* l

* [autofix.ci] apply automated fixes

* more logs

* [autofix.ci] apply automated fixes

* j

* fix init_command

* CORE DUMP HELL

* i swear im being pranked by the github actions gods

* fadsjkfdshjkhjkdfsahjkdfshjksdafjkhhjkfdsahfsdkjhfsdjkahf

* thanks IAS

* this is the correct fix

* personal review

* ddisablbe these

* revisions!

* ok

* fix submodule

* stuff

* fix libarchive

* [autofix.ci] apply automated fixes

* stuff

* [autofix.ci] apply automated fixes

* a

* fix addressToJS on windows

* make dns async again

* dx: add flag to update submodules ps1 to clone webkit

* dns error case for libuv

* dx improvements on windows

* newline

* obvious fix

* install steps

* extra note

* fix fs test

* Update building-windows.md

* fix builtins bundler to support \r\n line endnigs

* better

* some windows stuff

* a

* a

* a

* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

* [autofix.ci] apply automated fixes

* bunfile text works

* fix build on the mac

* hellooooooooooo

* install steps

* ci for baseline?

* fix

* aaa

* wow

* install script revamp

* bug

* OK

* ok

* aaaaaaaaaaaaaa

* okay

* fix the node test runner lol

* fix napi stuff

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: cirospaciari <ciro.spaciai@gmail.com>
Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
2023-12-14 16:56:33 -08:00
Osmose
adcad39e1d Update install.dryRun docs to be accurate. (#7275)
The previous line appeared to be copied from `install.optional`.
2023-12-14 15:44:13 -08:00
Jarred Sumner
453a270b2e linker ld scripts expect unmangled names 2023-12-14 14:25:18 -08:00
Jarred Sumner
fe5e19da59 Implement v8::Isolate::TryGetCurrent, v8::Isolate::GetCurrent, v8::Isolate::GetCurrentContext, stub node::AddEnvironmentCleanupHook & node:: RemoveEnvironmentCleanupHook (#7665)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-14 13:46:38 -08:00
Vlad Sirenko
19e80771ac http convert es5 class (#7485)
* http convert es5 class

* remove additional object with private fields

* add comment to http method
2023-12-14 03:03:30 -08:00
Dylan Conway
36c316a24a fix(install) make sure node-gyp is available during lifecycle scripts (#7622)
* bunx node-gyp

* add test

* create temp node-gyp when used in script

* windows reminder

* closer?

* Update bunx_command.zig

* append fake node to end of path

* Update install.zig

* correct temp node-gyp dir, always append parent `node_modules/.bin` dir

* make sure temp node-gyp doesnt run itself

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-13 23:19:37 -08:00
James Anderson
c0ccdccbeb fix(resolver): wildcard tsconfig path not including suffix (#7612)
* fix(resolver): wildcard tsconfig path not including suffix

* different approach
2023-12-13 23:19:20 -08:00
dave caruso
1fc9b56936 feat(test): rejects.toThrow and resolves.toThrow (#7652) 2023-12-13 23:18:17 -08:00
dave caruso
8ec405facc fix(build): add a missing / in a fallback path route (#7653) 2023-12-13 23:12:25 -08:00
dave caruso
beedb28e38 fix: stuff i forgot to push (#7651)
* i forgot

* a
2023-12-13 22:41:37 -08:00
BaboonKing
1aaf63efc4 fix(types): add "webcrypto" to "node:crypto" (#7580)
* fix(types):  add "webcrypto" to "node:crypto"

* chore(types): remove wrong version flag as jsdoc
2023-12-13 22:15:00 -08:00
Jarred Sumner
0bce2b46ca Fixes #7641 2023-12-13 22:04:05 -08:00
dave caruso
c8305df5c2 fix(runtime): make process.stdin work (fix vite create on linux) (#7650)
* a

* make fds cached

* fghjfdsaa

* dsfafsa

* 😭
2023-12-13 21:52:37 -08:00
dave caruso
9787ea91f2 fix(node): always use .RunCommand when binary is named node (#7615)
* make the cli act more like node when the binary is named node

* mmmmmmmmmmm review comments

* whatever

* fix test

* am stupid am stupid

* sure
2023-12-13 21:43:05 -08:00
Hanaasagi
a648ed9e6a chore: fix build (#7648) 2023-12-13 18:56:51 -08:00
chocolateboy
ab95e2189f Prevent shell-option changes leaking out of the bash-completion script (#7646)
- save and restore `globstar` rather than leaving it unset
  - don't change `extglob` as it's already defined and required by
    bash-completion
2023-12-13 17:32:53 -08:00
Andrew Shoener
dc0736d61d Clarify dead code elimination (#7639) 2023-12-13 17:31:50 -08:00
dave caruso
5029fc8564 fix: do not inline process.env during bun run and bun test (#7614)
* env stuff

* ok

* undo

* remove unused param

* resolve review comment

* dupe

* it compiles now i promise
2023-12-13 06:05:03 -08:00
Jarred Sumner
38c6575dc8 Fix incorrect pipe reading code for lifecycle scripts, add basic ioctl_ficlone support (#7628)
* Move code for lifecycle scripts into a separate file

* Fix slow & incorrect pipe reading code used for bun install lifecycle scripts

* Fix crash in IPC due to calling on_socket_long_timeout when its a null ptr

* Only try to get the node path one time

* Fix incorrect glob pattern for rebuilding Zig files

@paperdave doing `**/**/**` does not work

* Implement basic support for ioctl_ficlone

* lowercase these

* intcast

* This is backwards

* Fix "waiting for tasks" spam

* Update install.zig

* Add helper

* Update install.zig

* Address PR feedback

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-13 06:03:21 -08:00
Dylan Conway
efb2cb5871 get auto and prefer from install expr (#7624) 2023-12-13 03:11:03 -08:00
pacexy
9fc12a1244 Fix install.exact does not work (#7603)
* fix

* fix
2023-12-13 01:24:05 -08:00
Jarred Sumner
900eec71fa Bump 2023-12-12 17:35:36 -08:00
Jarred Sumner
4fec7f84c8 Run libc atexit callbacks 2023-12-12 17:34:19 -08:00
Dylan Conway
5787350243 add sharp 2023-12-12 13:38:43 -08:00
Imamuzzaki Abu Salam
35ba928430 test: init sharp integration test (#7481)
* test: init sharp integration test

* Update sharp integration tests and package.json

* Delete unnecessary files and dependencies

* refactor sharp dir with path.join import.meta.dir

Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>

* Update dependencies and fix image resizing

* Remove trustedDependencies from package.json

---------

Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
2023-12-12 13:35:13 -08:00
Jarred Sumner
7ec64c2cc8 Update lifecycle.md 2023-12-12 02:36:48 -08:00
Jarred Sumner
5e60861c34 Disable this warning 2023-12-12 02:32:48 -08:00
Jarred Sumner
39b66ded08 Bump 2023-12-12 02:31:36 -08:00
dave caruso
a2f595d352 fix: better error message for bun install fs permission errors (#7550)
* remove `prettyWarn`, add easy print utils, clarify a package.json loading error

* error when node_modules isnt writable

* hmm

* fix instal

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-12 00:18:05 -08:00
Dylan Conway
d163351f3e fix(install): fix semver sorting with prereleases (#7588)
* compare number with string correctly

* Update semver.zig

* invalidate cache

* seconds
2023-12-11 22:29:22 -08:00
Dylan Conway
351e47355a add default trustedDependencies and run lifecycle scripts during installation (#7132)
* [install] allow parallel execution of `postinstall` scripts

- fixes spurious exit code 42 from `spawn()`

* postinstall to a pipe

* feat(install): include top 500 packages as defaults for postinstall

* windows newline handling*

*i did not test it

* stuff

* cool

* a

* fix merge

* set `has_trusted_dependencies`

* fix a bunch of tests

* fix merge

* remove `PackageManager`

* remove commented code

* change to function

* Update lockfile.zig

* run scripts if added to `trustedDependencies` after install

* packages without `resolved` properties

* node-gyp scripts

* node-gyp script in the root

* another test

* git deps run prepare scripts

* fix merge

* run lifecycle scripts during installation

* Update lockfile.zig

* always increment

* 🏗️

* update tests

* tickWIthoutIdle

* const uws

* loop forwards through trees

* single buffer bitset list

* tag.isGit

* windows path separators

* `bun.sys.read` and enable/disable buffering

* fix test and waiter thread

* waiter thread and tests

* Update bun-install-registry.test.ts

* workspace exclude `preprepare` and `postprepare`

* Create esbuild.test.ts

* make sure length is the same

* remove deferred binlinks, add estrella test

* test with another version

* address some comments

* remove .verdaccio-db.json

* ooops

* fix build

* use `pid` to wait

* dont register pid_poll when using waiter thread

* stress test

* free

* fix failing tests

* fix linux crash, snapshot stress test

* oops

* concurrent scripts

* activate as soon as possible

* test

* delete stress test packages

* remove unused packages

* comment stress test and maybe fix segfault

* delete snapshot

* fix assertion

* use cpu_count * 2 for default concurrent scripts

* gear emoji

* add --concurrent-scripts to docs

* more docs

---------

Co-authored-by: alexlamsl <alexlamsl@gmail.com>
Co-authored-by: dave caruso <me@paperdave.net>
Co-authored-by: Dylan Conway <33744874+MilesWright7@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-12-11 22:08:25 -08:00
hustLer2k
83ed65c687 Add -h as alias to --help (#7519)
* feat: add -h as alias to --help

* fix: remove redundant -h flag check

* fix: remove unneeded -h equality tests
2023-12-11 16:27:17 -08:00
hustLer2k
ab85b2a2a0 test: Migration tests fixes (#7393)
* use lockfile path passed as an argument instead of a literal string

* clean up tmp folders in migrate.test

---------

Co-authored-by: Alex See <alexsee@Alexs-MacBook-Air.local>
2023-12-11 16:07:20 -08:00
hustLer2k
6a63224f86 fix(node:fs): interpret string options as encoding in Readable constructor and fs.createReadStream (#7516)
* fix: match Readable constructor and createReadStream to node api

* remove typo from node-stream.test.js

Co-authored-by: Aaron Silvas <aaronsilvas@gmail.com>

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Aaron Silvas <aaronsilvas@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2023-12-11 16:06:29 -08:00
Dale Seo
c9e98db258 docs: remove unncessary empty line (#7581) 2023-12-11 14:54:18 -08:00
Jarred Sumner
351810e5bc Switch to std.sort.pdq from std.sort.block (#7574)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-10 19:49:21 -08:00
Nick Reilingh
3aabe58180 bun-types: add recursive option to readdir/Sync (#7568) 2023-12-10 19:48:54 -08:00
Jarred Sumner
800fb12906 Handle holey arrays in console.log, don't omit length property, cleanup logLevel option (#7557)
* Add `fromJS` helper method to `ComptimeStringMap` and `logLevel` parsing better

* Handle holey arrays

* Update console-log.expected.txt

* More tests

* Add TODO

* More fixture

* [autofix.ci] apply automated fixes

* Update bindings.cpp

* Cleanup some spacing

* update

* Handle externals in `bun build` from package.json "imports"

* Prevent recursion in Web Worker

* Fix failing test

---------

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>
2023-12-10 04:33:25 -08:00
Bin Xin
7541f4ce4f fix: jsx key after spread (#7464)
* fix: jsx key after spread

* feat: configurable logLevel
2023-12-09 22:49:39 -08:00
Jarred Sumner
402f3353ac Make some regexes lazy 2023-12-09 22:37:25 -08:00
Jarred Sumner
73b0426596 Fixes #7400 2023-12-09 22:17:08 -08:00
Jarred Sumner
54f1f4635e Fixes #7554 2023-12-09 21:59:27 -08:00
Jarred Sumner
300d17f223 Slightly refactor Bun.file().text() control flow (#7535)
* Clean up control flow in Bun.file().* file reader

* Preallocate large files on Linux

* remove `this.wrote` field

* push

* doesnt work yet

* Create if not exists

* Fix for macOS

* Update blob.zig

* Slightly clean up this test

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-09 21:47:40 -08:00
Otger Rogla
ce63023553 fix: re-enable util.parseArgs with memory fixes (#7460)
* Fix parseArgs issues and reenable it

* Minor changes to parseArgs

* Another minor change to parseArgs

* Add exception handling to JSValue putMayBeIndex
2023-12-08 17:43:40 -08:00
dfa
59f9d2fe70 fix: Unconditionally reset stack on Bun.deepEquals exit (#7542)
* Unconditionally reset stack on deepEqual exit

* [autofix.ci] apply automated fixes

---------

Co-authored-by: evan <Evan Bergeron>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2023-12-08 17:32:27 -08:00
dave caruso
aaa827f90e fix(node:module): allow file url strings in createRequire (#7533)
* fix(node:module): allow file url strings in createRequire

* add a non-happy path test :)
2023-12-08 16:32:35 -08:00
Brady Madden
c84be8c48b fix: ws onmessage callback to return data within an object (#7529) 2023-12-07 19:05:23 -08:00
Dale Seo
1d45c1c412 docs: remove unncessary phrase (#7532) 2023-12-07 18:48:08 -08:00
Jarred Sumner
653e2934fe Fixes #7503 (#7511)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-07 02:19:11 -08:00
dave caruso
798f548607 fix(resolver): allow builtins to be imported via subpath imports (#7505)
* fix(resolver): allow builtins to be imported via subpath imports

* [autofix.ci] apply automated fixes

* Fix target

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-07 01:51:21 -08:00
dave caruso
1337bb6923 fix(create): make bun create @ org work (#7498) 2023-12-07 00:57:31 -08:00
dave caruso
b6775e2df7 fix(upgrade): print a better message on NixOS (#7489) 2023-12-07 00:56:36 -08:00
Jarred Sumner
4519f97661 Don't call read() with an empty buffer (#7509)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-07 00:55:34 -08:00
Hanaasagi
dfd4b01a97 fix(jest): fix segfault when passing jest.fn into another jest.fn (#7507)
Close: #5900
2023-12-07 00:41:31 -08:00
dave caruso
1bf540efcf feat: allow "bun:test" utilities at runtime (#7486)
* feat: allow "bun:test" utilities at runtime

* fsdafdsafd

* yippee
2023-12-06 22:09:43 -08:00
Jarred Sumner
b1c8ae97ff Rewrite IO for Bun.file() (#7470)
* WIP rewrite IO for Bun.file()

* It seems to work on macOS

* Update ffi.zig

* Handle many more cases

* Clarify this more

* More comments

* [autofix.ci] apply automated fixes

* Add empty

* Make it work in epoll

* fetch fixes + tests fmt

---------

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>
Co-authored-by: cirospaciari <ciro.spaciari@gmail.com>
2023-12-06 18:10:06 -08:00
Jérôme Benoit
6a5995e27d test(worker): refactor worker tests (#6732)
* test(worker): refactor worker tests

+ constify variables
+ typing
+ untangle web worker from worker_threads tests
+ cleanup variables namespace

no functional changes on tests

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

* test: move worker_threads related code to node/worker_threads

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

* test: move worker tests into workers directory

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

* refactor: report upstream changes

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

* refactor: report upstream change

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

* fix: address review comments

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

* chore: fix submodule

---------

Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
Co-authored-by: dave caruso <me@paperdave.net>
2023-12-06 17:06:11 -08:00
dave caruso
24ca605832 feat(test): run any test file by passing it as a path (#7483)
* feat(test): allow file paths to test specific files.

* [autofix.ci] apply automated fixes

* be less stupid about what files the CI runs as tests

* aa

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2023-12-06 08:52:12 -08:00
dave caruso
ad4b98b287 perf: make napi_create_object 2.5x faster (#7475)
* Faster napi

* Reduce number of headers exposed for JSStringDecoder

* Add missing header

* test: this test was meant to be marked as TODO

* revert the string decoder garbage

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-06 00:30:51 -08:00
Sylvain
fd1d4b4e5a Fix small typo in update.md (#7477)
* Fix small typo in update.md

* Update update.md

---------

Co-authored-by: Ashcon Partovi <ashcon@partovi.net>
2023-12-05 21:12:55 -08:00
Vlad Sirenko
f0e0c6d5df fix: improve compatibility of http.ServerResponse (#4431) 2023-12-05 16:15:16 -08:00
dave caruso
b77480758f Fix bug with syntax highlighter (#7474)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-05 15:53:44 -08:00
Dylan Conway
93d9b20974 increase (#7476) 2023-12-05 15:53:05 -08:00
Imamuzzaki Abu Salam
f303bcd997 docs: update misleading clonefile information (#7388)
* docs: update misleading `clonefile` information

* Fix macOS exception in cache module
2023-12-05 14:35:19 -08:00
dave caruso
62e1389e17 test: import describe properly
@Jarred-Sumner you forgot to import describe. this is casusing test failures on all PRs.
2023-12-05 14:22:28 -08:00
Anner Visser
b952ef8ad9 Base prelease build stage on base instead of on install (#7289)
There is no reason to have the entire install stage for the
prerelease stage. Instead use the base as base and copy
in the relevent files (which already happened)
2023-12-04 17:06:46 -08:00
Aaron Silvas
ec6339c25a Fix for building lambda runtime zip files (#7446) 2023-12-04 09:44:26 -08:00
Max Kayander
2ff788f463 Update typedarray-to-string.md (#7453) 2023-12-04 09:43:42 -08:00
Jarred Sumner
df17598026 Allow expect.extend in preload, remove "expect must be called in a test" error (#7430)
* Allow `expect.extend` in preload, remove "expect must be called in a test" error

* Bump

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-03 22:31:56 -08:00
Michael H
298a60419b Fix bun create help script (#7450)
* remove unnessary escape + fix bold

* ...
2023-12-03 22:31:36 -08:00
Jarred Sumner
2f83f32582 Update websockets.md 2023-12-02 09:30:58 -08:00
Jarred Sumner
b3bdf22ebb Handle EXDEV when saving lockfile (#7419)
* Handle `EXDEV` when saving lockfile

* Update fs.zig

* Update c.zig

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-02 08:00:35 -08:00
Jarred Sumner
d45f2dae15 Disable usage of O_TMPFILE for now 2023-12-02 06:54:33 -08:00
Jarred Sumner
67c7769ddb Make some warnings errors (#7417)
* Make some warnings errors

* Modifying CMake should trigger a rebuild...

* bring this back + fix tmpfile issue

* Add assertion + fix error

* use cast

* Handle EEXIST

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-02 06:03:14 -08:00
Jarred Sumner
03298cba70 Disable parseArgs implementation until https://github.com/oven-sh/bun/pull/7310#issuecomment-1837135393 is addressed 2023-12-02 04:29:13 -08:00
Jarred Sumner
3963d2de64 Rename async asymmetric matchers 2023-12-02 03:50:30 -08:00
Jarred Sumner
b2bf3f0dcf Handle stack overflow in binary expressions in JS Parser (#7414)
* Fix stack overflow in large files

* Add test for stack overflow

* wip

* Disable cache in debug build

* Remove our extra `captureStackTrace` call

* Update RuntimeTranspilerCache.zig

* Update RuntimeTranspilerCache.zig

* Fix issues with integer environment variables

* Add missing ref

* Add missing null check

* Update bindings.cpp

* Update transpiler-cache.test.ts

* Add version check

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-12-02 03:46:25 -08:00
dave caruso
ffe447ba5a fix(standalone): runtime dynamic imports now transpile correctly. (#7404)
* fix issue in compile

* add tests

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2023-12-02 00:42:34 -08:00
Jay Bell
7389f1b108 fix(lockfile): print yarn lockfile aliases deps with quotes (#7409)
* fix(lockfile): print yarn lockfile aliases deps with quotes

* Update src/install/lockfile.zig

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-12-02 00:42:21 -08:00
Hanaasagi
7538c20afe fix(worker): fix SIGSEGV when terminating a Worker (#7411)
Close: #7209
2023-12-02 00:39:26 -08:00
Dylan Conway
ed02691f8b Remove line truncation in logger (#7413)
* Update logger.zig

* less out of bounds
2023-12-02 00:06:02 -08:00
Ashcon Partovi
dae985ab3c Fix Location header not being cloned from Response.redirect() (#7402)
* Fix `Location` header not being cloned from `Response.redirect()`

* Fix was something else
2023-12-01 16:35:28 -08:00
Jarred Sumner
52e1c2de08 feat: syntax highlight stack traces + overall visual improvements (#7335)
* Parse stack trace string

* Syntax highlight error messages

* Fix off-by-one

* Undo changes to populateStackTrace

* Highlight more things

* Add a way to write tests for it

* Create highlight-cat.ts

* Bump

* fix: off by ones

* feat: add function highlighting to these errors

* revisions

* undo

* l

* fix webkit submodule

* imo this looks worse

* [autofix.ci] apply automated fixes

* fix off by one <3

* fix more situations

* ch changes

* ok

* [autofix.ci] apply automated fixes

* fix this

* fix snapshot

* ok

* mark test as todo

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: dave caruso <me@paperdave.net>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2023-12-01 14:02:08 -08:00
Jarred Sumner
0c532eac7b Make tsc --help 2x faster (#7365) 2023-12-01 22:56:40 +01:00
Jarred Sumner
70e57a7da0 Fixes #4876 (#7391) 2023-12-01 22:54:40 +01:00
Dylan Conway
fdece8611a Update thread_pool.zig (#7389)
* Update thread_pool.zig

* default stack size

* fix assertion
2023-12-01 02:07:13 -08:00
Zack Radisic
1147c70881 Glob fixes + optimization (#7344)
* idk why that was left out

* No need for stat call, add text for broken symlinks

* tests for crashes

* Fix test

* Add some checks to limit max open file descriptors

* Update glob.zig

* Update glob.zig

* Update scan.test.ts

---------

Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
2023-11-30 19:18:55 -08:00
mimikun
3c97f568a7 Fix typos (#7378) 2023-11-30 18:36:44 -08:00
Dylan Conway
310d0c5646 oopsies 2023-11-30 18:16:47 -08:00
Dylan Conway
d79fa7ac1a remove bun.parseargs and update docs 2023-11-30 18:04:48 -08:00
Ciro Spaciari
906ba8b2a0 fix(WebSocket) improve WebSocket Client (#7371)
* improvements

* autobahn tests

* add all tests

* check if docker is active move autobahn to a new file

* fix non SIMD UTF8 validation

* use no trim to catch utf8 issues

* fix extended payload fragmentation

* fmt

* Update src/string_immutable.zig

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

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-11-30 18:00:41 -08:00
Dylan Conway
54df5c032d createEmptyObjectWithNullPrototype 2023-11-30 16:48:53 -08:00
Otger Rogla
70039ff038 feat(parseArgs): Native implementation of parseArgs from node:util (#7310)
* Native implementation of parseArgs from node:util

* small change to validators + added some docs
2023-11-30 16:34:44 -08:00
Otger Rogla
90654143bb feat(test): expect.extend and asymmetric matcher improvements (#7319)
* bun-test expect.extend and asymmetric matcher improvements

* [autofix.ci] apply automated fixes

* Changes to expect.extend and asymmetric matchers

* expect-extend: remove global custom matchers registry

* test custom matchers: better way of storing matcher func

* made expect.arrayContaining/objectMatching reject non-arrays/non-objects

* [autofix.ci] apply automated fixes

* fixes for test changes

* create 1 wrapping function instead of 2 per each custom matcher

* fix expect.extend error messages and support for async matchers

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-11-29 23:20:25 -08:00
liqiang
bc114fb9d3 fix console.timeLog (#7089)
* fix console.timeLog

* fix console.timeLog can log arguments

* console timeLog test use bunEnv

Co-authored-by: Ashcon Partovi <ashcon@partovi.net>

* fix console timeLog test

* Update console.timeLog

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

* Update test/js/web/console/console-timeLog.js

Co-authored-by: Radhi Rasho <54078496+RadhiRasho@users.noreply.github.com>

* Update console-timeLog.js

* fix console-timeLog.js test

* fix timeLog tests due to trailing comma PR

---------

Co-authored-by: Ashcon Partovi <ashcon@partovi.net>
Co-authored-by: dave caruso <me@paperdave.net>
Co-authored-by: Radhi Rasho <54078496+RadhiRasho@users.noreply.github.com>
2023-11-29 20:07:03 -08:00
dave caruso
f3727f00dc allow migrating from npm lockfile v2 (#6695)
* allow lockfile version 2

* force save lockfile

* add migration from npm lockfilev2 test (#7370)

Co-authored-by: Alex See <alexsee@Alexs-MacBook-Air.local>

* [autofix.ci] apply automated fixes

---------

Co-authored-by: hustLer2k <61846786+hustLer2k@users.noreply.github.com>
Co-authored-by: Alex See <alexsee@Alexs-MacBook-Air.local>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2023-11-29 20:06:44 -08:00
Jarred Sumner
6389a6e24f fix: reduce noise in stack traces (#7307)
* Mark require as private

* [autofix.ci] apply automated fixes

* fix(runtime): clean up cjs + stack trace stuff

- CJS wrapper is like 200x simpler to understand. it is also 1-10% faster
- Make a few more things hidden in stack tracess. This only affects release build.

* [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>
Co-authored-by: dave caruso <me@paperdave.net>
2023-11-29 18:03:29 -08:00
Brian Knight
851b19ee0e Fix imports in run-tests example (#7368)
Adds `describe` to the import statement in a run tests example. Without this, the example does not run properly and returns an error.
2023-11-29 18:00:15 -08:00
Nick Reilingh
ebae02a08b Update file-io.md: BunFile.stream() doesn't return promise (#7372)
According to my lsp, `.stream()` returns a ReadableStream directly instead of a promise.
2023-11-29 13:44:31 -08:00
dave caruso
809266fc7a dx: clarify zig version error 2023-11-29 11:21:50 -08:00
Joey Wendt
98885279eb Fix scripts/download-zig.sh (#7364)
* fix: scripts/download-zig.sh file is not gzipped

* fix: scripts/download-zig.sh Linux x86_64 arch var
2023-11-29 00:52:59 -08:00
hustLer2k
666e615889 feat(console): Use trailing commas when printing multiline JS objects (#7334)
* feat: use trailing commas when printing multi-line objects

* test: update console-log.expected.txt to include trailing commas

* test: update a couple tests to match new object output with trailing commas

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Alex See <alexsee@Alexs-MacBook-Air.local>
Co-authored-by: dave caruso <me@paperdave.net>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2023-11-28 13:28:37 -08:00
Adrien Brault
0b99b01b0e fix: printf invalid option in download-zig (#7351) 2023-11-28 13:27:19 -08:00
Adrien Brault
eb98b61201 docs: fix macos clang-16 PATH command (#7350)
Even though I had run the export, `bun setup` was erroring with:
```
$ ./scripts/setup.sh
setup error: LLVM 16 is required. Detected CXX as '/usr/bin/clang++'
error: script "setup" exited with code 1 (SIGHUP)
```

Running `export PATH="$(brew --prefix llvm@16)/bin:$PATH"` fixed the error
2023-11-28 13:26:53 -08:00
Jérôme Benoit
a043497fb4 fix(worker_threads): do not terminate worker at parentPort closing (#7238)
* fix(worker_threads): do not crash worker at parentPort closing

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

* doc: add TODO comment as per review request

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

---------

Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
2023-11-28 11:44:01 -08:00
Sukka
f5115835da dx: fix auto install zig script (#7348) 2023-11-27 20:34:12 -08:00
Alexandre Seo
34881922c8 fix(transpiler): error when parsing keys with hyphen in some JSON files (#7316)
* Quote export aliases with hyphens when converting jsons to modules

* Add test

* Handle quotes in printer and not in bundler

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2023-11-27 20:03:53 -08:00
Jérôme Benoit
44b9960113 fix(worker_threads): make onmessageerror setter work (#7237)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
2023-11-27 19:32:24 -08:00
Bin Xin
713d72703d feat(transpiler): add jsx spread children support (#7294)
* feat: jsx spread children

* test: spread children
2023-11-27 19:30:59 -08:00
dave caruso
383a615d21 dx: automatically install and update zig (#7305)
* dx: automatically install and update zig

* update repo

* ensure system zig compiler in ci

* a

* b

* good

* i am stupid

* why did this happen

* fix installer
2023-11-27 17:27:01 -08:00
Jarred Sumner
6ee42f7719 Fixes #7324 (#7330)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-27 12:12:55 -08:00
James Anderson
1840de3661 feat(test): toHaveBeenNthCalledWith + improve some fail messages (#7320)
* feat(test): `toHaveBeenNthCalledWith` + improve some fail messages

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2023-11-26 15:59:44 -08:00
Steven Almeroth
6aa1319fd9 fix typo (#7327) 2023-11-26 15:59:19 -08:00
Jarred Sumner
6a7b1a3208 Clean up lifetime handling for napi_create_string_utf16 (#7311)
* Clean up lifetime handling for `napi_create_string_utf16` and `napi_create_string_latin1`

* Fix `napi_create_arraybuffer`

* Update globals.d.ts

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-26 15:59:03 -08:00
Jarred Sumner
5c23d670a3 Fix bug with readable streams that have been detached (#7308)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-26 02:11:42 -08:00
Jarred Sumner
22818e6806 Fix assertion failure when Worker is shutting down 2023-11-25 02:15:53 -08:00
Michael H
0abe3745d2 Add import.meta.env to bun-types (#7309)
* Add `import.meta.env` to `bun-types`

* add type to codeblock
2023-11-24 22:04:20 -08:00
DidaS
ea0ffde991 Update docs (#7193) 2023-11-24 21:25:37 -08:00
Sam
194294f5b5 fix(node:fs): fix fs.promises.opendir not having a path property (#7292)
Closes #4995
2023-11-24 19:11:45 -08:00
Jarred Sumner
7f10622a84 Implement recursive option in fs.readdir (#7296)
* Implement `fs.readdir(path, {recursive: true})` and `fs.readdirSync(path, {recursive: true})`

* Update node_fs.zig

* FIx memory leak in error code

* Add fail test

* Update readdir.mjs

* Update bun.zig

* Update readdir.mjs

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-24 19:08:07 -08:00
Jarred Sumner
a71a9e3447 Fix warning 2023-11-24 18:49:59 -08:00
Ciro Spaciari
53ee2d77b2 fix(crypto) oneshot Sign and Verify (#7256)
* WIP

* native oneshot sign

* add native verify

* fallback rsa to non-native

* WIP der dsaEncoding

* pass encoding

* RSA-PSS padding and saltLength

* oopies

* improve RSA-PSS support

* accepts hash identifiers like nodejs and add options.hashAlgorithm support

* fix string check

* tests

* define hash for ECDSA

* fix compilation
2023-11-24 18:43:17 -08:00
WingLim
3d58437fc8 fix(Response): single Content-Range in http response (#7199)
* fix: only write header if not exist

If user set header by himself, then we not write duplicate header.

* feat: add test to check header

* chore: format code
2023-11-24 18:29:52 -08:00
Michael H
6517252153 Environment Variables (#7306)
* Environment variables

* .
2023-11-24 18:25:34 -08:00
James Anderson
5f86b839b4 feat(test): toHaveBeenCalledWith and toHaveBeenLastCalledWith (#7277) 2023-11-24 18:24:21 -08:00
Jarred Sumner
5692f82aaf Delete bun_dev_http_server.zig (#7283)
* Rename http_client_async -> http

* Delete bun_dev_http_server.zig

* update these

* [uws] Add method for getting SO_ERROR

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-24 18:21:56 -08:00
Dylan Conway
93714292bf require bun:test (#7276) 2023-11-23 01:12:03 -08:00
Jarred Sumner
0766fb5ae8 Fix assertion failure in mocks 2023-11-23 00:54:12 -08:00
Dylan Conway
e83a9132d5 fix duplicate workspace bug (#7281)
* fix duplicate workspace dependency bug

* dedupe workspace names from package json

* more tests

* Update bun-install-registry.test.ts

* make sure workspace path entry is assigned

* Update bun-install-registry.test.ts

* Update bun-install-registry.test.ts
2023-11-22 22:18:27 -08:00
Jarred Sumner
bc4146295f Update nav.ts 2023-11-22 16:13:41 -08:00
Jarred Sumner
d8be3e51b4 Support glob.scan(string) (#7279)
* Support `glob.scan(string)`

* Create glob.md

* Update glob.md

* fixup

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-22 16:12:28 -08:00
Zack Radisic
6ba4e950cc Add Bun.Glob (#6861)
* initial glob impl

* Add `Bun.globMatch`

* Glob boilerplate setup

* Experiment with Rust glob implementation

* Rust impl is slow revert

* Setup glob walking

* Basic glob walker working

* Fix segfault

* Recursive directory traversal

* Fix glob match non-ascii

* Make faster lil bit

* use arena

* ASCII fast path

* Experiment with packed codepoint cursor

Results in ~4% perf boost if the glob pattern needs to create/manipulate cursors (for example when the pattern uses braces)

* Try converting to u32 array

Made it pretty slow

* Lazily create codepoint buffer

* Different walk algorithm

* Fast path optimizations

* Add `dot` option to `Glob`

* .

* Fix some bugs

* Fix bug, clean up lil bit

* Windows fix

* Non absolute paths

* use specific version of fast-glob for benchmarks and tests

* .

* Fix some stuff

* Fix more stuff

* Add `hasPendingActivity()` to glob

* accident

* Symlinks

* fast-glob e2e tests

* remove

* woops

* Fix relative paths

* Fix absolute

* add test for `onlyFiles`

* Fix invalid surrogate pairs problem

* Rename: `match/matchSync` -> `scan/scanSync` and `matchString` -> `match`

* forgot to close cwd fd

* Update types

* Add stress test

* Port `micromatch` / `glob-match` / `globlin` tests

* fix stale reference arena thing

* stupid bug

* Add builtins to classes code generator and add `Glob.scanIter()`

* all iterables

* generate fixtures, remove from git

* fix test

* Fix

* woops on test

* Fix stuff

licenses

license

`has_pending_activity` to usize

cwd threadSafe fix atomic compile errors

`GlobWalker` own `cwd`

Fix windows path and absolute test

stuff

* Fixes

* Fix stuff

* Use Syscall.close

* Use private symbols for underlying scan functions to preevent misuse

* Update types

* Fix build for zig

* Fix tests

* Fix more tests

* Prevent these tests from GC'ing too much

* Make this benchmark work in Node and Bun

* Fix memory leak

* Add leak test

* Fix windows

* comment about arena allocator use for glob walker

* Make leak test run in separate process

* Iterator api for glob

* GlobWalker.Iterator

* fix leak test

* Remove old impl

* filter functions wip start

* stuff

* wip lockfile use glob

* glob working with lockfile

* revert lockfile changes

* Update bun.lockb

* Manually set to cwd to prevent test failing on linux CI

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-22 14:26:09 -08:00
Jarred Sumner
81067477dc Load *.{m,c}ts{x} last in node_modules (#7259)
* Load `.{m,c}ts{x}` last in node_modules

* feat(console.log): Print className for an object if present (#6508)

* feat(console-log): fix className not printed for objects that are instances of classes

Uses getClassName native method instead of getName

* test(console-log): objects with class names are printed correctly

* test(esbuild): add class name to log message

* Fix failing `which` test (#7258)

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

* Make test less flaky

* Get it working and add test

* Handle relative paths

* Add comment

* Consolidate + add test

* Bump

* Fix getObjectName

* Update dir_info.zig

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Jibran Kalia <jibran.kalia@gmail.com>
2023-11-22 14:11:35 -08:00
Jarred Sumner
d8ca6ca699 Make test less flaky 2023-11-21 18:56:14 -08:00
Jarred Sumner
05ef3329c4 Fix failing which test (#7258)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-21 18:10:21 -08:00
Jibran Kalia
ab93f9f74e feat(console.log): Print className for an object if present (#6508)
* feat(console-log): fix className not printed for objects that are instances of classes

Uses getClassName native method instead of getName

* test(console-log): objects with class names are printed correctly

* test(esbuild): add class name to log message
2023-11-21 17:39:00 -08:00
Dylan Conway
8db407e9a7 make tmpdir more random (#7243)
* make tmpdir more random

* 100
2023-11-21 14:29:35 -08:00
Dylan Conway
5eb6f83251 fix test :( 2023-11-21 12:34:36 -08:00
Jarred Sumner
1b8d7d5cb1 Update base64 library (#7220)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-20 15:12:31 -08:00
Jarred Sumner
bf32d36e4c Cleanup how build errors are displayed slightly (#7223)
* Cleanup error formatting a little

* Add error for using import statement with CommonJS-only features

* Update js_ast.zig

* Further tweaks to formatting, also print error.cause

* Add some snapshot tests for errors

* Make these snapshot tests

* Ignore mimalloc warnings

* Update error message parsing in bundling tests

* Increase timeout on the test

* Update expectBundled.ts

* Update test

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-20 15:07:13 -08:00
Anton Golub
e9661c2953 fix(process): enable SIGKILL and SIGSTOP mappings (#7172)
* fix: enable SIGKILL -> 9 mapping

* fix: enable SIGSTOP -> 18 mapping
2023-11-20 14:11:46 -08:00
Jérôme Benoit
0b66fd643e fix: test for make presence in the buildsystem (#7234)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
2023-11-20 09:12:24 -08:00
Liz
778bad9dfd fix(Bun.serve): return EACCESS when we don't have perms (#7191)
* fix(Bun.serve): return EACCESS when we don't have perms

The error reported to js land when listening fails was always the same,
this adds a second one for EACCESS when we are not the super user.

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

* fix: adjust code to be only ran on linuz

* fix: correct typo

* fix: remove comment since its linux only now
2023-11-19 10:38:33 -08:00
Jarred Sumner
ef8b9efaa4 Fixes #7201 2023-11-18 22:24:49 -08:00
Jarred Sumner
864d59f822 Add missing JSC debug build flag 2023-11-18 21:04:45 -08:00
Dylan Conway
f5bf67bd1b choose correct resolved package for peer dependencies (#7192)
* fix sometimes failing install test

* loop to make sure it happens
2023-11-17 19:15:47 -08:00
Ashcon Partovi
075c09401a Output verbose logs when running in Github Action with debug mode (#7183) 2023-11-17 18:19:29 -08:00
Ciro Spaciari
c23579d66c feat(http2) Client Support (#6761)
* init

* WIP fix post data/refactor

* make it compile again

* more things

* undo padding and continue + fix posting + update lshpack

* re-add fixes

* really simple tests + fixes

* add aborted event

* fix trailers

* add getDefaultSettings, getPackedSettings and getUnpackedSettings

* fix + fmt

* fixes

* fix enablePush o be boolean

* fix sendTrailers

* fmt

* fix goaway, fix some error messages

* oops

* revert some changes

* more reverts

* WIP

* get CMAKE building lspack + ping behavior

* remove files that should not be added anymore

* remove old out files

* remove old file

* fix header reduce

* bunch of fixes

* fix socket unref

* fix abort signal, rebase and fmt

* socket unref tests

* oops re-add cmake

* fix stream state

* more tests and fixes

* fixes and ping tests

* lshpack in Dockerfile

* just copy lshpack

* oops

* fix end

* wantTrailers

* encode/decode fixes + grpc

* channel credentials test

* rebase

* support h2c

* fix h2c

* fix h2c connect event + h2c tests

* 'copy ls-hpack

* ls-hpack build sh

* oops

* changing CMake + Docker

* add ps1 build for ls-hpack fix clean

* optimizations + fixes

* remove protect/unprotect from handlers

* more consistent errors

* fix error code

* oops

* add goaway tests

* oops uncoment tests

* better errors more tests

* add broken priority frame

* better memory leak, some fixes and less flask tests

* zig update .Big -> .big

* closer threshold + h2 fix

* remove log

* test should not be flask

* increase timeout on leak memory test

* windows build

* less flasky

* always 127.0.0.1

* [autofix.ci] apply automated fixes

* remove .call and use primordials

* apply socket fix

* fix win-build

* should properly mark inactive

* postgres fix

* increase deadline

* test tests

* high light deadline timeouts

* event loop test

* make memory leak test faster

* use buffer on payload test

* check for socket.data before use

* reduce iterations to see if timeout on mac intel

* fix assertions

* avoid localhost and simplify things

* refactor memory leak test

* Update src/js/node/tls.js

* fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: cirospaciari <ciro.spaciai@gmail.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-17 18:14:54 -08:00
Jarred Sumner
6c200c089c Tweak napi PR (#7177)
* Fix assertion failure

* Fix the test

* Fix assertion failure

* Update bun.lockb

* Add node-gyp

* Update CMakeLists.txt

* Update napi.test.ts

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-17 17:00:44 -08:00
Mike Dotty
3eb086f5fa fix(dx): Stop swallowing errors from create_hash_table during the build (#7110)
* Stop swallowing errors from create_hash_table during the build

If src/codegen/create_hash_table can't be run due to some reason
(e.g. due to missing Math::BigInt Perl module) the build continues
but fails later, during bindings compilation, because the generated
files are empty.

Fix it by handling the failure to run create_hash_table properly.

Closes #7074

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2023-11-17 13:45:32 -08:00
DidaS
fbff18a723 fix(types): Change Bun.serve types to allow void when using websockets (#7160)
* `Response` -> `any`

* Revert previous commit & allow void in ws fetch

* Added type test to check if you can upgrade connection without returning

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2023-11-17 05:34:05 -08:00
Olivier Guimbal
6e7014c91b Fix napi_get_value_string_utf8 to match node (#7175)
* fix napi_get_value_string_utf8 to match node
closes #6949

* [autofix.ci] apply automated fixes

* Update test/napi/napi.test.ts

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

* Update test/napi/napi.test.ts

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

* [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>
2023-11-17 05:27:58 -08:00
Jarred Sumner
711ea1604b Set umask once (#7176)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-17 05:08:25 -08:00
Jarred Sumner
538a243453 Bump! 2023-11-17 04:12:08 -08:00
Dylan Conway
8be492c080 fix require transpile (#7170)
* bounds checks

* do this all the time

cc @paperdave

* use length of string

* ttest

* min

* can't prefix if length isn't at least equal

* substring

* Update pretty_format.zig

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-11-17 04:10:50 -08:00
jhmaster
6c7a0e5a79 node:util core-js compat. fix (#7101)
* node:util: fix compatibility issue with corejs
2023-11-17 09:10:32 -03:00
Jarred Sumner
f4d14c02c7 Implement process.report.getReport() (#7171)
* Prevent assertion failure

* Implement process.report.getReport()

* Update process.test.js

* }

* Update BunProcess.cpp

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-17 03:35:35 -08:00
Dylan Conway
3ca2d8ae5e ensure .bin folder is created before linking binaries (#7166)
* bin might need to be created after iterating node_modules

* Update bun-install-registry.test.ts

* test this functionality in a few more tests

* fix a test

* another test

* revert

* more test
2023-11-16 23:54:49 -08:00
Jarred Sumner
c23aed993f Update pull_request_template.md 2023-11-16 23:52:27 -08:00
Jarred Sumner
11e07caaa4 Update pull_request_template.md 2023-11-16 23:52:19 -08:00
Jarred Sumner
e4de49df2a Update pull_request_template.md 2023-11-16 23:51:28 -08:00
Jarred Sumner
47e1fbe468 Update pull_request_template.md 2023-11-16 23:50:09 -08:00
Jarred Sumner
8353ba7857 Update pull_request_template.md 2023-11-16 23:50:02 -08:00
HK-SHAO
606c80b049 Fix the TypeError of isValidTLSArray for http (https://github.com/oven-sh/bun/issues/7153) (#7154) 2023-11-16 23:41:19 -08:00
Jarred Sumner
d1436e3ecc Support Object.create in Stats within node:fs (#7168)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-16 23:39:10 -08:00
Jarred Sumner
7e0e007e3e Fix bug where with statements do not trigger CommonJS (#7167)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-16 23:37:22 -08:00
Ashcon Partovi
2e74f7f079 Properly handle errors from posix_spawn (#7163) 2023-11-16 21:02:13 -08:00
Jarred Sumner
2c81c2a13f Fix crash due to isEmpty check checking only size and not capacity 2023-11-16 19:37:14 -08:00
Jarred Sumner
d9a0fd4f59 Don't allocate new "require" and "resolve" strings in CJS modules (#7162)
* Don't allocate new `"require"` and `"resolve"` strings in every CommonJS module

* Use builtinNames more

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-16 15:10:27 -08:00
Mathias Wulff
d1ec8f86f3 Add license to bun-types (#7149) 2023-11-16 09:18:46 -08:00
Dylan Conway
85c997513d node modules bin directory fix (#7151)
* place binaries in `.bin` of package node_modules

* test

* fix tests
2023-11-15 22:44:44 -08:00
Mike Dotty
904134cc75 Handle whitespace in no_proxy environment variable (#7072)
De facto standard format of no_proxy enivronment
variable allows whitespace around the host names.
Make it work.

Closes #6339
2023-11-15 21:55:31 -08:00
Alex Kwiatkowski
15e4f1bad3 fix typo in help menu (#7150) 2023-11-15 21:19:38 -08:00
Jarred Sumner
09b8b6b468 Bump! 2023-11-15 19:41:00 -08:00
Jarred Sumner
4dfc7feae0 Reorder the flags 2023-11-15 19:17:10 -08:00
Jarred Sumner
77e6b946f4 Support using bultin functions in macros (#7113)
* `zig fmt`

* Support using macros in builtins

* Make fetch work a little better in macros

* Delete a bunch of code

* Update macro-test.test.ts

* Update macro-test.test.ts

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-15 18:25:27 -08:00
Colin McDonnell
31814934f3 CLI flags (#6395)
* WIP

* WIP

* Improve helptext

* WIP

* WIP

* WIP

* WIP

* Clean up, implement warn_on_unrecognized_flag

* Fix struct

* Tweaks

* Fix bunx test

* Address reviews

* Init and create

* Updates

* bunx

* Tweaks

* Lockfile

* tweak

* tweak

* tweak

* tweak

* Remove comments

* Add back origin and port

* Remove logging

* Updates

* fmt

* fix rebasing mistakes

* bruh

* expose node builtins for -e

* add tests and fix it on windows

* a

* lol

* okay

* finish things up

* Update src/deps/zig-clap/clap/streaming.zig

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

---------

Co-authored-by: dave caruso <me@paperdave.net>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-11-15 18:15:10 -08:00
Jarred Sumner
b43a8b54cf Implement expect.unreachable(msg?: string | Error) (#7131)
* Implement `expect.unreachable`

* UIse expect.unreachable() in some tests

* Use more unreachable

* More unreachable

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-15 16:14:13 -08:00
Pierre-Mike
a165306fd9 Update gitignore-for-init removing duplicate .cache pattern (#7133)
'.cache' pattern is defined more than once
2023-11-15 09:19:12 -08:00
Hanaasagi
056d45cf6b fix(install): fix the case that package scope contains tilde. (#7049)
* fix(install): fix the case that package name contains tilde.
Close: #7045

* add tests

* emm, let me know why test failed

* overwrite registry config

* check more chars

* remove $
2023-11-15 01:31:31 -08:00
Dylan Conway
46955e95ef migration without resolved properties (#7123)
* packages without `resolved` properties

* test

* free more

* find registry scope
2023-11-14 23:17:59 -08:00
Jarred Sumner
e6e4ffb4ae Fixes #6789 (#7129)
* `zig fmt`

* Fixes #6879

* Update bun-test.d.ts

* More tests

* Bump WebKit

* [autofix.ci] apply automated fixes

* woops

---------

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>
2023-11-14 21:00:28 -08:00
Jarred Sumner
5946e13e27 Fixes #7035 2023-11-14 20:18:04 -08:00
Anton Golub
8f3e278ab9 Add stubs for zlib.brotli* (#7096) 2023-11-14 08:52:42 -08:00
Ashcon Partovi
547ed6d74d Add workflow that fixes PRs that do not match formatting (#7098) 2023-11-14 08:51:19 -08:00
Jarred Sumner
d4adcb3ccf Update zig version (#7103)
* Update zig version

* Update Dockerfile

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-14 02:34:18 -08:00
Jarred Sumner
d4628992d8 Fixes #6929 (#7059)
* Fixes #6929

* TIL macOS symbols are case insensitive

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-14 02:14:11 -08:00
Jarred Sumner
24b4b2c16d Remove unnecessary unprotect() call causing assertion failure 2023-11-14 02:06:40 -08:00
Jarred Sumner
35bac672bb Make globalThis.crypto.subtle = 123 do nothing 2023-11-14 01:46:46 -08:00
Jarred Sumner
d649f69404 Add a test for expect() no arguments called repeatedly 2023-11-14 01:32:16 -08:00
Jarred Sumner
7ce5061343 Make a test less flaky 2023-11-14 01:20:41 -08:00
Jarred Sumner
20d9e25ae2 Fix hang introduced in #6991 (#7104)
This causes keep-alive to be disabled for HTTP status codes that do not support bodies, leading to many HTTP client hangs.

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-14 01:14:56 -08:00
Jarred Sumner
89c76f2b45 Fixes #6604 2023-11-14 00:55:19 -08:00
Jarred Sumner
a9a68c3143 Allow a longer timeout in this potentially flaky test 2023-11-13 22:25:13 -08:00
Jarred Sumner
d1c1c8fb5f Fix flaky test 2023-11-13 22:16:34 -08:00
Jarred Sumner
4228ecea98 [Guides] Suggest actions/checkout@v4 2023-11-13 22:15:36 -08:00
Jarred Sumner
909a821d3d [CI] Disable assertions build for now 2023-11-13 22:15:13 -08:00
Jarred Sumner
7a4e0158d6 Lots of stuff (#7027)
* Use debug mode by default

* Enable build with assertions enabled

* Update cli.zig

* Update bun-linux-build.yml

* Fixes

* Fix `ASSERT_ENABLED`

* try this

* Update Dockerfile

* mimalloc debug

* Update CMakeLists.txt

* `Bun.deepMatch` - fix assertion failures

cc @dylan-conway, looks like we need to use `putDirectMayBeIndex` and check for `isCell` more carefully.

* Object.create support in code generator and callbacks wrapper

* Remove unused file

* zig upgrade

* zls

* Fix various errors

* Support `BuiltinAccessor` in create_hash_table script

* Fix assertion failure in `process.mainModule`

* Fix assertion failure in `onerror`

* Fix assertion failure when creating a Worker

* Fix asssertion failure when loading lots of files in bun test

* Fix assertion failure when termating a `Worker`

* Add helper for converting BunString to a WTFString

* Fix assertion failure in notifyNeedTermination

* Add more debug logs in `bun test`

* Fix compiler warning in usockets

* Fix assertion failure with `Worker` termination (another)

* Fix assertion failure in `coerceToInt64`

* Fix assertion failure in `BroadcastChannel`

* Fix assertion failure in `Headers.prototype.getAll`

* Fixes #7067

* Add heap analyzer label for CommonJS modules

* Fix assertion failure in module.require && module.require.resolve

* Remove unused code

* Fix assertion failure in debugger

* Fix crash in debugger

* Fix assertion failures in bun:sqlite

* Bump zig

* Bump WebKit

* Fix assertion failure in JSPromise::reject && JSInternalPromise::reject

* Fix assertion failure in ReadableStream::cancel

* Fix assertion failure in AsyncContextFrame::create

* Fix assertion failure in bun:sqlite

* Fix assertion failure in mocks

* Fix assertion failure in ServerWebSocket.close

* Fix assertion failure in N-API with subclasses

* [napi] Make promises cheaper

* undo

* Don't check for exceptions in ObjectInitializationScope

* Add separate entry point for test runner that doesn't generate code

* Don't deref builtin code

* Fix preload test

* Fix assertion failure in memoryUsage()

* Fix preload test, part 2

* Ensure that the env map for a Worker is empty after it is used

* The pointer for the Arena allocator used in parsing should not change

* Terminate thread on exit

* Start to implement scriptExecutionStatus

* Update worker.test.ts

* Fix Dirent.name setter

* Update settings.json

* Fix assertion failure in node:http

* Use correct value for `JSFinalObject::maxInlineCapacity`

* JSFinalObject::maxInlineCapacity x2

* Don't strip when assertions are enabled

* Make `m_wasTerminated` atomic

* Preserve directives in the transpiler

cc @ctjlewis

* Workaround assertion failure in ServerWebSocket.sendBinary and ServerWebSocket.sendText

* windows

* Buffer lockfile serialization in-memory

* PR feedback

* PR feedback

* PR feedback

* Windows

* quotes

* Update CMakeLists.txt

* Update bun-linux-build.yml

* Update bun-linux-build.yml

* Move this code to BunString.cpp

* Update BunString.cpp

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-13 22:10:09 -08:00
Zack Kollar
228bfbd24a Install the deps from test during the setup.sh script (#7047) 2023-11-13 17:26:57 -08:00
Ashcon Partovi
45e1bc3a21 Revert "Stop swallowing errors from create_hash_table during the build (#7086)" (#7097)
This reverts commit e1489d4fe3.
2023-11-13 14:42:25 -08:00
Mike Dotty
e1489d4fe3 Stop swallowing errors from create_hash_table during the build (#7086)
If src/codegen/create_hash_table can't be run due to some reason
(e.g. due to missing Math::BigInt Perl module) the build continues
but fails later, during bindings compilation, because the generated
files are empty.

Fix it by handling the failure to run create_hash_table properly.

Closes #7074
2023-11-13 13:46:20 -08:00
Ciro Spaciari
273f612c77 fix(async_hooks) fix disable and disable test (#7090)
* fix disable

* test should fail on exception

* oops
2023-11-13 13:21:27 -08:00
Otger Rogla
a82b2b2d04 support import.meta.env (#7094) 2023-11-13 12:37:20 -08:00
Shah Bakhteyar Haider
bf767b53d7 Update CI/CD guide (#7050)
* Update CI/CD guide

The guide at https://bun.sh/guides/runtime/cicd shows an outdated example for specifying a version of Bun.
It currently shows "version" and it should be updated to "bun-version".

* Add more examples in CI/CD guide
2023-11-13 09:54:03 -08:00
Juan A
1db1941577 Remove bad escaping from .gitignore in bun init (#7056)
Closes #7036
2023-11-13 09:37:42 -08:00
Mike Dotty
49f86c87b4 Refresh dependencies in contribution guide (#7087)
- move dependencies installation to the front, as the next steps
  depend on them
- add missing xz-utils, which, libicu-devel to the dependencies

Closes #7076
Closes #7077
2023-11-13 09:33:57 -08:00
cdfzo
346e27083f Fix typo in bundler docs (#7085) 2023-11-13 02:43:13 -08:00
Jarred Sumner
6d666da4b9 Update schema after env file change (#7061)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-11 21:08:08 -08:00
Jarred Sumner
feca0c2647 Delete unused files (#7060)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-11 21:07:56 -08:00
Jarred Sumner
bf806602d8 Update .gitattributes 2023-11-11 19:55:27 -08:00
Jarred Sumner
e3ab7408c9 Update .gitattributes 2023-11-11 19:39:56 -08:00
Jarred Sumner
c49a5a7d7d When getting properties, treat undefined the same as though the property was not defined (#7048)
It works this way in JS.

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-11 05:06:24 -08:00
Otger Rogla
450397a277 Fix fetch response skipping body if no content-length (#6932) (#6991)
* Fix fetch response skipping body if no content-length (#6932)

* Fix timeout on status 1xx/204/304 without content-length, tests changes

* Fix test that was wrong

* fix fetch response without content-length not disabling keep-alive

---------

Co-authored-by: Ashcon Partovi <ashcon@partovi.net>
2023-11-11 02:22:05 -08:00
Antonin CLAUZIER
f63eba952e Fixes output path for build command (#7026) 2023-11-11 02:13:23 -08:00
Otger Rogla
eaa9ba99fa add support for --env-file arg to bun run to load custom env files (#7032) 2023-11-11 02:10:47 -08:00
Ashcon Partovi
f0cbc79d8b Implement server.url (#7043)
* Implement `server.url`

* Fix memory leak
2023-11-10 23:00:27 -08:00
Lorenzo Donadio
01e0136d7c fixed small typo in allow_in_out_variance_annotations (#7030) 2023-11-10 15:17:08 -08:00
Joseph Yu
520845217e Fix toBeNaN's misleading JSDoc comment (#7019) 2023-11-10 11:25:08 -08:00
Brett Goulder
42d8a0b44b Fix util.formatWithOptions typings. (#7002) 2023-11-10 03:29:02 -08:00
Meghan Denny
84414f8fe8 fix fs.read being passed to util.promisify (#6999)
* fix fs.read being passed to util.promisify

* Update test/js/node/fs/fs.test.ts

* Update test/js/node/fs/fs.test.ts

* Update src/js/node/fs.js

* Fix write, add more tests, clean up the code

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-09 20:00:41 -08:00
Ciro Spaciari
046d197519 fix asyncLocalStorage disabled (#7015) 2023-11-09 17:51:49 -08:00
Dylan Conway
1250655ddb check for empty in JSValue.jsType (#7000)
* check for empty

* better comment

* move empty check to before `jsType()`

* Update src/bun.js/test/jest.zig

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-11-09 14:17:22 -08:00
dave caruso
29b1a4f61b fix(ffi): fix ffi with large uint32_t values (#7009)
* fix(ffi): fix ffi with large uint32_t values

* clean up
2023-11-09 12:02:20 -08:00
Ciro Spaciari
2d5698c719 fix(node-fetch) Set-Cookie key on node-fetch.raw() should be set-cookie instead of Set-Cookie to match nodejs behavior (#7011)
* fix set-cookie header name

* add test

* fix test

* fix test to match nodejs behavior

* oops
2023-11-09 11:59:20 -08:00
Meghan Denny
c08e8a76ef don't pass script flags to pre- or post- scripts (#6997) 2023-11-08 17:44:15 -08:00
MuhibAhmed
03298eb8dd Update edgedb.md (#6985)
Small fix
2023-11-08 04:41:12 -08:00
Jarred Sumner
a86a57e1b8 Update semver.md 2023-11-08 04:40:07 -08:00
Jarred Sumner
45f2eac44c Add a doc on Bun.semver 2023-11-08 04:32:29 -08:00
Jarred Sumner
b05e753c9f Add microbenchmark for Bun.semver 2023-11-08 04:03:48 -08:00
Dylan Conway
f7f6233ea8 fix semver edge cases and buffer used for prerelease comparisons (#6981)
* use different buf for group and manifest versions

* tests

* tests for installs that should fail

* allow `<=<prerelease-version`

* `Bun.semver.satisfies`

* one

* stringify

* symbol tests

* deinit

* arena

* more tests

* fix test

* version always on the left

* `Bun.semver.order`

* handle more edge cases, more tests

* whitespace

* more
2023-11-08 03:36:17 -08:00
Jarred Sumner
6d5c513195 Fixes #6200 (#6983)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-08 03:28:57 -08:00
Jarred Sumner
131b96bbba Fix debug build crash 2023-11-07 23:26:22 -08:00
Jarred Sumner
b7587b76e0 Revert "fix: correctly prepend system path to relative urls on pathToFileURL (#6472)"
This reverts commit 8130d9f3e1.

This fixes https://github.com/oven-sh/bun/issues/6953
2023-11-07 19:04:25 -08:00
Jarred Sumner
ee43932189 Update CMakeLists.txt 2023-11-07 19:02:32 -08:00
Jarred Sumner
9082193568 Add missing raw method to node-fetch polyfill (#6976)
* Add missing `raw` method to node-fetch polyfill

* Update node-fetch.ts

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-07 16:58:48 -08:00
Jarred Sumner
b52e503ce4 Fixes #6973 (#6975)
Fixes #6973

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-07 16:42:25 -08:00
cirospaciari
e581f732d7 callback instead of trhowing 2023-11-08 00:21:24 +01:00
cirospaciari
c939ec1544 change sinon version to match jsonwebtoken tests 2023-11-08 00:21:24 +01:00
cirospaciari
a2f2ed5411 less flasky test utils 2023-11-08 00:21:24 +01:00
cirospaciari
55f636ffb8 fix reference error 2023-11-08 00:21:24 +01:00
cirospaciari
cbba20804e revert 2023-11-08 00:19:49 +01:00
cirospaciari
91c2edc0f2 really fix 2023-11-08 00:19:49 +01:00
cirospaciari
09a4d864da better test name 2023-11-08 00:19:49 +01:00
cirospaciari
11e7937c3c cleanup 2023-11-08 00:19:49 +01:00
cirospaciari
22a7e3a310 clean read before handshake 2023-11-08 00:19:49 +01:00
Jarred Sumner
4fbde727d2 Revert d1244c8b1f
This fixes #6954 and adds a test. `DOMAttribute` ensures the `this` value of getters are always set.
2023-11-07 04:22:44 -08:00
Jarred Sumner
990ca9cb9d the real fix 2023-11-07 13:19:58 +01:00
Jarred Sumner
21e32c042e Speculative fix for #6951 2023-11-07 13:19:58 +01:00
Dylan Conway
d85bd49d87 remove error 2023-11-07 07:55:01 +01:00
Dylan Conway
c0853959c2 cleanup tests 2023-11-07 07:55:01 +01:00
Dylan Conway
fef7920b17 Revert "split('||'), fix up tests"
This reverts commit 5fd09153cd.
2023-11-07 07:55:01 +01:00
Dylan Conway
b5a04827e1 split('||'), fix up tests 2023-11-07 07:55:01 +01:00
Dylan Conway
bb5d6fff77 count might be zero for alias 2023-11-07 07:55:01 +01:00
Dylan Conway
8d3a0ddd47 another test 2023-11-07 07:55:01 +01:00
Dylan Conway
75aa963fef test for invalid version 2023-11-07 07:55:01 +01:00
Dylan Conway
b0126b5962 remove &, mark skip tests as todo 2023-11-07 07:55:01 +01:00
Dylan Conway
a7251047b7 allow no spaces 2023-11-07 07:55:01 +01:00
Dylan Conway
2f301e8404 skip tags in version ranges 2023-11-07 07:55:01 +01:00
Jarred Sumner
3fae8933e5 Bump 2023-11-06 21:41:47 -08:00
Jarred Sumner
c3a7b574c8 Update sys.zig (#6942)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-06 18:05:46 -08:00
Paul Baumgart
fa25d60df8 fix: remove stray semicolon that causes sqlite3_compileoption_used to always return true on Mac (#6941) 2023-11-06 16:52:40 -08:00
Liz
8130d9f3e1 fix: correctly prepend system path to relative urls on pathToFileURL (#6472)
* fix: correctly prepend system path to relative urls on `pathToFileURL`

The `pathToFileURL` was not handling the case that when a relative link is passed,
it should convert it to a absolute url and prepend the top_folder,
or otherwise described, resolve the path before creating the url.

This does that by calling into buns Path api and using its `resolve` function.

Theres the detail that i used preprocessor directives to determine whether
we are on windows because there does not seam to be a easy way to get that
at runtime in the `BunObject.cpp` file.

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

* fix: add issue id to test name

* fix: implement changes requested in review

* style: fix styling

* Update src/bun.js/bindings/BunObject.cpp

* Update src/bun.js/bindings/BunObject.cpp

* Update src/bun.js/bindings/BunObject.cpp

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-11-06 13:57:25 -08:00
Jarred Sumner
3ba9647858 Fix a couple bugs with node:http (#6924)
* Update to latest SIMDUTF

* Fix issue with `Headers.toJSON` having an incorrect size set with set-cookie header

* [node:http] Fix `undefined` when multiple Set-Cookie headers are sent

* Count UTF8 byteLength for headers

This is not necessary, just being cautious.

* Update http-hello.node.mjs

* Be 100% sure the test isn't caching anything

* move this up

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-06 03:51:49 -08:00
Jarred Sumner
c77c6ea53e Update settings.json 2023-11-05 03:35:20 -08:00
Jarred Sumner
98f20170a3 Add more tests for Bun.spawn lifecycle and address edgecase (#6904)
* FIxup spawn ref / unref

* Fix test failures

* Add test for #3480

* windows

* 🪟

* Skip on linux

* Fix test

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-05 00:00:19 -07:00
Jarred Sumner
e954bce301 Fix test 2023-11-04 16:19:38 -07:00
Jarred Sumner
8554683297 Fix build 2023-11-04 16:11:42 -07:00
Dylan Conway
5d1a7d8d5a Spawn ref count (#6890)
* fix(Bun.spawn): Fix integer overflow from unref()

* rewite

* has disable flag

* tests

* packed

* remove comments

* make tests more smarter

* unref

* another test

* kevent timeout 0

* possibly fix MacOS x64 baseline action

---------

Co-authored-by: dave caruso <me@paperdave.net>
2023-11-04 15:21:37 -07:00
dave caruso
39101d16c3 fix: baseline+linux arm64 builds (#6873)
* Fix the linux aarch64 workflow.

* sanity check

* do not set march to native

* fix windows compile error

* enable verbose

* fix baseline builds

* fix windows build canary flags

* use a real windows runner

* w
2023-11-03 21:35:52 -07:00
Jarred Sumner
e7a83ad70e Fix edgecase from eeb3f7be18 (#6870)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-03 02:58:57 -07:00
Dylan Conway
142cdf1714 more install tests (#6867)
* some tests

* Apply suggestions from code review

* Update src/install/install.zig

* `zig fmt`

* Update install.zig

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-03 02:37:03 -07:00
Jarred Sumner
2d4011b22f Fix clang warnings in usockets
cc @cirospaciari
2023-11-02 23:53:09 -07:00
Dylan Conway
eeb3f7be18 fix jsx key parse and visit order (#6866)
* jsx key parse and visit order

* only use index

* fix underflow

* oops

* tests
2023-11-02 22:56:40 -07:00
dave caruso
12272bb527 ci: publish workflow to gh releases 2023-11-02 22:47:49 -07:00
dave caruso
4403c40755 chore: build and publish canary windows builds (#6834)
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-11-02 22:40:00 -07:00
Dylan Conway
2a405f691e fix #6831 (#6859)
* latin1 zigstring

* skip check
2023-11-02 15:55:54 -07:00
Jarred Sumner
75393e02b8 Fix assertion 2023-11-02 15:46:18 -07:00
Jarred Sumner
e646853d7a Fix assertion failure 2023-11-02 15:15:16 -07:00
Liz
3912f4d064 fix(build): add option and auto detect for arch linux (#6835)
* fix(build): add option and auto detect for arch linux

This adds a option and a automatic routine for decting arch linux,
where the path for libatomic is a bit special.

* fix: don't statically link if not needed
2023-10-31 23:21:45 -07:00
dave caruso
53d1acb0a5 chore: build system improvements (#6811)
* build system improvements

* public the secret download link

* typo

* i think i fixed it

* fix ci

* un-bump the cmake version
2023-10-31 17:25:13 -07:00
マルコメ
23d2c4c8e4 workflows(bun-mac-x64.yml): Fix typo "bun-obj-darwin-x6" (#6819) 2023-10-31 09:47:16 -07:00
Anton Golub
732650d6a4 fix: provide nodejs compat for dns methods wrapped with util.promisify (#6748)
* fix: add nodejs compat for dns methods wrapping with util.promisify

* fix: use single symbol for util.promisify.custom

* style: linting
2023-10-30 23:54:48 -07:00
Jarred Sumner
b29d68bbaf Fix memory leak in require (#6790)
* Fix memory leak in require() and add test

* Mark fixtures as generated code

* Add optimization for large files

* Fix small memory leak

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-10-30 23:54:02 -07:00
Kerem Kat
715be35764 Fix 6281 (#6809)
* throw an error when `Script` is called without new

fix https://github.com/oven-sh/bun/issues/6281

* fix typo in `File` without constructor error

fix https://github.com/oven-sh/bun/issues/6281
2023-10-30 23:05:32 -07:00
Dylan Conway
e259056bd8 peer dependency and semver prerelease bug fixes (#6814)
* `order` and `satisfy` prerelease numbers

* remove sorter

* use existing package for peer dep if possible

* fix test, remove loop

* count workspace versions, compare each part of prerelease

* other peer dependencies

* use existing packages if possible

* don't install peer more than once

* fix update tests
2023-10-30 23:04:47 -07:00
Kerem Kat
68146d0544 Fix minify-whitespace case undefined (#6808)
Print a space before `undefined` in `printUndefined`.

fix https://github.com/oven-sh/bun/issues/6750
2023-10-30 16:15:45 -07:00
Dylan Conway
7e09c7ca1e format 2023-10-30 16:09:34 -07:00
Ciro Spaciari
4d780837ac fix(fetch) (#6672)
* fix fetch

* oops

* revert

* fix checkServerIdentity

* check dns len

* use same checks on wsclient and fetch, fix tests

* more tests and more fixes

* fix node-http flask test

* orelse

* fix requestCert

* more fixes, but no data receiving

* fix pause on connect behavior on TLS

* WS Client + rejectUnauthorized progress

* move test to the right place

* more test

* oops

* oops 2

* fmt

* cleanup

* WIP: handle handshake properly on uWS

* handle rejectUnauthorized in uWS

* fmt

* duplicated test

* fix leak

* add rejectUnauthorized option in WS types

* fix merge

* fix merge2
2023-10-30 12:56:31 -07:00
IAS
cbc5ca770b fix: Macro segmentation faults (#6756)
* Fix for seg faults when using macros

* Update src/js_ast.zig to reflect review suggestions

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

* add test for checking non-zero exitcodes under macros. regression, issue 3830

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-10-30 12:36:38 -07:00
Jarred Sumner
2972cfadfb More resilient test for fetch body memory leak (#6794)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-10-30 12:35:55 -07:00
Jarred Sumner
6be17538e7 Fix flaky test 2023-10-30 02:01:29 -07:00
Liz
e5ccce1e89 feat(console): add printer for mapiterator (#6778)
* feat(console): add printer for mapiterator

MapIterator was not supported in printing, libraries like discordjs make big use of maps and
so i think supporting them would be a good idea.

* fix: snake case var

* fix: add tests for log and add setiterator printer
2023-10-30 01:29:25 -07:00
Rohit Kaushal
08fdbb3c7d [docs] fix ws/pubsub; closed ws don't publish to topic (#6739) 2023-10-30 00:07:50 -07:00
Hanaasagi
8880bf1026 fix(node:buffer): fix Buffer.readUintBE (#6770)
Close: #6759
2023-10-30 00:07:27 -07:00
Ross Martin
d7cb7884c3 Update contributing.md (#6787)
Adding ruby as a dev dependency to Arch list
2023-10-29 18:07:00 -07:00
Samuel Batista
bb19677ae4 docs(contributing) add ruby dependency (#6788)
Don't know why ruby is required to build bun, but without it `bun setup` fails.
2023-10-29 18:06:40 -07:00
Smoothieewastaken
a7a74b73f2 docs: spelling of necessarily (#6772) 2023-10-29 06:34:54 -07:00
perpetualsquid
e4394ef5cc Fixed broken link in deflatesync section (#6774)
* Fixed broken link in deflatesync section

* fixed link

* fixed link
2023-10-29 06:34:35 -07:00
Omar
e4e811d0a7 fix: remove extra parenthesis (#6775) 2023-10-29 06:34:19 -07:00
Jarred Sumner
6851a57ebd Update nodejs-apis.md 2023-10-28 20:17:20 -07:00
dave caruso
3b25c8637b dx: Fix setup script and contributing docs (#6752)
* Updated Dependencies Script

* demo

* fix submodule hell!!!

* lol

* attmept 2

* install nasm in ci

* setup sh 1

* yeah

* better zlib building

* codegen stuff

* attempt 2 at bun codegen ci

* o

* deps improvements

* generaet part of compile-cpp-only.ps1

* restore these

* good enough for Unix

* remove libuv submodule lol

* pass over docs
2023-10-28 04:46:56 -07:00
Jarred Sumner
d1244c8b1f Remove unnecessary DOMAttribute annotation
Preparation for https://github.com/WebKit/WebKit/pull/19606
2023-10-27 22:00:29 -07:00
Rohan Mayya
d1a7bb4a69 add cache and main (#6679) 2023-10-27 11:26:59 -07:00
Darshan Sen
a0bd8365da docs: fix setup.sh path in contributing.md (#6745)
It was added in https://github.com/oven-sh/bun/pull/4410. The `src`
directory is not supposed to be a part of the path.

Signed-off-by: Darshan Sen <raisinten@gmail.com>
2023-10-27 04:08:37 -07:00
Jarred Sumner
16a0801058 Format cmakelists + increase stack size 2023-10-27 04:01:06 -07:00
Jarred Sumner
c4156376d9 Fix debug log 2023-10-27 04:01:05 -07:00
dave caruso
4ff54139b7 fix(ci): typo 2023-10-27 03:20:44 -07:00
Jarred Sumner
8d2e0725e7 Fix fallback to copyfile 2023-10-27 02:36:10 -07:00
Jarred Sumner
700f932ddf Fix warning 2023-10-27 02:20:51 -07:00
Jarred Sumner
7485c7c7cb feat: Windows + CMake Build System (#4410)
* Prepare for windows event loop

* More progress

* Update libuv.zig

* wip

* Make compiling each dependency a shell script

* Bump mimalloc

* Add the build scripts

* Update settings.json

* Fix a bunch of compiler warnings

* Remove more warnings

* more warnings

* cmake works

* Update JSSQLStatement.h

* put it in the zig file

* Fix usockets warnings

* Fixup

* Fix one of the compiler errors

* chunk

* draw the rest of the owl

* theres more

* Rename Process -> BunProcess

Works around a Windows issue

* Add musl polyfill for memmem on Windows

* More

* 12 mb

* Fix getenvZ

* fix variosu issues

* Add fast-ish path for bun install on Windows

* Update windows.zig

* Update windows.zig

* Fix build issue

* it works

* hmmm

* Rename file

* Fixups

* Update wtf-bindings.cpp

* Update src/bun.js/bindings/headers-handwritten.h

Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>

* further!

* more

* Update .gitignore

* hm

* quite a lot of fixes

* Update CMakeLists.txt

* zig fmt

* Many more things are starting to work.

* reb

* regenaret

* Update JSSink.h

* fixup

* fetch works

* Bun.serve() and much of the event loop works now

* Make require() work

* bun install progress

* more things work

* use less std.os

* Fixes

* small fixes

* Bump

* Bummp

* Undo that change

* We have to bump the version of Debian because libarchive has a higher minimum requirement

* ok

* some clenaup

* windows

* Update bun.zig

* fixup

* avoid duplicate symbols

* avoid undefined symbols

* bump

* Remove issue template for install

It's not used, and use the bug issue instead.

* Add types for cp and cpSync

* Add types for watchFile and unwatchFile

* Add bun-types to 'bun fmt' script

* Update nodejs compat docs cp/cpSync/watchFile/unwatchFile (#4525)

* feat(fetch) rejectUnauthorized and checkServerIdentity (#4514)

* enable root certs on fetch

* rebase

* fix lookup

* some fixes and improvements

* fmt

* more fixes

* more fixes

* check detached onHandshake

* fix promise case

* fix cert non-Native

* add fetch tls tests

* more one test

* churn

* Update feature_flags.zig

* Update response.zig

* Revert "avoid undefined symbols"

This reverts commit ca835b726f.

* Revert "avoid duplicate symbols"

This reverts commit 4ac6ca8700.

* Update feature_flags.zig

* Set permissions

* more

* Update mimalloc

* Fix sqlite test failures

* Fix some test failures

* Make sure we remove libusockets is removed

* hm

* [dave]: fix webcrypto crash

* bump

* Update index.ts

* windows zig compiles

* cmake on mac works

* progress

* yay

* bun run build

* fix

* ok

* oops

* asdfasfdafdsafda

* fghjkl

* git ignore

* wow

* Process -> BunProcess

* hmm

* blah

* finalize merge

* now it only has linker errors on mac

* sdfadsf

* g

* getting farther

* sxdcvbnmk,

* adfhjskfjdhkas

* a

* fgh

* update build dot zig

* asdfg

* theoretical -DCANARY flag we can use

* asdf

* cool

* okay

* colorterm

* New build workflow

* Fix script

* Use sudo

* More sudo

* Tweak dependencies

* Another sudo attempt

* Tweak script

* 16.0 -> 16

* Tweak script

* Tweak script

* Tweak script

* Tweak script

* Tweak script

* bun install

* ssh into github actions

* add more to ssh

* Fix postinstal

* Skip llvm

* New dockerfile

* Build

* More changes to Dockerfile

* chaos chaos chaos

* okay

* a

* more cmake nonsense

* add unified sources code (does not work)

* stuff

* prepare for CI builds

* ok

* yay

* yeah

* make this more stable simply by trying again if it fails, 5 times, then lose. it fixes the stability issue i was running into L O L

* messing with ci

* x

* a

* clean dependencies before build

* oops

* this is not going to work but its closer

* not gonna work either

* a

* a

* did i do it

* a

* a

* work around weird fs+Bun.build issues

* properly pass debug flag correctly

* idk im sorry

* lose

* maybe

* run the tests please

* a

* fix zlib script

* a

* hi

* prevent stupid ci issue

* i totally didnt leave in a syntax error on cmakelists

* a

* lol

* relax

* 😭

* a

* SO SILLY

* 😡 one line mistake

* one character diff

* fix linking symbols missing

* work on dependency scripts

* does this work now?

* fix mac build

* a

* bump!

* woops

* add macos baseline build

* .

* fix sqlite and also enable $assert/$debug support in builtin functions

* okay

* oops

* zig upgrade lol

* Merge

* Fix spawn test issue

* Set a timeout

* yeah

* etc

* mi

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
Co-authored-by: Ashcon Partovi <ashcon@partovi.net>
Co-authored-by: Birk Skyum <74932975+birkskyum@users.noreply.github.com>
Co-authored-by: dave caruso <me@paperdave.net>
2023-10-27 01:51:56 -07:00
Jarred Sumner
46a337cbc8 Fix running Bun.spawn on Vercel and GCP (#6724)
* Fix running `Bun.spawn` on Vercel and GCP

* Update subprocess.zig

* Deflake test

* Update spawn-streaming-stdout.test.ts

* Fix tests + cleanup

* Fix hang

* Handle edgecase

* Update subprocess.zig

* Update subprocess.zig

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-10-27 00:03:03 -07:00
Colin McDonnell
58d9a0d770 Add EdgeDB guide 2023-10-26 17:28:57 -07:00
Liz
8f42d8c2dd fix: emit close on stdin stream end (#6720)
* fix: emit close on stdin stream end

We where not emitting the `close` event when done reading stdin data.
It took me way too long to find this but i kept searching in zig/cpp code of the stream implementations...

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

* fix: don't emit close twice
2023-10-26 17:00:37 -07:00
Hanaasagi
b5fb980145 fix(requestIP): fix type cast from binary to text format for IPv4. (#6725)
* fix(requestIP): fix type cast from binary to text format for IPv4.
Close: #6668

* use ares_inet_ntop
2023-10-26 12:31:53 -03:00
Jarred Sumner
2b8aae05d1 Add test for custom thenables in AsyncLocalStorage and fix flaky test and make expect(fn).toThrow drain unhandled promise rejections (#6701)
* Copy Node.js test for async-local-storage thenables

* Fix flaky test

* Make expect(fn).toThrow() more reliable

* Fix setImmediate order

* Support restoring mocked modules with spyOn

* Fix vm test

* Fix more tests

* alright

* Upgrade WebKit

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-10-25 22:35:14 -07:00
Susheel Thapa
2327737b14 docs: fixed typo in guides, install and runtime folder (#6718) 2023-10-25 18:27:05 -07:00
Pierre CM
58ce044607 fix cli create from local template (#6670)
* fix #4766

* fix cli create command for local folders

* zig fmt

* rm comment
2023-10-25 16:54:36 -07:00
Jasper Kelder
85bde43c2f fix bun add drizzle to bun add drizzle-orm (#6703) 2023-10-25 12:55:16 -07:00
Colin McDonnell
4fb5ab0ca8 Update drizzle guide 2023-10-25 12:52:15 -07:00
Colin McDonnell
c275cecfd1 Updates to drizzle 2023-10-25 12:16:59 -07:00
Jarred Sumner
6a2768f247 Implement mock.module in bun:test (#6685)
* Implement Module Mocks

* Update javascript.zig

* Add test for spyOn + ESM namespace

* Bump WebKit

* Bump WebKit

* Drain microtasks at end of test executions

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-10-25 02:59:47 -07:00
Jarred Sumner
7bcf60324a Fix setTimeout(() => {}, 0) and align setImmediate behavior with Node.js (#6674)
* Fix setTimeout(() => {}, 0)

* Align `setImmediate` with Node.js

* Update event_loop.zig

* Update test

* use Bun.sleep

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-10-25 02:59:29 -07:00
dave caruso
c700a70872 fix(runtime): remove env variable limit (#6697)
* fix env limit

* test
2023-10-24 20:11:06 -07:00
Colin McDonnell
ce4e1894f6 Remove unnecessary line 2023-10-24 18:48:07 -07:00
Colin McDonnell
f60167c015 Add Drizzle guide (#6698)
* Add drizzle guide

* Add Drizzle guide

* Tweak
2023-10-24 18:28:39 -07:00
Dylan Conway
042a6cdbce Update worker_threads.test.ts 2023-10-24 17:07:48 -07:00
Jérôme Benoit
85a0d71c52 fix(worker_threads): off by one on threadId (#6671)
* fix(worker_threads): off by one on threadId

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

* test: refine worker_threads threadId consistency test

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

* test: improve worker_threads tests

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

* test: fix worker_threads threadId consistency test

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

* test: simplify worker_threads threadId consistency test

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

* test: refine worker_threads threadId consistency test

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

* refactor: cleanup import on worker_threads tests

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

* test: switch worker_threads worker to TS

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

* test: revert wrong refactoring

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

* test: format

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

* test: port worker_threads worker to ESM

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

* test: cleanup worker_threads test

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

* test: improve worker_threads coverage

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

---------

Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
2023-10-24 17:05:22 -07:00
Dylan Conway
fa1bbec023 Update bun-install.test.ts 2023-10-24 13:18:51 -07:00
nxzq
1496681297 Update workspaces.md (#6673) 2023-10-23 23:16:42 -07:00
Liz
3906d17165 add new repo (#6676) 2023-10-23 23:16:13 -07:00
Yam Borodetsky
f297b95436 docs: fix react.md typos (#6656)
* docs: fix react.md typos

* docs: fix one more typo
2023-10-23 13:48:45 -07:00
Jarred Sumner
fafd9368f5 Backport uWS & usockets changes (#6649)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-10-22 13:44:08 -07:00
Ai Hoshino
1836ecd2ed fix(node:buffer): fix Buffer.write stuck (#6651) 2023-10-22 13:42:05 -07:00
Jarred Sumner
4cdaabd433 Dump as json 2023-10-21 16:27:11 -07:00
Jarred Sumner
4a74a46780 Add require builtins snippet 2023-10-21 16:18:18 -07:00
Dylan Conway
b62c010e95 fix bun link in workspace package (#6631)
* link workspace package

* add test

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

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

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

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

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

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

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

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

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

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

This was already added when the project initialized it seems.

* Typescript section

---------

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

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

* PR feedback

* PR feedback

* This test doesn't reproduce the original issue

* Support pre release versions the same way

* Add a test that reproduces the original issue

* Sort the list of package versions before serializing to disk

* Remove test that didnt reproduce it

* Fix the count

* Fix 0 and 1 and sorting order

* Fix assertions and ordering

---------

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

* optional peer dependencies

* rename offset variable name, cache invalidation time

* Update install.zig

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

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

* PR feedback

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

* Fix failing tests

* Handle @@toStringTag

* Update bindings.cpp

* Revert breaking changes to snapshots until a minor version

* Fix test

---------

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

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

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

* fix: implement changes requested in review

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

* Fix `Host` header excluding port in WebSocket upgrade

* `byteSlice()`

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

* fix: set request e_string

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

* update test

* initWithCLI once

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

Resolve #6559

* Update guide

---------

Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-10-19 17:29:31 -07:00
Jarred Sumner
378385ba60 Bump Zig 2023-10-19 00:19:21 -07:00
Ai Hoshino
ef5930e8bc fix(serve): When IPv6 is not enabled, attempt to bind to IPv4 address under the same hostname. (#6533)
* fix(serve): When IPv6 configuration is incorrect, attempt to bind to IPv4 address under the same hostname.
Close: #5315

* fix review

* fix review again

---------

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

* fix buffer totalLength type

---------

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

* Update install.md

* Update install.md

* Update install.md

---------

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

* other buf

* make sure version works

* make sure overrides don't override alias

* tests

* update

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

* install bun-webkit-debug

* more progress

* ok

* progress...

* more debug build stuff

* ok

* a

* asdfghjkl

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

* ok

* stuff

* upgrade webkit

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

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

* fix message for colin's changes

* okay

* fix cjs prototype

* implement mainModule

* i think this fixes it all

---------

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

* Handle messages that did not finish

* tidy

* ok

* a

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

* test failures

---------

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

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

* fix-tests

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

---------

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

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

* fix: rename lazy worker_threads module properties

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

* fix: add getter for threadId

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

* test: improve worker_threads UTs

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

* test: fix lazy loading

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

* test: fix worker_threads test

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

* fix: return the worker threadId

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

* test: refine worker_threads expectation on threadId

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

---------

Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
2023-10-16 15:19:38 -07:00
Ashcon Partovi
d65b1fd80b Fix use before define bug in sqlite
Fixes #6481
2023-10-16 15:14:15 -07:00
João Alisson
7becb5ec74 fix(jest): fix toStrictEqual on same URLs (#6528)
Fixes #6492
2023-10-16 15:14:15 -07:00
Ashcon Partovi
c3f5baa091 Fix toHaveBeenCalled having wrong error signature
Fixes #6527
2023-10-16 15:14:15 -07:00
Ashcon Partovi
800ad150ff Fix formatting 2023-10-16 15:14:15 -07:00
Ashcon Partovi
5608e59270 Add reusePort to Bun.serve types 2023-10-16 15:14:15 -07:00
Ashcon Partovi
e31ed84b1b Fix request.url having incorrect port
Fixes #6443
2023-10-16 15:14:15 -07:00
Ashcon Partovi
548b1d02f2 Remove uWebSockets header from Bun.serve responses 2023-10-16 15:14:15 -07:00
Ashcon Partovi
f63955a01f Rename some tests 2023-10-16 15:14:15 -07:00
Ashcon Partovi
2996ef7156 Fix #6467 2023-10-16 15:14:15 -07:00
Dylan Conway
2b1f3438e6 Update InternalModuleRegistryConstants.h 2023-10-16 14:21:39 -07:00
Colin McDonnell
2a8f3a3b4e Development -> Contributing (#6538)
Co-authored-by: Colin McDonnell <colin@KennyM1.local>
2023-10-16 16:11:03 -04:00
Ciro Spaciari
a87aa2fafe fix(net/tls) fix pg hang on end + hanging on query (#6487)
* fix pg hang on end + hanging on query

* remove dummy function

* fix node-stream

* add test

* fix test

* return error in test

* fix test use once instead of on

* fix OOM

* generated

* 💅

* 💅
2023-10-14 16:16:49 -07:00
Dylan Conway
9b5e66453b fix installing dependencies that match workspace versions (#6494)
* check if dependency matches workspace version

* test

* Update lockfile.zig

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

* error message for bytes at end of struct
2023-10-13 20:37:06 -07:00
Nicolae-Rares Ailincai
21576589c6 Guide to containerize a bun application using Docker (#6478)
* docker.md

* use-debian

* Updates

---------

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

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

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

* remove-root-from-example

* add-more-description

* Updates

* Updates

* Updates

* Update

---------

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

* save

* works?

* better workaround

* fix install

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

* check for github tag

* remove alloc

* some tests

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

* overrides

* it works

* ok

* a

---------

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

* test and fix

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

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

* Add pm2 guide

* Add pm2 file

---------

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

* stuff

* a

* basics work

* stuff

* yoo

* build lockfile

* correct

* f

* a

* install fixture havent tested

* i made it worse

* lol

* be more reasonable

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

* a

* works now

* ok

* a

* a

* cool

* nah

* fix stuff

* l

* a

* idfk

* LAME

* prettier errors

* does this fix tests?

* Add more safety checks to Integrity

* Add another check

* More careful lifetime handling

* Fix linux debugger issue

* a

* tmp dir and snapshot test

---------

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

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

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

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

* default true

* add test

* cleanup

* some tests

* skip peer deps if they are non optional

* remove debug print, fix build

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

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

* Updates

* Rearrange

* Rearrange

* Add files

* readme

---------

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

* update/spawn.md

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

* Updates

* Updates

---------

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

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

This allows the range to be 0-255

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

* createSecretKey but weird error

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

* HMAC JWT export + base64 fix

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

* fix RSA export

* add EC exports

* X25519 and ED25519 export + fixes

* fix default exports

* better asymmetricKeyType

* fix private exports

* fix symmetricKeySize

* createPublicKey validations + refactor

* jwt + der fixes

* oopsies

* add PEM into createPublicKey

* cleanup

* WIP

* bunch of fixes

* public from private + private OKP

* encrypted keys fixes

* oops

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

* more fixes and tests working

* more fixes more tests

* more clear hmac errors

* more tests and fixes

* add generateKeyPair

* more tests passing, some skips

* fix EC key from private

* fix OKP JWK

* nodejs ignores ext and key_ops on KeyObject.exports

* add EC sign verify test

* some fixes

* add crypto.generateKeyPairSync(type, options)

* more fixes and more tests

* fix hmac tests

* jsonwebtoken tests

* oops

* oops2

* generated files

* revert package.json

* vm tests

* todos instead of failues

* toBunString -> toString

* undo simdutf

* improvements

* unlikely

* cleanup

* cleanup 2

* oops

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

* No commas

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

* Fix one more pluralization

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

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

* handle different repo hosts

* remove log

* Update bun-install.test.ts

* test for `bun add`

* gitlab test

* use comptime hash map, another test case

* don't need length

* bump timeout, use tld

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

* Don't leak

---------

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

* bump webkit

* Update Dockerfile

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

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

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

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

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

* more logging

* wip

* keep information from workspace name array and cache

* hash key

* remove cache, compare workspaces with initially loaded

* uncomment sort

* remove comments

* remove allocation

* package json

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

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

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

---------

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

* Update uws.zig

---------

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

* Update src/install/install.zig

---------

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

* Remove incorrect assertion

* Remove extra check

* Remove extra check

* Update bsd.c

* More consistent

---------

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

* better

* better

* actions

---------

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

* Another test

* Update docs

* Update isBuiltinModule.cpp

---------

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

* oops

* yeah

* sure

* Update src/deps/libuwsockets.cpp

* Update Dockerfile

* lol

---------

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

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

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

* it works now

* better implementation imo

* yippee

* more tests and better unrefing

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

* [server] basic `requestIp` implementation

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

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

* binary address formatting

* uws getRemoteAddress binding

* remove dead code

* working

* final touches

* I will abide by the results of this poll.

---------

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

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

* Upgrade

---------

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

* use bunExe()

* use absolute path to copy tarball

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

* make it so bun-debug-src

* teag

* wild

* yippee

* fas

* fix async hooks assertions

* yap

* yeah that's wild

* aa

* a

* increase time allowed

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

* fix util.types.isArrayBuffer

* fix some utl tests and bugs

* fix node:tty missing primordials

* fix utl stackoverflow handling & some tests

* narrow down diff. context test

* util.inspect indirect circulars optimization

* temp workaround for buggy is...Function checks

* impl. Map/Set/Iterator entries inspection

* fix bigint & symbol objects inspection

* error inspection fixes

* misc util tests stuff

* inline getExternalValue stub

* leftovers

* util.inspect promise internals

* run bun fmt

* commit make js changes

* cut out unnecessary utl files

* reorganize utl folder structure

* remove browserify buffer check

* Try to revert git messing up uws somehow

This reverts commit 2c27e16e7d.

* commit src/js/out files again

* redo this edit too

* refresh js/out files

* Removed uws submodule

* tidy up

* unused primordials

* run fmt

---------

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

* a test

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

* mark DCE toggle experimental + tests

* full (hopefully) DCE toggle

* update DCE toggle tests

* add DCE option to types

* run fmt

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

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

* Simplify github tarball detection

---------

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

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

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

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

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

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

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

* test

* always use the package name

* more tests

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

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

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

* style: format zig file

* fix: implement changes from review

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

* Add alpine and distroless images

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

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

* redact

---------

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

* add typescript test for create command

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

* More consistent CI

* Fix serialization issue

* Update bun.lockb

* Update bun.lockb

* fixup

* Fix `Bin{}`

* `bun update` should not cache the manifest

* Make bun install tests more consistent

* This differs by platform evidently

---------

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

* Update confirm-fixture.js

---------

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

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

* Upadte

---------

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

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

* yay

* oops

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

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

* stuff

---------

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

* Updates

* Update

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

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

* chore: add generated files

* chore: add test

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

* Fixes #5851

---------

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

* Add a comment

* Handle max

* Missing header

* We can use WTF::ramSize now

* Update WebKit

* Update ZigGlobalObject.cpp

* WebKit

* ✂️

---------

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

This caused test failures in text-encoder. cc @WingLim
2023-09-21 07:10:07 -07:00
Jarred Sumner
a18ef053a4 Don't await plugins 2023-09-21 06:16:31 -07:00
Jarred Sumner
6abc9af472 Add another test 2023-09-21 06:04:58 -07:00
Jarred Sumner
e1cf08b3a6 Fixes #5859 2023-09-21 05:48:40 -07:00
Jarred Sumner
28f3453466 Regenerate builtins 2023-09-21 02:59:50 -07:00
Aaron Dewes
9c45487763 Fix make jsc on Linux (#4779)
* Fix `make jsc` on Linux

Previously, it failed with `/usr/bin/bash: Line 3: -DUSE_BUN_JSC_ADDITIONS=ON: Command not found`.

* Update Makefile

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

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-09-21 02:10:54 -07:00
Jarred Sumner
01d2cb5d98 Prettier 2023-09-21 00:51:48 -07:00
Liz
2664dfad9b fix: add check to sqlite extension loading logic (#5773)
The sqlite3 logic to dynamically load extensions can be disabled to save space,
which macos does by default.
sqlite3 provides a api to check for these compile time settings at runtime,
we can use that to throw a js error rather then crashing.
It is worth noting though that the api to check for these settings at runtime
itself can be disabled through SQLITE_OMIT_COMPILEOPTION_DIAGS but this seams
to be a edge case.
2023-09-20 23:43:21 -07:00
Jibran Kalia
e0c5debc57 fix(console.log): change default depth from 8 to 2 (#5839)
This make it as the same default depth in Node.
Source: 480ab8c3a4/doc/api/console.md (L285)
2023-09-20 23:42:44 -07:00
Jarred Sumner
e160223627 In http client, use .toOwnedSlice() instead of potentially re-using the WTFString here 2023-09-20 23:40:42 -07:00
Ai Hoshino
b00588e98c fix(fetch): fix redirect in relative path location. (#5781)
* fix(fetch): fix redirect in relative path location.

* fix utf-8 encoding

* use server.reload

* check buf size

* add RedirectURLTooLong test
2023-09-20 23:34:00 -07:00
dave caruso
ac19c7c62e remove /test.js and git ignore it - sorry 2023-09-20 20:30:15 -07:00
saurabh
539eec85db docs(project): development fix Arch install-dependencies command (#5270)
sudo is required to run pacman if not root user
2023-09-20 20:11:13 -07:00
dave caruso
b7951511a3 fix(run): interpret extensionless files as typescript (#5711)
* test

* gadsgsagdsa

* add better err msg

* r

* oops

* ok
2023-09-20 19:48:46 -07:00
Ciro Spaciari
b65862e23b fix(ffi) fix size limit for dlopen (#5516)
* fix size limit

* 63

* throw error

* ffi.test.js

* add macos tests

* oops
2023-09-20 18:50:10 -07:00
WingLim
5f66b4e729 feat(encoding): support BOM detection (#5550)
* fix(encoding): export `getIgnoreBOM`

* feat(encoding): support ignoreBOM

* fix(encoding): not replace BOM to 0xFFFD

* chore: use strict equal
2023-09-20 18:44:05 -07:00
Ai Hoshino
7319142fd8 feat(node:dns): implement dns.lookupService (#5613)
* feat(node:dns): implement dns.lookupService
Close: #4347

* fix flags

* add `getSockaddr`

* fix sockaddr size

* flaky test
2023-09-20 18:43:08 -07:00
dave caruso
365fc0d39d implement Module.prototype._compile (#5840) 2023-09-20 18:31:57 -07:00
dave caruso
34d191be67 feat(runtime): implement console._stdout (#5842)
* implement console._stdout

* nonenum
2023-09-20 18:28:07 -07:00
Colin McDonnell
5c6d7760a5 Improve types for test.each, describe.each (#5838)
* Improve types for each

* more

* remove
2023-09-20 17:43:08 -07:00
Ashcon Partovi
3c7b9353e1 Fix rendering of bun.lockb in vscode extension 2023-09-20 17:39:33 -07:00
Ashcon Partovi
64a717ab33 Run bun fmt 2023-09-20 17:24:09 -07:00
Colin McDonnell
bbff5b7735 Update quickstart 2023-09-20 16:32:51 -07:00
Colin McDonnell
2e06dbaffe Update prisma guide 2023-09-20 15:42:03 -07:00
Colin McDonnell
19151bb1d2 Update env doc 2023-09-20 13:04:03 -07:00
Colin McDonnell
f8343f25b8 Clarify hot mode 2023-09-20 13:04:02 -07:00
Jonah Snider
67defd95af [bun install] Add -E as alias of --exact (#5104)
* [bun install] Add `-E` as alias of `--exact`

* Add test for -E flag
2023-09-20 11:14:55 -07:00
Lucas Coratger
aa3355dc82 feat: switch disableTelemetry to bunfig (#5690)
* feat: switch disableTelemetry to bunfig

* feat: zig fmt

* revert: the env variable and invert the logic of telemetry

---------

Co-authored-by: MrPalixir <73360179+MrPalixir@users.noreply.github.com>
2023-09-20 10:13:31 -07:00
LongYinan
8c612adcdb Treat undefined value as empty in expect.toThrow (#5788)
Fix: https://github.com/napi-rs/napi-rs/blob/main/examples/napi/__tests__/test.framework.js#L16-L19
2023-09-20 10:11:41 -07:00
JeremyFunk
711a2bcdd1 Fix various bugs in vscode extension (#5772)
* Fix bugs

* Fix bugs

* Revert "Fix bugs"

This reverts commit 608639eb22.
2023-09-20 10:09:51 -07:00
Dylan Conway
689b28455c add emitDecoratorMetadata (#5777)
* some progess

* needs more tests

* make tests easier to debug

* get metadata for constructor arg decorators

* fix some things

* merge `emitDecoratorMetadata` option

* remove `^`

* bundler tests and get option from tsconfig earlier

* remove spaces

* fix tests
2023-09-20 08:10:03 -07:00
Ai Hoshino
4439f16155 fix(doc): correct server.reload (#5799) 2023-09-20 08:08:11 -07:00
Jarred Sumner
ff7f642099 Call Error.prepareStackTrace on new Error().stack (#5802)
* Always call `Error.prepareStackTrace`

* Support node:vm

* Remove this

* Handle more cases

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-20 05:52:59 -07:00
Jarred Sumner
1456c72648 Fixes #5800
Fixes #5800
2023-09-20 04:33:38 -07:00
Jarred Sumner
5d09a06100 Fix path used in bunx (#5785)
* Fix path used in bunx

* Add test

* Use a different package

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-20 01:00:29 -07:00
ggobbe
4a0eb19038 Fix RedirectURLTooLong errors (#5786)
The URL to download the manifest for Artifact Registry in Google
is larger than 4092 bytes.

cf. issue #4748
2023-09-20 00:18:47 -07:00
Jarred Sumner
edee1e3d04 Show when a newer version is available in the install screen (#5780)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-19 23:03:11 -07:00
Colin McDonnell
e2fb524993 Fix broken links 2023-09-19 22:42:54 -07:00
Sanyam Kamat
ee33d5ced4 docs: add Qwik guide (#4810) 2023-09-19 21:54:45 -07:00
h2210316651
53fd9ff4bf Updated modules.md to address issue #5420 (#5456)
* Update modules.md

Updated docs to address `The ES modules aren't always asynchronous. #5420` Issue. 
- Included an elaborate explanation citing the difference between CommonJS and ES Modules, 
- Added a summary

* Tweaks

---------

Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-09-19 21:39:22 -07:00
Ahmad Addel
e3558b626c add warning to Ensure correct placement of the '--watch' flag (#5447)
* Update run.md

* remove the wrong command example

* Tweak

---------

Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-09-19 21:34:26 -07:00
Jarred Sumner
5defdf3e28 Fixes #5769 (#5775)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-19 18:16:51 -07:00
Ciro Spaciari
f8d7f50cdb some fix (#5762) 2023-09-19 17:20:50 -07:00
WingLim
ddb1189b2d fix(cli): bun pm cache rm command not work (#4571)
* fix(cli): rm arg is in positionals[1]

* chore(cli): add cache remove test

* chore: remvoe unnecessary join

* chore: run formatter

---------

Co-authored-by: dave caruso <me@paperdave.net>
2023-09-19 16:54:54 -07:00
Colin McDonnell
4fce34854b Doc updates (#5759)
* WIP

* WIP
2023-09-19 16:31:38 -07:00
Colin McDonnell
615beee1ae More improvements to azure guide 2023-09-19 13:48:59 -07:00
Colin McDonnell
ef98a1b761 Improve formatting again 2023-09-19 13:38:00 -07:00
sum117
8709fd7855 docs(development): typo which would lead to wrong llvm installation (#5513) 2023-09-19 13:35:37 -07:00
Colin McDonnell
ebc7b037ed Update azure guide 2023-09-19 13:31:31 -07:00
Weyert de Boer
f4e7f6db7c docs: update node compability (#5562) 2023-09-19 13:26:50 -07:00
Kilian von Pflugk
f6eaf4bc78 remind users of the latest version (#5597)
Reduce Bug reports for fixed issues.
2023-09-19 13:26:23 -07:00
Andrey Gurtovoy
fc14902f73 Added react installation to react.md (#5620)
* Update react.md

Added install react part

* Updates

* Updates

---------

Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-09-19 13:25:13 -07:00
Brooks Lybrand
d362a8b9ec docs: Update Remix guide (#5702)
* Update Remix guide

* Update callout

* Update docs/guides/ecosystem/remix.md

Co-authored-by: Michael Jackson <michael@jackson.us>

* update

* Add link to remix

---------

Co-authored-by: Michael Jackson <michael@jackson.us>
Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-09-19 12:39:23 -07:00
Jarred Sumner
8677ae9fb1 Get artifactory to work (#5744)
* Get artifactory to work

* Cleanup url normalization a ltitle more

* Clean up tests

* prettier

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-19 08:01:47 -07:00
Jarred Sumner
66d490d109 Align fetch() redirect behavior with spec (#5729)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-19 05:51:05 -07:00
Jarred Sumner
19fc8ecba2 Fixes #3712 (#5730)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-19 05:50:23 -07:00
Jarred Sumner
ed9e64805f Delete long-broken package which is causing confusion 2023-09-19 04:33:58 -07:00
Jarred Sumner
8ca691693f Delete extremely out of date docs 2023-09-19 04:32:45 -07:00
Jarred Sumner
4b5dcc8a6a Make bun install --verbose more verbose (#5726)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-19 03:58:55 -07:00
Jarred Sumner
d2328285f9 Update azure-artifacts.md 2023-09-19 00:13:52 -07:00
Jarred Sumner
346f8e9c94 Update azure-artifacts.md 2023-09-18 23:52:42 -07:00
Jarred Sumner
b34da183bd Update azure-artifacts.md 2023-09-18 23:50:37 -07:00
Jarred Sumner
db1263662c Update azure-artifacts.md 2023-09-18 23:49:42 -07:00
Jarred Sumner
63afadcb91 Update azure-artifacts.md 2023-09-18 23:46:42 -07:00
Jarred Sumner
8b690aaf0d Update azure-artifacts.md 2023-09-18 23:43:06 -07:00
Jarred Sumner
9b7fb8b0f3 Update azure-artifacts.md 2023-09-18 23:42:34 -07:00
Jarred Sumner
cc54b62fac Encode slashes in package names in the registry manifest request (#5716)
* Encode slashes in package names in the registry manifest request

Co-Authored-By: Max Brosnahan <1177034+gingermusketeer@users.noreply.github.com>

* Update dummy.registry.ts

* Fix tests

* Add guide for Azure Artifacts

* Update azure-artifacts.md

* Update azure-artifacts.md

* Typo

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Max Brosnahan <1177034+gingermusketeer@users.noreply.github.com>
2023-09-18 23:27:02 -07:00
Jarred Sumner
9d3f60d44e Prettier 2023-09-18 21:30:17 -07:00
Rui He
b453ec38d6 add navigator type definition (#5444) 2023-09-18 20:23:18 -07:00
Julian
1b949d4f5a bun run fix missing script error on empty file (#5025)
* Fix empty file not found bug

* Add tests

* fix test

---------

Co-authored-by: Jeremy Funk <jeremy@kombo.dev>
Co-authored-by: dave caruso <me@paperdave.net>
2023-09-18 20:14:32 -07:00
Liz
0647216687 fix: provide empty string to 0 length process environment variables (#5679)
* fix: provide empty string to len 0 process env vars

For process loaded env vars, its a bug to give them the literal value '""'
if the provided length is 0.

* fix: add test and remove unneeded branch

Removes the redundant branch for empty env vars and adds a test for the
process specific case.

* fix: remove empty_string_value

Removes the constant in favor of using the empty values or passing the
literal "".

* style: format env.test.ts
2023-09-18 18:14:29 -07:00
Nithin K Joy
6df837cff1 updated llvm version from 15 to 16 in makefile (#5696) 2023-09-18 17:34:57 -07:00
Liz
c55b2c56a4 fix: remove unneeded branch in toJSONWithBytes (#5684)
This branch resulted in the same the same statement so having the branch,
is not needed
2023-09-18 17:34:39 -07:00
dave caruso
eb1dc7eede fix(runtime/node): Allow new Buffer.alloc() + Upgrade WebKit (#5699)
* make bufferconstructor a static hash table

* chore: Upgrade WebKit to 4d995edbc44062b251be638818edcd88d7d14dd7

* make it constructable now

* fix comment

* yippee

* update CI workflows
2023-09-18 17:33:58 -07:00
Jarred Sumner
79dd196edd Implement node_api_create_external_string_latin1 and node_api_create_external_string_utf16 (#5675)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-18 17:31:26 -07:00
dave caruso
333e217c32 feat(runtime): Implement console.Console (#5448)
* prototype

* asdfg

* It works!

* okay its done now fr

* self review

* ok

* fix

* fix test

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-09-18 16:29:56 -07:00
dave caruso
f77df12894 Fix HTTP listen behavior being non-compliant with node (#5689)
* Fix HTTP listen behavior being non-compliant with node

* Add error code for address in use

* use SystemError

---------

Co-authored-by: SuperAuguste <19855629+SuperAuguste@users.noreply.github.com>
2023-09-18 14:57:48 -07:00
Hamed Zakery Miab
8f8ab301b4 change circles for color-blinds (#5594) 2023-09-18 10:31:53 -07:00
Kilian von Pflugk
0800f7017c docs: add missing options from bun init (#5638) 2023-09-18 10:28:57 -07:00
Rauny
8c1c2a0d9d fix(docs): update formatting (#5685) 2023-09-18 10:26:25 -07:00
Ai Hoshino
bab9889601 fix(config): support for registry url without trailing slash (#5662)
* fix(config): support for registry URLs without trailing slash
Close: #4589, #5368

* Update src/bunfig.zig

* Update src/bunfig.zig

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-09-18 04:32:02 -07:00
Jarred Sumner
b27b04690b In bun:sqlite, make sure we set the number tag correctly when creating the JSValue (#5655)
* Make sure we set the number tag correctly when returning values from SQLite

* Add DOMJIT test

* Update JSSQLStatement.cpp

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-18 03:01:19 -07:00
WingLim
c7de270bbb feat(test): Implement arrayContaining (#5572)
* feat(test): implement `arrayContaining`

* feat: early return when expectedArray is empty

* feat: add test for toEqual

* chore: use `JSC::isArray`

* chore: use getIndex for performance

* fix: use deepEqual

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-09-18 02:59:09 -07:00
Jibran Kalia
c66d4a724b feat(console.log): Print annonymus when class name is unknown (#5595)
This matches the functionality in Node.
2023-09-18 00:33:07 -07:00
Reagan
9acc081c3a Remove hardcoded references to zig in Makefile (#5660) 2023-09-18 00:32:20 -07:00
Jarred Sumner
630bbfca91 Add a way to disable the GC timer (#5656)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-18 00:11:18 -07:00
Jarred Sumner
57e38e8312 Fix assertion failure in debug builds 2023-09-17 19:41:51 -07:00
Jarred Sumner
ffa88a1f81 Fix make headers 2023-09-17 19:41:33 -07:00
Quentin
2a6fdc2298 Fix a 'app.server' is possibly 'null'. error (#5626) 2023-09-17 18:18:18 -07:00
Jarred Sumner
bca88b67e3 Workaround #5604 (#5615)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-17 17:38:03 -07:00
Cilooth
c6899940ab Added .DS_Store to gitignore-for-init (#5628) 2023-09-17 17:34:35 -07:00
Shinichi Katayama
639a12f59f Fix ZLS commit hash in the document (#5510)
* Fix ZLS commit hash in the document

* Remove ZLS section from the doc
2023-09-17 09:13:30 -07:00
pan93412
25aa51dfc4 fix(install): Return NotSupported when errno == XDEV (#5610) 2023-09-17 09:09:57 -07:00
JeremyFunk
c6b25adeea Implement VSCode tasks for bun (#5529)
* Fix VSCode extension configuration documentation

* Fix config descriptions

* Fix typo

* Implement bun.lockb highlighter

* Update style

* Improve styling

* Revert bunlock change

* Implement bun tasks

* Revert change

* Package json codelens

* Fixes

* Refactor
2023-09-17 08:59:01 -07:00
Jarred Sumner
0404d09cc7 Bump minimum macOS version 2023-09-16 23:45:09 -07:00
Jarred Sumner
f5b37fa0b0 Use a better error label 2023-09-16 22:53:23 -07:00
Ciro Spaciari
4e0c589562 fix(child_process) unref next tick so exit/close event can be fired before application exits (#5481)
* unref next tick so exit callback can be called

* fmt + test

* oops

* add ref_count

* update pending

* comment and fix
2023-09-16 22:44:13 -07:00
WingLim
a098c6e5f6 feat(encoding): TextDecoder support undefined (#5387)
* feat(encoding): TextDecoder support undefined

* chore: format test file
2023-09-16 22:41:52 -07:00
Ciro Spaciari
383d5b55d6 fix(fetch) handle 100 continue (#5496)
* handle 100 continue

* move comment

* cleanup

* fmt
2023-09-16 21:55:41 -07:00
Ethan Steere
80e1f32ca1 Update tsconfig-paths.md (#5593)
Change string:string mapping in the docs to match the expected string:array[string] mapping. 

See: https://www.typescriptlang.org/tsconfig#paths
2023-09-16 21:44:02 -07:00
Vilsol
eca93d4257 docs: fix typo in lockflie nav (#5576)
Looks like someone shifted their hand a bit to the right.

Changes `ytrr` to `tree`
2023-09-16 21:43:43 -07:00
Jarred Sumner
77781e2fa1 Make this error message clearer (#5603)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-16 21:32:52 -07:00
MrPalixir
0a318ecca1 fix: node compatibility with empty path string (#4693)
Co-authored-by: MrPalixir <73360179+MrPalixir@users.noreply.github.com>
2023-09-16 18:51:18 -07:00
Max Karou
08426962fa fix: failing array-buffer.test-d.ts test (#5580) 2023-09-16 12:07:01 -07:00
Max Karou
7f45866d76 fix: ArrayBufferConstructor type signature (#5579) 2023-09-16 11:19:36 -07:00
Bruce Denham
5e6490d905 Update workspaces.md to reflect "workspace:*" syntax (#5555) 2023-09-16 10:21:42 -07:00
Dylan Conway
b651b16fdd webkit upgrade (#5535)
* update files

* Update cold-jsc-start.cpp

* bump webkit
2023-09-16 00:44:07 -07:00
Dylan Conway
caa192480c mark binding 2023-09-15 23:39:36 -07:00
Jarred Sumner
6d8056554e Update build-id 2023-09-15 22:22:39 -07:00
David Hewitt
43c463f078 fix(node/fs.watch): Check first char before trimming event filenames (#5505)
* Add failing test

* fix(node/fs.watch): Don't lose first char in event

* run prettier
2023-09-15 21:21:15 -07:00
David Hewitt
787281ee5e fix(bundler): Add a space before minified require (#5521)
Fixes #5501
2023-09-15 21:19:49 -07:00
Ciro Spaciari
cb057e61ba fix(request) handle undefined/null/empty signal on request (#5503)
* handle undefined/null/empty signal on request

* better approach
2023-09-15 21:19:26 -07:00
Ciro Spaciari
b54e3f3c04 fix(corking) uncork if needed (#5525)
* fix size limit

* uncork if needed instead of terminating

* undo unrelated changes
2023-09-15 21:18:57 -07:00
Sony AK
7f2e40af46 Update development.md (#5531)
Fix to version 16 on docs
2023-09-15 20:28:52 -07:00
Dylan Conway
d976b22c95 Update InternalModuleRegistryConstants.h 2023-09-15 16:00:59 -07:00
Zong
575a85a3fd docs(runtime): fix some typo. (#5451) 2023-09-15 14:10:04 -07:00
JeremyFunk
8eabb4d1d5 Improve rending of lockfiles in VSCode extension (#4652)
* Fix VSCode extension configuration documentation

* Fix config descriptions

* Fix typo

* Implement bun.lockb highlighter

* Update style

* Improve styling

* Revert bunlock change
2023-09-15 13:25:44 -07:00
Jarred Sumner
99a92465f3 Add Permission 2023-09-15 09:54:58 -07:00
Jarred Sumner
37edd5a6e3 Add missing visitors
cc @paperdave
2023-09-15 08:24:35 -07:00
dave caruso
29b22175bf feat(runtime): add process.binding uv/natives/config + make global object properties lazy (#5355)
* binding uv

* we did that

* some more bindings

* fix doc

* fix uv

* yo

* static hash table nonsense <3

* huge refactor to the global object i am not ready for merge conflicts

* it works part 3

* lose

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-09-15 08:22:06 -07:00
Jarred Sumner
75697890ce Rename this file 2023-09-15 07:10:30 -07:00
Jarred Sumner
7662f99ee0 Update README.md 2023-09-15 07:09:48 -07:00
Jarred Sumner
1e99419127 Set permissions 2023-09-15 07:09:06 -07:00
Jarred Sumner
cd1846a414 Update build-id 2023-09-15 07:04:38 -07:00
Jarred Sumner
a39b0d86a0 Fixes #5465 (#5468)
* Fixes #5465

Fixes #5465

* Update tty.js

* Update InternalModuleRegistryConstants.h

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-15 06:53:39 -07:00
Jarred Sumner
6cc5872765 Fixes #5461 (#5467)
* Fixes #5461

* Update runtime-transpiler.test.ts

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-15 06:04:34 -07:00
Jarred Sumner
898962770e Implement URL.canParse (#5463)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-15 05:36:06 -07:00
Ai Hoshino
7d0db82bb3 fix(proxy): allow empty string http_proxy env. (#5464)
Close: #5380
2023-09-15 05:24:03 -07:00
Jarred Sumner
4b00144211 Revert "decode regex if needed (#5167)"
This reverts commit 32664df254.
2023-09-15 05:07:22 -07:00
Jarred Sumner
92f2d9ab27 Does not fix #4622 (#5452)
* Fixes #4622

* cleanup

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-15 04:23:37 -07:00
Jarred Sumner
56c471a005 Make bun run --silent omit "error: "..." exited with code 1 (#5459)
* Make --silent behave as expected

* Make the "tsconfig.json extends" error a debug level

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-15 04:21:43 -07:00
Jarred Sumner
20f61b2369 Fix test 2023-09-15 04:10:05 -07:00
Jarred Sumner
9168be4f15 Add missing "size" getter to URLSearchParams prototype 2023-09-15 03:50:03 -07:00
Dylan Conway
d26addeca1 dup and close file descriptors (#5341)
* track one shot fds

* dup fd

* skip for rearm on mac

* dup if fd

* cleanup

* force unregister on close

* deinitForceUnregister

* test

* add prompts

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-09-15 01:39:42 -07:00
Dylan Conway
f84fbd6e3e remove convertToASCIILowercase 2023-09-15 00:45:47 -07:00
Jarred Sumner
f2a8575e4d Reduce log level for loading tsconfig.json extends message 2023-09-15 00:15:22 -07:00
Dylan Conway
29a6ece6c6 next bun.lockb 2023-09-15 00:03:21 -07:00
Dylan Conway
9c44ec1b0d next 2023-09-15 00:02:39 -07:00
Sony AK
819a1fde28 Update docs/quickstart.md (#5425)
* Update quickstart.md

Update quickstart.md

* Update quickstart.md

Update quickstart.md
2023-09-15 00:01:05 -07:00
Colin McDonnell
31fec8f704 Clean up run.md 2023-09-14 23:44:19 -07:00
Jarred Sumner
c5e8271cdc [build] --force on git submodule update 2023-09-14 23:27:37 -07:00
Ciro Spaciari
da7db2230f fix(nitro) fix sourcemaps and JSSink closing (#5422)
* fix JSSink progress on sourcemap checking

* fix sourcemaps

* update JSSink fix

* undo + tests

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-09-14 23:25:01 -07:00
Dylan Conway
94e9f8bdca fix http set cookie headers (#5428)
* allow multiple set-cookie values

* make it work for `getHeader`

* move `getHeader` to cpp

* remove set-cookie check

* move `setHeader` to cpp

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-09-14 23:03:20 -07:00
Jarred Sumner
2e6898470e fix dockerfile (#5439)
* fixup docker

* Update Dockerfile

* Update Dockerfile

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-14 22:23:10 -07:00
Dylan Conway
d606958f11 thread 2023-09-14 21:43:58 -07:00
Jarred Sumner
ced69d3818 async-ify all node:fs functions (#5360)
* async all node:fs functions

* draw the rest of the owl

* LLVM & Clang 16

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-14 21:26:37 -07:00
Colin McDonnell
b262b0153a Clean up bunfig.md 2023-09-14 21:25:57 -07:00
Colin McDonnell
75e68e356b Mention dotenv 2023-09-14 21:09:14 -07:00
Colin McDonnell
31691e3898 Fix links 2023-09-14 21:02:52 -07:00
Colin McDonnell
332141a6f2 Rework bunfig docs 2023-09-14 20:54:53 -07:00
Dylan Conway
308237752a v8 date parser tests (#5332)
* Create v8-date-parser.test.js

* one more test

* add permalinks and enable parser in bun

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-09-14 19:43:11 -07:00
dave caruso
e8d58f24af fix(runtime): emit node:net connect error event vs throw (#5336)
* fix(runtime): emit `node:net` connect error event vs throw

* oops

* finally

* ok

* we are good
2023-09-14 17:30:30 -07:00
Colin McDonnell
07b10bbc16 Clean up trustedDependencies guide 2023-09-14 17:28:11 -07:00
Dylan Conway
969b0cf539 remove tsconfig warning 2023-09-14 17:10:32 -07:00
Nang Chan
23b1276ee2 fix warnings during bun run publish-layer (#5419)
- add missing package @oclif/plugin-plugins to resolved warning: could not find package.json with { type: 'dev',
2023-09-14 15:47:44 -07:00
Colin McDonnell
a983ec713f Improve run.md 2023-09-14 15:30:14 -07:00
DuGlaser
a31d69bf93 fix(docs): Fix the text that bun run --bun is the same as bun (#4647)
* fix(docs): Fix the text that `bun run --bun` is the same as `bun`

* Updates

---------

Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-09-14 15:19:37 -07:00
Dylan Greene
f3fe4508ae docs - Add "workspace:*" to workspace docs. (#5379)
* add workspace:* to docs

* Updates

---------

Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-09-14 15:04:26 -07:00
Colin McDonnell
96a1d5382f Improve docs 2023-09-14 14:51:42 -07:00
Dylan Conway
e923e23270 oops 2023-09-14 14:38:46 -07:00
Dylan Conway
f815ffa467 bump webkit 2023-09-14 14:01:33 -07:00
Chris Boette
6e1472b9f8 Fix typo in HTTPThread name. (#5376) 2023-09-14 09:09:22 -07:00
Jarred Sumner
92e95c86dd Always get latest version when @tag is explicitly passed (#5346) 2023-09-14 00:48:18 -07:00
Nathan Hammond
8ae9aeea6b Remove the ability to configure lockfile. (#5335) 2023-09-13 22:32:03 -07:00
Colin McDonnell
4ebed280dc Fix helptext for bun update 2023-09-13 22:01:31 -07:00
Soheil Nazari
b31d76b03d Update nuxt.md (#4452)
* Update nuxt.md

* --bun

---------

Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-09-13 22:00:31 -07:00
Twan L
0a5e44cd39 Update simple.md (#4881)
I have removed the / before ${server.port} because it its incorrect and I replaced the localhost to ${server.hostname}

Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-09-13 22:00:05 -07:00
kryparnold
49a44eef0f Update nextjs.md (#4905) 2023-09-13 21:59:16 -07:00
Ciro Spaciari
fa2ef0972b fix(Bun.serve) fix buffering edge case (#5152)
* fix buffering clean

* fix resolveMaybeNeedsTrailingSlash and try to fix ci/cd error

* fix resolveMaybeNeedsTrailingSlash and try to fix ci/cd error

* oops

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-09-13 21:48:30 -07:00
dave caruso
9976e3f528 fix(runtime): make most globals configurable/deletable, allow resuming the console iterator (#5216)
* Fix #5177

* Fix #5175

* make most globals deletable/overridable

* not done

* cool

* a

* done

* fix test

* oops

* yippee
2023-09-13 21:39:36 -07:00
Colin McDonnell
fbafbd3394 Reorganize Intro section 2023-09-13 21:36:35 -07:00
Colin McDonnell
66c0401426 Make TypeScript instructions easier to find 2023-09-13 21:22:41 -07:00
Colin McDonnell
631c826866 Use Bun global 2023-09-13 21:22:41 -07:00
Mordy Tikotzky
088bea026e Fix bug with multiline string in CRLF terminated files (#4893) (#5318)
* Fix bug with multiline string in CRLF terminated files (#4893)

* add test for #4893
2023-09-13 21:05:02 -07:00
dave caruso
503c808929 test (#5244) 2023-09-13 20:54:46 -07:00
Jacques Desmarais
0927624608 fix link to "local template" (#5115) 2023-09-13 20:50:58 -07:00
miccou
cf834964a6 modules documentation didn't have correct import example (#5225) 2023-09-13 20:50:21 -07:00
Colin McDonnell
6ac70a6dd2 Use bun create everywhere 2023-09-13 20:47:36 -07:00
Madhurjya Roy
a8cef7ae75 doc(guides): update sveltekit guide (#5285)
* doc(guides): update sveltekit guide

Use `bun create svelte` instead of `bunx create-svelte`. 

This is to bring the documentation at par with the SvelteKit official doc to [create a project](https://kit.svelte.dev/docs/creating-a-project).

* Update text instructions for sveltekit.md
2023-09-13 20:45:37 -07:00
Colin McDonnell
c99caccdb2 More docs & helptext cleanup (#5229)
* wip

* Flesh out resolution docs

* Polish

* More

* WIP

* WIP

* WIP

* Document --watch
2023-09-13 20:43:39 -07:00
Colin McDonnell
22f14129e5 Fix mock example 2023-09-13 20:42:10 -07:00
Ciro Spaciari
d37602f316 fix(BunFile.slice) fix slice when length is greater than the size (#5186)
* check the limits for file, when slicing

* check eof

* undo test
2023-09-13 19:49:43 -07:00
Patrick Klitzke
cb52556bd1 fix(doc): Add "compilerOptions" to bun-types README.md (#5325)
Reading the documentation on bun-types it was not clear to me that the tsconfig.ts needs to look like this:

```
{
  "compilerOptions": {
    "types": ["bun-types"]
  }
}
```

So i added the "compilerOptions" information.
2023-09-13 19:27:49 -07:00
Ai Hoshino
03d9bcd440 fix(node:dns): fix the crash. (#5200) 2023-09-13 17:43:10 -07:00
Ciro Spaciari
972a6f29cc fix(console.log) fix printing long custom format (#5164)
* avoid overflow

* Update src/bun.js/bindings/exports.zig

* add mongodb inspect test

* bun db test

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-09-13 17:41:47 -07:00
WingLim
932fa35f99 feat(nodejs): implement os.availableParallelism (#5109)
* feat(nodejs): implement `os.availableParallelism`

* chore: do not throw error as same as node

* refactor: use `navigator.hardwareConcurrency`
2023-09-13 17:41:09 -07:00
Jarred Sumner
9c9f4ed6ad Make --watch instant (#5236)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-13 17:31:59 -07:00
dave caruso
4f8edb825f fix(runtime): require cache should not include unevaluated ESM modules. (#5233) 2023-09-13 16:57:59 -07:00
James Gordo
cb01cb0d4a Fixed api & cli docs typo. (#5262)
* Fixed api & cli docs typo.

* Fix

---------

Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-09-13 16:36:11 -07:00
Steven
64033f11cc chore(docs): include missing links to Node.js APIs (#5281)
These links make it easy to click and jump to another section.
2023-09-13 14:08:28 -07:00
wing
1c570b41bc docs(guide): fix expect assertion example in guide for spyOn (#5294)
Fixes example with `spyOn` and assertions. The example failed because the spied function would be called once but the expectation asserted 0 calls.
2023-09-13 14:08:09 -07:00
Andrew Brown
500bd15fb5 add uninstall instructions (#5311)
it's always good to have uninstall instructions as well as install, and I couldn't find them anywhere else on the site.

IMO, this gives users a little more confidence to try new tools out, as they know it's easily reversible.

I'm not familiar with how to uninstall with Docker, so would appreciate some help there.

We could possibly add a note for "bash" on how to remove Bun from the `$PATH`.
2023-09-13 14:07:43 -07:00
Guilherme J. Tramontina
687e31dc3a docs: update lockfile diff instructions (#5275) 2023-09-13 10:27:32 -07:00
David Hewitt
c3455c0cee fix(node/fetch): Make data URL fetch consistent with node (#5126) 2023-09-13 05:35:39 -07:00
iidebyo
9101774593 avoid inserting extraneous"accept-encoding" header (#5057)
* add no extraneous accept-encoding header test

* ensure fetch honors no decompress opt

* fix format on test/js/node/http/node-http.test.ts
2023-09-13 02:02:25 -07:00
Zong
9a0ea00705 docs(runtime): fix plugins loader extensions typo (#5250) 2023-09-13 02:00:11 -07:00
Gareth Jones
ec6b75ff54 chore: make comment grammatically correct (#5140) 2023-09-13 01:56:19 -07:00
Colin McDonnell
a18e3ff451 Add informative message on 'bun create react' (#5248) 2023-09-13 01:48:42 -07:00
Zong
eeb790a2f1 docs(runtime): fix jsx FragmentFactory output example (#5243) 2023-09-13 01:47:54 -07:00
amt8u
878b473085 file.exists() needs to be awaited to get the value (#5061) 2023-09-13 01:41:18 -07:00
Antonin CLAUZIER
6161c201e1 Update discordjs.md (#5227) 2023-09-13 01:38:17 -07:00
Dylan Conway
32664df254 decode regex if needed (#5167)
* decode regex if non-ascii

* make it comptime

* add test

* use `bun.BabyList(u16)`
2023-09-13 01:26:18 -07:00
Nathan Hammond
15f7bacb8b Correct the configuration file names. (#5234) 2023-09-13 01:19:15 -07:00
Colin McDonnell
473513db7e Update tsconfig.json for bun init 2023-09-12 23:53:28 -07:00
cfal
75b5c71540 js/node/stream.js: call write() callback when encoding is not provided (#4841)
* js/node/stream.js: call write() callback when encoding is not provided

* js/out/InternalModuleRegistryConstants.h: update
2023-09-12 22:21:58 -07:00
Gordon Goldbach
c9c62f37e5 docs: Made bun-types install as dev dependency in example (#5120) 2023-09-12 22:04:39 -07:00
Colin McDonnell
18b521d9b8 Various docs (#5201)
* Updates

* Improve jest guide

* Improve
2023-09-12 21:51:49 -07:00
Southpaw
534fd30dbd Use git's --global flag for lockfile diffs instead of manually modifying config files (#5143) 2023-09-12 21:51:07 -07:00
Jonathan Neal
3b2c0941e4 docs: fix typo in import.meta.resolve (#5146) 2023-09-12 19:14:26 -07:00
Nazeel
8d3829114e Update hot.md (#4990) 2023-09-12 18:54:23 -07:00
Tom Redman
5f9c30b717 Update simple.md (#4997)
Remove errant slash preventing the correct console log
2023-09-12 18:53:55 -07:00
xnacly
c55574b4d3 fix typo and grammar errors (#5046) 2023-09-12 18:53:23 -07:00
mi4uu
2f27e24778 clang and llvm on arch install v16, update to use v15 (#5069) 2023-09-12 18:52:30 -07:00
Diogo Goncalves
b910db74be Add missing full stop on nodejs-apis.md (#5072) 2023-09-12 18:51:15 -07:00
Toby
b37cb98a6e udate README.md (#5127)
update path
2023-09-12 18:50:50 -07:00
Samuel Rigaud
263382103f docs: fix typos (#5151) 2023-09-12 18:50:05 -07:00
Thomas Rupprecht
8777c3f72c fix lifecycle docu (#5159) 2023-09-12 18:49:19 -07:00
Colin McDonnell
996491f719 Clean up Modules doc 2023-09-12 16:54:07 -07:00
Colin McDonnell
12c2da0ebf Create SECURITY.md 2023-09-12 16:53:59 -07:00
Dylan Conway
a3166457d3 Update node-dns.test.js 2023-09-12 16:50:11 -07:00
Mitchell K
b1bd93bffc fix(bun-lambda) Fix API Gateway V1 events and expand on Lambda documentation (#5161)
* Fix issues with using V1 API Gateway events with Bun Lambda Layer.

* Remove aws-lambda as it is not needed
2023-09-12 14:59:19 -07:00
James Gordo
4c113d1866 Fixed Websocket Compression Example. (#5087)
* Passed message variable to ws.send() method.

* Passed message variable to ws.send() method.
2023-09-12 08:30:23 -07:00
ped
f9d2e687f5 Fix typo in http file upload example (#5088) 2023-09-12 08:30:06 -07:00
Jarred Sumner
31aec4ebe3 Fix bug with bun build --compile (#5102)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-12 07:07:07 -07:00
Jarred Sumner
b432006e43 Clean up some edgecases with posix_spawn usage (#5079)
* Check that the pid matches

* Fixup EINTR check

* Remove extra slashes

* fixup

* fixup

* != 0

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-12 06:34:20 -07:00
Alex Lam S.L
015f0a6e9a fix up with prettier (#5092) 2023-09-12 05:53:55 -07:00
David Hewitt
07a6443a80 fix(node/path): Prevent memory corruption in parse (#5083)
* Add failing test for issue #4954

* fix(node/path): Return results with toValueGC
2023-09-12 05:05:00 -07:00
Jarred Sumner
6e4f746ace Fix some bugs blocking Turborepo from using bun run (#5071)
* Clean up some error handling when loading `tsconfig.json`

* [bun run] don't parse tsconfig.json for package.json scripts

* Make this error message better

* Bump

* Don't print build errors twice

* Handle quotes in error messages a little better

* Add a couple tests

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-12 03:35:29 -07:00
Ai Hoshino
b5a3bed7f2 fix(JSC): copy string in toJSStringValueGC (#5067) 2023-09-12 03:08:42 -07:00
Ciro Spaciari
8615b8ad6b add NODE_TLS_REJECT_UNAUTHORIZED (#4829) 2023-09-11 21:52:31 -07:00
Eric Bidelman
4992839232 Update gzip.md (#5041)
typo
2023-09-11 21:47:35 -07:00
Colin McDonnell
03b8e9d5cf fix formatting in sveltekit guide 2023-09-11 20:12:48 -07:00
Ai Hoshino
f267c1d097 fix(path): Fix edge case in path.relative (#4811)
Close: #4789
2023-09-11 17:53:43 -07:00
Ai Hoshino
c4507a5db3 Fix Buffer.from to handle double-byte hex encoding strings (#4933)
Close: #4919
2023-09-11 17:27:12 -07:00
Ciro Spaciari
c9a0ea96cd fix(BunFile) .slice offset on macOS (#4991)
* fix offset

* simplify error
2023-09-11 17:19:43 -07:00
Dylan Conway
ca461f9e83 fix loading env from .env.production and friends (#4630)
* reload conditional vars

* test

* change `get` and `put` methods

* dont clone empty env variables
2023-09-11 17:19:21 -07:00
Colin McDonnell
9c4765f616 Update benchmark readme 2023-09-11 16:53:34 -07:00
Justin "J.R." Hill
e091290748 fix(bun-lambda): Don't drop arguments in console.log(...) (#4992)
Closes #4826
2023-09-11 12:39:56 -07:00
Ben Jervis
350403663e Fix error message typo in js_ast.zig (#4937) 2023-09-11 11:03:45 -07:00
Dylan Conway
895f3824b5 update test 2023-09-11 10:43:33 -07:00
Diogo Goncalves
58e69ef9f4 Remove unnecessary backticks in quickstart doc page (#4927) 2023-09-11 08:54:22 -07:00
Vladimir Pesterev
decad91d24 Fixed inconsistent log messages in the Quickstart guide (#4942)
Looks like it is just a typo and needs to be fixed.

Signed-off-by: Vladimir Pesterev <8786922+pesterev@users.noreply.github.com>
2023-09-11 08:53:54 -07:00
Yonathan Benolol
ea56182c5a Update http.js - Fix Methods Fallback naming (#4948) 2023-09-11 08:51:35 -07:00
Matthew Yu
9d6a8ee79d Fix punctuation (#4870) 2023-09-11 08:50:39 -07:00
fehnomenal
b55b511f68 Make detect-libc package match the upstream api (#4910) 2023-09-11 08:49:57 -07:00
Krzysztof Szala
49b9306dce fix: changes wrong command name in the tests chapter (#4965)
This PR fixes the command name for running tests flagged with `.only`
2023-09-11 08:48:53 -07:00
Krystian Pracuk
2956ed4289 added .idea to .gitignore (#4951) 2023-09-11 08:48:26 -07:00
Jarred Sumner
51d3d43822 Support named imports for json & toml files at runtime (#4783)
* Support named exports in json imports

* Support named imports for `*.json` files

* Remove stale comments

* Don't export arrays as non-default

* Add test for default exports

* Don't break webpack

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-10 23:15:35 -07:00
Jarred Sumner
edea4f095a Fixes #4588 (#4804)
* Fixes #4588

* typo

* fixup

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-09-10 21:40:46 -07:00
Diogo Goncalves
07c88435e0 Replace unnecessary '' wih "` in code snippets (#4792) 2023-09-10 11:34:04 -07:00
Jeroen van Rensen
7121c1d6ab Update modules.md - Explain case-insensitivity (#4782) 2023-09-10 11:33:39 -07:00
Ed Knowles
60dc76676c docs: remove duplicate sentence from debugger (#4807) 2023-09-10 11:33:04 -07:00
toneyzhen
f64b504bae Update todo-tests.md (#4771) 2023-09-10 11:32:31 -07:00
Vyacheslav Kulik
97153c5a5f Add compatibility page link to index.md (#4809)
Add a link to compatibility page (https://bun.sh/docs/runtime/nodejs-apis) to its reference in index.md, so it's easier to reach out to.
2023-09-10 11:30:46 -07:00
Tom Sherman
d48ff53e4e docs: Update Bun.write(path, Response) example to be clear that it writes the body (#4802) 2023-09-10 05:06:25 -07:00
WingLim
afcbed218c fix(bindings): add missing binding (#4682) 2023-09-10 02:58:10 -07:00
Rinku Chaudhari
682406c42c docs: fix spelling (#4763) 2023-09-09 22:40:56 -07:00
Richard
6fe40f383a Fix mongoose ecosystem guid (#4740)
Fix missing method declaration on schema and Schema database name from Kitten to Animal
2023-09-09 19:05:13 -07:00
thunfisch987
e2d327881c fix(docs); typo on Nuxt guide page (#4745) 2023-09-09 19:04:05 -07:00
Robert Soriano
4280f74429 docs: fix wasi-js link (#4741) 2023-09-09 19:03:46 -07:00
Chris Hutchinson
8139a20c9f fix: remove from bun-server.test.ts test case (#4709) 2023-09-09 19:03:28 -07:00
akumarujon
620f6c51ce fix typo (#4639) 2023-09-09 14:46:41 -07:00
Ashcon Partovi
ffe4f561a3 Fix listen() using unix socket if argument is a valid port (#4620)
* Fix listen() using unix socket if argument is a valid port

Fixes #4582

* Add test
2023-09-08 16:27:44 -07:00
Ana Margarida Silva
c896792c37 fix(docs): connect websocket client repeated documentation (#4615) 2023-09-08 14:22:28 -07:00
Colin McDonnell
088491cb59 Add extension guide 2023-09-08 13:49:12 -07:00
xxxhussein
f27ef667c7 Delete docs/ecosystem/buchta.md (#4536)
Delete buchta.md since its development is discontinued by LowByteFox: https://twitter.com/LowByteFox/status/1694025965452636612
2023-09-08 13:21:41 -07:00
Arjunkumar
7d9820d478 Update mongoose.md (#4534) 2023-09-08 13:20:07 -07:00
Ethan Steere
b5da5168bf Update Svelte Kit Docs (#4541)
* Update Svelte Kit Docs

I added some guidance about how to build for production. Still WIP since I would like to add a more complete deployment guide.

* Formatting

---------

Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-09-08 13:19:53 -07:00
rajatdua
61569fab80 docs(template.md): spelling (#4614) 2023-09-08 13:19:33 -07:00
Frederik De Bleser
0887825f54 Fix code typo in transpiler.md (#4604)
There are some extra closing brackets at the end of the `scanImports` example. These cause a syntax error ("Unterminated string literal")
2023-09-08 12:10:17 -07:00
Colin McDonnell
6d02b18680 Remove await plugin 2023-09-08 11:42:27 -07:00
Vitor Dino
1b8c6f266f docs: fix --backend options list on cache.md (#4599)
`symlink` wasn’t an item, it appeared the same as `copyfile`
2023-09-08 11:19:29 -07:00
Dan Fabulich
989dd92ea8 Move "Importing CJS from CJS" back out of low-level details section (#4600)
This section appears to have been accidentally moved into the low-level details section in 5424ea3403.

This fixes the example in the low-level details section, because the "Importing CJS from CJS" section is not the example code that the low-level details section is intended to provide.
2023-09-08 11:18:52 -07:00
Colin McDonnell
9e3cabc540 Remove community-templates 2023-09-08 10:55:16 -07:00
Ondrej Brablc
3170cf08ba Make the link to application clickable in the terminal (#4544)
Terminals like iTerm require valid URL to make them clickable. Adding a space to make it valid. Similar problem is on https://bun.sh/, where protocol is missing.
2023-09-08 09:33:35 -07:00
Samual Norman
182d3f1567 Fix Bun.CryptoHasher missing argument in docs (#4585) 2023-09-08 09:32:36 -07:00
Tiramify (A.K. Daniel)
189f0f7c36 Update development.md (#4578) 2023-09-08 09:32:15 -07:00
Ashcon Partovi
a05a1780c1 Fix bun-types 2023-09-08 08:29:59 -07:00
Jarred Sumner
822a00c4d5 Fix a couple important bugs (#4560) 2023-09-07 21:07:00 -08:00
Adam
f6a621f36a Fix typo in sveltekit.md (#4550) 2023-09-07 13:11:09 -07:00
dave caruso
5b9d8b87c4 Bump version to Bun 1.0.0 (#4543)
* hi

* Update Version to 1.0.0

* 2

---------

Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
2023-09-07 10:57:46 -07:00
Colin McDonnell
a7c3bc8a5a Fix markdown 2023-09-07 10:12:52 -07:00
Colin McDonnell
5424ea3403 Doc updates for v1.0 (#4485)
* Remove v0.x messages

* Add windows section to Installatino

* update

* update

* Update

* Comment out windows
2023-09-07 10:09:09 -07:00
dave caruso
4b63ced72d fix(cli): final touches for 1.0 (#4538)
* better

* cli

* remove submodule

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-09-07 09:04:21 -07:00
Ciro Spaciari
c8883a39a5 fix(fetch) closeAndFail instead of close (#4537)
* closeAndFail instead of close

* use constant

* add some protection

* dont deinit

---------

Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-09-07 08:34:13 -07:00
dave caruso
36e5a072a9 revert (#4539)
* Revert "remove native events from streams"

This reverts commit e063a47a53.

* finish revert

* remove accidental submodule

* dfghj
2023-09-07 07:45:00 -07:00
dave caruso
57a06745a4 Progress for Next.js (#4468)
* L

* ipc

* asdfghjkl

* dfghjk

* it works!

* types

* patches for next.js

* sdfghj

* wsdfgn,./

* this

* yolo

* okay loser

* asdfghjk

* add some more APIs

* MESS

* sdfghjkl

* remove native events from streams

* stuff

* remove lazy(primordials) test

* debugging

* okay

* less fake extensions object

* fix `Buffer.toString()` args logic

* fix deserialize

* make tests work

* add test for `Buffer.toString` args

* Update server.zig

* remove test

* update test

* Update spawn-streaming-stdin.test.ts

* fix linux build

* Update fs.test.ts

* cli message improvements

* dfshaj

* Fix fs.watch bug maybe?

* remove

---------

Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
2023-09-07 04:58:44 -07:00
Ciro Spaciari
4360ec83b4 feat(fetch) rejectUnauthorized and checkServerIdentity (#4514)
* enable root certs on fetch

* rebase

* fix lookup

* some fixes and improvements

* fmt

* more fixes

* more fixes

* check detached onHandshake

* fix promise case

* fix cert non-Native

* add fetch tls tests

* more one test
2023-09-06 22:23:24 -07:00
Birk Skyum
3b9829f171 Update nodejs compat docs cp/cpSync/watchFile/unwatchFile (#4525) 2023-09-06 14:04:07 -07:00
Ashcon Partovi
849a2cdfae Add bun-types to 'bun fmt' script 2023-09-06 10:03:12 -07:00
Ashcon Partovi
77f1f2480d Add types for watchFile and unwatchFile 2023-09-06 10:02:48 -07:00
Ashcon Partovi
5e074209c6 Add types for cp and cpSync 2023-09-06 09:58:00 -07:00
Ashcon Partovi
0c2675c8d3 Remove issue template for install
It's not used, and use the bug issue instead.
2023-09-06 09:37:39 -07:00
dave caruso
a79440f0c3 fix(runtime): fix events.once not working (#4520) 2023-09-06 07:13:05 -07:00
Dylan Conway
daaac7792c allocate task for ThreadSafeFunction (#4513)
* create thread safe function task

* Update napi.zig

* Update napi.zig
2023-09-06 02:04:00 -07:00
2411 changed files with 338847 additions and 171608 deletions

View File

@@ -1,17 +1,15 @@
node_modules
**/node_modules
src/bun.js/WebKit/LayoutTests
zig-out
zig-build
**/*.o
**/*.a
examples
**/*.o
**/.next
.git
src/bun.js/WebKit
**/CMakeCache.txt
**/node_modules
.git
examples
node_modules
packages/**/bun
packages/**/bun-profile
src/bun.js/WebKit
src/bun.js/WebKit/LayoutTests
zig-build
zig-cache
zig-out

36
.gitattributes vendored
View File

@@ -17,37 +17,31 @@
*.mjs text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.mts text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
*.lockb binary diff=lockb
.vscode/launch.json linguist-generated
src/api/schema.d.ts linguist-generated
fixture.*.c linguist-generated
src/api/schema.js linguist-generated
src/bun.js/bindings/sqlite/sqlite3.c linguist-vendored
src/bun.js/bindings/sqlite/sqlite3_local.h linguist-vendored
*.lockb binary diff=lockb
src/bun.js/bindings/simdutf.cpp linguist-vendored
src/bun.js/bindings/simdutf.h linguist-vendored
src/js/out/WebCoreJSBuiltins.cpp linguist-generated
src/js/out/WebCoreJSBuiltins.h linguist-generated
src/js/out/WebCoreJSBuiltins.d.ts linguist-generated
src/bun.js/bindings/ZigGeneratedClasses.h linguist-generated
src/bun.js/bindings/ZigGeneratedClasses.cpp linguist-generated
*-fixture* linguist-generated
src/bun.js/bindings/ZigGeneratedCode.h linguist-generated
src/bun.js/bindings/ZigGeneratedCode.cpp linguist-generated
src/bun.js/bindings/headers.h linguist-generated
src/bun.js/bindings/headers.zig linguist-generated
src/bun.js/bindings/JSSink.h linguist-generated
src/bun.js/bindings/JSSink.zig linguist-generated
packages/bun-uws/fuzzing/seed-corpus/**/* linguist-generated
src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h linguist-generated
src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h linguist-generated
src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h linguist-generated
src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h linguist-generated
src/bun.js/bindings/sqlite/sqlite3.c linguist-vendored
src/bun.js/bindings/sqlite/sqlite3_local.h linguist-vendored
src/bun.js/bindings/simdutf.cpp linguist-vendored
src/bun.js/bindings/simdutf.h linguist-vendored
docs/**/* linguist-documentation
packages/bun-uws/fuzzing/seed-corpus/**/* linguist-generated
# Don't count tests in the language stats - https://github.com/github-linguist/linguist/blob/master/docs/overrides.md
test/**/* linguist-documentation
bench/**/* linguist-documentation
examples/**/* linguist-documentation
src/deps/*.c linguist-vendored
src/deps/brotli/** linguist-vendored

View File

@@ -1,35 +0,0 @@
name: 📥 Install Problem
description: Report an issue during install or upgrade
labels: [bug, install]
body:
- type: markdown
attributes:
value: |
Thank you for submitting a bug report. It helps make Bun better.
If you need help or support using Bun, and are not reporting an issue, please
join our [Discord](https://discord.gg/CXdq2DP29u) server, where you can ask questions in the [`#help`](https://discord.gg/32EtH6p7HN) forum.
Please try to include as much information as possible.
- type: input
attributes:
label: What platform is your computer?
description: |
For MacOS and Linux: copy the output of `uname -mprs`
For Windows: copy the output of `"$([Environment]::OSVersion | ForEach-Object VersionString) $(if ([Environment]::Is64BitOperatingSystem) { "x64" } else { "x86" })"` in the PowerShell console
- type: textarea
attributes:
label: How did you attempt to install or upgrade?
description: Please provide the commands you ran to install or upgrade.
validations:
required: true
- type: textarea
attributes:
label: What do you see instead?
description: If possible, please provide text instead of a screenshot.
validations:
required: true
- type: textarea
attributes:
label: Additional information
description: Is there anything else you think we should know?

View File

@@ -10,7 +10,11 @@ body:
If you need help or support using Bun, and are not reporting a bug, please
join our [Discord](https://discord.gg/CXdq2DP29u) server, where you can ask questions in the [`#help`](https://discord.gg/32EtH6p7HN) forum.
Make sure you are running the [latest](https://bun.sh/docs/installation#upgrading) version of Bun.
The bug you are experiencing may already have been fixed.
Please try to include as much information as possible.
- type: input
attributes:
label: What version of Bun is running?

View File

@@ -0,0 +1,45 @@
name: 🇹 TypeScript Type Bug Report
description: Report an issue with TypeScript types
labels: [bug, typescript]
body:
- type: markdown
attributes:
value: |
Thank you for submitting a bug report. It helps make Bun better.
If you need help or support using Bun, and are not reporting a bug, please
join our [Discord](https://discord.gg/CXdq2DP29u) server, where you can ask questions in the [`#help`](https://discord.gg/32EtH6p7HN) forum.
Make sure you are running the [latest](https://bun.sh/docs/installation#upgrading) version of Bun.
The bug you are experiencing may already have been fixed.
Please try to include as much information as possible.
- type: input
attributes:
label: What version of Bun is running?
description: Copy the output of `bun --revision`
- type: input
attributes:
label: What platform is your computer?
description: |
For MacOS and Linux: copy the output of `uname -mprs`
For Windows: copy the output of `"$([Environment]::OSVersion | ForEach-Object VersionString) $(if ([Environment]::Is64BitOperatingSystem) { "x64" } else { "x86" })"` in the PowerShell console
- type: textarea
attributes:
label: What steps can reproduce the bug?
description: Explain the bug and provide a code snippet that can reproduce it.
validations:
required: true
- type: textarea
attributes:
label: What is the expected behavior?
description: If possible, please provide text instead of a screenshot.
- type: textarea
attributes:
label: What do you see instead?
description: If possible, please provide text instead of a screenshot.
- type: textarea
attributes:
label: Additional information
description: Is there anything else you think we should know?

View File

@@ -8,7 +8,7 @@ body:
Thank you for submitting an idea. It helps make Bun better.
If you want to discuss Bun, or learn how others are using Bun, please
join our [Discord](https://discord.gg/CXdq2DP29u) server, where you can share in the [`#feedback-ideas`](https://discord.gg/unwUnHBNqy) channel.
join our [Discord](https://discord.gg/CXdq2DP29u) server, where you can share in the [`#feedback`](https://discord.gg/unwUnHBNqy) channel.
- type: textarea
attributes:
label: What is the problem this feature would solve?

View File

@@ -19,18 +19,17 @@ This adds a new flag --bail to bun test. When set, it will stop running tests af
<!-- If JavaScript/TypeScript modules or builtins changed:
- [ ] I ran `make js` and committed the transpiled changes
- [ ] I or my editor ran Prettier on the changed files (or I ran `bun fmt`)
- [ ] I included a test for the new code, or an existing test covers it
- [ ] I included a test for the new code, or existing tests cover it
- [ ] I ran my tests locally and they pass (`bun-debug test test-file-name.test`)
-->
<!-- If Zig files changed:
- [ ] I checked the lifetime of memory allocated to verify it's (1) freed and (2) only freed when it should be
- [ ] I or my editor ran `zig fmt` on the changed files
- [ ] I included a test for the new code, or an existing test covers it
- [ ] JSValue used outside outside of the stack is either wrapped in a JSC.Strong or is JSValueProtect'ed
- [ ] I wrote TypeScript/JavaScript tests and they pass locally (`bun-debug test test-file-name.test`)
-->
<!-- If new methods, getters, or setters were added to a publicly exposed class:
@@ -43,17 +42,6 @@ This adds a new flag --bail to bun test. When set, it will stop running tests af
- [ ] I made sure that specific versions of dependencies are used instead of ranged or tagged versions
-->
<!-- If functions were added to exports.zig or bindings.zig
- [ ] I ran `make headers` to regenerate the C header file
-->
<!-- If \*.classes.ts files were added or changed:
- [ ] I ran `make codegen` to regenerate the C++ and Zig code
-->
<!-- If a new builtin ESM/CJS module was added:
- [ ] I updated Aliases in `module_loader.zig` to include the new module

View File

@@ -1,50 +0,0 @@
name: bun-ecosystem-test
on:
schedule:
- cron: "0 15 * * *" # every day at 7am PST
workflow_dispatch:
inputs:
version:
description: "The version of Bun to run"
required: true
default: "canary"
type: string
jobs:
test:
name: ${{ matrix.tag }}
runs-on: ${{ matrix.os }}
if: github.repository_owner == 'oven-sh'
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
tag: linux-x64
url: linux/x64?avx2=true
- os: ubuntu-latest
tag: linux-x64-baseline
url: linux/x64?baseline=true
# FIXME: runner fails with "No tests found"?
#- os: macos-latest
# tag: darwin-x64
# url: darwin/x64?avx2=true
- os: macos-latest
tag: darwin-x64-baseline
url: darwin/x64?baseline=true
steps:
- id: checkout
name: Checkout
uses: Bhacaz/checkout-files@v2
with:
files: packages/bun-internal-test
- id: setup
name: Setup
uses: oven-sh/setup-bun@v1
with:
bun-download-url: https://bun.sh/download/${{ github.event.inputs.version }}/${{ matrix.url }}
- id: test
name: Test
working-directory: packages/bun-internal-test
run: bun run test:ecosystem

View File

@@ -1,41 +0,0 @@
name: bun-framework-next
on:
push:
paths:
- packages/bun-framework-next/**/*
branches: [main, bun-framework-next-actions]
pull_request:
paths:
- packages/bun-framework-next/**/*
branches: [main]
jobs:
build:
name: lint, test and build on Node ${{ matrix.node }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
node: ["14.x"]
os: [macOS-latest]
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- name: Install PNPM
uses: pnpm/action-setup@v2.0.1
with:
version: 6.21.0
- name: Install dependencies
run: cd packages/bun-framework-next && pnpm install
- name: Type check bun-framework-next
run: cd packages/bun-framework-next && pnpm check

View File

@@ -4,11 +4,6 @@ concurrency:
group: bun-linux-aarch64-${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
TEST_TAG: bun-test'
on:
push:
branches:
@@ -16,9 +11,26 @@ on:
paths:
- "src/**/*"
- "test/**/*"
- "packages/bun-usockets/src/**/*"
- "packages/bun-uws/src/**/*"
- "CMakeLists.txt"
- "build.zig"
- "Makefile"
- "Dockerfile"
- ".github/workflows/bun-linux-aarch64.yml"
pull_request:
branches:
- main
paths:
- "src/**/*"
- "test/**/*"
- "packages/bun-usockets/src/**/*"
- "packages/bun-uws/src/**/*"
- "CMakeLists.txt"
- "build.zig"
- "Makefile"
- "Dockerfile"
- ".github/workflows/bun-linux-aarch64.yml"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
@@ -28,6 +40,7 @@ jobs:
runs-on: ${{matrix.runner}}
if: github.repository_owner == 'oven-sh'
timeout-minutes: 90
permissions: write-all
strategy:
matrix:
include:
@@ -36,14 +49,15 @@ jobs:
arch: aarch64
build_arch: arm64
runner: linux-arm64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-linux-arm64-lto.tar.gz"
webkit_basename: "bun-webkit-linux-arm64-lto"
build_machine_arch: aarch64
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
submodules: false
ref: ${{github.sha}}
clean: true
- run: |
bash ./scripts/update-submodules.sh
- uses: docker/setup-buildx-action@v2
id: buildx
with:
@@ -71,9 +85,7 @@ jobs:
BUILDARCH=${{matrix.build_arch}}
BUILD_MACHINE_ARCH=${{matrix.build_machine_arch}}
CPU_TARGET=${{matrix.cpu}}
WEBKIT_URL=${{matrix.webkit_url}}
GIT_SHA=${{github.sha}}
WEBKIT_BASENAME=${{matrix.webkit_basename}}
platforms: linux/${{matrix.build_arch}}
target: artifact
outputs: type=local,dest=${{runner.temp}}/release
@@ -109,14 +121,6 @@ jobs:
with:
name: bun-${{matrix.tag}}
path: ${{runner.temp}}/release/bun-${{matrix.tag}}.zip
- uses: actions/upload-artifact@v3
with:
name: bun-obj-${{matrix.tag}}
path: ${{runner.temp}}/release/bun-obj
- uses: actions/upload-artifact@v3
with:
name: ${{matrix.tag}}-dependencies
path: ${{runner.temp}}/release/bun-dependencies
- name: Release
id: release
uses: ncipollo/release-action@v1

View File

@@ -4,11 +4,6 @@ concurrency:
group: bun-linux-build-${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
TEST_TAG: bun-test'
on:
push:
branches:
@@ -16,6 +11,9 @@ on:
paths:
- "src/**/*"
- "test/**/*"
- "packages/bun-usockets/src/**/*"
- "packages/bun-uws/src/**/*"
- "CMakeLists.txt"
- "build.zig"
- "Makefile"
- "Dockerfile"
@@ -25,6 +23,9 @@ on:
paths:
- "src/**/*"
- "test/**/*"
- "packages/bun-usockets/src/**/*"
- "packages/bun-uws/src/**/*"
- "CMakeLists.txt"
- "build.zig"
- "Makefile"
- "Dockerfile"
@@ -37,6 +38,7 @@ jobs:
runs-on: ${{matrix.runner}}
if: github.repository_owner == 'oven-sh'
timeout-minutes: 90
permissions: write-all
strategy:
fail-fast: false
matrix:
@@ -46,22 +48,44 @@ jobs:
arch: x86_64
build_arch: amd64
runner: big-ubuntu
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-linux-amd64-lto.tar.gz"
webkit_basename: "bun-webkit-linux-amd64-lto"
build_machine_arch: x86_64
assertions: "OFF"
zig_optimize: "ReleaseFast"
target: "artifact"
- cpu: nehalem
tag: linux-x64-baseline
arch: x86_64
build_arch: amd64
runner: big-ubuntu
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-linux-amd64-lto.tar.gz"
webkit_basename: "bun-webkit-linux-amd64-lto"
build_machine_arch: x86_64
assertions: "OFF"
zig_optimize: "ReleaseFast"
target: "artifact"
# - cpu: haswell
# tag: linux-x64-assertions
# arch: x86_64
# build_arch: amd64
# runner: big-ubuntu
# build_machine_arch: x86_64
# assertions: "ON"
# zig_optimize: "ReleaseSafe"
# target: "artifact-assertions"
# - cpu: nehalem
# tag: linux-x64-baseline-assertions
# arch: x86_64
# build_arch: amd64
# runner: big-ubuntu
# build_machine_arch: x86_64
# assertions: "ON"
# zig_optimize: "ReleaseSafe"
# target: "artifact-assertions"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
ref: ${{github.sha}}
clean: true
- uses: docker/setup-buildx-action@v2
id: buildx
with:
@@ -89,12 +113,23 @@ jobs:
BUILDARCH=${{matrix.build_arch}}
BUILD_MACHINE_ARCH=${{matrix.build_machine_arch}}
CPU_TARGET=${{matrix.cpu}}
WEBKIT_URL=${{matrix.webkit_url}}
GIT_SHA=${{github.sha}}
WEBKIT_BASENAME=${{matrix.webkit_basename}}
ASSERTIONS=${{matrix.assertions}}
ZIG_OPTIMIZE=${{matrix.zig_optimize}}
SCCACHE_BUCKET=bun
SCCACHE_REGION=auto
SCCACHE_S3_USE_SSL=true
SCCACHE_ENDPOINT=${{ secrets.CACHE_S3_ENDPOINT }}
AWS_ACCESS_KEY_ID=${{ secrets.CACHE_S3_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }}
platforms: linux/${{matrix.build_arch}}
target: artifact
target: ${{matrix.target}}
outputs: type=local,dest=${{runner.temp}}/release
- id: bun-version-check
name: Bun version check
run: |
# If this hangs, it means something is seriously wrong with the build
${{runner.temp}}/release/bun-profile --version
- name: Zip
run: |
# if zip is not found
@@ -152,13 +187,33 @@ jobs:
name: "Canary (${{github.sha}})"
tag: "canary"
artifacts: "${{runner.temp}}/release/bun-${{matrix.tag}}.zip,${{runner.temp}}/release/bun-${{matrix.tag}}-profile.zip"
- uses: sarisia/actions-status-discord@v1
if: failure() && github.repository_owner == 'oven-sh' && github.event_name == 'pull_request'
with:
title: ""
webhook: ${{ secrets.DISCORD_WEBHOOK }}
status: ${{ job.status }}
noprefix: true
nocontext: true
description: |
Pull Request
### [${{github.event.pull_request.title}}](https://github.com/oven-sh/bun/pull/${{github.event.number}})
@${{ github.actor }}
Build failed on ${{ matrix.tag }}:
**[View build output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})**
[Commit ${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})
linux-test:
name: Tests ${{matrix.tag}}
runs-on: ubuntu-latest
needs: [linux]
if: github.event_name == 'pull_request'
timeout-minutes: 20
permissions:
pull-requests: write
outputs:
failing_tests: ${{ steps.test.outputs.failing_tests }}
failing_tests_count: ${{ steps.test.outputs.failing_tests_count }}
@@ -168,27 +223,54 @@ jobs:
include:
- tag: linux-x64
- tag: linux-x64-baseline
# - tag: linux-x64-assertions
# - tag: linux-x64-baseline-assertions
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: false
clean: true
- id: download
name: Download
uses: actions/download-artifact@v3
with:
name: bun-${{matrix.tag}}
path: ${{runner.temp}}/release
- id: install
name: Install
- id: install-bun
name: Install Bun
run: |
cd ${{runner.temp}}/release
unzip bun-${{matrix.tag}}.zip
cd bun-${{matrix.tag}}
chmod +x bun
pwd >> $GITHUB_PATH
./bun --version
- id: bun-version-check
name: Bun version check
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
# 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
# - name: Set core dumps to get stored in /cores
# run: |
# sudo mkdir /cores
# sudo chmod 777 /cores
# # Core filenames will be of the form executable.pid.timestamp:
# sudo bash -c 'echo "/cores/%e.%p.%t" > /proc/sys/kernel/core_pattern'
- id: test
name: Test (node runner)
env:
@@ -197,11 +279,32 @@ jobs:
TLS_POSTGRES_DATABASE_URL: ${{ secrets.TLS_POSTGRES_DATABASE_URL }}
# if: ${{github.event.inputs.use_bun == 'false'}}
run: |
sudo apt-get update && sudo apt-get install -y openssl
bun install
bun install --cwd test
bun install --cwd packages/bun-internal-test
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: sarisia/actions-status-discord@v1
if: always() && steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request'
with:
title: ""
webhook: ${{ secrets.DISCORD_WEBHOOK }}
status: "failure"
noprefix: true
nocontext: true
description: |
Pull Request
### ❌ [${{github.event.pull_request.title}}](https://github.com/oven-sh/bun/pull/${{github.event.number}})
@${{ github.actor }}, there are ${{ steps.test.outputs.failing_tests_count }} files with test failures on ${{ matrix.tag }}:
${{ steps.test.outputs.failing_tests }}
**[View test output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})**
- name: Comment on PR
if: steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request'
uses: thollander/actions-comment-pull-request@v2

View File

@@ -5,9 +5,8 @@ concurrency:
cancel-in-progress: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
TEST_TAG: bun-test'
LLVM_VERSION: 16
BUN_DOWNLOAD_URL_BASE: https://pub-5e11e972747a44bf9aaf9394f185a982.r2.dev/releases/latest
on:
push:
@@ -15,6 +14,9 @@ on:
paths:
- "src/**/*"
- "test/**/*"
- "packages/bun-usockets/src/**/*"
- "packages/bun-uws/src/**/*"
- "CMakeLists.txt"
- "build.zig"
- "Makefile"
- "Dockerfile"
@@ -23,6 +25,9 @@ on:
paths:
- "src/**/*"
- "test/**/*"
- "packages/bun-usockets/src/**/*"
- "packages/bun-uws/src/**/*"
- "CMakeLists.txt"
- "build.zig"
- "Makefile"
- "Dockerfile"
@@ -30,79 +35,141 @@ on:
workflow_dispatch:
jobs:
macos-object-files:
name: macOS Object
macOS-zig:
name: macOS Zig Object
runs-on: med-ubuntu
if: github.repository_owner == 'oven-sh'
strategy:
matrix:
include:
# - cpu: nehalem
# arch: x86_64
# tag: bun-obj-darwin-x64-baseline
# - cpu: haswell
# arch: x86_64
# tag: bun-obj-darwin-x64
- cpu: native
arch: aarch64
tag: bun-obj-darwin-aarch64
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: docker/setup-buildx-action@v2
- uses: actions/checkout@v4
# - name: Checkout submodules
# run: git submodule update --init --recursive --depth=1 --progress --force
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
id: buildx
with:
install: true
- name: Run
run: |
rm -rf ${{runner.temp}}/release
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
- name: Compile Zig Object
uses: docker/build-push-action@v3
if: runner.arch == 'X64'
with:
context: .
push: false
cache-from: type=gha
cache-to: type=gha,mode=min
# This doesnt seem to work
# cache-from: type=s3,endpoint_url=${{ secrets.CACHE_S3_ENDPOINT }},blobs_prefix=docker_blobs/,manifests_prefix=docker_manifests/,access_key_id=${{ secrets.CACHE_S3_ACCESS_KEY_ID }},secret_access_key=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }},bucket=bun,region=auto
# cache-to: type=s3,endpoint_url=${{ secrets.CACHE_S3_ENDPOINT }},blobs_prefix=docker_blobs/,manifests_prefix=docker_manifests/,access_key_id=${{ secrets.CACHE_S3_ACCESS_KEY_ID }},secret_access_key=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }},bucket=bun,region=auto
build-args: |
BUILDARCH=${{ runner.arch == 'X64' && 'amd64' || 'arm64' }}
BUILD_MACHINE_ARCH=${{ runner.arch == 'X64' && 'x86_64' || 'aarch64' }}
ARCH=${{ matrix.arch }}
BUILDARCH=amd64
BUILD_MACHINE_ARCH=x86_64
CPU_TARGET=${{ matrix.cpu }}
TRIPLET=${{matrix.arch}}-macos-none
GIT_SHA=${{github.sha}}
platforms: linux/amd64
TRIPLET=${{ matrix.arch }}-macos-none
GIT_SHA=${{ github.sha }}
platforms: linux/${{ runner.arch == 'X64' && 'amd64' || 'arm64' }}
target: build_release_obj
outputs: type=local,dest=${{runner.temp}}/release
- name: Build and push
uses: docker/build-push-action@v3
if: runner.arch == 'ARM64'
with:
context: .
push: false
cache-from: type=gha
cache-to: type=gha,mode=min
build-args: |
ARCH=${{ matrix.arch }}
BUILDARCH=arm64
BUILD_MACHINE_ARCH=aarch64
CPU_TARGET=${{ matrix.cpu }}
TRIPLET=${{matrix.arch}}-macos-none
GIT_SHA=${{github.sha}}
platforms: linux/arm64
target: build_release_obj
outputs: type=local,dest=${{runner.temp}}/release
- uses: actions/upload-artifact@v3
- name: Upload Zig Object
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.tag }}
path: ${{runner.temp}}/release/bun.o
path: ${{runner.temp}}/release/bun-zig.o
macOS-dependencies:
name: macOS Dependencies
runs-on: ${{ matrix.runner }}
if: github.repository_owner == 'oven-sh'
timeout-minutes: 15
strategy:
matrix:
include:
- cpu: native
arch: aarch64
tag: bun-darwin-aarch64
obj: bun-obj-darwin-aarch64
artifact: bun-obj-darwin-aarch64
runner: macos-13-xlarge
steps:
- uses: actions/checkout@v4
- name: Checkout submodules
run: git submodule update --init --recursive --depth=1 --progress --force
- name: Install system dependencies
env:
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
run: |
brew install go sccache ccache rust llvm@$LLVM_VERSION pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config --force
echo "$(brew --prefix ccache)/bin" >> $GITHUB_PATH
# echo "$(brew --prefix sccache)/bin" >> $GITHUB_PATH
echo "$(brew --prefix coreutils)/libexec/gnubin" >> $GITHUB_PATH
echo "$(brew --prefix llvm@$LLVM_VERSION)/bin" >> $GITHUB_PATH
brew link --overwrite llvm@$LLVM_VERSION
curl -LO "$BUN_DOWNLOAD_URL_BASE/bun-darwin-aarch64.zip"
unzip bun-darwin-aarch64.zip
mkdir -p ${{ runner.temp }}/.bun/bin
mv bun-darwin-aarch64/bun ${{ runner.temp }}/.bun/bin/bun
chmod +x ${{ runner.temp }}/.bun/bin/bun
echo "${{ runner.temp }}/.bun/bin" >> $GITHUB_PATH
- name: Hash submodule versions
run: |
print_data() {
git submodule | grep -v WebKit
llvm-config --version
rustc --version
cat $(echo scripts/build*.sh scripts/all-dependencies.sh | tr " " "\n" | sort)
}
echo "sha=$(print_data | sha1sum | cut -c 1-10)" >> $GITHUB_OUTPUT
id: submodule-versions
- name: Cache submodule dependencies
id: cache-deps-restore
uses: actions/cache/restore@v3
with:
path: ${{runner.temp}}/bun-deps
key: bun-deps-${{ matrix.tag }}-${{ steps.submodule-versions.outputs.sha }}
- name: Compile submodule dependencies
if: ${{ !steps.cache-deps-restore.outputs.cache-hit }}
env:
CPU_TARGET: ${{ matrix.cpu }}
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
run: |
mkdir -p $BUN_DEPS_OUT_DIR
bash ./scripts/clean-dependencies.sh
bash ./scripts/all-dependencies.sh
- name: Cache submodule dependencies
if: ${{ !steps.cache-deps-restore.outputs.cache-hit }}
id: cache-deps-save
uses: actions/cache/save@v3
with:
path: ${{runner.temp}}/bun-deps
key: ${{ steps.cache-deps-restore.outputs.cache-primary-key }}
- name: Upload submodule dependencies
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.tag }}-deps
path: ${{runner.temp}}/bun-deps
macOS-cpp:
name: macOS C++
runs-on: ${{ matrix.runner }}
@@ -111,256 +178,152 @@ jobs:
strategy:
matrix:
include:
# - cpu: nehalem
# arch: x86_64
# tag: bun-darwin-x64-baseline
# obj: bun-obj-darwin-x64-baseline
# runner: macos-11
# artifact: bun-obj-darwin-x64-baseline
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: true
# compile_obj: false
# - cpu: haswell
# arch: x86_64
# tag: bun-darwin-x64
# obj: bun-obj-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: true
# compile_obj: false
# - cpu: nehalem
# arch: x86_64
# tag: bun-darwin-x64-baseline
# obj: bun-obj-darwin-x64-baseline
# runner: macos-11
# artifact: bun-obj-darwin-x64-baseline
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: false
# compile_obj: true
# - cpu: haswell
# arch: x86_64
# tag: bun-darwin-x64
# obj: bun-obj-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: false
# compile_obj: true
- cpu: native
arch: aarch64
tag: bun-darwin-aarch64
obj: bun-obj-darwin-aarch64
artifact: bun-obj-darwin-aarch64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-arm64-lto.tar.gz"
runner: macos-arm64
dependencies: true
compile_obj: true
runner: macos-13-xlarge
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Checkout submodules
run: git submodule update --init --recursive --depth=1 --progress -j $(sysctl -n hw.ncpu)
- name: Install dependencies
run: git submodule update --init --recursive --depth=1 --progress --force
- name: Install system dependencies
env:
CPU_TARGET: ${{ matrix.cpu }}
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
run: |
brew install ccache rust llvm@15 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
brew install go sccache ccache rust llvm@$LLVM_VERSION pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config --force
echo "$(brew --prefix ccache)/bin" >> $GITHUB_PATH
# echo "$(brew --prefix sccache)/bin" >> $GITHUB_PATH
echo "$(brew --prefix coreutils)/libexec/gnubin" >> $GITHUB_PATH
echo "$(brew --prefix llvm@15)/bin" >> $GITHUB_PATH
brew link --overwrite llvm@15
echo "$(brew --prefix llvm@$LLVM_VERSION)/bin" >> $GITHUB_PATH
brew link --overwrite llvm@$LLVM_VERSION
curl -LO "$BUN_DOWNLOAD_URL_BASE/bun-darwin-aarch64.zip"
unzip bun-darwin-aarch64.zip
mkdir -p ${{ runner.temp }}/.bun/bin
mv bun-darwin-aarch64/bun ${{ runner.temp }}/.bun/bin/bun
chmod +x ${{ runner.temp }}/.bun/bin/bun
echo "${{ runner.temp }}/.bun/bin" >> $GITHUB_PATH
# TODO: replace with sccache
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ runner.os }}-ccache-${{ matrix.tag }}
restore-keys: ${{ runner.os }}-ccache-${{ matrix.tag }}
- name: Download WebKit
if: matrix.compile_obj
env:
CPU_TARGET: ${{ matrix.cpu }}
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
BUN_RELEASE_DIR: ${{ runner.temp }}/release
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
run: |
rm -rf $JSC_BASE_DIR
mkdir -p $JSC_BASE_DIR
curl -L ${{ matrix.webkit_url }} | tar -xz -C $JSC_BASE_DIR --strip-components=1
- name: Compile dependencies
if: matrix.dependencies
env:
CPU_TARGET: ${{ matrix.cpu }}
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
BUN_RELEASE_DIR: ${{ runner.temp }}/release
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
run: |
mkdir -p $BUN_DEPS_OUT_DIR
make vendor-without-check
- name: Compile C++
if: matrix.compile_obj
env:
CPU_TARGET: ${{ matrix.cpu }}
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
SOURCE_DIR: ${{ github.workspace }}
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
BUN_RELEASE_DIR: ${{ runner.temp }}/release
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
run: |
mkdir -p $OBJ_DIR $BUN_DEPS_OUT_DIR
make clean-bindings
make -j $(sysctl -n hw.ncpu) release-bindings
mkdir -p $OBJ_DIR
cd $OBJ_DIR
cmake -S $SOURCE_DIR -B $OBJ_DIR \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DBUN_CPP_ONLY=1 \
-DNO_CONFIGURE_DEPENDS=1
bash compile-cpp-only.sh -v
- name: Upload C++
if: matrix.compile_obj
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.tag }}-cpp
path: ${{ runner.temp }}/bun-cpp-obj
- name: Upload Dependencies
if: matrix.dependencies
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.tag }}-deps
path: ${{runner.temp}}/bun-deps
macOS:
path: ${{ runner.temp }}/bun-cpp-obj/bun-cpp-objects.a
macOS-link:
name: macOS Link
runs-on: ${{ matrix.runner }}
if: github.repository_owner == 'oven-sh'
needs: [macOS-cpp, macos-object-files]
timeout-minutes: 90
needs: [macOS-zig, macOS-cpp, macOS-dependencies]
timeout-minutes: 60
permissions: write-all
strategy:
matrix:
include:
# - cpu: nehalem
# arch: x86_64
# tag: bun-darwin-x64-baseline
# obj: bun-obj-darwin-x64-baseline
# package: bun-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64-baseline
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
# - cpu: haswell
# arch: x86_64
# tag: bun-darwin-x64
# obj: bun-obj-darwin-x64
# package: bun-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
- cpu: native
arch: aarch64
tag: bun-darwin-aarch64
obj: bun-obj-darwin-aarch64
package: bun-darwin-aarch64
artifact: bun-obj-darwin-aarch64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-arm64-lto.tar.gz"
runner: macos-arm64
runner: macos-13-xlarge
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
ref: ${{github.sha}}
clean: true
- name: Checkout submodules
run: git submodule update --init --recursive --depth=1 --progress -j $(sysctl -n hw.ncpu)
- name: Install dependencies
run: git submodule update --init --recursive --depth=1 --progress --force
- name: Install system dependencies
env:
CPU_TARGET: ${{ matrix.cpu }}
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
run: |
brew install rust ccache llvm@15 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
brew install ccache llvm@$LLVM_VERSION pkg-config coreutils libtool cmake libiconv openssl@1.1 ninja --force
echo "$(brew --prefix ccache)/bin" >> $GITHUB_PATH
echo "$(brew --prefix coreutils)/libexec/gnubin" >> $GITHUB_PATH
echo "$(brew --prefix llvm@15)/bin" >> $GITHUB_PATH
brew link --overwrite llvm@15
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ runner.os }}-ccache-${{ matrix.tag }}-link
restore-keys: ${{ runner.os }}-ccache-${{ matrix.tag }}-link
- name: Download WebKit
env:
CPU_TARGET: ${{ matrix.cpu }}
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
run: |
rm -rf $JSC_BASE_DIR
mkdir -p $JSC_BASE_DIR
curl -L ${{ matrix.webkit_url }} | tar -xz -C $JSC_BASE_DIR --strip-components=1
echo "$(brew --prefix llvm@$LLVM_VERSION)/bin" >> $GITHUB_PATH
brew link --overwrite llvm@$LLVM_VERSION
curl -LO "$BUN_DOWNLOAD_URL_BASE/bun-darwin-${{matrix.arch}}.zip"
unzip bun-darwin-${{matrix.arch}}.zip
mkdir -p ${{ runner.temp }}/.bun/bin
mv bun-darwin-${{matrix.arch}}/bun ${{ runner.temp }}/.bun/bin/bun
chmod +x ${{ runner.temp }}/.bun/bin/bun
echo "${{ runner.temp }}/.bun/bin" >> $GITHUB_PATH
- name: Download C++
uses: actions/download-artifact@v3
with:
name: ${{ matrix.tag }}-cpp
path: ${{ runner.temp }}/bun-cpp-obj
- name: Download Dependencies
uses: actions/download-artifact@v3
with:
name: ${{ matrix.tag }}-deps
path: ${{ runner.temp }}/bun-deps
- name: Download Object
- name: Download Zig Object
uses: actions/download-artifact@v3
with:
name: ${{ matrix.obj }}
path: ${{ runner.temp }}/release
- name: Downloaded submodule dependencies
uses: actions/download-artifact@v3
with:
name: ${{ matrix.tag }}-deps
path: ${{runner.temp}}/bun-deps
- name: Link
env:
CPU_TARGET: ${{ matrix.cpu }}
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
BUN_RELEASE_DIR: ${{ runner.temp }}/release
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
run: |
rm -rf packages/${{ matrix.package }}
mkdir -p packages/${{ matrix.package }}
mv ${{ runner.temp }}/release/* packages/${{ matrix.package }}/
make bun-link-lld-release copy-to-bun-release-dir-bin
SRC_DIR=$PWD
mkdir ${{runner.temp}}/link-build
cd ${{runner.temp}}/link-build
cmake $SRC_DIR \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DBUN_LINK_ONLY=1 \
-DBUN_ZIG_OBJ="${{ runner.temp }}/release/bun-zig.o" \
-DBUN_CPP_ARCHIVE="${{ runner.temp }}/bun-cpp-obj/bun-cpp-objects.a" \
-DBUN_DEPS_OUT_DIR="${{runner.temp}}/bun-deps" \
-DNO_CONFIGURE_DEPENDS=1
ninja -v
- name: Zip
env:
CPU_TARGET: ${{ matrix.cpu }}
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
BUN_RELEASE_DIR: ${{ runner.temp }}/release
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
run: |
cd ${{runner.temp}}/release
cd ${{runner.temp}}/link-build
chmod +x bun-profile bun
mkdir ${{matrix.tag}}-profile
mkdir ${{matrix.tag}}
/usr/bin/strip -S bun
mkdir -p ${{matrix.tag}}-profile/ ${{matrix.tag}}/
mv bun-profile ${{matrix.tag}}-profile/bun-profile
mv bun ${{matrix.tag}}/bun
@@ -370,11 +333,11 @@ jobs:
- uses: actions/upload-artifact@v3
with:
name: ${{matrix.tag}}-profile
path: ${{runner.temp}}/release/${{matrix.tag}}-profile.zip
path: ${{runner.temp}}/link-build/${{matrix.tag}}-profile.zip
- uses: actions/upload-artifact@v3
with:
name: ${{matrix.tag}}
path: ${{runner.temp}}/release/${{matrix.tag}}.zip
path: ${{runner.temp}}/link-build/${{matrix.tag}}.zip
- name: Release
id: release
uses: ncipollo/release-action@v1
@@ -391,12 +354,33 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
name: "Canary (${{github.sha}})"
tag: "canary"
artifacts: "${{runner.temp}}/release/${{matrix.tag}}.zip,${{runner.temp}}/release/${{matrix.tag}}-profile.zip"
artifacts: "${{runner.temp}}/link-build/${{matrix.tag}}.zip,${{runner.temp}}/link-build/${{matrix.tag}}-profile.zip"
- uses: sarisia/actions-status-discord@v1
if: failure() && github.repository_owner == 'oven-sh' && github.event_name == 'pull_request'
with:
title: ""
webhook: ${{ secrets.DISCORD_WEBHOOK }}
status: ${{ job.status }}
noprefix: true
nocontext: true
description: |
Pull Request
### [${{github.event.pull_request.title}}](https://github.com/oven-sh/bun/pull/${{github.event.number}})
@${{ github.actor }}
Build failed on ${{ matrix.tag }}:
**[View build output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})**
[Commit ${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})
macOS-test:
name: Tests ${{matrix.tag}}
runs-on: ${{ matrix.runner }}
needs: [macOS]
needs: [macOS-link]
if: github.event_name == 'pull_request' && github.repository_owner == 'oven-sh'
permissions:
pull-requests: write
timeout-minutes: 30
outputs:
failing_tests: ${{ steps.test.outputs.failing_tests }}
@@ -406,7 +390,7 @@ jobs:
matrix:
include:
- tag: bun-darwin-aarch64
runner: macos-arm64
runner: macos-13-xlarge
steps:
- id: checkout
name: Checkout
@@ -419,15 +403,25 @@ jobs:
with:
name: ${{matrix.tag}}
path: ${{runner.temp}}/release
- id: install
name: Install
- id: install-bun
name: Install Bun
run: |
cd ${{runner.temp}}/release
unzip ${{matrix.tag}}.zip
cd ${{matrix.tag}}
chmod +x bun
pwd >> $GITHUB_PATH
./bun --version
- id: bun-version-check
name: Bun version check
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
- id: test
name: Test (node runner)
env:
@@ -436,10 +430,24 @@ jobs:
TLS_POSTGRES_DATABASE_URL: ${{ secrets.TLS_POSTGRES_DATABASE_URL }}
# if: ${{github.event.inputs.use_bun == 'false'}}
run: |
bun install
bun install --cwd test
bun install --cwd packages/bun-internal-test
node packages/bun-internal-test/src/runner.node.mjs || true
- uses: sarisia/actions-status-discord@v1
if: always() && steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request'
with:
title: ""
webhook: ${{ secrets.DISCORD_WEBHOOK }}
status: "failure"
noprefix: true
nocontext: true
description: |
Pull Request
### ❌ [${{github.event.pull_request.title}}](https://github.com/oven-sh/bun/pull/${{github.event.number}})
@${{ github.actor }}, there are ${{ steps.test.outputs.failing_tests_count }} files with test failures on ${{ matrix.tag }}:
${{ steps.test.outputs.failing_tests }}
**[View test output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})**
- name: Comment on PR
if: steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request'
uses: thollander/actions-comment-pull-request@v2

View File

@@ -5,9 +5,8 @@ concurrency:
cancel-in-progress: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
TEST_TAG: bun-test'
LLVM_VERSION: 16
BUN_DOWNLOAD_URL_BASE: https://pub-5e11e972747a44bf9aaf9394f185a982.r2.dev/releases/latest
on:
push:
@@ -15,6 +14,9 @@ on:
paths:
- "src/**/*"
- "test/**/*"
- "packages/bun-usockets/src/**/*"
- "packages/bun-uws/src/**/*"
- "CMakeLists.txt"
- "build.zig"
- "Makefile"
- "Dockerfile"
@@ -23,6 +25,9 @@ on:
paths:
- "src/**/*"
- "test/**/*"
- "packages/bun-usockets/src/**/*"
- "packages/bun-uws/src/**/*"
- "CMakeLists.txt"
- "build.zig"
- "Makefile"
- "Dockerfile"
@@ -47,62 +52,129 @@ jobs:
# arch: aarch64
# tag: bun-obj-darwin-aarch64
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: docker/setup-buildx-action@v2
- uses: actions/checkout@v4
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
id: buildx
with:
install: true
- name: Run
run: |
rm -rf ${{runner.temp}}/release
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
- name: Compile Zig Object
uses: docker/build-push-action@v3
if: runner.arch == 'X64'
with:
context: .
push: false
cache-from: type=gha
cache-to: type=gha,mode=min
# This doesnt seem to work
# cache-from: type=s3,endpoint_url=${{ secrets.CACHE_S3_ENDPOINT }},blobs_prefix=docker_blobs/,manifests_prefix=docker_manifests/,access_key_id=${{ secrets.CACHE_S3_ACCESS_KEY_ID }},secret_access_key=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }},bucket=bun,region=auto
# cache-to: type=s3,endpoint_url=${{ secrets.CACHE_S3_ENDPOINT }},blobs_prefix=docker_blobs/,manifests_prefix=docker_manifests/,access_key_id=${{ secrets.CACHE_S3_ACCESS_KEY_ID }},secret_access_key=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }},bucket=bun,region=auto
# This was used before, but also does not really work
cache-from: type=local,src=/tmp/.buildx-cache-${{matrix.tag}}
cache-to: type=local,dest=/tmp/.buildx-cache-${{matrix.tag}}
build-args: |
BUILDARCH=${{ runner.arch == 'X64' && 'amd64' || 'arm64' }}
BUILD_MACHINE_ARCH=${{ runner.arch == 'X64' && 'x86_64' || 'aarch64' }}
ARCH=${{ matrix.arch }}
BUILDARCH=amd64
BUILD_MACHINE_ARCH=x86_64
CPU_TARGET=${{ matrix.cpu }}
TRIPLET=${{matrix.arch}}-macos-none
GIT_SHA=${{github.sha}}
platforms: linux/amd64
TRIPLET=${{ matrix.arch }}-macos-none
GIT_SHA=${{ github.sha }}
SCCACHE_BUCKET=bun
SCCACHE_REGION=auto
SCCACHE_S3_USE_SSL=true
SCCACHE_ENDPOINT=${{ secrets.CACHE_S3_ENDPOINT }}
AWS_ACCESS_KEY_ID=${{ secrets.CACHE_S3_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }}
platforms: linux/${{ runner.arch == 'X64' && 'amd64' || 'arm64' }}
target: build_release_obj
outputs: type=local,dest=${{runner.temp}}/release
- name: Build and push
uses: docker/build-push-action@v3
if: runner.arch == 'ARM64'
with:
context: .
push: false
cache-from: type=gha
cache-to: type=gha,mode=min
build-args: |
ARCH=${{ matrix.arch }}
BUILDARCH=arm64
BUILD_MACHINE_ARCH=aarch64
CPU_TARGET=${{ matrix.cpu }}
TRIPLET=${{matrix.arch}}-macos-none
GIT_SHA=${{github.sha}}
platforms: linux/arm64
target: build_release_obj
outputs: type=local,dest=${{runner.temp}}/release
- uses: actions/upload-artifact@v3
- name: Upload Zig Object
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.tag }}
path: ${{runner.temp}}/release/bun.o
path: ${{runner.temp}}/release/bun-zig.o
macOS-dependencies:
name: macOS Dependencies
runs-on: ${{ matrix.runner }}
if: github.repository_owner == 'oven-sh'
timeout-minutes: 15
strategy:
matrix:
include:
- cpu: nehalem
arch: x86_64
tag: bun-darwin-x64-baseline
obj: bun-obj-darwin-x64-baseline
runner: macos-12-large
artifact: bun-obj-darwin-x64-baseline
steps:
- uses: actions/checkout@v4
- name: Checkout submodules
run: git submodule update --init --recursive --depth=1 --progress --force
- name: Install system dependencies
env:
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
run: |
brew install sccache ccache rust llvm@$LLVM_VERSION pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config --force
echo "$(brew --prefix ccache)/bin" >> $GITHUB_PATH
# echo "$(brew --prefix sccache)/bin" >> $GITHUB_PATH
echo "$(brew --prefix coreutils)/libexec/gnubin" >> $GITHUB_PATH
echo "$(brew --prefix llvm@$LLVM_VERSION)/bin" >> $GITHUB_PATH
brew link --overwrite llvm@$LLVM_VERSION
- name: Hash submodule versions
run: |
print_data() {
git submodule | grep -v WebKit
llvm-config --version
rustc --version
cat $(echo scripts/build*.sh scripts/all-dependencies.sh | tr " " "\n" | sort)
}
echo "sha=$(print_data | sha1sum | cut -c 1-10)" >> $GITHUB_OUTPUT
id: submodule-versions
- name: Cache submodule dependencies
id: cache-deps-restore
uses: actions/cache/restore@v3
with:
path: ${{runner.temp}}/bun-deps
key: bun-deps-${{ matrix.tag }}-${{ steps.submodule-versions.outputs.sha }}
- name: Compile submodule dependencies
if: ${{ !steps.cache-deps-restore.outputs.cache-hit }}
env:
CPU_TARGET: ${{ matrix.cpu }}
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
run: |
mkdir -p $BUN_DEPS_OUT_DIR
bash ./scripts/clean-dependencies.sh
bash ./scripts/all-dependencies.sh
- name: Cache submodule dependencies
if: ${{ !steps.cache-deps-restore.outputs.cache-hit }}
id: cache-deps-save
uses: actions/cache/save@v3
with:
path: ${{runner.temp}}/bun-deps
key: ${{ steps.cache-deps-restore.outputs.cache-primary-key }}
- name: Upload submodule dependencies
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.tag }}-deps
path: ${{runner.temp}}/bun-deps
macOS-cpp:
name: macOS C++
runs-on: ${{ matrix.runner }}
@@ -115,139 +187,70 @@ jobs:
arch: x86_64
tag: bun-darwin-x64-baseline
obj: bun-obj-darwin-x64-baseline
runner: macos-11
runner: macos-12-large
artifact: bun-obj-darwin-x64-baseline
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
dependencies: true
compile_obj: false
# - cpu: haswell
# arch: x86_64
# tag: bun-darwin-x64
# obj: bun-obj-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: true
# compile_obj: false
- cpu: nehalem
arch: x86_64
tag: bun-darwin-x64-baseline
obj: bun-obj-darwin-x64-baseline
runner: macos-11
artifact: bun-obj-darwin-x64-baseline
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
dependencies: false
compile_obj: true
# - cpu: haswell
# arch: x86_64
# tag: bun-darwin-x64
# obj: bun-obj-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: false
# compile_obj: true
# - cpu: native
# arch: aarch64
# tag: bun-darwin-aarch64
# obj: bun-obj-darwin-aarch64
# artifact: bun-obj-darwin-aarch64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
# runner: macos-arm64
# dependencies: true
# compile_obj: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Checkout submodules
run: git submodule update --init --recursive --depth=1 --progress -j $(sysctl -n hw.ncpu)
- name: Install dependencies
run: git submodule update --init --recursive --depth=1 --progress --force
- name: Install system dependencies
env:
CPU_TARGET: ${{ matrix.cpu }}
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
run: |
brew install ccache rust llvm@15 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
brew install sccache ccache rust llvm@$LLVM_VERSION pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config --force
echo "$(brew --prefix ccache)/bin" >> $GITHUB_PATH
# echo "$(brew --prefix sccache)/bin" >> $GITHUB_PATH
echo "$(brew --prefix coreutils)/libexec/gnubin" >> $GITHUB_PATH
echo "$(brew --prefix llvm@15)/bin" >> $GITHUB_PATH
brew link --overwrite llvm@15
- name: ccache (dependencies)
echo "$(brew --prefix llvm@$LLVM_VERSION)/bin" >> $GITHUB_PATH
brew link --overwrite llvm@$LLVM_VERSION
curl -LO "$BUN_DOWNLOAD_URL_BASE/bun-darwin-x64-baseline.zip"
unzip bun-darwin-x64-baseline.zip
mkdir -p ${{ runner.temp }}/.bun/bin
mv bun-darwin-x64-baseline/bun ${{ runner.temp }}/.bun/bin/bun
chmod +x ${{ runner.temp }}/.bun/bin/bun
echo "${{ runner.temp }}/.bun/bin" >> $GITHUB_PATH
# TODO: replace with sccache
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
if: matrix.dependencies
with:
key: ${{ runner.os }}-ccache-${{ matrix.tag }}-dependencies
restore-keys: ${{ runner.os }}-ccache-${{ matrix.tag }}-dependencies
- name: ccache (c++)
uses: hendrikmuhs/ccache-action@v1.2
if: matrix.compile_obj
with:
key: ${{ runner.os }}-ccache-${{ matrix.tag }}-obj
restore-keys: ${{ runner.os }}-ccache-${{ matrix.tag }}-obj
- name: Download WebKit
if: matrix.compile_obj
env:
CPU_TARGET: ${{ matrix.cpu }}
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
run: |
rm -rf $JSC_BASE_DIR
mkdir -p $JSC_BASE_DIR
curl -L ${{ matrix.webkit_url }} | tar -xz -C $JSC_BASE_DIR --strip-components=1
- name: Compile dependencies
if: matrix.dependencies
env:
CPU_TARGET: ${{ matrix.cpu }}
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
run: |
mkdir -p $OBJ_DIR $BUN_DEPS_OUT_DIR
make vendor-without-check
key: ${{ runner.os }}-ccache-${{ matrix.tag }}
restore-keys: ${{ runner.os }}-ccache-${{ matrix.tag }}
- name: Compile C++
if: matrix.compile_obj
env:
CPU_TARGET: ${{ matrix.cpu }}
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
SOURCE_DIR: ${{ github.workspace }}
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
run: |
mkdir -p $OBJ_DIR $BUN_DEPS_OUT_DIR
make -j $(sysctl -n hw.ncpu) release-bindings
mkdir -p $OBJ_DIR
cd $OBJ_DIR
cmake -S $SOURCE_DIR -B $OBJ_DIR \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DBUN_CPP_ONLY=1 \
-DNO_CONFIGURE_DEPENDS=1
bash compile-cpp-only.sh -v
- name: Upload C++
if: matrix.compile_obj
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.tag }}-cpp
path: ${{ runner.temp }}/bun-cpp-obj
- name: Upload Dependencies
if: matrix.dependencies
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.tag }}-deps
path: ${{runner.temp}}/bun-deps
path: ${{ runner.temp }}/bun-cpp-obj/bun-cpp-objects.a
macOS:
name: macOS Link
runs-on: ${{ matrix.runner }}
if: github.repository_owner == 'oven-sh'
needs: [macOS-cpp, macos-object-files]
needs: [macOS-cpp, macos-object-files, macOS-dependencies]
timeout-minutes: 90
permissions: write-all
strategy:
matrix:
include:
@@ -256,115 +259,72 @@ jobs:
tag: bun-darwin-x64-baseline
obj: bun-obj-darwin-x64-baseline
package: bun-darwin-x64
runner: macos-11
runner: macos-12-large
artifact: bun-obj-darwin-x64-baseline
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
# - cpu: haswell
# arch: x86_64
# tag: bun-darwin-x64
# obj: bun-obj-darwin-x64
# package: bun-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
# - cpu: native
# arch: aarch64
# tag: bun-darwin-aarch64
# obj: bun-obj-darwin-aarch64
# package: bun-darwin-aarch64
# artifact: bun-obj-darwin-aarch64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
# runner: macos-arm64
steps:
- uses: actions/checkout@v3
- name: Checkout submodules
run: git submodule update --init --recursive --depth=1 --progress -j $(sysctl -n hw.ncpu)
- name: Install dependencies
run: git submodule update --init --recursive --depth=1 --progress --force
- name: Install system dependencies
env:
CPU_TARGET: ${{ matrix.cpu }}
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
run: |
brew install ccache rust llvm@15 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
brew install ccache llvm@$LLVM_VERSION pkg-config coreutils libtool cmake libiconv openssl@1.1 ninja --force
echo "$(brew --prefix ccache)/bin" >> $GITHUB_PATH
echo "$(brew --prefix coreutils)/libexec/gnubin" >> $GITHUB_PATH
echo "$(brew --prefix llvm@15)/bin" >> $GITHUB_PATH
brew link --overwrite llvm@15
- name: ccache (link)
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ runner.os }}-ccache-${{ matrix.tag }}-link
restore-keys: ${{ runner.os }}-ccache-${{ matrix.tag }}-link
- name: Download WebKit
env:
CPU_TARGET: ${{ matrix.cpu }}
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
BUN_RELEASE_DIR: ${{ runner.temp }}/release
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
run: |
rm -rf $JSC_BASE_DIR
mkdir -p $JSC_BASE_DIR
curl -L ${{ matrix.webkit_url }} | tar -xz -C $JSC_BASE_DIR --strip-components=1
echo "$(brew --prefix llvm@$LLVM_VERSION)/bin" >> $GITHUB_PATH
brew link --overwrite llvm@$LLVM_VERSION
curl -LO "$BUN_DOWNLOAD_URL_BASE/bun-darwin-x64-baseline.zip"
unzip bun-darwin-x64-baseline.zip
mkdir -p ${{ runner.temp }}/.bun/bin
mv bun-darwin-x64-baseline/bun ${{ runner.temp }}/.bun/bin/bun
chmod +x ${{ runner.temp }}/.bun/bin/bun
echo "${{ runner.temp }}/.bun/bin" >> $GITHUB_PATH
- name: Download C++
uses: actions/download-artifact@v3
with:
name: ${{ matrix.tag }}-cpp
path: ${{ runner.temp }}/bun-cpp-obj
- name: Download Dependencies
uses: actions/download-artifact@v3
with:
name: ${{ matrix.tag }}-deps
path: ${{ runner.temp }}/bun-deps
- name: Download Object
- name: Download Zig Object
uses: actions/download-artifact@v3
with:
name: ${{ matrix.obj }}
path: ${{ runner.temp }}/release
- name: Downloaded submodule dependencies
uses: actions/download-artifact@v3
with:
name: ${{ matrix.tag }}-deps
path: ${{runner.temp}}/bun-deps
- name: Link
env:
CPU_TARGET: ${{ matrix.cpu }}
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
BUN_RELEASE_DIR: ${{ runner.temp }}/release
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
run: |
rm -rf packages/${{ matrix.package }}
mkdir -p packages/${{ matrix.package }}
mv ${{ runner.temp }}/release/* packages/${{ matrix.package }}/
make bun-link-lld-release copy-to-bun-release-dir-bin
SRC_DIR=$PWD
mkdir ${{runner.temp}}/link-build
cd ${{runner.temp}}/link-build
cmake $SRC_DIR \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DBUN_LINK_ONLY=1 \
-DBUN_ZIG_OBJ="${{ runner.temp }}/release/bun-zig.o" \
-DBUN_CPP_ARCHIVE="${{ runner.temp }}/bun-cpp-obj/bun-cpp-objects.a" \
-DBUN_DEPS_OUT_DIR="${{runner.temp}}/bun-deps" \
-DNO_CONFIGURE_DEPENDS=1
ninja -v
- name: Zip
env:
CPU_TARGET: ${{ matrix.cpu }}
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
BUN_RELEASE_DIR: ${{ runner.temp }}/release
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
run: |
cd ${{runner.temp}}/release
cd ${{runner.temp}}/link-build
chmod +x bun-profile bun
mkdir ${{matrix.tag}}-profile
mkdir ${{matrix.tag}}
/usr/bin/strip -S bun
mkdir -p ${{matrix.tag}}-profile/ ${{matrix.tag}}/
mv bun-profile ${{matrix.tag}}-profile/bun-profile
mv bun ${{matrix.tag}}/bun
@@ -374,11 +334,11 @@ jobs:
- uses: actions/upload-artifact@v3
with:
name: ${{matrix.tag}}-profile
path: ${{runner.temp}}/release/${{matrix.tag}}-profile.zip
path: ${{runner.temp}}/link-build/${{matrix.tag}}-profile.zip
- uses: actions/upload-artifact@v3
with:
name: ${{matrix.tag}}
path: ${{runner.temp}}/release/${{matrix.tag}}.zip
path: ${{runner.temp}}/link-build/${{matrix.tag}}.zip
- name: Release
id: release
uses: ncipollo/release-action@v1
@@ -395,12 +355,34 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
name: "Canary (${{github.sha}})"
tag: "canary"
artifacts: "${{runner.temp}}/release/${{matrix.tag}}.zip,${{runner.temp}}/release/${{matrix.tag}}-profile.zip"
artifacts: "${{runner.temp}}/link-build/${{matrix.tag}}.zip,${{runner.temp}}/link-build/${{matrix.tag}}-profile.zip"
- uses: sarisia/actions-status-discord@v1
if: failure() && github.repository_owner == 'oven-sh' && github.event_name == 'pull_request'
with:
title: ""
webhook: ${{ secrets.DISCORD_WEBHOOK }}
status: ${{ job.status }}
noprefix: true
nocontext: true
description: |
Pull Request
### [${{github.event.pull_request.title}}](https://github.com/oven-sh/bun/pull/${{github.event.number}})
@${{ github.actor }}
Build failed on ${{ matrix.tag }}:
**[View build output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})**
[Commit ${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})
macOS-test:
name: Tests ${{matrix.tag}}
name: macOS Test
runs-on: ${{ matrix.runner }}
needs: [macOS]
if: github.event_name == 'pull_request' && github.repository_owner == 'oven-sh'
# if: github.event_name == 'pull_request' && github.repository_owner == 'oven-sh'
if: false
permissions:
pull-requests: write
timeout-minutes: 30
outputs:
failing_tests: ${{ steps.test.outputs.failing_tests }}
@@ -410,7 +392,7 @@ jobs:
matrix:
include:
- tag: bun-darwin-x64-baseline
runner: macos-11
runner: macos-12-large
steps:
- id: checkout
name: Checkout
@@ -423,15 +405,25 @@ jobs:
with:
name: ${{matrix.tag}}
path: ${{runner.temp}}/release
- id: install
name: Install
- id: install-bun
name: Install Bun
run: |
cd ${{runner.temp}}/release
unzip ${{matrix.tag}}.zip
cd ${{matrix.tag}}
chmod +x bun
pwd >> $GITHUB_PATH
./bun --version
- id: bun-version-check
name: Bun version check
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
- id: test
name: Test (node runner)
env:
@@ -440,10 +432,27 @@ jobs:
TLS_POSTGRES_DATABASE_URL: ${{ secrets.TLS_POSTGRES_DATABASE_URL }}
# if: ${{github.event.inputs.use_bun == 'false'}}
run: |
bun install
bun install --cwd test
bun install --cwd packages/bun-internal-test
node packages/bun-internal-test/src/runner.node.mjs || true
- uses: sarisia/actions-status-discord@v1
if: always() && steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request'
with:
title: ""
webhook: ${{ secrets.DISCORD_WEBHOOK }}
status: "failure"
noprefix: true
nocontext: true
description: |
Pull Request
### ❌ [${{github.event.pull_request.title}}](https://github.com/oven-sh/bun/pull/${{github.event.number}})
Hey @${{ github.actor }},
${{ steps.test.outputs.failing_tests_count }} files with test failures on ${{ matrix.tag }}:
${{ steps.test.outputs.failing_tests }}
**[View test output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})**
- name: Comment on PR
if: steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request'
uses: thollander/actions-comment-pull-request@v2

View File

@@ -5,9 +5,8 @@ concurrency:
cancel-in-progress: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
TEST_TAG: bun-test'
LLVM_VERSION: 16
BUN_DOWNLOAD_URL_BASE: https://pub-5e11e972747a44bf9aaf9394f185a982.r2.dev/releases/latest
on:
push:
@@ -15,6 +14,9 @@ on:
paths:
- "src/**/*"
- "test/**/*"
- "packages/bun-usockets/src/**/*"
- "packages/bun-uws/src/**/*"
- "CMakeLists.txt"
- "build.zig"
- "Makefile"
- "Dockerfile"
@@ -23,6 +25,9 @@ on:
paths:
- "src/**/*"
- "test/**/*"
- "packages/bun-usockets/src/**/*"
- "packages/bun-uws/src/**/*"
- "CMakeLists.txt"
- "build.zig"
- "Makefile"
- "Dockerfile"
@@ -30,8 +35,8 @@ on:
workflow_dispatch:
jobs:
macos-object-files:
name: macOS Object
macOS-zig:
name: macOS Zig Object
runs-on: med-ubuntu
if: github.repository_owner == 'oven-sh'
strategy:
@@ -43,66 +48,131 @@ jobs:
- cpu: haswell
arch: x86_64
tag: bun-obj-darwin-x64
# - cpu: native
# arch: aarch64
# tag: bun-obj-darwin-aarch64
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: docker/setup-buildx-action@v2
- uses: actions/checkout@v4
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
id: buildx
with:
install: true
- name: Run
run: |
rm -rf ${{runner.temp}}/release
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
- name: Compile Zig Object
uses: docker/build-push-action@v3
if: runner.arch == 'X64'
with:
context: .
push: false
cache-from: type=gha
cache-to: type=gha,mode=min
# This doesnt seem to work
# cache-from: type=s3,endpoint_url=${{ secrets.CACHE_S3_ENDPOINT }},blobs_prefix=docker_blobs/,manifests_prefix=docker_manifests/,access_key_id=${{ secrets.CACHE_S3_ACCESS_KEY_ID }},secret_access_key=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }},bucket=bun,region=auto
# cache-to: type=s3,endpoint_url=${{ secrets.CACHE_S3_ENDPOINT }},blobs_prefix=docker_blobs/,manifests_prefix=docker_manifests/,access_key_id=${{ secrets.CACHE_S3_ACCESS_KEY_ID }},secret_access_key=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }},bucket=bun,region=auto
# This was used before, but also does not really work
cache-from: type=local,src=/tmp/.buildx-cache-${{matrix.tag}}
cache-to: type=local,dest=/tmp/.buildx-cache-${{matrix.tag}}
build-args: |
BUILDARCH=${{ runner.arch == 'X64' && 'amd64' || 'arm64' }}
BUILD_MACHINE_ARCH=${{ runner.arch == 'X64' && 'x86_64' || 'aarch64' }}
ARCH=${{ matrix.arch }}
BUILDARCH=amd64
BUILD_MACHINE_ARCH=x86_64
CPU_TARGET=${{ matrix.cpu }}
TRIPLET=${{matrix.arch}}-macos-none
GIT_SHA=${{github.sha}}
platforms: linux/amd64
TRIPLET=${{ matrix.arch }}-macos-none
GIT_SHA=${{ github.sha }}
SCCACHE_BUCKET=bun
SCCACHE_REGION=auto
SCCACHE_S3_USE_SSL=true
SCCACHE_ENDPOINT=${{ secrets.CACHE_S3_ENDPOINT }}
AWS_ACCESS_KEY_ID=${{ secrets.CACHE_S3_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }}
platforms: linux/${{ runner.arch == 'X64' && 'amd64' || 'arm64' }}
target: build_release_obj
outputs: type=local,dest=${{runner.temp}}/release
- name: Build and push
uses: docker/build-push-action@v3
if: runner.arch == 'ARM64'
with:
context: .
push: false
cache-from: type=gha
cache-to: type=gha,mode=min
build-args: |
ARCH=${{ matrix.arch }}
BUILDARCH=arm64
BUILD_MACHINE_ARCH=aarch64
CPU_TARGET=${{ matrix.cpu }}
TRIPLET=${{matrix.arch}}-macos-none
GIT_SHA=${{github.sha}}
platforms: linux/arm64
target: build_release_obj
outputs: type=local,dest=${{runner.temp}}/release
- uses: actions/upload-artifact@v3
- name: Upload Zig Object
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.tag }}
path: ${{runner.temp}}/release/bun.o
path: ${{runner.temp}}/release/bun-zig.o
macOS-dependencies:
name: macOS Dependencies
runs-on: ${{ matrix.runner }}
if: github.repository_owner == 'oven-sh'
timeout-minutes: 15
strategy:
matrix:
include:
- cpu: haswell
arch: x86_64
tag: bun-darwin-x64
obj: bun-obj-darwin-x64
runner: macos-12-large
artifact: bun-obj-darwin-x64
steps:
- uses: actions/checkout@v4
- name: Checkout submodules
run: git submodule update --init --recursive --depth=1 --progress --force
- name: Install system dependencies
env:
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
run: |
brew install sccache ccache rust llvm@$LLVM_VERSION pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config --force
echo "$(brew --prefix ccache)/bin" >> $GITHUB_PATH
# echo "$(brew --prefix sccache)/bin" >> $GITHUB_PATH
echo "$(brew --prefix coreutils)/libexec/gnubin" >> $GITHUB_PATH
echo "$(brew --prefix llvm@$LLVM_VERSION)/bin" >> $GITHUB_PATH
brew link --overwrite llvm@$LLVM_VERSION
- name: Hash submodule versions
run: |
print_data() {
git submodule | grep -v WebKit
llvm-config --version
rustc --version
cat $(echo scripts/build*.sh scripts/all-dependencies.sh | tr " " "\n" | sort)
}
echo "sha=$(print_data | sha1sum | cut -c 1-10)" >> $GITHUB_OUTPUT
id: submodule-versions
- name: Cache submodule dependencies
id: cache-deps-restore
uses: actions/cache/restore@v3
with:
path: ${{runner.temp}}/bun-deps
key: bun-deps-${{ matrix.tag }}-${{ steps.submodule-versions.outputs.sha }}
- name: Compile submodule dependencies
if: ${{ !steps.cache-deps-restore.outputs.cache-hit }}
env:
CPU_TARGET: ${{ matrix.cpu }}
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
run: |
mkdir -p $BUN_DEPS_OUT_DIR
bash ./scripts/clean-dependencies.sh
bash ./scripts/all-dependencies.sh
- name: Cache submodule dependencies
if: ${{ !steps.cache-deps-restore.outputs.cache-hit }}
id: cache-deps-save
uses: actions/cache/save@v3
with:
path: ${{runner.temp}}/bun-deps
key: ${{ steps.cache-deps-restore.outputs.cache-primary-key }}
- name: Upload submodule dependencies
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.tag }}-deps
path: ${{runner.temp}}/bun-deps
macOS-cpp:
name: macOS C++
runs-on: ${{ matrix.runner }}
@@ -111,262 +181,148 @@ jobs:
strategy:
matrix:
include:
# - cpu: nehalem
# arch: x86_64
# tag: bun-darwin-x64-baseline
# obj: bun-obj-darwin-x64-baseline
# runner: macos-11
# artifact: bun-obj-darwin-x64-baseline
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: true
# compile_obj: false
- cpu: haswell
arch: x86_64
tag: bun-darwin-x64
obj: bun-obj-darwin-x64
runner: macos-11
runner: macos-12-large
artifact: bun-obj-darwin-x64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
dependencies: true
compile_obj: false
# - cpu: nehalem
# arch: x86_64
# tag: bun-darwin-x64-baseline
# obj: bun-obj-darwin-x64-baseline
# runner: macos-11
# artifact: bun-obj-darwin-x64-baseline
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: false
# compile_obj: true
- cpu: haswell
arch: x86_64
tag: bun-darwin-x64
obj: bun-obj-darwin-x64
runner: macos-11
artifact: bun-obj-darwin-x64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
dependencies: false
compile_obj: true
# - cpu: native
# arch: aarch64
# tag: bun-darwin-aarch64
# obj: bun-obj-darwin-aarch64
# artifact: bun-obj-darwin-aarch64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-arm64-lto.tar.gz"
# runner: macos-arm64
# dependencies: true
# compile_obj: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Checkout submodules
run: git submodule update --init --recursive --depth=1 --progress -j $(sysctl -n hw.ncpu)
- name: Install dependencies
run: git submodule update --init --recursive --depth=1 --progress --force
- name: Install system dependencies
env:
CPU_TARGET: ${{ matrix.cpu }}
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
run: |
brew install rust ccache llvm@15 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
brew install sccache ccache rust llvm@$LLVM_VERSION pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config --force
# echo "$(brew --prefix sccache)/bin" >> $GITHUB_PATH
echo "$(brew --prefix ccache)/bin" >> $GITHUB_PATH
echo "$(brew --prefix coreutils)/libexec/gnubin" >> $GITHUB_PATH
echo "$(brew --prefix llvm@15)/bin" >> $GITHUB_PATH
brew link --overwrite llvm@15
- name: Download WebKit
if: matrix.compile_obj
env:
CPU_TARGET: ${{ matrix.cpu }}
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
run: |
rm -rf $JSC_BASE_DIR
mkdir -p $JSC_BASE_DIR
curl -L ${{ matrix.webkit_url }} | tar -xz -C $JSC_BASE_DIR --strip-components=1
- name: ccache (dependencies)
echo "$(brew --prefix llvm@$LLVM_VERSION)/bin" >> $GITHUB_PATH
brew link --overwrite llvm@$LLVM_VERSION
curl -LO "$BUN_DOWNLOAD_URL_BASE/bun-darwin-x64.zip"
unzip bun-darwin-x64.zip
mkdir -p ${{ runner.temp }}/.bun/bin
mv bun-darwin-x64/bun ${{ runner.temp }}/.bun/bin/bun
chmod +x ${{ runner.temp }}/.bun/bin/bun
echo "${{ runner.temp }}/.bun/bin" >> $GITHUB_PATH
# TODO: replace with sccache
- name: ccache
uses: hendrikmuhs/ccache-action@v1.2
if: matrix.dependencies
with:
key: ${{ runner.os }}-ccache-${{ matrix.tag }}-dependencies
restore-keys: ${{ runner.os }}-ccache-${{ matrix.tag }}-dependencies
- name: ccache (c++)
uses: hendrikmuhs/ccache-action@v1.2
if: matrix.compile_obj
with:
key: ${{ runner.os }}-ccache-${{ matrix.tag }}-obj
restore-keys: ${{ runner.os }}-ccache-${{ matrix.tag }}-obj
- name: Compile dependencies
if: matrix.dependencies
env:
CPU_TARGET: ${{ matrix.cpu }}
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
run: |
mkdir -p $OBJ_DIR $BUN_DEPS_OUT_DIR
make vendor-without-check
key: ${{ runner.os }}-ccache-${{ matrix.tag }}
restore-keys: ${{ runner.os }}-ccache-${{ matrix.tag }}
- name: Compile C++
if: matrix.compile_obj
env:
CPU_TARGET: ${{ matrix.cpu }}
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
SOURCE_DIR: ${{ github.workspace }}
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
run: |
mkdir -p $OBJ_DIR $BUN_DEPS_OUT_DIR
make -j $(sysctl -n hw.ncpu) release-bindings
mkdir -p $OBJ_DIR
cd $OBJ_DIR
cmake -S $SOURCE_DIR -B $OBJ_DIR \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DBUN_CPP_ONLY=1 \
-DNO_CONFIGURE_DEPENDS=1
bash compile-cpp-only.sh -v
- name: Upload C++
if: matrix.compile_obj
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.tag }}-cpp
path: ${{ runner.temp }}/bun-cpp-obj
- name: Upload Dependencies
if: matrix.dependencies
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.tag }}-deps
path: ${{runner.temp}}/bun-deps
path: ${{ runner.temp }}/bun-cpp-obj/bun-cpp-objects.a
macOS:
name: macOS Link
runs-on: ${{ matrix.runner }}
if: github.repository_owner == 'oven-sh'
needs: [macOS-cpp, macos-object-files]
needs: [macOS-cpp, macOS-zig, macOS-dependencies]
timeout-minutes: 90
permissions: write-all
strategy:
matrix:
include:
# - cpu: nehalem
# arch: x86_64
# tag: bun-darwin-x64-baseline
# obj: bun-obj-darwin-x64-baseline
# package: bun-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64-baseline
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
- cpu: haswell
arch: x86_64
tag: bun-darwin-x64
obj: bun-obj-darwin-x64
package: bun-darwin-x64
runner: macos-11
runner: macos-12-large
artifact: bun-obj-darwin-x64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-amd64-lto.tar.gz"
# - cpu: native
# arch: aarch64
# tag: bun-darwin-aarch64
# obj: bun-obj-darwin-aarch64
# package: bun-darwin-aarch64
# artifact: bun-obj-darwin-aarch64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-aug3-5/bun-webkit-macos-arm64-lto.tar.gz"
# runner: macos-arm64
steps:
- uses: actions/checkout@v3
- name: Checkout submodules
run: git submodule update --init --recursive --depth=1 --progress -j $(sysctl -n hw.ncpu)
- name: Install dependencies
run: git submodule update --init --recursive --depth=1 --progress --force
- name: Install system dependencies
env:
CPU_TARGET: ${{ matrix.cpu }}
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
run: |
brew install rust ccache llvm@15 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
brew install ccache llvm@$LLVM_VERSION pkg-config coreutils libtool cmake libiconv openssl@1.1 ninja --force
echo "$(brew --prefix ccache)/bin" >> $GITHUB_PATH
echo "$(brew --prefix coreutils)/libexec/gnubin" >> $GITHUB_PATH
echo "$(brew --prefix llvm@15)/bin" >> $GITHUB_PATH
brew link --overwrite llvm@15
- name: Download WebKit
env:
CPU_TARGET: ${{ matrix.cpu }}
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
BUN_RELEASE_DIR: ${{ runner.temp }}/release
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
run: |
rm -rf $JSC_BASE_DIR
mkdir -p $JSC_BASE_DIR
curl -L ${{ matrix.webkit_url }} | tar -xz -C $JSC_BASE_DIR --strip-components=1
echo "$(brew --prefix llvm@$LLVM_VERSION)/bin" >> $GITHUB_PATH
brew link --overwrite llvm@$LLVM_VERSION
curl -LO "$BUN_DOWNLOAD_URL_BASE/bun-darwin-x64-baseline.zip"
unzip bun-darwin-x64-baseline.zip
mkdir -p ${{ runner.temp }}/.bun/bin
mv bun-darwin-x64-baseline/bun ${{ runner.temp }}/.bun/bin/bun
chmod +x ${{ runner.temp }}/.bun/bin/bun
echo "${{ runner.temp }}/.bun/bin" >> $GITHUB_PATH
- name: Download C++
uses: actions/download-artifact@v3
with:
name: ${{ matrix.tag }}-cpp
path: ${{ runner.temp }}/bun-cpp-obj
- name: Download Dependencies
uses: actions/download-artifact@v3
with:
name: ${{ matrix.tag }}-deps
path: ${{ runner.temp }}/bun-deps
- name: Download Object
- name: Download Zig Object
uses: actions/download-artifact@v3
with:
name: ${{ matrix.obj }}
path: ${{ runner.temp }}/release
- name: ccache (link)
uses: hendrikmuhs/ccache-action@v1.2
- name: Downloaded submodule dependencies
uses: actions/download-artifact@v3
with:
key: ${{ runner.os }}-ccache-${{ matrix.tag }}-link
restore-keys: ${{ runner.os }}-ccache-${{ matrix.tag }}-link
name: ${{ matrix.tag }}-deps
path: ${{runner.temp}}/bun-deps
- name: Link
env:
CPU_TARGET: ${{ matrix.cpu }}
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
BUN_RELEASE_DIR: ${{ runner.temp }}/release
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
run: |
rm -rf packages/${{ matrix.package }}
mkdir -p packages/${{ matrix.package }}
mv ${{ runner.temp }}/release/* packages/${{ matrix.package }}/
make bun-link-lld-release copy-to-bun-release-dir-bin
SRC_DIR=$PWD
mkdir ${{runner.temp}}/link-build
cd ${{runner.temp}}/link-build
cmake $SRC_DIR \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DBUN_LINK_ONLY=1 \
-DBUN_ZIG_OBJ="${{ runner.temp }}/release/bun-zig.o" \
-DBUN_CPP_ARCHIVE="${{ runner.temp }}/bun-cpp-obj/bun-cpp-objects.a" \
-DBUN_DEPS_OUT_DIR="${{runner.temp}}/bun-deps" \
-DNO_CONFIGURE_DEPENDS=1
ninja -v
- name: Zip
env:
CPU_TARGET: ${{ matrix.cpu }}
JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
BUN_RELEASE_DIR: ${{ runner.temp }}/release
WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
run: |
cd ${{runner.temp}}/release
cd ${{runner.temp}}/link-build
chmod +x bun-profile bun
mkdir ${{matrix.tag}}-profile
mkdir ${{matrix.tag}}
/usr/bin/strip -S bun
mkdir -p ${{matrix.tag}}-profile/ ${{matrix.tag}}/
mv bun-profile ${{matrix.tag}}-profile/bun-profile
mv bun ${{matrix.tag}}/bun
@@ -376,11 +332,11 @@ jobs:
- uses: actions/upload-artifact@v3
with:
name: ${{matrix.tag}}-profile
path: ${{runner.temp}}/release/${{matrix.tag}}-profile.zip
path: ${{runner.temp}}/link-build/${{matrix.tag}}-profile.zip
- uses: actions/upload-artifact@v3
with:
name: ${{matrix.tag}}
path: ${{runner.temp}}/release/${{matrix.tag}}.zip
path: ${{runner.temp}}/link-build/${{matrix.tag}}.zip
- name: Release
id: release
uses: ncipollo/release-action@v1
@@ -397,12 +353,33 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
name: "Canary (${{github.sha}})"
tag: "canary"
artifacts: "${{runner.temp}}/release/${{matrix.tag}}.zip,${{runner.temp}}/release/${{matrix.tag}}-profile.zip"
artifacts: "${{runner.temp}}/link-build/${{matrix.tag}}.zip,${{runner.temp}}/link-build/${{matrix.tag}}-profile.zip"
- uses: sarisia/actions-status-discord@v1
if: failure() && github.repository_owner == 'oven-sh' && github.event_name == 'pull_request'
with:
title: ""
webhook: ${{ secrets.DISCORD_WEBHOOK }}
status: ${{ job.status }}
noprefix: true
nocontext: true
description: |
Pull Request
### [${{github.event.pull_request.title}}](https://github.com/oven-sh/bun/pull/${{github.event.number}})
@${{ github.actor }}
Build failed on ${{ matrix.tag }}:
**[View build output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})**
[Commit ${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})
macOS-test:
name: Tests ${{matrix.tag}}
runs-on: ${{ matrix.runner }}
needs: [macOS]
if: github.event_name == 'pull_request' && github.repository_owner == 'oven-sh'
permissions:
pull-requests: write
timeout-minutes: 30
outputs:
failing_tests: ${{ steps.test.outputs.failing_tests }}
@@ -412,7 +389,7 @@ jobs:
matrix:
include:
- tag: bun-darwin-x64
runner: macos-11
runner: macos-12-large
steps:
- id: checkout
name: Checkout
@@ -425,15 +402,25 @@ jobs:
with:
name: ${{matrix.tag}}
path: ${{runner.temp}}/release
- id: install
name: Install
- id: install-bun
name: Install Bun
run: |
cd ${{runner.temp}}/release
unzip ${{matrix.tag}}.zip
cd ${{matrix.tag}}
chmod +x bun
pwd >> $GITHUB_PATH
./bun --version
- id: bun-version-check
name: Bun version check
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
- id: test
name: Test (node runner)
env:
@@ -442,10 +429,24 @@ jobs:
TLS_POSTGRES_DATABASE_URL: ${{ secrets.TLS_POSTGRES_DATABASE_URL }}
# if: ${{github.event.inputs.use_bun == 'false'}}
run: |
bun install
bun install --cwd test
bun install --cwd packages/bun-internal-test
node packages/bun-internal-test/src/runner.node.mjs || true
- uses: sarisia/actions-status-discord@v1
if: always() && steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request'
with:
title: ""
webhook: ${{ secrets.DISCORD_WEBHOOK }}
status: "failure"
noprefix: true
nocontext: true
description: |
Pull Request
### ❌ [${{github.event.pull_request.title}}](https://github.com/oven-sh/bun/pull/${{github.event.number}})
@${{ github.actor }}, there are ${{ steps.test.outputs.failing_tests_count }} files with test failures on ${{ matrix.tag }}:
${{ steps.test.outputs.failing_tests }}
**[View test output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})**
- name: Comment on PR
if: steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request'
uses: thollander/actions-comment-pull-request@v2

View File

@@ -1,179 +0,0 @@
name: bun-release-canary
concurrency: release-canary
on:
schedule:
- cron: "0 14 * * *" # every day at 6am PST
workflow_dispatch:
jobs:
sign:
name: Sign Release
runs-on: ubuntu-latest
if: github.repository_owner == 'oven-sh'
defaults:
run:
working-directory: packages/bun-release
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
- id: setup-gpg
name: Setup GPG
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- id: setup-bun
name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: canary
- id: bun-install
name: Install Dependencies
run: bun install
- id: bun-run
name: Sign Release
run: |
echo "$GPG_PASSPHRASE" | bun upload-assets -- "canary"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
npm:
name: Release to NPM
runs-on: ubuntu-latest
needs: sign
if: github.repository_owner == 'oven-sh'
defaults:
run:
working-directory: packages/bun-release
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
- id: setup-bun
name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: canary
- id: bun-install
name: Install Dependencies
run: bun install
- id: bun-run
name: Release
run: bun upload-npm -- canary publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# npm-types:
# name: Release types to NPM
# runs-on: ubuntu-latest
# defaults:
# run:
# working-directory: packages/bun-types
# steps:
# - id: checkout
# name: Checkout
# uses: actions/checkout@v3
# - id: setup-node
# name: Setup Node.js
# uses: actions/setup-node@v3
# with:
# node-version: latest
# - id: setup-bun
# name: Setup Bun
# uses: oven-sh/setup-bun@v1
# with:
# bun-version: canary
# - id: bun-install
# name: Install Dependencies
# run: bun install
# - id: setup-env
# name: Setup Environment
# run: |
# SHA=$(git rev-parse --short "$GITHUB_SHA")
# VERSION=$(bun --version)
# TAG="${VERSION}-canary.$(date '+%Y%m%d').1+${SHA}"
# echo "Setup tag: ${TAG}"
# echo "TAG=${TAG}" >> ${GITHUB_ENV}
# - id: bun-run
# name: Build
# run: bun run build
# env:
# BUN_VERSION: ${{ env.TAG }}
# - id: npm-publish
# name: Release
# uses: JS-DevTools/npm-publish@v1
# with:
# package: packages/bun-types/dist/package.json
# token: ${{ secrets.NPM_TOKEN }}
# tag: canary
docker:
name: Release to Dockerhub
runs-on: ubuntu-latest
needs: sign
if: github.repository_owner == 'oven-sh'
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
- id: qemu
name: Setup Docker QEMU
uses: docker/setup-qemu-action@v2
- id: buildx
name: Setup Docker buildx
uses: docker/setup-buildx-action@v2
with:
platforms: linux/amd64,linux/arm64
- id: metadata
name: Setup Docker metadata
uses: docker/metadata-action@v4
with:
images: oven/bun
tags: canary
- id: login
name: Login to Docker
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- id: push
name: Push to Docker
uses: docker/build-push-action@v3
with:
context: ./dockerhub
file: ./dockerhub/Dockerfile-debian
platforms: linux/amd64,linux/arm64
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
build-args: |
BUN_VERSION=canary
s3:
name: Upload to S3
runs-on: ubuntu-latest
needs: sign
if: github.repository_owner == 'oven-sh'
defaults:
run:
working-directory: packages/bun-release
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
- id: setup-bun
name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: canary
- id: bun-install
name: Install Dependencies
run: bun install
- id: bun-run
name: Release
run: bun upload-s3 -- canary
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
AWS_ENDPOINT: ${{ secrets.AWS_ENDPOINT }}
AWS_BUCKET: bun

View File

@@ -1,54 +0,0 @@
name: bun-release-types-canary
concurrency: release-canary
on:
push:
branches:
- main
paths:
- "packages/bun-types/**"
workflow_dispatch:
jobs:
npm-types:
name: Release types to NPM
runs-on: ubuntu-latest
if: github.repository_owner == 'oven-sh'
defaults:
run:
working-directory: packages/bun-types
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
- id: setup-node
name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: latest
- id: setup-bun
name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: canary
- id: bun-install
name: Install Dependencies
run: bun install
- id: setup-env
name: Setup Environment
run: |
SHA=$(git rev-parse --short "$GITHUB_SHA")
VERSION=$(bun --version)
TAG="${VERSION}-canary.$(date +'%Y%m%dT%H%M%S')"
echo "Setup tag: ${TAG}"
echo "TAG=${TAG}" >> ${GITHUB_ENV}
- id: bun-run
name: Build
run: bun run build
env:
BUN_VERSION: ${{ env.TAG }}
- id: npm-publish
name: Release
uses: JS-DevTools/npm-publish@v1
with:
package: packages/bun-types/dist/package.json
token: ${{ secrets.NPM_TOKEN }}
tag: canary

View File

@@ -1,52 +1,71 @@
name: bun-release
concurrency: release
env:
BUN_VERSION: ${{ github.event.inputs.tag || github.event.release.tag_name || 'canary' }}
BUN_LATEST: ${{ (github.event.inputs.is-latest || github.event.release.tag_name) && 'true' || 'false' }}
on:
release:
types:
- published
schedule:
- cron: "0 14 * * *" # every day at 6am PST
workflow_dispatch:
inputs:
is-latest:
description: Is this the latest release?
type: boolean
default: false
tag:
type: string
description: The tag to publish
description: What is the release tag? (e.g. "1.0.2", "canary")
required: true
use-docker:
description: Should Docker images be released?
type: boolean
default: false
use-npm:
description: Should npm packages be published?
type: boolean
default: false
use-homebrew:
description: Should binaries be released to Homebrew?
type: boolean
default: false
use-s3:
description: Should binaries be uploaded to S3?
type: boolean
default: false
use-types:
description: Should types be released to npm?
type: boolean
default: false
jobs:
sign:
name: Sign Release
runs-on: ubuntu-latest
if: github.repository_owner == 'oven-sh'
if: ${{ github.repository_owner == 'oven-sh' }}
permissions:
contents: write
defaults:
run:
working-directory: packages/bun-release
steps:
- id: checkout
name: Checkout
- name: Checkout
uses: actions/checkout@v3
- id: setup-env
name: Setup Environment
run: |
TAG="${{ github.event.inputs.tag }}"
TAG="${TAG:-"${{ github.event.release.tag_name }}"}"
echo "Setup tag: ${TAG}"
echo "TAG=${TAG}" >> ${GITHUB_ENV}
- id: setup-gpg
name: Setup GPG
- name: Setup GPG
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- id: setup-bun
name: Setup Bun
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: canary
- id: bun-install
name: Install Dependencies
bun-version: "1.0.21"
- name: Install Dependencies
run: bun install
- id: bun-run
name: Sign Release
- name: Sign Release
run: |
echo "$GPG_PASSPHRASE" | bun upload-assets -- "${{ env.TAG }}"
echo "$GPG_PASSPHRASE" | bun upload-assets -- "${{ env.BUN_VERSION }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
@@ -54,32 +73,23 @@ jobs:
name: Release to NPM
runs-on: ubuntu-latest
needs: sign
if: github.repository_owner == 'oven-sh'
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.use-npm == 'true' }}
permissions:
contents: read
defaults:
run:
working-directory: packages/bun-release
steps:
- id: checkout
name: Checkout
- name: Checkout
uses: actions/checkout@v3
- id: setup-env
name: Setup Environment
run: |
TAG="${{ github.event.inputs.tag }}"
TAG="${TAG:-"${{ github.event.release.tag_name }}"}"
echo "Setup tag: ${TAG}"
echo "TAG=${TAG}" >> ${GITHUB_ENV}
- id: setup-bun
name: Setup Bun
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: canary
- id: bun-install
name: Install Dependencies
bun-version: "1.0.21"
- name: Install Dependencies
run: bun install
- id: bun-run
name: Release
run: bun upload-npm -- "${{ env.TAG }}" publish
- name: Release
run: bun upload-npm -- "${{ env.BUN_VERSION }}" publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -87,63 +97,81 @@ jobs:
name: Release types to NPM
runs-on: ubuntu-latest
needs: sign
if: github.repository_owner == 'oven-sh'
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.use-types == 'true' }}
permissions:
contents: read
defaults:
run:
working-directory: packages/bun-types
steps:
- id: checkout
name: Checkout
- name: Checkout
uses: actions/checkout@v3
- id: setup-env
name: Setup Environment
run: |
TAG="${{ github.event.inputs.tag }}"
TAG="${TAG:-"${{ github.event.release.tag_name }}"}"
echo "Setup tag: ${TAG}"
echo "TAG=${TAG}" >> ${GITHUB_ENV}
- id: setup-node
name: Setup Node.js
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: latest
- id: setup-bun
name: Setup Bun
- name: Setup Bun
if: ${{ env.BUN_VERSION != 'canary' }}
uses: oven-sh/setup-bun@v1
with:
bun-version: canary
- id: bun-install
name: Install Dependencies
bun-version: "1.0.21"
- name: Setup Bun
if: ${{ env.BUN_VERSION == 'canary' }}
uses: oven-sh/setup-bun@v1
with:
bun-version: "canary" # Must be 'canary' so tag is correct
- name: Install Dependencies
run: bun install
- id: bun-run
name: Build
- name: Setup Tag
if: ${{ env.BUN_VERSION == 'canary' }}
run: |
VERSION=$(bun --version)
TAG="${VERSION}-canary.$(date +'%Y%m%dT%H%M%S')"
echo "Setup tag: ${TAG}"
echo "TAG=${TAG}" >> ${GITHUB_ENV}
- name: Build
run: bun run build
env:
BUN_VERSION: ${{ env.TAG }}
- id: npm-publish
name: Release
BUN_VERSION: ${{ env.TAG || env.BUN_VERSION }}
- name: Release (canary)
if: ${{ env.BUN_VERSION == 'canary' }}
uses: JS-DevTools/npm-publish@v1
with:
package: packages/bun-types/dist/package.json
package: packages/bun-types/package.json
token: ${{ secrets.NPM_TOKEN }}
tag: canary
- name: Release (latest)
if: ${{ env.BUN_LATEST == 'true' }}
uses: JS-DevTools/npm-publish@v1
with:
package: packages/bun-types/package.json
token: ${{ secrets.NPM_TOKEN }}
docker:
name: Release to Dockerhub
runs-on: ubuntu-latest
needs: sign
if: github.repository_owner == 'oven-sh'
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.use-docker == 'true' }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- variant: debian
suffix: ""
- variant: debian
suffix: -debian
- variant: slim
suffix: -slim
dir: debian-slim
- variant: alpine
suffix: -alpine
- variant: distroless
suffix: -distroless
steps:
- id: checkout
name: Checkout
- name: Checkout
uses: actions/checkout@v3
- id: environment
name: Setup Environment
run: |
TAG="${{ github.event.inputs.tag }}"
TAG="${TAG:-"${{ github.event.release.tag_name }}"}"
echo "Setup tag: ${TAG}"
echo "TAG=${TAG}" >> ${GITHUB_ENV}
- id: qemu
name: Setup Docker QEMU
- name: Setup Docker emulator
uses: docker/setup-qemu-action@v2
- id: buildx
name: Setup Docker buildx
@@ -155,67 +183,60 @@ jobs:
uses: docker/metadata-action@v4
with:
images: oven/bun
flavor: |
latest=false
tags: |
type=match,pattern=(bun-v)?(\d+.\d+.\d+),group=2,value=${{ env.TAG }}
type=match,pattern=(bun-v)?(\d+.\d+),group=2,value=${{ env.TAG }}
- id: login
name: Login to Docker
type=raw,value=latest,enable=${{ env.BUN_LATEST == 'true' && matrix.suffix == '' }}
type=raw,value=${{ matrix.variant }},enable=${{ env.BUN_LATEST == 'true' }}
type=match,pattern=(bun-v)?(canary|\d+.\d+.\d+),group=2,value=${{ env.BUN_VERSION }},suffix=${{ matrix.suffix }}
type=match,pattern=(bun-v)?(canary|\d+.\d+),group=2,value=${{ env.BUN_VERSION }},suffix=${{ matrix.suffix }}
type=match,pattern=(bun-v)?(canary|\d+),group=2,value=${{ env.BUN_VERSION }},suffix=${{ matrix.suffix }}
- name: Login to Docker
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- id: push
name: Push to Docker
- name: Push to Docker
uses: docker/build-push-action@v3
with:
context: ./dockerhub
file: ./dockerhub/Dockerfile-debian
context: ./dockerhub/${{ matrix.dir || matrix.variant }}
platforms: linux/amd64,linux/arm64
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
build-args: |
BUN_VERSION=${{ env.TAG }}
BUN_VERSION=${{ env.BUN_VERSION }}
homebrew:
name: Release to Homebrew
runs-on: ubuntu-latest
needs: sign
if: github.repository_owner == 'oven-sh'
permissions:
contents: read
if: ${{ github.event_name == 'release' || github.event.inputs.use-homebrew == 'true' }}
steps:
- id: checkout
name: Checkout
- name: Checkout
uses: actions/checkout@v3
with:
repository: oven-sh/homebrew-bun
token: ${{ secrets.ROBOBUN_TOKEN }}
- id: setup-gpg
- id: gpg
name: Setup GPG
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- id: setup-env
name: Setup Environment
run: |
TAG="${{ github.event.inputs.tag }}"
TAG="${TAG:-"${{ github.event.release.tag_name }}"}"
echo "Setup tag: ${TAG}"
echo "TAG=${TAG}" >> ${GITHUB_ENV}
- id: setup-ruby
name: Setup Ruby
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "2.6"
- id: update-tap
name: Update Tap
run: ruby scripts/release.rb "${{ env.TAG }}"
- id: commit-tap
name: Commit Tap
- name: Update Tap
run: ruby scripts/release.rb "${{ env.BUN_VERSION }}"
- name: Commit Tap
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_options: --gpg-sign=${{ steps.setup-gpg.outputs.keyid }}
commit_message: Release ${{ env.TAG }}
commit_options: --gpg-sign=${{ steps.gpg.outputs.keyid }}
commit_message: Release ${{ env.BUN_VERSION }}
commit_user_name: robobun
commit_user_email: robobun@oven.sh
commit_author: robobun <robobun@oven.sh>
@@ -223,32 +244,23 @@ jobs:
name: Upload to S3
runs-on: ubuntu-latest
needs: sign
if: github.repository_owner == 'oven-sh'
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.use-s3 == 'true' }}
permissions:
contents: read
defaults:
run:
working-directory: packages/bun-release
steps:
- id: checkout
name: Checkout
- name: Checkout
uses: actions/checkout@v3
- id: setup-env
name: Setup Environment
run: |
TAG="${{ github.event.inputs.tag }}"
TAG="${TAG:-"${{ github.event.release.tag_name }}"}"
echo "Setup tag: ${TAG}"
echo "TAG=${TAG}" >> ${GITHUB_ENV}
- id: setup-bun
name: Setup Bun
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: canary
- id: bun-install
name: Install Dependencies
bun-version: "1.0.21"
- name: Install Dependencies
run: bun install
- id: bun-run
name: Release
run: bun upload-s3 -- "${{ env.TAG }}"
- name: Release
run: bun upload-s3 -- "${{ env.BUN_VERSION }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}

492
.github/workflows/bun-windows.yml vendored Normal file
View File

@@ -0,0 +1,492 @@
name: bun-windows
concurrency:
group: bun-windows-${{ github.ref }}
cancel-in-progress: true
env:
# note: in other files, this version is only the major version, but for windows it is the full version
LLVM_VERSION: 16.0.6
BUN_DOWNLOAD_URL_BASE: https://pub-5e11e972747a44bf9aaf9394f185a982.r2.dev/releases/latest
tag: bun-windows
# TODO: wire this up to workflow_dispatch.
# github's expression syntax makes this hard to set a default to true
canary: true
on:
push:
branches: [main]
paths:
- "src/**/*"
- "test/**/*"
- "packages/bun-usockets/src/**/*"
- "packages/bun-uws/src/**/*"
- "CMakeLists.txt"
- "build.zig"
- "Makefile"
- "Dockerfile"
pull_request:
branches: [main]
paths:
- "src/**/*"
- "test/**/*"
- "packages/bun-usockets/src/**/*"
- "packages/bun-uws/src/**/*"
- "CMakeLists.txt"
- "build.zig"
- "Makefile"
- "Dockerfile"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# inputs:
# is-canary:
# type: boolean
# description: Is Canary Build?
# default: true
jobs:
windows-zig:
strategy:
fail-fast: false
matrix:
cpu: [haswell, nehalem]
arch: [x86_64]
name: Zig Build
runs-on: med-ubuntu
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: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Calculate Canary Revision
if: ${{ env.canary == 'true' }}
id: canary
run: |
echo "canary_revision=$(GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" bash ./scripts/calculate-canary-revision.sh --raw)" >> $GITHUB_OUTPUT
- name: Compile Zig Object
uses: docker/build-push-action@v3
if: runner.arch == 'X64'
with:
context: .
push: false
# This doesnt seem to work
# cache-from: type=s3,endpoint_url=${{ secrets.CACHE_S3_ENDPOINT }},blobs_prefix=docker_blobs/,manifests_prefix=docker_manifests/,access_key_id=${{ secrets.CACHE_S3_ACCESS_KEY_ID }},secret_access_key=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }},bucket=bun,region=auto
# cache-to: type=s3,endpoint_url=${{ secrets.CACHE_S3_ENDPOINT }},blobs_prefix=docker_blobs/,manifests_prefix=docker_manifests/,access_key_id=${{ secrets.CACHE_S3_ACCESS_KEY_ID }},secret_access_key=${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }},bucket=bun,region=auto
build-args: |
BUILDARCH=${{ runner.arch == 'X64' && 'amd64' || 'arm64' }}
BUILD_MACHINE_ARCH=${{ runner.arch == 'X64' && 'x86_64' || 'aarch64' }}
ARCH=${{ matrix.arch }}
CPU_TARGET=${{ matrix.cpu }}
TRIPLET=${{ matrix.arch }}-windows-msvc
GIT_SHA=${{ github.sha }}
CANARY=${{ env.canary == 'true' && steps.canary.outputs.canary_revision || '0' }}
ZIG_OPTIMIZE=ReleaseSafe
# TODO(@paperdave): enable ASSERTIONS=1
platforms: linux/${{ runner.arch == 'X64' && 'amd64' || 'arm64' }}
target: build_release_obj
outputs: type=local,dest=${{runner.temp}}/release
- name: Upload Zig Object
uses: actions/upload-artifact@v3
with:
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}-zig${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}
path: ${{runner.temp}}/release/bun-zig.o
windows-dependencies:
name: Dependencies
runs-on: windows
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
cpu: [haswell, nehalem]
arch: [x86_64]
steps:
- run: git config --global core.autocrlf false && git config --global core.eol lf
- name: Checkout
uses: actions/checkout@v4
- name: Clone Submodules
run: .\scripts\update-submodules.ps1
- name: Hash submodule versions
shell: pwsh
run: |
$data = "$(& {
git submodule | Where-Object { $_ -notmatch 'WebKit' }
clang --version
rustc --version
Get-Content -Path (Get-ChildItem -Path 'scripts/build*.ps1', 'scripts/all-dependencies.ps1', 'scripts/env.ps1' | Sort-Object -Property Name).FullName | Out-String
echo 1
})"
$hash = ( -join ((New-Object -TypeName System.Security.Cryptography.SHA1CryptoServiceProvider).ComputeHash([System.Text.Encoding]::UTF8.GetBytes($data)) | ForEach-Object { $_.ToString("x2") } )).Substring(0, 10)
echo "sha=${hash}" >> $env:GITHUB_OUTPUT
id: submodule-versions
- name: Try fetch dependencies
id: cache-deps-restore
uses: actions/cache/restore@v3
with:
path: bun-deps
key: bun-deps-${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}-${{ steps.submodule-versions.outputs.sha }}
- name: Install LLVM ${{ env.LLVM_VERSION }}
if: ${{ !steps.cache-deps-restore.outputs.cache-hit }}
uses: KyleMayes/install-llvm-action@1a3da29f56261a1e1f937ec88f0856a9b8321d7e
with:
version: ${{ env.LLVM_VERSION }}
- name: Install Ninja
if: ${{ !steps.cache-deps-restore.outputs.cache-hit }}
run: choco install -y ninja
- name: Build Dependencies
if: ${{ !steps.cache-deps-restore.outputs.cache-hit }}
run: |
.\scripts\env.ps1 ${{ matrix.cpu == 'nehalem' && '-Baseline' || '' }}
Invoke-WebRequest -Uri "https://www.nasm.us/pub/nasm/releasebuilds/2.16.01/win64/nasm-2.16.01-win64.zip" -OutFile nasm.zip
Expand-Archive nasm.zip (mkdir -Force "nasm")
$Nasm = (Get-ChildItem "nasm")
$env:Path += ";${Nasm}"
$env:BUN_DEPS_OUT_DIR = (mkdir -Force "./bun-deps")
.\scripts\all-dependencies.ps1
- name: Upload Dependencies
uses: actions/upload-artifact@v3
with:
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}-deps${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}
path: bun-deps/
- name: Cache Dependencies
if: ${{ !steps.cache-deps-restore.outputs.cache-hit }}
id: cache-deps-save
uses: actions/cache/save@v3
with:
path: bun-deps
key: ${{ steps.cache-deps-restore.outputs.cache-primary-key }}
windows-codegen:
name: Codegen
runs-on: ubuntu-latest
timeout-minutes: 10
if: github.repository_owner == 'oven-sh'
strategy:
fail-fast: false
matrix:
arch: [x86_64]
steps:
- uses: actions/checkout@v4
- run: |
curl -fsSL $BUN_DOWNLOAD_URL_BASE/bun-linux-x64.zip > bun.zip
unzip bun.zip
export PATH="$PWD/bun-linux-x64:$PATH"
./scripts/cross-compile-codegen.sh win32 x64
# Sort of a hack to do this step in the codegen stage
- name: Calculate Canary Revision
if: ${{ env.canary == 'true' }}
run: |
echo "canary_revision=$(GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" bash ./scripts/calculate-canary-revision.sh --raw)" > build-codegen-win32-x64/.canary_revision
- uses: actions/upload-artifact@v3
with:
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}-codegen
path: build-codegen-win32-x64/
windows-cpp:
name: C++ Build
needs: [windows-codegen]
runs-on: windows
if: github.repository_owner == 'oven-sh'
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
cpu: [haswell, nehalem]
arch: [x86_64]
steps:
- run: git config --global core.autocrlf false && git config --global core.eol lf
- uses: actions/checkout@v4
- uses: KyleMayes/install-llvm-action@1a3da29f56261a1e1f937ec88f0856a9b8321d7e
with:
version: ${{ env.LLVM_VERSION }}
- run: choco install -y ninja
- name: Download Codegen
uses: actions/download-artifact@v3
with:
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}-codegen
path: build
- name: Build C++
run: |
# Using SCCache was blocked by an issue that is fixed in a newer version.
# TODO UPDATE
# $sczip = "sccache-v0.6.0-x86_64-pc-windows-msvc"
# Invoke-WebRequest -Uri "https://github.com/mozilla/sccache/releases/download/v0.6.0/${sczip}.zip" -OutFile "${sczip}.zip"
# Expand-Archive "${sczip}.zip"
# $env:SCCACHE_BUCKET="bun"
# $env:SCCACHE_REGION="auto"
# $env:SCCACHE_S3_USE_SSL="true"
# $env:SCCACHE_ENDPOINT="${{ secrets.CACHE_S3_ENDPOINT }}"
# $env:AWS_ACCESS_KEY_ID="${{ secrets.CACHE_S3_ACCESS_KEY_ID }}"
# $env:AWS_SECRET_ACCESS_KEY="${{ secrets.CACHE_S3_SECRET_ACCESS_KEY }}"
# $SCCACHE="$PWD/${sczip}/${sczip}/sccache.exe"
$CANARY_REVISION = if (Test-Path build/.canary_revision) { Get-Content build/.canary_revision } else { "0" }
.\scripts\env.ps1 ${{ matrix.cpu == 'nehalem' && '-Baseline' || '' }}
.\scripts\update-submodules.ps1
.\scripts\build-libuv.ps1 -CloneOnly $True
cd build
# "-DCCACHE_PROGRAM=${SCCACHE}"
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release `
-DNO_CODEGEN=1 `
-DNO_CONFIGURE_DEPENDS=1 `
"-DCANARY=${CANARY_REVISION}" `
-DBUN_CPP_ONLY=1 ${{ matrix.cpu == 'nehalem' && '-DUSE_BASELINE_BUILD=1' || '' }}
if ($LASTEXITCODE -ne 0) { throw "CMake configuration failed" }
.\compile-cpp-only.ps1 -v
if ($LASTEXITCODE -ne 0) { throw "C++ compilation failed" }
- uses: actions/upload-artifact@v3
with:
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}-cpp${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}
path: build/bun-cpp-objects.a
windows-link:
strategy:
fail-fast: false
matrix:
cpu: [haswell, nehalem]
arch: [x86_64]
name: Link
needs: [windows-dependencies, windows-codegen, windows-cpp, windows-zig]
runs-on: windows-small
if: github.repository_owner == 'oven-sh'
timeout-minutes: 30
permissions: write-all
steps:
- run: git config --global core.autocrlf false && git config --global core.eol lf
- uses: actions/checkout@v4
- uses: KyleMayes/install-llvm-action@1a3da29f56261a1e1f937ec88f0856a9b8321d7e
with:
version: ${{ env.LLVM_VERSION }}
- run: choco install -y ninja
- name: Download Codegen
uses: actions/download-artifact@v3
with:
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}-codegen
path: build
- name: Download Dependencies
uses: actions/download-artifact@v3
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
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
with:
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}-cpp${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}
path: bun-cpp
- name: Link
run: |
.\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" }
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release `
-DNO_CODEGEN=1 `
-DNO_CONFIGURE_DEPENDS=1 `
"-DCANARY=${CANARY_REVISION}" `
-DBUN_LINK_ONLY=1 `
"-DBUN_DEPS_OUT_DIR=$(Resolve-Path ../bun-deps)" `
"-DBUN_CPP_ARCHIVE=$(Resolve-Path ../bun-cpp/bun-cpp-objects.a)" `
"-DBUN_ZIG_OBJ=$(Resolve-Path ../bun-zig/bun-zig.o)" `
${{ matrix.cpu == 'nehalem' && '-DUSE_BASELINE_BUILD=1' || '' }}
if ($LASTEXITCODE -ne 0) { throw "CMake configuration failed" }
ninja -v
if ($LASTEXITCODE -ne 0) { throw "Link failed!" }
- name: Package
run: |
$Dist = mkdir -Force "${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}"
cp -r build\bun.exe "$Dist\bun.exe"
Compress-Archive "$Dist" "${Dist}.zip"
$Dist = "$Dist-profile"
MkDir -Force "$Dist"
cp -r build\bun.exe "$Dist\bun.exe"
cp -r build\bun.pdb "$Dist\bun.pdb"
Compress-Archive "$Dist" "$Dist.zip"
- uses: actions/upload-artifact@v3
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
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
- name: Release
id: release
uses: ncipollo/release-action@v1
if: |
github.repository_owner == 'oven-sh'
&& github.ref == 'refs/heads/main'
with:
prerelease: true
body: "This canary release of Bun corresponds to the commit [${{ github.sha }}]"
allowUpdates: true
replacesArtifacts: true
generateReleaseNotes: true
artifactErrorsFailBuild: true
token: ${{ secrets.GITHUB_TOKEN }}
name: "Canary (${{github.sha}})"
tag: "canary"
artifacts: "${{env.tag}}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}.zip,${{env.tag}}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}-profile.zip"
- uses: sarisia/actions-status-discord@v1
if: failure() && github.repository_owner == 'oven-sh' && github.event_name == 'pull_request'
with:
title: ""
webhook: ${{ secrets.DISCORD_WEBHOOK }}
status: ${{ job.status }}
noprefix: true
nocontext: true
description: |
### [${{github.event.pull_request.title}}](https://github.com/oven-sh/bun/pull/${{github.event.number}})
@${{ github.actor }}
Build failed on Windows ${{ matrix.arch }}${{ matrix.cpu == 'nehalem' && ' Baseline' || '' }}
**[Build Output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})** | [Commit](https://github.com/oven-sh/bun/commits/${{github.sha}})
windows-test:
name: Test
runs-on: windows-small
needs: [windows-link]
if: github.event_name == 'pull_request' && github.repository_owner == 'oven-sh'
permissions:
pull-requests: write
timeout-minutes: 180
outputs:
failing_tests: ${{ steps.test.outputs.failing_tests }}
failing_tests_count: ${{ steps.test.outputs.failing_tests_count }}
strategy:
fail-fast: false
matrix:
# TODO: test baseline, disabled due to noise
cpu: [haswell]
arch: [x86_64]
steps:
- run: git config --global core.autocrlf false && git config --global core.eol lf
- id: checkout
name: Checkout
uses: actions/checkout@v3
with:
submodules: false
- id: download
name: Download Release
uses: actions/download-artifact@v3
with:
name: ${{ env.tag }}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}-profile
path: ${{runner.temp}}/release
- name: Install Bun
run: |
cd ${{runner.temp}}/release
unzip ${{env.tag}}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}-profile.zip
cd ${{env.tag}}-${{ matrix.arch == 'x86_64' && 'x64' || 'aarch64' }}${{ matrix.cpu == 'nehalem' && '-baseline' || '' }}-profile
pwd >> $env:GITHUB_PATH
- name: Install Node
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 ../..
- id: test
name: Run tests
env:
SMTP_SENDGRID_SENDER: ${{ secrets.SMTP_SENDGRID_SENDER }}
TLS_MONGODB_DATABASE_URL: ${{ secrets.TLS_MONGODB_DATABASE_URL }}
TLS_POSTGRES_DATABASE_URL: ${{ secrets.TLS_POSTGRES_DATABASE_URL }}
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"
- uses: sarisia/actions-status-discord@v1
if: always() && steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request'
with:
title: ""
webhook: ${{ secrets.DISCORD_WEBHOOK_WINTEST }}
status: "failure"
noprefix: true
nocontext: true
description: |
### ❌🪟 [${{github.event.pull_request.title}}](https://github.com/oven-sh/bun/pull/${{github.event.number}})
@${{ github.actor }}, there are **${{ steps.test.outputs.failing_test_count }} failing tests** on Windows ${{ matrix.arch }}${{ matrix.cpu == 'nehalem' && ' Baseline' || '' }}
${{ steps.test.outputs.failing_tests }}
[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'
with:
title: ""
webhook: ${{ secrets.DISCORD_WEBHOOK }}
status: "failure"
noprefix: true
nocontext: true
description: |
### ❌🪟 [${{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' || '' }}
${{ steps.test.outputs.regressing_tests }}
[Full 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'
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' || '' }}
${{ steps.test.outputs.regressing_tests }}
[Full Test Output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})
- name: Uncomment on PR
if: steps.test.outputs.regressing_tests == '' && github.event_name == 'pull_request'
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: test-windows-${{ matrix.arch }}-${{ matrix.cpu }}
mode: upsert
create_if_not_exists: false
message: |
✅🪟 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'
run: exit 1

45
.github/workflows/format.yml vendored Normal file
View File

@@ -0,0 +1,45 @@
name: autofix.ci # Must be named this for autofix.ci to work
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
env:
ZIG_VERSION: 0.12.0-dev.1828+225fe6ddb
permissions:
contents: read
jobs:
format:
name: format
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
sparse-checkout: |
src
packages
test
bench
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: "1.0.21"
- name: Setup Zig
uses: goto-bus-stop/setup-zig@c7b6cdd3adba8f8b96984640ff172c37c93f73ee
with:
version: ${{ env.ZIG_VERSION }}
- name: Install Dependencies
run: |
bun install
- name: Format
run: |
bun fmt
bun fmt:zig
- name: Commit # https://autofix.ci/
uses: autofix-ci/action@d3e591514b99d0fca6779455ff8338516663f7cc

View File

@@ -1,76 +0,0 @@
name: prettier
on:
pull_request:
branches:
- main
- jarred/test-actions
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
prettier-fmt:
name: prettier
runs-on: ubuntu-latest
outputs:
prettier_fmt_errs: ${{ steps.fmt.outputs.prettier_fmt_errs }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- id: setup
name: Setup
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- id: install
name: Install prettier
run: bun install
- name: Run prettier
id: fmt
run: |
rm -f .failed
bun prettier --check "./bench/**/*.{ts,tsx,js,jsx,mjs}" "./test/**/*.{ts,tsx,js,jsx,mjs}" "./src/**/*.{ts,tsx,js,jsx}" --config .prettierrc.cjs 2> prettier-fmt.err > prettier-fmt1.err || echo 'failed' > .failed
if [ -s .failed ]; then
delimiter="$(openssl rand -hex 8)"
echo "prettier_fmt_errs<<${delimiter}" >> "${GITHUB_OUTPUT}"
cat prettier-fmt.err >> "${GITHUB_OUTPUT}"
cat prettier-fmt1.err >> "${GITHUB_OUTPUT}"
echo "${delimiter}" >> "${GITHUB_OUTPUT}"
fi
- name: Comment on PR
if: steps.fmt.outputs.prettier_fmt_errs != ''
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: prettier-fmt
message: |
❌ @${{ github.actor }} `prettier` reported errors
```js
${{ steps.fmt.outputs.prettier_fmt_errs }}
```
To one-off fix this manually, run:
```sh
bun fmt
```
You might need to run `bun install` locally and configure your text editor to [auto-format on save](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode).
<sup>[#${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})</sup>
- name: Uncomment on PR
if: steps.fmt.outputs.prettier_fmt_errs == ''
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: prettier-fmt
mode: upsert
create_if_not_exists: false
message: |
✅ `prettier` errors have been resolved. Thank you.
<sup>[#${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})</sup>
- name: Fail the job
if: steps.fmt.outputs.prettier_fmt_errs != ''
run: exit 1

View File

@@ -1,87 +0,0 @@
name: zig-fmt
env:
ZIG_VERSION: 0.12.0-dev.163+6780a6bbf
on:
pull_request:
branches:
- main
- jarred/test-actions
paths:
- "src/**/*.zig"
- "src/*.zig"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
zig-fmt:
name: zig fmt
runs-on: ubuntu-latest
outputs:
zig_fmt_errs: ${{ steps.fmt.outputs.zig_fmt_errs }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Install zig
run: |
curl https://ziglang.org/builds/zig-linux-x86_64-${{env.ZIG_VERSION}}.tar.xz -L -o zig.tar.xz
tar -xf zig.tar.xz
echo "$(pwd)/zig-linux-x86_64-${{env.ZIG_VERSION}}" >> $GITHUB_PATH
- name: Run zig fmt
id: fmt
run: |
zig fmt --check src/*.zig src/**/*.zig 2> zig-fmt.err > zig-fmt.err2 || echo "Failed"
delimiter="$(openssl rand -hex 8)"
echo "zig_fmt_errs<<${delimiter}" >> "${GITHUB_OUTPUT}"
if [ -s zig-fmt.err ]; then
echo "// The following errors occurred:" >> "${GITHUB_OUTPUT}"
cat zig-fmt.err >> "${GITHUB_OUTPUT}"
fi
if [ -s zig-fmt.err2 ]; then
echo "// The following files were not formatted:" >> "${GITHUB_OUTPUT}"
cat zig-fmt.err2 >> "${GITHUB_OUTPUT}"
fi
echo "${delimiter}" >> "${GITHUB_OUTPUT}"
- name: Comment on PR
if: steps.fmt.outputs.zig_fmt_errs != ''
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: zig-fmt
message: |
❌ @${{ github.actor }} `zig fmt` reported errors. Consider configuring your text editor to [auto-format on save](https://github.com/ziglang/vscode-zig)
```zig
// # zig fmt --check src/*.zig src/**/*.zig
${{ steps.fmt.outputs.zig_fmt_errs }}
```
To one-off fix this manually, run:
```sh
zig fmt src/*.zig src/**/*.zig
```
<sup>[#${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})</sup>
<sup>zig v${{env.ZIG_VERSION}}</sup>
- name: Uncomment on PR
if: steps.fmt.outputs.zig_fmt_errs == ''
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: zig-fmt
mode: upsert
create_if_not_exists: false
message: |
✅ `zig fmt` errors have been resolved. Thank you.
<sup>[#${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})</sup>
<sup>zig v${{env.ZIG_VERSION}}</sup>
- name: Fail the job
if: steps.fmt.outputs.zig_fmt_errs != ''
run: exit 1

302
.gitignore vendored
View File

@@ -1,135 +1,167 @@
.DS_Store
zig-cache
packages/*/*.wasm
*.o
*.a
profile.json
node_modules
.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
/test.ts
src/js/out/modules*
src/js/out/functions*
src/js/out/tmp
src/js/out/DebugPath.h
make-dev-stats.csv
.uuid
tsconfig.tsbuildinfo
.DS_Store
zig-cache
packages/*/*.wasm
*.o
*.a
profile.json
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

49
.gitmodules vendored
View File

@@ -1,10 +1,3 @@
[submodule "src/deps/picohttpparser"]
path = src/deps/picohttpparser
url = https://github.com/h2o/picohttpparser.git
ignore = dirty
depth = 1
shallow = true
fetchRecurseSubmodules = false
[submodule "src/javascript/jsc/WebKit"]
path = src/bun.js/WebKit
url = https://github.com/oven-sh/WebKit.git
@@ -13,6 +6,13 @@ depth = 1
update = none
shallow = true
fetchRecurseSubmodules = false
[submodule "src/deps/picohttpparser"]
path = src/deps/picohttpparser
url = https://github.com/h2o/picohttpparser.git
ignore = dirty
depth = 1
shallow = true
fetchRecurseSubmodules = false
[submodule "src/deps/mimalloc"]
path = src/deps/mimalloc
url = https://github.com/Jarred-Sumner/mimalloc.git
@@ -56,15 +56,30 @@ depth = 1
shallow = true
fetchRecurseSubmodules = false
[submodule "src/deps/c-ares"]
path = src/deps/c-ares
url = https://github.com/c-ares/c-ares.git
path = src/deps/c-ares
url = https://github.com/c-ares/c-ares.git
ignore = dirty
depth = 1
shallow = true
fetchRecurseSubmodules = false
[submodule "src/deps/zstd"]
path = src/deps/zstd
url = https://github.com/facebook/zstd.git
ignore = dirty
path = src/deps/zstd
url = https://github.com/facebook/zstd.git
ignore = dirty
depth = 1
shallow = true
fetchRecurseSubmodules = false
[submodule "src/deps/base64"]
path = src/deps/base64
url = https://github.com/aklomp/base64.git
ignore = dirty
depth = 1
shallow = true
path = src/deps/base64
url = https://github.com/aklomp/base64.git
ignore = dirty
depth = 1
shallow = true
fetchRecurseSubmodules = false
[submodule "src/deps/ls-hpack"]
path = src/deps/ls-hpack
url = https://github.com/litespeedtech/ls-hpack.git
ignore = dirty
depth = 1
shallow = true
fetchRecurseSubmodules = false

View File

@@ -1,13 +0,0 @@
src/fallback.html
src/bun.js/WebKit
src/js/out
src/*.out.js
src/*out.*.js
src/deps
src/test/fixtures
src/react-refresh.js
test/snapshots
test/snapshots-no-hmr
test/js/deno/*.test.ts
test/js/deno/**/*.test.ts
bench/react-hello-world/react-hello-world.node.js

View File

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

View File

@@ -1,21 +0,0 @@
// I would have made this a bash script but there isn't an easy way to track
// time in bash sub-second cross platform.
import fs from "fs";
const start = Date.now() + 5;
const result = Bun.spawnSync(process.argv.slice(2), {
stdio: ["inherit", "inherit", "inherit"],
});
const end = Date.now();
const diff = (Math.max(Math.round(end - start), 0) / 1000).toFixed(3);
const success = result.exitCode === 0;
try {
const line = `${new Date().toISOString()}, ${success ? "success" : "fail"}, ${diff}\n`;
if (fs.existsSync(".scripts/make-dev-stats.csv")) {
fs.appendFileSync(".scripts/make-dev-stats.csv", line);
} else {
fs.writeFileSync(".scripts/make-dev-stats.csv", line);
}
} catch {
// Ignore
}
process.exit(result.exitCode);

View File

@@ -1,13 +0,0 @@
#!/bin/bash
set -euxo pipefail
# if bun-webkit node_modules directory exists
if [ -d ./node_modules/bun-webkit ]; then
rm -f bun-webkit
# get the first matching bun-webkit-* directory name
ln -s ./node_modules/$(ls ./node_modules | grep bun-webkit- | head -n 1) ./bun-webkit
fi
# sets up vscode C++ intellisense
rm -f .vscode/clang++
ln -s $(which clang++-15 || which clang++) .vscode/clang++ 2>/dev/null

View File

@@ -1,16 +1,65 @@
{
"configurations": [
{
"name": "Mac",
"name": "Debug",
"forcedInclude": ["${workspaceFolder}/src/bun.js/bindings/root.h"],
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
"includePath": [
"${workspaceFolder}/build/bun-webkit/include",
"${workspaceFolder}/build/codegen",
"${workspaceFolder}/src/bun.js/bindings/",
"${workspaceFolder}/src/bun.js/bindings/webcore/",
"${workspaceFolder}/src/bun.js/bindings/sqlite/",
"${workspaceFolder}/src/bun.js/bindings/webcrypto/",
"${workspaceFolder}/src/bun.js/modules/",
"${workspaceFolder}/src/js/builtins/",
"${workspaceFolder}/src/deps/boringssl/include/",
"${workspaceFolder}/src/deps",
"${workspaceFolder}/src/napi/*",
"${workspaceFolder}/packages/bun-usockets/src",
"${workspaceFolder}/packages/"
],
"browse": {
"path": [
"${workspaceFolder}/build/bun-webkit/include",
"${workspaceFolder}/src/bun.js/bindings",
"${workspaceFolder}/src/napi/*",
"${workspaceFolder}/src/js/builtins/*",
"${workspaceFolder}/src/bun.js/modules/*",
"${workspaceFolder}/src/deps/*",
"${workspaceFolder}/src/deps/boringssl/include/*",
"${workspaceFolder}/packages/bun-usockets/*",
"${workspaceFolder}/packages/bun-uws/*",
"${workspaceFolder}/src/napi/*"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ".vscode/cppdb"
},
"defines": [
"STATICALLY_LINKED_WITH_JavaScriptCore=1",
"STATICALLY_LINKED_WITH_WTF=1",
"BUILDING_WITH_CMAKE=1",
"NOMINMAX",
"ENABLE_INSPECTOR_ALTERNATE_DISPATCHERS=0",
"BUILDING_JSCONLY__",
"USE_FOUNDATION=1",
"ASSERT_ENABLED=1",
"DU_DISABLE_RENAMING=1"
],
"macFrameworkPath": [],
"compilerPath": "${workspaceFolder}/.vscode/clang++",
"cStandard": "c17",
"cppStandard": "c++20"
},
{
"name": "BunWithJSCDebug",
"forcedInclude": ["${workspaceFolder}/src/bun.js/bindings/root.h"],
"includePath": [
"${workspaceFolder}/../webkit-build/include/",
"${workspaceFolder}/bun-webkit/include/",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/ICU/Headers/",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/JavaScriptCore/PrivateHeaders/",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/WTF/Headers",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/bmalloc/Headers/",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Debug/",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Debug/ICU/Headers/",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Debug/JavaScriptCore/PrivateHeaders/",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Debug/WTF/Headers",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Debug/bmalloc/Headers/",
"${workspaceFolder}/src/bun.js/bindings/",
"${workspaceFolder}/src/bun.js/bindings/webcore/",
"${workspaceFolder}/src/bun.js/bindings/sqlite/",
@@ -26,13 +75,11 @@
],
"browse": {
"path": [
"${workspaceFolder}/../webkit-build/include/",
"${workspaceFolder}/bun-webkit/include/",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/ICU/Headers/",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/JavaScriptCore/PrivateHeaders/**",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/WTF/Headers/**",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/bmalloc/Headers/**",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Debug/",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Debug/ICU/Headers/",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Debug/JavaScriptCore/PrivateHeaders/**",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Debug/WTF/Headers/**",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Debug/bmalloc/Headers/**",
"${workspaceFolder}/src/bun.js/bindings/*",
"${workspaceFolder}/src/bun.js/bindings/*",
"${workspaceFolder}/src/napi/*",
@@ -49,7 +96,7 @@
"${workspaceFolder}/src/napi"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ".vscode/cppdb"
"databaseFilename": ".vscode/cppdb_debug"
},
"defines": [
"STATICALLY_LINKED_WITH_JavaScriptCore=1",
@@ -59,7 +106,7 @@
"ENABLE_INSPECTOR_ALTERNATE_DISPATCHERS=0",
"BUILDING_JSCONLY__",
"USE_FOUNDATION=1",
"ASSERT_ENABLED=0",
"ASSERT_ENABLED=1",
"DU_DISABLE_RENAMING=1"
],
"macFrameworkPath": [],

View File

@@ -1,10 +1,33 @@
{
"recommendations": [
// Zig
"ziglang.vscode-zig",
"esbenp.prettier-vscode",
// C/C++
"clang.clangd",
"ms-vscode.cmake-tools",
"xaver.clang-format",
"vadimcn.vscode-lldb",
// JavaScript
"oven.bun-vscode",
"biomejs.biome",
// TypeScript
"better-ts-errors.better-ts-errors",
"MylesMurphy.prettify-ts",
// Markdown
"bierner.markdown-preview-github-styles",
"bierner.markdown-emoji",
"bierner.emojisense",
"bierner.markdown-checkbox",
"bierner.jsdoc-markdown-highlighting",
// TOML
"tamasfe.even-better-toml",
// Other
"bierner.comment-tagged-templates",
"ms-vscode.cpptools"
]
}

1035
.vscode/launch.json generated vendored

File diff suppressed because it is too large Load Diff

186
.vscode/settings.json vendored
View File

@@ -1,50 +1,89 @@
{
"git.autoRepositoryDetection": "openEditors",
// Editor
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file",
// Search
"search.quickOpen.includeSymbols": false,
"search.seedWithNearestWord": true,
"search.smartCase": true,
"search.exclude": {},
"search.exclude": {
"node_modules": true,
".git": true,
"src/bun.js/WebKit": true,
"src/deps/*/**": true
},
"search.followSymlinks": false,
"search.useIgnoreFiles": true,
// Git
"git.autoRepositoryDetection": "openEditors",
"git.ignoreSubmodules": true,
"git.ignoreLimitWarning": true,
// Zig
"zig.initialSetupDone": true,
"zig.buildOnSave": false,
// We do this until we upgrade to latest Zig so that zls doesn't break our code.
"zig.formattingProvider": "extension",
"zig.buildArgs": ["obj", "-Dfor-editor"],
"zig.buildOption": "build",
"zig.buildFilePath": "${workspaceFolder}/build.zig",
"zig.path": "${workspaceFolder}/.cache/zig/zig.exe",
"zig.formattingProvider": "zls",
"zig.zls.enableInlayHints": false,
"[zig]": {
"editor.tabSize": 4,
"editor.useTabStops": false,
"editor.defaultFormatter": "ziglang.vscode-zig",
"editor.formatOnSave": true
"editor.defaultFormatter": "ziglang.vscode-zig"
},
"[ts]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[js]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"zig.zls.enableInlayHints": false,
"[jsx]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
// C++
"lldb.verboseLogging": false,
"cmake.configureOnOpen": false,
"C_Cpp.errorSquiggles": "enabled",
"[cpp]": {
"editor.defaultFormatter": "xaver.clang-format"
},
"[tsx]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
"[c]": {
"editor.defaultFormatter": "xaver.clang-format"
},
"[yaml]": {
"editor.formatOnSave": true
"[h]": {
"editor.defaultFormatter": "xaver.clang-format"
},
// JavaScript
"prettier.enable": false,
"eslint.workingDirectories": ["${workspaceFolder}/packages/bun-types"],
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome",
},
"[javascriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
},
// TypeScript
"typescript.tsdk": "${workspaceFolder}/node_modules/typescript/lib",
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[typescriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
},
// JSON
"[json]": {
"editor.defaultFormatter": "biomejs.biome",
},
"[jsonc]": {
"editor.defaultFormatter": "biomejs.biome",
},
// Markdown
"[markdown]": {
"editor.defaultFormatter": "biomejs.biome",
"editor.unicodeHighlight.ambiguousCharacters": false,
"editor.unicodeHighlight.invisibleCharacters": false,
"diffEditor.ignoreTrimWhitespace": false,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.wordWrap": "on",
"editor.quickSuggestions": {
"comments": "off",
@@ -52,7 +91,18 @@
"other": "off"
}
},
"lldb.verboseLogging": false,
// TOML
"[toml]": {
"editor.defaultFormatter": "biomejs.biome",
},
// YAML
"[yaml]": {
"editor.defaultFormatter": "biomejs.biome",
},
// Files
"files.exclude": {
"**/.git": true,
"**/.svn": true,
@@ -64,8 +114,6 @@
"**/*.xcscheme": true,
"**/*.pem": true,
"**/*.xcodeproj": true,
"test/snapshots": true,
"test/snapshots-no-hmr": true,
"src/bun.js/WebKit": true,
"src/deps/libarchive": true,
"src/deps/mimalloc": true,
@@ -78,36 +126,8 @@
"src/deps/c-ares": true,
"src/deps/tinycc": true,
"src/deps/zstd": true,
"test/snippets/package-json-exports/_node_modules_copy": true,
"src/js/out": true,
"src/packages/bun-uws/fuzzing/seed-corpus/": true
},
"C_Cpp.files.exclude": {
"**/.vscode": true,
"src/bun.js/WebKit/JSTests": true,
"src/bun.js/WebKit/Tools": true,
"src/bun.js/WebKit/WebDriverTests": true,
"src/bun.js/WebKit/WebKit.xcworkspace": true,
"src/bun.js/WebKit/WebKitLibraries": true,
"src/bun.js/WebKit/Websites": true,
"src/bun.js/WebKit/resources": true,
"src/bun.js/WebKit/LayoutTests": true,
"src/bun.js/WebKit/ManualTests": true,
"src/bun.js/WebKit/PerformanceTests": true,
"src/bun.js/WebKit/WebKitLegacy": true,
"src/bun.js/WebKit/WebCore": true,
"src/bun.js/WebKit/WebDriver": true,
"src/bun.js/WebKit/WebKitBuild": true,
"src/bun.js/WebKit/WebInspectorUI": true
},
"[cpp]": {
"editor.defaultFormatter": "xaver.clang-format"
},
"[h]": {
"editor.defaultFormatter": "xaver.clang-format"
},
"[c]": {
"editor.defaultFormatter": "xaver.clang-format"
"**/*.i": true,
"packages/bun-uws/fuzzing/seed-corpus/**/*": true
},
"files.associations": {
"*.lock": "yarnlock",
@@ -189,20 +209,12 @@
"set": "cpp",
"__memory": "cpp",
"memory_resource": "cpp",
"resource.h": "c",
"sysinfo.h": "c",
"*.tcc": "cpp",
"list": "cpp",
"shared_mutex": "cpp",
"cinttypes": "cpp",
"variant": "cpp",
"sysctl.h": "c",
"interface_adresses.h": "c",
"interface_addresses.h": "c",
"ctype.h": "c",
"ethernet.h": "c",
"inet.h": "c",
"packet.h": "c",
"queue": "cpp",
"compare": "cpp",
"concepts": "cpp",
@@ -218,10 +230,40 @@
"regex": "cpp",
"span": "cpp",
"valarray": "cpp",
"codecvt": "cpp"
"codecvt": "cpp",
"xtr1common": "cpp",
"stop_token": "cpp",
"xfacet": "cpp",
"xhash": "cpp",
"xiosbase": "cpp",
"xlocale": "cpp",
"xlocbuf": "cpp",
"xlocinfo": "cpp",
"xlocmes": "cpp",
"xlocmon": "cpp",
"xlocnum": "cpp",
"xloctime": "cpp",
"xmemory": "cpp",
"xstring": "cpp",
"xtree": "cpp",
"xutility": "cpp"
},
"C_Cpp.files.exclude": {
"**/.vscode": true,
"WebKit/JSTests": true,
"WebKit/Tools": true,
"WebKit/WebDriverTests": true,
"WebKit/WebKit.xcworkspace": true,
"WebKit/WebKitLibraries": true,
"WebKit/Websites": true,
"WebKit/resources": true,
"WebKit/LayoutTests": true,
"WebKit/ManualTests": true,
"WebKit/PerformanceTests": true,
"WebKit/WebKitLegacy": true,
"WebKit/WebCore": true,
"WebKit/WebDriver": true,
"WebKit/WebKitBuild": true,
"WebKit/WebInspectorUI": true
},
"cmake.configureOnOpen": false,
"C_Cpp.errorSquiggles": "enabled",
"eslint.workingDirectories": ["packages/bun-types"],
"typescript.tsdk": "node_modules/typescript/lib"
}

64
.vscode/tasks.json vendored
View File

@@ -2,33 +2,51 @@
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "process",
"command": "zig",
"args": ["build"],
"presentation": {
"echo": true,
"reveal": "silent",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": false
"label": "Install Dependencies",
"command": "scripts/all-dependencies.sh",
"windows": {
"command": "scripts/all-dependencies.ps1"
},
"icon": {
"id": "arrow-down"
},
"options": {
"cwd": "${workspaceFolder}"
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "run",
"type": "process",
"command": "zig",
"args": ["run", "${file}"],
"group": "build",
"presentation": {
"showReuseMessage": false,
"clear": true
}
}
"label": "Setup Environment",
"dependsOn": ["Install Dependencies"],
"command": "scripts/setup.sh",
"windows": {
"command": "scripts/setup.ps1"
},
"icon": {
"id": "check"
},
"options": {
"cwd": "${workspaceFolder}"
},
},
{
"type": "process",
"label": "Build Bun",
"dependsOn": ["Setup Environment"],
"command": "bun",
"args": ["run", "build"],
"icon": {
"id": "gear"
},
"options": {
"cwd": "${workspaceFolder}"
},
"isBuildCommand": true,
"runOptions": {
"instanceLimit": 1,
"reevaluateOnRerun": true,
},
},
]
}

1337
CMakeLists.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -10,7 +10,7 @@ Today (February 2023), Bun's codebase has five distinct parts:
- JavaScript, JSX, & TypeScript transpiler, module resolver, and related code
- JavaScript runtime ([`src/bun.js/`](src/bun.js/))
- JavaScript runtime bindings ([`src/bun.zig/bindings/**/*.cpp`](src/bun.zig/bindings/))
- JavaScript runtime bindings ([`src/bun.js/bindings/**/*.cpp`](src/bun.js/bindings/))
- Package manager ([`src/install/`](src/install/))
- Shared utilities ([`src/string_immutable.zig`](src/string_immutable.zig))
@@ -18,7 +18,7 @@ The JavaScript transpiler & module resolver is mostly independent from the runti
## Getting started
Please refer to [Bun's Development Guide](https://bun.sh/docs/project/development) to get your dev environment setup!
Please refer to [Bun's Development Guide](https://bun.sh/docs/project/contributing) to get your dev environment setup!
## Memory management in Bun

File diff suppressed because it is too large Load Diff

183
Makefile
View File

@@ -38,8 +38,7 @@ NATIVE_OR_OLD_MARCH = -march=nehalem
endif
MIN_MACOS_VERSION ?= $(DEFAULT_MIN_MACOS_VERSION)
BUN_BASE_VERSION = 0.8
BUN_BASE_VERSION = 1.0
CI ?= false
AR=
@@ -66,7 +65,7 @@ PACKAGE_JSON_VERSION = $(BUN_BASE_VERSION).$(BUILD_ID)
BUN_BUILD_TAG = bun-v$(PACKAGE_JSON_VERSION)
BUN_RELEASE_BIN = $(PACKAGE_DIR)/bun
PRETTIER ?= $(shell which prettier 2>/dev/null || echo "./node_modules/.bin/prettier")
ESBUILD = $(shell which esbuild 2>/dev/null || echo "./node_modules/.bin/esbuild")
ESBUILD = "$(shell which esbuild 2>/dev/null || echo "./node_modules/.bin/esbuild")"
DSYMUTIL ?= $(shell which dsymutil 2>/dev/null || which dsymutil-15 2>/dev/null)
WEBKIT_DIR ?= $(realpath src/bun.js/WebKit)
WEBKIT_RELEASE_DIR ?= $(WEBKIT_DIR)/WebKitBuild/Release
@@ -74,7 +73,7 @@ WEBKIT_DEBUG_DIR ?= $(WEBKIT_DIR)/WebKitBuild/Debug
WEBKIT_RELEASE_DIR_LTO ?= $(WEBKIT_DIR)/WebKitBuild/ReleaseLTO
NPM_CLIENT ?= $(shell which bun 2>/dev/null || which npm 2>/dev/null)
NPM_CLIENT = "$(shell which bun 2>/dev/null || which npm 2>/dev/null)"
ZIG ?= $(shell which zig 2>/dev/null || echo -e "error: Missing zig. Please make sure zig is in PATH. Or set ZIG=/path/to-zig-executable")
# We must use the same compiler version for the JavaScriptCore bindings and JavaScriptCore
@@ -82,9 +81,9 @@ ZIG ?= $(shell which zig 2>/dev/null || echo -e "error: Missing zig. Please make
# This is easier to happen than you'd expect.
# Using realpath here causes issues because clang uses clang++ as a symlink
# so if that's resolved, it won't build for C++
REAL_CC = $(shell which clang-15 2>/dev/null || which clang 2>/dev/null)
REAL_CXX = $(shell which clang++-15 2>/dev/null || which clang++ 2>/dev/null)
CLANG_FORMAT = $(shell which clang-format-15 2>/dev/null || which clang-format 2>/dev/null)
REAL_CC = $(shell which clang-16 2>/dev/null || which clang 2>/dev/null)
REAL_CXX = $(shell which clang++-16 2>/dev/null || which clang++ 2>/dev/null)
CLANG_FORMAT = $(shell which clang-format-16 2>/dev/null || which clang-format 2>/dev/null)
CC = $(REAL_CC)
CXX = $(REAL_CXX)
@@ -108,14 +107,14 @@ CC_WITH_CCACHE = $(CCACHE_PATH) $(CC)
ifeq ($(OS_NAME),darwin)
# Find LLVM
ifeq ($(wildcard $(LLVM_PREFIX)),)
LLVM_PREFIX = $(shell brew --prefix llvm@15)
LLVM_PREFIX = $(shell brew --prefix llvm@16)
endif
ifeq ($(wildcard $(LLVM_PREFIX)),)
LLVM_PREFIX = $(shell brew --prefix llvm)
endif
ifeq ($(wildcard $(LLVM_PREFIX)),)
# This is kinda ugly, but I can't find a better way to error :(
LLVM_PREFIX = $(shell echo -e "error: Unable to find llvm. Please run 'brew install llvm@15' or set LLVM_PREFIX=/path/to/llvm")
LLVM_PREFIX = $(shell echo -e "error: Unable to find llvm. Please run 'brew install llvm@16' or set LLVM_PREFIX=/path/to/llvm")
endif
LDFLAGS += -L$(LLVM_PREFIX)/lib
@@ -155,7 +154,7 @@ CMAKE_FLAGS_WITHOUT_RELEASE = -DCMAKE_C_COMPILER=$(CC) \
-DCMAKE_OSX_DEPLOYMENT_TARGET=$(MIN_MACOS_VERSION) \
$(CMAKE_CXX_COMPILER_LAUNCHER_FLAG) \
-DCMAKE_AR=$(AR) \
-DCMAKE_RANLIB=$(which llvm-15-ranlib 2>/dev/null || which llvm-ranlib 2>/dev/null)
-DCMAKE_RANLIB=$(which llvm-16-ranlib 2>/dev/null || which llvm-ranlib 2>/dev/null)
@@ -177,7 +176,7 @@ endif
ifeq ($(OS_NAME),linux)
LIBICONV_PATH =
AR = $(shell which llvm-ar-15 2>/dev/null || which llvm-ar 2>/dev/null || which ar 2>/dev/null)
AR = $(shell which llvm-ar-16 2>/dev/null || which llvm-ar 2>/dev/null || which ar 2>/dev/null)
endif
OPTIMIZATION_LEVEL=-O3 $(MARCH_NATIVE)
@@ -187,11 +186,6 @@ BUN_CFLAGS = $(MACOS_MIN_FLAG) $(MARCH_NATIVE) $(OPTIMIZATION_LEVEL) -fno-excep
BUN_TMP_DIR := /tmp/make-bun
CFLAGS=$(CFLAGS_WITHOUT_MARCH) $(MARCH_NATIVE)
DEFAULT_USE_BMALLOC := 1
USE_BMALLOC ?= DEFAULT_USE_BMALLOC
# Set via postinstall
ifeq (,$(realpath $(JSC_BASE_DIR)))
JSC_BASE_DIR = $(realpath $(firstword $(wildcard bun-webkit)))
@@ -274,7 +268,7 @@ STRIP=/usr/bin/strip
endif
ifeq ($(OS_NAME),linux)
STRIP=$(shell which llvm-strip 2>/dev/null || which llvm-strip-15 2>/dev/null || which strip 2>/dev/null || echo "Missing strip")
STRIP=$(shell which llvm-strip 2>/dev/null || which llvm-strip-16 2>/dev/null || which strip 2>/dev/null || echo "Missing strip")
endif
@@ -380,9 +374,7 @@ ICU_FLAGS ?=
# Ideally, we could just look up the linker search paths
ifeq ($(OS_NAME),linux)
LIB_ICU_PATH ?= $(JSC_LIB)
ICU_FLAGS += $(LIB_ICU_PATH)/libicuuc.a $(LIB_ICU_PATH)/libicudata.a $(LIB_ICU_PATH)/libicui18n.a
else
LIB_ICU_PATH ?= $(BUN_DEPS_DIR)
ICU_FLAGS += $(LIB_ICU_PATH)/libicuuc.a $(LIB_ICU_PATH)/libicudata.a $(LIB_ICU_PATH)/libicui18n.a
endif
ifeq ($(OS_NAME),darwin)
@@ -463,7 +455,8 @@ ARCHIVE_FILES_WITHOUT_LIBCRYPTO = $(MINIMUM_ARCHIVE_FILES) \
-lusockets \
-lcares \
-lzstd \
$(BUN_DEPS_OUT_DIR)/libuwsockets.o
$(BUN_DEPS_OUT_DIR)/libuwsockets.o \
$(BUN_DEPS_OUT_DIR)/liblshpack.a
ARCHIVE_FILES = $(ARCHIVE_FILES_WITHOUT_LIBCRYPTO)
@@ -550,7 +543,7 @@ tinycc:
cd $(TINYCC_DIR) && \
make clean && \
AR=$(AR) $(CCACHE_CC_FLAG) CFLAGS='$(CFLAGS_WITHOUT_MARCH) $(NATIVE_OR_OLD_MARCH) -mtune=native $(TINYCC_CFLAGS)' ./configure --enable-static --cc=$(CCACHE_CC_OR_CC) --ar=$(AR) --config-predefs=yes && \
make -j10 && \
make libtcc.a -j10 && \
cp $(TINYCC_DIR)/*.a $(BUN_DEPS_OUT_DIR)
PYTHON=$(shell which python 2>/dev/null || which python3 2>/dev/null || which python2 2>/dev/null)
@@ -664,7 +657,7 @@ endif
.PHONY: assert-deps
assert-deps:
@echo "Checking if the required utilities are available..."
@if [ $(CLANG_VERSION) -lt "15" ]; then echo -e "ERROR: clang version >=15 required, found: $(CLANG_VERSION). Install with:\n\n $(POSIX_PKG_MANAGER) install llvm@15"; exit 1; fi
@if [ $(CLANG_VERSION) -lt "15" ]; then echo -e "ERROR: clang version >=15 required, found: $(CLANG_VERSION). Install with:\n\n $(POSIX_PKG_MANAGER) install llvm@16"; exit 1; fi
@cmake --version >/dev/null 2>&1 || (echo -e "ERROR: cmake is required."; exit 1)
@$(PYTHON) --version >/dev/null 2>&1 || (echo -e "ERROR: python is required."; exit 1)
@$(ESBUILD) --version >/dev/null 2>&1 || (echo -e "ERROR: esbuild is required."; exit 1)
@@ -680,7 +673,7 @@ assert-deps:
@echo "You have the dependencies installed! Woo"
# the following allows you to run `make submodule` to update or init submodules. but we will exclude webkit
# unless you explicity clone it yourself (a huge download)
# unless you explicitly clone it yourself (a huge download)
SUBMODULE_NAMES=$(shell cat .gitmodules | grep 'path = ' | awk '{print $$3}')
ifeq ("$(wildcard src/bun.js/WebKit/.git)", "")
SUBMODULE_NAMES := $(filter-out src/bun.js/WebKit, $(SUBMODULE_NAMES))
@@ -757,14 +750,24 @@ wasm: api mimalloc-wasm build-obj-wasm-small
build-obj-safe:
$(ZIG) build obj -Doptimize=ReleaseSafe -Dcpu="$(CPU_TARGET)"
UWS_CC_FLAGS = -pthread -DLIBUS_USE_OPENSSL=1 -DUWS_HTTPRESPONSE_NO_WRITEMARK=1 -DLIBUS_USE_BORINGSSL=1 -DWITH_BORINGSSL=1 -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion $(UWS_INCLUDE) -DUWS_WITH_PROXY
UWS_CC_FLAGS = -pthread -DLIBUS_USE_OPENSSL=1 -DUWS_HTTPRESPONSE_NO_WRITEMARK=1 -DLIBUS_USE_BORINGSSL=1 -DWITH_BORINGSSL=1 -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion $(UWS_INCLUDE) -DUWS_WITH_PROXY
UWS_CXX_FLAGS = $(UWS_CC_FLAGS) -std=$(CXX_VERSION) -fno-exceptions -fno-rtti
UWS_LDFLAGS = -I$(BUN_DEPS_DIR)/boringssl/include -I$(ZLIB_INCLUDE_DIR)
USOCKETS_DIR = $(BUN_DIR)/packages/bun-usockets
USOCKETS_SRC_DIR = $(USOCKETS_DIR)/src
LSHPACK_SRC_DIR = $(BUN_DEPS_DIR)/ls-hpack
LSHPACK_CC_FLAGS = -DXXH_HEADER_NAME="<xxhash.h>"
LSHPACK_LDFLAGS = -I$(LSHPACK_SRC_DIR) -I$(LSHPACK_SRC_DIR)/deps/xxhash
lshpack:
rm -rf $(LSHPACK_SRC_DIR)/*.i $(LSHPACK_SRC_DIR)/*.bc $(LSHPACK_SRC_DIR)/*.o $(LSHPACK_SRC_DIR)/*.s $(LSHPACK_SRC_DIR)/*.ii $(LSHPACK_SRC_DIR)/*.s
cd $(LSHPACK_SRC_DIR) && $(CC_WITH_CCACHE) -I$(LSHPACK_SRC_DIR) -fno-builtin-malloc -fno-builtin-free -fno-builtin-realloc $(EMIT_LLVM_FOR_RELEASE) $(MACOS_MIN_FLAG) -fPIC $(CFLAGS) $(LSHPACK_CC_FLAGS) -save-temps -I$(BUN_DEPS_DIR)/uws/lshpack/src $(LSHPACK_LDFLAGS) -g $(DEFAULT_LINKER_FLAGS) $(PLATFORM_LINKER_FLAGS) $(OPTIMIZATION_LEVEL) -c $(wildcard $(LSHPACK_SRC_DIR)/lshpack.c) $(wildcard $(LSHPACK_SRC_DIR)/deps/**/*.c)
cd $(LSHPACK_SRC_DIR) && $(AR) rcvs $(BUN_DEPS_OUT_DIR)/liblshpack.a $(LSHPACK_SRC_DIR)/*.{o,bc}
usockets:
rm -rf $(USOCKETS_DIR)/*.i $(USOCKETS_DIR)/*.bc $(USOCKETS_DIR)/*.o $(USOCKETS_DIR)/*.s $(USOCKETS_DIR)/*.ii $(USOCKETS_DIR)/*.s
rm -rf $(USOCKETS_DIR)/*.i $(USOCKETS_DIR)/*.bc $(USOCKETS_DIR)/*.o $(USOCKETS_DIR)/*.s $(USOCKETS_DIR)/*.ii $(USOCKETS_DIR)/*.s $(BUN_DEPS_OUT_DIR)/libusockets.a
cd $(USOCKETS_DIR) && $(CC_WITH_CCACHE) -I$(USOCKETS_SRC_DIR) -fno-builtin-malloc -fno-builtin-free -fno-builtin-realloc $(EMIT_LLVM_FOR_RELEASE) $(MACOS_MIN_FLAG) -fPIC $(CFLAGS) $(UWS_CC_FLAGS) -save-temps -I$(BUN_DEPS_DIR)/uws/uSockets/src $(UWS_LDFLAGS) -g $(DEFAULT_LINKER_FLAGS) $(PLATFORM_LINKER_FLAGS) $(OPTIMIZATION_LEVEL) -c $(wildcard $(USOCKETS_SRC_DIR)/*.c) $(wildcard $(USOCKETS_SRC_DIR)/**/*.c)
cd $(USOCKETS_DIR) && $(CXX_WITH_CCACHE) -I$(USOCKETS_SRC_DIR) -fno-builtin-malloc -fno-builtin-free -fno-builtin-realloc $(EMIT_LLVM_FOR_RELEASE) $(MACOS_MIN_FLAG) -fPIC $(CXXFLAGS) $(UWS_CXX_FLAGS) -save-temps -I$(BUN_DEPS_DIR)/uws/uSockets/src $(UWS_LDFLAGS) -g $(DEFAULT_LINKER_FLAGS) $(PLATFORM_LINKER_FLAGS) $(OPTIMIZATION_LEVEL) -c $(wildcard $(USOCKETS_SRC_DIR)/*.cpp) $(wildcard $(USOCKETS_SRC_DIR)/**/*.cpp)
cd $(USOCKETS_DIR) && $(AR) rcvs $(BUN_DEPS_OUT_DIR)/libusockets.a $(USOCKETS_DIR)/*.{o,bc}
@@ -811,7 +814,7 @@ fmt-cpp:
.PHONY: fmt-zig
fmt-zig:
cd src && zig fmt **/*.zig
cd src && $(ZIG) fmt **/*.zig
.PHONY: fmt
fmt: fmt-cpp fmt-zig
@@ -820,7 +823,6 @@ fmt: fmt-cpp fmt-zig
api:
./node_modules/.bin/peechy --schema src/api/schema.peechy --esm src/api/schema.js --ts src/api/schema.d.ts --zig src/api/schema.zig
$(ZIG) fmt src/api/schema.zig
$(PRETTIER) --config=.prettierrc.cjs --write src/api/schema.js src/api/schema.d.ts
.PHONY: node-fallbacks
node-fallbacks:
@@ -833,17 +835,7 @@ fallback_decoder:
.PHONY: runtime_js
runtime_js:
@NODE_ENV=production $(ESBUILD) --define:process.env.NODE_ENV="production" --target=esnext --bundle src/runtime/index.ts --format=iife --platform=browser --global-name=BUN_RUNTIME --minify --external:/bun:* > src/runtime.out.js; cat src/runtime.footer.js >> src/runtime.out.js
@NODE_ENV=production $(ESBUILD) --define:process.env.NODE_ENV="production" --target=esnext --bundle src/runtime/index-with-refresh.ts --format=iife --platform=browser --global-name=BUN_RUNTIME --minify --external:/bun:* > src/runtime.out.refresh.js; cat src/runtime.footer.with-refresh.js >> src/runtime.out.refresh.js
@NODE_ENV=production $(ESBUILD) --define:process.env.NODE_ENV="production" --target=esnext --bundle src/runtime/index-without-hmr.ts --format=iife --platform=node --global-name=BUN_RUNTIME --minify --external:/bun:* > src/runtime.node.pre.out.js; cat src/runtime.node.pre.out.js src/runtime.footer.node.js > src/runtime.node.out.js
@NODE_ENV=production $(ESBUILD) --define:process.env.NODE_ENV="production" --target=esnext --bundle src/runtime/index-without-hmr.ts --format=iife --platform=node --global-name=BUN_RUNTIME --minify --external:/bun:* > src/runtime.bun.pre.out.js; cat src/runtime.bun.pre.out.js src/runtime.footer.bun.js > src/runtime.bun.out.js
.PHONY: runtime_js_dev
runtime_js_dev:
@NODE_ENV=development $(ESBUILD) --define:process.env.NODE_ENV="development" --target=esnext --bundle src/runtime/index.ts --format=iife --platform=browser --global-name=BUN_RUNTIME --external:/bun:* > src/runtime.out.js; cat src/runtime.footer.js >> src/runtime.out.js
@NODE_ENV=development $(ESBUILD) --define:process.env.NODE_ENV="development" --target=esnext --bundle src/runtime/index-with-refresh.ts --format=iife --platform=browser --global-name=BUN_RUNTIME --external:/bun:* > src/runtime.out.refresh.js; cat src/runtime.footer.with-refresh.js >> src/runtime.out.refresh.js
@NODE_ENV=development $(ESBUILD) --define:process.env.NODE_ENV="development" --target=esnext --bundle src/runtime/index-without-hmr.ts --format=iife --platform=node --global-name=BUN_RUNTIME --external:/bun:* > src/runtime.node.pre.out.js; cat src/runtime.node.pre.out.js src/runtime.footer.node.js > src/runtime.node.out.js
@NODE_ENV=development $(ESBUILD) --define:process.env.NODE_ENV="development" --target=esnext --bundle src/runtime/index-without-hmr.ts --format=iife --platform=node --global-name=BUN_RUNTIME --external:/bun:* > src/runtime.bun.pre.out.js; cat src/runtime.bun.pre.out.js src/runtime.footer.bun.js > src/runtime.bun.out.js
@NODE_ENV=production $(ESBUILD) --define:process.env.NODE_ENV=\"production\" --target=esnext --bundle src/runtime.bun.js --format=esm --platform=node --minify --external:/bun:* > src/runtime.out.js
.PHONY: bun_error
bun_error:
@@ -937,6 +929,9 @@ clone-submodules:
.PHONY: headers
headers:
echo please don't run the headers generator anymore. i don't think it works.
echo if you really need it, run make headers2
headers2:
rm -f /tmp/build-jsc-headers src/bun.js/bindings/headers.zig
touch src/bun.js/bindings/headers.zig
$(ZIG) build headers-obj
@@ -945,7 +940,7 @@ headers:
$(ZIG) translate-c src/bun.js/bindings/headers.h > src/bun.js/bindings/headers.zig
$(BUN_OR_NODE) misctools/headers-cleaner.js
$(ZIG) fmt src/bun.js/bindings/headers.zig
$(CLANG_FORMAT) -i src/bun.js/bindings/ZigGeneratedCode.cpp
$(CLANG_FORMAT) -i src/bun.js/bindings/ZigGeneratedCode.cpp
.PHONY: jsc-bindings-headers
jsc-bindings-headers: headers
@@ -1251,6 +1246,7 @@ jsc-build-mac-compile-debug:
-DENABLE_FTL_JIT=ON \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DUSE_BUN_JSC_ADDITIONS=ON \
-DENABLE_BUN_SKIP_FAILING_ASSERTIONS=ON \
-DALLOW_LINE_AND_COLUMN_NUMBER_IN_BUILTINS=ON \
-G Ninja \
$(CMAKE_FLAGS_WITHOUT_RELEASE) \
@@ -1291,7 +1287,7 @@ jsc-build-linux-compile-config:
jsc-build-linux-compile-build:
mkdir -p $(WEBKIT_RELEASE_DIR) && \
cd $(WEBKIT_RELEASE_DIR) && \
CFLAGS="$(CFLAGS) -Wl,--whole-archive -ffat-lto-objects" CXXFLAGS="$(CXXFLAGS) -Wl,--whole-archive -ffat-lto-objects" -DUSE_BUN_JSC_ADDITIONS=ON \
CFLAGS="$(CFLAGS) -Wl,--whole-archive -ffat-lto-objects" CXXFLAGS="$(CXXFLAGS) -Wl,--whole-archive -ffat-lto-objects -DUSE_BUN_JSC_ADDITIONS=ON" \
cmake --build $(WEBKIT_RELEASE_DIR) --config relwithdebuginfo --target jsc
@@ -1326,7 +1322,7 @@ release-bindings: $(OBJ_DIR) $(OBJ_FILES) $(WEBCORE_OBJ_FILES) $(SQLITE_OBJ_FILE
# Do not add $(DEBUG_DIR) to this list
# It will break caching, causing you to have to wait for every .cpp file to rebuild.
.PHONY: bindings
bindings: $(DEBUG_OBJ_DIR) $(DEBUG_OBJ_FILES) $(DEBUG_WEBCORE_OBJ_FILES) $(DEBUG_SQLITE_OBJ_FILES) $(DEBUG_NODE_OS_OBJ_FILES) $(DEBUG_BUILTINS_OBJ_FILES) $(DEBUG_IO_FILES) $(DEBUG_MODULES_OBJ_FILES) $(DEBUG_WEBCRYPTO_OBJ_FILES)
bindings-real: $(DEBUG_OBJ_DIR) $(DEBUG_OBJ_FILES) $(DEBUG_WEBCORE_OBJ_FILES) $(DEBUG_SQLITE_OBJ_FILES) $(DEBUG_NODE_OS_OBJ_FILES) $(DEBUG_BUILTINS_OBJ_FILES) $(DEBUG_IO_FILES) $(DEBUG_MODULES_OBJ_FILES) $(DEBUG_WEBCRYPTO_OBJ_FILES)
.PHONY: jsc-bindings-mac
jsc-bindings-mac: bindings
@@ -1360,7 +1356,7 @@ mimalloc-debug:
-GNinja \
. \
&& ninja
cp $(BUN_DEPS_DIR)/mimalloc/$(_MIMALLOC_DEBUG_FILE) $(BUN_DEPS_OUT_DIR)/$(MIMALLOC_FILE)
cp $(BUN_DEPS_DIR)/mimalloc/$(_MIMALLOC_DEBUG_FILE) $(BUN_DEPS_OUT_DIR)/$(_MIMALLOC_DEBUG_FILE)
# mimalloc is built as object files so that it can overload the system malloc on linux
@@ -1482,15 +1478,15 @@ bun-relink: bun-relink-copy bun-link-lld-release bun-link-lld-release-dsym
bun-relink-fast: bun-relink-copy bun-link-lld-release-no-lto
wasm-return1:
zig build-lib -OReleaseSmall test/bun.js/wasm-return-1-test.zig -femit-bin=test/bun.js/wasm-return-1-test.wasm -target wasm32-freestanding
$(ZIG) build-lib -OReleaseSmall test/bun.js/wasm-return-1-test.zig -femit-bin=test/bun.js/wasm-return-1-test.wasm -target wasm32-freestanding
generate-classes:
bun src/bun.js/scripts/generate-classes.ts
bun src/codegen/generate-classes.ts
$(ZIG) fmt src/bun.js/bindings/generated_classes.zig
$(CLANG_FORMAT) -i src/bun.js/bindings/ZigGeneratedClasses.h src/bun.js/bindings/ZigGeneratedClasses.cpp
generate-sink:
bun src/bun.js/scripts/generate-jssink.js
bun src/codegen/generate-jssink.js
$(CLANG_FORMAT) -i src/bun.js/bindings/JSSink.cpp src/bun.js/bindings/JSSink.h
./src/bun.js/scripts/create_hash_table src/bun.js/bindings/JSSink.cpp > src/bun.js/bindings/JSSinkLookupTable.h
$(SED) -i -e 's/#include "Lookup.h"//' src/bun.js/bindings/JSSinkLookupTable.h
@@ -1518,7 +1514,7 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
-ferror-limit=10 \
$(EMIT_LLVM) \
-c -o $@ $<
@@ -1529,7 +1525,7 @@ $(OBJ_DIR)/%.o: src/bun.js/modules/%.cpp
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
-ferror-limit=10 \
$(EMIT_LLVM) \
-c -o $@ $<
@@ -1540,7 +1536,7 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/webcore/%.cpp
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
-ferror-limit=10 \
$(EMIT_LLVM) \
-c -o $@ $<
@@ -1551,7 +1547,7 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/sqlite/%.cpp
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
-ferror-limit=10 \
$(EMIT_LLVM) \
-c -o $@ $<
@@ -1562,7 +1558,7 @@ $(OBJ_DIR)/%.o: src/io/%.cpp
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
-ferror-limit=10 \
$(EMIT_LLVM) \
-c -o $@ $<
@@ -1573,7 +1569,7 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/node_os/%.cpp
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
-ferror-limit=10 \
$(EMIT_LLVM) \
-c -o $@ $<
@@ -1584,7 +1580,7 @@ $(OBJ_DIR)/%.o: src/js/out/%.cpp
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
-ferror-limit=10 \
$(EMIT_LLVM) \
-c -o $@ $<
@@ -1596,7 +1592,7 @@ $(OBJ_DIR)/%.o: src/bun.js/bindings/webcrypto/%.cpp
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
-ferror-limit=10 \
$(EMIT_LLVM) \
-c -o $@ $<
@@ -1610,7 +1606,7 @@ $(DEBUG_OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
-ferror-limit=10 \
-DBUN_DEBUG \
$(EMIT_LLVM_FOR_DEBUG) \
-g3 -c -o $@ $<
@@ -1625,7 +1621,7 @@ $(DEBUG_OBJ_DIR)/%.o: $(SRC_DIR)/webcore/%.cpp
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
-ferror-limit=10 \
$(EMIT_LLVM_FOR_DEBUG) \
-DBUN_DEBUG \
-g3 -c -o $@ $<
@@ -1638,7 +1634,7 @@ $(DEBUG_OBJ_DIR)/%.o: src/io/%.cpp
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
-ferror-limit=10 \
-DBUN_DEBUG \
$(EMIT_LLVM_FOR_DEBUG) \
-g3 -c -o $@ $<
@@ -1654,7 +1650,7 @@ $(DEBUG_OBJ_DIR)/%.o: $(SRC_DIR)/sqlite/%.cpp
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
-ferror-limit=10 \
$(EMIT_LLVM_FOR_DEBUG) \
-DBUN_DEBUG \
-g3 -c -o $@ $<
@@ -1669,7 +1665,7 @@ $(DEBUG_OBJ_DIR)/%.o: $(SRC_DIR)/node_os/%.cpp
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
-ferror-limit=10 \
$(EMIT_LLVM_FOR_DEBUG) \
-DBUN_DEBUG \
-g3 -c -o $@ $<
@@ -1684,7 +1680,7 @@ $(DEBUG_OBJ_DIR)/%.o: src/js/out/%.cpp
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
-ferror-limit=10 \
$(EMIT_LLVM_FOR_DEBUG) \
-DBUN_DEBUG \
-g3 -c -o $@ $<
@@ -1697,7 +1693,7 @@ $(DEBUG_OBJ_DIR)/%.o: src/bun.js/modules/%.cpp
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
-ferror-limit=10 \
$(EMIT_LLVM_FOR_DEBUG) \
-DBUN_DEBUG \
-g3 -c -o $@ $<
@@ -1712,7 +1708,7 @@ $(DEBUG_OBJ_DIR)/%.o: src/bun.js/bindings/webcrypto/%.cpp
-fno-exceptions \
-I$(SRC_DIR) \
-fno-rtti \
-ferror-limit=1000 \
-ferror-limit=10 \
$(EMIT_LLVM_FOR_DEBUG) \
-DBUN_DEBUG \
-g3 -c -o $@ $<
@@ -1825,7 +1821,7 @@ endif
build-unit: # to build your unit tests
@rm -rf zig-out/bin/$(testname)
@mkdir -p zig-out/bin
zig test $(realpath $(testpath)) \
$(ZIG) test $(realpath $(testpath)) \
$(testfilterflag) \
$(PACKAGE_MAP) \
--main-pkg-path $(BUN_DIR) \
@@ -1843,7 +1839,7 @@ build-unit: # to build your unit tests
run-all-unit-tests: # to run your unit tests
@rm -rf zig-out/bin/__main_test
@mkdir -p zig-out/bin
zig test src/main.zig \
$(ZIG) test src/main.zig \
$(PACKAGE_MAP) \
--main-pkg-path $(BUN_DIR) \
--test-no-exec \
@@ -1880,7 +1876,7 @@ PACKAGE_MAP = --pkg-begin async_io $(BUN_DIR)/src/io/io_darwin.zig --pkg-begin b
.PHONY: base64
base64:
cd $(BUN_DEPS_DIR)/base64 && make clean && cmake $(CMAKE_FLAGS) . && make
cd $(BUN_DEPS_DIR)/base64 && make clean && rm -rf CMakeCache.txt CMakeFiles && cmake $(CMAKE_FLAGS) . && make
cp $(BUN_DEPS_DIR)/base64/libbase64.a $(BUN_DEPS_OUT_DIR)/libbase64.a
.PHONY: cold-jsc-start
@@ -1891,7 +1887,7 @@ cold-jsc-start:
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
-ferror-limit=10 \
$(LIBICONV_PATH) \
$(DEFAULT_LINKER_FLAGS) \
$(PLATFORM_LINKER_FLAGS) \
@@ -1900,7 +1896,7 @@ cold-jsc-start:
misctools/cold-jsc-start.cpp -o cold-jsc-start
.PHONY: vendor-without-npm
vendor-without-npm: node-fallbacks runtime_js fallback_decoder bun_error mimalloc picohttp zlib boringssl libarchive lolhtml sqlite usockets uws tinycc c-ares zstd base64
vendor-without-npm: node-fallbacks runtime_js fallback_decoder bun_error mimalloc picohttp zlib boringssl libarchive lolhtml sqlite usockets uws lshpack tinycc c-ares zstd base64
.PHONY: vendor-without-check
@@ -1913,41 +1909,30 @@ vendor: assert-deps submodule vendor-without-check
vendor-dev: assert-deps submodule npm-install-dev vendor-without-npm
.PHONY: bun
bun: vendor identifier-cache build-obj bun-link-lld-release bun-codesign-release-local
bun:
@echo 'makefile is deprecated - use `cmake` / `bun run build`'
@echo 'See https://bun.sh/docs/project/contributing for more details'
.PHONY: cpp
cpp: ## compile src/js/builtins + all c++ code then link
@make clean-bindings js
@make bindings -j$(CPU_COUNT)
@make link
cpp:
@echo 'makefile is deprecated - use `cmake` / `bun run build`'
@echo 'See https://bun.sh/docs/project/contributing for more details'
.PHONY: cpp
cpp-no-link:
@make clean-bindings js
@make bindings -j$(CPU_COUNT)
zig:
@echo 'makefile is deprecated - use `cmake` / `bun run build`'
@echo 'See https://bun.sh/docs/project/contributing for more details'
.PHONY: zig
zig: ## compile zig code then link
@make mkdir-dev dev-obj link
dev:
@echo 'makefile is deprecated - use `cmake` / `bun run build`'
@echo 'See https://bun.sh/docs/project/contributing for more details'
.PHONY: zig-no-link
zig-no-link:
@make mkdir-dev dev-obj
setup:
@echo 'makefile is deprecated - use `cmake` / `bun run build`'
@echo 'See https://bun.sh/docs/project/contributing for more details'
.PHONY: dev
dev: # combo of `make cpp` and `make zig`
@make cpp-no-link zig-no-link -j2
@make link
bindings:
@echo 'makefile is deprecated - use `cmake` / `bun run build`'
@echo 'See https://bun.sh/docs/project/contributing for more details'
.PHONY: setup
setup: vendor-dev identifier-cache clean-bindings
make jsc-check dev
@echo ""
@echo "First build complete!"
@echo "\"bun-debug\" is available at $(DEBUG_BIN)/bun-debug"
@echo ""
.PHONY: help
help: ## to print this help
@echo "For detailed build instructions, see https://bun.sh/docs/project/development"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9_-]+:.*?## / {gsub("\\\\n",sprintf("\n%22c",""), $$2);printf "\033[36m%-20s\033[0m \t\t%s\n", $$1, $$2}' $(MAKEFILE_LIST)
help:
@echo 'makefile is deprecated - use `cmake` / `bun run build`'
@echo 'See https://bun.sh/docs/project/contributing for more details'

View File

@@ -24,14 +24,14 @@
## What is Bun?
> **Bun is still under development.** Use it to speed up your development workflows or run simpler production code in resource-constrained environments like serverless functions. We're working on more complete Node.js compatibility and integration with existing frameworks. Join the [Discord](https://bun.sh/discord) and watch the [GitHub repository](https://github.com/oven-sh/bun) to keep tabs on future releases.
> **Bun is under active development.** Use it to speed up your development workflows or run simpler production code in resource-constrained environments like serverless functions. We're working on more complete Node.js compatibility and integration with existing frameworks. Join the [Discord](https://bun.sh/discord) and watch the [GitHub repository](https://github.com/oven-sh/bun) to keep tabs on future releases.
Bun is an all-in-one toolkit for JavaScript and TypeScript apps. It ships as a single executable called `bun`.
At its core is the _Bun runtime_, a fast JavaScript runtime designed as a drop-in replacement for Node.js. It's written in Zig and powered by JavaScriptCore under the hood, dramatically reducing startup times and memory usage.
```bash
bun run index.tsx # TS and JSX supported out of the box
bun run index.tsx # TS and JSX supported out-of-the-box
```
The `bun` command-line tool also implements a test runner, script runner, and Node.js-compatible package manager. Instead of 1,000 node_modules for development, you only need `bun`. Bun's built-in tools are significantly faster than existing options and usable in existing Node.js projects with little to no changes.
@@ -93,7 +93,8 @@ bun upgrade --canary
- [`bun run`](https://bun.sh/docs/cli/run)
- [`bun install`](https://bun.sh/docs/cli/install)
- [`bun test`](https://bun.sh/docs/cli/test)
- [`bun create`](https://bun.sh/docs/cli/create)
- [`bun init`](https://bun.sh/docs/cli/init)
- [`bun create`](https://bun.sh/docs/cli/bun-create)
- [`bunx`](https://bun.sh/docs/cli/bunx)
- Runtime
- [Runtime](https://bun.sh/docs/runtime/index)
@@ -127,7 +128,7 @@ bun upgrade --canary
## Contributing
Refer to the [Project > Development](https://bun.sh/docs/project/development) guide to start contributing to Bun.
Refer to the [Project > Contributing](https://bun.sh/docs/project/contributing) guide to start contributing to Bun.
## License

12
SECURITY.md Normal file
View File

@@ -0,0 +1,12 @@
# Security Policy
## Supported Versions
| Version | Supported |
| ------- | ------------------ |
| 1.x.x | :white_check_mark: |
## Reporting a Vulnerability
Report any discovered vulnerabilities to the Bun team by emailing `security@bun.sh`. Your report will acknowledged within 5 days, and a team member will be assigned as the primary handler. To the greatest extent possible, the security team will endeavor to keep you informed of the progress being made towards a fix and full announcement, and may ask for additional information or guidance surrounding the reported issue.

Binary file not shown.

View File

@@ -1,7 +1,7 @@
import { bench, run } from "mitata";
import { groupForEmitter } from "./implementations.mjs";
// Psuedo RNG is derived from https://stackoverflow.com/a/424445
// Pseudo RNG is derived from https://stackoverflow.com/a/424445
let rngState = 123456789;
function nextInt() {
const m = 0x80000000; // 2**31;

View File

@@ -10,7 +10,7 @@ To run in Bun:
```bash
# so it doesn't run the vitest one
bun wiptest expect-to-equal.test.js
bun test expect-to-equal.test.js
```
To run in Jest:

37
bench/glob/braces.mjs Normal file
View File

@@ -0,0 +1,37 @@
import braces from "braces";
import { group, bench, run } from "mitata";
// const iterations = 1000;
const iterations = 100;
const simplePattern = "foo.{js,jsx,ts,tsx}";
const complexPattern = "{a,b,HI{c,e,LMAO{d,f}Q}} wow {a,b}";
const veryComplexPattern = "{a,b,HI{c,e,LMAO{d,f}Q}}{1,2,{3,4},5}";
console.log(braces(complexPattern, { expand: true }));
function benchPattern(pattern, name) {
group({ name: `${name} pattern: "${pattern}"`, summary: true }, () => {
if (typeof Bun !== "undefined")
bench("Bun", () => {
for (let i = 0; i < iterations; i++) {
Bun.$.braces(pattern);
}
});
bench("micromatch/braces", () => {
for (let i = 0; i < iterations; i++) {
braces(pattern, { expand: true });
}
});
});
}
benchPattern(simplePattern, "simple");
benchPattern(complexPattern, "complex");
benchPattern(veryComplexPattern, "very complex pattern");
await run({
avg: true,
min_max: true,
percentiles: true,
});

19
bench/glob/match.mjs Normal file
View File

@@ -0,0 +1,19 @@
import micromatch from "micromatch";
import { bench, run } from "mitata";
const Glob = typeof Bun !== "undefined" ? Bun.Glob : undefined;
const doMatch = typeof Bun === "undefined" ? micromatch.isMatch : (a, b) => new Glob(b).match(a);
bench((Glob ? "Bun.Glob - " : "micromatch - ") + "**/*.js", () => {
doMatch("foo/bar.js", "**/*.js");
});
bench((Glob ? "Bun.Glob - " : "micromatch - ") + "*.js", () => {
doMatch("bar.js", "*.js");
});
await run({
avg: true,
min_max: true,
percentiles: true,
});

113
bench/glob/scan.mjs Normal file
View File

@@ -0,0 +1,113 @@
import { run, bench, group } from "mitata";
import fg from "fast-glob";
import { fdir } from "fdir";
const normalPattern = "*.ts";
const recursivePattern = "**/*.ts";
const nodeModulesPattern = "**/node_modules/**/*.js";
const benchFdir = false;
const cwd = undefined;
const bunOpts = {
cwd,
followSymlinks: false,
absolute: true,
};
const fgOpts = {
cwd,
followSymbolicLinks: false,
onlyFiles: false,
absolute: true,
};
const Glob = "Bun" in globalThis ? globalThis.Bun.Glob : undefined;
group({ name: `async pattern="${normalPattern}"`, summary: true }, () => {
bench("fast-glob", async () => {
const entries = await fg.glob([normalPattern], fgOpts);
});
if (Glob)
bench("Bun.Glob", async () => {
const entries = await Array.fromAsync(new Glob(normalPattern).scan(bunOpts));
});
if (benchFdir)
bench("fdir", async () => {
const entries = await new fdir().withFullPaths().glob(normalPattern).crawl(process.cwd()).withPromise();
});
});
group({ name: `async-recursive pattern="${recursivePattern}"`, summary: true }, () => {
bench("fast-glob", async () => {
const entries = await fg.glob([recursivePattern], fgOpts);
});
if (Glob)
bench("Bun.Glob", async () => {
const entries = await Array.fromAsync(new Glob(recursivePattern).scan(bunOpts));
});
if (benchFdir)
bench("fdir", async () => {
const entries = await new fdir().withFullPaths().glob(recursivePattern).crawl(process.cwd()).withPromise();
});
});
group({ name: `sync pattern="${normalPattern}"`, summary: true }, () => {
bench("fast-glob", () => {
const entries = fg.globSync([normalPattern], fgOpts);
});
if (Glob)
bench("Bun.Glob", () => {
const entries = [...new Glob(normalPattern).scanSync(bunOpts)];
});
if (benchFdir)
bench("fdir", async () => {
const entries = new fdir().withFullPaths().glob(normalPattern).crawl(process.cwd()).sync();
});
});
group({ name: `sync-recursive pattern="${recursivePattern}"`, summary: true }, () => {
bench("fast-glob", () => {
const entries = fg.globSync([recursivePattern], fgOpts);
});
if (Glob)
bench("Bun.Glob", () => {
const entries = [...new Glob(recursivePattern).scanSync(bunOpts)];
});
if (benchFdir)
bench("fdir", async () => {
const entries = new fdir().withFullPaths().glob(recursivePattern).crawl(process.cwd()).sync();
});
});
group({ name: `node_modules pattern="${nodeModulesPattern}"`, summary: true }, () => {
bench("fast-glob", async () => {
const entries = await fg.glob([nodeModulesPattern], fgOpts);
});
if (Glob)
bench("Bun.Glob", async () => {
const entries = await Array.fromAsync(new Glob(nodeModulesPattern).scan(bunOpts));
});
if (benchFdir)
bench("fdir", async () => {
const entries = await new fdir().withFullPaths().glob(nodeModulesPattern).crawl(process.cwd()).withPromise();
});
});
await run({
avg: true,
colors: false,
min_max: true,
collect: true,
percentiles: true,
});

View File

@@ -25,7 +25,7 @@ pub var all_timestamps: [RUN_COUNT + 1]usize = undefined;
// 1. file path
// 2. Byte offset in file
// 3. ms update interval
var color_buf: [8096 + SIMULATE_LONG_FILE.len]u8 = undefined;
var color_buf: [8192 + SIMULATE_LONG_FILE.len]u8 = undefined;
pub fn main() anyerror!void {
var allocator = std.heap.c_allocator;

View File

@@ -25,7 +25,7 @@ pub var all_timestamps: [RUN_COUNT + 1]usize = undefined;
// 1. file path
// 2. Byte offset in file
// 3. ms update interval
var color_buf: [8096 + SIMULATE_LONG_FILE.len]u8 = undefined;
var color_buf: [8192 + SIMULATE_LONG_FILE.len]u8 = undefined;
pub fn main() anyerror!void {
var allocator = std.heap.c_allocator;

View File

@@ -7,280 +7,166 @@
"version": "0.0.34"
},
"timestamps": [
16336202536562, 16336202536908, 16336202537294, 16336202537705,
16336202538114, 16336202538534, 16336202538941, 16336202539323,
16336202539742, 16336202540159, 16336202540877, 16336202541310,
16336202541749, 16336202542159, 16336202542565, 16336202542996,
16336202543333, 16336202543761, 16336202544159, 16336202544534,
16336202544944, 16336202545345, 16336202545744, 16336202546159,
16336202546573, 16336202546986, 16336202547399, 16336202547781,
16336202548202, 16336202548564, 16336202548949, 16336202549329,
16336202549762, 16336202550168, 16336202550534, 16336202550887,
16336202551305, 16336202551659, 16336202552060, 16336202552449,
16336202552854, 16336202553270, 16336202553609, 16336202554034,
16336202554437, 16336202554783, 16336202555191, 16336202555623,
16336202556034, 16336202556449, 16336202556890, 16336202557283,
16336202557669, 16336202558084, 16336202558496, 16336202558863,
16336202559271, 16336202559659, 16336202560051, 16336202560452,
16336202560873, 16336202561290, 16336202561659, 16336202562035,
16336202562440, 16336202562862, 16336202563284, 16336202563659,
16336202564034, 16336202564444, 16336202564853, 16336202565245,
16336202565659, 16336202566034, 16336202566455, 16336202566873,
16336202567284, 16336202567659, 16336202568034, 16336202568386,
16336202568790, 16336202569204, 16336202569620, 16336202570384,
16336202570768, 16336202571188, 16336202571551, 16336202572327,
16336202572717, 16336202573116, 16336202573541, 16336202573959,
16336202574319, 16336202574682, 16336202575040, 16336202575375,
16336202577001, 16336202577342, 16336202577680, 16336202578066,
16336202578451, 16336202579166, 16336202579534, 16336202579960,
16336202580370, 16336202580789, 16336202581159, 16336202581576,
16336202581949, 16336202582294, 16336202583087, 16336202583496,
16336202583858, 16336202584203, 16336202584606, 16336202585034,
16336202585386, 16336202585788, 16336202586211, 16336202586604,
16336202587034, 16336202587459, 16336202587869, 16336202588295,
16336202588668, 16336202589092, 16336202589452, 16336202589831,
16336202590197, 16336202590608, 16336202591034, 16336202591460,
16336202591880, 16336202592295, 16336202592727, 16336202593172,
16336202593567, 16336202593994, 16336202594397, 16336202594795,
16336202595224, 16336202595659, 16336202596058, 16336202596463,
16336202596890, 16336202597322, 16336202597732, 16336202598159,
16336202598534, 16336202598951, 16336202599365, 16336202599785,
16336202600159, 16336202600593, 16336202601005, 16336202601402,
16336202601807, 16336202602214, 16336202602556, 16336202602895,
16336202603307, 16336202603661, 16336202604075, 16336202604491,
16336202604853, 16336202605268, 16336202605670, 16336202606034,
16336202606393, 16336202606748, 16336202607170, 16336202607568,
16336202607982, 16336202608411, 16336202608836, 16336202609197,
16336202609596, 16336202609965, 16336202610333, 16336202610740,
16336202611159, 16336202611573, 16336202611975, 16336202612317,
16336202612691, 16336202613060, 16336202613474, 16336202613903,
16336202614341, 16336202614707, 16336202615094, 16336202615534,
16336202615883, 16336202616296, 16336202616671, 16336202617034,
16336202617391, 16336202617727, 16336202618159, 16336202618534,
16336202618937, 16336202619360, 16336202619770, 16336202620179,
16336202620716, 16336202621143, 16336202621534, 16336202622303,
16336202622659, 16336202623085, 16336202623498, 16336202623850,
16336202624220, 16336202624606, 16336202625034, 16336202625387,
16336202625805, 16336202626210, 16336202626599, 16336202627034,
16336202627386, 16336202627748, 16336202628159, 16336202628534,
16336202628954, 16336202629373, 16336202629809, 16336202630197,
16336202630535, 16336202630916, 16336202631290, 16336202631666,
16336202632034, 16336202632369, 16336202633152, 16336202633534,
16336202633883, 16336202634309, 16336202634717, 16336202635106,
16336202635871, 16336202636253, 16336202636671, 16336202637070,
16336202637434, 16336202637798, 16336202638184, 16336202638539,
16336202638938, 16336202639307, 16336202639666, 16336202640095,
16336202640534, 16336202640962, 16336202641307, 16336202641659,
16336202642087, 16336202642521, 16336202642886, 16336202643309,
16336202643662, 16336202644067, 16336202644491, 16336202644853,
16336202645226, 16336202645659, 16336202646074, 16336202646497,
16336202646890, 16336202647311, 16336202647749, 16336202648169,
16336202648976, 16336202649378, 16336202649810, 16336202650165,
16336202650534, 16336202650875, 16336202651250, 16336202651659,
16336202652093, 16336202652516, 16336202652921, 16336202653332,
16336202653722, 16336202654142, 16336202654534, 16336202654880,
16336202655221, 16336202655562, 16336202655997, 16336202656378,
16336202656811, 16336202657161, 16336202657588, 16336202657944,
16336202658360, 16336202658708, 16336202659089, 16336202659428,
16336202659849, 16336202660273, 16336202660685, 16336202661105,
16336202661534, 16336202661873, 16336202662228, 16336202662658,
16336202663438, 16336202663843, 16336202664219, 16336202664646,
16336202665050, 16336202665487, 16336202665838, 16336202666211,
16336202666573, 16336202666927, 16336202667334, 16336202667746,
16336202668158, 16336202668563, 16336202668980, 16336202669406,
16336202669753, 16336202670192, 16336202670554, 16336202670903,
16336202671324, 16336202671734, 16336202672159, 16336202672573,
16336202672982, 16336202673346, 16336202673680, 16336202674087,
16336202674499, 16336202674909, 16336202675260, 16336202676110,
16336202676535, 16336202676913, 16336202677312, 16336202677658,
16336202678044, 16336202678413, 16336202678793, 16336202679208,
16336202679604, 16336202680034, 16336202680385, 16336202680799,
16336202681213, 16336202681595, 16336202682004, 16336202682346,
16336202682726, 16336202683158, 16336202683586, 16336202683990,
16336202684323, 16336202684742, 16336202685175, 16336202685578,
16336202685979, 16336202686805, 16336202687206, 16336202687614,
16336202688038, 16336202688473, 16336202688848, 16336202689221,
16336202689559, 16336202689971, 16336202690368, 16336202690776,
16336202691159, 16336202691585, 16336202692010, 16336202692373,
16336202692780, 16336202693179, 16336202693580, 16336202693991,
16336202694324, 16336202694727, 16336202695159, 16336202695588,
16336202695991, 16336202696335, 16336202697160, 16336202697542,
16336202697929, 16336202698323, 16336202698674, 16336202699060,
16336202699492, 16336202699835, 16336202700238, 16336202700658,
16336202701059, 16336202701420, 16336202701815, 16336202702229,
16336202702659, 16336202703857, 16336202704256, 16336202704659,
16336202705497, 16336202706309, 16336202706660, 16336202707085,
16336202707511, 16336202707866, 16336202708210, 16336202708552,
16336202708925, 16336202709287, 16336202709670, 16336202710045,
16336202710402, 16336202710802, 16336202711167, 16336202711533,
16336202712249, 16336202712660, 16336202713088, 16336202713519,
16336202713936, 16336202714355, 16336202714740, 16336202715160,
16336202715533, 16336202715878, 16336202716290, 16336202716708,
16336202717102, 16336202718290, 16336202718699, 16336202719052,
16336202719388, 16336202719808, 16336202720225, 16336202720659,
16336202721052, 16336202721414, 16336202721828, 16336202722925,
16336202723664, 16336202724063, 16336202724405, 16336202726003,
16336202726736, 16336202727158, 16336202727543, 16336202727930,
16336202728336, 16336202728703, 16336202729061, 16336202729483,
16336202729832, 16336202730222, 16336202730659, 16336202731084,
16336202731500, 16336202731911, 16336202732326, 16336202733158,
16336202733585, 16336202734001, 16336202734691, 16336202735042,
16336202735442, 16336202735863, 16336202736255, 16336202736671,
16336202737043, 16336202737884, 16336202738671, 16336202739110,
16336202739533, 16336202739886, 16336202740283, 16336202740706,
16336202741143, 16336202741534, 16336202741942, 16336202742352,
16336202742697, 16336202743103, 16336202743940, 16336202745172,
16336202745542, 16336202745937, 16336202746339, 16336202746758,
16336202747531, 16336202747877, 16336202748232, 16336202748658,
16336202749055, 16336202749468, 16336202749859, 16336202750416,
16336202750839, 16336202751178, 16336202751572, 16336202752002,
16336202752419, 16336202753269, 16336202753678, 16336202754086,
16336202754432, 16336202754835, 16336202755260, 16336202755683,
16336202756059, 16336202756402, 16336202756837, 16336202758084,
16336202758507, 16336202758879, 16336202759270, 16336202759674,
16336202760044, 16336202760400, 16336202760801, 16336202761659,
16336202762053, 16336202762397, 16336202763199, 16336202763547,
16336202763948, 16336202764714, 16336202765113, 16336202765947,
16336202766329, 16336202766664, 16336202767085, 16336202768233,
16336202769056, 16336202769758, 16336202770178, 16336202770585,
16336202770929, 16336202771325, 16336202772158, 16336202772594,
16336202773033, 16336202773403, 16336202773801, 16336202774179,
16336202774555, 16336202774989, 16336202775393, 16336202775809,
16336202776209, 16336202776618, 16336202777033, 16336202777421,
16336202777845, 16336202778246, 16336202778658, 16336202779055,
16336202779411, 16336202779761, 16336202780175, 16336202780594,
16336202781002, 16336202781848, 16336202782658, 16336202783033,
16336202783857, 16336202784211, 16336202784557, 16336202784972,
16336202785377, 16336202785810, 16336202786172, 16336202786934,
16336202787343, 16336202787765, 16336202788201, 16336202788563,
16336202788970, 16336202789329, 16336202789672, 16336202790055,
16336202790456, 16336202790802, 16336202791580, 16336202791920,
16336202792326, 16336202793158, 16336202793953, 16336202794368,
16336202795187, 16336202795622, 16336202796033, 16336202796393,
16336202796777, 16336202797173, 16336202797540, 16336202797975,
16336202798317, 16336202798739, 16336202799158, 16336202799567,
16336202799966, 16336202800378, 16336202800803, 16336202801232,
16336202801658, 16336202802033, 16336202802374, 16336202802759,
16336202803158, 16336202803533, 16336202803947, 16336202804354,
16336202804729, 16336202805158, 16336202805534, 16336202805950,
16336202806390, 16336202806805, 16336202807219, 16336202807643,
16336202808033, 16336202808377, 16336202808790, 16336202809211,
16336202809560, 16336202809920, 16336202810355, 16336202810758,
16336202811187, 16336202811596, 16336202811943, 16336202812348,
16336202812710, 16336202813060, 16336202813398, 16336202813791,
16336202814158, 16336202814533, 16336202814878, 16336202815246,
16336202815658, 16336202816079, 16336202816851, 16336202817202,
16336202817540, 16336202817905, 16336202818244, 16336202818663,
16336202819068, 16336202819418, 16336202819777, 16336202820193,
16336202820599, 16336202821033, 16336202821395, 16336202821745,
16336202822158, 16336202822590, 16336202822996, 16336202823396,
16336202823804, 16336202824210, 16336202824581, 16336202824991,
16336202825406, 16336202825806, 16336202826210, 16336202826598,
16336202827033, 16336202827446, 16336202827839, 16336202828201,
16336202828577, 16336202828968, 16336202829362, 16336202829709,
16336202830096, 16336202830533, 16336202830917, 16336202831290,
16336202831699, 16336202832035, 16336202832406, 16336202832804,
16336202833200, 16336202833604, 16336202834033, 16336202834386,
16336202834759, 16336202835190, 16336202835621, 16336202836033,
16336202836405, 16336202837191, 16336202837613, 16336202838033,
16336202838374, 16336202838798, 16336202839200, 16336202839603,
16336202840034, 16336202840389, 16336202840783, 16336202841200,
16336202841617, 16336202842034, 16336202842390, 16336202842737,
16336202843158, 16336202843585, 16336202843923, 16336202844313,
16336202844724, 16336202845158, 16336202845576, 16336202845939,
16336202846368, 16336202846728, 16336202847158, 16336202847568,
16336202847911, 16336202848291, 16336202848695, 16336202849103,
16336202849533, 16336202849942, 16336202850368, 16336202850747,
16336202851158, 16336202851549, 16336202851978, 16336202852383,
16336202852725, 16336202853158, 16336202853554, 16336202853961,
16336202854308, 16336202854704, 16336202855060, 16336202855418,
16336202855776, 16336202856203, 16336202856617, 16336202857036,
16336202857455, 16336202857884, 16336202858262, 16336202858658,
16336202859071, 16336202859847, 16336202860237, 16336202860658,
16336202861037, 16336202861452, 16336202861869, 16336202862218,
16336202862590, 16336202863001, 16336202863422, 16336202863857,
16336202864219, 16336202864658, 16336202865047, 16336202865404,
16336202865789, 16336202866210, 16336202866624, 16336202867033,
16336202867380, 16336202867797, 16336202868227, 16336202868658,
16336202869083, 16336202869500, 16336202869906, 16336202870246,
16336202870658, 16336202871086, 16336202871441, 16336202871820,
16336202872204, 16336202872546, 16336202872943, 16336202873380,
16336202873811, 16336202874213, 16336202874566, 16336202874918,
16336202875261, 16336202875655, 16336202876047, 16336202876771,
16336202877202, 16336202877612, 16336202878033, 16336202878412,
16336202878846, 16336202879241, 16336202879658, 16336202880072,
16336202880508, 16336202880901, 16336202881308, 16336202881725,
16336202882158, 16336202882579, 16336202882945, 16336202883286,
16336202883657, 16336202884048, 16336202884404, 16336202884752,
16336202885158, 16336202885533, 16336202885938, 16336202886364,
16336202886759, 16336202887175, 16336202887585, 16336202887929,
16336202888345, 16336202888743, 16336202889157, 16336202889570,
16336202889970, 16336202890382, 16336202890761, 16336202891187,
16336202891600, 16336202892033, 16336202892454, 16336202892794,
16336202893178, 16336202893533, 16336202893903, 16336202894264,
16336202894668, 16336202895049, 16336202895400, 16336202895774,
16336202896157, 16336202896537, 16336202896883, 16336202897232,
16336202897658, 16336202898065, 16336202898493, 16336202898884,
16336202899251, 16336202899673, 16336202900047, 16336202900467,
16336202900883, 16336202901300, 16336202901676, 16336202902068,
16336202902479, 16336202902902, 16336202903260, 16336202903675,
16336202904094, 16336202904476, 16336202904824, 16336202905158,
16336202905533, 16336202905934, 16336202906289, 16336202906717,
16336202907158, 16336202907547, 16336202907904, 16336202908294,
16336202908717, 16336202909157, 16336202909582, 16336202910005,
16336202910399, 16336202910800, 16336202911220, 16336202911657,
16336202912064, 16336202912405, 16336202912779, 16336202913158,
16336202913553, 16336202913966, 16336202914376, 16336202914719,
16336202915091, 16336202915515, 16336202915887, 16336202916293,
16336202916649, 16336202917438, 16336202917869, 16336202918221,
16336202919053, 16336202919425, 16336202919833, 16336202920234,
16336202920658, 16336202921033, 16336202921433, 16336202921801,
16336202922161, 16336202922589, 16336202923017, 16336202923418,
16336202923804, 16336202924199, 16336202924593, 16336202925033,
16336202925449, 16336202925818, 16336202926223, 16336202926662,
16336202927431, 16336202927812, 16336202928227, 16336202928658,
16336202929061, 16336202929473, 16336202929891, 16336202930241,
16336202930657, 16336202931057, 16336202931396, 16336202931811,
16336202932225, 16336202932657, 16336202933058, 16336202933445,
16336202933790, 16336202934157, 16336202934562, 16336202934988,
16336202935391, 16336202935777, 16336202936160, 16336202936562,
16336202936986, 16336202937396, 16336202937751, 16336202938158,
16336202938578, 16336202938985, 16336202939396, 16336202939752,
16336202940157, 16336202940585
16336202536562, 16336202536908, 16336202537294, 16336202537705, 16336202538114, 16336202538534, 16336202538941,
16336202539323, 16336202539742, 16336202540159, 16336202540877, 16336202541310, 16336202541749, 16336202542159,
16336202542565, 16336202542996, 16336202543333, 16336202543761, 16336202544159, 16336202544534, 16336202544944,
16336202545345, 16336202545744, 16336202546159, 16336202546573, 16336202546986, 16336202547399, 16336202547781,
16336202548202, 16336202548564, 16336202548949, 16336202549329, 16336202549762, 16336202550168, 16336202550534,
16336202550887, 16336202551305, 16336202551659, 16336202552060, 16336202552449, 16336202552854, 16336202553270,
16336202553609, 16336202554034, 16336202554437, 16336202554783, 16336202555191, 16336202555623, 16336202556034,
16336202556449, 16336202556890, 16336202557283, 16336202557669, 16336202558084, 16336202558496, 16336202558863,
16336202559271, 16336202559659, 16336202560051, 16336202560452, 16336202560873, 16336202561290, 16336202561659,
16336202562035, 16336202562440, 16336202562862, 16336202563284, 16336202563659, 16336202564034, 16336202564444,
16336202564853, 16336202565245, 16336202565659, 16336202566034, 16336202566455, 16336202566873, 16336202567284,
16336202567659, 16336202568034, 16336202568386, 16336202568790, 16336202569204, 16336202569620, 16336202570384,
16336202570768, 16336202571188, 16336202571551, 16336202572327, 16336202572717, 16336202573116, 16336202573541,
16336202573959, 16336202574319, 16336202574682, 16336202575040, 16336202575375, 16336202577001, 16336202577342,
16336202577680, 16336202578066, 16336202578451, 16336202579166, 16336202579534, 16336202579960, 16336202580370,
16336202580789, 16336202581159, 16336202581576, 16336202581949, 16336202582294, 16336202583087, 16336202583496,
16336202583858, 16336202584203, 16336202584606, 16336202585034, 16336202585386, 16336202585788, 16336202586211,
16336202586604, 16336202587034, 16336202587459, 16336202587869, 16336202588295, 16336202588668, 16336202589092,
16336202589452, 16336202589831, 16336202590197, 16336202590608, 16336202591034, 16336202591460, 16336202591880,
16336202592295, 16336202592727, 16336202593172, 16336202593567, 16336202593994, 16336202594397, 16336202594795,
16336202595224, 16336202595659, 16336202596058, 16336202596463, 16336202596890, 16336202597322, 16336202597732,
16336202598159, 16336202598534, 16336202598951, 16336202599365, 16336202599785, 16336202600159, 16336202600593,
16336202601005, 16336202601402, 16336202601807, 16336202602214, 16336202602556, 16336202602895, 16336202603307,
16336202603661, 16336202604075, 16336202604491, 16336202604853, 16336202605268, 16336202605670, 16336202606034,
16336202606393, 16336202606748, 16336202607170, 16336202607568, 16336202607982, 16336202608411, 16336202608836,
16336202609197, 16336202609596, 16336202609965, 16336202610333, 16336202610740, 16336202611159, 16336202611573,
16336202611975, 16336202612317, 16336202612691, 16336202613060, 16336202613474, 16336202613903, 16336202614341,
16336202614707, 16336202615094, 16336202615534, 16336202615883, 16336202616296, 16336202616671, 16336202617034,
16336202617391, 16336202617727, 16336202618159, 16336202618534, 16336202618937, 16336202619360, 16336202619770,
16336202620179, 16336202620716, 16336202621143, 16336202621534, 16336202622303, 16336202622659, 16336202623085,
16336202623498, 16336202623850, 16336202624220, 16336202624606, 16336202625034, 16336202625387, 16336202625805,
16336202626210, 16336202626599, 16336202627034, 16336202627386, 16336202627748, 16336202628159, 16336202628534,
16336202628954, 16336202629373, 16336202629809, 16336202630197, 16336202630535, 16336202630916, 16336202631290,
16336202631666, 16336202632034, 16336202632369, 16336202633152, 16336202633534, 16336202633883, 16336202634309,
16336202634717, 16336202635106, 16336202635871, 16336202636253, 16336202636671, 16336202637070, 16336202637434,
16336202637798, 16336202638184, 16336202638539, 16336202638938, 16336202639307, 16336202639666, 16336202640095,
16336202640534, 16336202640962, 16336202641307, 16336202641659, 16336202642087, 16336202642521, 16336202642886,
16336202643309, 16336202643662, 16336202644067, 16336202644491, 16336202644853, 16336202645226, 16336202645659,
16336202646074, 16336202646497, 16336202646890, 16336202647311, 16336202647749, 16336202648169, 16336202648976,
16336202649378, 16336202649810, 16336202650165, 16336202650534, 16336202650875, 16336202651250, 16336202651659,
16336202652093, 16336202652516, 16336202652921, 16336202653332, 16336202653722, 16336202654142, 16336202654534,
16336202654880, 16336202655221, 16336202655562, 16336202655997, 16336202656378, 16336202656811, 16336202657161,
16336202657588, 16336202657944, 16336202658360, 16336202658708, 16336202659089, 16336202659428, 16336202659849,
16336202660273, 16336202660685, 16336202661105, 16336202661534, 16336202661873, 16336202662228, 16336202662658,
16336202663438, 16336202663843, 16336202664219, 16336202664646, 16336202665050, 16336202665487, 16336202665838,
16336202666211, 16336202666573, 16336202666927, 16336202667334, 16336202667746, 16336202668158, 16336202668563,
16336202668980, 16336202669406, 16336202669753, 16336202670192, 16336202670554, 16336202670903, 16336202671324,
16336202671734, 16336202672159, 16336202672573, 16336202672982, 16336202673346, 16336202673680, 16336202674087,
16336202674499, 16336202674909, 16336202675260, 16336202676110, 16336202676535, 16336202676913, 16336202677312,
16336202677658, 16336202678044, 16336202678413, 16336202678793, 16336202679208, 16336202679604, 16336202680034,
16336202680385, 16336202680799, 16336202681213, 16336202681595, 16336202682004, 16336202682346, 16336202682726,
16336202683158, 16336202683586, 16336202683990, 16336202684323, 16336202684742, 16336202685175, 16336202685578,
16336202685979, 16336202686805, 16336202687206, 16336202687614, 16336202688038, 16336202688473, 16336202688848,
16336202689221, 16336202689559, 16336202689971, 16336202690368, 16336202690776, 16336202691159, 16336202691585,
16336202692010, 16336202692373, 16336202692780, 16336202693179, 16336202693580, 16336202693991, 16336202694324,
16336202694727, 16336202695159, 16336202695588, 16336202695991, 16336202696335, 16336202697160, 16336202697542,
16336202697929, 16336202698323, 16336202698674, 16336202699060, 16336202699492, 16336202699835, 16336202700238,
16336202700658, 16336202701059, 16336202701420, 16336202701815, 16336202702229, 16336202702659, 16336202703857,
16336202704256, 16336202704659, 16336202705497, 16336202706309, 16336202706660, 16336202707085, 16336202707511,
16336202707866, 16336202708210, 16336202708552, 16336202708925, 16336202709287, 16336202709670, 16336202710045,
16336202710402, 16336202710802, 16336202711167, 16336202711533, 16336202712249, 16336202712660, 16336202713088,
16336202713519, 16336202713936, 16336202714355, 16336202714740, 16336202715160, 16336202715533, 16336202715878,
16336202716290, 16336202716708, 16336202717102, 16336202718290, 16336202718699, 16336202719052, 16336202719388,
16336202719808, 16336202720225, 16336202720659, 16336202721052, 16336202721414, 16336202721828, 16336202722925,
16336202723664, 16336202724063, 16336202724405, 16336202726003, 16336202726736, 16336202727158, 16336202727543,
16336202727930, 16336202728336, 16336202728703, 16336202729061, 16336202729483, 16336202729832, 16336202730222,
16336202730659, 16336202731084, 16336202731500, 16336202731911, 16336202732326, 16336202733158, 16336202733585,
16336202734001, 16336202734691, 16336202735042, 16336202735442, 16336202735863, 16336202736255, 16336202736671,
16336202737043, 16336202737884, 16336202738671, 16336202739110, 16336202739533, 16336202739886, 16336202740283,
16336202740706, 16336202741143, 16336202741534, 16336202741942, 16336202742352, 16336202742697, 16336202743103,
16336202743940, 16336202745172, 16336202745542, 16336202745937, 16336202746339, 16336202746758, 16336202747531,
16336202747877, 16336202748232, 16336202748658, 16336202749055, 16336202749468, 16336202749859, 16336202750416,
16336202750839, 16336202751178, 16336202751572, 16336202752002, 16336202752419, 16336202753269, 16336202753678,
16336202754086, 16336202754432, 16336202754835, 16336202755260, 16336202755683, 16336202756059, 16336202756402,
16336202756837, 16336202758084, 16336202758507, 16336202758879, 16336202759270, 16336202759674, 16336202760044,
16336202760400, 16336202760801, 16336202761659, 16336202762053, 16336202762397, 16336202763199, 16336202763547,
16336202763948, 16336202764714, 16336202765113, 16336202765947, 16336202766329, 16336202766664, 16336202767085,
16336202768233, 16336202769056, 16336202769758, 16336202770178, 16336202770585, 16336202770929, 16336202771325,
16336202772158, 16336202772594, 16336202773033, 16336202773403, 16336202773801, 16336202774179, 16336202774555,
16336202774989, 16336202775393, 16336202775809, 16336202776209, 16336202776618, 16336202777033, 16336202777421,
16336202777845, 16336202778246, 16336202778658, 16336202779055, 16336202779411, 16336202779761, 16336202780175,
16336202780594, 16336202781002, 16336202781848, 16336202782658, 16336202783033, 16336202783857, 16336202784211,
16336202784557, 16336202784972, 16336202785377, 16336202785810, 16336202786172, 16336202786934, 16336202787343,
16336202787765, 16336202788201, 16336202788563, 16336202788970, 16336202789329, 16336202789672, 16336202790055,
16336202790456, 16336202790802, 16336202791580, 16336202791920, 16336202792326, 16336202793158, 16336202793953,
16336202794368, 16336202795187, 16336202795622, 16336202796033, 16336202796393, 16336202796777, 16336202797173,
16336202797540, 16336202797975, 16336202798317, 16336202798739, 16336202799158, 16336202799567, 16336202799966,
16336202800378, 16336202800803, 16336202801232, 16336202801658, 16336202802033, 16336202802374, 16336202802759,
16336202803158, 16336202803533, 16336202803947, 16336202804354, 16336202804729, 16336202805158, 16336202805534,
16336202805950, 16336202806390, 16336202806805, 16336202807219, 16336202807643, 16336202808033, 16336202808377,
16336202808790, 16336202809211, 16336202809560, 16336202809920, 16336202810355, 16336202810758, 16336202811187,
16336202811596, 16336202811943, 16336202812348, 16336202812710, 16336202813060, 16336202813398, 16336202813791,
16336202814158, 16336202814533, 16336202814878, 16336202815246, 16336202815658, 16336202816079, 16336202816851,
16336202817202, 16336202817540, 16336202817905, 16336202818244, 16336202818663, 16336202819068, 16336202819418,
16336202819777, 16336202820193, 16336202820599, 16336202821033, 16336202821395, 16336202821745, 16336202822158,
16336202822590, 16336202822996, 16336202823396, 16336202823804, 16336202824210, 16336202824581, 16336202824991,
16336202825406, 16336202825806, 16336202826210, 16336202826598, 16336202827033, 16336202827446, 16336202827839,
16336202828201, 16336202828577, 16336202828968, 16336202829362, 16336202829709, 16336202830096, 16336202830533,
16336202830917, 16336202831290, 16336202831699, 16336202832035, 16336202832406, 16336202832804, 16336202833200,
16336202833604, 16336202834033, 16336202834386, 16336202834759, 16336202835190, 16336202835621, 16336202836033,
16336202836405, 16336202837191, 16336202837613, 16336202838033, 16336202838374, 16336202838798, 16336202839200,
16336202839603, 16336202840034, 16336202840389, 16336202840783, 16336202841200, 16336202841617, 16336202842034,
16336202842390, 16336202842737, 16336202843158, 16336202843585, 16336202843923, 16336202844313, 16336202844724,
16336202845158, 16336202845576, 16336202845939, 16336202846368, 16336202846728, 16336202847158, 16336202847568,
16336202847911, 16336202848291, 16336202848695, 16336202849103, 16336202849533, 16336202849942, 16336202850368,
16336202850747, 16336202851158, 16336202851549, 16336202851978, 16336202852383, 16336202852725, 16336202853158,
16336202853554, 16336202853961, 16336202854308, 16336202854704, 16336202855060, 16336202855418, 16336202855776,
16336202856203, 16336202856617, 16336202857036, 16336202857455, 16336202857884, 16336202858262, 16336202858658,
16336202859071, 16336202859847, 16336202860237, 16336202860658, 16336202861037, 16336202861452, 16336202861869,
16336202862218, 16336202862590, 16336202863001, 16336202863422, 16336202863857, 16336202864219, 16336202864658,
16336202865047, 16336202865404, 16336202865789, 16336202866210, 16336202866624, 16336202867033, 16336202867380,
16336202867797, 16336202868227, 16336202868658, 16336202869083, 16336202869500, 16336202869906, 16336202870246,
16336202870658, 16336202871086, 16336202871441, 16336202871820, 16336202872204, 16336202872546, 16336202872943,
16336202873380, 16336202873811, 16336202874213, 16336202874566, 16336202874918, 16336202875261, 16336202875655,
16336202876047, 16336202876771, 16336202877202, 16336202877612, 16336202878033, 16336202878412, 16336202878846,
16336202879241, 16336202879658, 16336202880072, 16336202880508, 16336202880901, 16336202881308, 16336202881725,
16336202882158, 16336202882579, 16336202882945, 16336202883286, 16336202883657, 16336202884048, 16336202884404,
16336202884752, 16336202885158, 16336202885533, 16336202885938, 16336202886364, 16336202886759, 16336202887175,
16336202887585, 16336202887929, 16336202888345, 16336202888743, 16336202889157, 16336202889570, 16336202889970,
16336202890382, 16336202890761, 16336202891187, 16336202891600, 16336202892033, 16336202892454, 16336202892794,
16336202893178, 16336202893533, 16336202893903, 16336202894264, 16336202894668, 16336202895049, 16336202895400,
16336202895774, 16336202896157, 16336202896537, 16336202896883, 16336202897232, 16336202897658, 16336202898065,
16336202898493, 16336202898884, 16336202899251, 16336202899673, 16336202900047, 16336202900467, 16336202900883,
16336202901300, 16336202901676, 16336202902068, 16336202902479, 16336202902902, 16336202903260, 16336202903675,
16336202904094, 16336202904476, 16336202904824, 16336202905158, 16336202905533, 16336202905934, 16336202906289,
16336202906717, 16336202907158, 16336202907547, 16336202907904, 16336202908294, 16336202908717, 16336202909157,
16336202909582, 16336202910005, 16336202910399, 16336202910800, 16336202911220, 16336202911657, 16336202912064,
16336202912405, 16336202912779, 16336202913158, 16336202913553, 16336202913966, 16336202914376, 16336202914719,
16336202915091, 16336202915515, 16336202915887, 16336202916293, 16336202916649, 16336202917438, 16336202917869,
16336202918221, 16336202919053, 16336202919425, 16336202919833, 16336202920234, 16336202920658, 16336202921033,
16336202921433, 16336202921801, 16336202922161, 16336202922589, 16336202923017, 16336202923418, 16336202923804,
16336202924199, 16336202924593, 16336202925033, 16336202925449, 16336202925818, 16336202926223, 16336202926662,
16336202927431, 16336202927812, 16336202928227, 16336202928658, 16336202929061, 16336202929473, 16336202929891,
16336202930241, 16336202930657, 16336202931057, 16336202931396, 16336202931811, 16336202932225, 16336202932657,
16336202933058, 16336202933445, 16336202933790, 16336202934157, 16336202934562, 16336202934988, 16336202935391,
16336202935777, 16336202936160, 16336202936562, 16336202936986, 16336202937396, 16336202937751, 16336202938158,
16336202938578, 16336202938985, 16336202939396, 16336202939752, 16336202940157, 16336202940585
],
"frameTimes": [
346, 411, 420, 382, 417, 433, 410, 431, 428, 375, 401, 415, 413, 382, 362,
380, 406, 353, 354, 389, 416, 425, 346, 432, 415, 393, 415, 367, 388, 401,
417, 376, 422, 375, 410, 392, 375, 418, 375, 352, 414, 764, 420, 776, 399,
418, 363, 335, 341, 386, 715, 426, 419, 417, 345, 409, 345, 428, 402, 393,
425, 426, 424, 379, 411, 426, 415, 445, 427, 398, 435, 405, 432, 427, 417,
420, 434, 397, 407, 339, 354, 416, 415, 364, 355, 398, 429, 361, 369, 407,
414, 342, 369, 429, 366, 440, 413, 363, 336, 375, 423, 409, 427, 769, 426,
352, 386, 353, 405, 435, 362, 375, 419, 388, 381, 376, 335, 382, 426, 389,
382, 399, 364, 355, 369, 429, 428, 352, 434, 423, 405, 362, 433, 423, 421,
420, 402, 355, 341, 409, 423, 411, 420, 346, 341, 381, 350, 356, 348, 339,
424, 420, 339, 430, 405, 427, 437, 373, 354, 412, 405, 426, 439, 349, 410,
414, 364, 407, 410, 850, 378, 346, 369, 415, 430, 414, 382, 342, 432, 404,
419, 403, 826, 408, 435, 373, 412, 408, 426, 363, 399, 411, 403, 429, 344,
382, 394, 386, 343, 420, 361, 414, 1198, 403, 812, 425, 355, 342, 362, 375,
400, 366, 411, 431, 419, 420, 345, 418, 1188, 353, 420, 434, 362, 1097, 399,
1598, 422, 387, 367, 422, 390, 425, 411, 832, 416, 351, 421, 416, 841, 439,
353, 423, 391, 410, 406, 1232, 395, 419, 346, 426, 413, 557, 339, 430, 850,
408, 403, 423, 343, 1247, 372, 404, 356, 858, 344, 348, 766, 834, 335, 1148,
702, 407, 396, 436, 370, 378, 434, 416, 409, 388, 401, 397, 350, 419, 846,
375, 354, 415, 433, 762, 422, 362, 359, 383, 346, 340, 832, 415, 435, 360,
396, 435, 422, 409, 412, 429, 375, 385, 375, 407, 429, 416, 415, 424, 344,
421, 360, 403, 409, 405, 350, 393, 375, 368, 421, 351, 365, 419, 350, 416,
434, 350, 432, 400, 406, 410, 400, 388, 413, 362, 391, 347, 437, 373, 336,
398, 404, 353, 431, 412, 786, 420, 424, 403, 355, 417, 417, 347, 427, 390,
434, 363, 360, 410, 380, 408, 409, 379, 391, 405, 433, 407, 396, 358, 427,
419, 429, 396, 776, 421, 415, 349, 411, 435, 439, 357, 421, 409, 417, 431,
417, 340, 428, 379, 342, 437, 402, 352, 394, 724, 410, 379, 395, 414, 393,
417, 421, 341, 391, 348, 375, 426, 416, 344, 398, 413, 412, 426, 433, 340,
355, 361, 381, 374, 380, 349, 407, 391, 422, 420, 417, 392, 423, 415, 382,
334, 401, 428, 389, 390, 440, 423, 401, 437, 341, 379, 413, 343, 424, 406,
789, 352, 372, 401, 375, 368, 428, 401, 395, 440, 369, 439, 381, 431, 412,
350, 400, 415, 432, 387, 367, 426, 386, 402, 410, 407, 407, 356, 428
346, 411, 420, 382, 417, 433, 410, 431, 428, 375, 401, 415, 413, 382, 362, 380, 406, 353, 354, 389, 416, 425, 346,
432, 415, 393, 415, 367, 388, 401, 417, 376, 422, 375, 410, 392, 375, 418, 375, 352, 414, 764, 420, 776, 399, 418,
363, 335, 341, 386, 715, 426, 419, 417, 345, 409, 345, 428, 402, 393, 425, 426, 424, 379, 411, 426, 415, 445, 427,
398, 435, 405, 432, 427, 417, 420, 434, 397, 407, 339, 354, 416, 415, 364, 355, 398, 429, 361, 369, 407, 414, 342,
369, 429, 366, 440, 413, 363, 336, 375, 423, 409, 427, 769, 426, 352, 386, 353, 405, 435, 362, 375, 419, 388, 381,
376, 335, 382, 426, 389, 382, 399, 364, 355, 369, 429, 428, 352, 434, 423, 405, 362, 433, 423, 421, 420, 402, 355,
341, 409, 423, 411, 420, 346, 341, 381, 350, 356, 348, 339, 424, 420, 339, 430, 405, 427, 437, 373, 354, 412, 405,
426, 439, 349, 410, 414, 364, 407, 410, 850, 378, 346, 369, 415, 430, 414, 382, 342, 432, 404, 419, 403, 826, 408,
435, 373, 412, 408, 426, 363, 399, 411, 403, 429, 344, 382, 394, 386, 343, 420, 361, 414, 1198, 403, 812, 425, 355,
342, 362, 375, 400, 366, 411, 431, 419, 420, 345, 418, 1188, 353, 420, 434, 362, 1097, 399, 1598, 422, 387, 367,
422, 390, 425, 411, 832, 416, 351, 421, 416, 841, 439, 353, 423, 391, 410, 406, 1232, 395, 419, 346, 426, 413, 557,
339, 430, 850, 408, 403, 423, 343, 1247, 372, 404, 356, 858, 344, 348, 766, 834, 335, 1148, 702, 407, 396, 436, 370,
378, 434, 416, 409, 388, 401, 397, 350, 419, 846, 375, 354, 415, 433, 762, 422, 362, 359, 383, 346, 340, 832, 415,
435, 360, 396, 435, 422, 409, 412, 429, 375, 385, 375, 407, 429, 416, 415, 424, 344, 421, 360, 403, 409, 405, 350,
393, 375, 368, 421, 351, 365, 419, 350, 416, 434, 350, 432, 400, 406, 410, 400, 388, 413, 362, 391, 347, 437, 373,
336, 398, 404, 353, 431, 412, 786, 420, 424, 403, 355, 417, 417, 347, 427, 390, 434, 363, 360, 410, 380, 408, 409,
379, 391, 405, 433, 407, 396, 358, 427, 419, 429, 396, 776, 421, 415, 349, 411, 435, 439, 357, 421, 409, 417, 431,
417, 340, 428, 379, 342, 437, 402, 352, 394, 724, 410, 379, 395, 414, 393, 417, 421, 341, 391, 348, 375, 426, 416,
344, 398, 413, 412, 426, 433, 340, 355, 361, 381, 374, 380, 349, 407, 391, 422, 420, 417, 392, 423, 415, 382, 334,
401, 428, 389, 390, 440, 423, 401, 437, 341, 379, 413, 343, 424, 406, 789, 352, 372, 401, 375, 368, 428, 401, 395,
440, 369, 439, 381, 431, 412, 350, 400, 415, 432, 387, 367, 426, 386, 402, 410, 407, 407, 356, 428
],
"percentileMs": {
"50": 40.7,

View File

@@ -1,11 +1,33 @@
# `install` benchmark
Requires [`hyperfine`](https://github.com/sharkdp/hyperfine)
Requires [`hyperfine`](https://github.com/sharkdp/hyperfine). The goal of this benchmark is to compare installation performance of Bun with other package managers _when caches are hot_.
```
### With lockfile, online mode
To run the benchmark with the standard "install" command for each package manager:
```sh
$ hyperfine --prepare 'rm -rf node_modules' --warmup 1 --runs 3 'bun install' 'pnpm install' 'yarn' 'npm install'
```
### With lockfile, offline mode
Even though all packages are cached, some tools may hit the npm API during the version resolution step. (This is not the same as re-downloading a package.) To entirely avoid network calls, the other package managers require `--prefer-offline/--offline` flag. To run the benchmark using "offline" mode:
```sh
$ hyperfine --prepare 'rm -rf node_modules' --runs 1 'bun install' 'pnpm install --prefer-offline' 'yarn --offline' 'npm install --prefer-offline'
```
### Without lockfile, offline mode
To run the benchmark with offline mode but without lockfiles:
```sh
$ hyperfine --prepare 'rm -rf node_modules' --warmup 1 'rm bun.lockb && bun install' 'rm pnpm-lock.yaml && pnpm install --prefer-offline' 'rm yarn.lock && yarn --offline' 'rm package-lock.json && npm install --prefer-offline'
```
##
To check that the app is working as expected:
```

View File

@@ -5,9 +5,15 @@
"@babel/preset-react": "^7.16.7",
"@swc/core": "^1.2.133",
"benchmark": "^2.1.4",
"braces": "^3.0.2",
"esbuild": "^0.14.12",
"eventemitter3": "^5.0.0",
"mitata": "^0.1.6"
"execa": "^8.0.1",
"fast-glob": "3.3.1",
"fdir": "^6.1.0",
"mitata": "^0.1.6",
"string-width": "^7.0.0",
"zx": "^7.2.3"
},
"scripts": {
"ffi": "cd ffi && bun run deps && bun run build && bun run bench",
@@ -19,6 +25,5 @@
},
"devDependencies": {
"fast-deep-equal": "^3.1.3"
},
"prettier": "../.prettierrc.cjs"
}
}

View File

@@ -6,23 +6,30 @@ bench("await 1", async function () {
return await 1;
});
function callnextTick(resolve) {
process.nextTick(resolve);
}
if (typeof process !== "undefined") {
bench("process.nextTick x 100", async function () {
var remaining = 100;
var cb, promise;
promise = new Promise(resolve => {
cb = resolve;
});
function awaitNextTick() {
return new Promise(callnextTick);
}
for (let i = 0; i < 100; i++) {
process.nextTick(() => {
if (--remaining === 0) cb();
});
}
bench("promise.nextTick", async function () {
return awaitNextTick();
});
return promise;
});
bench("await 1 x 100", async function () {
for (let i = 0; i < 100; i++) await 1;
});
}
bench("await new Promise(resolve => resolve())", async function () {
await new Promise(resolve => resolve());
});
bench("Promise.all(Array.from({length: 100}, () => new Promise((resolve) => resolve())))", async function () {
return Promise.all(Array.from({ length: 100 }, () => Promise.resolve(1)));
});
await run();

View File

@@ -0,0 +1,54 @@
import { bench, run } from "./runner.mjs";
for (let size of [32, 2048, 1024 * 16, 1024 * 1024 * 2, 1024 * 1024 * 16]) {
const first = Buffer.allocUnsafe(size);
const second = Buffer.allocUnsafe(size);
const third = Buffer.allocUnsafe(size);
first.fill(1);
second.fill(2);
third.fill(3);
const check = true;
const buffers = [first, second, third];
const fmt =
size > 1024 * 1024
? new Intl.NumberFormat(undefined, { unit: "megabyte", style: "unit" })
: size > 1024
? new Intl.NumberFormat(undefined, { unit: "kilobyte", style: "unit" })
: new Intl.NumberFormat(undefined, { unit: "byte", style: "unit" });
bench(
`Buffer.concat(${fmt.format(
Number((size > 1024 * 1024 ? size / 1024 / 1024 : size > 1024 ? size / 1024 : size).toFixed(2)),
)} x 3)`,
() => {
const result = Buffer.concat(buffers);
if (check) {
if (result.byteLength != size * 3) throw new Error("Wrong length");
if (result[0] != 1) throw new Error("Wrong first byte");
if (result[size] != 2) throw new Error("Wrong second byte");
if (result[size * 2] != 3) throw new Error("Wrong third byte");
result[0] = 10;
if (first[0] != 1) throw new Error("First buffer was modified");
result[size] = 20;
if (second[0] != 2) throw new Error("Second buffer was modified");
result[size * 2] = 30;
if (third[0] != 3) throw new Error("Third buffer was modified");
}
},
);
}
const chunk = Buffer.alloc(16);
chunk.fill("3");
const array = Array.from({ length: 100 }, () => chunk);
bench("Buffer.concat 100 tiny chunks", () => {
return Buffer.concat(array);
});
await run();

View File

@@ -0,0 +1,7 @@
import { bench, run } from "./runner.mjs";
bench("crypto.randomUUID()", () => {
return crypto.randomUUID();
});
await run();

View File

@@ -1,9 +1,9 @@
import { bench, run } from "../node_modules/mitata/src/cli.mjs";
// pure JS implementation will optimze this out
// bench("new Headers", function () {
// return new Headers();
// });
bench("new Headers", function () {
return new Headers();
});
var big = new Headers({
"Content-Type": "text/plain",
@@ -17,17 +17,128 @@ var big = new Headers({
"X-Yet-Another-Custom-Headz": "Hello Worlda",
});
// bench("Header.get", function () {
// return big.get("Content-Type");
// });
bench("new Headers([])", () => {
return new Headers([]);
});
// bench("Header.set (standard)", function () {
// return big.set("Content-Type", "text/html");
// });
bench("new Headers({})", () => {
return new Headers({});
});
// bench("Header.set (non-standard)", function () {
// return big.set("X-My-Custom", "text/html123");
// });
bench("new Headers(object)", () => {
return new Headers({
"Content-Type": "text/plain",
"Content-Length": "123",
"User-Agent": "node-fetch/1.0",
});
});
bench("new Headers(hugeObject)", () => {
return new Headers({
"Accept": "123",
"Accept-Charset": "123",
"Accept-Language": "123",
"Accept-Encoding": "123",
"Accept-Ranges": "123",
"Access-Control-Allow-Credentials": "123",
"Access-Control-Allow-Headers": "123",
"Access-Control-Allow-Methods": "123",
"Access-Control-Allow-Origin": "123",
"Access-Control-Expose-Headers": "123",
"Access-Control-Max-Age": "123",
"Access-Control-Request-Headers": "123",
"Access-Control-Request-Method": "123",
"Age": "123",
"Authorization": "123",
"Cache-Control": "123",
"Connection": "123",
"Content-Disposition": "123",
"Content-Encoding": "123",
"Content-Language": "123",
"Content-Length": "123",
"Content-Location": "123",
"Content-Security-Policy": "123",
"Content-Security-Policy-Report-Only": "123",
"Content-Type": "123",
"Content-Range": "123",
"Cookie": "123",
"Cookie2": "123",
"Cross-Origin-Embedder-Policy": "123",
"Cross-Origin-Embedder-Policy-Report-Only": "123",
"Cross-Origin-Opener-Policy": "123",
"Cross-Origin-Opener-Policy-Report-Only": "123",
"Cross-Origin-Resource-Policy": "123",
"Date": "123",
"DNT": "123",
"Default-Style": "123",
"ETag": "123",
"Expect": "123",
"Expires": "123",
"Host": "123",
"If-Match": "123",
"If-Modified-Since": "123",
"If-None-Match": "123",
"If-Range": "123",
"If-Unmodified-Since": "123",
"Keep-Alive": "123",
"Last-Event-ID": "123",
"Last-Modified": "123",
"Link": "123",
"Location": "123",
"Origin": "123",
"Ping-From": "123",
"Ping-To": "123",
"Purpose": "123",
"Pragma": "123",
"Proxy-Authorization": "123",
"Range": "123",
"Referer": "123",
"Referrer-Policy": "123",
"Refresh": "123",
"Report-To": "123",
"Sec-Fetch-Dest": "123",
"Sec-Fetch-Mode": "123",
"Sec-WebSocket-Accept": "123",
"Sec-WebSocket-Extensions": "123",
"Sec-WebSocket-Key": "123",
"Sec-WebSocket-Protocol": "123",
"Sec-WebSocket-Version": "123",
"Server-Timing": "123",
"Service-Worker": "123",
"Service-Worker-Allowed": "123",
"Service-Worker-Navigation-Preload": "123",
"Set-Cookie": "123",
"Set-Cookie2": "123",
"SourceMap": "123",
"TE": "123",
"Timing-Allow-Origin": "123",
"Trailer": "123",
"Transfer-Encoding": "123",
"Upgrade": "123",
"Upgrade-Insecure-Requests": "123",
"User-Agent": "123",
"Vary": "123",
"Via": "123",
"X-Content-Type-Options": "123",
"X-DNS-Prefetch-Control": "123",
"X-Frame-Options": "123",
"X-SourceMap": "123",
"X-XSS-Protection": "123",
"X-Temp-Tablet": "123",
});
});
bench("Header.get", function () {
return big.get("Content-Type");
});
bench("Header.set (standard)", function () {
return big.set("Content-Type", "text/html");
});
bench("Header.set (non-standard)", function () {
return big.set("X-My-Custom", "text/html123");
});
if (big.toJSON)
bench("Headers.toJSON", function () {
@@ -42,4 +153,4 @@ bench("Object.fromEntries(headers)", function () {
return Object.fromEntries(big);
});
run();
await run();

View File

@@ -4,5 +4,9 @@ var i = 0;
const server = createServer((req, res) => {
res.writeHead(200);
res.end("Hello, World!" + i);
if (i++ === 200_000 - 1) queueMicrotask(() => process.exit(0));
if (i++ === 200_000 - 1)
setTimeout(() => {
console.log("RSS", (process.memoryUsage().rss / 1024 / 1024) | 0, "MB");
process.exit(0);
}, 0);
}).listen(parseInt(process.env.PORT || "3000", 10));

View File

@@ -0,0 +1,52 @@
import { bench, run } from "./runner.mjs";
import { IncomingMessage } from "node:http";
const headers = {
date: "Mon, 06 Nov 2023 05:12:49 GMT",
expires: "-1",
"cache-control": "private, max-age=0",
"content-type": "text/html; charset=ISO-8859-1",
"content-security-policy-report-only":
"object-src 'none';base-uri 'self';script-src 'nonce-lcrU7l9xScCq4urW13K9gw' 'strict-dynamic' 'report-sample' 'unsafe-eval' 'unsafe-inline' https: http:;report-uri https://csp.withgoogle.com/csp/gws/other-hp",
"x-xss-protection": "0",
"x-frame-options": "SAMEORIGIN",
"accept-ranges": "none",
vary: "Accept-Encoding",
"transfer-encoding": "chunked",
"set-cookie": [
"1P_JAR=2023-11-06-05; expires=Wed, 06-Dec-2023 05:12:49 GMT; path=/; domain=.google.com; Secure",
"AEC=Ackid1TiuGtRsmu1yaDCAdL1u1J4eM4S67simzDHfWaMPQzH-UB4DZkRwm8; expires=Sat, 04-May-2024 05:12:49 GMT; path=/; domain=.google.com; Secure; HttpOnly; SameSite=lax",
"NID=511=jQcg9cM7vjKawWnf6f3qhs3WDIIN2gaRq3i4bdMiVRWFkaFNYmiI-Xquf1kAmWGcmDN0skldS7uHheru3CMJrWjMt56VaaqO6Pilb54jFjQS_ZJRfG3Uc7dGV5WXGV-slUGE1Bicxlajdn0E_R8tZOoWiFzFDQW7YGmyfRqWQ2k; expires=Tue, 07-May-2024 05:12:49 GMT; path=/; domain=.google.com; HttpOnly",
],
p3p: 'CP="This is not a P3P policy! See g.co/p3phelp for more info."',
server: "gws",
"alt-svc": 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000',
};
const request = new Request("https://www.google.com/", {
headers: new Headers(headers),
method: "GET",
});
// const server = Bun.serve({
// port: 8080,
// async fetch(request) {
// // bench("new IncomingMessage()", b => {
// // for (let i = 0; i < 1000; i++) {
// // new IncomingMessage(request);
// // }
// // });
// const msg = new IncomingMessage(request);
// console.log(msg.headers, msg.rawHeaders, msg.url);
// // await run();
// return new Response("Hello, world!");
// },
// });
bench("new IncomingMessage()", b => {
for (let i = 0; i < 1000; i++) {
new IncomingMessage(request);
}
});
await run();

View File

@@ -0,0 +1,31 @@
import { bench, run } from "mitata";
import { peek } from "bun";
let pending = Bun.sleep(1000);
let resolved = Promise.resolve(1);
bench("Bun.peek - pending", () => {
return peek(pending);
});
bench("Bun.peek - resolved", () => {
return peek(resolved);
});
bench("Bun.peek - non-promise", () => {
return peek(1);
});
bench("Bun.peek.status - resolved", () => {
return peek.status(pending);
});
bench("Bun.peek.status - pending", () => {
return peek.status(resolved);
});
bench("Bun.peek.status - non-promise", () => {
return peek.status(1);
});
await run();

View File

@@ -77,4 +77,24 @@ bench("ConventionalPrivates", () => {
new Foo().run();
});
const _state = Symbol("state");
const _inc = Symbol("inc");
bench("SymbolPrivates", () => {
class Foo {
[_state] = 1;
[_inc] = 13;
run() {
let n = 1000000;
while (n-- > 0) {
this[_state] += this[_inc];
}
return n;
}
}
new Foo().run();
});
await run();

View File

@@ -1,13 +1,50 @@
import { readdirSync } from "fs";
import { readdirSync, readdir as readdirCb } from "fs";
import { readdir } from "fs/promises";
import { bench, run } from "./runner.mjs";
import { argv } from "process";
import { fileURLToPath } from "url";
import { relative, resolve } from "path";
import { createHash } from "crypto";
const dir = argv.length > 2 ? argv[2] : "/tmp";
let dir = resolve(argv.length > 2 ? argv[2] : fileURLToPath(new URL("../../node_modules", import.meta.url)));
if (dir.includes(process.cwd())) {
dir = relative(process.cwd(), dir);
}
const count = readdirSync(dir).length;
bench(`readdir("${dir}")`, () => {
readdirSync(dir, { withFileTypes: true });
const result = await readdir(dir, { recursive: true });
const count = result.length;
const syncCount = readdirSync(dir, { recursive: true }).length;
const hash = createHash("sha256").update(result.sort().join("\n")).digest("hex");
bench(`await readdir("${dir}", {recursive: true})`, async () => {
await readdir(dir, { recursive: true });
});
bench(`await readdir("${dir}", {recursive: true}) x 10`, async () => {
const promises = [
readdir(dir, { recursive: true }),
readdir(dir, { recursive: true }),
readdir(dir, { recursive: true }),
readdir(dir, { recursive: true }),
readdir(dir, { recursive: true }),
readdir(dir, { recursive: true }),
readdir(dir, { recursive: true }),
readdir(dir, { recursive: true }),
readdir(dir, { recursive: true }),
readdir(dir, { recursive: true }),
readdir(dir, { recursive: true }),
];
await Promise.all(promises);
});
bench(`await readdir("${dir}", {recursive: false})`, async () => {
await readdir(dir, { recursive: false });
});
await run();
console.log("\n\nFor", count, "files/dirs in", dir);
console.log("\n", count, "files/dirs in", dir, "\n", "SHA256:", hash, "\n");
if (count !== syncCount) {
throw new Error(`Mismatched file counts: ${count} async !== ${syncCount} sync`);
}

View File

@@ -0,0 +1,25 @@
import { bench, run } from "./runner.mjs";
import { builtinModules } from "node:module";
import { writeFile } from "node:fs/promises";
import { spawnSync } from "child_process";
for (let builtin of builtinModules) {
const path = `/tmp/require.${builtin.replaceAll("/", "_")}.cjs`;
await writeFile(
path,
`
const builtin = ${JSON.stringify(builtin)};
const now = require("perf_hooks").performance.now();
require(builtin);
const end = require("perf_hooks").performance.now();
process.stdout.write(JSON.stringify({builtin, time: end - now}) + "\\n");
`,
);
const result = spawnSync(typeof Bun !== "undefined" ? "bun" : "node", [path], {
stdio: ["inherit", "inherit", "inherit"],
env: {
...process.env,
NODE_NO_WARNINGS: "1",
},
});
}

22
bench/snippets/rmdir.mjs Normal file
View File

@@ -0,0 +1,22 @@
import { tmpdir } from "node:os";
import { promises, existsSync, mkdirSync } from "node:fs";
const count = 1024 * 12;
var queue = new Array(count);
var paths = new Array(count);
for (let i = 0; i < count; i++) {
const path = `${tmpdir()}/${Date.now()}.rm.dir${i}`;
try {
mkdirSync(path);
} catch (e) {}
paths[i] = path;
queue[i] = promises.rmdir(path);
}
await Promise.all(queue);
for (let i = 0; i < count; i++) {
if (existsSync(paths[i])) {
throw new Error(`Path ${paths[i]} was not removed`);
}
}

143
bench/snippets/semver.mjs Normal file
View File

@@ -0,0 +1,143 @@
import { satisfies } from "semver";
import { bench, run } from "./runner.mjs";
const tests = [
["~1.2.3", "1.2.3", true],
["~1.2", "1.2.0", true],
["~1", "1.0.0", true],
["~1", "1.2.0", true],
["~1", "1.2.999", true],
["~0.2.3", "0.2.3", true],
["~0.2", "0.2.0", true],
["~0.2", "0.2.1", true],
["~0 ", "0.0.0", true],
["~1.2.3", "1.3.0", false],
["~1.2", "1.3.0", false],
["~1", "2.0.0", false],
["~0.2.3", "0.3.0", false],
["~0.2.3", "1.0.0", false],
["~0 ", "1.0.0", false],
["~0.2", "0.1.0", false],
["~0.2", "0.3.0", false],
["~3.0.5", "3.3.0", false],
["^1.1.4", "1.1.4", true],
[">=3", "3.5.0", true],
[">=3", "2.999.999", false],
[">=3", "3.5.1", true],
[">=3.x.x", "3.x.x", false],
["<6 >= 5", "5.0.0", true],
["<6 >= 5", "4.0.0", false],
["<6 >= 5", "6.0.0", false],
["<6 >= 5", "6.0.1", false],
[">2", "3", false],
[">2", "2.1", false],
[">2", "2", false],
[">2", "1.0", false],
[">1.3", "1.3.1", false],
[">1.3", "2.0.0", true],
[">2.1.0", "2.2.0", true],
["<=2.2.99999", "2.2.0", true],
[">=2.1.99999", "2.2.0", true],
["<2.2.99999", "2.2.0", true],
[">2.1.99999", "2.2.0", true],
[">1.0.0", "2.0.0", true],
["1.0.0", "1.0.0", true],
["1.0.0", "2.0.0", false],
["1.0.0 || 2.0.0", "1.0.0", true],
["2.0.0 || 1.0.0", "1.0.0", true],
["1.0.0 || 2.0.0", "2.0.0", true],
["2.0.0 || 1.0.0", "2.0.0", true],
["2.0.0 || >1.0.0", "2.0.0", true],
[">1.0.0 <2.0.0 <2.0.1 >1.0.1", "1.0.2", true],
["2.x", "2.0.0", true],
["2.x", "2.1.0", true],
["2.x", "2.2.0", true],
["2.x", "2.3.0", true],
["2.x", "2.1.1", true],
["2.x", "2.2.2", true],
["2.x", "2.3.3", true],
["<2.0.1 >1.0.0", "2.0.0", true],
["<=2.0.1 >=1.0.0", "2.0.0", true],
["^2", "2.0.0", true],
["^2", "2.9.9", true],
["~2", "2.0.0", true],
["~2", "2.1.0", true],
["~2.2", "2.2.1", true],
["2.1.0 || > 2.2 || >3", "2.1.0", true],
[" > 2.2 || >3 || 2.1.0", "2.1.0", true],
[" > 2.2 || 2.1.0 || >3", "2.1.0", true],
["> 2.2 || 2.1.0 || >3", "2.3.0", true],
["> 2.2 || 2.1.0 || >3", "2.2.1", false],
["> 2.2 || 2.1.0 || >3", "2.2.0", false],
["> 2.2 || 2.1.0 || >3", "2.3.0", true],
["> 2.2 || 2.1.0 || >3", "3.0.1", true],
["~2", "2.0.0", true],
["~2", "2.1.0", true],
["1.2.0 - 1.3.0", "1.2.2", true],
["1.2 - 1.3", "1.2.2", true],
["1 - 1.3", "1.2.2", true],
["1 - 1.3", "1.3.0", true],
["1.2 - 1.3", "1.3.1", true],
["1.2 - 1.3", "1.4.0", false],
["1 - 1.3", "1.3.1", true],
["1.2 - 1.3 || 5.0", "6.4.0", false],
["1.2 - 1.3 || 5.0", "1.2.1", true],
["5.0 || 1.2 - 1.3", "1.2.1", true],
["1.2 - 1.3 || 5.0", "5.0", false],
["5.0 || 1.2 - 1.3", "5.0", false],
["1.2 - 1.3 || 5.0", "5.0.2", true],
["5.0 || 1.2 - 1.3", "5.0.2", true],
["1.2 - 1.3 || 5.0", "5.0.2", true],
["5.0 || 1.2 - 1.3", "5.0.2", true],
["5.0 || 1.2 - 1.3 || >8", "9.0.2", true],
];
bench("semver.satisfies x " + tests.length, () => {
for (const [range, version, expected] of tests) {
if (satisfies(version, range) !== expected) {
throw new Error("Unexpected result for " + range + " " + version);
}
}
});
if (typeof Bun !== "undefined") {
const satisfies = Bun.semver.satisfies;
bench("Bun.semver.satisfies x " + tests.length, () => {
for (const [range, version, expected] of tests) {
if (satisfies(version, range) !== expected) {
throw new Error("Unexpected result for " + range + " " + version);
}
}
});
}
bench("semver.satisfies", () => {
const [range, version, expected] = tests[0];
if (satisfies(version, range) !== expected) {
throw new Error("Unexpected result for " + range + " " + version);
}
});
if (typeof Bun !== "undefined") {
const satisfies = Bun.semver.satisfies;
bench("Bun.semver.satisfies", () => {
const [range, version, expected] = tests[0];
if (satisfies(version, range) !== expected) {
throw new Error("Unexpected result for " + range + " " + version);
}
});
}
await run();

View File

@@ -0,0 +1,37 @@
import { $ as zx } from "zx";
import { $ as execa$ } from "execa";
import { bench, run, group } from "./runner.mjs";
const execa = execa$({ stdio: "ignore", cwd: import.meta.dirname });
group("echo hi", () => {
if (typeof Bun !== "undefined")
bench("$`echo hi`", async () => {
await Bun.$`echo hi`.quiet();
});
bench("execa`echo hi`", async () => {
await execa`echo hi`;
});
bench("zx`echo hi`", async () => {
await zx`echo hi`.quiet();
});
});
group("ls .", () => {
if (typeof Bun !== "undefined")
bench("$`ls .`", async () => {
await Bun.$`ls .`.quiet();
});
bench("execa`ls .`", async () => {
await execa`ls .`;
});
bench("zx`ls .`", async () => {
await zx`ls .`.quiet();
});
});
await run();

View File

@@ -0,0 +1,44 @@
import { bench, run } from "./runner.mjs";
import npmStringWidth from "string-width";
const bunStringWidth = globalThis?.Bun?.stringWidth;
bench("npm/string-width (ansi + emoji + ascii)", () => {
npmStringWidth("hello there! 😀\u001b[31m😀😀");
});
bench("npm/string-width (ansi + emoji)", () => {
npmStringWidth("😀\u001b[31m😀😀");
});
bench("npm/string-width (ansi + ascii)", () => {
npmStringWidth("\u001b[31mhello there!");
});
if (bunStringWidth) {
bench("Bun.stringWidth (ansi + emoji + ascii)", () => {
bunStringWidth("hello there! 😀\u001b[31m😀😀");
});
bench("Bun.stringWidth (ansi + emoji)", () => {
bunStringWidth("😀\u001b[31m😀😀");
});
bench("Bun.stringWidth (ansi + ascii)", () => {
bunStringWidth("\u001b[31mhello there!");
});
if (npmStringWidth("😀\u001b[31m😀😀") !== bunStringWidth("😀\u001b[31m😀😀")) {
console.error("string-width mismatch");
}
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");
}
}
await run();

View File

@@ -0,0 +1,113 @@
import { bench, run } from "./runner.mjs";
// bench("new URLSearchParams({})", () => {
// return new URLSearchParams({});
// });
bench("new URLSearchParams(obj)", () => {
return new URLSearchParams({
"Content-Type": "text/plain",
"Content-Length": "123",
"User-Agent": "node-fetch/1.0",
"Accept-Encoding": "gzip,deflate",
"Content-Length": "0",
"Content-Range": "bytes 0-9/10",
});
});
bench("new URLSearchParams(absurdlyHugeObject)", () => {
return new URLSearchParams({
"Accept": "123",
"Accept-Charset": "123",
"Accept-Language": "123",
"Accept-Encoding": "123",
"Accept-Ranges": "123",
"Access-Control-Allow-Credentials": "123",
"Access-Control-Allow-Headers": "123",
"Access-Control-Allow-Methods": "123",
"Access-Control-Allow-Origin": "123",
"Access-Control-Expose-Headers": "123",
"Access-Control-Max-Age": "123",
"Access-Control-Request-Headers": "123",
"Access-Control-Request-Method": "123",
"Age": "123",
"Authorization": "123",
"Cache-Control": "123",
"Connection": "123",
"Content-Disposition": "123",
"Content-Encoding": "123",
"Content-Language": "123",
"Content-Length": "123",
"Content-Location": "123",
"Content-Security-Policy": "123",
"Content-Security-Policy-Report-Only": "123",
"Content-Type": "123",
"Content-Range": "123",
"Cookie": "123",
"Cookie2": "123",
"Cross-Origin-Embedder-Policy": "123",
"Cross-Origin-Embedder-Policy-Report-Only": "123",
"Cross-Origin-Opener-Policy": "123",
"Cross-Origin-Opener-Policy-Report-Only": "123",
"Cross-Origin-Resource-Policy": "123",
"Date": "123",
"DNT": "123",
"Default-Style": "123",
"ETag": "123",
"Expect": "123",
"Expires": "123",
"Host": "123",
"If-Match": "123",
"If-Modified-Since": "123",
"If-None-Match": "123",
"If-Range": "123",
"If-Unmodified-Since": "123",
"Keep-Alive": "123",
"Last-Event-ID": "123",
"Last-Modified": "123",
"Link": "123",
"Location": "123",
"Origin": "123",
"Ping-From": "123",
"Ping-To": "123",
"Purpose": "123",
"Pragma": "123",
"Proxy-Authorization": "123",
"Range": "123",
"Referer": "123",
"Referrer-Policy": "123",
"Refresh": "123",
"Report-To": "123",
"Sec-Fetch-Dest": "123",
"Sec-Fetch-Mode": "123",
"Sec-WebSocket-Accept": "123",
"Sec-WebSocket-Extensions": "123",
"Sec-WebSocket-Key": "123",
"Sec-WebSocket-Protocol": "123",
"Sec-WebSocket-Version": "123",
"Server-Timing": "123",
"Service-Worker": "123",
"Service-Worker-Allowed": "123",
"Service-Worker-Navigation-Preload": "123",
"Set-Cookie": "123",
"Set-Cookie2": "123",
"SourceMap": "123",
"TE": "123",
"Timing-Allow-Origin": "123",
"Trailer": "123",
"Transfer-Encoding": "123",
"Upgrade": "123",
"Upgrade-Insecure-Requests": "123",
"User-Agent": "123",
"Vary": "123",
"Via": "123",
"X-Content-Type-Options": "123",
"X-DNS-Prefetch-Control": "123",
"X-Frame-Options": "123",
"X-SourceMap": "123",
"X-XSS-Protection": "123",
"X-Temp-Tablet": "123",
});
});
await run();

View File

@@ -9,9 +9,8 @@ bench("writeFile(/tmp/foo.txt, short string)", async () => {
await writeFile("/tmp/foo.txt", "short string", "utf8");
});
const buffer = Buffer.from("short string");
bench("writeFile(/tmp/foo.txt, Buffer.from(short string))", async () => {
await writeFile("/tmp/foo.txt", buffer);
await writeFile("/tmp/foo.txt", Buffer.from("short string"));
});
const fd = openSync("/tmp/foo.txt", "w");
@@ -22,7 +21,7 @@ bench("write(fd, short string)", () => {
});
bench("write(fd, Uint8Array(short string))", () => {
const bytesWritten = write(fd, buffer);
const bytesWritten = write(fd, Buffer.from("short string"));
if (bytesWritten !== 12) throw new Error("wrote !== 12");
});

View File

@@ -1,7 +1,8 @@
import { run, bench } from "mitata";
import { Database } from "bun:sqlite";
import { join } from "path";
const db = Database.open("./src/northwind.sqlite");
const db = Database.open(join(import.meta.dir, "src", "northwind.sqlite"));
{
const sql = db.prepare(`SELECT * FROM "Order"`);

70
biome.json Normal file
View File

@@ -0,0 +1,70 @@
{
"$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"
]
}
}

286
build.zig
View File

@@ -1,31 +1,22 @@
const std = @import("std");
const pathRel = std.fs.path.relative;
const builtin = @import("builtin");
const Wyhash = @import("./src/wyhash.zig").Wyhash;
const zig_version = builtin.zig_version;
/// Do not rename this constant. It is scanned by some scripts to determine which zig version to install.
const recommended_zig_version = "0.12.0-dev.1828+225fe6ddb";
var is_debug_build = false;
fn moduleSource(comptime out: []const u8) FileSource {
if (comptime std.fs.path.dirname(@src().file)) |base| {
const outpath = comptime base ++ std.fs.path.sep_str ++ out;
return FileSource.relative(outpath);
} else {
return FileSource.relative(out);
}
fn exists(path: []const u8) bool {
_ = std.fs.openFileAbsolute(path, .{ .mode = .read_only }) catch return false;
return true;
}
const color_map = std.ComptimeStringMap([]const u8, .{
&.{ "black", "30m" },
&.{ "blue", "34m" },
&.{ "b", "1m" },
&.{ "d", "2m" },
&.{ "cyan", "36m" },
&.{ "green", "32m" },
&.{ "magenta", "35m" },
&.{ "red", "31m" },
&.{ "white", "37m" },
&.{ "yellow", "33m" },
});
fn addInternalPackages(b: *Build, step: *CompileStep, _: std.mem.Allocator, _: []const u8, target: anytype) !void {
var io: *Module = brk: {
const io: *Module = brk: {
if (target.isDarwin()) {
break :brk b.createModule(.{
.source_file = FileSource.relative("src/io/io_darwin.zig"),
@@ -46,19 +37,50 @@ fn addInternalPackages(b: *Build, step: *CompileStep, _: std.mem.Allocator, _: [
};
step.addModule("async_io", io);
step.addModule("zlib-internal", brk: {
if (target.isWindows()) {
break :brk b.createModule(.{ .source_file = FileSource.relative("src/deps/zlib.win32.zig") });
}
break :brk b.createModule(.{ .source_file = FileSource.relative("src/deps/zlib.posix.zig") });
});
const async_: *Module = brk: {
if (target.isDarwin() or target.isLinux() or target.isFreeBSD()) {
break :brk b.createModule(.{
.source_file = FileSource.relative("src/async/posix_event_loop.zig"),
});
} else if (target.isWindows()) {
break :brk b.createModule(.{
.source_file = FileSource.relative("src/async/windows_event_loop.zig"),
});
}
break :brk b.createModule(.{
.source_file = FileSource.relative("src/async/stub_event_loop.zig"),
});
};
step.addModule("async", async_);
}
const BunBuildOptions = struct {
canary: bool = false,
is_canary: bool = false,
canary_revision: u32 = 0,
sha: [:0]const u8 = "",
version: []const u8 = "",
baseline: bool = false,
bindgen: bool = false,
sizegen: bool = false,
base_path: [:0]const u8 = "",
tracy_callstack_depth: u16,
runtime_js_version: u64 = 0,
fallback_html_version: u64 = 0,
tinycc: bool = true,
project: [:0]const u8 = "",
pub fn updateRuntime(this: *BunBuildOptions) anyerror!void {
if (std.fs.cwd().openFile("src/runtime.out.js", .{ .mode = .read_only })) |file| {
defer file.close();
@@ -89,7 +111,13 @@ const BunBuildOptions = struct {
pub fn step(this: BunBuildOptions, b: anytype) *std.build.OptionsStep {
var opts = b.addOptions();
opts.addOption(@TypeOf(this.canary), "is_canary", this.canary);
opts.addOption(@TypeOf(this.is_canary), "is_canary", this.is_canary);
opts.addOption(@TypeOf(this.canary_revision), "canary_revision", this.canary_revision);
opts.addOption(
std.SemanticVersion,
"version",
std.SemanticVersion.parse(this.version) catch @panic(b.fmt("Invalid version: {s}", .{this.version})),
);
opts.addOption(@TypeOf(this.sha), "sha", this.sha);
opts.addOption(@TypeOf(this.baseline), "baseline", this.baseline);
opts.addOption(@TypeOf(this.bindgen), "bindgen", this.bindgen);
@@ -97,35 +125,15 @@ const BunBuildOptions = struct {
opts.addOption(@TypeOf(this.base_path), "base_path", this.base_path);
opts.addOption(@TypeOf(this.runtime_js_version), "runtime_js_version", this.runtime_js_version);
opts.addOption(@TypeOf(this.fallback_html_version), "fallback_html_version", this.fallback_html_version);
opts.addOption(@TypeOf(this.tinycc), "tinycc", this.tinycc);
return opts;
}
};
// relative to the prefix
var output_dir: []const u8 = "";
fn panicIfNotFound(comptime filepath: []const u8) []const u8 {
var file = std.fs.cwd().openFile(filepath, .{ .optimize = .read_only }) catch |err| {
std.debug.panic("error: {s} opening {s}. Please ensure you've downloaded git submodules, and ran `make vendor`, `make jsc`.", .{ filepath, @errorName(err) });
};
file.close();
return filepath;
}
const fmt = struct {
pub usingnamespace @import("std").fmt;
pub fn hexInt(value: anytype) @TypeOf(std.fmt.fmtSliceHexLower("")) {
return std.fmt.fmtSliceHexLower(std.mem.asBytes(&value));
}
pub fn hexIntUp(value: anytype) @TypeOf(std.fmt.fmtSliceHexUpper("")) {
return std.fmt.fmtSliceHexUpper(std.mem.asBytes(&value));
}
};
var x64 = "x64";
var optimize: std.builtin.OptimizeMode = undefined;
var optimize: std.builtin.OptimizeMode = .Debug;
const Build = std.Build;
const CrossTarget = std.zig.CrossTarget;
@@ -146,6 +154,26 @@ pub fn build(b: *Build) !void {
}
pub fn build_(b: *Build) !void {
switch (comptime zig_version.order(std.SemanticVersion.parse(recommended_zig_version) catch unreachable)) {
.eq => {},
.lt => {
@compileError("The minimum version of Zig required to compile Bun is " ++ recommended_zig_version ++ ", found " ++ @import("builtin").zig_version_string ++ ". Please follow the instructions at https://bun.sh/docs/project/contributing. You may need to re-run `bun setup`.");
},
.gt => {
const colors = std.io.getStdErr().supportsAnsiEscapeCodes();
std.debug.print(
"{s}WARNING:\nBun recommends Zig version '{s}', but found '{s}', build may fail...\nMake sure you are following the instructions at https://bun.sh/docs/project/contributing\n{s}You can update to the right version using 'zigup {s}'\n\n",
.{
if (colors) "\x1b[1;33m" else "",
recommended_zig_version,
builtin.zig_version_string,
if (colors) "\x1b[0m" else "",
recommended_zig_version,
},
);
},
}
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
@@ -155,47 +183,65 @@ pub fn build_(b: *Build) !void {
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
optimize = b.standardOptimizeOption(.{});
var generated_code_directory = b.option([]const u8, "generated-code", "Set the generated code directory") orelse "";
if (generated_code_directory.len == 0) {
generated_code_directory = b.pathFromRoot("build/codegen");
}
var output_dir_buf = std.mem.zeroes([4096]u8);
var bin_label = if (optimize == std.builtin.OptimizeMode.Debug) "packages/debug-bun-" else "packages/bun-";
const bin_label = if (optimize == std.builtin.OptimizeMode.Debug) "packages/debug-bun-" else "packages/bun-";
var triplet_buf: [64]u8 = undefined;
var os_tagname = @tagName(target.getOs().tag);
const arch: std.Target.Cpu.Arch = target.getCpuArch();
if (std.mem.eql(u8, os_tagname, "macos")) {
os_tagname = "darwin";
target.os_version_min = std.zig.CrossTarget.OsVersion{ .semver = .{ .major = 11, .minor = 0, .patch = 0 } };
} else if (target.isLinux()) {
target.setGnuLibCVersion(2, 27, 0);
var os_tagname = @tagName(target.getOs().tag);
switch (target.getOs().tag) {
.macos => {
os_tagname = "darwin";
target.os_version_min = std.zig.CrossTarget.OsVersion{ .semver = .{ .major = 11, .minor = 0, .patch = 0 } };
},
.windows => {
target.os_version_min = std.zig.CrossTarget.OsVersion{
// Windows 1809
// Minimum version for a syscall related to bun.sys.renameat
// if you update this please update install.ps1
.windows = .win10_rs5,
};
},
.linux => {
target.setGnuLibCVersion(2, 27, 0);
},
else => {},
}
std.mem.copy(
u8,
&triplet_buf,
os_tagname,
);
var osname = triplet_buf[0..os_tagname.len];
@memcpy(triplet_buf[0..].ptr, os_tagname);
const osname = triplet_buf[0..os_tagname.len];
triplet_buf[osname.len] = '-';
std.mem.copy(u8, triplet_buf[osname.len + 1 ..], @tagName(target.getCpuArch()));
@memcpy(triplet_buf[osname.len + 1 ..].ptr, @tagName(target.getCpuArch()));
var cpuArchName = triplet_buf[osname.len + 1 ..][0..@tagName(target.getCpuArch()).len];
std.mem.replaceScalar(u8, cpuArchName, '_', '-');
if (std.mem.eql(u8, cpuArchName, "x86-64")) {
std.mem.copy(u8, cpuArchName, "x64");
@memcpy(cpuArchName.ptr, "x64");
cpuArchName = cpuArchName[0..3];
}
var triplet = triplet_buf[0 .. osname.len + cpuArchName.len + 1];
const triplet = triplet_buf[0 .. osname.len + cpuArchName.len + 1];
if (b.option([]const u8, "output-dir", "target to install to") orelse std.os.getenv("OUTPUT_DIR")) |output_dir_| {
output_dir = try pathRel(b.allocator, b.install_prefix, output_dir_);
const outfile_maybe = b.option([]const u8, "output-file", "target to install to");
if (outfile_maybe) |outfile| {
output_dir = try pathRel(b.allocator, b.install_prefix, std.fs.path.dirname(outfile) orelse "");
} else {
const output_dir_base = try std.fmt.bufPrint(&output_dir_buf, "{s}{s}", .{ bin_label, triplet });
output_dir = try pathRel(b.allocator, b.install_prefix, output_dir_base);
}
is_debug_build = optimize == OptimizeMode.Debug;
const bun_executable_name = if (optimize == std.builtin.OptimizeMode.Debug) "bun-debug" else "bun";
const bun_executable_name = if (outfile_maybe) |outfile| std.fs.path.basename(outfile[0 .. outfile.len - std.fs.path.extension(outfile).len]) else if (is_debug_build) "bun-debug" else "bun";
const root_src = if (target.getOsTag() == std.Target.Os.Tag.freestanding)
"root_wasm.zig"
else
@@ -217,10 +263,31 @@ pub fn build_(b: *Build) !void {
.root_source_file = FileSource.relative(root_src),
.target = target,
.optimize = optimize,
.main_pkg_path = .{ .cwd_relative = b.pathFromRoot(".") },
.main_mod_path = .{ .cwd_relative = b.pathFromRoot(".") },
});
b.reference_trace = 16;
if (!exists(b.pathFromRoot(try std.fs.path.join(b.allocator, &.{
"src",
"js_lexer",
"id_continue_bitset.blob",
})))) {
const identifier_data = b.pathFromRoot(try std.fs.path.join(b.allocator, &.{ "src", "js_lexer", "identifier_data.zig" }));
var run_step = b.addSystemCommand(&.{
b.zig_exe,
"run",
identifier_data,
});
run_step.has_side_effects = true;
obj.step.dependOn(&run_step.step);
}
b.reference_trace = if (b.option(u32, "reference-trace", "Set the reference trace")) |trace|
if (trace == 0)
null
else
trace
else
16;
var default_build_options: BunBuildOptions = brk: {
const is_baseline = arch.isX86() and (target.cpu_model == .baseline or
@@ -231,7 +298,7 @@ pub fn build_(b: *Build) !void {
git_sha = b.allocator.dupeZ(u8, sha) catch unreachable;
} else {
sha: {
const result = std.ChildProcess.exec(.{
const result = std.ChildProcess.run(.{
.allocator = b.allocator,
.argv = &.{
"git",
@@ -246,13 +313,22 @@ pub fn build_(b: *Build) !void {
}
}
const is_canary = (std.os.getenvZ("BUN_CANARY") orelse "0")[0] == '1';
const is_canary, const canary_revision = if (b.option(u32, "canary", "Treat this as a canary build")) |rev|
if (rev == 0)
.{ false, 0 }
else
.{ true, rev }
else
.{ false, 0 };
break :brk .{
.canary = is_canary,
.is_canary = is_canary,
.canary_revision = canary_revision,
.version = b.option([]const u8, "version", "Value of `Bun.version`") orelse "0.0.0",
.sha = git_sha,
.baseline = is_baseline,
.bindgen = false,
.base_path = try b.allocator.dupeZ(u8, b.pathFromRoot(".")),
.tracy_callstack_depth = b.option(u16, "tracy_callstack_depth", "") orelse 10,
};
};
@@ -269,10 +345,12 @@ pub fn build_(b: *Build) !void {
obj.target.cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v2 };
} else if (arch.isX86()) {
obj.target.cpu_model = .{ .explicit = &std.Target.x86.cpu.haswell };
} else if (arch.isAARCH64() and target.isDarwin()) {
obj.target.cpu_model = .{ .explicit = &std.Target.aarch64.cpu.apple_m1 };
} else if (arch.isAARCH64() and target.isLinux()) {
obj.target.cpu_model = .{ .explicit = &std.Target.aarch64.cpu.generic };
} else if (arch.isAARCH64()) {
if (target.isDarwin()) {
obj.target.cpu_model = .{ .explicit = &std.Target.aarch64.cpu.apple_m1 };
} else {
obj.target.cpu_model = .{ .explicit = &std.Target.aarch64.cpu.generic };
}
}
try default_build_options.updateRuntime();
@@ -283,8 +361,8 @@ pub fn build_(b: *Build) !void {
min_version,
max_version,
obj.target.getCpuModel().name,
}) catch unreachable;
std.io.getStdErr().writer().print("Output: {s}/{s}\n\n", .{ output_dir, bun_executable_name }) catch unreachable;
}) catch {};
std.io.getStdErr().writer().print("Zig v{s}\n", .{builtin.zig_version_string}) catch {};
defer obj_step.dependOn(&obj.step);
@@ -301,15 +379,26 @@ pub fn build_(b: *Build) !void {
actual_build_options.sizegen = true;
}
actual_build_options.project = "bun";
obj.addOptions("build_options", actual_build_options.step(b));
obj.linkLibC();
// Generated Code
// TODO: exit with a better error early if these files do not exist. it is an indication someone ran `zig build` directly without the code generators.
obj.addModule("ZigGeneratedClasses", b.createModule(.{
.source_file = .{ .path = b.pathJoin(&.{ generated_code_directory, "ZigGeneratedClasses.zig" }) },
}));
obj.addModule("ResolvedSourceTag", b.createModule(.{
.source_file = .{ .path = b.pathJoin(&.{ generated_code_directory, "ResolvedSourceTag.zig" }) },
}));
obj.linkLibC();
obj.dll_export_fns = true;
obj.strip = false;
obj.bundle_compiler_rt = false;
obj.omit_frame_pointer = optimize != .Debug;
obj.subsystem = .Console;
// Disable stack probing on x86 so we don't need to include compiler_rt
if (target.getCpuArch().isX86()) obj.disable_stack_probing = true;
if (target.getCpuArch().isX86() or target.isWindows()) obj.disable_stack_probing = true;
if (b.option(bool, "for-editor", "Do not emit bin, just check for errors") orelse false) {
// obj.emit_bin = .no_emit;
@@ -331,7 +420,7 @@ pub fn build_(b: *Build) !void {
.root_source_file = FileSource.relative("src/bindgen.zig"),
.target = target,
.optimize = optimize,
.main_pkg_path = obj.main_pkg_path,
.main_mod_path = obj.main_mod_path,
});
defer headers_step.dependOn(&headers_obj.step);
try configureObjectStep(b, headers_obj, headers_step, @TypeOf(target), target);
@@ -348,7 +437,7 @@ pub fn build_(b: *Build) !void {
.root_source_file = FileSource.relative("root_wasm.zig"),
.target = target,
.optimize = optimize,
.main_pkg_path = obj.main_pkg_path,
.main_mod_path = obj.main_mod_path,
});
defer wasm_step.dependOn(&wasm.step);
wasm.strip = false;
@@ -367,7 +456,7 @@ pub fn build_(b: *Build) !void {
.root_source_file = FileSource.relative("misctools/http_bench.zig"),
.target = target,
.optimize = optimize,
.main_pkg_path = obj.main_pkg_path,
.main_mod_path = obj.main_mod_path,
});
defer headers_step.dependOn(&headers_obj.step);
try configureObjectStep(b, headers_obj, headers_step, @TypeOf(target), target);
@@ -381,7 +470,7 @@ pub fn build_(b: *Build) !void {
.root_source_file = FileSource.relative("misctools/machbench.zig"),
.target = target,
.optimize = optimize,
.main_pkg_path = obj.main_pkg_path,
.main_mod_path = obj.main_mod_path,
});
defer headers_step.dependOn(&headers_obj.step);
try configureObjectStep(b, headers_obj, headers_step, @TypeOf(target), target);
@@ -395,7 +484,7 @@ pub fn build_(b: *Build) !void {
.root_source_file = FileSource.relative("misctools/fetch.zig"),
.target = target,
.optimize = optimize,
.main_pkg_path = obj.main_pkg_path,
.main_mod_path = obj.main_mod_path,
});
defer headers_step.dependOn(&headers_obj.step);
try configureObjectStep(b, headers_obj, headers_step, @TypeOf(target), target);
@@ -409,7 +498,7 @@ pub fn build_(b: *Build) !void {
.root_source_file = FileSource.relative("src/bench/string-handling.zig"),
.target = target,
.optimize = optimize,
.main_pkg_path = obj.main_pkg_path,
.main_mod_path = obj.main_mod_path,
});
defer headers_step.dependOn(&headers_obj.step);
try configureObjectStep(b, headers_obj, headers_step, @TypeOf(target), target);
@@ -423,7 +512,7 @@ pub fn build_(b: *Build) !void {
.root_source_file = FileSource.relative("src/sha.zig"),
.target = target,
.optimize = optimize,
.main_pkg_path = obj.main_pkg_path,
.main_mod_path = obj.main_mod_path,
});
defer headers_step.dependOn(&headers_obj.step);
try configureObjectStep(b, headers_obj, headers_step, @TypeOf(target), target);
@@ -437,7 +526,7 @@ pub fn build_(b: *Build) !void {
.root_source_file = FileSource.relative("src/sourcemap/vlq_bench.zig"),
.target = target,
.optimize = optimize,
.main_pkg_path = obj.main_pkg_path,
.main_mod_path = obj.main_mod_path,
});
defer headers_step.dependOn(&headers_obj.step);
try configureObjectStep(b, headers_obj, headers_step, @TypeOf(target), target);
@@ -451,7 +540,7 @@ pub fn build_(b: *Build) !void {
.root_source_file = FileSource.relative("misctools/tgz.zig"),
.target = target,
.optimize = optimize,
.main_pkg_path = obj.main_pkg_path,
.main_mod_path = obj.main_mod_path,
});
defer headers_step.dependOn(&headers_obj.step);
try configureObjectStep(b, headers_obj, headers_step, @TypeOf(target), target);
@@ -461,14 +550,14 @@ pub fn build_(b: *Build) !void {
{
const headers_step = b.step("test", "Build test");
var test_file = b.option([]const u8, "test-file", "Input file for test");
var test_bin_ = b.option([]const u8, "test-bin", "Emit bin to");
var test_filter = b.option([]const u8, "test-filter", "Filter for test");
const test_file = b.option([]const u8, "test-file", "Input file for test");
const test_bin_ = b.option([]const u8, "test-bin", "Emit bin to");
const test_filter = b.option([]const u8, "test-filter", "Filter for test");
var headers_obj: *CompileStep = b.addTest(.{
.root_source_file = FileSource.relative(test_file orelse "src/main.zig"),
.target = target,
.main_pkg_path = obj.main_pkg_path,
.main_mod_path = obj.main_mod_path,
});
headers_obj.filter = test_filter;
if (test_bin_) |test_bin| {
@@ -490,7 +579,20 @@ pub fn build_(b: *Build) !void {
headers_obj.addOptions("build_options", default_build_options.step(b));
}
b.default_step.dependOn(obj_step);
// Running `zig build` with no arguments is almost always a mistake.
const mistake_message = b.addSystemCommand(&.{
"echo",
\\
\\error: To build Bun from source, please use `bun run setup` instead of `zig build`"
\\
\\If you want to build the zig code only, run:
\\ 'zig build obj -Dgenerated-code=./build/codegen [...opts]'
\\
\\For more info, see https://bun.sh/docs/project/contributing
\\
});
b.default_step.dependOn(&mistake_message.step);
}
pub var original_make_fn: ?*const fn (step: *std.build.Step) anyerror!void = null;

BIN
bun.lockb

Binary file not shown.

View File

@@ -1,8 +1,8 @@
[test]
# Large monorepos (like Bun) may want to specify the test directory more specifically
# By default, `bun test` scans every single folder recurisvely which, if you
# have a gigantic submodule (like WebKit), it has to do lots of directory
# By default, `bun test` scans every single folder recursively which, if you
# have a gigantic submodule (like WebKit), requires lots of directory
# traversals
#
# Instead, we can just make it scan only the test directory for Bun's runtime tests
# Instead, we can only scan the test directory for Bun's runtime tests
root = "test"

View File

@@ -1,15 +1,17 @@
#/usr/bin/env bash
_file_arguments() {
shopt -s extglob globstar
local extensions="${1}";
local extensions="${1}"
local reset=$(shopt -p globstar)
shopt -s globstar
if [[ -z "${cur_word}" ]]; then
COMPREPLY=( $(compgen -fG -X "${extensions}" -- "${cur_word}") );
else
COMPREPLY=( $(compgen -f -X "${extensions}" -- "${cur_word}") );
fi
shopt -u extglob globstar
$reset
}
_long_short_completion() {
@@ -43,9 +45,7 @@ _read_scripts_in_package_json() {
local package_json_compreply;
local matched="${BASH_REMATCH[@]:1}";
local scripts="${matched%%\}*}";
shopt -s extglob;
scripts="${scripts//@(\"|\')/}";
shopt -u extglob;
readarray -td, scripts <<<"${scripts}";
for completion in "${scripts[@]}"; do
package_json_compreply+=( "${completion%:*}" );
@@ -84,7 +84,7 @@ _bun_completions() {
local SUBCOMMANDS="dev bun create run install add remove upgrade completions discord help init pm x";
GLOBAL_OPTIONS[LONG_OPTIONS]="--use --cwd --bunfile --server-bunfile --config --disable-react-fast-refresh --disable-hmr --extension-order --jsx-factory --jsx-fragment --extension-order --jsx-factory --jsx-fragment --jsx-import-source --jsx-production --jsx-runtime --main-fields --no-summary --version --platform --public-dir --tsconfig-override --define --external --help --inject --loader --origin --port --dump-environment-variables --dump-limits --disable-bun-js";
GLOBAL_OPTIONS[LONG_OPTIONS]="--use --cwd --bunfile --server-bunfile --config --disable-react-fast-refresh --disable-hmr --env-file --extension-order --jsx-factory --jsx-fragment --extension-order --jsx-factory --jsx-fragment --jsx-import-source --jsx-production --jsx-runtime --main-fields --no-summary --version --platform --public-dir --tsconfig-override --define --external --help --inject --loader --origin --port --dump-environment-variables --dump-limits --disable-bun-js";
GLOBAL_OPTIONS[SHORT_OPTIONS]="-c -v -d -e -h -i -l -u -p";
PACKAGE_OPTIONS[ADD_OPTIONS_LONG]="--development --optional";
@@ -92,12 +92,12 @@ _bun_completions() {
PACKAGE_OPTIONS[REMOVE_OPTIONS_LONG]="";
PACKAGE_OPTIONS[REMOVE_OPTIONS_SHORT]="";
PACKAGE_OPTIONS[SHARED_OPTIONS_LONG]="--config --yarn --production --frozen-lockfile --no-save --dry-run --lockfile --force --cache-dir --no-cache --silent --verbose --global --cwd --backend --link-native-bins --help";
PACKAGE_OPTIONS[SHARED_OPTIONS_LONG]="--config --yarn --production --frozen-lockfile --no-save --dry-run --force --cache-dir --no-cache --silent --verbose --global --cwd --backend --link-native-bins --help";
PACKAGE_OPTIONS[SHARED_OPTIONS_SHORT]="-c -y -p -f -g";
PM_OPTIONS[LONG_OPTIONS]="--config --yarn --production --frozen-lockfile --no-save --dry-run --lockfile --force --cache-dir --no-cache --silent --verbose --no-progress --no-summary --no-verify --ignore-scripts --global --cwd --backend --link-native-bins --help"
PM_OPTIONS[LONG_OPTIONS]="--config --yarn --production --frozen-lockfile --no-save --dry-run --force --cache-dir --no-cache --silent --verbose --no-progress --no-summary --no-verify --ignore-scripts --global --cwd --backend --link-native-bins --help"
PM_OPTIONS[SHORT_OPTIONS]="-c -y -p -f -g"
local cur_word="${COMP_WORDS[${COMP_CWORD}]}";
local prev="${COMP_WORDS[$(( COMP_CWORD - 1 ))]}";

View File

@@ -51,7 +51,7 @@ function __bun_last_cmd --argument-names n
end
set -l bun_install_boolean_flags yarn production optional development no-save dry-run force no-cache silent verbose global
set -l bun_install_boolean_flags_descriptions "Write a yarn.lock file (yarn v1)" "Don't install devDependencies" "Add dependency to optionalDependencies" "Add dependency to devDependencies" "Don't install devDependencies" "Don't install anything" "Always request the latest versions from the registry & reinstall all dependenices" "Ignore manifest cache entirely" "Don't output anything" "Excessively verbose logging" "Use global folder"
set -l bun_install_boolean_flags_descriptions "Write a yarn.lock file (yarn v1)" "Don't install devDependencies" "Add dependency to optionalDependencies" "Add dependency to devDependencies" "Don't install devDependencies" "Don't install anything" "Always request the latest versions from the registry & reinstall all dependencies" "Ignore manifest cache entirely" "Don't output anything" "Excessively verbose logging" "Use global folder"
set -l bun_builtin_cmds dev create help bun upgrade discord run install remove add init link unlink pm x
set -l bun_builtin_cmds_without_run dev create help bun upgrade discord install remove add init pm x

File diff suppressed because it is too large Load Diff

View File

@@ -78,6 +78,9 @@ subcommands:
- name: server-bunfile
type: string
summary: "Use a specific .bun file for SSR in bun dev (default: node_modules.server.bun)"
- name: env-file
type: string
summary: "Load environment variables from the specified file(s)"
- name: extension-order
type: string
summary: "defaults to: .tsx,.ts,.jsx,.js,.json"
@@ -118,10 +121,7 @@ subcommands:
- frozen-lockfile -- "Disallow changes to lockfile"
- no-save --
- dry-run -- "Don't install anything"
- force -- "Always request the latest versions from the registry & reinstall all dependenices"
- name: lockfile
type: string
summary: "Store & load a lockfile at a specific filepath"
- force -- "Always request the latest versions from the registry & reinstall all dependencies"
- name: cache-dir
type: string
summary: "Store & load cached data from a specific directory path"
@@ -156,13 +156,10 @@ subcommands:
- frozen-lockfile -- "Disallow changes to lockfile"
- no-save --
- dry-run -- "Don't install anything"
- force -- "Always request the latest versions from the registry & reinstall all dependenices"
- force -- "Always request the latest versions from the registry & reinstall all dependencies"
- no-cache -- "Ignore manifest cache entirely"
- silent -- "Don't output anything"
- verbose -- "Excessively verbose logging"
- name: lockfile
type: string
summary: "Store & load a lockfile at a specific filepath"
- name: cache-dir
type: string
summary: "Store & load cached data from a specific directory path"
@@ -197,10 +194,7 @@ subcommands:
- frozen-lockfile -- "Disallow changes to lockfile"
- no-save --
- dry-run -- "Don't install anything"
- force -- "Always request the latest versions from the registry & reinstall all dependenices"
- name: lockfile
type: string
summary: "Store & load a lockfile at a specific filepath"
- force -- "Always request the latest versions from the registry & reinstall all dependencies"
- name: cache-dir
type: string
summary: "Store & load cached data from a specific directory path"

View File

@@ -1,29 +0,0 @@
# bun:alpine
# Not officially supported (yet)
ARG GLIBC_RELEASE=2.35-r0
FROM alpine:latest AS build
WORKDIR /tmp
RUN apk --no-cache add unzip
ARG GLIBC_RELEASE
RUN wget https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_RELEASE}/glibc-${GLIBC_RELEASE}.apk
ADD https://github.com/oven-sh/bun/releases/latest/download/bun-linux-x64.zip bun-linux-x64.zip
RUN unzip bun-linux-x64.zip
FROM alpine:latest
ARG GLIBC_RELEASE
COPY --from=build /tmp/sgerrand.rsa.pub /etc/apk/keys
COPY --from=build /tmp/glibc-${GLIBC_RELEASE}.apk /tmp
COPY --from=build /tmp/bun-linux-x64/bun /usr/local/bin
RUN apk --no-cache --force-overwrite add /tmp/glibc-${GLIBC_RELEASE}.apk \
&& rm /etc/apk/keys/sgerrand.rsa.pub \
&& rm /tmp/glibc-${GLIBC_RELEASE}.apk
RUN bun --version

View File

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

118
dockerhub/alpine/Dockerfile Normal file
View File

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

View File

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

View File

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

View File

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

View File

@@ -26,10 +26,10 @@ Below is a quick "cheat sheet" that doubles as a table of contents. Click an ite
---
<!-- - [`File`](#file)
- _Browser only_. A subclass of `Blob` that represents a file. Has a `name` and `lastModified` timestamp. There is experimental support in Node.js v20; Bun does not support `File` yet; most of its functionality is provided by `BunFile`.
- [`File`](#file)
- A subclass of `Blob` that represents a file. Has a `name` and `lastModified` timestamp. There is experimental support in Node.js v20.
--- -->
---
- [`BunFile`](#bunfile)
- _Bun only_. A subclass of `Blob` that represents a lazily-loaded file on disk. Created with `Bun.file(path)`.
@@ -49,7 +49,6 @@ Despite the name, it isn't an array and supports none of the array methods and o
```ts
const buf = new ArrayBuffer(8);
buf.byteLength; // => 8
const slice = buf.slice(0, 4); // returns new ArrayBuffer
@@ -66,19 +65,19 @@ Below we create a new `DataView` and set the first byte to 5.
```ts
const buf = new ArrayBuffer(4);
// [0x0, 0x0, 0x0, 0x0]
// [0b00000000, 0b00000000, 0b00000000, 0b00000000]
const dv = new DataView(buf);
dv.setUint8(0, 3); // write value 3 at byte offset 0
dv.getUint8(0); // => 3
// [0x11, 0x0, 0x0, 0x0]
// [0b00000011, 0b00000000, 0b00000000, 0b00000000]
```
Now lets write a `Uint16` at byte offset `1`. This requires two bytes. We're using the value `513`, which is `2 * 256 + 1`; in bytes, that's `00000010 00000001`.
Now let's write a `Uint16` at byte offset `1`. This requires two bytes. We're using the value `513`, which is `2 * 256 + 1`; in bytes, that's `00000010 00000001`.
```ts
dv.setUint16(1, 513);
// [0x11, 0x10, 0x1, 0x0]
// [0b00000011, 0b00000010, 0b00000001, 0b00000000]
console.log(dv.getUint16(1)); // => 513
```
@@ -90,7 +89,7 @@ console.log(dv.getUint8(1)); // => 2
console.log(dv.getUint8(2)); // => 1
```
Attempting to write a value that requires more space than is available in the underlying `ArrayBuffer` will cuase an error. Below we attempt to write a `Float64` (which requires 8 bytes) at byte offset `0`, but there are only four total bytes in the buffer.
Attempting to write a value that requires more space than is available in the underlying `ArrayBuffer` will cause an error. Below we attempt to write a `Float64` (which requires 8 bytes) at byte offset `0`, but there are only four total bytes in the buffer.
```ts
dv.setFloat64(0, 3.1415);
@@ -412,7 +411,7 @@ For complete documentation, refer to the [Node.js documentation](https://nodejs.
`Blob` is a Web API commonly used for representing files. `Blob` was initially implemented in browsers (unlike `ArrayBuffer` which is part of JavaScript itself), but it is now supported in Node and Bun.
It isn't common to directly create `Blob` instances. More often, you'll recieve instances of `Blob` from an external source (like an `<input type="file">` element in the browser) or library. That said, it is possible to create a `Blob` from one or more string or binary "blob parts".
It isn't common to directly create `Blob` instances. More often, you'll receive instances of `Blob` from an external source (like an `<input type="file">` element in the browser) or library. That said, it is possible to create a `Blob` from one or more string or binary "blob parts".
```ts
const blob = new Blob(["<html>Hello</html>"], {
@@ -507,7 +506,7 @@ for await (const chunk of stream) {
}
```
For a more complete discusson of streams in Bun, see [API > Streams](/docs/api/streams).
For a more complete discussion of streams in Bun, see [API > Streams](/docs/api/streams).
## Conversion

View File

@@ -229,7 +229,11 @@ const lib = linkSymbols({
},
});
const [major, minor, patch] = [lib.symbols.getMajor(), lib.symbols.getMinor(), lib.symbols.getPatch()];
const [major, minor, patch] = [
lib.symbols.getMajor(),
lib.symbols.getMinor(),
lib.symbols.getPatch(),
];
```
## Callbacks
@@ -249,10 +253,13 @@ const {
},
});
const searchIterator = new JSCallback((ptr, length) => /hello/.test(new CString(ptr, length)), {
returns: "bool",
args: ["ptr", "usize"],
});
const searchIterator = new JSCallback(
(ptr, length) => /hello/.test(new CString(ptr, length)),
{
returns: "bool",
args: ["ptr", "usize"],
},
);
const str = Buffer.from("wwutwutwutwutwutwutwutwutwutwutut\0", "utf8");
if (search(ptr(str), searchIterator)) {
@@ -376,10 +383,6 @@ If you want to track when a `TypedArray` is no longer in use from JavaScript, yo
#### From C, Rust, Zig, etc
{% callout %}
**Note** — Available in Bun v0.1.8 and later.
{% /callout %}
If you want to track when a `TypedArray` is no longer in use from C or FFI, you can pass a callback and an optional context pointer to `toArrayBuffer` or `toBuffer`. This function is called at some point later, once the garbage collector frees the underlying `ArrayBuffer` JavaScript object.
The expected signature is the same as in [JavaScriptCore's C API](https://developer.apple.com/documentation/javascriptcore/jstypedarraybytesdeallocator?language=objc):

View File

@@ -2,7 +2,7 @@
<!-- **Note** — The `Bun.file` and `Bun.write` APIs documented on this page are heavily optimized and represent the recommended way to perform file-system tasks using Bun. Existing Node.js projects may use Bun's [nearly complete](/docs/runtime/nodejs-apis#node-fs) implementation of the [`node:fs`](https://nodejs.org/api/fs.html) module. -->
**Note** — The `Bun.file` and `Bun.write` APIs documented on this page are heavily optimized and represent the recommended way to perform file-system tasks using Bun. For operations that are not yet available with `Bun.file`, such as `mkdir`, you can use Bun's [nearly complete](/docs/runtime/nodejs-apis#node-fs) implementation of the [`node:fs`](https://nodejs.org/api/fs.html) module.
**Note** — The `Bun.file` and `Bun.write` APIs documented on this page are heavily optimized and represent the recommended way to perform file-system tasks using Bun. For operations that are not yet available with `Bun.file`, such as `mkdir` or `readdir`, you can use Bun's [nearly complete](/docs/runtime/nodejs-apis#node-fs) implementation of the [`node:fs`](https://nodejs.org/api/fs.html) module.
{% /callout %}
@@ -195,7 +195,7 @@ const input = Bun.file("input.txt");
await Bun.write(Bun.stdout, input);
```
To write an HTTP response to disk:
To write the body of an HTTP response to disk:
```ts
const response = await fetch("https://bun.sh");
@@ -249,6 +249,42 @@ writer.unref();
writer.ref();
```
## Directories
Bun's implementation of `node:fs` is fast, and we haven't implemented a Bun-specific API for reading directories just yet. For now, you should use `node:fs` for working with directories in Bun.
### Reading directories (readdir)
To read a directory in Bun, use `readdir` from `node:fs`.
```ts
import { readdir } from "node:fs/promises";
// read all the files in the current directory
const files = await readdir(import.meta.dir);
```
#### Reading directories recursively
To recursively read a directory in Bun, use `readdir` with `recursive: true`.
```ts
import { readdir } from "node:fs/promises";
// read all the files in the current directory, recursively
const files = await readdir("../", { recursive: true });
```
### Creating directories (mkdir)
To recursively create a directory, use `mkdir` in `node:fs`:
```ts
import { mkdir } from "node:fs/promises";
await mkdir("path/to/dir", { recursive: true });
```
## Benchmarks
The following is a 3-line implementation of the Linux `cat` command.
@@ -300,7 +336,7 @@ interface BunFile {
readonly type: string;
text(): Promise<string>;
stream(): Promise<ReadableStream>;
stream(): ReadableStream;
arrayBuffer(): Promise<ArrayBuffer>;
json(): Promise<any>;
writer(params: { highWaterMark?: number }): FileSink;

View File

@@ -46,7 +46,7 @@ router.match("/settings?foo=bar");
kind: "dynamic",
name: "/settings",
pathname: "/settings?foo=bar",
src: "https://mydomain.com/_next/static/pages/settings.tsx"
src: "https://mydomain.com/_next/static/pages/settings.tsx",
query: {
foo: "bar"
}
@@ -64,7 +64,7 @@ router.match("/blog/my-cool-post");
kind: "dynamic",
name: "/blog/[slug]",
pathname: "/blog/my-cool-post",
src: "https://mydomain.com/_next/static/pages/blog/[slug].tsx"
src: "https://mydomain.com/_next/static/pages/blog/[slug].tsx",
params: {
slug: "my-cool-post"
}
@@ -93,6 +93,7 @@ interface Bun {
style: "nextjs";
origin?: string;
assetPrefix?: string;
fileExtensions?: string[];
});
reload(): void;

157
docs/api/glob.md Normal file
View File

@@ -0,0 +1,157 @@
Bun includes a fast native implementation of file globbing.
## Quickstart
**Scan a directory for files matching `*.ts`**:
```ts
import { Glob } from "bun";
const glob = new Glob("**/*.ts");
// Scans the current working directory and each of its sub-directories recursively
for await (const file of glob.scan(".")) {
console.log(file); // => "index.ts"
}
```
**Match a string against a glob pattern**:
```ts
import { Glob } from "bun";
const glob = new Glob("*.ts");
glob.match("index.ts"); // => true
glob.match("index.js"); // => false
```
`Glob` is a class which implements the following interface:
```ts
class Glob {
scan(root: string | ScanOptions): AsyncIterable<string>;
scanSync(root: string | ScanOptions): Iterable<string>;
match(path: string): boolean;
}
interface ScanOptions {
/**
* The root directory to start matching from. Defaults to `process.cwd()`
*/
cwd?: string;
/**
* Allow patterns to match entries that begin with a period (`.`).
*
* @default false
*/
dot?: boolean;
/**
* Return the absolute path for entries.
*
* @default false
*/
absolute?: boolean;
/**
* Indicates whether to traverse descendants of symbolic link directories.
*
* @default false
*/
followSymlinks?: boolean;
/**
* Throw an error when symbolic link is broken
*
* @default false
*/
throwErrorOnBrokenSymlink?: boolean;
/**
* Return only files.
*
* @default true
*/
onlyFiles?: boolean;
}
```
## Supported Glob Patterns
Bun supports the following glob patterns:
### `?` - Match any single character
```ts
const glob = new Glob("???.ts");
glob.match("foo.ts"); // => true
glob.match("foobar.ts"); // => false
```
### `*` - Matches zero or more characters, except for path separators (`/` or `\`)
```ts
const glob = new Glob("*.ts");
glob.match("index.ts"); // => true
glob.match("src/index.ts"); // => false
```
### `**` - Match any number of characters including `/`
```ts
const glob = new Glob("**/*.ts");
glob.match("index.ts"); // => true
glob.match("src/index.ts"); // => true
glob.match("src/index.js"); // => false
```
### `[ab]` - Matches one of the characters contained in the brackets, as well as character ranges
```ts
const glob = new Glob("ba[rz].ts");
glob.match("bar.ts"); // => true
glob.match("baz.ts"); // => true
glob.match("bat.ts"); // => false
```
You can use character ranges (e.g `[0-9]`, `[a-z]`) as well as the negation operators `^` or `!` to match anything _except_ the characters contained within the braces (e.g `[^ab]`, `[!a-z]`)
```ts
const glob = new Glob("ba[a-z][0-9][^4-9].ts");
glob.match("bar01.ts"); // => true
glob.match("baz83.ts"); // => true
glob.match("bat22.ts"); // => true
glob.match("bat24.ts"); // => false
glob.match("ba0a8.ts"); // => false
```
### `{a,b,c}` - Match any of the given patterns
```ts
const glob = new Glob("{a,b,c}.ts");
glob.match("a.ts"); // => true
glob.match("b.ts"); // => true
glob.match("c.ts"); // => true
glob.match("d.ts"); // => false
```
These match patterns can be deeply nested (up to 10 levels), and contain any of the wildcards from above.
### `!` - Negates the result at the start of a pattern
```ts
const glob = new Glob("!index.ts");
glob.match("index.ts"); // => false
glob.match("foo.ts"); // => true
```
### `\` - Escapes any of the special characters above
```ts
const glob = new Glob("\\!index.ts");
glob.match("!index.ts"); // => true
glob.match("index.ts"); // => false
```

View File

@@ -6,10 +6,6 @@ Bun implements the `createHash` and `createHmac` functions from [`node:crypto`](
## `Bun.password`
{% callout %}
**Note** — Added in Bun 0.6.8.
{% /callout %}
`Bun.password` is a collection of utility functions for hashing and verifying passwords with various cryptographically secure algorithms.
```ts
@@ -136,7 +132,7 @@ hasher.digest();
Once initialized, data can be incrementally fed to to the hasher using `.update()`. This method accepts `string`, `TypedArray`, and `ArrayBuffer`.
```ts
const hasher = new Bun.CryptoHasher();
const hasher = new Bun.CryptoHasher("sha256");
hasher.update("hello world");
hasher.update(new Uint8Array([1, 2, 3]));
@@ -174,7 +170,7 @@ hasher.update("hello world", "latin1");
After the data has been feed into the hasher, a final hash can be computed using `.digest()`. By default, this method returns a `Uint8Array` containing the hash.
```ts
const hasher = new Bun.CryptoHasher();
const hasher = new Bun.CryptoHasher("sha256");
hasher.update("hello world");
hasher.digest();

View File

@@ -13,7 +13,7 @@ Start an HTTP server in Bun with `Bun.serve`.
```ts
Bun.serve({
fetch(req) {
return new Response(`Bun!`);
return new Response("Bun!");
},
});
```
@@ -24,9 +24,9 @@ The `fetch` handler handles incoming requests. It receives a [`Request`](https:/
Bun.serve({
fetch(req) {
const url = new URL(req.url);
if (url.pathname === "/") return new Response(`Home page!`);
if (url.pathname === "/") return new Response("Home page!");
if (url.pathname === "/blog") return new Response("Blog!");
return new Response(`404!`);
return new Response("404!");
},
});
```
@@ -38,7 +38,7 @@ Bun.serve({
port: 8080, // defaults to $BUN_PORT, $PORT, $NODE_PORT otherwise 3000
hostname: "mydomain.com", // defaults to "0.0.0.0"
fetch(req) {
return new Response(`404!`);
return new Response("404!");
},
});
```
@@ -71,7 +71,7 @@ In development mode, Bun will surface errors in-browser with a built-in error pa
{% image src="/images/exception_page.png" caption="Bun's built-in 500 page" /%}
To handle server-side errors, implement an `error` handler. This function should return a `Response` to served to the client when an error occurs. This response will supercede Bun's default error page in `development` mode.
To handle server-side errors, implement an `error` handler. This function should return a `Response` to serve to the client when an error occurs. This response will supersede Bun's default error page in `development` mode.
```ts
Bun.serve({
@@ -140,12 +140,6 @@ Bun.serve({
});
```
{% callout %}
**Note** — Earlier versions of Bun supported passing a file path as `keyFile` and `certFile`; this has been deprecated as of `v0.6.3`.
{% /callout %}
If your private key is encrypted with a passphrase, provide a value for `passphrase` to decrypt it.
```ts-diff
@@ -177,14 +171,14 @@ Optionally, you can override the trusted CA certificates by passing a value for
});
```
To override Diffie-Helman parameters:
To override Diffie-Hellman parameters:
```ts
Bun.serve({
// ...
tls: {
// other config
dhParamsFile: "/path/to/dhparams.pem", // path to Diffie Helman parameters
dhParamsFile: "/path/to/dhparams.pem", // path to Diffie Hellman parameters
},
});
```
@@ -198,7 +192,7 @@ import {type Serve} from "bun";
export default {
fetch(req) {
return new Response(`Bun!`);
return new Response("Bun!");
},
} satisfies Serve;
```
@@ -218,9 +212,7 @@ $ bun --hot server.ts
To stream a file, return a `Response` object with a `BunFile` object as the body.
```ts
import { serve, file } from "bun";
serve({
Bun.serve({
fetch(req) {
return new Response(Bun.file("./hello.txt"));
},
@@ -231,7 +223,7 @@ serve({
⚡️ **Speed** — Bun automatically uses the [`sendfile(2)`](https://man7.org/linux/man-pages/man2/sendfile.2.html) system call when possible, enabling zero-copy file transfers in the kernel—the fastest way to send files.
{% /callout %}
**[v0.3.0+]** You can send part of a file using the [`slice(start, end)`](https://developer.mozilla.org/en-US/docs/Web/API/Blob/slice) method on the `Bun.file` object. This automatically sets the `Content-Range` and `Content-Length` headers on the `Response` object.
You can send part of a file using the [`slice(start, end)`](https://developer.mozilla.org/en-US/docs/Web/API/Blob/slice) method on the `Bun.file` object. This automatically sets the `Content-Range` and `Content-Length` headers on the `Response` object.
```ts
Bun.serve({
@@ -260,7 +252,7 @@ Below are Bun and Node.js implementations of a simple HTTP server that responds
```ts#Bun
Bun.serve({
fetch(req: Request) {
return new Response(`Bun!`);
return new Response("Bun!");
},
port: 3000,
});

View File

@@ -23,6 +23,11 @@ import.meta.resolveSync("zod")
---
- `import.meta.dirname`
- An alias to `import.meta.dir`, for Node.js compatibility
---
- `import.meta.file`
- The name of the current file, e.g. `index.tsx`
@@ -33,13 +38,28 @@ import.meta.resolveSync("zod")
---
- `import.meta.filename`
- An alias to `import.meta.path`, for Node.js compatibility
---
- `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?
---
- `import.meta.env`
- An alias to `process.env`.
---
- `import.meta.resolve{Sync}`
- Resolve a module specifier (e.g. `"zod"` or `"./file.tsx`) to an absolute path. While file would be imported if the specifier were imported from this file?
- Resolve a module specifier (e.g. `"zod"` or `"./file.tsx"`) to an absolute path. While file would be imported if the specifier were imported from this file?
```ts
import.meta.resolveSync("zod");

52
docs/api/semver.md Normal file
View File

@@ -0,0 +1,52 @@
Bun implements a semantic versioning API which can be used to compare versions and determine if a version is compatible with another range of versions. The versions and ranges are designed to be compatible with `node-semver`, which is used by npm clients.
It's about 20x faster than `node-semver`.
![Benchmark](https://github.com/oven-sh/bun/assets/709451/94746adc-8aba-4baf-a143-3c355f8e0f78)
Currently, this API is two functions.
#### `Bun.semver.satisfies(version: string, range: string): boolean`
Returns `true` if `version` satisfies `range`, otherwise `false`.
Example:
```typescript
import { semver } from "bun";
semver.satisfies("1.0.0", "^1.0.0"); // true
semver.satisfies("1.0.0", "^1.0.1"); // false
semver.satisfies("1.0.0", "~1.0.0"); // true
semver.satisfies("1.0.0", "~1.0.1"); // false
semver.satisfies("1.0.0", "1.0.0"); // true
semver.satisfies("1.0.0", "1.0.1"); // false
semver.satisfies("1.0.1", "1.0.0"); // false
semver.satisfies("1.0.0", "1.0.x"); // true
semver.satisfies("1.0.0", "1.x.x"); // true
semver.satisfies("1.0.0", "x.x.x"); // true
semver.satisfies("1.0.0", "1.0.0 - 2.0.0"); // true
semver.satisfies("1.0.0", "1.0.0 - 1.0.1"); // true
```
If `range` is invalid, it returns false. If `version` is invalid, it returns false.
#### `Bun.semver.order(versionA: string, versionB: string): 0 | 1 | -1`
Returns `0` if `versionA` and `versionB` are equal, `1` if `versionA` is greater than `versionB`, and `-1` if `versionA` is less than `versionB`.
Example:
```typescript
import { semver } from "bun";
semver.order("1.0.0", "1.0.0"); // 0
semver.order("1.0.0", "1.0.1"); // -1
semver.order("1.0.1", "1.0.0"); // 1
const unsorted = ["1.0.0", "1.0.1", "1.0.0-alpha", "1.0.0-beta", "1.0.0-rc"];
unsorted.sort(semver.order); // ["1.0.0-alpha", "1.0.0-beta", "1.0.0-rc", "1.0.0", "1.0.1"]
console.log(unsorted);
```
If you need other semver functions, feel free to open an issue or pull request.

View File

@@ -28,7 +28,9 @@ By default, the input stream of the subprocess is undefined; it can be configure
```ts
const proc = Bun.spawn(["cat"], {
stdin: await fetch("https://raw.githubusercontent.com/oven-sh/bun/main/examples/hashing.js"),
stdin: await fetch(
"https://raw.githubusercontent.com/oven-sh/bun/main/examples/hashing.js",
),
});
const text = await new Response(proc.stdout).text();
@@ -181,6 +183,60 @@ const proc = Bun.spawn(["echo", "hello"]);
proc.unref();
```
## Inter-process communication (IPC)
Bun supports direct inter-process communication channel between two `bun` processes. To receive messages from a spawned Bun subprocess, specify an `ipc` handler.
{%callout%}
**Note** — This API is only compatible with other `bun` processes. Use `process.execPath` to get a path to the currently running `bun` executable.
{%/callout%}
```ts#parent.ts
const child = Bun.spawn(["bun", "child.ts"], {
ipc(message) {
/**
* The message received from the sub process
**/
},
});
```
The parent process can send messages to the subprocess using the `.send()` method on the returned `Subprocess` instance. A reference to the sending subprocess is also available as the second argument in the `ipc` handler.
```ts#parent.ts
const childProc = Bun.spawn(["bun", "child.ts"], {
ipc(message, childProc) {
/**
* The message received from the sub process
**/
childProc.send("Respond to child")
},
});
childProc.send("I am your father"); // The parent can send messages to the child as well
```
Meanwhile the child process can send messages to its parent using with `process.send()` and receive messages with `process.on("message")`. This is the same API used for `child_process.fork()` in Node.js.
```ts#child.ts
process.send("Hello from child as string");
process.send({ message: "Hello from child as object" });
process.on("message", (message) => {
// print message from parent
console.log(message);
});
```
All messages are serialized using the JSC `serialize` API, which allows for the same set of [transferrable types](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Transferable_objects) supported by `postMessage` and `structuredClone`, including strings, typed arrays, streams, and objects.
```ts#child.ts
// send a string
process.send("Hello from child as string");
// send an object
process.send({ message: "Hello from child as object" });
```
## Blocking API (`Bun.spawnSync()`)
Bun provides a synchronous equivalent of `Bun.spawn` called `Bun.spawnSync`. This is a blocking API that supports the same inputs and parameters as `Bun.spawn`. It returns a `SyncSubprocess` object, which differs from `Subprocess` in a few ways.
@@ -209,7 +265,7 @@ Bun's `spawnSync` spawns processes 60% faster than the Node.js `child_process` m
```bash
$ bun spawn.mjs
cpu: Apple M1 Max
runtime: bun 0.2.0 (arm64-darwin)
runtime: bun 1.x (arm64-darwin)
benchmark time (avg) (min … max) p75 p99 p995
--------------------------------------------------------- -----------------------------
@@ -230,10 +286,15 @@ A simple reference of the Spawn API and types are shown below. The real types ha
```ts
interface Bun {
spawn(command: string[], options?: SpawnOptions.OptionsObject): Subprocess;
spawnSync(command: string[], options?: SpawnOptions.OptionsObject): SyncSubprocess;
spawnSync(
command: string[],
options?: SpawnOptions.OptionsObject,
): SyncSubprocess;
spawn(options: { cmd: string[] } & SpawnOptions.OptionsObject): Subprocess;
spawnSync(options: { cmd: string[] } & SpawnOptions.OptionsObject): SyncSubprocess;
spawnSync(
options: { cmd: string[] } & SpawnOptions.OptionsObject,
): SyncSubprocess;
}
namespace SpawnOptions {
@@ -243,7 +304,12 @@ namespace SpawnOptions {
stdin?: SpawnOptions.Readable;
stdout?: SpawnOptions.Writable;
stderr?: SpawnOptions.Writable;
onExit?: (proc: Subprocess, exitCode: number | null, signalCode: string | null, error: Error | null) => void;
onExit?: (
proc: Subprocess,
exitCode: number | null,
signalCode: string | null,
error: Error | null,
) => void;
}
type Readable =

View File

@@ -57,6 +57,23 @@ import { Database } from "bun:sqlite";
const db = new Database("mydb.sqlite", { create: true });
```
### Load via ES module import
You can also use an import attribute to load a database.
```ts
import db from "./mydb.sqlite" with {"type": "sqlite"};
console.log(db.query("select * from users LIMIT 1").get());
```
This is equivalent to the following:
```ts
import { Database } from "bun:sqlite";
const db = new Database("./mydb.sqlite");
```
### `.close()`
To close a database:
@@ -99,6 +116,20 @@ const query = db.prepare("SELECT * FROM foo WHERE bar = ?");
{% /callout %}
## WAL mode
SQLite supports [write-ahead log mode](https://www.sqlite.org/wal.html) (WAL) which dramatically improves performance, especially in situations with many concurrent writes. It's broadly recommended to enable WAL mode for most typical applications.
To enable WAL mode, run this pragma query at the beginning of your application:
```ts
db.exec("PRAGMA journal_mode = WAL;");
```
{% details summary="What is WAL mode" %}
In WAL mode, writes to the database are written directly to a separate file called the "WAL file" (write-ahead log). This file will be later integrated into the main database file. Think of it as a buffer for pending writes. Refer to the [SQLite docs](https://www.sqlite.org/wal.html) for a more detailed overview.
{% /details %}
## Statements
A `Statement` is a _prepared query_, which means it's been parsed and compiled into an efficient binary form. It can be executed multiple times in a performant way.

View File

@@ -73,10 +73,11 @@ sink.end();
// ArrayBuffer(5) [ 104, 101, 108, 108, 111 ]
```
To instead retrieve the data as a `Uint8Array`, pass the `asUint8Array` option to the constructor.
To instead retrieve the data as a `Uint8Array`, pass the `asUint8Array` option to the `start` method.
```ts-diff
const sink = new Bun.ArrayBufferSink({
const sink = new Bun.ArrayBufferSink();
sink.start({
+ asUint8Array: true
});
@@ -103,7 +104,8 @@ sink.end();
Once `.end()` is called, no more data can be written to the `ArrayBufferSink`. However, in the context of buffering a stream, it's useful to continuously write data and periodically `.flush()` the contents (say, into a `WriteableStream`). To support this, pass `stream: true` to the constructor.
```ts
const sink = new Bun.ArrayBufferSink({
const sink = new Bun.ArrayBufferSink();
sink.start({
stream: true,
});
@@ -124,7 +126,8 @@ The `.flush()` method returns the buffered data as an `ArrayBuffer` (or `Uint8Ar
To manually set the size of the internal buffer in bytes, pass a value for `highWaterMark`:
```ts
const sink = new Bun.ArrayBufferSink({
const sink = new Bun.ArrayBufferSink();
sink.start({
highWaterMark: 1024 * 1024, // 1 MB
});
```

View File

@@ -76,12 +76,6 @@ Bun.listen({
});
```
{% callout %}
**Note** Earlier versions of Bun supported passing a file path as `keyFile` and `certFile`; this has been deprecated as of `v0.6.3`.
{% /callout %}
The `key` and `cert` fields expect the _contents_ of your TLS key and certificate. This can be a string, `BunFile`, `TypedArray`, or `Buffer`.
```ts
@@ -95,7 +89,7 @@ Bun.listen({
// string
key: fs.readFileSync("./key.pem", "utf8"),
// array of above
key: [Bun.file('./key1.pem'), Bun.file('./key2.pem')]
key: [Bun.file("./key1.pem"), Bun.file("./key2.pem")],
},
});
```
@@ -201,7 +195,10 @@ socket.write("hello");
To simplify this for now, consider using Bun's `ArrayBufferSink` with the `{stream: true}` option:
```ts
const sink = new ArrayBufferSink({ stream: true, highWaterMark: 1024 });
import { ArrayBufferSink } from "bun";
const sink = new ArrayBufferSink();
sink.start({ stream: true, highWaterMark: 1024 });
sink.write("h");
sink.write("e");
@@ -210,10 +207,11 @@ sink.write("l");
sink.write("o");
queueMicrotask(() => {
var data = sink.flush();
if (!socket.write(data)) {
const data = sink.flush();
const wrote = socket.write(data);
if (wrote < data.byteLength) {
// put it back in the sink if the socket is full
sink.write(data);
sink.write(data.subarray(wrote));
}
});
```

View File

@@ -50,7 +50,7 @@ export default jsx(
To override the default loader specified in the `new Bun.Transpiler()` constructor, pass a second argument to `.transformSync()`.
```ts
await transpiler.transform("<div>hi!</div>", "tsx");
transpiler.transformSync("<div>hi!</div>", "tsx");
```
{% details summary="Nitty gritty" %}
@@ -76,7 +76,7 @@ await transpiler.transform("<div>hi!</div>", "tsx");
```
{% details summary="Nitty gritty" %}
The `.tranform()` method runs the transpiler in Bun's worker threadpool, so if you run it 100 times, it will run it across `Math.floor($cpu_count * 0.8)` threads, without blocking the main JavaScript thread.
The `.transform()` method runs the transpiler in Bun's worker threadpool, so if you run it 100 times, it will run it across `Math.floor($cpu_count * 0.8)` threads, without blocking the main JavaScript thread.
If your code uses a macro, it will potentially spawn a new copy of Bun's JavaScript runtime environment in that new thread.
{% /details %}
@@ -160,7 +160,6 @@ export const name = "hello";
`;
const result = transpiler.scanImports(code);
`);
```
```json#Results

View File

@@ -43,7 +43,7 @@ This is analogous to the [`require.main = module` trick](https://stackoverflow.c
## `Bun.sleep()`
`Bun.sleep(ms: number)` (added in Bun v0.5.6)
`Bun.sleep(ms: number)`
Returns a `Promise` that resolves after the given number of milliseconds.
@@ -65,7 +65,7 @@ console.log("hello one second later!");
## `Bun.sleepSync()`
`Bun.sleepSync(ms: number)` (added in Bun v0.5.6)
`Bun.sleepSync(ms: number)`
A blocking synchronous version of `Bun.sleep`.
@@ -108,7 +108,7 @@ console.log(ls); // null
## `Bun.peek()`
`Bun.peek(prom: Promise)` (added in Bun v0.2.2)
`Bun.peek(prom: Promise)`
Reads a promise's result without `await` or `.then`, but only if the promise has already fulfilled or rejected.
@@ -183,7 +183,7 @@ const currentFile = import.meta.url;
Bun.openInEditor(currentFile);
```
You can override this via the `debug.editor` setting in your [`bunfig.toml`](/docs/runtime/configuration)
You can override this via the `debug.editor` setting in your [`bunfig.toml`](/docs/runtime/bunfig)
```toml-diff#bunfig.toml
+ [debug]
@@ -204,7 +204,7 @@ Bun.ArrayBufferSink;
## `Bun.deepEquals()`
Nestedly checks if two objects are equivalent. This is used internally by `expect().toEqual()` in `bun:test`.
Recursively checks if two objects are equivalent. This is used internally by `expect().toEqual()` in `bun:test`.
```ts
const foo = { a: 1, b: 2, c: { d: 3 } };
@@ -261,6 +261,24 @@ 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()`
```ts
Bun.stringWidth(input: string, options?: { countAnsiEscapeCodes?: boolean = false }): number
```
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.
```ts
Bun.stringWidth("hello"); // => 5
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)
<!-- ## `Bun.enableANSIColors()` -->
## `Bun.fileURLToPath()`
@@ -378,10 +396,10 @@ Decompresses a `Uint8Array` using zlib's GUNZIP algorithm.
```ts
const buf = Buffer.from("hello".repeat(100)); // Buffer extends Uint8Array
const compressed = Bun.gunzipSync(buf);
const compressed = Bun.gzipSync(buf);
const dec = new TextDecoder();
const uncompressed = Bun.inflateSync(compressed);
const uncompressed = Bun.gunzipSync(compressed);
dec.decode(uncompressed);
// => "hellohellohello..."
```
@@ -398,7 +416,7 @@ buf; // => Uint8Array(25)
compressed; // => Uint8Array(10)
```
The second argument supports the same set of configuration options as [`Bun.gzipSync`](#bun.gzipSync).
The second argument supports the same set of configuration options as [`Bun.gzipSync`](#bungzipsync).
## `Bun.inflateSync()`

View File

@@ -87,7 +87,7 @@ ws.send(new Uint8Array([1, 2, 3])); // TypedArray | DataView
### Headers
Once the upgrade succeeds, Bun will send a `101 Switching Protocols` response per the [spec](https://developer.mozilla.org/en-US/docs/Web/HTTP/Protocol_upgrade_mechanism). Additional `headers` can be attched to this `Response` in the call to `server.upgrade()`.
Once the upgrade succeeds, Bun will send a `101 Switching Protocols` response per the [spec](https://developer.mozilla.org/en-US/docs/Web/HTTP/Protocol_upgrade_mechanism). Additional `headers` can be attached to this `Response` in the call to `server.upgrade()`.
```ts
Bun.serve({
@@ -161,7 +161,7 @@ socket.addEventListener("message", event => {
### Pub/Sub
Bun's `ServerWebSocket` implementation implements a native publish-subscribe API for topic-based broadcasting. Individual sockets can `.subscribe()` to a topic (specified with a string identifier) and `.publish()` messages to all other subscribers to that topic. This topic-based broadcast API is similar to [MQTT](https://en.wikipedia.org/wiki/MQTT) and [Redis Pub/Sub](https://redis.io/topics/pubsub).
Bun's `ServerWebSocket` implementation implements a native publish-subscribe API for topic-based broadcasting. Individual sockets can `.subscribe()` to a topic (specified with a string identifier) and `.publish()` messages to all other subscribers to that topic (excluding itself). This topic-based broadcast API is similar to [MQTT](https://en.wikipedia.org/wiki/MQTT) and [Redis Pub/Sub](https://redis.io/topics/pubsub).
```ts
const server = Bun.serve<{ username: string }>({
@@ -182,17 +182,17 @@ const server = Bun.serve<{ username: string }>({
open(ws) {
const msg = `${ws.data.username} has entered the chat`;
ws.subscribe("the-group-chat");
ws.publish("the-group-chat", msg);
server.publish("the-group-chat", msg);
},
message(ws, message) {
// this is a group chat
// so the server re-broadcasts incoming message to everyone
ws.publish("the-group-chat", `${ws.data.username}: ${message}`);
server.publish("the-group-chat", `${ws.data.username}: ${message}`);
},
close(ws) {
const msg = `${ws.data.username} has left the chat`;
ws.unsubscribe("the-group-chat");
ws.publish("the-group-chat", msg);
server.publish("the-group-chat", msg);
},
},
});
@@ -200,7 +200,18 @@ const server = Bun.serve<{ username: string }>({
console.log(`Listening on ${server.hostname}:${server.port}`);
```
Calling `.publish(data)` will send the message to all subscribers of a topic _except_ the socket that called `.publish()`.
Calling `.publish(data)` will send the message to all subscribers of a topic _except_ the socket that called `.publish()`. To send a message to all subscribers of a topic, use the `.publish()` method on the `Server` instance.
```ts
const server = Bun.serve({
websocket: {
// ...
},
});
// listen for some external event
server.publish("the-group-chat", "Hello world");
```
### Compression
@@ -234,9 +245,37 @@ The `.send(message)` method of `ServerWebSocket` returns a `number` indicating t
This gives you better control over backpressure in your server.
### Timeouts and limits
By default, Bun will close a WebSocket connection if it is idle for 120 seconds. This can be configured with the `idleTimeout` parameter.
```ts
Bun.serve({
fetch(req, server) {}, // upgrade logic
websocket: {
idleTimeout: 60, // 60 seconds
// ...
},
});
```
Bun will also close a WebSocket connection if it receives a message that is larger than 16 MB. This can be configured with the `maxPayloadLength` parameter.
```ts
Bun.serve({
fetch(req, server) {}, // upgrade logic
websocket: {
maxPayloadLength: 1024 * 1024, // 1 MB
// ...
},
});
```
## Connect to a `Websocket` server
To connect to an external socket server, either from a browser or from Bun, create an instance of `WebSocket` with the constructor.
Bun implements the `WebSocket` class. To create a WebSocket client that connects to a `ws://` or `wss://` server, create an instance of `WebSocket`, as you would in the browser.
```ts
const socket = new WebSocket("ws://localhost:3000");
@@ -285,6 +324,14 @@ namespace Bun {
close?: (ws: ServerWebSocket) => void;
error?: (ws: ServerWebSocket, error: Error) => void;
drain?: (ws: ServerWebSocket) => void;
maxPayloadLength?: number; // default: 16 * 1024 * 1024 = 16 MB
idleTimeout?: number; // default: 120 (seconds)
backpressureLimit?: number; // default: 1024 * 1024 = 1 MB
closeOnBackpressureLimit?: boolean; // default: false
sendPings?: boolean; // default: true
publishToSelf?: boolean; // default: false
perMessageDeflate?:
| boolean
| {

View File

@@ -1,5 +1,5 @@
{% callout %}
`Worker` support was added in Bun v0.7.0.
**🚧** — The `Worker` API is still experimental and should not be considered ready for production.
{% /callout %}
[`Worker`](https://developer.mozilla.org/en-US/docs/Web/API/Worker) lets you start and communicate with a new JavaScript instance running on a separate thread while sharing I/O resources with the main thread.
@@ -10,7 +10,7 @@ Bun implements a minimal version of the [Web Workers API](https://developer.mozi
Like in browsers, [`Worker`](https://developer.mozilla.org/en-US/docs/Web/API/Worker) is a global. Use it to create a new worker thread.
From the main thread:
### From the main thread
```js#Main_thread
const workerURL = new URL("worker.ts", import.meta.url).href;
@@ -22,16 +22,25 @@ worker.onmessage = event => {
};
```
Worker thread:
### Worker thread
```ts#worker.ts_(Worker_thread)
// prevents TS errors
declare var self: Worker;
self.onmessage = (event: MessageEvent) => {
console.log(event.data);
postMessage("world");
};
```
You can use `import`/`export` syntax in your worker code. Unlike in browsers, there's no need to specify `{type: "module"}` to use ES Modules.
To prevent TypeScript errors when using `self`, add this line to the top of your worker file.
```ts
declare var self: Worker;
```
You can use `import` and `export` syntax in your worker code. Unlike in browsers, there's no need to specify `{type: "module"}` to use ES Modules.
To simplify error handling, the initial script to load is resolved at the time `new Worker(url)` is called.
@@ -123,14 +132,14 @@ By default, an active `Worker` will keep the main (spawning) process alive, so a
### `worker.unref()`
To stop a running worker from keeping the process alive, call `worker.unref()`. This decouples the lifetime of the worker to the lifetime of the main process, and is equivlent to what Node.js' `worker_threads` does.
To stop a running worker from keeping the process alive, call `worker.unref()`. This decouples the lifetime of the worker to the lifetime of the main process, and is equivalent to what Node.js' `worker_threads` does.
```ts
const worker = new Worker(new URL("worker.ts", import.meta.url).href);
worker.unref();
```
Note: `worker.unref()` is not available in browers.
Note: `worker.unref()` is not available in browsers.
### `worker.ref()`
@@ -151,7 +160,7 @@ const worker = new Worker(new URL("worker.ts", import.meta.url).href, {
});
```
Note: `worker.ref()` is not available in browers.
Note: `worker.ref()` is not available in browsers.
## Memory usage with `smol`

View File

@@ -52,7 +52,6 @@ Run this with `bun cat.js /path/to/big/file`.
## Reading from standard input
```ts
// As of Bun v0.3.0, console is an AsyncIterable
for await (const line of console) {
// line of text from stdin
console.log(line);

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