Compare commits

...

1679 Commits

Author SHA1 Message Date
Colin McDonnell
12cbb28cbf Back to any 2023-03-29 21:31:00 -07:00
Colin McDonnell
3a0894e305 Fix tests 2023-03-29 21:30:03 -07:00
Colin McDonnell
2939316f9c Fix type tests 2023-03-29 21:25:39 -07:00
Colin McDonnell
73d96cc7d9 ReadableStream defaults to Uint8array 2023-03-29 21:21:38 -07:00
Colin McDonnell
b0e0853360 Update vscode auto save mention 2023-03-29 17:27:13 -07:00
Colin McDonnell
f16995910a Update vscode auto save mention 2023-03-29 17:26:52 -07:00
Colin McDonnell
b2f3dbfd43 Typo 2023-03-29 17:12:06 -07:00
Niles Salter
9f07073074 Fix some lockfile creation issues (#2506) 2023-03-29 17:10:44 -07:00
Colin McDonnell
546f78a49e Update --watch docs 2023-03-29 17:02:16 -07:00
Jarred Sumner
767fdfbb97 Fixes #2499 (#2501)
* Fixes #2499

* This needs to be quoted

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-03-29 09:37:15 -03:00
Jarred Sumner
f0def8c770 Add doc on watch mode (#2502)
* Add doc on watch mode

* Update hot.md

* Update hot.md

* More words

* Update hot.md

* Update hot.md

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-03-28 23:26:43 -07:00
Jarred Sumner
786475ff58 bun --watch and bun test --watch (#2500)
* --watch wip

* Upgrade for latest zig

* Implement `bun --watch`

* Implement `bun test --watch`

* Auto restart on crash in --watch

* 🕐 🕑 🕒 🕞

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-03-28 21:28:35 -07:00
Jarred Sumner
b76384351c More bug fixes (#2486)
* readline_promises test fix

* fix `escapeHTML` for baseline builds

* fs test fixes, use `tmpdir()`

* add paths for `resolve.test.js`

* isError with toString symbol and error prototype

* comment about `toString`

* skip async macro transform

* test cleanup, skip stack format test

* readline undo and redo fix

* capture error from readline keypress

* Update tcp-server.test.ts

* use `removefileat` for recursive rmdir

* use strong for `signal.reason`

* initialize `m_flags`

* directory with file fs test

* recursive option

* import expect

* could be less than

* move abort signal tests to another process

* fix typecheck

---------

Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
2023-03-28 18:23:50 -07:00
Alex Lam S.L
0a91490226 [install] support tarball URLs (#2497)
closes #2448
2023-03-28 13:45:00 -07:00
Ashcon Partovi
93585291f9 Sign canary release before Docker release 2023-03-28 12:06:22 -07:00
Ashcon Partovi
de46ad23e5 Fix BUN_VERSION in bun-release 2023-03-28 12:03:25 -07:00
Ashcon Partovi
f455845a0a Fix BUN_VERSION in bun-release-canary 2023-03-28 12:01:06 -07:00
Andres Beltran
d5418052b1 Remove extra 's' on keep (#2498) 2023-03-28 09:37:46 -07:00
Jarred Sumner
cfceb26edd Fix for latest zig (#2495)
* Fix for latest zig

* Revert "Use PATH instead of sudo to install bun for testing (#2460)"

This reverts commit 5fd406ca2f.

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-03-27 18:22:13 -07:00
Ciro Spaciari
b2d90f07ba fix https default port on http.request (#2490)
* fix https default port on http.request

* Update http.exports.js
2023-03-26 22:45:52 -05:00
Alex Lam S.L
319efe9c7b [install] fix tests (#2488)
- avoid creating spurious directories next to test scripts
2023-03-25 21:51:03 -07:00
Jarred Sumner
52d27659a2 Fixes #2462 (#2463) 2023-03-23 15:49:42 +02:00
Derrick Farris
732c5e7fa9 test(undici): rm external http reqs from tests (#2459)
* test(undici): rm external http reqs from tests

* cleanup(http-test-server): remove finished TODOs

* test(undici): fix server type, remove type:module to fix typings in test dir

* test(undici): make the typings better

* test(undici): fix typo
2023-03-22 21:22:31 -07:00
Josh Soref
5fd406ca2f Use PATH instead of sudo to install bun for testing (#2460) 2023-03-22 21:21:57 -07:00
Dylan Conway
31c2fea74a A couple bug fixes (#2458)
* fix valid status code range

* update path

* highwatermark option

* throw DOMException

* remove extra transpiler output

* more transpiler tests

* comment

* get index not quickly

* replace with `getDirectIndex`

* update abort test

* throw out of range status code

* promisify test fix

* move stdio test instance files

* working crypto tests

* allow duplicate set-cookie headers

* different formatting

* revert, fix will be in different pr

* it is called

* use min buffer size

* fix url tests

* null origin for other protocols

* remove overload

* add very large file test

* await

* coerce to int64

* 64

* no cast

* add todo blob url tests

* use `tryConvertToInt52`
2023-03-22 18:09:51 -07:00
Colin McDonnell
a5f92224b5 Fix types (#2453)
* WIP

* WIP

* WIP

* WIP

* Improve typechecking in type files

* Fix typechecking

* Update

* Update submodule

* CI for typechecking

* Add ci

* Update commands

* Format after build

* Dont use bunx

* Rename job

* Use nodemodules prettier

* Update workflow

* Use symlink

* Debug

* Debug

* Clean up and rename jobs
2023-03-22 15:01:01 -07:00
Jarred Sumner
2bdaa81b1c Upgrade Mimalloc 2023-03-21 23:32:04 -07:00
Jarred Sumner
8b92469d42 Update build-id 2023-03-21 21:52:43 -07:00
Jarred Sumner
5915ab19fe Don't use function from bundler branch 2023-03-21 21:52:11 -07:00
Jarred Sumner
58a5c2a3aa Fix possible crash with export namespace ns { export class F {} } 2023-03-21 21:44:42 -07:00
Joker_
f3a91339fc Update sqlite.md (#2452)
Fix benchmark source pointing to wrong URL.
2023-03-21 18:51:31 -07:00
Igor Shevchenko
54b62aad05 Fix typo (#2446)
- fixed typo in the month name
2023-03-21 10:14:21 -07:00
Ján Gajdoš
15f23d70d6 docs: Buchta Docs Page (#2378)
* Idea: Buchta Docs Page

* Tweaks

---------

Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-03-20 21:32:20 -07:00
Colin McDonnell
42eff1d917 Add test-d files for eventemitter 2023-03-20 20:39:57 -07:00
Gaurish Sethia
02e5c5f795 Make event emitter type-safe (#2414)
* Add filePath property on MatchedRoute

* Fix #1880 #851

* Fix #1972 as well

* FMC

* Bump querystring-es3

* fix querystring status

* Fix typos in docs

* Make event-emitter by default type-safe

* Remove Makefile.save

* Resolve merge conflict

* Tweaks

---------

Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-03-20 20:32:28 -07:00
John Reilly
2503b3409e docs: update moduleResolution to bundler (#2429)
* docs: update moduleResolution to bundler

* docs: bundler as well

* Updates

---------

Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-03-20 19:51:24 -07:00
jq170727
6539f66642 "bun-create" example "postinstall"→"preinstall" (#2441)
"postinstall" is listed twice in the example for the "bun-create" section of package.json.
Based on the context and content of the echo commands I believe the intent is that the
first "postinstall" should be "preinstall".  This change corrects this.
2023-03-20 17:49:55 -07:00
Jackson Kearl
4dd4bab7b9 Support directories in ZSH run completions (#2425)
* Support scripts in dirs in zsh run completions

* add back wasm support
2023-03-20 11:27:39 -07:00
jq170727
035183eb12 Fix example for "bun pm ls" (#2440) 2023-03-20 11:26:22 -07:00
Jarred Sumner
aaef99ab68 Update install.md 2023-03-20 06:20:16 -07:00
Jarred Sumner
1a25af5e3d Implement simple workspaces glob support in bun install (#2435)
* [bun install] Implement `packages/*`-style globs

* Fix incorrect assertion

* 💅

* remove extraneous console.log

* Fix pointer to stack memory

* Add a test with a scoped package name from a glob workspace

* Fixup

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-03-20 05:57:23 -07:00
Jarred Sumner
343721627e Finish the upgrade 2023-03-19 23:03:08 -07:00
Dylan Conway
6e0e140f2f remove addLog, remove --prominent-compile-errors 2023-03-19 23:03:00 -07:00
Jarred Sumner
0edd8d262d Fix bug with scoped aliased dependencies in bun install on macOS 2023-03-19 20:58:27 -07:00
Ciro Spaciari
76622e41d6 remove unnecessary check (#2432) 2023-03-19 20:09:13 -07:00
Ciro Spaciari
7aa297012b add some extra abort checks into streams (#2430)
* add some checks to avoid UAF

* avoid multiple calls to finalize if endFromJS is called more than once

* fix no-op comment

* mark as requested_end on abort

* remove requested_end from abort
2023-03-19 19:42:45 -07:00
Jarred Sumner
9443cca1bb Reduce number of module scopes created 2023-03-19 19:09:16 -07:00
Jarred Sumner
a83c5c996f [bun test] Implement --rerun-each flag to run each test N times 2023-03-19 19:07:56 -07:00
Jarred Sumner
b053dffca7 Prevent undefined memory access 2023-03-19 19:06:52 -07:00
Jarred Sumner
cb1b881746 Remove -g 2023-03-19 18:11:38 -07:00
Jarred Sumner
9679cdb12c Set -O2 and -fno-rtti 2023-03-19 18:08:46 -07:00
Jarred Sumner
9ce18245d1 Remove usages of port numbers in tests 2023-03-19 16:51:13 -07:00
Jarred Sumner
5a23d17620 Several bug fixes (#2427)
* Fix test

* Fix segfault when unexpected type is passed in `expect().toThrow`

* Fix issues with request constructor

* Don't bother cloning headers when its empty

* woops

* more tests

* fix incorrect test

* Make the fetch error messages better

* Update response.zig

* Fix test that failed on macOS

* Fix test

* Remove extra hash table lookups

* Support running dummy registry directly

cc @alexlamsl

* Update test

* Update test

* fixup

* Workaround crash in test runner

* Fixup test

* Fixup test

* Update os.test.js

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-03-19 14:08:20 -07:00
Jarred Sumner
8f02ef8294 0 length body is a null stream 2023-03-18 18:03:05 -07:00
Jarred Sumner
e41e884747 Hanging abort test 2023-03-18 17:55:05 -07:00
Jarred Sumner
1b7423412a Make this test more thorough 2023-03-18 16:58:15 -07:00
Jarred Sumner
41c4a66e4a Update UWS
cc @cirospaciari
2023-03-18 16:58:04 -07:00
Jarred Sumner
7216bfe016 Fix out of bounds access
Repro'd in Buffer tests
2023-03-18 16:57:55 -07:00
Jarred Sumner
1c85e94977 Always clear timers in node test harness 2023-03-18 16:36:40 -07:00
Jarred Sumner
25097cd632 [node:net] Fix issue with listen callback firing before it's listening 2023-03-18 16:36:19 -07:00
Jarred Sumner
d9711c64eb Make node-net tests less flaky 2023-03-18 16:35:49 -07:00
Jarred Sumner
96fcecdcc9 [fetch] Make the default body value null when unspecified
This is better aligned with the fetch spec
2023-03-18 16:15:21 -07:00
Jarred Sumner
12c4ed89e3 Fix crash when rendering error page and the server or network is slow 2023-03-18 15:53:19 -07:00
Kamil Ogórek
f1cfa5dfeb docs: Use correct url in the 'Issues' link in README header (#2420) 2023-03-18 03:10:31 -07:00
Dylan Conway
dd9ebe9c50 💅 2023-03-18 00:57:38 -07:00
Dylan Conway
a9c41c67e6 Fix several bugs (#2418)
* utf16 codepoint with replacement character

* Fix test failure with `TextEncoder("ascii')`

* Add missing type

* Fix Response.prototype.bodyUsed and Request.prototype.bodyUsed

* Fix bug with scrypt error not clearing

* Update server.zig

* oopsie
2023-03-18 00:55:05 -07:00
Dylan Conway
1d4cc63154 Fix various fetch/response/request tests (#2416)
* fix most fetch tests, skip a few

* fastGet, toValueGC, and invalid init

* bigint unreachable, range error, log process as process

* remove extra fetch_headers

* remove js_type parameter, check isObject()

* throw invalid mime type error, use enum literal

* switch back to promise rejection

* RangeError pascal case
2023-03-17 17:14:39 -07:00
zhiyuan
c5f2b42649 Feat(test): add toMatch (#2404) 2023-03-17 03:49:41 -07:00
Ashcon Partovi
37293cb26a Remove old Docker workflow 2023-03-16 15:51:54 -07:00
Ashcon Partovi
57255ad565 Remove test Dockerfile 2023-03-16 15:50:28 -07:00
Ashcon Partovi
2dd99a37fd Organize Dockerfiles for official status 2023-03-16 15:49:41 -07:00
Dylan Conway
baf8787fa4 remove trailing comma 2023-03-15 22:06:28 -07:00
Dylan Conway
d5ef247b3b Fix socket tests with connection errors (#2403)
* release pending activity with connection error handler

* unref poll_ref
2023-03-15 22:01:58 -07:00
Jarred Sumner
b66df90b49 Rename expectObjectTypeCount to expectMaxObjectTypeCount 2023-03-15 22:00:53 -07:00
zhiyuan
0befd9ad85 feat(expect): update toBeInstanceOf (#2396)
* feat: update instanceof binding

* fix: according to PR comments
2023-03-15 20:04:55 -07:00
Jarred Sumner
79a05d50ad Make the test work in any timezone 2023-03-15 19:59:09 -07:00
Jarred Sumner
9a5f78fa3b Fixes #2399 2023-03-15 19:18:56 -07:00
Alex Lam S.L
47865fe82a fix gc-related flaky test failures (#2402) 2023-03-15 18:51:22 -07:00
Ashcon Partovi
480567a5af Remove nested tests from harness 2023-03-15 17:45:24 -07:00
Ashcon Partovi
976ef92473 Improve reliability of generated tests 2023-03-15 17:34:23 -07:00
Jarred Sumner
abd34abf08 some test matchers 2023-03-15 16:50:05 -07:00
Dylan Conway
1f811980c3 fix gc import from harness 2023-03-15 16:48:02 -07:00
Jarred Sumner
654ba5b671 Case sensitive 2023-03-15 16:47:40 -07:00
Jarred Sumner
babbfc6404 fix fixture 2023-03-15 16:47:08 -07:00
Jarred Sumner
86891a5d12 ✂️ 2023-03-15 16:43:32 -07:00
Jarred Sumner
9b321c3b06 Make this test more reliable 2023-03-15 16:41:23 -07:00
Jarred Sumner
cb5b08b22e Fix broken import path in test 2023-03-15 15:39:38 -07:00
Dylan Conway
a4741f6fe1 add tsconfig and update path (#2401) 2023-03-15 15:18:31 -07:00
Ciro Spaciari
ac970146b4 allows Bun.serve to listen on IPV6 (#2400) 2023-03-15 14:30:31 -07:00
Alex Lam S.L
acd361855a [install] sanitise against malformed bun.lockb (#2397)
* [install] sanitise against malformed `bun.lockb`

fixes #2392

* fix `prettier` checks in unrelated files
2023-03-15 08:49:52 -07:00
Dylan Conway
b6ec31ba4b don't delete bun-snapshots 2023-03-14 18:33:10 -07:00
Dylan Conway
62acc096f5 test added snapshots in new process 2023-03-14 18:09:36 -07:00
Jarred Sumner
7baaf2065a Update child_process-node.test.js 2023-03-14 18:07:58 -07:00
Dylan Conway
0f434f9457 generate jest snapshots manually 2023-03-14 17:33:32 -07:00
Jarred Sumner
d0522bb6a7 Condense snapshot output 2023-03-14 17:18:09 -07:00
Jarred Sumner
9b066ac6b1 Fix failing test 2023-03-14 17:17:43 -07:00
Dylan Conway
7fcbffa19a calculated class name after name prop 2023-03-14 17:03:52 -07:00
Ashcon Partovi
fc11894235 Skip some more irrelevant tests 2023-03-14 16:52:13 -07:00
Dylan Conway
4792abdb7f Implement toMatchSnapshot() (#2294)
* buggy snapshot

* error output for failed snapshot

* missing first

* hints

* open dir once, better cleanup

* update flag

* truncate on update

* object and class snapshot formatting

* array formatting

* no function name, single item is empty array

* string objects, maps, sets, promise

* avoid using invalid memory

* handle number objects

* handle extending `Number`

* boolean objects

* snapshot tests and test updates

* snapshot format for buffers

* safer snapshot parsing

* property matchers setup

* strings and tests

* generate classes with empty prototype

* optional `propertyMatchers` parameter

* new test folder structure

* strings.eqlLong

* globalObject.throwPretty() and expect.any tests

* add updateSnapshot flag to help

* move snapshot format out of `printErrorlikeObject`

* empty object snapshot format

* separate typed array, remove trailing comma

* use `isCell`, object trailing commas

* handle unicode

* todo for primitive constructors

* switch to `JSC.Node.Syscall.open` and `JSC.Maybe`

* use js parser for snapshot files

* deinit ast, log parse error

* copy/paste most of `exports.ZigConsoleClient`

* remove snapshot option

* remove ordered properties option

* remove snapshot format option from `exports.zig`

* remove extra newlines

* change mode

* update test runner output

* escape backticks faster

* `bunx jest` in temp dir

* remove buffered writer

* add `toMatchSnapshot` to types

* cleanup, switch to `pread`

* cli `--update` flag

* `--update-snapshots`

* remove string object format
2023-03-14 16:50:59 -07:00
Jarred Sumner
76b875e414 Update .prettierignore 2023-03-14 16:42:49 -07:00
Jarred Sumner
eb9e3e9aec Update harness.ts 2023-03-14 16:42:26 -07:00
Ashcon Partovi
851fd039da Ignore irrelevant tests in encoding.test.ts 2023-03-14 16:37:32 -07:00
Jarred Sumner
e1921ff8c5 Fix node test harness 2023-03-14 15:59:55 -07:00
Jarred Sumner
2b5139aa46 Add missing export 2023-03-14 15:58:00 -07:00
Ashcon Partovi
d1d2d842d5 Move tobeInstanceOf() tests to expect.test.ts 2023-03-14 12:19:24 -07:00
Ashcon Partovi
5d89efedec Add tests for AbortSignal, AbortController 2023-03-14 11:54:16 -07:00
Jarred Sumner
80f3bc64ed Fix incorrect test folder 2023-03-14 08:49:03 -07:00
Jarred Sumner
e613b501e2 Fix missing constants export in zlib 2023-03-14 08:49:03 -07:00
zhiyuan
6d50b90070 feat: add toBeInstanceOf matcher in expect (#2389) 2023-03-14 08:30:50 -07:00
Jarred Sumner
27f5012f50 Fix node:https being readonly 2023-03-14 08:16:53 -07:00
Josh Soref
ba994c52b8 Markdown (#2383)
* Fix test/README.md reference

* Apply markdown links
2023-03-14 08:13:47 -07:00
Jarred Sumner
4c38798142 Fix text formatting in .remoteAddress in ServerWebSocket and Socket
Fixes #2387
2023-03-14 07:44:54 -07:00
Ashcon Partovi
f63c26208a Better test coverage for Request and Response 2023-03-13 17:13:24 -07:00
Ciro Spaciari
ac9f8c0e93 feat(net.createServer) and adds socket.connect IPC support (#2337)
* added net.Server

* fix fmt

* fix cast and move test

* fix node-net.tests.ts but breaks server data receive

* fix end and close only emitting when data or pipe was added

* fix socket starting paused

* add echo test

* fix fmt

* fix fmt

* on close if the socket is paused, keep paused until the user resumes it to match node behavior

* resume on connect

* fix getConnections, error on close, make _Handler private and create symbols for SocketServerHandlers

* add path support (IPC)

* fix unix domains support, add connect unix tests

* fix unix socket tests

* emit listening and listening error on next tick

* fix connection flask test

* try fix connect error on macos test

* merge connection and drop tests

* added exclusive option

* fix socket.zig fmt

* fix validation for options and add test for it

* pass prettier fmt
2023-03-13 16:42:35 -07:00
Miles Johnson
8d320d1373 Add install with proto examples. (#2361) 2023-03-13 13:47:57 -07:00
dave caruso
21f9fc828f fix require.resolve with an empty options object #2370 (#2371)
* fix #2370 and import-meta test

* edit test to not allow transpiler optimization
2023-03-12 03:43:32 -07:00
Nicholas
8c91278a00 Update comparison matchers compatibility in docs (#2366) 2023-03-11 08:33:46 -08:00
Haris Sulaiman
d61e90d558 Update file-system-router.md (#2365) 2023-03-11 01:28:33 -08:00
noahmarro
a4fdc1e0d5 removed JSON trailing comma (#2364) 2023-03-11 00:13:00 -08:00
Fran Zekan
cc7d2cf343 Fix link in globals.md (#2362) 2023-03-10 16:47:33 -08:00
Ashcon Partovi
d7e067902f Add more tests for Headers 2023-03-09 12:34:11 -08:00
Ashcon Partovi
c5e76f8bfe Remove websocket test because it's not substantial 2023-03-08 15:37:42 -08:00
Ashcon Partovi
ebb42bb67b Add so many more tests, it's not even funny 2023-03-08 15:36:16 -08:00
Derrick Farris
42edcaae8c fix(node:child_process): fix missing primordial StringPrototypeSlice (#2352) 2023-03-08 14:04:21 -08:00
Ashcon Partovi
ab02ab25b1 Improve test harness 2023-03-08 11:38:09 -08:00
buu
deb7a2b192 docs(react): add the missing props.message to <Component /> (#2347) 2023-03-08 08:16:06 -08:00
Jarred Sumner
0fd9b2421e Fix bug in test runner 2023-03-08 00:18:52 -08:00
Jarred Sumner
f22336b5b5 More spec compliant Blob.prototype.type (#2340)
* Make `Blob.prototype. type` more spec compliant

* Add a few more checks for isNumber()

* Fix `make headers`

* Safer JSValue.isString()

* More tests for blob.slice

* Make `Blob.prototype.type` more spec compliant

* Add isASCII check

* Fix types

* Fix failing type test

* Update blob.zig

* Update blob.zig

* Fix .eql check on empty values

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-03-08 00:18:14 -08:00
Jarred Sumner
e16053c39e "binary" is an alias of "latin1"
Fixes https://github.com/oven-sh/bun/issues/2110
2023-03-07 22:59:29 -08:00
Alex Lam S.L
e389b6ef19 run bun test after macOS builds (#2343) 2023-03-07 22:30:53 -08:00
Alex Lam S.L
28346e4a39 improve Buffer compatibility with Node.js (#2341)
* improve `Buffer` compatibility with Node.js

* use `memmove()`
allow `encoding` to be `undefined`
2023-03-07 22:29:29 -08:00
Colin McDonnell
95b59ea0ef Document openInEditor 2023-03-07 21:05:44 -08:00
Jarred Sumner
24e90726fd run prettier 2023-03-07 18:44:12 -08:00
Colin McDonnell
cac4012a7e Fix links 2023-03-07 18:43:15 -08:00
Colin McDonnell
6505e5c3a4 Fix typo 2023-03-07 18:07:53 -08:00
Colin McDonnell
9bf4d9b8a2 Improve Benchmarking page, small fixes (#2339)
* Improve benchmarking page

* WIP

* Add typescript instructions to hot

* Document preload in Plugins. Fix loader in plugin types.
2023-03-07 17:44:05 -08:00
Ashcon Partovi
1d2b0bbc98 Add more test harness 2023-03-07 17:02:43 -08:00
pfg
45ddf321b1 fix the wrong thing being incremented in hmr example (#2334) 2023-03-07 13:11:54 -08:00
Ashcon Partovi
e84ff1d8b7 Fix html-rewriter.test.js 2023-03-07 12:28:16 -08:00
Ashcon Partovi
f7e4eb8369 Reorganize tests (#2332) 2023-03-07 12:22:34 -08:00
Ashcon Partovi
36275a44ce Add reference documentation for bun:test (#2327) 2023-03-06 22:50:11 -08:00
Dylan Conway
68e58605b6 throw invalid parameter errors in crypto.scryptSync (#2331)
* throw invalid parameter errors

* remove comptime, add empty buffer function

* remove error_name comptime
2023-03-06 20:00:50 -08:00
Jarred Sumner
0a9cb0e13a Fixes #2323 2023-03-06 19:22:52 -08:00
Alex Lam S.L
b211fb1298 bun test on macOS in GitHub Actions (#2322) 2023-03-06 15:22:42 -08:00
Ashcon Partovi
7f715e15cc Fix docker install command 2023-03-06 14:05:43 -08:00
Derrick Farris
a512bdad8d feat(tty): add some tty.WriteStream methods to process.{stdout, stderr} (#2320)
* feat(stdio): add some `tty.WriteStream` methods

* chore(builtins): add process builtin gen'd code
2023-03-06 13:09:52 -08:00
Alex Lam S.L
3e1d368a27 fix & clean up tests (#2318)
- skip flaky tests when running as `root`
- use `expect().toThrow()`
- clean up temporary files after tests
2023-03-06 12:09:44 -08:00
Alex Lam S.L
993fed51c1 fix missing Blob error messages on Linux (#2315) 2023-03-05 22:45:27 -08:00
Alex Lam S.L
d4bd156d9d support expect().toThrow(/pattern/) (#2314)
- fix time-zone-dependent test failure
2023-03-06 03:33:38 +02:00
Alex Lam S.L
c7bfb3aa3a consider current working directory when resolving relative paths (#2313)
* consider current working directory when resolving relative paths

fixes #2298

* comment test

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-03-05 08:54:00 -08:00
Jarred Sumner
7273713158 Update out of date doc 2023-03-05 08:31:56 -08:00
Alex Lam S.L
67422785cc [install] fix connection error detection (#2307) 2023-03-05 08:09:17 -08:00
Jarred Sumner
42f6b35a5b Test action comment (#2310)
* test

* Update bun-linux-build.yml

* fixup

* Update bun-linux-build.yml

* Use outputs

* set id

* Update bun-linux-build.yml

* Update runner.node.mjs

* Update runner.node.mjs

* wip (will revert)

* Update runner.node.mjs

* Update runner.node.mjs

* Update runner.node.mjs

* Update runner.node.mjs

* Update bun-linux-build.yml

* Update bun-linux-build.yml

* works well enough for now

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-03-05 00:21:00 -08:00
Jarred Sumner
665486dab8 Run tests 2023-03-04 19:22:20 -08:00
Jarred Sumner
a7cdd49244 Artifact version 2023-03-04 19:01:42 -08:00
Jarred Sumner
0b4e7179b5 dump failing tests to disk 2023-03-04 18:58:10 -08:00
Jarred Sumner
c34b92d16b Update runner.node.mjs 2023-03-04 18:39:40 -08:00
Jarred Sumner
339b811b48 Update runner.node.mjs 2023-03-04 18:36:14 -08:00
Jarred Sumner
adf8bae23c Update runner.node.mjs 2023-03-04 18:32:27 -08:00
Jarred Sumner
03997086ea Update runner.node.mjs 2023-03-04 18:22:48 -08:00
Jarred Sumner
cbfe17d95a Update runner.node.mjs 2023-03-04 18:18:15 -08:00
Jarred Sumner
f915abf3be Update run-test-manually.yml 2023-03-04 18:15:35 -08:00
Jarred Sumner
c6b0e45a52 Update run-test-manually.yml 2023-03-04 18:14:25 -08:00
Jarred Sumner
571ba8ef3f Add node runner 2023-03-04 18:11:54 -08:00
Jarred Sumner
9963e1c3d8 Update runner.ts 2023-03-04 17:52:13 -08:00
Jarred Sumner
9e2f6ef1be chdir 2023-03-04 17:45:50 -08:00
Jarred Sumner
1843a37ebb oops 2023-03-04 17:38:44 -08:00
Jarred Sumner
f333a0c243 Update run-test-manually.yml 2023-03-04 17:35:18 -08:00
Jarred Sumner
ffdc8a19d1 fixup 2023-03-04 17:31:59 -08:00
Jarred Sumner
c1c8d6356f Update run-test-manually.yml 2023-03-04 17:26:24 -08:00
Jarred Sumner
7a8a887d4b Update run-test-manually.yml 2023-03-04 17:25:42 -08:00
Jarred Sumner
5ca4778746 Update run-test-manually.yml 2023-03-04 17:24:41 -08:00
Jarred Sumner
28b80e6433 Update run-test-manually.yml 2023-03-04 17:23:09 -08:00
Jarred Sumner
dcc46b2862 Rename packages/bun-test to packages/bun-internal-test 2023-03-04 17:21:25 -08:00
Jarred Sumner
e4bd4d134d Update run-test-manually.yml 2023-03-04 17:18:39 -08:00
Jarred Sumner
cfa21dc9d0 Update run-test-manually.yml 2023-03-04 17:18:15 -08:00
Jarred Sumner
7dde3d4974 Update run-test-manually.yml 2023-03-04 17:17:18 -08:00
Jarred Sumner
5c6cbb0283 Update run-test-manually.yml 2023-03-04 17:16:30 -08:00
Jarred Sumner
6a1667a5f4 Add a manual test running action 2023-03-04 17:15:54 -08:00
Jarred Sumner
d77bd35556 Delete broken CI action 2023-03-04 17:01:36 -08:00
aab
ddb6624ad1 docs: Fix invalid default port on bun-types docs (#2300) 2023-03-04 06:01:39 -08:00
aab
0eeac32ef4 docs(websocket): change server port on example to default port (#2301)
Current example will fail without explicitly configure the server to use port 8080. Hence, replacing it with default port (3000).
2023-03-04 06:01:04 -08:00
Alex Lam S.L
31447fdc19 [install] use latest tagged version if in range (#2302) 2023-03-04 06:00:38 -08:00
Fran Zekan
8e1d2a5af9 fix(bunx): can't resolve executable for scoped packages (#2293)
Fixes #2292
2023-03-04 14:56:25 +02:00
Derrick Farris
3626845051 fix(node:http): match Node headers casing (lowercase only) (#2288)
* fix(node:http): match Node headers casing (lowercase only)

* fix(JSFetchHeaders): `WTFMove` the ascii string
2023-03-03 21:08:26 -08:00
Jarred Sumner
d8d23f2594 Update Dockerfile 2023-03-03 19:03:47 -08:00
Jarred Sumner
122e6a8860 Update bindings.zig 2023-03-03 18:59:20 -08:00
Jarred Sumner
9f132ea241 BigInt64Array and BigUint64Array are typed arrays too
Fixes #2296
2023-03-03 18:51:52 -08:00
Fran Zekan
7c367ff687 fix(bunx): Show usage when calling bunx without arguments (#2295)
* Make sure to return a helpful error message if no args are passed to bunx

* Add tests for bunx without args
2023-03-03 17:49:32 -08:00
Colin McDonnell
0f8f484e21 Improve types for node:http (#2284)
* Document node:http

* Fix test

* Fix default

* Fix default
2023-03-03 14:24:12 -08:00
Hannes Käufler
7e5dddd2fa Fix broken async test example (#2291) 2023-03-03 12:41:36 -08:00
Jarred Sumner
838b37eed0 Update react-dom-render.bun.js 2023-03-03 04:45:33 -08:00
Jarred Sumner
1f10e25bd9 react-dom/server@next 2023-03-03 04:26:30 -08:00
zhiyuan
18178b4e48 Fix http server req url (#2285)
* fix: http url add search query

* fix: add tests
2023-03-03 02:45:34 -08:00
aab
3456831b82 docs: Fix variable name in transpiler API docs (#2281) 2023-03-02 21:49:12 -08:00
zhiyuan
6a1701fedd Fix update zls version in devcontainer (#2280)
* fix: update zls version for new zig

* fix: rm outdated vscode extension

---------

Co-authored-by: Zhiyuan Guo <zhiyuan.guo@shopee.com>
2023-03-02 19:53:37 -08:00
Jarred Sumner
3318ccfb4a Update Makefile 2023-03-02 19:11:41 -08:00
Jarred Sumner
9388b3f825 Add a zig fmt action (#2277)
* Add a zig fmt action

* add failing file

* Setup prettier better

* Update prettier-fmt.yml

* Fail on error

* Update prettier-fmt.yml

* boop

* boop2

* tar.gz

* Update zig-fmt.yml

* Update zig-fmt.yml

* Update zig-fmt.yml

* Update zig-fmt.yml

* Update zig-fmt.yml

* boop

* Update prettier-fmt.yml

* tag

* newlines

* multiline

* fixup

* Update zig-fmt.yml

* update it

* fixup

* both

* w

* Update prettier-fmt.yml

* prettier all the things

* Update package.json

* zig fmt

*  

* bump

* .

* quotes

* fix prettier ignore

* once more

* Update prettier-fmt.yml

* Update fallback.ts

* consistentcy

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-03-02 19:02:10 -08:00
Colin McDonnell
b469e50351 Add fs/promises tests and migrate fs.test.js to TypeScript (#2279) 2023-03-02 17:36:47 -08:00
Ciro Spaciari
27c3579118 fix(os.tmpdir()) strip trailing slash on *unix machines (#2276)
* fix(os.tmpdir()) strip trailing slash on *unix machines

* make use of strings.withoutTrailingSlash(dir);
2023-03-02 17:33:25 -08:00
Colin McDonnell
3852a52601 Add separate bun-types release CI (#2275)
* Release on every commit

* Remove bun-types publish from bun-release-canary

* Undo formatting changes
2023-03-02 15:34:36 -08:00
Jarred Sumner
1ba007831d Ensure prettier knows where to look 2023-03-02 15:12:00 -08:00
Alex Lam S.L
c0a49e405e add tests for scoped dependency aliasing (#2271) 2023-03-02 13:30:20 -08:00
Ciro Spaciari
78762e8305 fix tmp dir in fetch.tests.js (#2270) 2023-03-02 12:54:59 -08:00
u9g
57fcf8f9ba Remake typings for FFI dlopen/linkSymbols + introduce Pointer type (#2227)
* Give dlopen & linkSymbols typings for exported functions

* Fix lookup table

* Fully change over to Pointer + fix examples

* add back header for typings

* Fix tsc errors

* Run formatter on ffi.d.ts

* Revert args/return type change

* Add type tests for ffi

---------

Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-03-02 12:24:43 -08:00
Ciro Spaciari
c81043bf5e put AbortSignal in WebCore namespace (#2267) 2023-03-02 11:49:32 -08:00
Ciro Spaciari
156c1d4bec only free sink after promises solves (#2268) 2023-03-02 11:48:11 -08:00
Justin Whear
20930849ce Fix Bun.sleepSync to actually use milliseconds (#2242)
* Fix Bun.sleep/sleepSync to actually use milliseconds

`Bun.sleepSync` was accidentally treating its argument as seconds rather than milliseconds as the docs stated.  This is a breaking change in that the function now behaves as documented.  Fixed relevant tests.

* sleepSync: add more argument checking, tests
2023-03-02 09:00:20 -08:00
Derrick Farris
efdf647460 fix(bindings): mark JSCInitialize (#2265) 2023-03-01 22:41:20 -08:00
Colin McDonnell
167de9091a Add page descriptions (#2260)
* Add page descriptions

* Update bun install

* Description tweaks

* Tweaks
2023-03-01 21:45:49 -08:00
Ciro Spaciari
1be834b073 fix bun server segfault with abortsignal (#2261)
* removed redundant tests, fixed server segfault

* fix onRejectStream, safer unassign signal

* fix abort Bun.serve signal.addEventListener on async

* move ctx.signal null check up

* keep original behavior of streams onAborted
2023-03-01 21:40:11 -08:00
Derrick Farris
b9137dbdc8 fix(node:http): match Node http.request() GET/HEAD w/ body (#2262) 2023-03-01 21:28:21 -08:00
Jarred Sumner
706a3e8169 Add a test for https request in node:http 2023-03-01 19:31:16 -08:00
Derrick Farris
7c81d97684 fix(node:http/https): fix passing URL objs to http.request(#2253) (#2258)
* fix(node:http/https): fix passing `URL` objs to `http.request`(#2253)

* fix(node:http): hoist debug env var

* fix(node:http): make body `undefined` when falsy
2023-03-01 18:11:38 -08:00
Jarred Sumner
6bc075e377 Revert "Update clap (#2238)"
This reverts commit 7b9a17f9d7.
2023-03-01 16:17:47 -08:00
Jarred Sumner
ba0706939d Revert "Add -D, --dev flags for bun install (#2240)"
This reverts commit ec20fae57f.
2023-03-01 16:15:55 -08:00
Ashcon Partovi
6e512eda0d Use GitHub action ID instead of SHA for test workflow 2023-03-01 16:07:27 -08:00
Ciro Spaciari
1227a7b995 avoids segfault after aborted onReject in Bun.serve streams (#2256)
* avoids segfault after aborted on reject

* silence err on handleRejectStream after aborted
2023-03-01 15:47:04 -08:00
Ashcon Partovi
ef56961007 Run tests in CI for bun-linux-aarch64 2023-03-01 14:31:56 -08:00
Jarred Sumner
ff51a253e2 Revert spawnSync change
cc @FireTheFox
2023-03-01 14:12:59 -08:00
Jarred Sumner
ee6f54180a Update bindings.zig 2023-03-01 14:12:59 -08:00
Ciro Spaciari
cf8568ccff fix deinit behavior when connection is aborted using ResponseStream and abort event behavior (#2252)
* fix deinit behavior when connection is aborted using ResponseStream

* fix abort handling on stream, and get better tests

* avoid segfault by trying to deinit 2x when aborted

* make tests more reliable

* more reliable onResolveStream after aborted

* add test case for not firing the abort signal
2023-03-01 13:15:52 -08:00
Ciro Spaciari
56ca48ece8 fix Bun.file.arrayBuffer() segmentation fault on empty file #2248 (#2249)
* fix Bun.file.arrayBuffer() segmentation fault on empty file #2248

* cleanner this.iotask check
2023-03-01 13:07:21 -08:00
Colin McDonnell
530cf4caf8 Fix async in sqlite 2023-03-01 12:27:14 -08:00
Justin Whear
9a7333dd5e Forces a specific libdir for c-ares (#2241)
The c-ares build expects lib/libcares.a to exist after cmake, but on my system it was being generated in lib64.  This simply sets the cmake variable so that the target ends up where we expect.
2023-02-28 23:35:04 -08:00
Jarred Sumner
88b5cda109 Make Bun.gc(true) more aggressive 2023-02-28 21:56:28 -08:00
Jarred Sumner
45704a55dc Expose JSC::Options via BUN_JSC_ prefix
Example usage:

BUN_JSC_logGC=1 bun file.js
2023-02-28 21:56:28 -08:00
Jarred Sumner
714b8d10e0 fixup 2023-02-28 21:56:28 -08:00
Colin McDonnell
931f23d360 Fix typecheck 2023-02-28 19:47:46 -08:00
Derrick Farris
1da8045ce4 Fix incorrect Bun version in docs (#2236) 2023-02-28 17:55:18 -08:00
Ciro Spaciari
e512be8c18 just some comments fix (#2237) 2023-02-28 16:56:12 -08:00
Justin Whear
ec20fae57f Add -D, --dev flags for bun install (#2240)
* remove vendored clap

* Update to latest zig-clap

Major changes:
* Instead of vendoring zig-clap and adding changes, this uses Hejsil/zig-clap directly as a submodule
* `cli.zig` and related files have been updated to use new API (no more `flag()` or `option()`)
* A workaround for the Run and Auto commands has been implemented that allows us to use the official upstream

Minor change:
* `-i` now has the long option `--install-fallback`; I didn't spend much time thinking about this name, so suggestions weclome.

* add --development and --optional to bun install

* Add support for `-D`, `--dev` in bun install, fix `--save`
2023-02-28 16:39:06 -08:00
Colin McDonnell
fd19d01583 Document punning 2023-02-28 16:10:51 -08:00
Colin McDonnell
1826abbc65 Add deploy hook workflow 2023-02-28 15:52:15 -08:00
Justin Whear
7b9a17f9d7 Update clap (#2238)
* remove vendored clap

* Update to latest zig-clap

Major changes:
* Instead of vendoring zig-clap and adding changes, this uses Hejsil/zig-clap directly as a submodule
* `cli.zig` and related files have been updated to use new API (no more `flag()` or `option()`)
* A workaround for the Run and Auto commands has been implemented that allows us to use the official upstream

Minor change:
* `-i` now has the long option `--install-fallback`; I didn't spend much time thinking about this name, so suggestions weclome.

* deinit jsBundleArgs
2023-02-28 13:49:05 -08:00
Jarred Sumner
bd91aa8c25 Don't tick the event loop in spawnSync 2023-02-28 00:12:32 -08:00
Jarred Sumner
31389b4906 Make response.body null only when user explicitly passes null/undefined 2023-02-28 00:12:32 -08:00
Jarred Sumner
d93d1013a6 Add back the tests 2023-02-28 00:12:32 -08:00
Jarred Sumner
12d6db0cad Add explicit Null tag to Body
This reverts commit e538bb31ad.
2023-02-28 00:12:32 -08:00
Jarred Sumner
ec7929b251 Implement preload support (like node -r except in a config file) (#2231)
* Update Makefile

* Introduce `preload`

* Add a test

* Support entry points

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-02-28 00:01:21 -08:00
maor-benami
590219966e Update file-io.md (#2230)
should `notreal.type` reflect the overridden value?
2023-02-27 21:08:27 -08:00
maor-benami
0a340d1920 Update file-io.md (#2229)
duplicated word
2023-02-27 21:07:35 -08:00
Jarred Sumner
56488d54d0 Add some more functions to sha bench 2023-02-27 18:30:42 -08:00
Derrick Farris
ae35f17a99 fix(bun:sqlite): fix sqliteDb.run(' ') throwing not an error (#2226) 2023-02-27 18:29:00 -08:00
Ciro Spaciari
062b5565a7 use abort signal on http.ClientRequest (#2222)
* use abort signal on http.ClientRequest

* fix edge case and add test
2023-02-27 20:28:42 -06:00
Ciro Spaciari
4b62745754 add signal on http.Server.listen (#2223)
* add signal on http.Server.listen

* actual call close instead of just stopping the server
2023-02-27 16:24:59 -08:00
Ciro Spaciari
0afb1693d3 fix(fetch.signal) capture socket and shutdown on abort signal (#2143)
* capture socket and shutdown on abort signal

* queue shutdown tasks

* little cleanup

* change shutdown strategy

* use fetchSwapRemove on fetch shutdown

* use fetchSwapRemove on fetch shutdown

* fix formatting, remove unused property
2023-02-27 16:10:03 -08:00
Gaurish Sethia
7a4ac03338 Update module statuses in docs (#2219)
* Add filePath property on MatchedRoute

* Fix #1880 #851

* Fix #1972 as well

* FMC

* Bump querystring-es3

* fix querystring status

* Fix typos in docs

---------

Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-02-27 16:08:01 -08:00
Tamas Sule
630d2314b6 Bundler uses incorrect port when dev server is listening on non-default port #1885 (#2191) 2023-02-27 16:06:28 -08:00
Justin Whear
18cce50390 Feat/os.network interfaces (#2142) 2023-02-27 09:58:45 -08:00
Alex Lam S.L
c8be1e9a5d resolve duplicated dependency correctly (#2213) 2023-02-27 09:36:17 -08:00
Rodo Abad
f420e81e85 docs(configuration): update misleading comment (#2205)
The comment was for peer dependencies and not dev dependencies.
2023-02-26 16:37:32 -08:00
Jarred Sumner
5d296f6228 Don't parse shasum twice 2023-02-26 14:53:32 -08:00
Alex Lam S.L
16898a23e6 fix ANSI escape codes piped from stdout to file (#2202) 2023-02-26 12:14:51 -08:00
Jarred Sumner
a55ca48797 Update emitter.mjs 2023-02-26 00:51:42 -08:00
Jarred Sumner
94abc87d6e Add callback to bench 2023-02-26 00:51:42 -08:00
cunzaizhuyi
f89c4c3a0d Update hot.md (#2198) 2023-02-26 00:23:58 -08:00
Jarred Sumner
451ccfd5ef Update bun.zig 2023-02-25 19:06:11 -08:00
Jarred Sumner
2dd484c180 Add more assertions 2023-02-25 18:48:59 -08:00
Jarred Sumner
58685638e2 Use libc memmove 2023-02-25 18:41:37 -08:00
Jarred Sumner
693be3d1c2 Faster eqlCaseInsensitiveASCII 2023-02-25 18:23:01 -08:00
Jarred Sumner
8ba65a4f0b Fixes #2194 (most likely) 2023-02-25 18:23:01 -08:00
Derrick Farris
4149b95543 Update node:http compatibility (#2184) 2023-02-25 16:37:39 -08:00
Alex Lam S.L
38314c02f2 improve bun pm ls (#2192) 2023-02-25 16:37:04 -08:00
Jarred Sumner
f58728ccc7 Call BoringSSL.load() in more places 2023-02-25 15:15:10 -08:00
Jarred Sumner
eb94e5b990 Use mimalloc heap for BoringSSL 2023-02-25 15:01:52 -08:00
Ryan Morey
d4dfb79b72 Fix broken link in developing.md (#2188)
* Fix broken link in developing.md

* Update developing.md
2023-02-25 12:25:16 -06:00
Florian Dreier
45f4353453 fix: Broken link to Node.js support status page (#2183)
Co-authored-by: Derrick Farris <mr.dcfarris@gmail.com>
2023-02-25 10:57:26 -06:00
Charlie Marsh
735d48190d Replace docs/runtime/nodejs with docs/ecosystem/nodejs (#2185)
* Replace docs/runtime/nodejs with docs/ecosystem/nodejs

* Replace a few more usages
2023-02-25 10:54:29 -06:00
Raxit Majithiya
a819e3b723 docs: Fix the link to Node.js ecosystem (#2181) 2023-02-25 09:49:44 -06:00
Tommaso A
8e09b1afff docs: improved language in yaml loader example (#2172)
* docs: improved language in yaml loader example

* docs(api/http): fix typo

* docs(api/spawn): fix typo

* docs(api/transpiler): fix typo
2023-02-25 09:47:11 -06:00
Akash Joshi
cf7a09c0d3 Update index.md (#2182) 2023-02-25 09:45:26 -06:00
Fernando Daciuk
0d5d3e5dfc docs: fix typo in install.md file (#2179) 2023-02-25 04:33:21 -08:00
Jarred Sumner
a931e21f49 make emitter bench work in node 2023-02-25 04:28:23 -08:00
Jarred Sumner
8f67cf75ee Bump WebKit 2023-02-25 04:28:04 -08:00
Jarred Sumner
0a7309c8f2 slight performance improvement to EventEmitter 2023-02-25 03:34:41 -08:00
Jarred Sumner
e6f33d9a52 make the test faster 2023-02-25 03:34:41 -08:00
John Reilly
e38cb9aa6a docs: consistent indentation for post install commands (#2175) 2023-02-25 02:45:48 -08:00
Flo
9b66e03a9b Fix sqlite.md .serialize typo (#2178) 2023-02-25 02:45:27 -08:00
Damian Stasik
31627530b9 docs: use proper CSS property in React examples (#2177) 2023-02-25 02:45:12 -08:00
Brett Bloxom
ae62825319 Docs: Fixes broken link in express docs (#2173)
Fixes broken internal link to nodejs compatability information.
2023-02-25 02:44:58 -08:00
Derrick Farris
1e6faa3815 Update hono.md (#2171) 2023-02-25 02:44:03 -08:00
Dylan Conway
40ebc994f9 remove parameters 2023-02-24 19:12:04 -08:00
Colin McDonnell
1e1b45b4d9 Tweak readme 2023-02-24 18:55:11 -08:00
Colin McDonnell
39fa458895 Fix indents 2023-02-24 18:50:48 -08:00
Colin McDonnell
a6a0ccf6f0 Rearrange ecosystem 2023-02-24 18:03:52 -08:00
Colin McDonnell
0ecd773081 Docs (#2170)
* Add hono and elysia

* Update elysia and add coming soon

* Fix typo

* Add back awesome
2023-02-24 17:48:49 -08:00
Colin McDonnell
c72c2c2338 Fixes (#2168) 2023-02-24 16:40:08 -08:00
Colin McDonnell
1836250542 Docs tweaks (#2160)
* Tweaks

* Add ecosystem. Add bunx. Flesh out install.

* Tweaks

* Add TS to installation

* Tweaks

* New readme

* Write new readme

* Tweak

* Center header

* Bun

* tweaks

* No dollar sign

* Fix links

* Update

* Tweak
2023-02-24 16:33:53 -08:00
Dylan Conway
1d85b5efa8 wiptest -> test 2023-02-24 16:32:04 -08:00
Charlie Marsh
7455f385ec Add missing "that" in modules.md (#2167) 2023-02-24 15:47:04 -08:00
Derrick Farris
4c4da4aae2 fix(zig-build): disable stack probing when building other objs too (#2165) 2023-02-24 15:37:45 -08:00
Charlie Marsh
3264ca991e Fix typo in developing.md (#2166)
* Fix typo in `developing.md`

* Apply suggestions from code review

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

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-02-24 15:36:12 -08:00
Jarred Sumner
599f63c204 Support macOS 10.15
Fixes #1266
Fixes #1323
Fixes #2154
2023-02-24 15:07:27 -08:00
Alex Lam S.L
26df7ca892 fix compiler_rt linking failure on x86_64 (#2163)
- minor code tweaks
2023-02-24 14:51:20 -08:00
Ciro Spaciari
d33a53deb0 fix(dns) Fix resolve4 and resolve6 behavior (#2144)
* fix https://github.com/oven-sh/bun/issues/2098

* fix last promisifyResolve call

* avoid some functions alloc on dns.exports
2023-02-24 13:56:41 -08:00
Justin Whear
6d5f0167c5 Fix lol_html_rewriter_builder_add_document_content_handlers binding (#2161)
The `lol_html_rewriter_builder_add_document_content_handlers` does not return a
 status code and always succeeds; errors are reported on subsequent calls to `write` or `end`.

Fixes #2024
2023-02-24 13:53:18 -08:00
Dylan Conway
f290b049e8 formatting 2023-02-24 13:34:28 -08:00
Justin Whear
f0e5d54579 Implement os.cpus for Darwin (OS X) (#2115)
* adding experimental Mac implementation os os.cpus

* Simplify cpus interfaces

* remove support for osx 10

* Refactor os.cpus implementation

This commit substantially refactors how the Linux and Darwin implementations of
 `os.cpus`.  The goal is to avoid unnecessary copying and allow broader latitude
 in responding to errors per implementation.

* improved comments

* ensure no buffer overrun

* use PROCESSOR_CPU_LOAD_INFO_COUNT; not sure if this is correct

* oh teh noes

* use sliceTo instead of span

* cpu_ticks are uints
2023-02-24 14:24:04 -06:00
Ciro Spaciari
1c531472c9 fix(body) Make Request/Reponse empty body to be null (#2156)
* make empty nullable

* revert mistake change
2023-02-24 12:22:14 -08:00
Derrick Farris
dc8e845049 fix(zig-build): disable stack probing on x86_64 so no compiler_rt required (#2159) 2023-02-24 12:20:05 -08:00
Ashcon Partovi
08308e2287 Update docs issue template 2023-02-24 09:57:39 -08:00
Jake Boone
f366231bff [docs] Minor syntax correction in test.md (#2153) 2023-02-24 09:56:18 -08:00
Alex Lam S.L
e887a064fb prefer bun.copy() over std.mem.copy() (#2152) 2023-02-24 05:53:26 -08:00
Jarred Sumner
6e4908e517 Update build-id 2023-02-24 00:20:50 -08:00
Dylan Conway
3f04f8d0a6 Upgrade Zig (#2151)
* fixup

* Upgrade Zig

* Remove bad assertion

* strings

* bump

* mode -> optimize

* optimize

* Linux build

* Update bindgen.zig
2023-02-23 23:57:19 -08:00
Ashcon Partovi
b5bdde28ed Fix release workflow 2023-02-23 17:58:56 -08:00
Colin McDonnell
f54300578b Add documentation (#2148)
* Add documentation

* Tweaks

* Fixes

* Rearrange

* Update
2023-02-23 17:13:30 -08:00
Alex Lam S.L
5929daeeae fix illegal memory reference in bun link (#2147) 2023-02-23 16:37:08 -08:00
Jarred Sumner
4122cb0b19 Update ZigGlobalObject.cpp 2023-02-23 16:33:51 -08:00
N0N1m3
e6e4e6b577 Update README.md (#2145) 2023-02-23 14:13:37 -08:00
Ashcon Partovi
dc634d3b30 Use newer version of setup-bun 2023-02-23 10:10:36 -08:00
Ashcon Partovi
2c795e6a3c bun-lambda: Fix 502 when handler name was 'fetch' 2023-02-23 09:54:22 -08:00
Jarred Sumner
17f1649c87 Fix flaky tests 2023-02-22 23:00:55 -08:00
B. Burt
93778a66d8 Update README.md (#2138) 2023-02-23 00:37:59 -06:00
Dylan Conway
9024125d41 uninstall 2023-02-22 21:54:48 -08:00
Derrick Farris
e687a1cf0c feat(undici): add undici.request (#2136)
* wip(undici): get basic requests working

* wip(undici): implement most request params, add tests

* fix(undici): get tests passing for `undici.request`

* test(undici): test headers in `undici.request`
2023-02-22 21:54:05 -08:00
Jarred Sumner
1d592a9489 Add leaky test 2023-02-22 21:50:39 -08:00
Jarred Sumner
17efd52ba3 Add a request.signal test with Bun.serve 2023-02-22 21:50:39 -08:00
Dylan Conway
0cf08c7e7b fix string diff extra newline 2023-02-22 21:35:44 -08:00
Jarred Sumner
0143eccb27 Fix flaky request.signal implementation 2023-02-22 21:29:43 -08:00
Jarred Sumner
583b29632c Make the tests run 2023-02-22 20:35:14 -08:00
Jarred Sumner
16ea1753b4 Fix missing ref() in lazily created signal 2023-02-22 20:16:08 -08:00
Ciro Spaciari
24d624b176 feat(Request.signal) Initial support for signal in Request + fetch and Request + Bun.serve (#2097)
* add fetch abort signal

* get aborted (still segfaults)

* bidings.zig u0 error

* still GC/memory error

* fix start crash

* fix AbortSignal fromJS

* change fromJS to obj.as

* addAbortSignalEventListenner

* handle abort types, and add tests

* fix tests

* add custom reason test

* merge 2 substring methods, use MAKE_STATIC_STRING_IMPL

* fix create AbortError and TimeoutError, move globalThis and exception creation to main thread

* fix tests and rebuild headers

* no need to check with substring reason is already an exception

* no need to check with substring reason is already an exception

* fix dumb error inverting conditions for check reason

* fix custom reason behavior

* Request signal

* remove package-lock.json

* Remove JSC.Strong from Request signal

* fix globals for fetch abort signal

* more tests, clone signal crashs

* fix AbortSignal.toJS

* fix toJS bidings for AbortSignal

* add streaming tests

* fix abortion before connecting

* fix tests and segfault

* add fetch testing abort after finish

* fix signal handler cleanup

* support signal event Bun.serve

* pull tests (failing)

* remove unsupported test

* formating

* fix server Request.signal, fix cleanNativeBindings

* add direct tests

* more pull tests

* fix stream tests

* fix fetch, pending onAborted fix in HTTPServerWritable

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-02-22 19:27:25 -08:00
Dylan Conway
9c5f02e120 newlines for array diff 2023-02-22 19:25:17 -08:00
Jarred Sumner
2a1558e4d6 [breaking] Return Node.js Timeout objects in setTimeout, setInterval, and setImmediate
Fixes #2129 #880
2023-02-22 19:07:27 -08:00
Jarred Sumner
0911bd3af2 Support well known symobls in prototypes for generated classes 2023-02-22 19:04:54 -08:00
Colin McDonnell
9f53a2210c Various type fixes (#2135)
* Simplify serve() types

* Remove baseURI

* Add Bun.serve type tests

* Number env vars

* Make loader optional

* FSRouter doesn't support URL

* Update sqlite types

* Bench

---------

Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
2023-02-22 17:45:22 -08:00
Dylan Conway
575291a301 format options with quote strings (#2134) 2023-02-22 15:46:56 -08:00
Jarred Sumner
ac3973016f Fixes #2121 in runtime, but not in tests 2023-02-22 15:29:09 -08:00
Andrea Giammarchi
9b5ddef598 Fix glibc error in alpine Docker image (#2126)
There's an override error with latest alpine and various versions of glibc (including 2.35): https://github.com/sgerrand/alpine-pkg-glibc/issues/185

This MR proposes a workaround (tested on fly.io - it works) so that it's possible to have bun usable with minimal linux dependencies.
2023-02-22 14:26:21 -08:00
Dylan Conway
424045835c wiptest -> test (#2131)
* +/- for object diff, quote more strings

* wiptest -> test

* quote strings fix
2023-02-22 13:55:42 -08:00
Derrick Farris
e8c9c644ca fix(child_process): import from primordials (#2132) 2023-02-22 12:51:17 -08:00
Jarred Sumner
629be18867 Update recommended extensions 2023-02-22 12:44:50 -08:00
Derrick Farris
9be68ac235 fix(child_process): match Node's promisified exec fn (#2128) 2023-02-22 12:39:40 -08:00
Ashcon Partovi
ee60a5c55c Add runtime layer for Bun on AWS Lambda (#2009) 2023-02-22 10:34:16 -08:00
Alex Lam S.L
2dc85c4e45 [install] support SCP-style git dependencies (#2124)
- try HTTPS first before SSH
- improve package name resolution
- improve report messages

fixes #2119
2023-02-21 19:32:35 -08:00
Dylan Conway
88c238dc5c isRegExp() without cpp 2023-02-21 12:18:24 -08:00
Dylan Conway
12b2ad7363 add diffz 2023-02-21 11:52:41 -08:00
Dylan Conway
d786dd6c0b Update test runner output with colors and diffs (#2122)
* add zig-diff

* move diff functions

* toHaveProperty diff for objects

* use formatter

* format labels

* move work to format, diff when it makes sense

* remove comptime, dim equal slices

* order before diff

* line diffs

* add diffz

* switch to diffz

* add `diffLines()` function

* small `prettyFmt()` bug fix

* test runner color output

* update `toBe()` error output

* fix test

* diff method, fix crash

* fix link test

* remove `isRegex`
2023-02-21 11:47:13 -08:00
Derrick Farris
e21796acf5 Add mention of bunx --bun to README (#2114)
* readme(bunx): add info about `bun --bun x`

* chore(formatting): add extension for formatting markdown to avoid a bunch of diffs

* chore(formatting): fix JS formatting in README
2023-02-20 16:46:26 -08:00
Craigory Coppola
f6705a73c7 docs(bunx): add initial documentation to readme (#2106) 2023-02-20 09:08:31 -06:00
Mathias Lafeldt
8bcf64c881 Fix Deno SQLite benchmark (#2112)
Deno has removed direct access to Deno.core:

https://deno.com/blog/v1.30#removal-of-internal-denocore

As a result, a newer version of sqlite3 is required:

https://deno.land/x/sqlite3@0.8.0/src/util.ts?source#L19
2023-02-20 08:52:33 -06:00
Jarred Sumner
bcb7be4909 fixup double export 2023-02-19 19:04:29 -08:00
Jarred Sumner
c006a7f054 Fixes #2108 2023-02-19 16:50:13 -08:00
Micha Reiser
8aa6ee5332 fix: Print URL as object in (#2104) 2023-02-18 15:44:29 -08:00
Carter Snook
963bb54e87 feat(node/os): implement os.machine() (#1378)
* feat(node/os): implement 'os.machine()'

---------

Co-authored-by: Justin Whear <justin.whear+github@gmail.com>
2023-02-18 13:54:59 -08:00
Jarred Sumner
8ff1ff16a5 Update fs.test.js 2023-02-17 22:28:28 -08:00
Alex Lam S.L
7285b9cf75 update bun.lockbs (#2101) 2023-02-17 22:07:02 -08:00
Jarred Sumner
7416672e93 Fix edgecase in some arg parsing in fs module 2023-02-17 22:03:22 -08:00
Jarred Sumner
fa10631c2f use map 2023-02-17 22:00:44 -08:00
Jarred Sumner
1106c8e2f2 More correct filesystem flags parsing 2023-02-17 21:41:58 -08:00
Jarred Sumner
20d9483cd0 Fix issue with express body-parser introduced by our async_hooks polyfill 2023-02-17 18:05:41 -08:00
Jarred Sumner
155e3706b1 Merge branch 'main' of github.com:oven-sh/bun 2023-02-17 17:30:51 -08:00
Jarred Sumner
44cdb1ec8e Fix a couple flaky tests 2023-02-17 17:30:29 -08:00
Alex Lam S.L
d406ca6328 use bun.logger instead of bun.Output (#2099) 2023-02-17 17:06:01 -08:00
Jarred Sumner
e542d9b4ed Fix flaky test 2023-02-17 17:02:55 -08:00
Justin Whear
fb313f210a Fix #1602 (#2066)
* initial test case

* fix segfault from JSObjectMakeDeferredPromise

* pass exceptions through from FetchHeader.createFromJS

* not resolved, but getting close

* implement review suggestions

* fix exception check, tests

* Change how header filtering is accomplished

Previously the FetchHeaders implementation relied on converting names and values
 to IDLByteString to catch non-ASCII data, though not always reliably.  This
 resulted in message-less TypeErrors when headers contained invalid characters.
This commit shifts everything to IDLDOMString for the conversion and relies on
 the actual error checking in FetchHeaders.canWriteHeader, resulting in nicer
 error messages.

To ensure that all headers are written as ASCII/UTF8 rather than UTF16, the
 copyTo bindings function checks the encoding and converts if necessary.

* wrapping up FetchHeader fixes

* since utf8 allocates only do so when needed

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

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

* WebCore__FetchHeaders__has should return on exception path

* strip out log calls from test

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-02-17 15:54:05 -08:00
Alex Lam S.L
c60d7db178 [install] support git dependencies (#2094) 2023-02-17 14:48:57 -08:00
Justin Whear
d37daeb76a Fix #2005 (#2096) 2023-02-17 14:48:10 -08:00
Alex Lam S.L
79f7d29d03 allow bun add of packages with capital letters (#2095) 2023-02-17 14:46:07 -08:00
Jarred Sumner
56b75dbac3 faster Buffer.byteLength("latin1") 2023-02-16 17:17:29 -08:00
Jarred Sumner
5007c6b218 Support yarn-like "workspaces"."packages": string[] (#2086)
* [workspaces] Support yarn-like `"workspaces"."packages": string[]`

* Add a test

* ✂️

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-02-16 15:06:35 -08:00
Justin Whear
d95404fd7a Implement machine for Linux (#2088) 2023-02-16 15:05:15 -08:00
Justin Whear
7762f3fad7 Fix #1516 (#2089)
`FileSystemFlags.fromJS` was hardcoded to return O_RDONLY when the flag value
 was null or undefined and this caused breakage when used with write functions.
Updated the function to take a `default` argument so that the caller can specify
 a sane default for their use.
2023-02-16 14:01:07 -08:00
Jarred Sumner
e7cd45d0fa Update globals.d.ts 2023-02-16 03:18:01 -08:00
Jarred Sumner
0e688d62f9 Add missing type definition 2023-02-16 03:11:40 -08:00
Jarred Sumner
ce01a31e94 [napi] Fix crash in creating arrays > 8 elements long 2023-02-16 03:11:22 -08:00
Luke Deen Taylor
37fafc208f Clarify and clean up macOS build process (#2087)
* Add missing steps to macOS build

* Remove codesigning step from make dev

ref: https://discord.com/channels/876711213126520882/888839314056839309/1075681626127872030
2023-02-16 00:01:41 -08:00
Jarred Sumner
88a8aa4797 Don't crash on null version string 2023-02-15 19:57:59 -08:00
Jarred Sumner
610eb06ddc Add disabled optimization 2023-02-15 19:31:14 -08:00
Jarred Sumner
49cd122bda Add more logging to napi 2023-02-15 18:08:31 -08:00
Jarred Sumner
1125728097 Incorrect implementation of napi_create_threadsafe_function 2023-02-15 18:08:31 -08:00
Ciro Spaciari
597053ea91 feat(fetch) AbortSignal (#2019)
* add fetch abort signal

* get aborted (still segfaults)

* bidings.zig u0 error

* still GC/memory error

* fix start crash

* fix AbortSignal fromJS

* change fromJS to obj.as

* addAbortSignalEventListenner

* handle abort types, and add tests

* fix tests

* add custom reason test

* merge 2 substring methods, use MAKE_STATIC_STRING_IMPL

* fix create AbortError and TimeoutError, move globalThis and exception creation to main thread

* fix tests and rebuild headers

* no need to check with substring reason is already an exception

* no need to check with substring reason is already an exception

* fix dumb error inverting conditions for check reason

* fix custom reason behavior
2023-02-15 14:20:40 -08:00
Derrick Farris
1c221d33b0 fix(webcrypto): fix ed25519 CryptoKey.algorithm (#2082) 2023-02-15 13:48:11 -08:00
Justin Whear
e67b4e73b5 Fix 2063 (#2079) 2023-02-15 12:58:53 -08:00
Jarred Sumner
95e727162b Make sure we test * in tesconfig
Fixes #540
2023-02-15 03:53:33 -08:00
Jarred Sumner
e860e12be5 don't return an error there 2023-02-15 03:28:35 -08:00
Jarred Sumner
ad0bee532c Fix cast 2023-02-15 03:18:54 -08:00
Jarred Sumner
c7d16d2ed5 ensure we allocate for > 6 arguments 2023-02-15 02:51:44 -08:00
Jarred Sumner
d150a73b9b Update async_hooks.exports.js 2023-02-15 01:41:28 -08:00
Jarred Sumner
0d7cea69c2 workaround prisma's usage of eval("__dirname") 2023-02-15 01:35:02 -08:00
Jarred Sumner
c83eaf09b9 some cleanup 2023-02-15 00:36:18 -08:00
Jarred Sumner
4320108add ED25519 WebCrypto (#1971)
* ed25519

* Register the algorithm

* try this?

* fix(webcrypto): fix ed25519 keypair gen (#1985)

* fix: import and export ed25519 (#2004)

* fix(webcrypto): allow import and export ed25519

* fix(webcrypto): copy exportkey

* fix(webcrypto): fix use after stack free

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Derrick Farris <mr.dcfarris@gmail.com>
2023-02-15 02:11:48 -06:00
Jarred Sumner
d91052516e Fix up async_hooks polyfill 2023-02-14 23:58:05 -08:00
Jarred Sumner
c6ee401bf4 Add temporary polyfill for async_hooks 2023-02-14 23:37:25 -08:00
Jarred Sumner
f19e3d66cb 😷 async_hooks 2023-02-14 22:29:10 -08:00
Alex Lam S.L
e63e3a0ca7 [install] link network-delayed .bin scripts correctly (#2076) 2023-02-14 22:25:50 -08:00
Jarred Sumner
5598ea69f2 don't break esbuild 2023-02-14 22:24:11 -08:00
Jarred Sumner
4dc6bf1b09 Add workaround for tls and worker_threads 2023-02-14 21:56:49 -08:00
Alex Lam S.L
7597e4ad2a [install] improve package.json validation (#2074)
- report error and exit gracefully instead of crashing
2023-02-14 18:04:06 -08:00
Derrick Farris
a80981c966 [WIP] fix(node:fs): export fs.ReadStream and fs.WriteStream (#1798)
* fix(node:fs): export fs.WriteStream and fs.ReadStream

* test(node:fs): add tests for fs.ReadStream and fs.WriteStream

* test(node:fs): prevent opening fd w/o closing

* fix(node:fs): hack ESM export for fs streams to keep lazy loading

* fix(node:fs): = -> ===, fix hasInstance comparison

* test(node:fs): add test that actually checks that re-exported streams work

* fix(fs): eagerly load our slow lazy fns (thanks esm)

* fix(fs): employ @alexlamsl 's constructor w/o new trick on Read/WriteStream
2023-02-14 15:54:50 -08:00
Eric Zhang
6e1a52691a Reject with error when invalid fetch() body (#2047)
* Reject with error when invalid fetch() body

Resolves #2014

* Make sure the test actually throws an exception

* Update fetch error paths to return TypeErrors
2023-02-14 15:43:18 -08:00
Derrick Farris
ef75cd4658 fix(FormData): make String explicit, thanks @dylan-conway (#2065) 2023-02-13 13:04:54 -05:00
Derrick Farris
af3f42e630 fix(FormData): add string literal operator (#2064) 2023-02-13 09:42:49 -08:00
Jarred Sumner
37186f4b0a Add pretty printer for FormData 2023-02-13 04:37:23 -08:00
Michał Warda
f310d7414b Add dynamic port assigning to Bun.serve (#2062) 2023-02-13 03:08:11 -08:00
Derrick Farris
739de2c9cd feat(napi): add napi_get_value_bigint_words (#2061)
* feat(napi): add `napi_get_value_bigint_words`

* fix(napi): handle `napi_get_value_bigint_words` arr too small
2023-02-13 03:07:18 -08:00
Jarred Sumner
0db8cdf4e9 Fixes https://github.com/oven-sh/bun/issues/1456 2023-02-13 03:05:26 -08:00
Jarred Sumner
246db4fed0 Add FormData bench snippet 2023-02-13 01:36:43 -08:00
Jarred Sumner
aa0762e466 Implement FormData (#2051)
* Backport std::forward change

* Implement `FormData`

* Fix io_darwin headers issue

* Implement `Blob` support in FormData

* Add test for file upload

* Fix bug with Blob not reading Content-Type

* Finish implementing FormData

* Add FormData to types

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-02-13 00:50:15 -08:00
Alex Lam S.L
cdbc620104 [install] support git://github.com/ dependencies (#2059) 2023-02-12 14:44:39 -08:00
Ashcon Partovi
bb2aaa36fb Add release signing to release workflow 2023-02-12 13:10:10 -08:00
Jarred Sumner
f4f88701c5 prettier + stop server 2023-02-12 04:41:18 -08:00
Michał Warda
cc214baacf Return server on listen (#2057) 2023-02-12 04:37:28 -08:00
Jarred Sumner
83473c60df Set require("module").globalPaths to empty array
https://github.com/oven-sh/bun/issues/1641#issuecomment-1427017442
2023-02-12 04:35:52 -08:00
Alex Lam S.L
8b4e58f3d2 fix string corruption in FS entry cache (#2055) 2023-02-11 21:35:33 -08:00
Alex Lam S.L
30e82c5df4 fix segfault during non-install script execution (#2045) 2023-02-11 20:40:18 -08:00
Derrick Farris
9eba1e0e3f [WIP] feat(napi): add napi-fatal-exception (#2054)
* feat(napi): add `napi-fatal-exception`

* fix(napi): fatal_exception - add symbol to list, don't optimize away
2023-02-11 20:20:25 -08:00
Jarred Sumner
675529bd0c Fixes https://github.com/oven-sh/bun/issues/2052 2023-02-11 18:11:09 -08:00
Jarred Sumner
5528c0fa47 Backport std::forward change 2023-02-11 17:31:16 -08:00
Justin Whear
c208c4e319 Fix #631: bun add throwing JSON lexer bug (#2041)
* add double-backslash to list of control chars

* update test

* stderr as string
2023-02-10 19:05:32 -08:00
Eric Zhang
10650cced2 Fix PATH setup in macOS setup instructions (#2044)
Very minor! I was just going through the setup instructions and had a bit of a double take.
2023-02-10 15:16:51 -08:00
Jarred Sumner
8466e60e3a update to simdutf 3.2.0
thanks @lemire
2023-02-10 15:02:30 -08:00
Derrick Farris
b1aac9ff6d fix(string_immutable): fix toUTF16Alloc for bindgen w/ use_simdutf = false (#2042) 2023-02-10 13:12:14 -08:00
Ashcon Partovi
ed2e0e1617 Add bun-ecosystem for running tests on npm packages 2023-02-10 09:47:59 -08:00
Alex Lam S.L
09585c4b24 [install] fix duplicate check on peerDependencies (#2039)
fixes #2037
2023-02-10 09:23:40 -08:00
Alex Lam S.L
5181aa54e2 drop ASCII double-scan and other minor clean-ups (#2038) 2023-02-10 09:22:24 -08:00
Jarred Sumner
995880a7ef Enable https://github.com/tc39/proposal-set-methods 2023-02-10 00:27:06 -08:00
Jarred Sumner
941c6ed814 Upgrade WebKit 2023-02-09 21:28:50 -08:00
Alex Lam S.L
6052a3edbd fix assertion failure (#2033) 2023-02-09 21:20:11 -08:00
Alex Lam S.L
6fd7c1921e [install] fix flaky tests (#2032) 2023-02-09 20:35:58 -08:00
Alex Lam S.L
119120d21c [simdutf] workaround validation OOB access (#2031) 2023-02-09 20:26:23 -08:00
Jarred Sumner
4bedd3833d Workaround https://github.com/simdutf/simdutf/issues/213 2023-02-09 19:06:20 -08:00
Alex Lam S.L
2abfa8abd2 [streams] fix byte accounting (#2029)
fixes #1939
2023-02-09 17:04:36 -08:00
Jarred Sumner
ad9d4fb0c4 Add a note about builtins 2023-02-09 14:09:50 -08:00
Jarred Sumner
523b112945 [bun:test] Auto-import jest globals in test files 2023-02-09 00:30:40 -08:00
Jarred Sumner
8aa29040e6 move some code around 2023-02-08 23:09:24 -08:00
Jarred Sumner
a2afb252bf Update CONTRIBUTING.md 2023-02-08 21:46:53 -08:00
Jarred Sumner
abb89f489f Create CONTRIBUTING.md 2023-02-08 20:47:11 -08:00
Jarred Sumner
ddec9e0bf6 handle more cases with util.isError 2023-02-08 17:18:02 -08:00
Jarred Sumner
4962bea4fc cleanup util.test 2023-02-08 17:17:40 -08:00
Alex Lam S.L
f31330d3e2 [install] pick latest tagged version by default (#2016)
* [install] pick `latest` tagged version by default

fixes #1993

* update `package.json` the same way as `npm
2023-02-08 16:28:29 -08:00
Ashcon Partovi
ee8ccca605 Remove test run workflow, for now 2023-02-08 16:11:24 -08:00
Dylan Conway
6fdbb25f9a utf16 to utf8 conversion validation (#2001)
* use replacement character for invalid surrogate pairs

* return index of non-ascii

* non-allocating case

* edge cases

* function rename

* oops

* get length once, index counter
2023-02-08 14:42:10 -08:00
RobViren
b8c0554839 Fix minor version bug for README.md (#2013)
Addresses issue #2012 and corrects the minor version to the current minor version
2023-02-08 14:39:57 -08:00
Alex Lam S.L
18807cef03 [install] assorted fixes & improvements (#2011)
- take `peerDependencies` into account during package placement
- do not recursively resolve `workspaces` (matches `npm`)
- link binaries to non-root packages correctly
- prune empty nodes during dependency tree construction
- support non-standard `workspace:` specifier
2023-02-08 14:37:14 -08:00
Ashcon Partovi
cbc28afd51 Fix 'MissingPackageJSON' in Dockerfile
Closes #2008
2023-02-07 14:33:22 -08:00
Jarred Sumner
7886bce8c8 cleanup 2023-02-07 10:51:55 -08:00
Ashcon Partovi
7cd26232b1 Update docker image in README 2023-02-07 08:46:09 -08:00
Ashcon Partovi
a0b0cd6844 Fix bugs with release script 2023-02-07 04:47:36 -08:00
Jarred Sumner
52f9c3d05e set the type 2023-02-06 23:27:18 -08:00
Jarred Sumner
f947987a2c default not configurable 2023-02-06 23:19:12 -08:00
Jarred Sumner
30106c4f54 Fix failing test in debug mode 2023-02-06 23:19:05 -08:00
Jarred Sumner
34b2d7fe57 Mark things as DontDelete 2023-02-06 23:15:32 -08:00
Jarred Sumner
153834cf5c Throw on process.binding 2023-02-06 23:15:23 -08:00
Jarred Sumner
6aea31f4fc cleanup 2023-02-06 22:41:44 -08:00
Jarred Sumner
0fd144993c Fix test failing on macOS 2023-02-06 22:41:37 -08:00
Jarred Sumner
6699fe14e7 minor cleanup 2023-02-06 22:32:10 -08:00
Jarred Sumner
add7b1101e Add bounds check 2023-02-06 22:29:24 -08:00
Alex Lam S.L
5a19f8434b [WIP] fix corner cases with aliases dependencies (#2000)
* fix corner cases with aliases dependencies

* in-memory convert legacy `bun.lockb`
2023-02-06 22:24:34 -08:00
Jarred Sumner
d5f3bb1c74 Update text-decoder.mjs 2023-02-06 22:13:05 -08:00
Colin McDonnell
08e33fbd42 Fix gaps in types (#2003)
* Add type for clearImmediate

* Expose Crypto class

* Add types for CustomEvent

* Add types for module and exports

* Add types for global

* Add types for DOMException

* Add types for WebAssembly

* Update formatting

* Fix clearTimeout

* Fix formatting

* Update formatting

* Remove log

---------

Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
2023-02-06 21:36:36 -08:00
Jarred Sumner
7ddbbc53b4 Make Stat functions fast 2023-02-06 21:18:58 -08:00
Jarred Sumner
85611272c6 bump 2023-02-06 20:35:59 -08:00
Jarred Sumner
c40912b8dc formatting 2023-02-06 20:28:59 -08:00
Jarred Sumner
77974f2a6e tweaks to generator 2023-02-06 19:27:21 -08:00
Jarred Sumner
ed72bee373 Mark some things as not configurable 2023-02-06 19:27:16 -08:00
Jarred Sumner
05f3a22cba Use new bindings for Stat
Fixes #1999
2023-02-06 18:40:52 -08:00
Jarred Sumner
f5df1044d4 Fix build 2023-02-06 18:39:03 -08:00
Jarred Sumner
4329f6ad16 Backport https://github.com/WebKit/WebKit/pull/9713 2023-02-06 14:21:25 -08:00
Michał Warda
fd4668d97c Expose Dirent and Stats (#1998)
* Expose dirent and stats

* Expose Dirent and Stats inside fs

* Add tests for Dirent and Stats exposing

* Automatically generate bindings
2023-02-06 14:15:20 -08:00
Ciro Spaciari
8c4ed963ec fix(uWS:capi) uws_req_set_yield typo and uws_res_override_write_offset (#1996) 2023-02-06 12:59:04 -08:00
Colin McDonnell
e7f9ce47f4 Add types for node:console and node:perf_hooks (#1982)
* Add types for node:console and node:perf_hooks

* Add types for util/types

---------

Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
2023-02-06 12:57:19 -08:00
Dylan Conway
98022bec1e mark binding 2023-02-06 12:23:59 -08:00
Cheng Shao
397f559e77 Fix URL of wasi-js (#1997) 2023-02-06 11:35:01 -08:00
Jarred Sumner
ca2e708be1 speed it up a little more 2023-02-05 07:07:35 -08:00
Jarred Sumner
8649136845 substringSharingImpl allocates, do not use 2023-02-05 06:17:21 -08:00
Jarred Sumner
e8fe6dd2f8 Faster Buffer.toString("ascii") 2023-02-05 04:14:16 -08:00
Gaurish Sethia
df126b2f3b Bump querystring-es3 (#1988)
* Add filePath property on MatchedRoute

* Fix #1880 #851

* Fix #1972 as well

* FMC

* Bump querystring-es3

---------

Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-02-04 23:15:42 -08:00
Jarred Sumner
7d3a2ca382 Add isDeepStructEqual to node:util 2023-02-04 00:34:03 -08:00
Jarred Sumner
b7c96bfaae Fixes #1978 2023-02-03 22:29:32 -08:00
Justin Whear
a2fd20e5c0 Implement os.cpus() for Linux (#1977)
* Implement os.cpus() for Linux

`os.cpus()` currently returns an empty array for all platforms.  This PR implements full functionality for Linux and has been tested on x86-64.  Other OSes will continue to return an empty array.

Note that Linux on Arm64 may report the CPU model differently; if this is the case the CPU model will currently be reported as "unknown".  As I do not have Arm64 hardware to verify and develop against, a todo has been left in the code.

* resolve issues from review
2023-02-03 18:13:33 -08:00
Jarred Sumner
de613baf81 Support passing Date to Bun.sleep 2023-02-03 17:25:25 -08:00
Jarred Sumner
4590e2b83a Add test for propagating exception 2023-02-03 17:04:47 -08:00
Jarred Sumner
2758e0cab9 Add missing crypto export
Fixes #1984
2023-02-03 16:39:16 -08:00
Jarred Sumner
7d386bf1f1 Introduce await Bun.sleep(ms) 2023-02-03 16:39:16 -08:00
Ashcon Partovi
164cd774f7 Fix types for Array.fromAsync 2023-02-03 16:29:03 -08:00
Gaurish Sethia
6469649f64 Fix/Update Typescript types (#1972)
* Add filePath property on MatchedRoute

* Fix #1880 #851

* Fix #1972 as well

* FMC

---------

Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-02-03 14:53:18 -08:00
Jarred Sumner
06d073003d fix require("perf_hooks") 2023-02-03 14:39:07 -08:00
Jarred Sumner
50f1dd61a6 allow other ArrayBufferView in Buffer functions 2023-02-03 14:39:07 -08:00
Jarred Sumner
c64d7933a1 Make it less flaky 2023-02-03 14:39:07 -08:00
Ashcon Partovi
b289b51894 Run tests on pull requests 2023-02-03 11:55:15 -08:00
Ashcon Partovi
17ad8005c7 Run tests on push 2023-02-03 11:54:31 -08:00
Dylan Conway
f572305013 another 2023-02-03 11:50:23 -08:00
Dylan Conway
17b4e5ce08 integers overflowing 2023-02-03 11:47:21 -08:00
Ashcon Partovi
3933ccab3b Attempt to debug annotations 2 2023-02-03 11:35:24 -08:00
Ashcon Partovi
92255d56c8 Attempt to debug annotations 2023-02-03 11:32:01 -08:00
Ashcon Partovi
ba076b0a2b Fix console output in bun wiptest 2023-02-03 11:23:55 -08:00
Ashcon Partovi
10600c4abd Use GitHub action SDK 2023-02-03 11:18:44 -08:00
Ashcon Partovi
d16dffa2b4 Add workflow for bun wiptest 2023-02-03 11:01:22 -08:00
Alex Lam S.L
65e0d10ee0 prettier deltas (#1973) 2023-02-02 17:29:28 -08:00
Colin McDonnell
742368f03a Update/fix types (#1955)
* WIP

* Update types

* Spacing

---------

Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
2023-02-02 17:29:10 -08:00
Dylan Conway
242dcea2fe match formatting 2023-02-02 16:15:12 -08:00
Jarred Sumner
198322073d Update string_immutable.zig 2023-02-02 15:58:10 -08:00
Jarred Sumner
b12762af6c Fix stack overflow when console.log'ing strings 2023-02-02 15:56:16 -08:00
Ashcon Partovi
440a21eb1d Add bun-test to run bun wiptest 2023-02-02 11:57:36 -08:00
Jarred Sumner
2bc4858346 export more 2023-02-02 01:34:41 -08:00
Jarred Sumner
26d15cf542 Update build-id 2023-02-02 01:32:39 -08:00
Derrick Farris
8361513acf feat: add http.request (#1959)
* fix(node-test-helpers): make sure to call done with any Errors thrown from wrapped fn

* feat(node:http): add http.request, patch some missing apis for IncomingRequest, etc.

* fix(node:http): FakeSocket -> Socket

* refactor(node:http): only save type from IncomingMessage.options for now

* fix(node:http): remove unnecessary check for UInt8Array

* perf(node:http): globalThis.fetch -> var fetch = Bun.fetch

* todo(node:http): add notes about handling abort/timeout w/ AbortSignal

* refactor(node:http): standardize on FakeSocket and this.#fakeSocket

* fix(node:http): fix headers getter

* fix(node:http): remove _headers

* perf(node:http): make http headers lazy

* fix(node:http): return bool from keepSocketAlive
2023-02-01 19:22:29 -08:00
Dylan Conway
19eca76498 change file extension 2023-02-01 19:06:56 -08:00
Dylan Conway
3c23f9ad57 fix text encoding for utf8 (#1967)
* use character

* replacement character

* also test encoding decoded points

* increase length by 1
2023-02-01 18:48:09 -08:00
Alex Lam S.L
76f3c9c07b resolve duplicate npm dependencies correctly (#1970)
* resolve duplicate npm dependencies correctly

fixes #1952

* modify the correct reference
2023-02-01 18:13:25 -08:00
Ashcon Partovi
3a3bf33335 Stop releasing bun:0 for docker 2023-02-01 15:01:12 -08:00
Ashcon Partovi
69ee87d8e2 Add script to calculate semver for release 2023-02-01 14:53:57 -08:00
Ashcon Partovi
6d0fff4fab Fix version in bun-types canary release 2023-02-01 14:16:48 -08:00
Ashcon Partovi
f7a93fe294 Add bun-types release to canary workflow 2023-02-01 14:13:39 -08:00
Ashcon Partovi
02fc87ea29 Fix bad tag in npm publish 2023-02-01 14:03:00 -08:00
Ashcon Partovi
7f853af6f0 Add bun-types release to workflow 2023-02-01 14:00:31 -08:00
Ashcon Partovi
04309431bb Tweak commit message for robobun 2023-02-01 13:37:36 -08:00
Ashcon Partovi
fc712ead2f Add GPG key to release 2023-02-01 13:28:30 -08:00
Ashcon Partovi
e7f2d34c44 Maybe fix permissions with Homebrew 2023-02-01 12:02:43 -08:00
Ashcon Partovi
0c3e55132c Update homebrew release action 2023-02-01 11:33:08 -08:00
Ashcon Partovi
c69bbbd24f Update trustdb in Docker image 2023-02-01 11:24:12 -08:00
Ashcon Partovi
c0bfdebbd9 Fix grouping for Docker tag 2023-02-01 11:02:39 -08:00
Ashcon Partovi
9c27b5d17f Fix getting SHA for canary 2023-02-01 10:56:08 -08:00
Ashcon Partovi
9973df028b Fix missing dependency from release script 2023-02-01 10:44:19 -08:00
Ashcon Partovi
a0be199b4f Add morningly workflow to release to canary 2023-02-01 10:42:04 -08:00
Ashcon Partovi
73d6c888b9 Add bun-release package 2023-02-01 10:28:01 -08:00
Gaurish Sethia
661fca9cde Add filePath property on MatchedRoute (#1964) 2023-02-01 05:10:48 -08:00
Jarred Sumner
b0803298f9 Update javascript_core_c_api.zig 2023-02-01 00:52:45 -08:00
Jarred Sumner
6318017f84 Update module_loader.zig 2023-02-01 00:52:45 -08:00
Colin McDonnell
696d4b6267 Add target for printing version in makefile (#1957)
* Add get-*

* Add print-version target

* Webkit

---------

Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
2023-01-31 20:35:12 -08:00
Jarred Sumner
cc4326cd82 Re-run prettier after changes 2023-01-31 17:55:16 -08:00
Jarred Sumner
c57b37d29f Handle invalid input in clear* timer 2023-01-31 17:52:17 -08:00
Jarred Sumner
b09896f06e mostly fix node:timers 2023-01-31 17:51:36 -08:00
Jarred Sumner
b7816f3175 Fixes fs.constants 2023-01-31 17:20:48 -08:00
Jarred Sumner
0dfde6f8c7 misc wasi fixes + prettier 2023-01-31 15:17:39 -08:00
Jarred Sumner
0788bc1d94 Fixes #1958 2023-01-31 15:05:52 -08:00
Jarred Sumner
28a7f27633 Remove validateion 2023-01-31 15:05:52 -08:00
Jarred Sumner
b2daf3c982 Update build-id 2023-01-31 13:32:24 -08:00
Alex Lam S.L
9598868b57 [bun add] various fixes (#1953) 2023-01-31 13:05:41 -08:00
Devin Rhode
79b32f80fa Use proper casing for tsconfig values (#1644)
See: https://share.cleanshot.com/gcB3gbXJz6RQk5tx559n
2023-01-31 12:22:50 -08:00
Jarred Sumner
4bfdad2981 Fix missing *ms getters in Stat
Related to #1949
2023-01-31 03:04:59 -08:00
Jarred Sumner
3ddd8b2fa5 Fixes #1949 2023-01-31 02:15:00 -08:00
Jarred Sumner
da598a3f37 Update build-id 2023-01-30 23:13:14 -08:00
Jarred Sumner
ad3295668f Fix crash in bun install <package-name> (#1947)
* Fix crash in `bun install <package-name>` when <package-name> already exists

* Prettier

* Add test

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-01-30 23:12:41 -08:00
Jarred Sumner
f9fd7e9d08 Fixes #1928 2023-01-30 17:39:52 -08:00
Jarred Sumner
8b8bd6a405 remove log that appears in production 2023-01-30 16:14:23 -08:00
Ciro Spaciari
aa10799d8a fix utf16le fill and utf8 partial write of utf16 (#1943) 2023-01-30 12:21:23 -08:00
Alex Lam S.L
ec2c16fefa fix assert() crash (#1941) 2023-01-30 12:20:29 -08:00
Alex Lam S.L
c11bb93552 report invalid input file as test failure (#1938)
fixes #1935
2023-01-30 01:55:32 -08:00
Alex Lam S.L
5c30983d5d [bunx] fix version parsing (#1937) 2023-01-30 00:33:13 -08:00
Jarred Sumner
c9ca729493 Update buffer-create.mjs 2023-01-29 22:59:16 -08:00
Jarred Sumner
9cd9df698a Update child_process-node.test.js 2023-01-29 22:42:03 -08:00
Jarred Sumner
57edf3d91f Skip flaky test 2023-01-29 22:36:29 -08:00
Jarred Sumner
f9b14dc87b Fix flaky websocket test
cc @dylan-conway, the tests should be able to run when cwd is not the test folder
2023-01-29 22:36:24 -08:00
Jarred Sumner
a9bdc0fd44 Add check in test 2023-01-29 22:35:32 -08:00
Jarred Sumner
703bee976b [breaking] Add binaryType option to Bun.connect & Bun.listen
This is a breaking change because the default is `Buffer`, but previously the default was `Uint8Array`. While `Buffer` is a subclass of `Uint8Array`, it still technically is a breaking change because `slice` in `Uint8Array` is not semantically identical to `slice` in `Buffer`

cc @colinhacks, the .d.ts changes I made here aren't great.
2023-01-29 22:33:37 -08:00
Jarred Sumner
eb5105aa09 Update buffer.test.js 2023-01-29 21:27:52 -08:00
Jarred Sumner
552a1940eb [buffer] More passing Node.js tests 2023-01-29 21:27:42 -08:00
Jarred Sumner
98becc3538 Add another latin1 test 2023-01-29 21:23:10 -08:00
Jarred Sumner
49d8316922 Make this more careful 2023-01-29 19:01:47 -08:00
Jarred Sumner
7a496fa41a Fixes #1915 2023-01-29 19:01:39 -08:00
Jarred Sumner
4211f733d1 cleanup 2023-01-29 18:59:14 -08:00
Jarred Sumner
44eec0c5bb Fixes #1933 2023-01-29 16:29:39 -08:00
Agnieszka Stec
ac64d87a1c Update README.md (#1934)
Hi, just caught 2 small typos in Readme
2023-01-29 14:58:26 -08:00
Jarred Sumner
8e52e36846 [buffer] Buffer.byteLength passes Node.js tests 2023-01-29 03:45:58 -08:00
Jarred Sumner
348e72356b Bump WebKit 2023-01-29 01:26:16 -08:00
Jarred Sumner
035d31904a Make the build less flaky 2023-01-29 00:25:10 -08:00
Jarred Sumner
192629c8ca Fix bug in fs.openSync 2023-01-29 00:10:46 -08:00
Jarred Sumner
75181ea1f3 Add helper 2023-01-29 00:10:46 -08:00
Alex Lam S.L
d9c1a18776 [bun add] fix more corner cases (#1930) 2023-01-28 23:54:47 -08:00
Jarred Sumner
f087388ebc Support running WASI (WebAssembly) files using bun run (#1929)
* another micro bench

* Support running WASI

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-01-28 23:23:26 -08:00
Alex Lam S.L
48eb0c12ab parse git+https://github.com/ as GitHub URLs (#1926)
fixes #1921
2023-01-28 22:14:07 -08:00
Alex Lam S.L
fe389ad5ab normalise bun add package specifiers (#1924)
- fix invalid buffer references

fixes #1920
2023-01-28 21:30:46 -08:00
Alex Lam S.L
97b637a0bc fix corner cases with aliased dependencies (#1927) 2023-01-28 15:49:30 -08:00
u9g
7e9c88aa41 Fix if condition always being true (#1923) 2023-01-28 14:07:57 -08:00
Alex Lam S.L
07258bd559 [WIP] append GitHub package after fully parsed (#1911) 2023-01-28 07:05:28 -08:00
Jarred Sumner
0646efbf30 fix broken build
this breaks the build

@Electroid feel free to re-enable once it works
2023-01-28 05:47:22 -08:00
Jarred Sumner
517bdbdd0c Update bun-linux-build.yml 2023-01-28 05:03:00 -08:00
Jarred Sumner
7f8be29f25 [buffer] Use jsDynamicCast 2023-01-28 04:06:35 -08:00
Jarred Sumner
7db4b90837 commit failing tests 2023-01-28 04:03:45 -08:00
Jarred Sumner
cd48346ca8 use wrapper 2023-01-28 04:03:33 -08:00
Jarred Sumner
1b6a99636d [buffer] Do not throw in getters 2023-01-28 03:52:47 -08:00
Jarred Sumner
188c1f1f75 [buffer] Use length instead of byteLength for non-uint8array and non-arraybuffer 2023-01-28 03:50:32 -08:00
Jarred Sumner
812490e4a4 [buffer] Add missing offset property 2023-01-28 03:49:57 -08:00
Jarred Sumner
128a293901 Make the parser error in bun install look better 2023-01-28 01:09:42 -08:00
Jarred Sumner
6557df2912 Fixes #1913 2023-01-28 01:00:26 -08:00
Jarred Sumner
aff91436c0 Buffer.from doesn't need to be the Buffer constructor 2023-01-27 22:55:46 -08:00
Jarred Sumner
8075158639 Make Bun.dns lazy 2023-01-27 21:58:33 -08:00
Jarred Sumner
2757dc5e1b prettier 2023-01-27 21:56:48 -08:00
Jarred Sumner
cd90342a76 Fix flakiness 2023-01-27 21:56:34 -08:00
Jarred Sumner
8d622ad541 Fixes #1904 2023-01-27 21:39:40 -08:00
Ashcon Partovi
ed5bcf17fc Fix incorrect docker image 2023-01-27 21:21:26 -08:00
Ashcon Partovi
9e46ca19d8 Maybe fix path issue with Docker action 2023-01-27 21:09:12 -08:00
Ashcon Partovi
866646a98e Fix latest later... 2023-01-27 21:00:19 -08:00
Ashcon Partovi
4118c3d0a6 Fix invalid expression, 2nd attempt 2023-01-27 20:56:59 -08:00
Ashcon Partovi
6029a57d0b Fix invalid expression 2023-01-27 20:55:15 -08:00
Ashcon Partovi
309b741aa1 Tweak release scripts 2023-01-27 20:53:09 -08:00
Dylan Conway
d90a00857b fix sentinel mismatches 2023-01-27 20:41:15 -08:00
Ashcon Partovi
5ab2c8e4d6 Remove 'id' from each job 2023-01-27 20:39:02 -08:00
Ashcon Partovi
c194f15418 Fixup docker release 2023-01-27 20:36:13 -08:00
Ashcon Partovi
3be8a4733a Create unified release workflow 2023-01-27 20:31:18 -08:00
Jarred Sumner
3243936d3e less flaky macOS build 2023-01-27 20:25:44 -08:00
Dylan Conway
ec1ba91c38 fix import 2023-01-27 20:00:21 -08:00
Dylan Conway
ea55ef504b ensure name is allocated with toSliceClone (#1917)
* ensure name is allocated with `toSliceClone`

* shorten toSliceClone
2023-01-27 19:38:40 -08:00
Ashcon Partovi
34b643e654 Enable release signing 2023-01-27 19:14:14 -08:00
Jarred Sumner
2e1c7f5597 sentinel 2023-01-27 15:27:04 -08:00
Jarred Sumner
6cccc0d26c Update uws 2023-01-27 15:27:04 -08:00
Dylan Conway
0147647e06 fix sentinel slice 2023-01-27 14:49:12 -08:00
Jarred Sumner
ec010e4930 Update buffer.test.js 2023-01-27 14:47:13 -08:00
Dylan Conway
41af4b43e2 more websocket ref/deref tests 2023-01-27 14:22:03 -08:00
Ciro Spaciari
c1d05cf623 fix(Express.js) Express.js try to use function as hostname (#1914) 2023-01-27 13:33:53 -08:00
Jarred Sumner
724f23c19f Update watcher.zig 2023-01-27 03:54:30 -08:00
Jarred Sumner
ddca89f425 🪦 2023-01-27 03:53:01 -08:00
Jarred Sumner
805e87eeb6 Add a comment 2023-01-27 03:29:53 -08:00
Jarred SUmner
8dc1140f43 Fixup 2023-01-27 02:10:30 -08:00
Jarred Sumner
b136125bb0 [[bun hot]] More reliability improvements to macOS watcher 2023-01-27 01:56:07 -08:00
Jarred Sumner
1da7f5fe5d [bun --hot] Report exceptions in reloaded modules 2023-01-27 00:21:04 -08:00
Jarred Sumner
655c19b07c More reliable bun --hot on macOS 2023-01-27 00:15:56 -08:00
Jarred SUmner
ed5bcfc76b Another test 2023-01-26 23:21:10 -08:00
Jarred SUmner
421588d631 More reliable bun --hot on Linux 2023-01-26 23:04:37 -08:00
Jarred SUmner
915b46768c Remove usages of assumeSentinel 2023-01-26 23:04:37 -08:00
Jarred Sumner
7169bbbb9c Fixes #1907 2023-01-26 19:18:35 -08:00
Ciro Spaciari
6d06606135 Implement all pending resolve methods in DNS (#1903)
* initial steps to create generic resolve

* add soa

* add naptr

* add naptr

* add mx and fix naptr

* add resolve caa

* fix Caa test

* fix toJS from caa

* add resolveNs

* add resolvePtr

* fix resolvePtr test

* add resolveCname

* add resolve rrtype options (still missing ANY)

* fix Naptr

* fix drainPendingCares
2023-01-26 18:36:53 -08:00
Dylan Conway
44c6ce11c4 fix websocket hang (#1910)
* ref and deref, and some tests

* subprocess file

* remove deref

* use flag in test
2023-01-26 18:26:05 -08:00
Ciro Spaciari
b32b0b8736 fix large packages receive for WS client (#1909) 2023-01-26 15:08:34 -08:00
Jarred SUmner
fbe45fcb03 Fix branching on undefined 2023-01-26 05:20:53 -08:00
Jarred SUmner
2c23d8736f valgrind 2023-01-26 04:45:24 -08:00
Jarred SUmner
f14032e4b4 zig changes 2023-01-26 04:43:57 -08:00
Jarred Sumner
d912214719 Upgrade Mimalloc 2023-01-26 04:03:36 -08:00
Jarred Sumner
6c9e7de824 copy paste is harder to mess up than C macros 2023-01-26 04:02:21 -08:00
Alex Lam S.L
f8f989f667 parse package-spec from CLI correctly (#1895)
* parse package-spec from CLI correctly

fixes #861

* copy separately for `UpdateRequest.name`

fix GItHub URL reporting in results

update tests to reflect latest code changes

* better fix for GitHub URL display issue
2023-01-26 01:06:51 -08:00
Jarred Sumner
781df80a90 [bun install] Support verifying GitHub dependencies 2023-01-25 17:26:49 -08:00
Jarred Sumner
b26ff0074d [bun install] Include the resolved version for github dependencies in the hash 2023-01-25 17:26:09 -08:00
Jarred Sumner
0a8e42a4ba [bun install] For github dependencies, write a .bun-tag to mark the revision 2023-01-25 17:25:19 -08:00
Jarred Sumner
b767f9a99a Add a test 2023-01-25 13:43:23 -08:00
Jarred Sumner
f61ee1ed42 Fixes #1902 2023-01-25 13:42:31 -08:00
Jarred Sumner
a8743f0a34 Fix "failed to resolve" 2023-01-25 02:21:40 -08:00
Jarred Sumner
468226fc90 be more careful 2023-01-25 01:52:04 -08:00
Jarred Sumner
9cb1ec2c58 Undo 2023-01-25 01:10:15 -08:00
Jarred Sumner
0f2c9c9ff3 Fix "failed to resolve" bug 🫠 2023-01-25 01:09:42 -08:00
Jarred Sumner
ed2a57fcc9 Add log 2023-01-25 01:09:05 -08:00
Jarred Sumner
81b6878e1a Add assertion 2023-01-24 23:54:42 -08:00
Jarred Sumner
325ffd70e1 one less alloc 2023-01-24 23:53:03 -08:00
Jarred Sumner
d4ce045f9e More careful about the lifetime of alias 2023-01-24 23:51:48 -08:00
Jarred Sumner
7f65875406 Update base.zig 2023-01-24 23:51:02 -08:00
Jarred Sumner
ce38365106 assert defined in development 2023-01-24 23:50:35 -08:00
Jarred Sumner
a3cc911e7a get cache key for github in one pass 2023-01-24 22:27:06 -08:00
Sean Scally
ac7aff1b47 Add FileSystemRouter + React example (#1894) 2023-01-24 19:09:39 -08:00
Ashcon Partovi
d714df48f9 Add npm install -g bun to README 2023-01-24 12:42:37 -08:00
Ashcon Partovi
fb1902448e Add bunx to bin for npm installer 2023-01-24 12:04:35 -08:00
Alex Lam S.L
f43b675200 support GitHub URLs as dependencies (#1875) 2023-01-24 11:57:25 -08:00
Alex Lam S.L
e47fe2ca00 support bun link of scoped packages (#1892) 2023-01-24 11:52:47 -08:00
Ashcon Partovi
2edbf4d0ec Iterate on canary version again 2023-01-24 11:17:08 -08:00
Ashcon Partovi
645b7271f9 npm does not accept '+build' in releases :( 2023-01-24 10:31:04 -08:00
Ashcon Partovi
77c72b3193 Fix detection of canary 2023-01-24 10:06:58 -08:00
Ashcon Partovi
34f97be86a Copy .npmrc to each package 2023-01-24 09:59:58 -08:00
Ashcon Partovi
2ffe77140e Maybe fix .npmrc 2023-01-24 09:38:44 -08:00
Jarred Sumner
be79f6e893 Add failing test 2023-01-24 04:08:24 -08:00
Jarred Sumner
bb5119f7eb Add simple test for bun --hot 2023-01-24 03:30:27 -08:00
Jarred Sumner
6f682c6369 Use more specific function 2023-01-24 03:03:57 -08:00
Jarred Sumner
05b1ce39d2 Faster string length in napi 2023-01-24 03:03:44 -08:00
Jarred Sumner
6cf87d022f [napi] Clean up some string handling code 2023-01-24 02:59:51 -08:00
Jarred Sumner
6c3842f67d Update text-decoder.test.js 2023-01-24 02:31:53 -08:00
Jarred Sumner
63403741ff flaky 2023-01-24 02:31:45 -08:00
Jarred Sumner
66643a5b57 Try resolving against the path without the .js extension 2023-01-24 02:22:16 -08:00
Jarred Sumner
e2f709b2a5 Always allow importing ${package}/package.json 2023-01-24 02:21:43 -08:00
Jarred Sumner
4ea104f5bd Fix canary bug 2023-01-24 00:57:03 -08:00
Jarred Sumner
0fe7f7b6f0 Update README.md 2023-01-24 00:56:39 -08:00
Jarred Sumner
566a2c668b Sort families 2023-01-24 00:14:59 -08:00
Jarred Sumner
ad692495a1 Update class-definitions.ts 2023-01-24 00:14:59 -08:00
Jarred Sumner
2c31beda75 Fixes #1887 2023-01-24 00:14:59 -08:00
Ashcon Partovi
cd684fdad0 Tweak semver for canary again 2023-01-23 23:38:38 -08:00
Ashcon Partovi
ad40eec079 Fix ordering of github action command 2023-01-23 23:10:16 -08:00
Jarred Sumner
90d62ecc24 Add DOMJIT test 2023-01-23 23:08:31 -08:00
Ashcon Partovi
cab1f860e4 npm install bun (#1874)
* Add bun-npm package to publish and install Bun via npm

* Add newlines to patchJson

* Update version to latest release

* Tweak semver for canary

* Use GITHUB_TOKEN

* Prevent bun from being run in slow mode
2023-01-23 23:06:13 -08:00
Jarred Sumner
7ca867f7c8 3x faster Buffer.isBuffer 2023-01-23 22:34:04 -08:00
Jarred Sumner
fe03e90d80 Update build-id 2023-01-23 19:05:41 -08:00
Jarred Sumner
f992942391 Make Object.prototype.toString.call(new Buffer(0)) consistent with Node.js 2023-01-23 18:51:04 -08:00
Jarred Sumner
7420cb1d73 fix test failure in aarch64 and add test for simd code path 2023-01-23 18:03:48 -08:00
Dylan Conway
73961a1494 missing test 2023-01-23 17:39:40 -08:00
Jarred Sumner
d7b5e4b901 Update uws 2023-01-23 16:51:52 -08:00
Jarred Sumner
efc024cfc4 clean up deps 2023-01-23 16:51:48 -08:00
Ciro Spaciari
b3533fb3a8 fix(Buffer) Fix arguments in buffer.write, fix size returned from buffer.write for utf16, fix size calc for base64, fix calc for hex byte size (#1881)
* fix buffer write when more than 2 args are passed

* fix encoding parameter

* better buffer write tests

* fix ucs2/utf8 len return

* fix base64 size in Buffer write

* fix hex encoding size

* actual fix base64

* actual fix base64

* fix segfault

* add fill parameter in Buffer.alloc

* use createUnitialized when alloc have fill parameter, use RETURN_IF_EXCEPTION when static casting

* fix utf16le, ucs2 copying in Buffer write
2023-01-23 16:48:52 -08:00
Dylan Conway
79c0b614ee fix child process node test hang (#1884)
* fix test hang from skipped tests

* add error target
2023-01-23 15:59:45 -08:00
Dylan Conway
f5cda8ff18 fix constructor statement order (#1883)
* leave super alone

* more tests
2023-01-23 15:57:47 -08:00
Jarred Sumner
4570ff7780 [napi] Support defining properties with symbol as names 2023-01-23 15:09:23 -08:00
Jarred Sumner
aa456805dd [napi] Handle missing description in napi_create_symbol 2023-01-23 15:09:18 -08:00
Ciro Spaciari
efd33c398f enhancement(fetch): Merge parameters from request parameter with the second parameter for fetch, move verbose and proxy options to second parameter, add non-TLS tests for fetch (#1862)
* initial steps for proxy-server

* added http_proxy in fetch, move 3rd argument to 3nd argument options, add some non-TLS proxy tests

* some changes

* use only 1 buffer for url+proxy, merge headers on fetch

* initial steps

* change back to override headers instead of merging in fetch

* fix build response.zig

* fix conditional in merged headers on fetch

* updated with main and make proxy disabled if null is passed

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-01-23 14:38:40 -08:00
Jarred Sumner
9a2b586337 Update bench 2023-01-23 05:22:03 -08:00
Jarred Sumner
df999306c0 ✂️ duplicate code 2023-01-23 05:05:54 -08:00
Jarred Sumner
45296570ce Fix crash in DOMJIT call with empty input 2023-01-23 04:58:42 -08:00
Jarred Sumner
f9306ff815 Update transpiler.zig 2023-01-23 04:09:28 -08:00
Jarred Sumner
c530ead1e0 Add a comment 2023-01-23 04:06:01 -08:00
Jarred Sumner
f6227bf6dd Upgrade Bun.Transpiler to use new bindings 2023-01-23 04:03:01 -08:00
Jarred Sumner
4f84c6bc34 Prepare for plugins 2023-01-23 04:02:06 -08:00
Jarred Sumner
d141783ebd Sort the generated classes list 2023-01-23 04:01:45 -08:00
Jarred Sumner
d4ef935478 [bindings] Add custom field to enable writing one-off C++ in the zig class 2023-01-23 04:01:36 -08:00
Jarred Sumner
bf68df0070 fix unrefOnNextTick 2023-01-22 21:22:46 -08:00
Jarred Sumner
407088f6ab Add tests for async failure 2023-01-22 20:49:21 -08:00
Jarred Sumner
2cce810190 Add a test for zlib (thanks @jiaz) 2023-01-22 19:54:42 -08:00
Jarred Sumner
eaea08ea45 Add one gc test for eventemitter 2023-01-22 19:53:59 -08:00
Jarred Sumner
4dfc09018f [EventEmitter] Preserve this in event emitter callbacks 2023-01-22 19:52:51 -08:00
Jarred Sumner
771db64cbe [bun:sqlite] cleanup run 2023-01-22 19:35:32 -08:00
Jarred Sumner
c6b941d803 Add some more emitters to the benchmark 2023-01-22 19:11:04 -08:00
Jarred Sumner
3492248697 Fixes #1366 2023-01-22 19:09:52 -08:00
Jarred Sumner
bc7192dca1 Add extremely slow node:zlib polyfill 2023-01-22 15:34:21 -08:00
Jarred Sumner
188f472ed2 Update http.exports.js 2023-01-22 14:58:57 -08:00
Jarred Sumner
befd97a891 [node:http] Add address() and fix callback / options parsing 2023-01-22 14:58:22 -08:00
Ciro Spaciari
481dbf7c6e feat(dns) resolveSrv (#1870)
* initial steps

* in-progress resolveSrv support

* fix memory leak and ZigGlobalObject

* promise.resolve + fix priority and weight mistake

* fix node dns export

* little better test

* add poll_ref to keep alive loop in callback for resolveSrv and lookup

* add test for error case in resolveSrc

* fix Bun.dns.resolveSrv type
2023-01-22 14:31:08 -08:00
Jarred Sumner
8d692f1511 Update Makefile 2023-01-22 14:20:44 -08:00
Jarred Sumner
c08b546728 Allow very old CPUs to use Bun (~2008) 2023-01-22 14:20:25 -08:00
Jarred Sumner
fefa4a1623 Add a test for require with a query string 2023-01-22 03:24:42 -08:00
Jarred Sumner
043e408b15 cleanup execArgv a little 2023-01-22 03:24:32 -08:00
Jarred Sumner
9f6658b981 stub out process.stdin.setRawMode 2023-01-22 02:40:18 -08:00
Jarred Sumner
5ce2b8e604 Implement process.execArgv 2023-01-21 23:52:51 -08:00
Jarred Sumner
ee9893c4e1 Zig stdlib change 2023-01-21 23:13:19 -08:00
Jarred Sumner
8b0e2efd6e Bump zig 2023-01-21 23:13:04 -08:00
Jarred Sumner
4d1e977399 Update uws 2023-01-21 23:12:30 -08:00
Jarred Sumner
0ee13892fd Update buffer-create.mjs 2023-01-21 23:11:55 -08:00
Jarred Sumner
99d2d6e607 Support query string parameters in module resolution 2023-01-21 23:11:31 -08:00
Jarred Sumner
a2cfdf0e1c Refactor new Buffer to pass Node.js tests 2023-01-21 23:03:43 -08:00
Jarred Sumner
29a576a167 [Buffer] Add deprecated parent property 2023-01-21 22:55:56 -08:00
Jarred Sumner
6424ce6397 Update .gitignore 2023-01-21 20:54:31 -08:00
Jarred Sumner
fdb9472f88 Fix make headers 2023-01-21 19:42:21 -08:00
Jarred Sumner
17bde9bc86 Fix test failure due to UB 2023-01-21 15:36:51 -08:00
Alex Lam S.L
fd29d05c6a minor clean-ups (#1869)
- use `Lockfile.str()` more
- allow `child-process-stdio.test.js` to run with `bun-debug`
2023-01-21 14:02:22 -08:00
Jarred Sumner
f475802206 Update module_loader.zig 2023-01-21 13:14:02 -08:00
Alex Lam S.L
f0fa760479 [semver] parse ^ & ~ expressions correctly (#1854)
* [semver] parse `^` & `~` expressions correctly

* handle semver ranges correctly against build tags
2023-01-21 04:16:26 -08:00
Jarred Sumner
24e8aa105f Remove UB with semver.String
Thanks @MasterQ32
2023-01-21 04:11:57 -08:00
Jarred Sumner
ed421855d7 [buffer] Add faster path for Uint8Array 2023-01-21 04:06:06 -08:00
Jarred Sumner
627da44527 Handle string subclasses and new String() in new Buffer 2023-01-21 03:14:00 -08:00
Jarred Sumner
9955b74622 Make Buffer.alloc* 3ns faster 2023-01-21 03:13:45 -08:00
Jarred Sumner
d955bfe50f [buffer] Make Buffer.from pass more tests 2023-01-21 03:12:59 -08:00
Dylan Conway
b8648adf87 constructor parameter properties in class expressions (#1867) 2023-01-20 16:24:40 -08:00
Jarred Sumner
ff6fb587f6 Update transpiler.test.js 2023-01-20 04:12:03 -08:00
Jarred Sumner
e361ed4451 Update transpiler.test.js 2023-01-20 04:11:47 -08:00
Dylan Conway
42e9f6e0b1 push super before generated statements (#1856) 2023-01-20 03:25:21 -08:00
Jarred Sumner
e3ed905b0a Clear the errors 2023-01-20 02:19:23 -08:00
Jarred Sumner
224312c014 one less hash table 2023-01-20 02:19:14 -08:00
Jarred Sumner
bdf792adbc Add another test 2023-01-20 00:20:33 -08:00
Jarred Sumner
3c6616a23d fix hanging test 2023-01-20 00:07:11 -08:00
Jarred Sumner
ff7e984f0a Further cleanup buffer encoding 2023-01-20 00:06:46 -08:00
Jarred Sumner
3a100af876 Fixes #1855 2023-01-20 00:06:27 -08:00
Jarred Sumner
7d7b535014 Fix assertion failure with boringssl messages 2023-01-20 00:05:48 -08:00
Jarred Sumner
a98b1751a6 Revert "ignore sighup"
This reverts commit 03ab4be9ee.
2023-01-19 23:59:20 -08:00
Jarred Sumner
03ab4be9ee ignore sighup 2023-01-19 23:56:49 -08:00
Jarred Sumner
f993975ae6 make this code easier to read 2023-01-19 21:00:53 -08:00
Jarred Sumner
53f7bd32d8 Update types.zig 2023-01-19 20:34:06 -08:00
Jarred Sumner
784496b773 Bump 2023-01-19 20:32:38 -08:00
Jarred Sumner
4c0b0e2e8e Fix buffer encoding bug 2023-01-19 20:28:34 -08:00
Alex Lam S.L
bab7e63d7c use String.from() (#1850) 2023-01-19 19:26:10 -08:00
Jarred Sumner
3511a4b5be Bump zig 2023-01-19 19:09:25 -08:00
Jarred Sumner
e485f7bb51 make it packed 2023-01-19 19:05:29 -08:00
Jarred Sumner
795cde6d62 Bugfixes to install (#1848) 2023-01-20 04:55:22 +02:00
Alex Lam S.L
9dfbf57397 repopulate alias_map correctly (#1847) 2023-01-19 16:24:56 -08:00
Jarred Sumner
e04fe64a82 Add a comment 2023-01-19 16:19:15 -08:00
Jarred Sumner
495c70053f Add a debug safety check for UAF in AST nodes 2023-01-19 16:14:56 -08:00
Jarred Sumner
9bcd4952ce Fix UAF when opening workspaces 2023-01-19 16:14:40 -08:00
Jarred Sumner
8745f10cd3 Improve error message when a workspace is not found 2023-01-19 15:48:03 -08:00
Volodymyr Palamar
ac0dab3679 Create new example http-file-extended.ts (#1827)
New code sample with http Range and ETag support
Some code is taken from here https://github.com/gornostay25/svelte-adapter-bun/blob/master/src/sirv.js
2023-01-19 10:35:55 -08:00
Ciro Spaciari
01c97e4033 fix(fetch:HTTP_PROXY) fix support for HTTP_PROXY/HTTPS_PROXY and NO_PROXY in fetch instances (#1844)
* fix response.zig fetch

* use VM bundler env instead of DotEnv.instance

* remove unnecessary import
2023-01-19 10:34:32 -08:00
Alex Lam S.L
cd5f2ab11f parse dependency specifier correctly (#1840) 2023-01-19 06:39:01 -08:00
Alex Lam S.L
61736966ad fix stale references upon Lockfile tree cloning (#1845) 2023-01-19 06:38:08 -08:00
Alex Lam S.L
8bdcded5c1 fix memory reference issues (#1841) 2023-01-19 00:53:01 -08:00
Alex Lam S.L
c0ec61cf16 support npm dependency aliasing (#1837)
* support npm dependency aliasing

* fix variable name
2023-01-18 20:11:52 -08:00
Alex Lam S.L
d4e323b997 add fs.rmdir & friends (#1838) 2023-01-18 19:56:34 -08:00
Jarred Sumner
58cbd6b211 Regenerate lockb 2023-01-18 16:51:18 -08:00
Colin McDonnell
d8d148e3bb Fix/simplify bun-types release (#1836)
* Simplify types release

* Further simplify

Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
2023-01-18 16:22:01 -08:00
Jarred Sumner
311185f6d6 Add a test for #1831 2023-01-18 15:00:00 -08:00
Jarred Sumner
7012d2fb74 Fixes #1831 2023-01-18 14:59:39 -08:00
Jarred Sumner
2db04ef9d9 Fix crash with invalid arguments in readdir() 2023-01-18 01:16:13 -08:00
Jarred Sumner
4cb6a34432 Don't report end() because it is inherently flaky 2023-01-18 00:28:53 -08:00
Jarred Sumner
2016e8a0af micro-optimize loading process environment variables 2023-01-18 00:28:19 -08:00
Jarred Sumner
0759530118 opposite 2023-01-18 00:24:52 -08:00
Jarred Sumner
5ed46913c4 Update node-net.test.ts 2023-01-18 00:17:11 -08:00
Jarred Sumner
bd5b90fbf1 Fix lifetime issue in require.resolve 2023-01-17 23:41:17 -08:00
Colin McDonnell
bba4054da3 Use canary in CI (#1823)
* Use canary in CI

* Only publish canary when types change

Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
2023-01-17 23:06:26 -08:00
华晨
d16951422b remove redundant allowSyntheticDefaultImports (#1802) 2023-01-17 21:01:55 -08:00
Jarred Sumner
e0eeb1c07e workaround lifetime issue 2023-01-17 20:10:19 -08:00
Ashcon Partovi
216e872801 Add Bun.dns to the README 2023-01-17 18:17:12 -08:00
Ashcon Partovi
6fbf437f50 Fix Bun.dns examples to use array instead of single result 2023-01-17 18:12:49 -08:00
Ciro Spaciari
c00fadab9e feat(cli): Support HTTPS_PROXY, HTTP_PROXY, and NO_PROXY #1440 (#1814)
* WIP: http_proxy implemented, first steps for https_proxy #1440

* add HTTP_PROXY support to upgrade_command and WIP: tunneling

* WIP async handshake, stuck on WANT_READ, try to defer  + check

* create and upgrade with proxy working, TLS and non-TLS to proxy TLS working

* bun install/upgrade/create working with http(s)_proxy #1440

* add NO_PROXY support #1440

* remove commented code and add TODO

* fix getHttpProxy no_proxy

* fix formatting

* refactor catch and getHttpProxy, fix empty strngs in env for proxy

* allow optimization for handleResponseBody
2023-01-17 17:47:01 -08:00
Jarred Sumner
9b260fb18b Allow error instance in process.emitWarning 2023-01-17 17:11:08 -08:00
Colin McDonnell
b931c19ba3 Add types for readline, tls, net (#1817)
* Add readline, tls, net types

* Remove unimplemented methods

Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
2023-01-17 16:49:18 -08:00
Jarred Sumner
9e403fc8bf cleanup error message 2023-01-17 16:47:45 -08:00
Jarred Sumner
fd0edd7aa0 [process] Implement process.emitWarning 2023-01-17 16:29:08 -08:00
Jarred Sumner
848658c533 [test] Add helper for bun env 2023-01-17 16:28:49 -08:00
Jarred Sumner
37d2a98331 Update logger.zig 2023-01-17 16:27:52 -08:00
Jarred Sumner
58d1ab02bd [canary] Fix missing .env log 2023-01-17 16:27:48 -08:00
Jarred Sumner
9f0d402a7d [EventEmitter] Fix emitter.off("eventName") 2023-01-17 16:27:21 -08:00
Jarred Sumner
f927567b9f bun install tests shouldn't fail due to terminal colors 2023-01-17 16:00:21 -08:00
Derrick Farris
94ea41a60b fix(readline/promises): new Interface() -> new PromisesInterface() (#1818) 2023-01-17 15:45:15 -08:00
Dylan Conway
8235e59a7f set available 2023-01-17 15:36:19 -08:00
Jarred Sumner
8924c521ba // flaky 2023-01-17 14:00:10 -08:00
Jarred Sumner
69875d86cd Fix console.log printing multiple properties 2023-01-17 13:44:13 -08:00
Jarred Sumner
5bdc923838 dont export twice 2023-01-17 12:53:28 -08:00
Jarred Sumner
25a2962186 Expose tls.connect 2023-01-17 12:52:49 -08:00
Jarred Sumner
c943dbadef Update crypto-hasher.mjs 2023-01-17 12:52:33 -08:00
Jarred Sumner
aacaa9b85d Bun v0.5.0 2023-01-17 00:43:56 -08:00
Jarred Sumner
74992f6f34 make node-redis work 2023-01-17 00:09:04 -08:00
Dylan Conway
12b8416b64 send and disconnect 2023-01-16 23:44:09 -08:00
Jarred Sumner
8a5ff676ea Bump zig 2023-01-16 23:21:52 -08:00
Jarred Sumner
f660f8d22f Make sure the socket keeps the process alive 2023-01-16 21:43:48 -08:00
Jarred Sumner
38cc947621 Don't need to skip these now 2023-01-16 21:42:52 -08:00
Jarred Sumner
0546aa4fd5 Make entire test line dim 2023-01-16 21:37:12 -08:00
Jarred Sumner
b8b7ad4982 [bun:test] Fix dim, fix missing space 2023-01-16 21:35:19 -08:00
Dylan Conway
d21119b347 remove onClose 2023-01-16 21:20:54 -08:00
Jarred Sumner
d3de366c67 Fix some reliability issues with net.connect and Bun.connect on macOS 2023-01-16 21:14:38 -08:00
Jarred Sumner
a1b581621c guess we'll check if it's defined 2023-01-16 20:33:31 -08:00
Jarred Sumner
274ae5de1b [bun install] Make it print workspace: instead of workspace:// 2023-01-16 18:57:04 -08:00
Jarred Sumner
74b0a1939d Fixes https://github.com/oven-sh/bun/issues/1654 2023-01-16 17:48:35 -08:00
Jarred Sumner
6f432e8b7d Remove assertion 2023-01-16 17:38:04 -08:00
Jarred Sumner
a5f7a23307 Update node-dns.exports.js 2023-01-16 17:12:23 -08:00
Jarred Sumner
88a8614abc [node:dns/promises] Fix missing import 2023-01-16 17:11:00 -08:00
Jarred Sumner
b23327c283 [node] Add process.config 2023-01-16 16:47:08 -08:00
Jarred Sumner
c83d56c75d Update c-bindings.cpp 2023-01-16 16:30:33 -08:00
Jarred Sumner
7dd28bbdd9 Fix which returning directories sometimes 2023-01-16 16:28:02 -08:00
Jarred Sumner
d54e23ca33 [napi] Fix potential crash in napi_create_buffer_copy, napi_create_buffer 2023-01-16 15:48:14 -08:00
Jarred Sumner
02f0212cbd [napi] Don't assume function exists
Fixes https://github.com/oven-sh/bun/issues/1808
2023-01-16 15:47:44 -08:00
Jarred Sumner
3484502839 [JS Parser] Don't inline rope strings 2023-01-16 15:21:11 -08:00
Jarred Sumner
a345efd270 Fix getFdPath when /proc/fd is not mounted 2023-01-16 13:59:52 -08:00
Jarred Sumner
30bfb31bce wip 2023-01-16 12:59:48 -08:00
Jarred Sumner
eef0e8c6bf Fix incorrect type 2023-01-16 12:56:16 -08:00
Jarred Sumner
4648131c41 Add missing buffer module exports 2023-01-16 12:49:57 -08:00
Colin McDonnell
b0702ce7b1 Publish bun-types@canary (#1767)
* Publish bun-types@canary

* Get version from bun cli

* Get version from bun cli

* Fixes

* Fixes

* Fixes

* Finalize

* Update names

* Add token

* Remove dryrun

* Switch setup-bun

* Test noncanary publish

* Fix path for GPR

* Use latest

* Remove testing code

* Remove dry run

* Fix paths

* Update bun-types links

* Verbose logging

* Ignore lockfile

* Run install in root

* Remove debug code

* Remove debug code

Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
2023-01-16 11:58:57 -08:00
Jarred Sumner
ff3f5aa154 Don't open non-blocking on Linux 2023-01-16 11:22:54 -08:00
Jarred Sumner
91bcfa9cb4 Clean up the test 2023-01-16 11:22:54 -08:00
Jarred Sumner
cf5f9df211 Use a reusable symbol 2023-01-16 11:22:54 -08:00
Alex Lam S.L
9eb4a4ff3a [Response] reject HTTP status code correctly (#1800) 2023-01-15 03:21:34 -08:00
Alex Lam S.L
7932a55870 fix handler reset in Server.reload() (#1801) 2023-01-15 03:19:37 -08:00
Alex Lam S.L
893ec2fb45 fix life-cycle script execution (#1799)
- change current working directory for workspaces
- add `node_modules/.bin` to `PATH` before running
2023-01-14 21:37:16 -08:00
Alex Lam S.L
136014b13a fix bugs (#1795)
- segfault reading stacktrace from `fs/promises` rejections
- `Promise` rejection within `describe()` ends testing abruptly
- `FSSink.write()` incorrectly handles `objectMode`
- `FSSink.write()` throws wrong error codes
2023-01-14 16:50:55 -08:00
Jarred Sumner
d01ec47529 Fixes #1794 2023-01-14 16:37:16 -08:00
Alex Lam S.L
7fa023b8b5 support installation of NPM workspaces (#1764) 2023-01-14 07:14:48 -08:00
Jarred Sumner
aa9e56edfe [bun:test] Always dim skip 2023-01-13 13:13:01 -08:00
Jarred Sumner
88ffdc5fec [TypeScript transpiler] Fix bug with export default class implements 2023-01-13 12:48:10 -08:00
Jarred Sumner
fab42148e4 Skip failing tests 2023-01-13 11:58:44 -08:00
Jarred Sumner
cce380ec37 Fix broken test helper 2023-01-13 11:57:22 -08:00
Jarred SUmner
828fd0cfea Fix debug mode crash 2023-01-13 11:55:46 -08:00
Jarred SUmner
168bb1427f move more things 2023-01-13 11:38:16 -08:00
Jarred SUmner
996ef44c02 Split some things into more files and use bun namespace instead of import more 2023-01-13 11:27:16 -08:00
Jarred Sumner
734b5b89da Add closeActiveConnections option to types 2023-01-12 19:38:27 -08:00
Jarred Sumner
490814aa35 Update serve.test.ts 2023-01-12 19:38:27 -08:00
Jarred Sumner
ffa8913e54 Update tcp-server.test.ts 2023-01-12 19:38:27 -08:00
Jarred Sumner
73e9cd8e06 [Bun.listen] Add flag to close all connections 2023-01-12 19:38:27 -08:00
Jarred Sumner
62cab3c719 [Bun.serve] Add flag to close all connections 2023-01-12 19:38:27 -08:00
Jarred Sumner
d4f1d29393 Fix https websockets 2023-01-12 19:38:27 -08:00
Jarred Sumner
2eac47a123 Upgrade uSockets 2023-01-12 19:38:27 -08:00
Dylan Conway
32f8cb31be set remaining indexes (#1785) 2023-01-12 18:44:45 -08:00
Dylan Conway
297732bbb3 0 initialize remaining indexes in array (#1783)
* 0 initialize remaining indexes in array

* switch to memset
2023-01-12 17:53:58 -08:00
Jarred Sumner
90be254373 fix missing error page 2023-01-12 16:26:25 -08:00
Jarred Sumner
034dd3d03d make the test more resilient 2023-01-12 16:06:28 -08:00
Jarred Sumner
0384d3c558 less flaky 2023-01-12 15:37:03 -08:00
Dylan Conway
00773e15f1 reset string decoder on end (#1782) 2023-01-12 15:13:05 -08:00
Jarred Sumner
126809f20c Add missing type 2023-01-12 15:08:32 -08:00
Dylan Conway
fbe3f5dfb3 pointer type 2023-01-12 13:59:27 -08:00
Jarred Sumner
29b4c84b8c woops 2023-01-12 13:28:10 -08:00
Jarred Sumner
38f9bb96df use .skip() for failing test 2023-01-12 13:20:10 -08:00
Jarred Sumner
6e0ec3248f Add c-ares to make clean 2023-01-12 13:11:05 -08:00
Jarred Sumner
35d0cf910d Uncomment flaky test 2023-01-12 13:11:05 -08:00
Jarred Sumner
5cb84231b2 Reduce amount of cloning 2023-01-12 13:11:05 -08:00
Jarred Sumner
bbd4504954 Add a couple more tests for errors with Bun.file() 2023-01-12 13:11:05 -08:00
Jarred Sumner
a0b44e9873 more careful 2023-01-12 13:11:05 -08:00
Jarred Sumner
90c395bdac Update inspect.test.js 2023-01-12 13:11:05 -08:00
Jarred Sumner
c2b7cadd4f [bindings] Make isObject align with JSC::isObjectType 2023-01-12 13:11:05 -08:00
Jarred Sumner
1a4685213b [bun:test] Support async in expect(async () => { await 1; }).toThrow() 2023-01-12 13:11:05 -08:00
Ethan Burrell
76e6a178e3 fix(bun-test): test title in results (#1753)
* fix(bun-test): test title in results

* missed case

* clean up import

* respond to reviews
2023-01-12 12:49:36 -08:00
Jarred Sumner
bb5efb67ab Update socket.test.ts 2023-01-12 12:08:11 -08:00
Jarred Sumner
4bac561184 missing 2023-01-12 12:07:52 -08:00
Jarred Sumner
edf9757650 Fixes #1772 2023-01-12 10:14:35 -08:00
Jarred Sumner
e65def0f82 Remove extra wrapper 2023-01-11 20:21:41 -08:00
Jarred Sumner
7970704222 end callback 2023-01-11 20:21:41 -08:00
Jarred Sumner
ced3226ffb Update ImportMetaObject.cpp 2023-01-11 20:21:41 -08:00
Jarred SUmner
1c20e05d70 [Bun.serve] Introduce publishToSelf boolean on websocket: {} config object 2023-01-11 17:14:07 -08:00
Colin McDonnell
4969f068f6 Types update (#1761)
* Fix type tests

* Add dns types

* Add node:net types

* Make process.exit return never

* Make ArrayBufferView tighter

* Add types for node:dns

* Remove docs

* Use latest

* Fix CI

* Fix CI

* Stop double trigger

Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
2023-01-11 14:56:41 -08:00
Jarred Sumner
4a1470d26c require.resolve in the runtime should use CommonJS export conditions 2023-01-11 14:22:31 -08:00
Jarred Sumner
5a3b634982 [breaking] Read the "node" export condition in package.json in Bun's runtime 2023-01-11 14:21:45 -08:00
Jarred Sumner
520ecc21ac [node:net] Hopefully fix unix sockets 2023-01-11 13:58:25 -08:00
Jarred Sumner
8911c398d9 Support socketPath 2023-01-10 20:39:11 -08:00
Jarred Sumner
1738588f38 potentially support tls in some cases 2023-01-10 19:39:34 -08:00
Jarred Sumner
5e60a9363f [node:tls] Stub out just enough to make it load 2023-01-10 19:29:27 -08:00
Jarred Sumner
cd20a84f18 Disable reading the browser field when targeting Bun's runtime (#1763)
* Fix flipped order

* Disable reading `"browser"` field when targeting Bun's runtime in the resolver

* Update resolver.zig

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-01-10 19:09:53 -08:00
Jarred Sumner
e07dd6194a make it size_t 2023-01-10 19:06:53 -08:00
Jarred Sumner
bcabf31121 Make Buffer mockable 2023-01-10 18:49:26 -08:00
Jarred Sumner
5cb6890fad Fix flipped order 2023-01-10 18:49:26 -08:00
Malcolm Still
f1e6ea2254 Implement Buffer swap16, swap32, swap64 (#1659)
* Implement Buffer swap16, swap32, swap64

* Initial incorporation of feedback

- Use constexpr
- Clean up the indexing
- Check for detached
- Use suggested text for exception text
2023-01-10 18:43:58 -08:00
Jarred Sumner
56a6cf716e [TCPSocket] Add a log for write() 2023-01-10 17:16:42 -08:00
Jarred Sumner
3517ce8e23 Add two tests for fs/promises 2023-01-10 17:16:16 -08:00
Jarred Sumner
3c525b4962 Fix fs:promises 2023-01-10 17:16:08 -08:00
Jarred Sumner
e945be72b4 Add some missing types 2023-01-10 14:36:00 -08:00
Jarred Sumner
3002a7e14f don't call add_server-name if len is not >0 2023-01-10 11:56:02 -08:00
Jarred Sumner
c18165b30f Allow tls: true in Bun.connect 2023-01-10 11:55:42 -08:00
Jarred Sumner
e18863df1b attempt (unsuccessfully) to improve c++ build time 2023-01-10 10:23:11 -08:00
Jarred Sumner
41f23273b0 [js parser] Do not inline regexp literals 2023-01-10 10:23:11 -08:00
Jarred Sumner
e62a422c14 Fix circular dependency in make headers 2023-01-10 10:23:11 -08:00
Jarred Sumner
91f7e6c66d Changes from upgrading webkit 2023-01-10 10:23:11 -08:00
Jarred Sumner
946424cf86 buffer.toString(undefined) should be UTF-8 2023-01-10 10:23:11 -08:00
Alex Lam S.L
270b07e85e use strings.hasPrefixComptime() (#1755) 2023-01-10 05:35:20 -08:00
Jiaji Zhou
b458abedbb Fix missing c-ares dep in dev build (#1754) 2023-01-10 04:51:01 -08:00
Derrick Farris
4ef60da8a9 refactor(readline/promises): re-export readline.promises from readline (#1748)
* refactor(readline/promises): re-export readline.promises from readline/promises

* fix(readline): don't export Readline from `readline`

* perf(readline): return Promise.reject immediately after failed validation
2023-01-09 16:27:56 -08:00
Jarred Sumner
0e7f69f179 Update child_process-node.test.js 2023-01-09 10:37:02 -08:00
Jarred Sumner
84ee02cb4b Update test_command.zig 2023-01-09 10:33:39 -08:00
Jarred Sumner
7a92bf87c8 Add very simple dns test 2023-01-09 10:12:46 -08:00
Jarred Sumner
55c1311aef fixup 2023-01-09 09:42:09 -08:00
Jarred Sumner
beed35e55e Update test_command.zig 2023-01-09 09:40:54 -08:00
Jarred Sumner
5cd37e5e8a Rename 2023-01-09 09:40:46 -08:00
Jarred Sumner
1761379135 Update test_command.zig 2023-01-09 09:13:23 -08:00
Jarred Sumner
30b10d5fb1 [bun:test] Implement test.root configuration option 2023-01-09 08:28:37 -08:00
Jarred Sumner
ca58556c54 Fix frozen IO stuff 2023-01-09 08:26:20 -08:00
Jarred Sumner
a1b2c23671 [bun:test] Implement test.skip 2023-01-09 08:25:39 -08:00
Jarred Sumner
5d60aae3b3 [dns] Fix UAF 2023-01-09 08:21:05 -08:00
Jarred Sumner
2392e48e9d Fixes https://github.com/oven-sh/bun/issues/1533 2023-01-09 03:41:03 -08:00
Jarred Sumner
3386afc0bc Add test for Bun.listen throwing 2023-01-09 03:26:16 -08:00
Jarred Sumner
1a1014525b Make autotick logic more consistent 2023-01-09 03:25:57 -08:00
Jarred Sumner
c30a110641 Cleanup code in expectToThrow 2023-01-09 03:25:41 -08:00
Jarred Sumner
ced6201cb0 Cleanup error handling in Bun.listen 2023-01-09 03:25:06 -08:00
Jarred Sumner
905a3313b5 check for isEmpty or !isCell 2023-01-09 03:18:41 -08:00
Jarred Sumner
f0475e89c5 Handle 0 in isCell 2023-01-09 02:28:14 -08:00
Jarred Sumner
cb75b4799f Add test for expect().toThrow 2023-01-09 00:22:54 -08:00
Jarred Sumner
5f1150442a Revert "lazily create buffer/string slices (#1735)"
This reverts commit e2ed31b7e7.
2023-01-08 23:53:31 -08:00
alexlamsl
94b6ab02c2 fix string encoding detection 2023-01-09 01:08:24 +02:00
Jarred Sumner
631181a503 Add welcome page when viewed from a browser 2023-01-08 07:37:51 -08:00
Jarred Sumner
83a5c9f3da [internal] Fix checking for Error object 2023-01-08 07:37:51 -08:00
Jarred Sumner
791f8ab0a1 [internal] Regenerate code 2023-01-08 07:37:51 -08:00
Jarred Sumner
da11bb4a82 [internal] Fix type casting in Zig bindings 2023-01-08 07:37:51 -08:00
Derrick Farris
94409770de feat(node:readline): add node:readline and node:readline/promises (#1738)
* feat(readline): WIP: add readline

* test(helpers): add deepStrictEqual helper

* feat(readline): add readline & readline/promises to loader

* fix(node:events): emit newListener on new listener added

* feat(readline): finish readline cb interface, add tests

* fix(stream): fix Transform.end()

* fix(node-test-helpers): correct throws behavior, improve how all asserts work

* feat(readline/promises): add readline/promises

* feat(assert): add assert.match

* test(readline): uncomment more tests

* fix(readline): MaxCeil -> MathCeil 🤦

* fix(readline): export promises from node:readline

* fix(readline): temp fix for circular dependency

* cleanup(readline): remove console.log

* fix(readline): change true -> 0 for CommonJS export

* perf(readline): micro-optimizations with some getters

* perf(readline): lazy load isWritable

* cleanup(readline): rename debug flag env var to BUN_JS_DEBUG
2023-01-08 01:49:49 -08:00
Jarred Sumner
c505f172b8 Add napi to process.versions 2023-01-08 01:11:23 -08:00
Jarred Sumner
9972e553a0 Update process.versions 2023-01-08 00:50:38 -08:00
Jarred Sumner
cdbdc55cbf We don't statically link iconv 2023-01-08 00:12:24 -08:00
Jarred Sumner
3f472bd511 cleanup 2023-01-08 00:10:02 -08:00
Jarred Sumner
4eb3067ef5 Workaround macOS issue 2023-01-07 23:58:25 -08:00
Jarred Sumner
3c8701362b Document connectError 2023-01-07 23:47:08 -08:00
Jarred Sumner
fadd1c0152 [Bun.connect] Fix bug where connect() Promise wouldn't reject on a connection error 2023-01-07 23:45:43 -08:00
Jarred Sumner
1e19d59273 Update uws 2023-01-07 23:45:43 -08:00
Jarred SUmner
cfd42c3999 Linux build 2023-01-07 21:48:31 -08:00
Jarred SUmner
98010efefc Change error 2023-01-07 21:41:07 -08:00
Jarred SUmner
020f49dcd6 Return ENOTFOUND instead of ENOTERROR 2023-01-07 21:05:34 -08:00
Jarred SUmner
1e841a7881 Fix segfault on Linux when getaddrinfo returns an error\nSee https://github.com/ziglang/zig/pull/14242 2023-01-07 21:05:34 -08:00
Jarred Sumner
b0d1cc1df7 Mark more things as only mac 2023-01-07 19:55:51 -08:00
Jarred Sumner
0a835ba963 Don't include this symbol on linux 2023-01-07 19:48:49 -08:00
Jarred Sumner
2b1b897375 very simple node:dns implementation
completely untested
2023-01-07 07:59:36 -08:00
Jarred Sumner
87983464d8 Implement DNS module (#1691)
* Boilerplate for DNS stuff

* Add c-ares

* lookup

* make

* Implement dns.lookup

* Create c-ares

* wip

* normalize

* repro

* Revert "repro"

This reverts commit 8b93e0c295b335b8882a9601da47720348549beb.

* Implement macOS `getaddrinfo_async_start`

* embiggen

* Update string_immutable.zig

* Update Makefile

* alright

* Update .gitignore

* Add types

* more ccache

* Update Dockerfile

* Update Dockerfile

* Update Dockerfile

* Update bun.d.ts

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-01-07 07:09:48 -08:00
alexlamsl
d5565ab2cd test BufferList against surrogate pairs 2023-01-07 12:39:32 +02:00
Jarred Sumner
8dc811e4aa Add missing null check
Fixes https://github.com/oven-sh/bun/issues/1739

probably
2023-01-06 16:41:34 -08:00
Ikko Eltociear Ashimine
1e1c817603 fix typo in install.sh (#1737)
infomation -> information
2023-01-06 10:15:32 -08:00
Alex Lam S.L
e2ed31b7e7 lazily create buffer/string slices (#1735) 2023-01-05 19:43:33 -08:00
Jarred Sumner
a7d9f16107 Report unhandled promise rejection on exit and make exit code 1 instead of 0 (#1734)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-01-05 16:23:45 -08:00
Jarred Sumner
bbbb4835b4 always report rejected promises 2023-01-05 15:08:06 -08:00
Jarred Sumner
f191993c8f Clean up some napi code 2023-01-05 14:49:41 -08:00
Jarred Sumner
994e58b5ea napi_boolean -> napi_number 2023-01-05 14:40:45 -08:00
Jarred Sumner
59639ba654 Fixes #1733 2023-01-05 14:06:27 -08:00
Alex Lam S.L
d22e3ebf9a [socket] fix double-free in finalize() (#1731)
- tidy up `.isEmptyOrUndefinedOrNull()` usage
2023-01-05 13:17:15 -08:00
Jarred Sumner
0873a15a63 Bump 2023-01-05 05:09:34 -08:00
Alex Lam S.L
20718b972e fix onConnectError() error propagation (#1730)
* fix `onConnectError()` error propagation
suppress extraneous logging messages

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

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-01-05 03:31:01 -08:00
Jarred Sumner
a951859c55 Update tcp-echo.bun.ts 2023-01-05 01:38:36 -08:00
Jarred Sumner
3005d9e348 Really fix #1722 2023-01-05 00:24:53 -08:00
Alex Lam S.L
7f96f72d65 improve .toThrow() compatibility with Jest (#1728) 2023-01-05 00:15:04 -08:00
u9g
7550658fab Fix Bun.serve typings (#1714) 2023-01-04 23:54:17 -08:00
Alex Lam S.L
80736043d6 implement expect().toThrow() (#1727)
- fix bugs in `JSBufferList`
- add tests
2023-01-04 22:37:14 -08:00
Jarred Sumner
3b259211df Add SharedBuffer from WebKit to make it easier to import more WebCore stuff 2023-01-04 18:55:16 -08:00
Jarred Sumner
6b777c4b0b Fix default export for stream
cc @alexlamsl
2023-01-04 18:55:16 -08:00
Jarred Sumner
81a6aef771 Fixes #1722 2023-01-04 18:55:16 -08:00
Jarred Sumner
f41bb3fb20 split server/client for tcp echo benchmark to better measure net.Socket perf 2023-01-04 18:55:16 -08:00
Alex Lam S.L
e0557d70e3 buffer list clean-ups (#1721) 2023-01-04 15:32:39 -08:00
Jarred Sumner
e2231f15e8 Support non-classes in node:net (#1712)
* Support non-classes

* Update net.exports.js

* Make it less observable

* Update net.exports.js

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-01-04 04:06:24 -08:00
Jarred Sumner
a19c7b4304 Fixes #1716 2023-01-04 03:46:56 -08:00
Jarred Sumner
4a328609b9 10x faster new Buffer (#1717)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-01-04 03:30:15 -08:00
Jarred Sumner
021331f154 Update README.md 2023-01-03 20:17:22 -08:00
Jarred Sumner
647093ff73 Add sqlite to vendor 2023-01-03 20:15:57 -08:00
Jarred Sumner
7df50add99 Fixes https://github.com/oven-sh/bun/issues/1695 2023-01-03 19:34:58 -08:00
Jarred Sumner
c99059db9f Remove usages of std.x 2023-01-03 18:53:40 -08:00
Alex Lam S.L
237bcdf99f [streams] speed up Readable in some cases (#1708)
If `encoding` is set, no `Buffer`s would be exposed thus `Uint8Array` can be used directly.

- fix data corruption in `BufferList.concat()`
- fix segfaults in `BufferList.join()`
2023-01-03 16:08:28 -08:00
Jarred Sumner
0b395ca1dc Fix crash in BufferList 2023-01-03 13:47:05 -08:00
Jarred Sumner
c1fd06c56d Create readme.md 2023-01-03 13:11:44 -08:00
Jarred Sumner
f79301c620 Implement napi_make_callback 2023-01-03 12:36:56 -08:00
Jarred Sumner
4ae33cbf45 Stub out missing napi functions and include error message 2023-01-03 10:55:13 -08:00
Jarred Sumner
59655d0587 Fix spec issue with napi_get_typedarray_info 2023-01-03 10:32:22 -08:00
Alex Lam S.L
7edaf736a2 [socket] handle connectError (#1705)
assorted clean-ups & fixes
2023-01-02 23:06:45 -08:00
Jarred Sumner
c770db7d52 make it work with homebrew zig 2023-01-02 22:06:52 -08:00
Jarred Sumner
cbc015d8d8 [internal] allow using zig from more directories 2023-01-02 21:26:02 -08:00
Alex Lam S.L
18e143ae7b fix double resolve() in test (#1707)
also clean up `reject()` values
2023-01-02 20:19:44 -08:00
Jarred Sumner
8989a1883e Support any ArrayBufferView in StringDecoder 2023-01-02 15:39:44 -08:00
Alex Lam S.L
983b747020 implement net.Socket (#1701)
- support TCP sockets for now, i.e. no IPC
- extra features like keep-alive, no-delay etc. are absent due to limitations of uSockets
- fix `jest` to treat `done(nullish)` as success
2023-01-02 14:55:01 -08:00
Jarred Sumner
1ba95a65ee Make the error message for unsupported dependency type a little clearer 2023-01-02 14:52:35 -08:00
Jarred Sumner
54b8cbd972 Add buffer creation snippet 2023-01-02 14:52:06 -08:00
Jarred Sumner
4eb9e8bb5a update node echo bench 2023-01-02 13:23:08 -08:00
Jarred Sumner
80c2da73ef Upgrade simdutf
Thanks @lemire
2023-01-02 12:48:44 -08:00
Jarred Sumner
4ba564dbf1 More instructions 2023-01-02 11:50:47 -08:00
Jarred Sumner
5fc8bc8f04 Update macOS instructions 2023-01-02 11:37:50 -08:00
Jarred Sumner
9fd3b5587b Auto-install and link webkit 2023-01-02 11:29:22 -08:00
Alex Lam S.L
04b00229cf fix lingering process by dead sockets (#1700)
`Bun.listen()` and `Bun.connect()` would create sockets that under certain conditions with calls to `.end()` or `.stop`,  prevents the process from exiting gracefully.
2023-01-02 02:24:23 -08:00
Alex Lam S.L
8a29c64302 clean up Promise handling (#1697) 2023-01-01 16:37:45 -08:00
Jarred Sumner
2345e268bc Fix bun --cwd after https://github.com/ziglang/zig/pull/13596 2023-01-01 13:34:50 -08:00
Jarred Sumner
97066d034d Add workaround 2023-01-01 12:37:00 -08:00
Jarred Sumner
5f24c8a4a8 Bump 2023-01-01 12:04:55 -08:00
Jarred Sumner
96438a4d58 test crypto.randomBytes returns a Buffer 2023-01-01 12:04:49 -08:00
Jarred SUmner
5b3cf8bec5 Handle extremely unlikely edgecase 2023-01-01 07:21:08 -08:00
Jarred SUmner
c02b921983 Fix linux build issue 2023-01-01 07:20:35 -08:00
Jarred SUmner
0b0aadfc5f Make asPromise() and asInternalPromise() safer, but slower 2023-01-01 07:20:16 -08:00
Jarred Sumner
905aff3cfc Update bindings.zig 2023-01-01 02:19:34 -08:00
Jarred Sumner
9e6d39bae6 [internal] Add more bindings 2023-01-01 02:19:11 -08:00
Jarred Sumner
f651f74f9d Add a test for empty chunks 2023-01-01 01:33:13 -08:00
Jarred Sumner
01b908ad64 Workaround https://github.com/ziglang/zig/issues/14148 2023-01-01 01:32:40 -08:00
Gabriel Wu
8a2729e75f Update ffi.d.ts (#1694)
* Update ffi.d.ts

Add "usize" and "callback", which are used in `README` but not typed here.

* Update packages/bun-types/ffi.d.ts

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2022-12-31 23:03:45 -08:00
Alex Lam S.L
9b3db96308 [jest] fix and improve hooks (#1689)
- wait for async hooks to complete before running tests
- add support for `done(err)` callbacks in hooks

fixes #1688
2022-12-31 03:14:23 -08:00
Jarred Sumner
b86915c808 [internal] Add flag to build bun for editor error reporting 2022-12-30 22:37:28 -08:00
Jarred Sumner
be706fecb4 Make NamesIterator safer 2022-12-30 21:30:23 -08:00
Jarred Sumner
2e94d1a033 Statically link libatomic 2022-12-30 20:27:01 -08:00
Jarred Sumner
fc6c4bbefb Upgrade WebKit 2022-12-30 06:33:22 -08:00
Jarred Sumner
2fc6913085 More assertions 2022-12-30 04:46:52 -08:00
Jarred Sumner
f444e628ca Don't use zig's memcpy function
It is very slow
2022-12-30 04:46:52 -08:00
Jarred Sumner
42be4e52fe Use ArrayBitSet that passes by reference instead of value 2022-12-30 04:46:52 -08:00
Jarred Sumner
385c81d67b Fix crash with bun install <foo> 2022-12-30 04:46:52 -08:00
Jarred SUmner
8b0a7b9fb8 Set CLOXEC 2022-12-29 21:53:04 -08:00
Jarred SUmner
2c5e1cb7d7 Fix broken hardlink installs 2022-12-29 21:46:32 -08:00
Jarred SUmner
7be1e85c6d Fix OOB when deinit'ing dir walker 2022-12-29 21:46:15 -08:00
Jarred Sumner
4cc9a43089 Update globals.d.ts 2022-12-29 06:18:38 -08:00
Jarred Sumner
01c81a5f57 [node:crypto] 50x faster createHash 2022-12-29 06:05:43 -08:00
Jarred Sumner
85eda20587 Introduce Bun.CryptoHasher 2022-12-29 06:05:43 -08:00
Jarred Sumner
940ecd05a8 [node] Implement process.uptime and process.umask 2022-12-29 06:05:43 -08:00
Jarred Sumner
7c8a196c76 [bun-types] Add missing performance.timeOrigin type 2022-12-29 06:05:43 -08:00
Sam Hughes
79a2f81447 Fix devcontainer (tested) (#1680)
zls changes may be imprecise.
2022-12-28 22:53:07 -08:00
Jarred Sumner
0504bb8984 Expose the rest of RIPEMD160 2022-12-28 22:24:37 -08:00
Jarred Sumner
d726a17aca Implement Bun.RIPEMD160
`RIPEMD160` is used by node:crypto.
2022-12-28 22:20:15 -08:00
Jarred Sumner
33e93e6789 Use BoringSSL with patches from Electron 2022-12-28 22:18:16 -08:00
Jarred Sumner
c8da2618ee ✂️ 2022-12-28 19:28:12 -08:00
Jarred Sumner
8e9af05d6a [WebSocket] Allow http: and https: protocols
See https://github.com/whatwg/websockets/pull/37
2022-12-28 18:41:07 -08:00
Jarred Sumner
ba0b5baee4 [WebSocket] Implement headers support
Fixes https://github.com/oven-sh/bun/issues/1676
2022-12-28 18:39:19 -08:00
Jarred Sumner
384a9cda5e Fix devcontainer (probably) 2022-12-28 18:00:03 -08:00
Jarred Sumner
97ec866f85 Fixes https://github.com/oven-sh/bun/issues/1677 2022-12-28 17:00:04 -08:00
Jarred Sumner
ef3c9b7c6d Workaround https://github.com/ziglang/zig/issues/14099 2022-12-28 06:09:14 -08:00
Jarred Sumner
6260aaac5f Add crypto module from browserify 2022-12-28 05:14:40 -08:00
Jarred Sumner
d3dab09690 Statically link atomic 2022-12-28 05:10:16 -08:00
Jarred Sumner
f8f8353108 Always bundle compiler rt 2022-12-28 05:09:51 -08:00
Jarred Sumner
66234d9d57 Move some code up 2022-12-28 04:24:07 -08:00
Jarred Sumner
3d60b870ee Fix ReadableStream.pipeTo 2022-12-28 03:43:39 -08:00
Jarred Sumner
3ae23091c6 Fix platform setting 2022-12-28 02:16:34 -08:00
Alex Lam S.L
092b86321c log object string correctly (#1674)
use `Symbol.toStringTag` of the object or that of its `.prototype`

fixes #1584
2022-12-28 01:21:21 -08:00
Jarred Sumner
da07811427 Fix build issue on latest zig 2022-12-28 01:05:24 -08:00
Jarred Sumner
c0dd284136 Upgrade to latest Zig (#1610)
* @min and @max

* builtins and some trivial ones

* Most of them

* more

* more!

* More Progress

* wip

* Update tagged_pointer.zig

* Update http_client_async.zig

* Most of the iterable dir changes

* alright

* Remove usages of deprecated formatters

* 📷

* fmt

* Update shimmer.zig

* wip

* wip

* wip

* progress

* more

* Latest

* stuck on error

* latest

* workaround stage2

* wip

* Update string_immutable.zig

* wip

* Migrate `Dirent` and `require("fs')` to use JSC<>Zig bindings

* Fix build errors

* Fixup most of the test failures

* Fix `make headers`

* Fix "outside package path" error

* Fixup aligned alloc

* Add missing file

* linux

* More linux fixes

* use latest peechy

* Fix transpiler test failure

* Forgot about these

* Fixup test failure

* Update node-timers.test.ts

* [node:htt] Fix `undefined is not an object` error

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

* Update http.exports.js

* Make this test less flaky

* fix hashes

* Fix hex formatting and zls issues

* Download zig version

* Update Dockerfile

* Update Dockerfile

* Update uws

* Update Dockerfile

* Set llvm version

* Update README.md

* Update uws

* Update Dockerfile

* Update io_linux.zig

* Update bun.zig

* Log output

* workaround strange @cInclude error

* Make ffi tests better

* Don't use cImport

* Update c.zig

* Update c-bindings.cpp

* call setOutputDir

* Update Dockerfile

* Use a longer name

* latest

* Update serve.test.ts

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-12-28 00:51:22 -08:00
Alex Lam S.L
504972fa5d [bundler] fix logging verbosity (#1671)
fixes #1666
2022-12-27 16:36:26 -08:00
Alex Lam S.L
f78f423d0b emit 206 Partial Content only for partial response (#1670)
fixes #1668
2022-12-27 16:34:33 -08:00
Alex Lam S.L
c4ca4c70d1 [install] specify auth-type (#1667) 2022-12-26 15:15:58 -08:00
Alex Lam S.L
d94b96d9f4 [install] use specified base URL as default fallback within scopes (#1665) 2022-12-26 00:25:59 -08:00
Alex Lam S.L
74251fbf5e [install] use default URL when only auth token is specified (#1664)
Previously it would default to `http://localhost/` which was inconsistent with the case sans token.

Use official `npm` registry as fallback in both cases.
2022-12-25 21:20:35 -08:00
Dylan Conway
08a738c6c8 always more packages at new depth 2022-12-23 15:21:03 -08:00
Dylan Conway
cc369ad9d0 fix bun pm ls connectors when node_modules is last 2022-12-23 15:13:09 -08:00
Jarred Sumner
a94bba6399 darken 2022-12-23 01:16:12 -08:00
Jarred Sumner
f6a62c01bf Cherry-pick #1638
Closes #1638
2022-12-23 00:59:41 -08:00
Jarred Sumner
979074de2b Prevent running compinit twice 2022-12-23 00:50:19 -08:00
Jarred Sumner
958504296d Disable optimization 2022-12-23 00:48:24 -08:00
Dylan Conway
75a3c25ff8 add node_modules to bin path 2022-12-23 00:04:51 -08:00
Jarred Sumner
3da9c728d6 Make bun pm ls only show top-level by default 2022-12-22 23:38:56 -08:00
Jarred Sumner
85733abe79 npx -> bunx 2022-12-22 23:37:18 -08:00
Jarred Sumner
89625c0cc8 add rome 2022-12-22 19:49:56 -08:00
Alex Lam S.L
2d881b88f9 [install] fix remaining corner cases with dependency resolution (#1649) 2022-12-22 19:42:06 -08:00
Colin McDonnell
9ef33312b1 Update bench (#1648)
Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
2022-12-22 19:02:59 -08:00
Dylan Conway
1d58da3cb3 fix finding package bin after install 2022-12-22 18:54:02 -08:00
Dylan Conway
c0dee9adf1 pass callback to super _construct if possible 2022-12-22 16:10:58 -08:00
Dylan Conway
afd66c62ff fix createReadStream hang
highWaterMark test not working correctly but this prevents createReadStream from hanging
2022-12-22 15:58:17 -08:00
Alex Lam S.L
57da449442 [install] avoid dependency conflicts between siblings (#1647)
- consider `peerDependencies` when hoisting packages
2022-12-22 15:19:21 -08:00
Alex Lam S.L
62d1e46b92 fix bun install dependency resolution (#1643)
- avoid conflicts due to hoisted placement when parent and child depends on different versions of the same package
2022-12-22 03:17:33 -08:00
Jarred Sumner
b988a63429 don't log for ctrl + c 2022-12-22 00:25:31 -08:00
Jarred Sumner
e322dfb589 woops 2022-12-21 22:28:59 -08:00
Jarred Sumner
989ac717fc Update launch.json 2022-12-21 14:57:04 -08:00
Jarred Sumner
3ceb2655d8 Add test for stat() 2022-12-21 14:57:04 -08:00
Jarred Sumner
8c3a2ff6cc Fix throw 2022-12-21 14:57:04 -08:00
Jarred Sumner
b9d143c99d Add section about --bun 2022-12-21 14:57:04 -08:00
Jarred Sumner
f40d6bd94d Bun v0.4.0 2022-12-21 14:57:04 -08:00
Ethan Burrell
4f7d06500c fix jest hooks in bun-test (#1639)
* fix(jest) fix broken jest hooks

* add tests
2022-12-21 14:36:44 -08:00
Jarred Sumner
f6bbfa7e40 [bunx] Install symlink with completions
@colinhacks lmk if you have ideas where else it should attempt to isntall:
1) same dir as `bun`
2) $BUN_INSTALL/bin/bunx
3) $HOME/.bun/bin/bunx
4) $HOME/.local/bin/bunx
2022-12-21 00:58:14 -08:00
Jarred Sumner
435fdbfddc [bunx] Make help a little prettier 2022-12-21 00:56:50 -08:00
Jarred Sumner
83602b6834 Refactor some of bun pm 2022-12-20 23:28:11 -08:00
Jarred Sumner
3b808f5ac5 Update ZigGlobalObject.cpp 2022-12-20 22:11:41 -08:00
Jarred Sumner
aaf1624346 typo 2022-12-20 22:07:04 -08:00
Jarred Sumner
a98e0adc7d [web] Support multiple arguments in setTimeout, setInterval, and setImmediate 2022-12-20 22:05:47 -08:00
Alex Lam S.L
06487ef64f add tests for #1633 (#1635)
- `setImmediate(fn, ...args)`
- `setInterval(fn, delay, ...args)`
- `setTimeout(fn, delay, ...args)`
2022-12-20 21:34:25 -08:00
Jarred Sumner
b2fdcad77b [bunx] Improve reliability by checking the "bin" from package.json if necessary 2022-12-20 21:33:34 -08:00
Jarred Sumner
51f9a91736 Fixes https://github.com/oven-sh/bun/issues/1636 2022-12-20 21:09:46 -08:00
Jarred Sumner
d7b73dd4fc Use endsWith 2022-12-19 23:37:53 -08:00
Jarred Sumner
5931e350cd New subcommand: bunx (#1634)
* Implement `bunx`

* copy cleanup

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2022-12-19 23:05:12 -08:00
Jarred Sumner
e7a14f857d [Bun.write] Slightly better handling for older linux kernels that lack io_uring support
If io_uring is unsupported, we do the writes synchronously even if they're huge
2022-12-19 12:20:59 -08:00
Jarred Sumner
79abd245e2 Regenerate builtins 2022-12-18 08:52:50 -08:00
Alex Lam S.L
2b622162ef bug compatible with stdin.on("readable") (#1626) 2022-12-17 22:37:45 -08:00
Jarred Sumner
5a3e0836b1 Upgrade WebKit 2022-12-17 17:02:56 -08:00
Jarred Sumner
24c4d92c0b Update globals.d.ts 2022-12-17 16:18:01 -08:00
Jarred Sumner
184c56704b Add warning in import.meta.require 2022-12-17 16:15:58 -08:00
Jarred Sumner
feea8824f1 Delete Oniguruma (#1625)
* Update .gitmodules

* Delete oniguruma

* Delete Oniguruma

* Make this test less flaky

* ✂️

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2022-12-17 15:41:47 -08:00
Jarred Sumner
028e48ed97 Missing from commit 2022-12-17 14:38:54 -08:00
Jarred Sumner
609222d05e Fixes https://github.com/oven-sh/bun/issues/1624
This was disabled anyway
2022-12-17 14:37:37 -08:00
Jarred Sumner
5d91922c5d Regenerate builtins 2022-12-17 12:31:07 -08:00
Jarred Sumner
d66831c4f3 Update transpiler.test.js 2022-12-17 12:26:19 -08:00
Jarred Sumner
7f1caaaa44 Update WebKit 2022-12-17 12:26:19 -08:00
Jarred Sumner
42fc49d413 Add node:assert bench 2022-12-17 12:26:19 -08:00
Jarred Sumner
72970ecd15 Update Makefile 2022-12-17 12:26:19 -08:00
Jarred Sumner
f9b573aa89 [bun-types] Add optional param to Bun.deepEquals 2022-12-17 12:26:19 -08:00
Jarred Sumner
bbf8a17bf5 Use Bun.deepEqual in assert module 2022-12-17 12:26:19 -08:00
Jarred Sumner
8c8accf968 Use Buffer.isBuffer and node:util/types in util module 2022-12-17 12:26:19 -08:00
Jarred Sumner
24be0f4fc5 Implement node:util/types
Fixes #1617
2022-12-17 12:26:19 -08:00
Jarred Sumner
e59c6f642d Add strict option to Bun.deepEquals 2022-12-17 12:26:19 -08:00
Jarred Sumner
1bdb4b2466 [napi] Fix assertion failure when argv is null 2022-12-17 12:26:19 -08:00
Hossein Pourdavar
ca0ab9508f docs(README.md): specify bun-types new path (#1622) 2022-12-17 10:34:35 -08:00
Alex Lam S.L
68fd43313d add tests for process.stdin (#1621) 2022-12-16 20:40:41 -08:00
Ikko Ashimine
b06ca07eee Fix typo in bun.d.ts (#1619)
occured -> occurred
2022-12-16 10:36:07 -08:00
Jarred Sumner
01ed3045cb [napi] Implement napi_create_bigint_words
warning: not tested
2022-12-16 00:40:08 -08:00
Jarred Sumner
6b3be4d821 [js parser] Workaround symbol collision bug
See https://github.com/oven-sh/bun/issues/1616
Fixes https://github.com/oven-sh/bun/issues/1594
2022-12-15 23:42:08 -08:00
Jarred Sumner
e399bceb3c [js parser] Skip appending empty statements 2022-12-15 23:41:40 -08:00
Jarred Sumner
a8fca7d679 [js parser] Make fnBodyContainsUseStrict faster 2022-12-15 23:41:24 -08:00
Jarred Sumner
b249d1b75b [js parser] Ignore calls to import.meta.require that will never happen 2022-12-15 23:39:59 -08:00
Jarred Sumner
3495b7c1f8 [bun-types] Remove outdated comments 2022-12-15 21:48:50 -08:00
Jarred Sumner
3c20290e49 [js parser] Fix bug where const {resolve} = require throws "require is not defined" 2022-12-15 21:48:38 -08:00
Jarred Sumner
0df3485132 [js printer] Fix missing space when printing import aliases with whitespace minification enabled 2022-12-15 21:40:56 -08:00
Jarred Sumner
3ea983578f [node:process] Implement process.argv0, process.execPath
Fixes https://github.com/oven-sh/bun/issues/1599
2022-12-15 17:31:18 -08:00
Jarred Sumner
000a0c9dca Fix missing error when command not found 2022-12-15 17:03:08 -08:00
Jarred Sumner
c1d7ec9564 [node:process] Implement process.abort() 2022-12-15 16:28:47 -08:00
Jarred Sumner
9e909dcae1 [bun run] Include signal code on error 2022-12-15 16:28:47 -08:00
Jarred Sumner
3c1ad4b568 prettier 2022-12-15 16:28:47 -08:00
Jarred Sumner
743531b4ac [bun run] Introduce --bun flag to run in bun instead of node 2022-12-15 16:28:47 -08:00
Jarred Sumner
d1834b5a92 [process.stdin] Support reading from process.stdin in the same tick 2022-12-15 16:28:47 -08:00
Jarred Sumner
e38a3e5d85 [bun run] Use execve instead of posix_spawn when bun no longer needs to run script/bin
When we launch a script & there's nothing left to do, we should replace the process image with the new process instead of keeping the bun process alive while the other script is running.
2022-12-15 16:28:47 -08:00
Derrick Farris
6a1fc20835 fix(stream): make Readable.read work w/o _construct implemented (#1613)
* fix(stream): put Readable._readableState.constructed default in spec (true, not false)

* cleanup(readable): remove unnecessary _construct methods

* test(stream): add test for Readable w/o _construct method
2022-12-15 00:25:19 -08:00
Dylan Conway
95c747f598 undo bad free 2022-12-14 17:50:14 -08:00
Dylan Conway
65302a1db5 remove incorrect connector character 2022-12-14 14:01:03 -08:00
Dylan Conway
c4557e57a1 add bun pm ls for printing lockfiles (#1612)
* list directory structure from lockfile

* dim connectors and versions
2022-12-13 22:47:46 -08:00
Jarred Sumner
f61d9e340d [bun:jsc] Introduce profile function 2022-12-13 20:47:51 -08:00
Jarred Sumner
47a2548cbf Fix crash in startSamplingProfiler 2022-12-13 20:39:49 -08:00
Jarred Sumner
5516adec57 Avoid creating closure 2022-12-13 19:16:51 -08:00
Alex Lam S.L
4e920d73b7 make process.stdin work under TTY (#1611)
- workarounds for #1607 & #1608

fixes #1604
2022-12-13 19:02:20 -08:00
Jarred Sumner
a92258355d Don't call debug streams getter when not in debug 2022-12-13 19:01:25 -08:00
Jarred Sumner
5bbaa7b400 Fix bug where importing a binary file throws a SyntaxError. Instead, return the public path for that file 2022-12-13 18:17:26 -08:00
Jarred Sumner
de8ace9fbe Add a test for importing unknown file types as file loader 2022-12-13 18:17:26 -08:00
Ashcon Partovi
375f69559f Move bun-landing to another repository 2022-12-13 17:25:46 -08:00
Jarred Sumner
7d15a040fd Add missing if 2022-12-13 15:12:14 -08:00
Dylan Conway
3236a99b2d missing id when over 8 packages 2022-12-13 11:37:50 -08:00
Jarred Sumner
18d4cfd4f2 Update build-id 2022-12-13 11:34:29 -08:00
Jarred Sumner
6255fe6a4b [internal] Add bun-debug build 2022-12-13 00:16:01 -08:00
Jarred Sumner
dd9691289f Don't use zls for formatting 2022-12-13 00:15:50 -08:00
Jarred Sumner
e98aae195c fix UB 2022-12-13 00:15:41 -08:00
Jarred Sumner
5741d4f9b4 [crypto] Implement scryptSync
Fixes https://github.com/oven-sh/bun/issues/1228
2022-12-13 00:15:29 -08:00
Jarred Sumner
1bed749d8c some bugs make you feel like a 🤡 2022-12-12 22:39:15 -08:00
Jarred Sumner
bbe66a4367 Add missing space 2022-12-12 19:29:25 -08:00
Jarred Sumner
f649aae36f [crypto] Implement crypto.timingSafeEqual
This uses BoringSSL's memcmp function

Fixes https://github.com/oven-sh/bun/issues/1308
2022-12-12 19:29:25 -08:00
Derrick Farris
9f9db85a94 fix(stream): Fix Readable.pipe() (#1606)
* fix(stream): fix some debug logs that were breaking .pipe

* fix(stream): another debug fix

* test(stream): add test for .pipe
2022-12-12 18:58:28 -08:00
Dylan Conway
bbc2dacd84 markbinding for utf8 length from utf16le 2022-12-12 13:41:55 -08:00
Dylan Conway
0bb9493e47 fix fallback install method 2022-12-12 13:38:12 -08:00
Jarred Sumner
14efd03b48 📷 2022-12-12 00:40:00 -08:00
Jarred Sumner
d5b11be769 [internal] Add helper to make it easier to print whitespace 2022-12-12 00:28:37 -08:00
Jarred Sumner
007133d060 [Transpiler] Implement minifyWhitespace option 2022-12-11 23:28:53 -08:00
Jarred Sumner
6279358cbc [internal] further cleanup for hoistSymbols 2022-12-11 20:25:20 -08:00
Jarred Sumner
ca34a09a4d fixup 2022-12-11 19:29:27 -08:00
Jarred Sumner
b746579863 [internal] Change HashMap implementation for storing symbols 2022-12-11 18:41:54 -08:00
Jarred Sumner
8549134658 [Bun.Transpiler] Introduce inline flag 2022-12-11 16:38:52 -08:00
Jarred Sumner
27e40b0836 Update WebKit
cc @cirospaciari you will need to re-download the precompiled WebKit build from the releases page https://github.com/oven-sh/WebKit/releases/tag/dec11 because there is one small WebKit API change. LMK if you have any trouble with that
2022-12-11 16:14:53 -08:00
Jarred Sumner
b57f51fda2 Add a test for some scopes 2022-12-11 14:18:09 -08:00
Jarred Sumner
fad1742410 [transpiler] Never trim exports 2022-12-11 13:55:31 -08:00
Jarred Sumner
768f4539e8 [transpiler] Fix unbalanced class_name scope
surprised this was never caught sooner
2022-12-11 13:55:15 -08:00
Jarred Sumner
37b16a9007 Add _read 2022-12-11 13:01:41 -08:00
Jarred Sumner
a2d96f9040 Fix checking the UTF-16 length twice 2022-12-11 13:01:24 -08:00
Jarred Sumner
b5519af7e7 cleanup some tests 2022-12-11 12:58:48 -08:00
Jarred Sumner
9d94f148dc Avoid re-visting AST nodes which create scopes 2022-12-11 11:55:06 -08:00
Jarred Sumner
5cf64b07be Fix segfault in release mode when module list is empty 2022-12-10 22:25:33 -08:00
Jarred Sumner
e301fde96d Include isTTY in types 2022-12-10 22:25:19 -08:00
Jarred Sumner
2a7687fff8 Regenerate builtins 2022-12-10 22:24:34 -08:00
Alex Lam S.L
780f7de843 override process.stdin.on() correctly (#1603)
* override `process.stdin.on()` correctly

fixes #1601

* add tests
2022-12-10 21:51:02 -08:00
Jarred Sumner
660eb46b17 [transpiler] Improve constant propagation 2022-12-10 21:36:14 -08:00
Jarred Sumner
c6f3044654 [transpiler] Fix issue with async macros in bun build 2022-12-10 15:30:09 -08:00
Jarred Sumner
b374c67c16 [transpiler] Fix bug with === on statically-known rope strings 2022-12-10 15:29:53 -08:00
Jarred Sumner
ce960f9506 ♻️ 2022-12-10 00:37:32 -08:00
Jarred Sumner
ab49f95ef2 📷 2022-12-10 00:19:19 -08:00
Jarred Sumner
047754d5dd Implement simple version of inlining single-use expressions and statements 2022-12-10 00:19:19 -08:00
YuX
b400dfb386 fix path string (#1597) 2022-12-09 18:17:12 -08:00
Jarred Sumner
88538b7c2c Deprecate very incomplete Solid.js JSX transform
We don't have time to do a good job of this and Bun.plugin makes it possible to use Solid with Bun
2022-12-09 16:41:38 -08:00
Jarred Sumner
79138c4c7c Add "bun" to list 2022-12-09 16:10:33 -08:00
Colin McDonnell
24fbcb8f52 Exclude other ts declaration file extensions (#1596)
Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
2022-12-09 14:26:33 -08:00
Jarred Sumner
51e437e8a0 EventEmitter - return original this value for better chainability 2022-12-08 18:27:16 -08:00
Colin McDonnell
e6c2f48895 Add filename completions on naked bun command (#1593)
Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
2022-12-08 17:32:25 -08:00
Ashcon Partovi
cf961336d0 Update install issue template 2022-12-08 09:50:03 -08:00
Ashcon Partovi
b44615a916 Improve bug report issue template 2022-12-08 09:49:19 -08:00
Ashcon Partovi
fd740d41e5 Fix issue template for docs 2022-12-08 09:44:55 -08:00
Ashcon Partovi
46a9b124f5 Remove needs-repro label from issue template 2022-12-08 09:33:59 -08:00
Simon He
7c2180194c chore: add eslintcache (#1586) 2022-12-07 22:03:11 -08:00
Jarred Sumner
3150ff49a7 fix dirname on an empty string 2022-12-07 21:41:30 -08:00
Jarred Sumner
2fe5b4da2f 📷 2022-12-07 21:41:30 -08:00
Dylan Conway
0b94ccdf8c disable assignment on user specified assigns 2022-12-07 21:29:32 -08:00
Dylan Conway
845421c44b fix __require linker collision (#1585) 2022-12-07 20:39:55 -08:00
Jarred Sumner
42ea8b2402 [node:events] EventEmitter#on and EventEmitter#off should return the EventEmitter instance 2022-12-07 14:06:18 -08:00
Jarred Sumner
a13e64c286 Update html_rewriter.zig 2022-12-07 00:37:40 -08:00
Derrick Farris
60d0e6b73f fix(stream): Fix Transform class constructor fn (#1583)
* fix(stream): fix ReadableFromWeb class, fix Transform

* test(stream): add tests for .call on stream constructors
2022-12-07 00:18:10 -08:00
Jarred Sumner
a315ee7e03 try 2022-12-06 22:31:26 -08:00
Jarred Sumner
57672eb266 try 2022-12-06 22:29:21 -08:00
Jarred Sumner
511c0ab386 Fix aarch64 2022-12-06 22:17:55 -08:00
Dylan Conway
d9306c2681 first_non_ascii != offset 2022-12-06 21:46:20 -08:00
Dylan Conway
aa17f97d13 fix failing text decoder test 2022-12-06 21:04:38 -08:00
Jarred Sumner
e547efbf4a Don't call getters in console.log 2022-12-06 20:20:08 -08:00
Jarred Sumner
3d243e5e95 Fix node:stream/consumers 2022-12-06 19:56:36 -08:00
Colin McDonnell
5ea8fe8c90 Update types (#1581)
* Fix TS types, improve child_process types

* Add prettier

* Add ArrayBuffer types

* Add namespace Bun, improve types for SharedArrayBuffer, add toStrictEqual

* Improve types, add test files for types

* Update type tests

* Fix typo

* Add stdio

* Stdio types

* Use latest setup-bun

* Update action

* Update action

* Update action

Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
Co-authored-by: Ashcon Partovi <ashcon@partovi.net>
2022-12-06 18:48:02 -08:00
Dylan Conway
84b2cc1739 fix child process test 2022-12-06 18:15:20 -08:00
Jarred Sumner
15ce587fa2 Update glibc-versions-hack.cpp 2022-12-06 18:10:17 -08:00
Dylan Conway
20a4b72ff4 add base64url switch case 2022-12-06 17:36:24 -08:00
Jarred Sumner
41d778fbfb dlsym pow 2022-12-06 17:21:07 -08:00
Dylan Conway
5f3a6f2bf3 add server scheduleDeinit, ignore logs in test 2022-12-06 17:10:14 -08:00
Jarred Sumner
58185e139a Add check 2022-12-06 17:08:21 -08:00
Dylan Conway
51d69d8c85 fix event emitter cast 2022-12-06 16:25:39 -08:00
Jarred Sumner
4dd2cb33b7 Ban statx 2022-12-06 15:48:41 -08:00
Jarred Sumner
31f025fa02 Add snippet 2022-12-06 14:18:25 -08:00
Jarred Sumner
81317a52ea Fix glibc symbol version issues preventing bun install from being used in older glibc versions (#1580)
* Prevent integer overflow in connectError

* Add missing deepEquals() type to Bun

* fix missing glibc symbols

* Fix missing symbol issues

* Try this

* Update glibc-versions-hack.cpp

* Update glibc-versions-hack.cpp

* Update glibc-versions-hack.cpp

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2022-12-06 14:14:27 -08:00
Derrick Farris
7d29782896 cleanup/fix(stdio,child_process): bug fixes, refactoring, etc. (#1574)
* fix(stream): add back call to Error.captureStackTrace, remove stray garbage

* cleanup(streams): remove unnecessary checks on Promise.then

* fix(child_process): WrappedFileSink -> NativeWritable for ChildProcess stdio

* cleanup(child_process): remove debug id

* fix(child_process): fix process.nextTick not working in onExit, fail to flush stdio

* refactor(streams): revert stream impls to functions from classes

* fix(child_process): revert runOnNextTick to process.nextTick
2022-12-06 13:26:39 -08:00
Dylan Conway
1aa4cd2f6a 9 characters 2022-12-05 19:42:49 -08:00
Jarred Sumner
c7f411bd88 Use more simdutf 2022-12-05 17:14:29 -08:00
Dylan Conway
60e6a47bb0 fix for double free and undefined this 2022-12-05 16:41:55 -08:00
Jarred Sumner
d9dc15115c linx build issue 2022-12-05 15:23:45 -08:00
Jarred Sumner
159ee8ddfc indexOfLine type 2022-12-05 14:11:23 -08:00
Jarred Sumner
84634117a9 Missing commit 2022-12-05 14:11:05 -08:00
Jarred Sumner
5ea278e1c6 Update README.md 2022-12-05 12:12:35 -08:00
Jarred Sumner
9e29159f44 More null checking for simdutf 2022-12-05 12:06:24 -08:00
Jarred Sumner
e23832d1ce Fix regression 2022-12-05 12:05:16 -08:00
Jarred Sumner
9665d7d216 Add some more text decoder tests 2022-12-05 11:37:04 -08:00
Jarred Sumner
c114956788 Fix crash when passing unexpected type to .writer() 2022-12-05 11:37:04 -08:00
Jarred Sumner
61bf957b99 Introduce console.write(text, or, arrayBufferLike) 2022-12-05 11:36:28 -08:00
Jarred Sumner
2cbac4bbdd Introduce Bun.indexOfLine 2022-12-05 11:36:04 -08:00
Jarred Sumner
320c23543c Fix alignment edgecase 2022-12-05 11:35:50 -08:00
Jarred Sumner
0ea8de4087 Make console an AsyncIterable 2022-12-05 11:35:34 -08:00
Jarred Sumner
7129303347 Update Process.h 2022-12-05 03:52:40 -08:00
Jarred Sumner
8582bc08ec microbench 2022-12-05 03:52:35 -08:00
Jarred Sumner
eeea1707a1 process.stdin exists but doesn't totally work yet 2022-12-05 03:52:20 -08:00
Jarred Sumner
b7e08cb937 [Bun.stdin] Fix handling tty 2022-12-05 03:43:09 -08:00
Jarred Sumner
054413ba1f [internal] Add some logs for string encoding 2022-12-05 03:38:45 -08:00
Jarred Sumner
04dcf180d5 Fix "is not event emitter" errror 2022-12-05 00:44:34 -08:00
Jarred Sumner
79094e6643 more tests for event emitter weirdness 2022-12-05 00:42:02 -08:00
Jarred Sumner
682af03cdc "Fix" monkey-patching EventEmitter prototype 2022-12-05 00:19:23 -08:00
Jarred Sumner
1564f75d06 Update test-test.test.ts 2022-12-04 23:30:25 -08:00
Jarred Sumner
224f980081 [bun:test] Fix crash when test("foo") is called without passing a function 2022-12-04 23:29:21 -08:00
Jarred Sumner
2369bade48 Clean up more cases 2022-12-04 08:47:22 -08:00
Jarred Sumner
10cd5aaa15 Fix race condition in child_process 2022-12-04 08:32:51 -08:00
Jarred Sumner
f4668e45f8 Update ZigGeneratedClasses.cpp 2022-12-04 08:15:45 -08:00
Jarred Sumner
a1e62e6bf9 Handle exception when creating stdout/stderr 2022-12-04 08:15:39 -08:00
Jarred Sumner
e009be1c5d Update ffi.zig 2022-12-04 08:15:07 -08:00
Jarred Sumner
af0bc28c51 Update child_process 2022-12-04 08:15:02 -08:00
Jarred Sumner
bb5450fad0 [breaking] onExit callback in Bun.spawn sets the first property to be the Subprocess object
Sometimes Bun.spawn calls the onExit callback before the Bun.spawn() callback is called.

Instead of delaying a tick, we set the `Subprocess` to be the first argument to the `onExit` callback now.
2022-12-04 08:11:44 -08:00
Jarred Sumner
5bb8c42bdb [Bun.spawn] Introduce Subprocess.prototype.signalCode 2022-12-04 08:09:23 -08:00
Jarred Sumner
69114ac0a9 Fix console.log sometimes incorrectly reporting undefined
cc @Electroid
2022-12-04 08:05:57 -08:00
Jarred Sumner
8830cbc51e [test] Ensure console.log(globalThis) doesn't crash 2022-12-04 06:55:12 -08:00
Jarred Sumner
23c90a76c2 Rename file 2022-12-04 06:54:56 -08:00
Jarred Sumner
714ce7619d [internal] Make string comparisons faster 2022-12-04 06:53:53 -08:00
Jarred Sumner
34b2e9acc2 Fix running zig tests 2022-12-04 05:02:14 -08:00
Jarred Sumner
4c818b9364 Mildly faster startup time 2022-12-04 03:50:22 -08:00
Jarred Sumner
cee33485d0 ✂️ 2022-12-04 03:22:10 -08:00
Jarred Sumner
f052e66df5 Add some basic tests for process.stdout 2022-12-04 02:53:04 -08:00
Jarred Sumner
46e34a3fa9 Re-add missing global 2022-12-04 02:28:25 -08:00
Jarred Sumner
2bcae716d1 Silence incorrect test failure 2022-12-04 02:28:15 -08:00
Jarred Sumner
4281a68a2b content-range is inclusive 2022-12-04 01:24:52 -08:00
Jarred Sumner
ab020b2275 Update README.md 2022-12-04 01:11:34 -08:00
Jarred Sumner
0617896d70 [Bun.serve] Implement Content-Range support with Bun.file() 2022-12-04 00:55:05 -08:00
Jarred Sumner
1c3cb22d1f [may revert later] Coerce Infinity to max int 64, -Infinity & NaN to min int64 2022-12-04 00:53:52 -08:00
Jarred Sumner
275a635ad7 Update .gitignore 2022-12-03 23:57:50 -08:00
Jarred Sumner
35bf039dfb [test] Add a couple tests for subarray toEqual 2022-12-03 23:57:13 -08:00
Jarred Sumner
de9a2b9fe5 [fetch] Fix bug where .arrayBuffer() on an empty Response body returned a Uint8Array instead of an ArrayBuffer 2022-12-03 23:56:40 -08:00
Jarred Sumner
201cbb20e4 Don't invalidate previous file descriptro to avoid tripping assertion 2022-12-03 08:26:53 -08:00
Jarred Sumner
8c51db0879 misc 2022-12-03 08:26:53 -08:00
Jarred Sumner
10b04fbd26 Add missing type 2022-12-03 08:26:53 -08:00
Jarred Sumner
bdc43c1696 process.stdout and process.stderr 2022-12-03 08:26:53 -08:00
Jarred Sumner
bc028168a8 simdutf ascii validation is about 20% faster on arm64 than our zig simd @Vector version 2022-12-03 08:26:53 -08:00
Reed Jones
00f428b627 typo in readme (#1576)
Succesfully => Successfully
2022-12-03 07:35:50 -08:00
Jarred Sumner
d28a4dbb00 Object.defineProperties snippet 2022-12-03 04:26:33 -08:00
Dylan Conway
0a30bf0212 make sure to not use incomplete characters (#1575) 2022-12-03 02:59:17 -08:00
Jarred Sumner
04658776e4 Push failing tests 2022-12-02 23:17:40 -08:00
Dylan Conway
369e9f3fbd add deps for make test command 2022-12-02 22:36:23 -08:00
Jarred Sumner
1b7b37232e Run promise before callback 2022-12-02 22:30:04 -08:00
Jarred Sumner
fe4f39fd17 Add AbortSignal.timeout 2022-12-02 20:48:57 -08:00
Dylan Conway
9cc03cd71a matchers for less than and greater than (#1573)
* toBeGreaterThan with tests

* toBeGreaterThanOrEqual and tests

* toBeLessThan and toBeLessThanOrEqual with tests

* expect types

* switch expressions
2022-12-02 20:35:13 -08:00
Jarred Sumner
d9f9fc975b Propagate reason in AbortSignal and reuse in ReadableStream.pipeTo
Similar to https://github.com/WebKit/WebKit/pull/7013
2022-12-02 20:15:50 -08:00
Jarred Sumner
bdbc0f23e7 Update TransformStream options getters to check for undefined
This is essentially copied from https://github.com/WebKit/WebKit/pull/7021
2022-12-02 20:00:27 -08:00
Jarred Sumner
ba6908aed7 Remove getSetCookie() from types 2022-12-02 19:35:35 -08:00
Jarred Sumner
4e6b905a98 Update test 2022-12-02 19:35:28 -08:00
Jarred Sumner
43f2a8eb85 Add some code I forgot to commit 2022-12-02 19:35:11 -08:00
Jarred Sumner
c72629d88a Make cloning headers object faster 2022-12-02 19:34:43 -08:00
Jarred Sumner
33cf491fea Add a userland way to hide stack frames 2022-12-02 19:33:59 -08:00
Jarred Sumner
2f917f7030 Make constructing headers from an existing headears faster 2022-12-02 19:33:45 -08:00
Jarred Sumner
207282862e Throw if passing a header not named "set-cookie" to getAll 2022-12-02 19:33:36 -08:00
Jarred Sumner
3c054253e1 Remove getSetCookie 2022-12-02 19:33:22 -08:00
Jarred Sumner
2c0fd28e72 [node:event] Add captureRejectionSymbol 2022-12-02 09:05:11 -08:00
Derrick Farris
b8586b33da feat(process): add process.{stdin, stdout, stderr} support (#1495)
* fix(stream): get Duplex working

* feat(process): add stdin,stdout,stderr in a semi-broken state (pipes??)

* test(NodeTestHelpers): fix test names

* test(NodeTestHelpers): add test for createDoneDotAll done called w error

* test(NodeTestHelpers): remove stray console.log

* fix(stream): fix bug in Duplex, Readable

* test(process.stdio): rename test

* fix(process.stdio): change onData listener to onReadable

* refactor(streams): add file-wide debug fn, destructure opts

* fix(child_process): check isCallable on promise

* fix: get stdio streams mostly working (mostly)

* fix(child_process): wait until stream is drained before calling end?

* fix(child_process): change to result?.then

* debug(child_process,streams): add EE id tracking, add shim for stdio after handle is dead

* test(child_process): fix double pipe test, temp fix for ChildProcess.kill() return val

* fix(child_process): remove immediate emit of exit on kill

* debug(streams): add more debug log

* debug(streams): add more debug logs part 2

* feat(streams,fs): add NativeWritable, adapt fs.WriteStream and fs.ReadStream to native
2022-12-02 08:25:13 -08:00
Jarred Sumner
beaf91590a Tests for set-Cookie 2022-12-02 07:44:57 -08:00
Jarred Sumner
d84f79bcc1 [fetch] Implement Headers#getAll and Headers#getSetCookie()
This matches Deno's behavior (get() combines, iterator preserves the order, set and append combine), but implements both the Cloudflare Workers `getAll()` and the potential standard `getSetCookie` function.  The rationale for choosing both is to better support libraries which check for `getAll` and also because `getSetCookie` seems a little confusing (names are hard)

This also makes `.toJSON` and JSON.stringify return an array for `Set-Cookie`
2022-12-02 07:42:44 -08:00
Dylan Conway
917cbc8d5d incorrect name for matcher 2022-12-02 02:30:35 -08:00
Jarred Sumner
074f236994 make the test run faster 2022-12-02 02:17:12 -08:00
Jarred Sumner
03eb000ad6 delete these fixtures which are no longer relevant 2022-12-02 02:16:59 -08:00
Jarred Sumner
9a184c8279 Fix incorrect StringDecoder export test 2022-12-02 01:56:55 -08:00
Jarred Sumner
b53a332809 Fix running tests in older versions of bun 2022-12-02 01:56:41 -08:00
Jarred Sumner
a09b515a62 Skip flaky test 2022-12-02 01:56:25 -08:00
Jarred Sumner
8eddfc61a8 Add generic way to block on a promise 2022-12-02 01:56:12 -08:00
Jarred Sumner
37525db5cf Faster test 2022-12-02 00:25:38 -08:00
Jarred Sumner
e9eb88355b Close stdin earlier 2022-12-02 00:25:30 -08:00
Jarred Sumner
9f5564b4bc Add file descriptor leak test 2022-12-02 00:25:08 -08:00
Jarred Sumner
931ba9ad49 Add file descriptor leak test 2022-12-02 00:23:29 -08:00
Jarred Sumner
851b8acb76 Fix incorrect panic in spawnSync 2022-12-02 00:05:33 -08:00
Jarred Sumner
7a158e68ae Fix crash when macros return a Promise 2022-12-01 23:46:18 -08:00
Jarred Sumner
cb36b4d1ab Fix double free in .json() and optimize UTF16 -> json slightly 2022-12-01 23:43:49 -08:00
Jarred Sumner
2621fbf206 Remove file blob caching 2022-12-01 23:42:57 -08:00
Jarred Sumner
d7ab2c04ec Faster test 2022-12-01 23:42:13 -08:00
Jarred Sumner
f84f77d1ed [streams] Handle empty state 2022-12-01 23:28:42 -08:00
Jarred Sumner
425f4b0de1 [fetch] Add test that invalid json rejects promise 2022-12-01 23:27:53 -08:00
Jarred Sumner
7b70ed52fa [bun bun] Fix incorrect package.hash 2022-12-01 21:37:25 -08:00
Jarred Sumner
8cf1707cd3 [bun bun] Fix crash in canary 2022-12-01 21:37:09 -08:00
Jarred Sumner
9f4d7690ac [fetch] Treat 302 like 303 2022-12-01 21:15:34 -08:00
Jarred Sumner
5854d39525 [fetch] Implement redirect: "manual" 2022-12-01 21:09:43 -08:00
Jarred Sumner
b4e6ca0462 ComptimeStringMap is faster than ExactSizeMatcher 2022-12-01 20:51:35 -08:00
Jarred Sumner
f408749182 Fix timers keeping process alive unnecessarily 2022-12-01 20:46:54 -08:00
Dylan Conway
92da72beb0 bun test toStrictEqual (#1568)
* toStrictEqual and bug fix in deepEqual

* rebase Remove some dead bindings code

* remove debugging test

* canGetIndexQuickly for array holes

* isStrict template

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2022-12-01 19:36:47 -08:00
Jarred Sumner
a896d6c46c [bun:sqlite] ~15% perf improvement to all() and get() 2022-12-01 19:34:02 -08:00
Jarred Sumner
4eed310a45 3x faster TextEncoder.prototype.encodeInto
thanks to @Constellation for the tip
2022-12-01 18:51:16 -08:00
Jarred Sumner
1daa61a45f Add test for DOMJIT call version of encodeInto 2022-12-01 18:40:56 -08:00
Jarred Sumner
03490afdb3 Fix crash in test runner with gc mode 2022-12-01 18:40:41 -08:00
Jarred Sumner
e1e5f8c43b Include size of ArrayBuffer and others in GC timer scheduling 2022-12-01 02:36:51 -08:00
Jarred Sumner
b655d09387 Incorrect readme 2022-12-01 02:36:33 -08:00
Jarred Sumner
e0503faec7 Increase sensitivity of GC timers 2022-12-01 02:36:18 -08:00
Jarred Sumner
bddf523ac9 Reduce memory usage in Bun.serve() by up to 3x (#1569)
* Update WebKit

* Use 5x less memory in Bun.serve()

* Update Dockerfile.devcontainer

* Update async-overhead.mjs

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2022-12-01 02:34:15 -08:00
Dylan Conway
1506a25198 formatting and remove comment 2022-11-30 16:40:54 -08:00
Dylan Conway
1abc89e391 fix slow regex tests 2022-11-30 16:36:03 -08:00
Jarred Sumner
3cb462a3e6 Fix console.log regression with emoji 2022-11-30 07:28:48 -08:00
Jarred Sumner
f8b87e3ee2 Redirect imports to "readable-stream" -> "node:stream" 2022-11-30 07:21:27 -08:00
Jarred Sumner
e6f055e9fb Accidentally deleted prompt as a result of the process.env changes 2022-11-30 06:16:59 -08:00
Jarred Sumner
f999bdca26 ✂️ 2022-11-29 23:56:52 -08:00
Jarred Sumner
e75ce84c37 Remove some dead bindings code 2022-11-29 23:49:11 -08:00
Jarred Sumner
b631ea7d72 import everything from "bun" where possible 2022-11-29 02:42:56 -08:00
Jarred Sumner
7b59d9d97c Make .toInt64 faster 2022-11-28 23:48:04 -08:00
Jarred Sumner
d28247573c Handle when the process already exited immediately 2022-11-28 23:48:04 -08:00
Dylan Conway
56884b5f1d toHaveProperty and tests (#1558)
* toHaveProperty and tests

* emoji tests
2022-11-28 23:15:12 -08:00
Jarred Sumner
887496bcf9 Fix failing spawn() and spawnSync() tests
cc @ThatOneBro
2022-11-28 23:00:22 -08:00
Jarred Sumner
da43761032 Update README.md 2022-11-28 19:18:17 -08:00
Jarred Sumner
4efce63dad Update README.md 2022-11-28 19:14:45 -08:00
Jarred Sumner
2a33bd2cc5 Add small section about profiling bun 2022-11-28 19:11:09 -08:00
Jarred Sumner
b337e36da1 Fix hanging in FIFO streams 2022-11-28 18:31:12 -08:00
Jarred Sumner
77d0828179 [internal] Add debug timer 2022-11-28 18:30:49 -08:00
Jarred Sumner
eccd854dbc Ensure we report errors in controller.close 2022-11-28 18:30:28 -08:00
Jarred Sumner
a64f2f5466 Update JSEnvironmentVariableMap.cpp 2022-11-28 16:57:48 -08:00
Jarred Sumner
d3cd753d4d Allow overriding node:fs 2022-11-28 16:23:41 -08:00
Jarred Sumner
f423791e19 Add test for process 2022-11-28 15:59:58 -08:00
Jarred Sumner
a6cadce6f6 Fix process.env and Bun.env object spread
Fixes https://github.com/oven-sh/bun/issues/1512
2022-11-28 15:55:02 -08:00
Jarred Sumner
51d0c3b79f Fix console.log(process.env) 2022-11-27 23:01:09 -08:00
Jarred Sumner
7672ee95af Add google fixture 2022-11-27 22:41:22 -08:00
Jarred Sumner
512acf072e Add missing v
Fixes https://github.com/oven-sh/bun/issues/1554
2022-11-27 22:41:16 -08:00
Jarred Sumner
4ee11d922c Cleanup some of the encoding code 2022-11-27 22:09:56 -08:00
Jarred Sumner
885049831f Fix handling delete process.env.foo 2022-11-27 22:09:23 -08:00
Jarred Sumner
e5106d320c Don't make toJSON enumerable in process.env 2022-11-27 22:09:07 -08:00
Jarred Sumner
ede2a494bc Fix UTF16 bug in await fetch().text() 2022-11-27 22:08:30 -08:00
Jarred Sumner
48df99c496 ✂️ dead code 2022-11-27 22:06:35 -08:00
Jarred Sumner
ed15259623 Fix Buffer.toString("latin1") and make Buffer.toString("utf16le") faster
Fixes #455
Fixes #1016
2022-11-27 20:21:41 -08:00
Jarred Sumner
4272038743 Fix failing buffer tests 2022-11-27 20:04:57 -08:00
Jarred Sumner
002f4ecc9e Fix crash in console.log 2022-11-27 19:37:14 -08:00
Jarred Sumner
495f25501f Increase the max prototype count 2022-11-27 09:32:40 -08:00
Jarred Sumner
0992c3867d Update bindings.cpp 2022-11-27 08:45:40 -08:00
Jarred Sumner
58a78ef8b7 [console.log] Remove extra indent 2022-11-27 08:41:08 -08:00
Jarred Sumner
740027975b Handle more cases with printing objects 2022-11-27 08:39:10 -08:00
Jarred Sumner
706406af48 remove leak 2022-11-27 07:58:10 -08:00
Jarred Sumner
39493e5d94 Add microbenchmark for console log 2022-11-27 07:40:10 -08:00
Jarred Sumner
a249c79983 Add tests for latin1 supplemental chars 2022-11-27 07:29:59 -08:00
Jarred Sumner
6459288c85 fix hanging test 2022-11-27 07:29:46 -08:00
Jarred Sumner
4726b7e227 don't start NetworkThread unless necessary 2022-11-27 07:29:40 -08:00
Jarred Sumner
358f388a46 Fix make headers 2022-11-27 07:29:07 -08:00
Jarred Sumner
4f35d0537b fix extra indent 2022-11-27 07:28:44 -08:00
Jarred Sumner
1d9c982488 [console.log] Fix printing latin1 supplement characters at runtime
Fixes https://github.com/oven-sh/bun/issues/1031#issuecomment-1236092120
2022-11-27 07:28:30 -08:00
Jarred Sumner
5e6e8ece4e [console.log] Improve Object formatting and error handling 2022-11-27 07:27:21 -08:00
Jarred Sumner
964c4037de [console.log] log Proxy objects 2022-11-27 07:26:16 -08:00
Jarred Sumner
1bc76511ec [console.log] Treat GlobalObject like Object 2022-11-27 07:25:55 -08:00
Jarred Sumner
35509126a6 [console.log] Treat ArrayBuffer like Uint8Array 2022-11-27 07:25:41 -08:00
Jarred Sumner
8765092591 [console.log] Fix logging Symbol values 2022-11-27 07:25:25 -08:00
Jarred Sumner
46678c46ee Now that utf16 is fast we can just count the length instead of re-allocating 2022-11-27 07:24:43 -08:00
Jarred Sumner
e8d948b9d9 Remove extra indent 2022-11-27 06:18:05 -08:00
Jarred Sumner
f891d1df50 Fix strangeness with Bun.env keys 2022-11-27 06:17:59 -08:00
Jarred Sumner
faad250559 Fix crash in Headers.prototype.count 2022-11-27 06:17:32 -08:00
Jarred Sumner
74e87b5a8a Fix crash in OnigurumaRegExp getters 2022-11-27 06:16:52 -08:00
Jarred Sumner
819a63e3ec Fix build issue 2022-11-26 22:14:29 -08:00
Jarred Sumner
c65c320b09 [bun:sqlite] Fix bug with latin1 supplemental characters
Fixes https://github.com/oven-sh/bun/issues/1553
2022-11-26 21:42:32 -08:00
Jarred Sumner
a53ed1bde1 prettier? 2022-11-26 21:29:53 -08:00
Jarred Sumner
d2190ea6f3 Update mimalloc 2022-11-26 21:20:38 -08:00
Jarred Sumner
b7850565f4 Update string_immutable.zig 2022-11-26 21:20:33 -08:00
Jarred Sumner
10996a797a Faster UTF16 -> UTF8 and UTF8 -> UTF16 (#1552)
* Fix freezing test

* Add SIMDUTF

* More micro bench snippets

* Update .gitattributes

* Update .gitattributes

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2022-11-26 21:04:38 -08:00
Jarred Sumner
949d715a14 Make HTTP status text more consistent with other HTTP servers 2022-11-26 18:03:20 -08:00
Jarred Sumner
90388aa7ea Add a console.log write bench 2022-11-26 06:27:49 -08:00
Jarred Sumner
1671977af7 Fix 0 2022-11-26 05:54:28 -08:00
Jarred Sumner
8aec181f16 Slightly improve when printing lots of numbers 2022-11-26 05:22:12 -08:00
Jarred Sumner
37753e9787 Make console.log prettier 2022-11-26 04:50:55 -08:00
Jarred Sumner
8519ff02e6 Prevent closing stdout / stderr 2022-11-25 22:55:35 -08:00
Jarred SUmner
397cb6600b Update test 2022-11-25 22:53:21 -08:00
Jarred SUmner
bef469ea55 Fix linux build issue 2022-11-25 22:53:07 -08:00
Jarred SUmner
ac7ad4d5c6 Fix double free 2022-11-25 22:52:32 -08:00
Jarred Sumner
0b27a26edb typo 2022-11-25 22:10:42 -08:00
Jarred Sumner
e12dc23c62 Use ccache for dependencies too 2022-11-25 21:14:57 -08:00
Jarred Sumner
7fec8a96ab Update zlib 2022-11-25 21:08:24 -08:00
Jarred Sumner
14b063d802 Simplify 2022-11-25 20:27:59 -08:00
Jarred Sumner
99fa95b954 Add some missing finalizers 2022-11-25 20:26:34 -08:00
Jarred Sumner
f27fdf932b Always watch 2022-11-25 20:26:18 -08:00
Jarred Sumner
d0dbafb32f Fix Subprocess.prototype.killed 2022-11-25 19:39:40 -08:00
Jarred Sumner
b5bd98c0ef Another test for macros 2022-11-25 07:04:08 -08:00
Jarred Sumner
e851e5fddb Fix macros that return a Promise 2022-11-25 06:48:02 -08:00
Jarred Sumner
1aff60d2ba More CCACHE 2022-11-25 06:24:34 -08:00
Jarred Sumner
d5c81b7423 Report Infinity when for non-regular files with a size of 0 2022-11-25 03:36:42 -08:00
Jarred Sumner
ddb6eced34 Update tests for behavior change 2022-11-25 03:04:12 -08:00
Jarred Sumner
5c3c50372b [internal] Log stat calls 2022-11-25 03:03:53 -08:00
Jarred Sumner
af0acaff37 [internal] Remove all usages of suspend and resume 2022-11-25 03:03:42 -08:00
Jarred Sumner
9090f06612 Fix memory leak with .json() 2022-11-25 03:02:56 -08:00
Jarred Sumner
7a193ed243 [behavior change] Bun.file().size now always reports a number 2022-11-25 03:02:45 -08:00
Jarred Sumner
c168c70e60 Improve test coverage for Bun.file 2022-11-25 03:01:37 -08:00
Jarred Sumner
557c2e97d7 Fix crash that sometimes occurred when freeing file data 2022-11-25 02:53:08 -08:00
Jarred Sumner
64871b2bfb Fix spurious assertion 2022-11-25 00:14:01 -08:00
Jarred Sumner
ce2cdb44e1 Use new enum for checking writable 2022-11-25 00:11:02 -08:00
Jarred Sumner
348ad87013 Enable Resizable ArrayBuffer proposal
https://github.com/tc39/proposal-resizablearraybuffer
2022-11-25 00:10:47 -08:00
Jarred Sumner
0e900c8ca9 Upgrade WebKit 2022-11-25 00:10:31 -08:00
Jarred Sumner
61673fa705 Add recv 2022-11-25 00:08:48 -08:00
Jarred Sumner
d1a4f4fd69 Introduce FileSink.ref() and FileSink.unref() 2022-11-25 00:08:36 -08:00
Jarred Sumner
0b915fed03 [streams] Always call start 2022-11-25 00:05:33 -08:00
Jarred Sumner
7b23cb5cd7 Fix reading FIFO files 2022-11-25 00:05:14 -08:00
Jarred Sumner
04328c163b [safety] Add a generation_number to FilePoll on macOS to check for use-after-free 2022-11-25 00:04:12 -08:00
Jarred Sumner
5a95fae533 Improve SIGPIPE handling 2022-11-24 18:57:58 -08:00
Jarred Sumner
47f0e14477 Use is_in_heap_region instead of _check_owned 2022-11-24 18:57:40 -08:00
Jarred Sumner
0ef25c65ec Add missing keys 2022-11-24 04:58:37 -08:00
Jarred Sumner
b0c89baac7 Fix crash when console.log() / console.error() fails to write to stdout/stdin 2022-11-24 04:26:04 -08:00
Jarred Sumner
7bc20c994c Fix missing sigpipe handler 2022-11-24 04:25:27 -08:00
Jarred Sumner
033b8936c9 Update streams.zig 2022-11-24 04:03:04 -08:00
Jarred Sumner
6336d01743 Add extra check 2022-11-24 03:55:04 -08:00
Jarred Sumner
cc062855af Add ccache to more steps 2022-11-24 03:54:54 -08:00
Jarred Sumner
d68f44d604 Don't pre-maturely close the input buffer 2022-11-24 03:54:32 -08:00
Jarred Sumner
ffacc1d02d Workaround strange crash 2022-11-24 03:53:26 -08:00
Jarred Sumner
1be13fa192 Update streams.zig 2022-11-24 02:41:14 -08:00
Jarred Sumner
46094189f4 update 2022-11-24 02:35:52 -08:00
Jarred Sumner
0c8fe888b9 Update streams.zig 2022-11-24 02:34:05 -08:00
Jarred Sumner
57fcd882fc Update streams.zig 2022-11-24 02:26:28 -08:00
Jarred Sumner
b2e48477db Update Dockerfile 2022-11-24 02:17:58 -08:00
Jarred Sumner
e4805d0895 Update bun-linux-build.yml 2022-11-24 02:10:42 -08:00
Jarred Sumner
e9eaab727b Update bun-linux-build.yml 2022-11-24 02:10:11 -08:00
Jarred Sumner
2ded9af4f7 Update bun-linux-build.yml 2022-11-24 02:07:55 -08:00
Jarred Sumner
2aa304a29d bump 2022-11-24 02:03:09 -08:00
Jarred Sumner
3419d3bc02 Update bun-mac-aarch64.yml 2022-11-24 01:57:24 -08:00
Jarred Sumner
a6644eac24 missing WORKDIR 2022-11-24 01:53:59 -08:00
Jarred Sumner
6c23035769 Attempt to make builds faster 2022-11-24 01:47:43 -08:00
Jarred Sumner
4a698ed52c [FileSystemRouter] Start to add types 2022-11-24 00:05:57 -08:00
Jarred Sumner
e1fcc810cb Remove extra newlines 2022-11-23 23:07:06 -08:00
Jarred Sumner
6bfb65b312 Add expect().toEqual() bench 2022-11-23 23:03:40 -08:00
Dylan Conway
dc330701d2 Bun.deepEquals and expect().toEqual() (#1548)
* all of deepEquals

* remove comment, tests, move inline function
2022-11-23 22:50:49 -08:00
Jarred Sumner
d434370500 uncomment 2022-11-23 21:46:56 -08:00
Jarred Sumner
9806c301dd Fix build error 2022-11-23 21:46:46 -08:00
Jarred Sumner
73416ebb62 nohang flag 2022-11-23 21:46:39 -08:00
Jarred Sumner
bddf484c2c Close the streams more 2022-11-23 21:31:38 -08:00
Jarred Sumner
21531f1e80 Linux build issue 2022-11-23 07:42:56 -08:00
Jarred Sumner
ac36ea51cf possibly more reliable Bun.spawn (#1547)
* wip

* wip

* Fix bug with stdin

* zig fmt

* seems to work!

* Update streams.test.js

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2022-11-23 07:14:33 -08:00
Jarred Sumner
ae3fcb5bd8 [FileSystemRouter] Fix reload() 2022-11-22 21:41:34 -08:00
Jarred Sumner
5767ad3fc5 Remove some dead code 2022-11-22 21:34:37 -08:00
Jarred Sumner
4f41c3fb40 [FileSystemRouter] Fix failing tests 2022-11-22 21:25:26 -08:00
Jarred Sumner
b249ed7257 [FileSystemRouter] Add more tests 2022-11-22 20:55:09 -08:00
Jarred Sumner
2b4dcc8c81 [FileSystemRouter] base_dir, Request, Response 2022-11-22 04:00:55 -08:00
Jarred Sumner
15a5aa1a68 Update filesystem_router.test.ts 2022-11-22 02:25:58 -08:00
Jarred Sumner
3cf229a898 Update launch.json 2022-11-22 02:13:25 -08:00
Jarred Sumner
e94172255d Support no constructor in class generator script 2022-11-22 02:13:19 -08:00
Jarred Sumner
d21aee5143 Introduce Bun.FileSystemRouter API 2022-11-22 02:13:03 -08:00
Jarred Sumner
65a56c2560 clone in putRecord 2022-11-22 02:09:57 -08:00
Jarred Sumner
1bd71f2f44 Handle when package version is missing 2022-11-21 18:34:18 -08:00
Jarred Sumner
fe33073f2e Use const ptr 2022-11-21 18:33:55 -08:00
Jarred Sumner
14d52897ad Update README.md 2022-11-21 17:49:07 -08:00
Jarred Sumner
ca434fba6e make it slightly clearer 2022-11-21 17:37:12 -08:00
Jarred Sumner
55f8029dc2 Add test for wildcard import without an extension 2022-11-21 17:31:42 -08:00
João Paquim
a3dc33c133 Wildcard imports map (#1483)
* Log extra info on missing file extension

* Improve error messages for missing /index.js on import

* Remove unnecessary function parameter path

* Add loadPackageImports function to match esbuild

* Add support for pattern trailer import syntax

* Fix review comments
2022-11-21 17:31:02 -08:00
Jarred Sumner
a274ddba3a [bun:test] Add test for returning MAX_SAFE_INTEGER 2022-11-21 17:02:43 -08:00
Dylan Conway
8e36485a76 fix oniguruma regex character properties (#1528)
* fix for character properties

* cleanup tests

* cleanup comments

* i - 2 >= 0
2022-11-21 16:52:00 -08:00
Dylan Conway
5f2e74bbcc specific error for invalid flag, correct position' (#1537)
'
2022-11-21 16:51:34 -08:00
Jarred Sumner
ce6fc8609b [bun:sqlite] fix truncating to int32 in results (now truncates to int52)
TODO: bigint
2022-11-21 16:46:45 -08:00
Jarred Sumner
a251669fa1 Make it yellow 2022-11-20 17:58:13 -08:00
Jarred Sumner
4f6636b3ca Update jest.zig 2022-11-20 16:48:09 -08:00
Jarred Sumner
28a3093d48 Print a count 2022-11-20 16:48:02 -08:00
Jarred Sumner
fe0506b88e Bump! 2022-11-20 16:31:11 -08:00
Jarred Sumner
e78f891acd [bun:test] Fix bug with returning a non-promise object in a test or it function 2022-11-20 14:35:48 -08:00
Jarred Sumner
948fdfe482 Fix spurious rejected promise handler calls 2022-11-20 14:33:57 -08:00
Jarred Sumner
757d19c2f7 Assert count 2022-11-20 07:12:01 -08:00
Jarred Sumner
a4b67ccbff fix protocol relative urls again 2022-11-20 07:03:50 -08:00
Jarred Sumner
1fca6becd3 Enable previously failing GC tests 2022-11-20 07:03:11 -08:00
Jarred Sumner
6965b5c192 mild clean up 2022-11-20 07:02:53 -08:00
Jarred Sumner
dfa62b660d [internal] Implement visitAdditionalChildren 2022-11-20 07:02:14 -08:00
Jarred Sumner
5ff2cd3418 [streams] Fix memory leak affecting React SSR and more 2022-11-20 06:58:29 -08:00
Jarred Sumner
f56eec6fa3 run clang-format on JSSink 2022-11-20 06:56:05 -08:00
Jarred Sumner
65330a32cc [jsx] Disable jsxs 2022-11-20 04:55:36 -08:00
Jarred Sumner
003237b086 Typo 2022-11-20 01:45:57 -08:00
Jarred Sumner
70f89b1bfc Add another test 2022-11-20 01:44:27 -08:00
Jarred Sumner
4f5f01a748 Fix flaky test 2022-11-20 01:44:18 -08:00
Jarred Sumner
e41d7a0bd5 [fetch] Add optimization for chunked encoding 2022-11-20 01:43:40 -08:00
Jarred Sumner
b745ae2667 [TCP] Make Socket more careful about GC 2022-11-20 00:58:46 -08:00
Jarred Sumner
2f1e9b2eb8 [streams] Fix exception in WritableStream
cc @Electroid
2022-11-19 23:37:52 -08:00
Jarred Sumner
c68b11e8cb [streams] Fix exception in streams with 1 item that sometimes occurred 2022-11-19 23:05:03 -08:00
Jarred Sumner
16d20bde09 Set aggression level in tests 2022-11-19 22:35:26 -08:00
Jarred Sumner
bea44d948e Fix freezing test due to calling GC 36,000 times 2022-11-19 22:35:16 -08:00
Jarred Sumner
b230e7a73a [fetch] Fix sporadic data corruption bug in HTTP client and add fast path
- This removes memory pooling from the HTTP client which sometimes caused invalid memory to be written to the response body.
- This adds a fast path for small HTTP/HTTPS responses that makes it a single memory allocation for the response body, instead of copying & allocating a temporary buffer

cc @Electroid
2022-11-19 22:34:57 -08:00
Jarred Sumner
e024116b77 Add a couple more tests for redirects 2022-11-19 22:23:45 -08:00
Jarred Sumner
79b6d4734a [internal] Add a function for appending without growing extra data 2022-11-19 22:23:20 -08:00
Jarred Sumner
dc26181da4 Add a log 2022-11-19 22:22:04 -08:00
Jarred Sumner
0603991beb Make hidden mimalloc dump report process-wide stats instead of thread 2022-11-19 22:21:58 -08:00
Jarred Sumner
17fa4211ac Introduce Bun.unsafe.gcAggressionLevel API 2022-11-19 22:21:35 -08:00
Jarred Sumner
81a1d8f589 [internal] Add assertion for freeing global strings 2022-11-19 22:15:20 -08:00
Jarred Sumner
055f1e9639 [napi] Fix missing instance data finalizer 2022-11-19 22:14:47 -08:00
Jarred Sumner
cac11ee826 [fetch] Fix bug with redirecting to a protocol-relative URL 2022-11-19 22:14:10 -08:00
Jarred Sumner
f8d9a8be87 [fetch] Fix bug with redirects losing the port number 2022-11-19 22:13:30 -08:00
Jarred Sumner
9c601542d0 Update to Mimalloc v2.0.7 2022-11-19 21:37:31 -08:00
Jarred Sumner
7c7769a7c7 Fix GC crash when handling rejected promises uncovered via BUN_GARBAGE_COLLECTOR_LEVEL 2022-11-19 04:59:38 -08:00
Jarred Sumner
17e8181b4e Fix GC crash in Bun.file(string).text(), Bun.file(string).arrayBuffer(), Bun.file(string).json() uncovered via BUN_GARBAGE_COLLECTOR_LEVEL 2022-11-19 04:59:17 -08:00
Jarred Sumner
ee939f7a6d Fix GC crash in Transpiler found via BUN_GARBAGE_COLLECTOR_LEVEL 2022-11-19 04:58:39 -08:00
Jarred Sumner
6cc89eff2c [internal] Introduce JSPromise.Strong 2022-11-19 04:57:59 -08:00
Jarred Sumner
d6d04cab24 Fix GC crash with WebSocket uncovered thx to BUN_GARBAGE_COLLECTOR_LEVEL 2022-11-19 04:57:32 -08:00
Jarred Sumner
bb95f90a62 Introduce BUN_GARBAGE_COLLECTOR_LEVEL debug environment variable 2022-11-19 04:56:46 -08:00
Jarred Sumner
1806322554 Fix failing test 2022-11-19 04:16:31 -08:00
Jarred Sumner
38b5a85d8a Fix a GC issue with Bun.spawn
The `Subprocess` object stays alive until the process exits, even if it's never referenced
2022-11-19 01:25:15 -08:00
Jarred Sumner
68b55cd855 Implement a singleton version of napi_get_instance_data and napi_set_instance_data
Still need to figure out how to do this without adding a layer of indirection to the global object as exposed to NAPI Addons

This code is not tested
2022-11-19 01:18:58 -08:00
Dylan Conway
43b4e1b67b bun test matchers and tests (#1526)
* ignore webkit for cherry-pick

* toContain and toBeTruthy

* toBe null, undefined, falsy, toHaveProperty, .not

* markBindings

* remove toHaveProperty, undo ignore webkit, more tests

* undo ignore webkit

* remove bad tests

* check if length property exists for toHaveLength()

* fix call signature

* handle argument that is not an integer

* getLengthOfArray returns u64

* switch to truncate

* toHaveLength() edge cases

* add toBooleanSlow()

* infinity, nan, negative
2022-11-18 23:03:39 -08:00
Jarred Sumner
f3fb712051 Fix crash in process.env.FOO = bar that happened sometimes 2022-11-18 03:47:10 -08:00
Jarred Sumner
f6779193c0 console.timeLog() but no extra arguments yet 2022-11-16 05:16:30 -08:00
Jarred Sumner
29f72efac3 Mark some more commonjs modules 2022-11-16 05:15:56 -08:00
Jarred Sumner
4985a44fe2 Remove incorrect assertion 2022-11-16 05:13:17 -08:00
Jarred Sumner
6a9bc6f6c2 Another test 2022-11-16 04:58:51 -08:00
Jarred Sumner
bf6b174233 Make node:http.createServer work better 2022-11-16 04:42:33 -08:00
Jarred Sumner
5de98f23bb Fix another assertion failure 2022-11-15 23:23:36 -08:00
Jarred Sumner
1d02104c51 Fix assertion failure 2022-11-15 23:23:23 -08:00
Jarred Sumner
4f22c39651 Handle trailing slash 2022-11-15 22:10:09 -08:00
Jarred Sumner
6c01a1191f Fixes #1390 2022-11-15 21:58:31 -08:00
Jarred Sumner
b95f7d5bbc Fixes #1403
cc @Electroid this should fix the fly.io api issue too
2022-11-15 21:40:54 -08:00
Jarred Sumner
c32013dbba Never resize on close 2022-11-15 21:37:28 -08:00
Jarred Sumner
6cdb7e77dd Handle blocking initial read 2022-11-15 21:01:08 -08:00
Jarred Sumner
0e7ed4c667 Prevent blocking write() 2022-11-15 20:57:21 -08:00
Jarred Sumner
3b802c9a13 Add non-standard headers API types
cc @colinhacks @Electroid
2022-11-15 18:32:57 -08:00
Jarred Sumner
996e5dd235 Add test for non-standard Headers API additions 2022-11-15 18:31:22 -08:00
Dylan Conway
025749027b add generated getter/setter type with thisValue (#1513) 2022-11-15 17:47:38 -08:00
Jarred Sumner
44babb9ce5 Update ZigGlobalObject.cpp 2022-11-15 00:12:34 -08:00
Jarred Sumner
a63fe2be24 Add a test with decently large headers 2022-11-15 00:12:34 -08:00
Jarred Sumner
bf75f61ddf Update test types a little
cc @colinhacks

`test` is an alias of `it`

`done` accepts an `error` object
2022-11-15 00:12:34 -08:00
Jarred Sumner
1b608fcc8a Add missing type 2022-11-15 00:12:34 -08:00
Dylan Conway
c4cf38601b switch default encoding order (#1510) 2022-11-14 22:00:45 -08:00
Jarred Sumner
25fc19e7c6 Fix spawn macOS issue 2022-11-14 21:52:04 -08:00
Jarred Sumner
9c3b2f7ad6 Fix crash in web crypto. caused by refptr 2022-11-14 19:55:48 -08:00
Jarred Sumner
436b8e1461 Fix crashiness with process.env
This also makes it a lot slower
2022-11-14 17:53:15 -08:00
Jarred Sumner
272e71fec2 Fix string encoding issue in JSC C API usages 2022-11-14 17:53:15 -08:00
Jarred Sumner
4ba97c7687 Prevent double-frees in log msgs 2022-11-14 17:53:15 -08:00
Jarred SUmner
3df5843503 Fix build error 2022-11-14 04:14:23 -08:00
Jarred SUmner
20eff9f6d2 Bugfixes and perf improvements to child_process 2022-11-14 04:08:36 -08:00
Jarred Sumner
69eedb4c92 use write$NOCANCEL, more logging 2022-11-13 21:57:14 -08:00
Jarred Sumner
4a8bbc2216 Add an e2e test 2022-11-13 20:51:27 -08:00
Jarred Sumner
92b766095d Add missing rmdir export 2022-11-13 20:09:37 -08:00
Jarred Sumner
b18e4064a2 Make node streams faster (#1502)
* Make node streams faster

* Fix for macOS, improve performance, handle ref and unref

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2022-11-13 19:14:44 -08:00
Jarred Sumner
58b67347e6 Fix incorrect exit status message 2022-11-13 02:38:54 -08:00
Jarred Sumner
1a0fb4cf83 Fix syntax error 2022-11-12 23:43:24 -08:00
Jarred SUmner
6393e1e709 Set linker script to Bun 0.2 2022-11-12 20:40:04 -08:00
Jarred SUmner
a78b6f920d Fix infinite write loop on Linux 2022-11-12 20:28:10 -08:00
Jarred SUmner
7da520b22e Add missing type 2022-11-12 20:28:10 -08:00
Tom Birch
45dc75b3be Add linker script to remove unwanted exports (#1499) 2022-11-12 20:22:38 -08:00
Jarred SUmner
1cce9da80a Fix memory leak in gzip pool + add test for gzip'd data 2022-11-12 18:32:53 -08:00
Jarred Sumner
21bf3ddaf2 Redo how we poll pipes (#1496)
* Fix pipe

* Handle unregistered

* Fix failing test
2022-11-12 18:30:12 -08:00
Jarred Sumner
514f2a8edd Add test that fails on linux 2022-11-11 16:02:35 -08:00
Jarred Sumner
5f5d74c534 2 frames 2022-11-11 04:18:15 -08:00
Jarred Sumner
b3b70035a1 Revert "Omit frame pointer"
This reverts commit 4f91f66a37.
2022-11-11 02:10:16 -08:00
Jarred Sumner
666f5c5ea9 Don't rm cached 2022-11-11 01:12:41 -08:00
Jarred Sumner
55488ad77f try this 2022-11-11 00:51:39 -08:00
Jarred Sumner
23fd28afc3 Update bun-linux-build.yml 2022-11-11 00:48:39 -08:00
Jarred Sumner
f6cb20f516 try using git action 2022-11-11 00:48:05 -08:00
Jarred Sumner
096abc638a Remove with git rm 2022-11-11 00:43:55 -08:00
Jarred Sumner
d3fc1ee7d2 Reactivate 2022-11-11 00:43:18 -08:00
Jarred Sumner
cd2bf2591d Re-add 2022-11-11 00:42:58 -08:00
Jarred Sumner
8428bd90a3 Delete .keep 2022-11-11 00:38:20 -08:00
Jarred Sumner
6872af907c Update .gitmodules 2022-11-11 00:38:09 -08:00
Jarred Sumner
dc906ba0c7 Create .keep 2022-11-11 00:37:10 -08:00
Jarred Sumner
36b814de57 Delete libbacktrace 2022-11-11 00:34:44 -08:00
Jarred Sumner
142ad97886 Update main.zig 2022-11-11 00:33:10 -08:00
Jarred Sumner
cbc3daf739 Update .gitmodules 2022-11-11 00:30:05 -08:00
Jarred Sumner
4f91f66a37 Omit frame pointer 2022-11-11 00:28:45 -08:00
Jarred Sumner
1671e3cc7e Remove dead code 2022-11-11 00:20:42 -08:00
Jarred Sumner
24a85f8de6 Improve error message 2022-11-11 00:20:42 -08:00
Jarred Sumner
2432150321 Replace libbacktrace with WTFGetBacktrace 2022-11-11 00:20:42 -08:00
Ashcon Partovi
38141e3aa7 Allow install script to specify debug-info variant with debug symbols (#1484) 2022-11-10 20:14:41 -08:00
Jarred Sumner
5f5ef81f11 [bun install] Support implicit pre tags in dependency versions 2022-11-10 19:52:39 -08:00
Jarred Sumner
a1e786011d [bun run] Fix potential crash when a command terminates abnormally 2022-11-10 19:50:35 -08:00
Jarred Sumner
7b4c8802a1 ✂️ 2022-11-10 15:07:12 -08:00
Jarred Sumner
dddbce8a41 Implement napi_create_external and napi_get_value_external 2022-11-10 15:05:23 -08:00
Dylan Conway
7ce8328d28 add ... switch case (#1482) 2022-11-10 13:08:32 -08:00
Jarred Sumner
b62c45fea3 Increase stackframe count 2022-11-10 00:02:16 -08:00
Jarred Sumner
7deca69820 Update websocket-server.test.ts 2022-11-09 23:57:24 -08:00
Jarred Sumner
8753c483ff Implement Server.publish()
Fixes https://github.com/oven-sh/bun/issues/1417
2022-11-09 23:54:56 -08:00
Jarred Sumner
2149e1f0a0 Update server.zig 2022-11-09 23:42:36 -08:00
Jarred Sumner
c52ebd96ba Fix crash when an exception occurs in open() 2022-11-09 23:42:30 -08:00
Jarred Sumner
904716f56b Clone all the strings 2022-11-09 22:55:10 -08:00
Jarred Sumner
a858261832 Clone the text 2022-11-09 22:45:02 -08:00
Jarred Sumner
9fccbf9364 Remove bun:wrap from stack traces 2022-11-09 22:44:45 -08:00
Jarred Sumner
41a023e21d Add another log 2022-11-09 18:56:17 -08:00
Jarred Sumner
cf378d51fd Fix broken stacktraces 2022-11-09 18:56:17 -08:00
Derrick Farris
7f5022db0c fix(child_process): fix execFileSync options.input (#1479)
* fix(child_process): fix execFileSync options.input

* fix(child_process): debug err, check for Uint8Array too

* fix(child_process): fix ArrayBufferIsView call

* test(child_process): fix missing toString() call on test result

* refactor(child_process): change options.input to input to getter calls
2022-11-09 18:10:29 -08:00
Jarred Sumner
9ea025c543 remove this
wrong approach
2022-11-09 17:23:48 -08:00
Jarred Sumner
477747142a Update bun-types-tests.yml 2022-11-09 17:13:54 -08:00
Jarred Sumner
29b0e3eaf7 Only run this for bun-types 2022-11-09 17:12:44 -08:00
Jarred Sumner
9ab21ceb59 Clarify 2022-11-09 17:11:25 -08:00
Colin McDonnell
f7f1b60444 Add bun-types, add typechecking, add child_process types (#1475)
* Add bun-types to packages

* Improve typing

* Fix types in tests

* Fix dts tests

* Run formatter

* Fix all type errors

* Add strict mode, fix type errors

* Add ffi changes

* Move workflows to root

* Add workflows

* Remove labeler

* Add child_process types

* Fix synthetic defaults issue

* Remove docs

* Move scripts

* Run prettier

* Include examples in typechecking

* captureStackTrace types

* moved captureStackTrace types to globals

* Address reviews

Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
2022-11-09 15:40:40 -08:00
Jarred Sumner
da257336b0 Fix #1354 2022-11-09 15:11:14 -08:00
Jarred Sumner
565996a087 Support TypeScript satisfies
Credit: @magic-akari, almost identical diff in https://github.com/evanw/esbuild/pull/2509/files#diff-ccc0bde7223236d93490b727b272f15765a2674be12a4c310b83b9555bef8816
2022-11-09 01:30:02 -08:00
Jarred Sumner
fac1c49727 Fixup 2022-11-09 01:15:36 -08:00
Jarred Sumner
3a760ec0ec Update response.zig 2022-11-09 01:12:35 -08:00
Jarred Sumner
d90a638101 Re-enable workaround for 127.0.0.01 2022-11-09 01:12:35 -08:00
Dylan Conway
047a8d3f0d Error.captureStackTrace implementation (#1476)
* capture stack trace formatting, tests

* fix callsite methods, stack formatting or undefined

* isNative, tests for callsite methods

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

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

* template and macros for visitchildren

* static strings, handle infinity and clamp stacktracelimit

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2022-11-09 00:37:57 -08:00
Jarred Sumner
2c4777f579 [libarchive][bun install] Fix file permissions not always being passed correctly in bun install
Fixes #1092
2022-11-09 00:32:50 -08:00
Jarred Sumner
0642cf31f3 [bun install] Support bin with bun link 2022-11-08 23:51:02 -08:00
Jarred Sumner
b1b3f7af54 Update bindings.cpp 2022-11-08 22:39:45 -08:00
Jarred Sumner
cb41d77d2a Fixes #1426 2022-11-08 22:27:22 -08:00
Jarred Sumner
0fd7d3a8c3 Fix incorrectly reporting URL sizes to GC in some cases 2022-11-08 22:26:58 -08:00
Jarred Sumner
8bc459ba99 Guard against closing the same pid twice 2022-11-08 22:08:49 -08:00
Jarred Sumner
5c312ec0c9 Only perform this check on macOS 2022-11-08 22:07:59 -08:00
Jarred Sumner
bf92c36be1 Fixes #1320
Tests pass now on linux
2022-11-08 22:05:59 -08:00
Jarred Sumner
253cb391b3 Remove base64 library 2022-11-08 21:32:08 -08:00
Jarred Sumner
55c262a321 handle undefined better 2022-11-08 21:31:21 -08:00
Jarred Sumner
af3931371e Fix Buffer.from(text, "base64") and Buffer.toString("base64") 2022-11-08 21:30:54 -08:00
Derrick Farris
9ccc455f8d Fix child_process tests (#1471)
* test(child_process): fix broken tests, add our-assert pkg for testing

* test(child_process): replace console.log with debug()

* test(child_process): rename our-assert -> node-test-helpers, use Bun.peek for subproc.exited
2022-11-08 15:33:47 -08:00
Jarred Sumner
8b0a3c75cb Fix #1473 2022-11-08 15:30:09 -08:00
Jarred Sumner
fac4efb9b9 Add a test for DOMJIT call version of TextDecoder 2022-11-08 15:28:30 -08:00
Jarred Sumner
f17080df7f Add a couple more tests for typeof 2022-11-08 15:27:55 -08:00
Jarred Sumner
2077e563b7 Fix failing transpiler tests 2022-11-08 15:26:29 -08:00
Jarred Sumner
1604666988 20% faster TextDecoder on small inputs 2022-11-08 12:55:45 -08:00
Jarred Sumner
6c6e680d91 Allow read_only packages to check the cache 2022-11-08 03:02:20 -08:00
Jarred Sumner
9f222c5ed2 Default enable optional dependencies for remote packages 2022-11-08 03:01:41 -08:00
Jarred Sumner
3d0b297306 Fix error message 2022-11-08 03:01:30 -08:00
Jarred Sumner
ce5cbb0491 Install optional dependencies for auto-install 2022-11-08 03:01:12 -08:00
Jarred Sumner
9bf03a84c1 Update crypto.js 2022-11-08 00:29:32 -08:00
Jarred Sumner
3e9bb6859b Stack allocate arguments to make it actually threadsafe 2022-11-08 00:28:14 -08:00
Jarred Sumner
86f0b08b8d Add missing exports 2022-11-08 00:14:17 -08:00
Jarred Sumner
38db5f1c83 Fix Buffer.slice and Buffer.subarray 2022-11-08 00:07:25 -08:00
Jarred Sumner
9f10724eda cast 2022-11-07 21:53:31 -08:00
Jarred Sumner
bb8c803bdf Fix newline normalization
credit: @Validark
2022-11-07 21:43:38 -08:00
Jarred Sumner
9d167deb10 Credit: @Validark 2022-11-07 21:43:38 -08:00
Niles Salter
093fe1bae9 Add more tags to be usable with typeof (#1258) 2022-11-07 21:10:19 -08:00
Niles Salter
9dc3fbcfc4 Remove improper coercion of environment variables (#1256) 2022-11-07 21:04:49 -08:00
Jarred Sumner
be9bab5c29 Update ZigGlobalObject.cpp 2022-11-07 20:52:21 -08:00
Jarred Sumner
52eac73726 Fix peek test 2022-11-07 20:49:19 -08:00
Jarred Sumner
f05e23ed20 Return a rejected promise if there was an error 2022-11-07 20:43:53 -08:00
Jarred Sumner
b4abb0f337 Visit all the fields 2022-11-07 20:43:34 -08:00
Jarred Sumner
41c983b386 clean up some reliability issues with automatic install 2022-11-07 19:50:54 -08:00
Jarred Sumner
f84b2ec6d1 Handle threadsafety issue 2022-11-07 19:50:54 -08:00
Ikko Ashimine
e0cb7e4342 Fix typo in Dockerfile (#1468)
specifc -> specific
2022-11-07 18:39:44 -08:00
Jarred Sumner
204f514633 [JS Parser] Do not perform the visit pass if the parse pass had "tolerable" errors 2022-11-07 16:00:14 -08:00
Jarred Sumner
5005188a13 Fix a couple failing tests 2022-11-07 15:20:47 -08:00
Jarred Sumner
8189f78eed Maybe fix bug with onExit callback? 2022-11-07 14:57:47 -08:00
Jarred Sumner
2eb19a96b1 Support unlimited arguments in process.nextTick 2022-11-07 14:14:19 -08:00
Jarred Sumner
fd26d2e9fa Fix missing error in process.nextTick and queueMicrotask 2022-11-07 14:13:55 -08:00
Jarred Sumner
370d9c2931 [bun:test] Rejected promises should cause tests to fail 2022-11-07 05:13:54 -08:00
Jarred Sumner
c00359a521 [bun:test] Implement done callback with support for async functions 2022-11-07 04:49:10 -08:00
Jarred Sumner
71d0e14210 [bun:test] Implement expect in faster Zig bindings 2022-11-07 00:53:24 -08:00
Jarred Sumner
d925367cae [bindings generator] Support cached values that do not correspond to properties and support call() functions 2022-11-07 00:51:36 -08:00
Jarred Sumner
179cd18f70 Handle types which do not support getting an object 2022-11-07 00:50:49 -08:00
Jarred Sumner
072cd5a745 Fix UAF in canary 2022-11-07 00:50:32 -08:00
Jarred Sumner
c52d9fd1b6 Bump 2022-11-06 21:45:45 -08:00
Jarred Sumner
e45f72e8e4 Automatically install npm packages when running a script in Bun's runtime (#1459)
* Update bundler.zig

* WIP

* Update README.md

* Update README.md

* wip

* Support running scripts without package.json

* Add `--no-auto-install` and `--prefer-offline` flags

* WIP

* wip

* Update headers-handwritten.h

* WIP

* Build fixes

* Fix UAF

* Update install.zig

* Must call .allocate()

* Micro-optimization: only call .timestamp() once per tick when installing packages

* Support progress bar

* Extend the timestamp for package staleness checks to 1 day

* Add `--prefer-latest`, `-i` CLI Flags

* Fix crash

* Support line text manually being set on an Error instance

* Add a few more fields for error messages

* Fix bug when counting 8 character strings in string builder

* Implement error handling for automatic package installs!

* Fix crash

* Make it say module when there's a slash

* Update module_loader.zig

* Ban dependency versions in import specifiers when a package.json is present

* Remove unused field

* Update README.md

* Update README.md

* Update README.md

* Update README.md

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2022-11-06 21:42:05 -08:00
Carter Snook
645cf90335 chore: remove space lookalike (#1465) 2022-11-06 18:03:06 -08:00
Jarred Sumner
e5b2e3c602 Fixes https://github.com/oven-sh/bun/issues/1451 2022-11-06 18:00:01 -08:00
Jarred Sumner
897d7bd564 Add way to explicitly coercion object to int32 2022-11-06 17:59:32 -08:00
Jarred Sumner
07cb04e311 Fix symbol error with make headers
cc @lawrencecchen
2022-11-06 17:45:16 -08:00
Jarred Sumner
b1fcc9e6bf Fix bug when passing ABI Types as integers 2022-11-06 17:45:05 -08:00
Jarred Sumner
1f174b9d95 Fixes https://github.com/oven-sh/bun/issues/1462 2022-11-06 16:14:46 -08:00
Jarred Sumner
c154402c45 Undo 2022-11-06 16:02:10 -08:00
Jarred Sumner
17b8056b31 Update action.yml 2022-11-06 15:45:28 -08:00
Jarred Sumner
40160ec6d6 Prettier 2022-11-06 15:35:35 -08:00
Jarred Sumner
fe92a89b93 Pass tar -C 2022-11-06 15:35:18 -08:00
Jarred Sumner
1cb5a73243 [TypeScript] Fix export = value 2022-11-06 15:26:12 -08:00
Jarred Sumner
70fa1564c2 Fix artifact name, use tarball 2022-11-06 15:02:58 -08:00
Jarred Sumner
fcd8397db2 Try tarball 2022-11-06 14:51:44 -08:00
Jarred Sumner
4688d72945 Try again 2022-11-06 14:33:04 -08:00
Jarred Sumner
c55f59e030 Node12 is deprecated 2022-11-06 14:09:24 -08:00
Derrick Farris
be108c0fea feat(child_process): add node:child_process polyfill (#1424)
* feat(child_process): beginning of child_process, add ChildProcess and spawn base case

* fix(child_process): remove invalid single arg array syntax (thanks Copilot)

* refactor(child_process): unhack Readable.on, move stuff into node:stream

* feat(child_process): add more params for spawn, refactor, add fromWeb() to Readable

* feat(child_process): finish rest of exports (minus fork), refactor, add tests

* cleanup(streams): remove a bunch of unnecessary stuff

* cleanup(child_process): remove dead refs

* fix(child_process): fix stdio

* fix(child_process): change stdio to bunStdio

* test(child_process): uncomment timeout test

* test(child_process): fix hanging tests

* test(child_process): remove stray console.log

* test(child_process): fix cwd test for linux

* refactor(child_process): divide paths for encoded vs raw execFile stdio

* fix(child_process): fix logic for execFile slow path
2022-11-06 13:43:42 -08:00
Derrick Farris
4e3fb8ed5b fix(subprocess): fix typo in spawnSync (#1464) 2022-11-06 03:41:32 -08:00
zhiyuan
9d3f1e0d26 Fix fetch api to accept stringifier object (#1460)
* fetch accept stringifier object

* test: update fetch params tests
2022-11-05 18:51:02 -07:00
Jarred Sumner
88ca7fd738 Fix crash in setTimeout/setInterval 2022-11-03 23:38:23 -07:00
Jarred Sumner
30e1fe1035 Fix incorrect exit code 2022-11-03 23:38:07 -07:00
Jarred Sumner
562595fa02 Fix crash when reading promise value wihtout checking if null 2022-11-03 23:37:54 -07:00
Jarred Sumner
d6520cd761 Fix which not handling absolute paths to a bin
This code has not been tested.
2022-11-03 23:22:51 -07:00
Jarred Sumner
13cfca4814 Fix cmd not found in $PATH printing raw struct 2022-11-03 23:02:49 -07:00
Jarred Sumner
e20461d961 Delete unused file 2022-11-03 23:02:23 -07:00
Colin McDonnell
d04c0d51fe Add minified prod build of react-dom/server.bun (#1458)
Co-authored-by: Colin McDonnell <colinmcd@alum.mit.edu>
2022-11-03 18:10:42 -07:00
Hyro
a5b25c5a79 chore: remove unecessary files (#1457)
* Delete labeler.yml

* Delete labels.yml
2022-11-03 12:42:44 -07:00
Jarred Sumner
6142715c06 Introduce import.meta.primordials for builtin JS
the `import.meta` object in Bun now has a `primordials` object which makes a handful of globals safe for access. Inside of bun: or node: modules, it is a special object (ownKeys is not implemented, so Object.keys() wont work on it)

- Array
- String
- `isPromise`
- `isCallable`
- `isConstructable`
- `tryGetById(foo, "bar')` which is like foo?.bar
- `arrayPush` which is like `Array.prototype.push`
- `Bun`
- `isAbortSignal`

cc @ThatOneBro @lawrencecchen
2022-11-03 00:18:26 -07:00
Jarred Sumner
34e130a3e0 Add a misc snippet 2022-11-02 20:46:24 -07:00
Jarred Sumner
09434f1486 Add failing test 2022-11-02 20:44:49 -07:00
Jarred Sumner
1a92b92f8a Add failing wildcard test 2022-11-02 20:44:13 -07:00
Jarred Sumner
fb903bb091 Update headers-handwritten.h 2022-11-02 20:10:12 -07:00
Jarred Sumner
34fce03f0f Add missing headers 2022-11-02 20:09:38 -07:00
Jarred Sumner
bfa40d1d3f Fix 4/4 failing tests 2022-11-02 20:00:44 -07:00
Jarred Sumner
f829bd7190 Fix 5/9 failing tests 2022-11-02 19:55:45 -07:00
Jarred Sumner
ab4e662484 Update ZigGlobalObject.cpp 2022-11-02 19:37:06 -07:00
Jarred Sumner
35ba83584f Fixes #1448 #1450 2022-11-02 19:25:52 -07:00
Jarred Sumner
50cf083668 Fix missing functions 2022-11-02 18:54:42 -07:00
1476 changed files with 267199 additions and 89131 deletions

View File

@@ -1,7 +1,7 @@
#!/bin/bash
curl -L https://github.com/Jarred-Sumner/vscode-zig/releases/download/march18/zig-0.2.5.vsix >/home/ubuntu/vscode-zig.vsix
git clone https://github.com/oven-sh/zls /home/ubuntu/zls
git clone https://github.com/zigtools/zls /home/ubuntu/zls
cd /home/ubuntu/zls
git checkout 30869d7d8741656448e46fbf14f14da9ca7e5a21
git submodule update --init --recursive --progress --depth=1
zig build -Drelease-fast
zig build -Doptimize=ReleaseFast

2
.gitattributes vendored
View File

@@ -6,3 +6,5 @@ src/bun.js/bindings/sqlite/sqlite3.c linguist-vendored
src/bun.js/bindings/sqlite/sqlite3_local.h linguist-vendored
*.lockb binary diff=lockb
*.zig text eol=lf
src/bun.js/bindings/simdutf.cpp linguist-vendored
src/bun.js/bindings/simdutf.h linguist-vendored

View File

@@ -15,7 +15,7 @@ body:
attributes:
label: What platform is your computer?
description: |
For MacOS and Linux: copy the output of `uname -mprsv`
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:

View File

@@ -1,6 +1,6 @@
name: 🐛 Bug Report
description: Report an issue that should be fixed
labels: [bug, need repro]
labels: [bug]
body:
- type: markdown
attributes:
@@ -19,15 +19,14 @@ body:
attributes:
label: What platform is your computer?
description: |
For MacOS and Linux: copy the output of `uname -mprsv`
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: Enter the details about your bug. If possible, please provide a small code snippet that can reproduce the issue.
- type: textarea
attributes:
label: How often does it reproduce? Is there a required condition?
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?
@@ -36,8 +35,6 @@ body:
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

View File

@@ -1,6 +1,6 @@
name: 📗 Documentation Request
name: 📗 Documentation Issue
description: Tell us if there is missing or incorrect documentation
labels: [documentation]
labels: [docs]
body:
- type: markdown
attributes:
@@ -18,8 +18,6 @@ body:
- Documentation is confusing
- Example code is not working
- Something else
validations:
required: true
- type: textarea
attributes:
label: What is the issue?
@@ -28,4 +26,4 @@ body:
- type: textarea
attributes:
label: Where did you find it?
description: If possible, please provide the URL(s) where you found this issue.
description: If possible, please provide the URL(s) where you found this issue.

52
.github/labeler.yml vendored
View File

@@ -1,52 +0,0 @@
chore:
- any: ['*', '**/*']
all: ['!packages/*', '!packages/**/*', '!src/*', '!src/**/*', '!types/*', '!types/**/*', '!test/*', '!test/**/*', '!bench/*', '!bench/**/*', '!examples/*', '!examples/**/*']
'packages:bun':
- src/*
- src/**/*
'packages:bun-darwin-aarch64':
- packages/bun-darwin-aarch64/*
- packages/bun-darwin-aarch64/**/*
'packages:bun-error':
- packages/bun-error/*
- packages/bun-error/**/*
'packages:bun-framework-next':
- packages/bun-framework-next/*
- packages/bun-framework-next/**/*
'packages:bun-landing':
- packages/bun-landing/*
- packages/bun-landing/**/*
'packages:bun-linux-x64':
- packages/bun-linux-x64/*
- packages/bun-linux-x64/**/*
'packages:bun-macro-relay':
- packages/bun-macro-relay/*
- packages/bun-macro-relay/**/*
'packages:bun-types':
- packages/bun-types/*
- packages/bun-types/**/*
- types/bun/*
'packages:bun-wasm':
- packages/bun-wasm/*
- packages/bun-wasm/**/*
'tests':
- test/*
- test/**/*
'benchmarks':
- bench/*
- bench/**/*
'templates':
- examples/*
- examples/**/*

66
.github/labels.yml vendored
View File

@@ -1,66 +0,0 @@
- name: 'bug'
color: 'd73a4a'
- name: 'segfault'
color: 'b60205'
- name: 'documentation'
color: '0075ca'
- name: 'duplicate'
color: 'cfd3d7'
- name: 'wontfix'
color: 'cfd3d7'
- name: 'question'
color: 'd876e3'
- name: 'enhancement'
color: 'a2eeef'
- name: 'good first issue'
color: '7057ff'
- name: 'help wanted'
color: '008672'
- name: 'infrastructure'
color: '7c5f8a'
- name: 'invalid'
color: 'e4e669'
- name: 'need repro'
color: 'c66037'
- name: 'node.js'
color: '0E8A16'
- name: 'napi'
color: 'BE05D2'
- name: 'esm<>cjs'
color: '7dcde3'
- name: 'performance'
color: 'E99695'
- name: 'polyfill'
color: 'f9c5e6'
- name: 'tracking'
color: '5319E7'
- name: 'transpiler'
color: 'BFDADC'
- name: 'typescript'
color: '87511b'
- name: 'chore'
color: 'cfd3d7'
- name: 'templates'
color: 'FBCA04'
- name: 'benchmarks'
color: 'FBCA04'
- name: 'tests'
color: 'FBCA04'
- name: 'packages:bun'
color: 'FBCA04'
- name: 'packages:bun-darwin-aarch64'
color: 'FBCA04'
- name: 'packages:bun-error'
color: 'FBCA04'
- name: 'packages:bun-framework-next'
color: 'FBCA04'
- name: 'packages:bun-landing'
color: 'FBCA04'
- name: 'packages:bun-linux-x64'
color: 'FBCA04'
- name: 'packages:bun-macro-relay'
color: 'FBCA04'
- name: 'packages:bun-types'
color: 'FBCA04'
- name: 'packages:bun-wasm'
color: 'FBCA04'

17
.github/workflows/bun-deploy-site.yml vendored Normal file
View File

@@ -0,0 +1,17 @@
# redeploy Vercel site when a file in `docs` changes
# using VERCEL_DEPLOY_HOOK environment variable
name: Deploy site
on:
push:
paths:
- "docs/**"
branches: [main]
jobs:
deploy:
name: Deploy site
runs-on: ubuntu-latest
steps:
- name: Trigger Vercel build
run: curl ${{ secrets.VERCEL_DEPLOY_HOOK }}

View File

@@ -1,47 +0,0 @@
name: bun-dockerhub
on:
push:
paths:
- dockerhub/Dockerfile
branches:
- main
pull_request:
paths:
- dockerhub/Dockerfile
branches:
- main
release:
types:
- published
jobs:
docker:
runs-on: ubuntu-latest
if: github.repository_owner == 'oven-sh'
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Collect metadata
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ secrets.DOCKERHUB_USERNAME }}/bun
tags: |
type=match,pattern=bun-v(\d.\d.\d),group=1
type=match,pattern=bun-v(\d.\d),group=1
type=match,pattern=bun-v(\d),group=1
type=ref,event=branch
type=ref,event=pr
- name: Login to DockerHub
if: github.event_name == 'release'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build image
uses: docker/build-push-action@v3
with:
context: ./dockerhub
push: ${{ github.event_name == 'release' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

View File

@@ -1,30 +0,0 @@
name: bun-homebrew
on:
release:
types:
- published
- edited
jobs:
homebrew:
runs-on: ubuntu-latest
if: github.repository_owner == 'oven-sh' && github.event.release.published_at != null
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
with:
repository: oven-sh/homebrew-bun
token: ${{ env.HOMEBREW_TOKEN }}
- id: 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 "${{ github.event.release.tag_name }}"
- id: commit-tap
name: Commit Tap
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Release ${{ github.event.release.tag_name }}

View File

@@ -1,46 +0,0 @@
name: bun-landing
on:
push:
paths:
- packages/bun-landing/**/*
branches: [main]
jobs:
build:
name: website build
runs-on: ubuntu-latest
if: github.repository_owner == 'oven-sh'
strategy:
fail-fast: false
matrix:
node-version:
- 16
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 bun
uses: xhyrom/setup-bun@v0.1.2
with:
bun-version: latest
- name: Install global dependencies
run: bun install
- name: Install package dependencies
run: cd packages/bun-landing && bun install
- name: Build
run: cd packages/bun-landing && bun run build.tsx
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: build:(landing) automated website build
token: ${{ secrets.GITHUB_TOKEN }}

130
.github/workflows/bun-linux-aarch64.yml vendored Normal file
View File

@@ -0,0 +1,130 @@
name: bun-linux
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
TEST_TAG: bun-test'
on:
push:
branches:
- main
paths:
- "src/**/*"
- "test/**/*"
- "build.zig"
- "Makefile"
- "Dockerfile"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
linux:
name: ${{matrix.tag}}
runs-on: ${{matrix.runner}}
timeout-minutes: 90
strategy:
matrix:
include:
- cpu: native
tag: linux-aarch64
arch: aarch64
build_arch: arm64
runner: linux-arm64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/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
- 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 }}
- run: |
mkdir -p /tmp/.buildx-cache-${{matrix.tag}}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
push: false
cache-from: type=local,src=/tmp/.buildx-cache-${{matrix.tag}}
cache-to: type=local,dest=/tmp/.buildx-cache-${{matrix.tag}}
build-args: |
ARCH=${{matrix.arch}}
BUILDARCH=${{matrix.build_arch}}
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
- name: Zip
run: |
# if zip is not found
if [ ! -x "$(command -v zip)" ]; then
sudo apt-get update && sudo apt-get install -y zip --no-install-recommends
fi
if [ ! -x "$(command -v strip)" ]; then
sudo apt-get update && sudo apt-get install -y binutils --no-install-recommends
fi
cd ${{runner.temp}}/release
chmod +x bun-profile bun
mkdir bun-${{matrix.tag}}-profile
mkdir bun-${{matrix.tag}}
strip bun
mv bun-profile bun-${{matrix.tag}}-profile/bun-profile
mv bun bun-${{matrix.tag}}/bun
zip -r bun-${{matrix.tag}}-profile.zip bun-${{matrix.tag}}-profile
zip -r bun-${{matrix.tag}}.zip bun-${{matrix.tag}}
- uses: actions/upload-artifact@v3
with:
name: bun-${{matrix.tag}}-profile
path: ${{runner.temp}}/release/bun-${{matrix.tag}}-profile.zip
- uses: actions/upload-artifact@v3
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
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: "${{runner.temp}}/release/bun-${{matrix.tag}}.zip,${{runner.temp}}/release/bun-${{matrix.tag}}-profile.zip"

View File

@@ -6,7 +6,8 @@ env:
on:
push:
branches: [main, bun-actions]
branches:
- main
paths:
- "src/**/*"
- "test/**/*"
@@ -14,7 +15,8 @@ on:
- "Makefile"
- "Dockerfile"
pull_request:
branches: [main]
branches:
- main
paths:
- "src/**/*"
- "test/**/*"
@@ -30,34 +32,30 @@ jobs:
runs-on: ${{matrix.runner}}
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
include:
- cpu: haswell
tag: linux-x64
arch: x86_64
build_arch: amd64
runner: linux-amd64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct28/bun-webkit-linux-amd64-lto.tar.gz"
runner: big-ubuntu
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-linux-amd64-lto.tar.gz"
webkit_basename: "bun-webkit-linux-amd64-lto"
- cpu: westmere
build_machine_arch: x86_64
- cpu: nehalem
tag: linux-x64-baseline
arch: x86_64
build_arch: amd64
runner: linux-amd64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct28/bun-webkit-linux-amd64-lto.tar.gz"
runner: big-ubuntu
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-linux-amd64-lto.tar.gz"
webkit_basename: "bun-webkit-linux-amd64-lto"
- cpu: native
tag: linux-aarch64
arch: aarch64
build_arch: arm64
runner: linux-arm64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct28/bun-webkit-linux-arm64-lto.tar.gz"
webkit_basename: "bun-webkit-linux-arm64-lto"
build_machine_arch: x86_64
steps:
- uses: actions/checkout@v3
- name: Checkout submodules
run: git -c submodule."src/bun.js/WebKit".update=none submodule update --init --recursive --depth=1 --progress -j $(nproc)
with:
submodules: recursive
- uses: docker/setup-buildx-action@v2
id: buildx
with:
@@ -71,16 +69,19 @@ jobs:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: |
mkdir -p /tmp/.buildx-cache-${{matrix.tag}}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
push: false
cache-from: type=gha
cache-to: type=gha,mode=max
cache-from: type=local,src=/tmp/.buildx-cache-${{matrix.tag}}
cache-to: type=local,dest=/tmp/.buildx-cache-${{matrix.tag}}
build-args: |
ARCH=${{matrix.arch}}
BUILDARCH=${{matrix.build_arch}}
BUILD_MACHINE_ARCH=${{matrix.build_machine_arch}}
CPU_TARGET=${{matrix.cpu}}
WEBKIT_URL=${{matrix.webkit_url}}
GIT_SHA=${{github.sha}}
@@ -120,19 +121,6 @@ jobs:
with:
name: bun-${{matrix.tag}}
path: ${{runner.temp}}/release/bun-${{matrix.tag}}.zip
- name: Release
id: release
uses: softprops/action-gh-release@v1
if: github.ref == 'refs/heads/main'
with:
prerelease: true
generate_release_notes: true
body: "This is the canary release of Bun that corresponds to the commit [${{ github.sha }}]"
name: "Canary (${{github.sha}})"
tag_name: "canary"
files: |
${{runner.temp}}/release/bun-${{matrix.tag}}.zip
${{runner.temp}}/release/bun-${{matrix.tag}}-profile.zip
- uses: actions/upload-artifact@v3
with:
name: bun-obj-${{matrix.tag}}
@@ -141,3 +129,93 @@ jobs:
with:
name: ${{matrix.tag}}-dependencies
path: ${{runner.temp}}/release/bun-dependencies
- 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: "${{runner.temp}}/release/bun-${{matrix.tag}}.zip,${{runner.temp}}/release/bun-${{matrix.tag}}-profile.zip"
linux-test:
name: Tests ${{matrix.tag}}
runs-on: ubuntu-latest
needs: [linux]
if: github.event_name == 'pull_request'
timeout-minutes: 10
outputs:
failing_tests: ${{ steps.test.outputs.failing_tests }}
failing_tests_count: ${{ steps.test.outputs.failing_tests_count }}
strategy:
fail-fast: false
matrix:
include:
- tag: linux-x64
- tag: linux-x64-baseline
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
with:
submodules: false
- id: download
name: Download
uses: actions/download-artifact@v3
with:
name: bun-${{matrix.tag}}
path: ${{runner.temp}}/release
- id: install
name: Install
run: |
cd ${{runner.temp}}/release
unzip bun-${{matrix.tag}}.zip
cd bun-${{matrix.tag}}
chmod +x bun
sudo mv bun /usr/local/bin/bun
bun --version
- id: test
name: Test (node runner)
# 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
- name: Comment on PR
if: steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request'
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: test-failures-${{matrix.tag}}
message: |
❌ @${{ 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}})**
<sup>[#${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})</sup>
- name: Uncomment on PR
if: steps.test.outputs.failing_tests == '' && github.event_name == 'pull_request'
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: test-failures-${{matrix.tag}}
mode: upsert
create_if_not_exists: false
message: |
✅ test failures on ${{ matrix.tag }} have been resolved.
<sup>[#${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})</sup>
- id: fail
name: Fail the build
if: steps.test.outputs.failing_tests != ''
run: exit 1

View File

@@ -6,7 +6,7 @@ env:
on:
push:
branches: [main, bun-actions]
branches: [main]
paths:
- "src/**/*"
- "test/**/*"
@@ -27,11 +27,11 @@ on:
jobs:
macos-object-files:
name: macOS Object
runs-on: zig-object
runs-on: med-ubuntu
strategy:
matrix:
include:
# - cpu: westmere
# - cpu: nehalem
# arch: x86_64
# tag: bun-obj-darwin-x64-baseline
# - cpu: haswell
@@ -42,8 +42,8 @@ jobs:
tag: bun-obj-darwin-aarch64
steps:
- uses: actions/checkout@v3
- name: Checkout submodules
run: git -c submodule."src/bun.js/WebKit".update=none submodule update --init --recursive --depth=1 --progress -j $(nproc)
with:
submodules: recursive
- uses: docker/setup-buildx-action@v2
id: buildx
with:
@@ -59,21 +59,40 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
if: runner.arch == 'X64'
with:
context: .
push: false
tags: ghcr.io/oven-sh/bun-obj:${{github.sha}}-${{matrix.cpu}}-${{matrix.arch}}-macos
cache-from: type=gha
cache-to: type=gha,mode=max
cache-to: type=gha,mode=min
build-args: |
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
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
with:
name: ${{ matrix.tag }}
@@ -85,13 +104,13 @@ jobs:
strategy:
matrix:
include:
# - cpu: westmere
# - 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/oct28/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: true
# compile_obj: false
# - cpu: haswell
@@ -100,16 +119,16 @@ jobs:
# obj: bun-obj-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct28/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: true
# compile_obj: false
# - cpu: westmere
# - 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/oct28/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: false
# compile_obj: true
# - cpu: haswell
@@ -118,7 +137,7 @@ jobs:
# obj: bun-obj-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct28/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: false
# compile_obj: true
- cpu: native
@@ -126,7 +145,7 @@ jobs:
tag: bun-darwin-aarch64
obj: bun-obj-darwin-aarch64
artifact: bun-obj-darwin-aarch64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct28/bun-webkit-macos-arm64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-macos-arm64-lto.tar.gz"
runner: macos-arm64
dependencies: true
compile_obj: true
@@ -146,10 +165,16 @@ jobs:
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
run: |
brew install rust llvm@13 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
brew install ccache rust llvm@15 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
echo "export PATH=$(brew --prefix ccache)/bin:\$PATH" >> $GITHUB_ENV
echo "export PATH=$(brew --prefix coreutils)/libexec/gnubin:\$PATH" >> $GITHUB_ENV
echo "export PATH=$(brew --prefix llvm@13)/bin:\$PATH" >> $GITHUB_ENV
brew link --overwrite llvm@13
echo "export PATH=$(brew --prefix llvm@15)/bin:\$PATH" >> $GITHUB_ENV
brew link --overwrite llvm@15
- 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:
@@ -209,7 +234,6 @@ jobs:
with:
name: ${{ matrix.tag }}-deps
path: ${{runner.temp}}/bun-deps
macOS:
name: macOS Link
runs-on: ${{ matrix.runner }}
@@ -218,14 +242,14 @@ jobs:
strategy:
matrix:
include:
# - cpu: westmere
# - 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/oct28/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-macos-amd64-lto.tar.gz"
# - cpu: haswell
# arch: x86_64
# tag: bun-darwin-x64
@@ -233,14 +257,14 @@ jobs:
# package: bun-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct28/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/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/oct28/bun-webkit-macos-arm64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-macos-arm64-lto.tar.gz"
runner: macos-arm64
steps:
- uses: actions/checkout@v3
@@ -258,10 +282,15 @@ jobs:
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
run: |
brew install rust llvm@13 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
brew install rust ccache llvm@15 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
echo "export PATH=$(brew --prefix coreutils)/libexec/gnubin:\$PATH" >> $GITHUB_ENV
echo "export PATH=$(brew --prefix llvm@13)/bin:\$PATH" >> $GITHUB_ENV
brew link --overwrite llvm@13
echo "export PATH=$(brew --prefix llvm@15)/bin:\$PATH" >> $GITHUB_ENV
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 }}
@@ -340,14 +369,90 @@ jobs:
path: ${{runner.temp}}/release/${{matrix.tag}}.zip
- name: Release
id: release
uses: softprops/action-gh-release@v1
if: github.ref == 'refs/heads/main'
uses: ncipollo/release-action@v1
if: |
github.repository_owner == 'oven-sh'
&& github.ref == 'refs/heads/main'
with:
prerelease: true
generate_release_notes: true
body: "This is the canary release of Bun that corresponds to the commit [${{ github.sha }}]"
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_name: "canary"
files: |
${{runner.temp}}/release/${{matrix.tag}}.zip
${{runner.temp}}/release/${{matrix.tag}}-profile.zip
tag: "canary"
artifacts: "${{runner.temp}}/release/${{matrix.tag}}.zip,${{runner.temp}}/release/${{matrix.tag}}-profile.zip"
macOS-test:
name: Tests ${{matrix.tag}}
runs-on: ${{ matrix.runner }}
needs: [macOS]
if: github.event_name == 'pull_request'
timeout-minutes: 10
outputs:
failing_tests: ${{ steps.test.outputs.failing_tests }}
failing_tests_count: ${{ steps.test.outputs.failing_tests_count }}
strategy:
fail-fast: false
matrix:
include:
- tag: bun-darwin-aarch64
runner: macos-arm64
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
with:
submodules: false
- id: download
name: Download
uses: actions/download-artifact@v3
with:
name: ${{matrix.tag}}
path: ${{runner.temp}}/release
- id: install
name: Install
run: |
cd ${{runner.temp}}/release
unzip ${{matrix.tag}}.zip
cd ${{matrix.tag}}
chmod +x bun
sudo mv bun /usr/local/bin/bun
bun --version
- id: test
name: Test (node runner)
# 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
- name: Comment on PR
if: steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request'
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: test-failures-${{matrix.tag}}
message: |
❌ @${{ 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}})**
<sup>[#${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})</sup>
- name: Uncomment on PR
if: steps.test.outputs.failing_tests == '' && github.event_name == 'pull_request'
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: test-failures-${{matrix.tag}}
mode: upsert
create_if_not_exists: false
message: |
✅ test failures on ${{ matrix.tag }} have been resolved.
<sup>[#${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})</sup>
- id: fail
name: Fail the build
if: steps.test.outputs.failing_tests != ''
run: exit 1

View File

@@ -6,7 +6,7 @@ env:
on:
push:
branches: [main, bun-actions]
branches: [main]
paths:
- "src/**/*"
- "test/**/*"
@@ -27,11 +27,11 @@ on:
jobs:
macos-object-files:
name: macOS Object
runs-on: zig-object
runs-on: med-ubuntu
strategy:
matrix:
include:
- cpu: westmere
- cpu: nehalem
arch: x86_64
tag: bun-obj-darwin-x64-baseline
# - cpu: haswell
@@ -42,8 +42,8 @@ jobs:
# tag: bun-obj-darwin-aarch64
steps:
- uses: actions/checkout@v3
- name: Checkout submodules
run: git -c submodule."src/bun.js/WebKit".update=none submodule update --init --recursive --depth=1 --progress -j $(nproc)
with:
submodules: recursive
- uses: docker/setup-buildx-action@v2
id: buildx
with:
@@ -59,21 +59,40 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
if: runner.arch == 'X64'
with:
context: .
push: false
tags: ghcr.io/oven-sh/bun-obj:${{github.sha}}-${{matrix.cpu}}-${{matrix.arch}}-macos-baseline
cache-from: type=gha
cache-to: type=gha,mode=max
cache-to: type=gha,mode=min
build-args: |
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
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
with:
name: ${{ matrix.tag }}
@@ -85,13 +104,13 @@ jobs:
strategy:
matrix:
include:
- cpu: westmere
- 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/oct28/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-macos-amd64-lto.tar.gz"
dependencies: true
compile_obj: false
# - cpu: haswell
@@ -100,16 +119,16 @@ jobs:
# obj: bun-obj-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct28/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: true
# compile_obj: false
- cpu: westmere
- 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/oct28/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-macos-amd64-lto.tar.gz"
dependencies: false
compile_obj: true
# - cpu: haswell
@@ -118,7 +137,7 @@ jobs:
# obj: bun-obj-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct28/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: false
# compile_obj: true
# - cpu: native
@@ -126,7 +145,7 @@ jobs:
# tag: bun-darwin-aarch64
# obj: bun-obj-darwin-aarch64
# artifact: bun-obj-darwin-aarch64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct28/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-macos-amd64-lto.tar.gz"
# runner: macos-arm64
# dependencies: true
# compile_obj: true
@@ -146,10 +165,23 @@ jobs:
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
run: |
brew install rust llvm@13 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
brew install ccache rust llvm@15 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
echo "export PATH=$(brew --prefix ccache)/bin:\$PATH" >> $GITHUB_ENV
echo "export PATH=$(brew --prefix coreutils)/libexec/gnubin:\$PATH" >> $GITHUB_ENV
echo "export PATH=$(brew --prefix llvm@13)/bin:\$PATH" >> $GITHUB_ENV
brew link --overwrite llvm@13
echo "export PATH=$(brew --prefix llvm@15)/bin:\$PATH" >> $GITHUB_ENV
brew link --overwrite llvm@15
- name: ccache (dependencies)
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:
@@ -203,7 +235,6 @@ jobs:
with:
name: ${{ matrix.tag }}-deps
path: ${{runner.temp}}/bun-deps
macOS:
name: macOS Link
runs-on: ${{ matrix.runner }}
@@ -212,14 +243,14 @@ jobs:
strategy:
matrix:
include:
- cpu: westmere
- 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/oct28/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-macos-amd64-lto.tar.gz"
# - cpu: haswell
# arch: x86_64
# tag: bun-darwin-x64
@@ -227,14 +258,14 @@ jobs:
# package: bun-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct28/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/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/oct28/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-macos-amd64-lto.tar.gz"
# runner: macos-arm64
steps:
- uses: actions/checkout@v3
@@ -252,10 +283,15 @@ jobs:
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
run: |
brew install rust llvm@13 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
brew install ccache rust llvm@15 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
echo "export PATH=$(brew --prefix coreutils)/libexec/gnubin:\$PATH" >> $GITHUB_ENV
echo "export PATH=$(brew --prefix llvm@13)/bin:\$PATH" >> $GITHUB_ENV
brew link --overwrite llvm@13
echo "export PATH=$(brew --prefix llvm@15)/bin:\$PATH" >> $GITHUB_ENV
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 }}
@@ -337,14 +373,90 @@ jobs:
path: ${{runner.temp}}/release/${{matrix.tag}}.zip
- name: Release
id: release
uses: softprops/action-gh-release@v1
if: github.ref == 'refs/heads/main'
uses: ncipollo/release-action@v1
if: |
github.repository_owner == 'oven-sh'
&& github.ref == 'refs/heads/main'
with:
prerelease: true
generate_release_notes: true
body: "This is the canary release of Bun that corresponds to the commit [${{ github.sha }}]"
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_name: "canary"
files: |
${{runner.temp}}/release/${{matrix.tag}}.zip
${{runner.temp}}/release/${{matrix.tag}}-profile.zip
tag: "canary"
artifacts: "${{runner.temp}}/release/${{matrix.tag}}.zip,${{runner.temp}}/release/${{matrix.tag}}-profile.zip"
macOS-test:
name: Tests ${{matrix.tag}}
runs-on: ${{ matrix.runner }}
needs: [macOS]
if: github.event_name == 'pull_request'
timeout-minutes: 10
outputs:
failing_tests: ${{ steps.test.outputs.failing_tests }}
failing_tests_count: ${{ steps.test.outputs.failing_tests_count }}
strategy:
fail-fast: false
matrix:
include:
- tag: bun-darwin-x64-baseline
runner: macos-11
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
with:
submodules: false
- id: download
name: Download
uses: actions/download-artifact@v3
with:
name: ${{matrix.tag}}
path: ${{runner.temp}}/release
- id: install
name: Install
run: |
cd ${{runner.temp}}/release
unzip ${{matrix.tag}}.zip
cd ${{matrix.tag}}
chmod +x bun
sudo mv bun /usr/local/bin/bun
bun --version
- id: test
name: Test (node runner)
# 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
- name: Comment on PR
if: steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request'
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: test-failures-${{matrix.tag}}
message: |
❌ @${{ 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}})**
<sup>[#${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})</sup>
- name: Uncomment on PR
if: steps.test.outputs.failing_tests == '' && github.event_name == 'pull_request'
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: test-failures-${{matrix.tag}}
mode: upsert
create_if_not_exists: false
message: |
✅ test failures on ${{ matrix.tag }} have been resolved.
<sup>[#${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})</sup>
- id: fail
name: Fail the build
if: steps.test.outputs.failing_tests != ''
run: exit 1

View File

@@ -6,7 +6,7 @@ env:
on:
push:
branches: [main, bun-actions]
branches: [main]
paths:
- "src/**/*"
- "test/**/*"
@@ -27,11 +27,11 @@ on:
jobs:
macos-object-files:
name: macOS Object
runs-on: zig-object
runs-on: med-ubuntu
strategy:
matrix:
include:
# - cpu: westmere
# - cpu: nehalem
# arch: x86_64
# tag: bun-obj-darwin-x64-baseline
- cpu: haswell
@@ -42,8 +42,8 @@ jobs:
# tag: bun-obj-darwin-aarch64
steps:
- uses: actions/checkout@v3
- name: Checkout submodules
run: git -c submodule."src/bun.js/WebKit".update=none submodule update --init --recursive --depth=1 --progress -j $(nproc)
with:
submodules: recursive
- uses: docker/setup-buildx-action@v2
id: buildx
with:
@@ -59,6 +59,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
if: runner.arch == 'X64'
with:
context: .
push: false
@@ -67,12 +68,31 @@ jobs:
build-args: |
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
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
with:
name: ${{ matrix.tag }}
@@ -84,13 +104,13 @@ jobs:
strategy:
matrix:
include:
# - cpu: westmere
# - 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/oct28/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: true
# compile_obj: false
- cpu: haswell
@@ -99,16 +119,16 @@ jobs:
obj: bun-obj-darwin-x64
runner: macos-11
artifact: bun-obj-darwin-x64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct28/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-macos-amd64-lto.tar.gz"
dependencies: true
compile_obj: false
# - cpu: westmere
# - 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/oct28/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: false
# compile_obj: true
- cpu: haswell
@@ -117,7 +137,7 @@ jobs:
obj: bun-obj-darwin-x64
runner: macos-11
artifact: bun-obj-darwin-x64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct28/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-macos-amd64-lto.tar.gz"
dependencies: false
compile_obj: true
# - cpu: native
@@ -125,7 +145,7 @@ jobs:
# tag: bun-darwin-aarch64
# obj: bun-obj-darwin-aarch64
# artifact: bun-obj-darwin-aarch64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct28/bun-webkit-macos-arm64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-macos-arm64-lto.tar.gz"
# runner: macos-arm64
# dependencies: true
# compile_obj: true
@@ -145,10 +165,10 @@ jobs:
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
run: |
brew install rust llvm@13 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
brew install rust ccache llvm@15 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
echo "export PATH=$(brew --prefix coreutils)/libexec/gnubin:\$PATH" >> $GITHUB_ENV
echo "export PATH=$(brew --prefix llvm@13)/bin:\$PATH" >> $GITHUB_ENV
brew link --overwrite llvm@13
echo "export PATH=$(brew --prefix llvm@15)/bin:\$PATH" >> $GITHUB_ENV
brew link --overwrite llvm@15
- name: Download WebKit
if: matrix.compile_obj
env:
@@ -164,6 +184,18 @@ jobs:
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)
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:
@@ -213,14 +245,14 @@ jobs:
strategy:
matrix:
include:
# - cpu: westmere
# - 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/oct28/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-macos-amd64-lto.tar.gz"
- cpu: haswell
arch: x86_64
tag: bun-darwin-x64
@@ -228,14 +260,14 @@ jobs:
package: bun-darwin-x64
runner: macos-11
artifact: bun-obj-darwin-x64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/oct28/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/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/oct28/bun-webkit-macos-arm64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-macos-arm64-lto.tar.gz"
# runner: macos-arm64
steps:
- uses: actions/checkout@v3
@@ -253,10 +285,10 @@ jobs:
OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
run: |
brew install rust llvm@13 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
brew install rust ccache llvm@15 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
echo "export PATH=$(brew --prefix coreutils)/libexec/gnubin:\$PATH" >> $GITHUB_ENV
echo "export PATH=$(brew --prefix llvm@13)/bin:\$PATH" >> $GITHUB_ENV
brew link --overwrite llvm@13
echo "export PATH=$(brew --prefix llvm@15)/bin:\$PATH" >> $GITHUB_ENV
brew link --overwrite llvm@15
- name: Download WebKit
env:
CPU_TARGET: ${{ matrix.cpu }}
@@ -287,6 +319,11 @@ jobs:
with:
name: ${{ matrix.obj }}
path: ${{ runner.temp }}/release
- 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: Link
env:
CPU_TARGET: ${{ matrix.cpu }}
@@ -338,14 +375,90 @@ jobs:
path: ${{runner.temp}}/release/${{matrix.tag}}.zip
- name: Release
id: release
uses: softprops/action-gh-release@v1
if: github.ref == 'refs/heads/main'
uses: ncipollo/release-action@v1
if: |
github.repository_owner == 'oven-sh'
&& github.ref == 'refs/heads/main'
with:
prerelease: true
generate_release_notes: true
body: "This is the canary release of Bun that corresponds to the commit [${{ github.sha }}]"
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_name: "canary"
files: |
${{runner.temp}}/release/${{matrix.tag}}.zip
${{runner.temp}}/release/${{matrix.tag}}-profile.zip
tag: "canary"
artifacts: "${{runner.temp}}/release/${{matrix.tag}}.zip,${{runner.temp}}/release/${{matrix.tag}}-profile.zip"
macOS-test:
name: Tests ${{matrix.tag}}
runs-on: ${{ matrix.runner }}
needs: [macOS]
if: github.event_name == 'pull_request'
timeout-minutes: 10
outputs:
failing_tests: ${{ steps.test.outputs.failing_tests }}
failing_tests_count: ${{ steps.test.outputs.failing_tests_count }}
strategy:
fail-fast: false
matrix:
include:
- tag: bun-darwin-x64
runner: macos-11
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
with:
submodules: false
- id: download
name: Download
uses: actions/download-artifact@v3
with:
name: ${{matrix.tag}}
path: ${{runner.temp}}/release
- id: install
name: Install
run: |
cd ${{runner.temp}}/release
unzip ${{matrix.tag}}.zip
cd ${{matrix.tag}}
chmod +x bun
sudo mv bun /usr/local/bin/bun
bun --version
- id: test
name: Test (node runner)
# 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
- name: Comment on PR
if: steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request'
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: test-failures-${{matrix.tag}}
message: |
❌ @${{ 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}})**
<sup>[#${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})</sup>
- name: Uncomment on PR
if: steps.test.outputs.failing_tests == '' && github.event_name == 'pull_request'
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: test-failures-${{matrix.tag}}
mode: upsert
create_if_not_exists: false
message: |
✅ test failures on ${{ matrix.tag }} have been resolved.
<sup>[#${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})</sup>
- id: fail
name: Fail the build
if: steps.test.outputs.failing_tests != ''
run: exit 1

146
.github/workflows/bun-release-canary.yml vendored Normal file
View File

@@ -0,0 +1,146 @@
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
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
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
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

View File

@@ -0,0 +1,53 @@
name: bun-release-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
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

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

@@ -0,0 +1,213 @@
name: bun-release
concurrency: release
on:
release:
types:
- published
workflow_dispatch:
inputs:
tag:
type: string
description: The tag to publish
required: true
jobs:
sign:
name: Sign Release
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/bun-release
steps:
- id: 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
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 -- "${{ env.TAG }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
npm:
name: Release to NPM
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/bun-release
steps:
- id: 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
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 -- "${{ env.TAG }}" 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-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
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: 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 }}
docker:
name: Release to Dockerhub
runs-on: ubuntu-latest
needs: sign
steps:
- id: 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
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: |
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
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=${{ env.TAG }}
homebrew:
name: Release to Homebrew
runs-on: ubuntu-latest
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
with:
repository: oven-sh/homebrew-bun
token: ${{ secrets.ROBOBUN_TOKEN }}
- 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-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
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
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_options: --gpg-sign=${{ steps.setup-gpg.outputs.keyid }}
commit_message: Release ${{ env.TAG }}
commit_user_name: robobun
commit_user_email: robobun@oven.sh
commit_author: robobun <robobun@oven.sh>

31
.github/workflows/bun-typecheck.yml vendored Normal file
View File

@@ -0,0 +1,31 @@
name: typecheck
on:
push:
branches: [main]
paths:
- "packages/bun-types/**"
- "test/**"
pull_request:
paths:
- "packages/bun-types/**"
- "test/**"
jobs:
tests:
name: check-tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: test
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Install bun
uses: oven-sh/setup-bun@v1
with:
bun-version: canary
- name: Install dependencies
run: bun install
- name: Typecheck tests
run: bun run typecheck

41
.github/workflows/bun-types-tests.yml vendored Normal file
View File

@@ -0,0 +1,41 @@
name: bun-types
on:
push:
paths:
- "packages/bun-types/**"
branches: [main]
pull_request:
paths:
- "packages/bun-types/**"
jobs:
tests:
name: type-tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/bun-types
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Install bun
uses: oven-sh/setup-bun@v1
with:
bun-version: canary
- name: Install node
uses: actions/setup-node@v3
with:
node-version: latest
- name: Install dependencies
run: |
bun install
- name: Generate package
run: bun run build
- name: Tests
run: bun run test

76
.github/workflows/prettier-fmt.yml vendored Normal file
View File

@@ -0,0 +1,76 @@
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

59
.github/workflows/run-test-manually.yml vendored Normal file
View File

@@ -0,0 +1,59 @@
name: Run Tests Manually
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
version:
description: "Version"
required: true
default: "canary"
type: string
use_bun:
description: "Use Bun?"
required: true
default: true
type: boolean
jobs:
linux-test:
name: Tests ${{matrix.tag}} ${{github.event.inputs.version}}
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
include:
- tag: linux-x64
- tag: linux-x64-baseline
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
with:
submodules: false
- id: install-npm
name: Install (npm)
run: |
npm install @oven/bun-${{matrix.tag}}@${{github.event.inputs.version}}
chmod +x node_modules/@oven/bun-${{matrix.tag}}/bin/bun
sudo cp node_modules/@oven/bun-${{matrix.tag}}/bin/bun /usr/bin/bun
- id: test
name: Test
if: ${{github.event.inputs.use_bun == 'true'}}
run: |
bun install
bun install --cwd test/bun.js
bun install --cwd test/bun.js/third-party/body-parser-test
cd packages/bun-internal-test
bun install
bun run test
- id: test-node-runner
name: Test (node runner)
if: ${{github.event.inputs.use_bun == 'false'}}
run: |
bun install
bun install --cwd test/bun.js
bun install --cwd test/bun.js/third-party/body-parser-test
cd packages/bun-internal-test
bun install
node src/runner.node.mjs

87
.github/workflows/zig-fmt.yml vendored Normal file
View File

@@ -0,0 +1,87 @@
name: zig-fmt
env:
ZIG_VERSION: 0.11.0-dev.1783+436e99d13
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
sudo mv zig-linux-x86_64-${{env.ZIG_VERSION}}/zig /usr/local/bin
- 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

14
.gitignore vendored
View File

@@ -1,7 +1,6 @@
.DS_Store
zig-cache
*.wasm
packages/*/*.wasm
*.o
*.a
profile.json
@@ -104,3 +103,14 @@ src/runtime.version
*.database
*.db
misctools/machbench
*.big
.eslintcache
bun-webkit
src/deps/c-ares/build
src/bun.js/debug-bindings-obj
failing-tests.txt
test.txt
myscript.sh

19
.gitmodules vendored
View File

@@ -36,14 +36,7 @@ shallow = true
fetchRecurseSubmodules = false
[submodule "src/deps/boringssl"]
path = src/deps/boringssl
url = https://github.com/google/boringssl.git
ignore = dirty
depth = 1
shallow = true
fetchRecurseSubmodules = false
[submodule "src/deps/libbacktrace"]
path = src/deps/libbacktrace
url = https://github.com/ianlancetaylor/libbacktrace
url = https://github.com/oven-sh/boringssl.git
ignore = dirty
depth = 1
shallow = true
@@ -69,10 +62,6 @@ ignore = dirty
depth = 1
shallow = true
fetchRecurseSubmodules = false
[submodule "src/deps/oniguruma"]
path = src/deps/oniguruma
url = https://github.com/kkos/oniguruma
ignore = dirty
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

12
.prettierignore Normal file
View File

@@ -0,0 +1,12 @@
src/fallback.html
src/bun.js/WebKit
src/bun.js/builtins/js
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

15
.prettierrc.cjs Normal file
View File

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

9
.scripts/postinstall.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/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

View File

@@ -8,6 +8,10 @@ PICOHTTPPARSER_VERSION=$(git rev-parse HEAD:./src/deps/picohttpparser)
BORINGSSL_VERSION=$(git rev-parse HEAD:./src/deps/boringssl)
ZLIB_VERSION=$(git rev-parse HEAD:./src/deps/zlib)
UWS_VERSION=$(git rev-parse HEAD:./src/deps/uws)
LOLHTML=$(git rev-parse HEAD:./src/deps/lol-html)
TINYCC=$(git rev-parse HEAD:./src/deps/tinycc)
C_ARES=$(git rev-parse HEAD:./src/deps/c-ares)
USOCKETS=$(cd src/deps/uws/uSockets && git rev-parse HEAD)
rm -rf src/generated_versions_list.zig
echo "// AUTO-GENERATED FILE. Created via .scripts/write-versions.sh" >src/generated_versions_list.zig
@@ -20,6 +24,9 @@ echo "pub const uws = \"$UWS_VERSION\";" >>src/generated_versions_list.zig
echo "pub const webkit = \"$WEBKIT_VERSION\";" >>src/generated_versions_list.zig
echo "pub const zig = @import(\"std\").fmt.comptimePrint(\"{}\", .{@import(\"builtin\").zig_version});" >>src/generated_versions_list.zig
echo "pub const zlib = \"$ZLIB_VERSION\";" >>src/generated_versions_list.zig
echo "pub const tinycc = \"$TINYCC\";" >>src/generated_versions_list.zig
echo "pub const lolhtml = \"$LOLHTML\";" >>src/generated_versions_list.zig
echo "pub const c_ares = \"$C_ARES\";" >>src/generated_versions_list.zig
echo "" >>src/generated_versions_list.zig
zig fmt src/generated_versions_list.zig

View File

@@ -2,49 +2,44 @@
"configurations": [
{
"name": "Mac",
"forcedInclude": ["${workspaceFolder}/src/bun.js/bindings/root.h"],
"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/*",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/bmalloc/Headers/",
"${workspaceFolder}/src/bun.js/bindings/",
"${workspaceFolder}/src/bun.js/bindings/webcore/",
"${workspaceFolder}/src/bun.js/bindings/sqlite/",
"${workspaceFolder}/src/bun.js/bindings/webcrypto/",
"${workspaceFolder}/src/deps/boringssl/include/",
"${workspaceFolder}/src/bun.js/bindings/webcrypto/openssl/",
"${workspaceFolder}/src/bun.js/bindings/webcrypto/algorithms/",
"${workspaceFolder}/src/bun.js/bindings/webcrypto/parameters/",
"${workspaceFolder}/src/bun.js/builtins/",
"${workspaceFolder}/src/bun.js/builtins/cpp",
"${workspaceFolder}/src/bun.js/bindings/WebCore/",
"${workspaceFolder}/src/bun.js/WebKit/Source/bmalloc/",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/ICU/Headers/",
"${workspaceFolder}/../webkit-build/include/",
"${workspaceFolder}/src/deps/boringssl/include/",
"${workspaceFolder}/src/deps",
"${workspaceFolder}/src/deps/uws/uSockets/src"
],
"browse": {
"path": [
"${workspaceFolder}/src/bun.js/bindings/*",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/JavaScriptCore/PrivateHeaders/**",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/JavaScriptCore/Headers/**",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/WTF/Headers/**",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/*",
"${workspaceFolder}/src/bun.js/bindings/**",
"${workspaceFolder}/src/bun.js/modules/**",
"${workspaceFolder}/src/bun.js/builtins/**",
"${workspaceFolder}/src/deps/boringssl/include/",
"${workspaceFolder}/src/bun.js/bindings/sqlite/",
"${workspaceFolder}/src/bun.js/builtins/cpp/**",
"${workspaceFolder}/src/bun.js/WebKit/Source/bmalloc/**",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/ICU/Headers/",
"${workspaceFolder}/src/bun.js/bindings/webcrypto/",
"${workspaceFolder}/src/bun.js/bindings/webcrypto/openssl/",
"${workspaceFolder}/src/bun.js/bindings/webcrypto/algorithms/",
"${workspaceFolder}/src/bun.js/bindings/webcrypto/parameters/",
"${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/bindings/*",
"${workspaceFolder}/src/bun.js/bindings/sqlite/",
"${workspaceFolder}/src/bun.js/bindings/webcrypto/",
"${workspaceFolder}/src/bun.js/builtins/*",
"${workspaceFolder}/src/bun.js/builtins/cpp/*",
"${workspaceFolder}/src/bun.js/modules/*",
"${workspaceFolder}/src/deps",
"${workspaceFolder}/src/deps/boringssl/include/",
"${workspaceFolder}/src/deps/uws/uSockets/src"
],
"limitSymbolsToIncludedHeaders": true,
@@ -64,8 +59,7 @@
"macFrameworkPath": [],
"compilerPath": "/opt/homebrew/opt/llvm/bin/clang++",
"cStandard": "c17",
"cppStandard": "c++20",
"intelliSenseMode": "macos-clang-x64"
"cppStandard": "c++20"
}
],
"version": 4

View File

@@ -1,8 +1,3 @@
{
"recommendations": [
"AugusteRame.zls-vscode",
"esbenp.prettier-vscode",
"xaver.clang-format",
"vadimcn.vscode-lldb"
]
"recommendations": ["ziglang.vscode-zig", "esbenp.prettier-vscode", "xaver.clang-format", "vadimcn.vscode-lldb"]
}

96
.vscode/launch.json generated vendored
View File

@@ -7,7 +7,19 @@
"name": "bun test",
"program": "bun-debug",
"args": ["wiptest", "${file}"],
"cwd": "${workspaceFolder}/test",
"cwd": "${workspaceFolder}",
"env": {
"FORCE_COLOR": "1"
},
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "bun test --watch",
"program": "bun-debug",
"args": ["--watch", "test", "${file}"],
"cwd": "${workspaceFolder}",
"env": {
"FORCE_COLOR": "1"
},
@@ -21,7 +33,8 @@
"args": ["wiptest"],
"cwd": "${workspaceFolder}/test",
"env": {
"FORCE_COLOR": "1"
"FORCE_COLOR": "1",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2"
},
"console": "internalConsole"
},
@@ -37,6 +50,30 @@
},
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "bun run (watch)",
"program": "bun-debug",
"args": ["--watch", "${file}"],
"cwd": "${file}/../../",
"env": {
"FORCE_COLOR": "1"
},
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "bun run (hot)",
"program": "bun-debug",
"args": ["--hot", "${file}"],
"cwd": "${file}/../../",
"env": {
"FORCE_COLOR": "1"
},
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
@@ -96,6 +133,43 @@
"cwd": "${workspaceFolder}",
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "bun build debug",
"program": "bun-debug",
"args": ["build", "--platform=bun", "--outdir=/tmp/testout", "${file}"],
"cwd": "${file}/../../",
"console": "internalConsole",
"env": {
"BUN_CONFIG_MINIFY_WHITESPACE": "1"
}
},
{
"type": "lldb",
"request": "launch",
"name": "bunx debug",
"program": "bun-debug",
"args": ["--bun", "x", "tsc", "--help"],
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"env": {
"BUN_DEBUG_QUIET_LOGS": "1"
}
},
{
"type": "lldb",
"request": "launch",
"name": "bun install",
"program": "bun-debug",
"args": ["install"],
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"env": {
"BUN_DEBUG_QUIET_LOGS": "1"
}
},
{
"type": "lldb",
"request": "launch",
@@ -104,6 +178,24 @@
"args": ["https://example.com", "--verbose"],
"cwd": "${workspaceFolder}",
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "Build zig unit test",
"program": "make",
"args": ["build-unit", "${file}"],
"cwd": "${workspaceFolder}",
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "Run zig unit test",
"program": "${workspaceFolder}/zig-out/bin/test",
"args": ["abc"],
"cwd": "${workspaceFolder}",
"console": "internalConsole"
}
]
}

44
.vscode/settings.json vendored
View File

@@ -7,10 +7,16 @@
"search.followSymlinks": false,
"search.useIgnoreFiles": true,
"zig.buildOnSave": false,
"zig.buildArgs": [
"obj",
"-Dfor-editor"
],
"zig.buildOption": "build",
"zig.buildFilePath": "${workspaceFolder}/build.zig",
"[zig]": {
"editor.tabSize": 4,
"editor.useTabStops": false,
"editor.defaultFormatter": "AugusteRame.zls-vscode",
"editor.defaultFormatter": "ziglang.vscode-zig",
"editor.formatOnSave": true
},
"[ts]": {
@@ -29,9 +35,24 @@
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[yaml]": {
"editor.formatOnSave": true
},
"zig.beforeDebugCmd": "make build-unit ${file} ${filter} ${bin}",
"zig.testCmd": "make test ${file} ${filter} ${bin}",
"[markdown]": {
"editor.unicodeHighlight.ambiguousCharacters": false,
"editor.unicodeHighlight.invisibleCharacters": false,
"diffEditor.ignoreTrimWhitespace": false,
"editor.defaultFormatter": "yzhang.markdown-all-in-one",
"editor.formatOnSave": true,
"editor.wordWrap": "on",
"editor.quickSuggestions": {
"comments": "off",
"strings": "off",
"other": "off"
}
},
"lldb.verboseLogging": false,
"files.exclude": {
"**/.git": true,
@@ -44,8 +65,6 @@
"**/*.xcscheme": true,
"**/*.pem": true,
"**/*.xcodeproj": true,
"packages/bun-types/*.d.ts": true,
"test/snapshots": true,
"test/snapshots-no-hmr": true,
"src/bun.js/WebKit": true,
@@ -57,6 +76,8 @@
"src/deps/uws": true,
"src/deps/zlib": true,
"src/deps/lol-html": true,
"src/deps/c-ares": true,
"src/deps/tinycc": true,
"test/snippets/package-json-exports/_node_modules_copy": true
},
"C_Cpp.files.exclude": {
@@ -180,7 +201,16 @@
"ethernet.h": "c",
"inet.h": "c",
"packet.h": "c",
"queue": "cpp"
"queue": "cpp",
"compare": "cpp",
"concepts": "cpp",
"typeindex": "cpp",
"__verbose_abort": "cpp"
},
"cmake.configureOnOpen": false
}
"cmake.configureOnOpen": false,
"C_Cpp.errorSquiggles": "Enabled",
"eslint.workingDirectories": [
"packages/bun-types"
],
"files.insertFinalNewline": true
}

86
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,86 @@
# Contributing to Bun
All contributions need test coverage. If you are adding a new feature, please add a test. If you are fixing a bug, please add a test that fails before your fix and passes after your fix.
## Bun's codebase
Bun is written mostly in Zig, but WebKit & JavaScriptCore (the JavaScript engine) is written in C++.
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/))
- Package manager ([`src/install/`](src/install/))
- Shared utilities ([`src/string_immutable.zig`](src/string_immutable.zig))
The JavaScript transpiler & module resolver is mostly independent from the runtime. It predates the runtime and is entirely in Zig. The JavaScript parser is mostly in [`src/js_parser.zig`](src/js_parser.zig). The JavaScript AST data structures are mostly in [`src/js_ast.zig`](src/js_ast.zig). The JavaScript lexer is in [`src/js_lexer.zig`](src/js_lexer.zig). A lot of this code started as a port of esbuild's equivalent code from Go to Zig, but has had many small changes since then.
## Memory management in Bun
For the Zig code, please:
1. Do your best to avoid dynamically allocating memory.
2. If we need to allocate memory, carefully consider the owner of that memory. If it's a JavaScript object, it will need a finalizer. If it's in Zig, it will need to be freed either via an arena or manually.
3. Prefer arenas over manual memory management. Manually freeing memory is leak & crash prone.
4. If the memory needs to be accessed across threads, use `bun.default_allocator`. Mimalloc threadlocal heaps are not safe to free across threads.
The JavaScript transpiler has special-handling for memory management. The parser allocates into a single arena and the memory is recycled after each parse.
## JavaScript runtime
Most of Bun's JavaScript runtime code lives in [`src/bun.js`](src/bun.js).
### Calling C++ from Zig & Zig from C++
TODO: document this (see [`bindings.zig`](src/bun.js/bindings/bindings.zig) and [`bindings.cpp`](src/bun.js/bindings/bindings.cpp) for now)
### Adding a new JavaScript class
1. Add a new file in [`src/bun.js/*.classes.ts`](src/bun.js) to define the instance and static methods for the class.
2. Add a new file in [`src/bun.js/**/*.zig`](src/bun.js) and expose the struct in [`src/bun.js/generated_classes_list.zig`](src/bun.js/generated_classes_list.zig)
3. Run `make codegen`
Copy from examples like `Subprocess` or `Response`.
### ESM modules
Bun implements ESM modules in a mix of native code and JavaScript.
Several Node.js modules are implemented in JavaScript and loosely based on browserify polyfills.
The ESM modules in Bun are located in [`src/bun.js/*.exports.js`](src/bun.js/). Unlike other code in Bun, these files are NOT transpiled. They are loaded directly into the JavaScriptCore VM. That means `require` does not work in these files. Instead, you must use `import.meta.require`, or ideally, not use require/import other files at all.
The module loader is in [`src/bun.js/module_loader.zig`](src/bun.js/module_loader.zig).
### JavaScript Builtins
JavaScript builtins are located in [`src/bun.js/builtins/*.js`](src/bun.js/builtins).
These files support a JavaScriptCore-only syntax for internal slots. `@` is used to access an internal slot. For example: `new @Array(123)` will create a new `Array` similar to `new Array(123)`, except if a library modifies the `Array` global, it will not affect the internal slot (`@Array`). These names must be allow-listed in `BunBuiltinNames.h` (though JavaScriptCore allowlists some names by default).
They can not use or reference ESM-modules. The files that end with `*Internals.js` are automatically loaded globally. Most usage of internals right now are the stream implementations (which share a lot of code from Safari/WebKit) and ImportMetaObject (which is how `require` is implemented in the runtime)
To regenerate the builtins:
```sh
make clean-bindings && make generate-builtins && make bindings -j10
```
It is recommended that you have ccache installed or else you will spend a lot of time waiting for the bindings to compile.
### Memory management in Bun's JavaScript runtime
TODO: fill this out (for now, use `JSC.Strong` in most cases)
### Strings
TODO: fill this out (for now, use `JSValue.toSlice()` in most cases)
#### JavaScriptCore C API
Do not copy from examples leveraging the JavaScriptCore C API. Please do not use this in new code. We will not accept PRs that add new code that uses the JavaScriptCore C API.
## Testing
See [`test/README.md`](test/README.md) for information on how to run tests.

View File

@@ -7,17 +7,20 @@ ARG BUN_DEPS_OUT_DIR=${GITHUB_WORKSPACE}/bun-deps
ARG BUN_DIR=${GITHUB_WORKSPACE}/bun
ARG CPU_TARGET=native
ARG ARCH=x86_64
ARG BUILD_MACHINE_ARCH=x86_64
ARG TRIPLET=${ARCH}-linux-gnu
ARG BUILDARCH=amd64
ARG WEBKIT_TAG=jul27-2
ARG WEBKIT_TAG=feb9
ARG ZIG_TAG=jul1
ARG ZIG_VERSION="0.11.0-dev.1783+436e99d13"
ARG WEBKIT_BASENAME="bun-webkit-linux-$BUILDARCH"
ARG ZIG_FOLDERNAME=zig-linux-${BUILD_MACHINE_ARCH}-${ZIG_VERSION}
ARG ZIG_FILENAME=${ZIG_FOLDERNAME}.tar.xz
ARG WEBKIT_URL="https://github.com/oven-sh/WebKit/releases/download/$WEBKIT_TAG/${WEBKIT_BASENAME}.tar.gz"
ARG ZIG_URL="https://github.com/oven-sh/zig/releases/download/$ZIG_TAG/zig-linux-$BUILDARCH.zip"
ARG ZIG_URL="https://ziglang.org/builds/${ZIG_FILENAME}"
ARG GIT_SHA=""
ARG BUN_BASE_VERSION=0.2
ARG BUN_BASE_VERSION=0.5
FROM bitnami/minideb:bullseye as bun-base
@@ -25,7 +28,7 @@ RUN install_packages ca-certificates curl wget lsb-release software-properties-c
RUN wget https://apt.llvm.org/llvm.sh && \
chmod +x llvm.sh && \
./llvm.sh 13
./llvm.sh 15
RUN install_packages \
cmake \
@@ -43,10 +46,11 @@ RUN install_packages \
rsync \
ruby \
unzip \
bash tar gzip
xz-utils \
bash tar gzip ccache
ENV CXX=clang++-13
ENV CC=clang-13
ENV CXX=clang++-15
ENV CC=clang-15
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \
install_packages nodejs && \
@@ -63,13 +67,15 @@ ARG BUILDARCH
ARG ZIG_PATH
ARG WEBKIT_URL
ARG ZIG_URL
ARG ZIG_FOLDERNAME
ARG ZIG_FILENAME
ENV WEBKIT_OUT_DIR=${WEBKIT_DIR}
ENV BUILDARCH=${BUILDARCH}
ENV AR=/usr/bin/llvm-ar-13
ENV AR=/usr/bin/llvm-ar-15
ENV ZIG "${ZIG_PATH}/zig"
ENV PATH="$ZIG/bin:$PATH"
ENV LD=lld-13
ENV LD=lld-15
RUN mkdir -p $BUN_DIR $BUN_DEPS_OUT_DIR
@@ -78,8 +84,8 @@ FROM bun-base as bun-base-with-zig-and-webkit
WORKDIR $GITHUB_WORKSPACE
ADD $ZIG_URL .
RUN unzip -q zig-linux-$BUILDARCH.zip && \
rm zig-linux-$BUILDARCH.zip;
RUN tar xf ${ZIG_FILENAME} && \
rm ${ZIG_FILENAME} && mv ${ZIG_FOLDERNAME} zig;
@@ -105,6 +111,30 @@ RUN mkdir -p ${WEBKIT_DIR} && cd ${GITHUB_WORKSPACE} && \
LABEL org.opencontainers.image.title="bun base image with zig & webkit ${BUILDARCH} (glibc)"
LABEL org.opencontainers.image.source=https://github.com/oven-sh/bun
FROM bun-base as c-ares
ARG DEBIAN_FRONTEND
ARG GITHUB_WORKSPACE
ARG ZIG_PATH
# Directory extracts to "bun-webkit"
ARG WEBKIT_DIR
ARG BUN_RELEASE_DIR
ARG BUN_DEPS_OUT_DIR
ARG BUN_DIR
ARG CPU_TARGET
ENV CPU_TARGET=${CPU_TARGET}
ENV CCACHE_DIR=/ccache
ENV JSC_BASE_DIR=${WEBKIT_DIR}
ENV LIB_ICU_PATH=${WEBKIT_DIR}/lib
COPY Makefile ${BUN_DIR}/Makefile
COPY src/deps/c-ares ${BUN_DIR}/src/deps/c-ares
WORKDIR $BUN_DIR
RUN --mount=type=cache,target=/ccache cd $BUN_DIR && make c-ares && rm -rf ${BUN_DIR}/src/deps/c-ares ${BUN_DIR}/Makefile
FROM bun-base as lolhtml
@@ -119,10 +149,15 @@ ARG BUN_RELEASE_DIR
ARG BUN_DEPS_OUT_DIR
ARG BUN_DIR
ARG CPU_TARGET
ENV CPU_TARGET=${CPU_TARGET}
COPY Makefile ${BUN_DIR}/Makefile
COPY src/deps/lol-html ${BUN_DIR}/src/deps/lol-html
RUN export PATH=$PATH:$HOME/.cargo/bin && export CC=$(which clang-13) && cd ${BUN_DIR} && \
ENV CCACHE_DIR=/ccache
RUN --mount=type=cache,target=/ccache export PATH=$PATH:$HOME/.cargo/bin && export CC=$(which clang-15) && cd ${BUN_DIR} && \
make lolhtml && rm -rf src/deps/lol-html Makefile
FROM bun-base as mimalloc
@@ -141,7 +176,9 @@ COPY src/deps/mimalloc ${BUN_DIR}/src/deps/mimalloc
ARG CPU_TARGET
ENV CPU_TARGET=${CPU_TARGET}
RUN cd ${BUN_DIR} && \
ENV CCACHE_DIR=/ccache
RUN --mount=type=cache,target=/ccache cd ${BUN_DIR} && \
make mimalloc && rm -rf src/deps/mimalloc Makefile
FROM bun-base as zlib
@@ -162,7 +199,9 @@ COPY src/deps/zlib ${BUN_DIR}/src/deps/zlib
WORKDIR $BUN_DIR
RUN cd $BUN_DIR && \
ENV CCACHE_DIR=/ccache
RUN --mount=type=cache,target=/ccache cd $BUN_DIR && \
make zlib && rm -rf src/deps/zlib Makefile
FROM bun-base as libarchive
@@ -183,29 +222,14 @@ RUN install_packages autoconf automake libtool pkg-config
COPY Makefile ${BUN_DIR}/Makefile
COPY src/deps/libarchive ${BUN_DIR}/src/deps/libarchive
RUN cd $BUN_DIR && \
ENV CCACHE_DIR=/ccache
WORKDIR $BUN_DIR
RUN --mount=type=cache,target=/ccache cd $BUN_DIR && \
make libarchive && rm -rf src/deps/libarchive Makefile
FROM bun-base as oniguruma
ARG DEBIAN_FRONTEND
ARG GITHUB_WORKSPACE
ARG ZIG_PATH
# Directory extracts to "bun-webkit"
ARG WEBKIT_DIR
ARG BUN_RELEASE_DIR
ARG BUN_DEPS_OUT_DIR
ARG BUN_DIR
ARG CPU_TARGET
ENV CPU_TARGET=${CPU_TARGET}
RUN install_packages autoconf automake libtool pkg-config
COPY Makefile ${BUN_DIR}/Makefile
COPY src/deps/oniguruma ${BUN_DIR}/src/deps/oniguruma
WORKDIR $BUN_DIR
RUN make oniguruma && rm -rf src/deps/oniguruma Makefile
FROM bun-base as tinycc
@@ -222,27 +246,6 @@ ENV CPU_TARGET=${CPU_TARGET}
RUN install_packages libtcc-dev && cp /usr/lib/$(uname -m)-linux-gnu/libtcc.a ${BUN_DEPS_OUT_DIR}
FROM bun-base as libbacktrace
ARG DEBIAN_FRONTEND
ARG GITHUB_WORKSPACE
ARG ZIG_PATH
# Directory extracts to "bun-webkit"
ARG WEBKIT_DIR
ARG BUN_RELEASE_DIR
ARG BUN_DEPS_OUT_DIR
ARG BUN_DIR
ARG CPU_TARGET
ENV CPU_TARGET=${CPU_TARGET}
COPY Makefile ${BUN_DIR}/Makefile
COPY src/deps/libbacktrace ${BUN_DIR}/src/deps/libbacktrace
WORKDIR $BUN_DIR
RUN cd $BUN_DIR && \
make libbacktrace && rm -rf src/deps/libbacktrace Makefile
FROM bun-base as boringssl
RUN install_packages golang
@@ -263,27 +266,9 @@ COPY src/deps/boringssl ${BUN_DIR}/src/deps/boringssl
WORKDIR $BUN_DIR
RUN make boringssl && rm -rf src/deps/boringssl Makefile
ENV CCACHE_DIR=/ccache
FROM bun-base as base64
ARG DEBIAN_FRONTEND
ARG GITHUB_WORKSPACE
ARG ZIG_PATH
# Directory extracts to "bun-webkit"
ARG WEBKIT_DIR
ARG BUN_RELEASE_DIR
ARG BUN_DEPS_OUT_DIR
ARG BUN_DIR
ARG CPU_TARGET
ENV CPU_TARGET=${CPU_TARGET}
COPY Makefile ${BUN_DIR}/Makefile
COPY src/base64 ${BUN_DIR}/src/base64
WORKDIR $BUN_DIR
RUN make base64 && rm -rf src/base64 Makefile
RUN --mount=type=cache,target=/ccache cd ${BUN_DIR} && make boringssl && rm -rf src/deps/boringssl Makefile
FROM bun-base as uws
@@ -392,11 +377,12 @@ ENV CPU_TARGET=${CPU_TARGET}
WORKDIR $BUN_DIR
COPY ./root.zig ${BUN_DIR}/root.zig
COPY ./src ${BUN_DIR}/src
COPY ./build.zig ${BUN_DIR}/build.zig
COPY ./completions ${BUN_DIR}/completions
COPY ./packages ${BUN_DIR}/packages
COPY ./build-id ${BUN_DIR}/build-id
COPY ./src/build-id ${BUN_DIR}/src/build-id
COPY ./package.json ${BUN_DIR}/package.json
COPY ./misctools ${BUN_DIR}/misctools
COPY Makefile ${BUN_DIR}/Makefile
@@ -416,6 +402,7 @@ ARG CPU_TARGET
ENV CPU_TARGET=${CPU_TARGET}
COPY Makefile ${BUN_DIR}/Makefile
COPY .prettierrc.cjs ${BUN_DIR}/.prettierrc.cjs
WORKDIR $BUN_DIR
@@ -434,12 +421,14 @@ ENV GIT_SHA=${GIT_SHA}
COPY --from=identifier_cache ${BUN_DIR}/src/js_lexer/*.blob ${BUN_DIR}/src/js_lexer/
COPY --from=node_fallbacks ${BUN_DIR}/src/node-fallbacks/out ${BUN_DIR}/src/node-fallbacks/out
COPY ./build-id ${BUN_DIR}/build-id
COPY ./src/build-id ${BUN_DIR}/src/build-id
RUN cd $BUN_DIR && mkdir -p src/bun.js/bindings-obj && rm -rf $HOME/.cache zig-cache && make prerelease && \
ENV CCACHE_DIR=/ccache
RUN --mount=type=cache,target=/ccache cd $BUN_DIR && mkdir -p src/bun.js/bindings-obj && rm -rf $HOME/.cache zig-cache && make prerelease && \
mkdir -p $BUN_RELEASE_DIR && \
OUTPUT_DIR=/tmp $ZIG_PATH/zig build obj -Drelease-fast -Dtarget="${TRIPLET}" -Dcpu="${CPU_TARGET}" && \
cp /tmp/bun.o /tmp/bun-${BUN_BASE_VERSION}.$(cat ${BUN_DIR}/build-id).o && cd / && rm -rf $BUN_DIR
OUTPUT_DIR=/tmp/bun-${TRIPLET}-${GIT_SHA} $ZIG_PATH/zig build obj -Doutput-dir=/tmp/bun-${TRIPLET}-${GIT_SHA} -Doptimize=ReleaseFast -Dtarget="${TRIPLET}" -Dcpu="${CPU_TARGET}" && \
cp /tmp/bun-${TRIPLET}-${GIT_SHA}/bun.o /tmp/bun-${TRIPLET}-${GIT_SHA}/bun-${BUN_BASE_VERSION}.$(cat ${BUN_DIR}/src/build-id).o && cd / && rm -rf $BUN_DIR
FROM scratch as build_release_obj
@@ -450,12 +439,13 @@ ARG ZIG_PATH
ARG WEBKIT_DIR
ARG BUN_RELEASE_DIR
ARG BUN_DEPS_OUT_DIR
ARG GIT_SHA
ARG TRIPLET
ARG BUN_DIR
ARG CPU_TARGET
ENV CPU_TARGET=${CPU_TARGET}
COPY --from=compile_release_obj /tmp/*.o /
COPY --from=compile_release_obj /tmp/bun-${TRIPLET}-${GIT_SHA}/*.o /
FROM prepare_release as compile_cpp
@@ -471,32 +461,22 @@ ARG CPU_TARGET
ENV CPU_TARGET=${CPU_TARGET}
COPY Makefile ${BUN_DIR}/Makefile
COPY .prettierrc.cjs ${BUN_DIR}/.prettierrc.cjs
WORKDIR $BUN_DIR
ENV JSC_BASE_DIR=${WEBKIT_DIR}
ENV LIB_ICU_PATH=${WEBKIT_DIR}/lib
COPY --from=boringssl ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=zlib ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=lolhtml ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=mimalloc ${BUN_DEPS_OUT_DIR}/*.o ${BUN_DEPS_OUT_DIR}/
COPY --from=libarchive ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=oniguruma ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=picohttp ${BUN_DEPS_OUT_DIR}/*.o ${BUN_DEPS_OUT_DIR}/
COPY --from=uws ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=uws ${BUN_DEPS_OUT_DIR}/*.o ${BUN_DEPS_OUT_DIR}/
COPY --from=libbacktrace ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=tinycc ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=base64 ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
# Required for `make webcrypto`
COPY src/deps/boringssl/include ${BUN_DIR}/src/deps/boringssl/include
RUN cd $BUN_DIR && mkdir -p src/bun.js/bindings-obj && rm -rf $HOME/.cache zig-cache && mkdir -p $BUN_RELEASE_DIR && make webcrypto && \
ENV CCACHE_DIR=/ccache
RUN --mount=type=cache,target=/ccache cd $BUN_DIR && mkdir -p src/bun.js/bindings-obj && rm -rf $HOME/.cache zig-cache && mkdir -p $BUN_RELEASE_DIR && make webcrypto && \
make release-bindings -j10 && mv ${BUN_DEPS_OUT_DIR}/libwebcrypto.a /tmp && mv src/bun.js/bindings-obj/* /tmp
FROM prepare_release as sqlite
FROM bun-base as sqlite
ARG DEBIAN_FRONTEND
ARG GITHUB_WORKSPACE
@@ -507,14 +487,21 @@ ARG BUN_RELEASE_DIR
ARG BUN_DEPS_OUT_DIR
ARG BUN_DIR
ARG CPU_TARGET
ENV CPU_TARGET=${CPU_TARGET}
ENV CCACHE_DIR=/ccache
COPY Makefile ${BUN_DIR}/Makefile
COPY src/bun.js/bindings/sqlite ${BUN_DIR}/src/bun.js/bindings/sqlite
COPY .prettierrc.cjs ${BUN_DIR}/.prettierrc.cjs
WORKDIR $BUN_DIR
ENV JSC_BASE_DIR=${WEBKIT_DIR}
ENV LIB_ICU_PATH=${WEBKIT_DIR}/lib
RUN cd $BUN_DIR && make sqlite
RUN --mount=type=cache,target=/ccache cd $BUN_DIR && make sqlite
FROM scratch as build_release_cpp
@@ -535,6 +522,7 @@ ARG CPU_TARGET
ENV CPU_TARGET=${CPU_TARGET}
COPY Makefile ${BUN_DIR}/Makefile
COPY .prettierrc.cjs ${BUN_DIR}/.prettierrc.cjs
WORKDIR $BUN_DIR
@@ -543,17 +531,16 @@ ENV LIB_ICU_PATH=${WEBKIT_DIR}/lib
COPY --from=zlib ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=libarchive ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=base64 ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=boringssl ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=libbacktrace ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=lolhtml ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=mimalloc ${BUN_DEPS_OUT_DIR}/*.o ${BUN_DEPS_OUT_DIR}/
COPY --from=oniguruma ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=picohttp ${BUN_DEPS_OUT_DIR}/*.o ${BUN_DEPS_OUT_DIR}/
COPY --from=sqlite ${BUN_DEPS_OUT_DIR}/*.o ${BUN_DEPS_OUT_DIR}/
COPY --from=tinycc ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=uws ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=uws ${BUN_DEPS_OUT_DIR}/*.o ${BUN_DEPS_OUT_DIR}/
COPY --from=c-ares ${BUN_DEPS_OUT_DIR}/*.a ${BUN_DEPS_OUT_DIR}/
COPY --from=build_release_obj /*.o /tmp
COPY --from=build_release_cpp /*.o ${BUN_DIR}/src/bun.js/bindings-obj/
COPY --from=build_release_cpp /*.a ${BUN_DEPS_OUT_DIR}/

View File

@@ -1,12 +1,18 @@
ARG DEBIAN_FRONTEND=noninteractive
ARG GITHUB_WORKSPACE=/build
ARG BUILDARCH=amd64
ARG ARCH=x86_64
ARG ZIG_PATH=${GITHUB_WORKSPACE}/zig
ARG WEBKIT_DIR=${GITHUB_WORKSPACE}/bun-webkit
ARG BUN_RELEASE_DIR=${GITHUB_WORKSPACE}/bun-release
ARG BUN_DEPS_OUT_DIR=${GITHUB_WORKSPACE}/bun-deps
ARG BUN_DIR=${GITHUB_WORKSPACE}/bun
ARG BUN_PACKAGES_DIR=${BUN_DIR}/packages
ARG ZIG_VERSION="0.11.0-dev.1783+436e99d13"
ARG ZIG_FOLDERNAME=zig-linux-${ARCH}-${ZIG_VERSION}
ARG ZIG_FILENAME=${ZIG_FOLDERNAME}.tar.xz
ARG ZIG_URL="https://ziglang.org/builds/${ZIG_FILENAME}"
FROM --platform=linux/${BUILDARCH} ubuntu:22.04 as bun.devcontainer
@@ -37,7 +43,7 @@ RUN apt-get update && \
add-apt-repository ppa:longsleep/golang-backports && \
wget https://apt.llvm.org/llvm.sh --no-check-certificate && \
chmod +x llvm.sh && \
./llvm.sh 13 && \
./llvm.sh 15 && \
curl -fsSL https://deb.nodesource.com/setup_16.x | bash - && \
apt-get update && \
apt-get install --no-install-recommends -y \
@@ -50,16 +56,16 @@ RUN apt-get update && \
git \
libssl-dev \
ruby \
liblld-13-dev \
libclang-13-dev \
liblld-15-dev \
libclang-15-dev \
nodejs \
gcc \
g++ \
clang-13 \
clang-format-13 \
libc++-13-dev \
libc++abi-13-dev \
lld-13 \
clang-15 \
clang-format-15 \
libc++-15-dev \
libc++abi-15-dev \
lld-15 \
libicu-dev \
wget \
rustc \
@@ -67,35 +73,38 @@ RUN apt-get update && \
unzip \
tar \
golang-go ninja-build pkg-config automake autoconf libtool curl && \
update-alternatives --install /usr/bin/cc cc /usr/bin/clang-13 90 && \
update-alternatives --install /usr/bin/cpp cpp /usr/bin/clang++-13 90 && \
update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-13 90 && \
update-alternatives --install /usr/bin/cc cc /usr/bin/clang-15 90 && \
update-alternatives --install /usr/bin/cpp cpp /usr/bin/clang++-15 90 && \
update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-15 90 && \
npm install -g esbuild
ENV CC=clang-13
ENV CXX=clang++-13
ENV CC=clang-15
ENV CXX=clang++-15
ENV ZIG "${ZIG_PATH}/zig"
WORKDIR $GITHUB_WORKSPACE
RUN cd / && mkdir -p $BUN_RELEASE_DIR $BUN_DEPS_OUT_DIR ${BUN_DIR} ${BUN_DEPS_OUT_DIR}
WORKDIR $GITHUB_WORKSPACE
RUN cd $GITHUB_WORKSPACE && \
curl -o zig-linux-$BUILDARCH.zip -L https://github.com/oven-sh/zig/releases/download/jul1/zig-linux-$BUILDARCH.zip && \
unzip -q zig-linux-$BUILDARCH.zip && \
rm zig-linux-$BUILDARCH.zip;
ARG ZIG_FOLDERNAME
ARG ZIG_FILENAME
ARG ZIG_URL
ADD $ZIG_URL .
RUN tar -xf ${ZIG_FILENAME} && \
rm ${ZIG_FILENAME} && \
mv ${ZIG_FOLDERNAME} ${ZIG_PATH};
RUN cd $GITHUB_WORKSPACE && \
curl -o bun-webkit-linux-$BUILDARCH.tar.gz -L https://github.com/oven-sh/WebKit/releases/download/oct28/bun-webkit-linux-$BUILDARCH.tar.gz && \
curl -o bun-webkit-linux-$BUILDARCH.tar.gz -L https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-linux-$BUILDARCH.tar.gz && \
tar -xzf bun-webkit-linux-$BUILDARCH.tar.gz && \
rm bun-webkit-linux-$BUILDARCH.tar.gz && \
cat $WEBKIT_OUT_DIR/include/cmakeconfig.h > /dev/null
RUN apt-get -y update && update-alternatives --install /usr/bin/lldb lldb /usr/bin/lldb-13 90
RUN apt-get -y update && update-alternatives --install /usr/bin/lldb lldb /usr/bin/lldb-15 90
COPY .devcontainer/workspace.code-workspace $GITHUB_WORKSPACE/workspace.code-workspace
COPY .devcontainer/zls.json $GITHUB_WORKSPACE/workspace.code-workspace

437
Makefile
View File

@@ -4,6 +4,10 @@ OS_NAME := $(shell uname -s | tr '[:upper:]' '[:lower:]')
ARCH_NAME_RAW := $(shell uname -m)
BUN_AUTO_UPDATER_REPO = Jarred-Sumner/bun-releases-for-updater
CMAKE_CXX_COMPILER_LAUNCHER_FLAG :=
# 'make' command will trigger the help target
.DEFAULT_GOAL := help
@@ -31,11 +35,11 @@ DOCKER_BUILDARCH = amd64
BREW_PREFIX_PATH = /usr/local
DEFAULT_MIN_MACOS_VERSION = 10.14
MARCH_NATIVE = -march=$(CPU_TARGET) -mtune=$(CPU_TARGET)
NATIVE_OR_OLD_MARCH = -march=westmere
NATIVE_OR_OLD_MARCH = -march=nehalem
endif
MIN_MACOS_VERSION ?= $(DEFAULT_MIN_MACOS_VERSION)
BUN_BASE_VERSION = 0.2
BUN_BASE_VERSION = 0.5
AR=
@@ -50,12 +54,12 @@ DEBUG_PACKAGE_DIR = $(PACKAGES_REALPATH)/debug-$(PACKAGE_NAME)
RELEASE_BUN = $(PACKAGE_DIR)/bun
DEBUG_BIN = $(DEBUG_PACKAGE_DIR)/
DEBUG_BUN = $(DEBUG_BIN)/bun-debug
BUILD_ID = $(shell cat ./build-id)
BUILD_ID = $(shell cat ./src/build-id)
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 || echo "./node_modules/.bin/prettier")
DSYMUTIL ?= $(shell which dsymutil || which dsymutil-13)
DSYMUTIL ?= $(shell which dsymutil || which dsymutil-15)
WEBKIT_DIR ?= $(realpath src/bun.js/WebKit)
WEBKIT_RELEASE_DIR ?= $(WEBKIT_DIR)/WebKitBuild/Release
WEBKIT_DEBUG_DIR ?= $(WEBKIT_DIR)/WebKitBuild/Debug
@@ -70,20 +74,39 @@ ZIG ?= $(shell which zig || echo -e "error: Missing zig. Please make sure zig is
# 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++
CC = $(shell which clang-13 || which clang)
CXX = $(shell which clang++-13 || which clang++)
REAL_CC = $(shell which clang-15 || which clang)
REAL_CXX = $(shell which clang++-15 || which clang++)
CC = $(REAL_CC)
CXX = $(REAL_CXX)
CCACHE_CC_OR_CC := $(REAL_CC)
CCACHE_PATH := $(shell which ccache 2>/dev/null)
CCACHE_CC_FLAG = CC=$(CCACHE_CC_OR_CC)
ifeq (,$(findstring,$(shell which ccache),ccache))
CMAKE_CXX_COMPILER_LAUNCHER_FLAG := -DCMAKE_CXX_COMPILER_LAUNCHER=$(CCACHE_PATH) -DCMAKE_C_COMPILER_LAUNCHER=$(CCACHE_PATH)
CCACHE_CC_OR_CC := "$(CCACHE_PATH) $(REAL_CC)"
export CCACHE_COMPILERTYPE = clang
CCACHE_CC_FLAG = CC=$(CCACHE_CC_OR_CC) CCACHE_COMPILER=$(REAL_CC)
CCACHE_CXX_FLAG = CXX=$(CCACHE_PATH) CCACHE_COMPILER=$(REAL_CXX)
endif
CXX_WITH_CCACHE = $(CCACHE_PATH) $(CXX)
CC_WITH_CCACHE = $(CCACHE_PATH) $(CC)
ifeq ($(OS_NAME),darwin)
# Find LLVM
ifeq ($(wildcard $(LLVM_PREFIX)),)
LLVM_PREFIX = $(shell brew --prefix llvm@13)
LLVM_PREFIX = $(shell brew --prefix llvm@15)
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@13' or set LLVM_PREFIX=/path/to/llvm")
LLVM_PREFIX = $(shell echo -e "error: Unable to find llvm. Please run 'brew install llvm@15' or set LLVM_PREFIX=/path/to/llvm")
endif
LDFLAGS += -L$(LLVM_PREFIX)/lib
@@ -118,7 +141,15 @@ LIBICONV_PATH ?= $(BREW_PREFIX_PATH)/opt/libiconv/lib/libiconv.a
OPENSSL_LINUX_DIR = $(BUN_DEPS_DIR)/openssl/openssl-OpenSSL_1_1_1l
CMAKE_FLAGS_WITHOUT_RELEASE = -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX) -DCMAKE_OSX_DEPLOYMENT_TARGET=$(MIN_MACOS_VERSION)
CMAKE_FLAGS_WITHOUT_RELEASE = -DCMAKE_C_COMPILER=$(CC) \
-DCMAKE_CXX_COMPILER=$(CXX) \
-DCMAKE_OSX_DEPLOYMENT_TARGET=$(MIN_MACOS_VERSION) \
$(CMAKE_CXX_COMPILER_LAUNCHER_FLAG) \
-DCMAKE_AR=$(AR) \
-DCMAKE_RANLIB=$(which llvm-15-ranlib || which llvm-ranlib)
CMAKE_FLAGS = $(CMAKE_FLAGS_WITHOUT_RELEASE) -DCMAKE_BUILD_TYPE=Release
# SQLite3 is dynamically linked on macOS
@@ -127,24 +158,23 @@ CMAKE_FLAGS = $(CMAKE_FLAGS_WITHOUT_RELEASE) -DCMAKE_BUILD_TYPE=Release
SQLITE_OBJECT =
BITCODE_OR_SECTIONS=
EMBED_OR_EMIT_BITCODE=
LIBTOOL=libtoolize
ifeq ($(OS_NAME),darwin)
LIBTOOL=glibtoolize
AR=$(LLVM_PREFIX)/bin/llvm-ar
BITCODE_OR_SECTIONS=-fembed-bitcode
BITCODE_OR_SECTIONS=
endif
ifeq ($(OS_NAME),linux)
LIBICONV_PATH =
AR = $(shell which llvm-ar-13 || which llvm-ar || which ar)
AR = $(shell which llvm-ar-15 || which llvm-ar || which ar)
endif
OPTIMIZATION_LEVEL=-O3 $(MARCH_NATIVE)
DEBUG_OPTIMIZATION_LEVEL= -O1 $(MARCH_NATIVE)
CFLAGS_WITHOUT_MARCH = $(MACOS_MIN_FLAG) $(BITCODE_OR_SECTIONS) $(OPTIMIZATION_LEVEL) -fno-exceptions -fvisibility=hidden -fvisibility-inlines-hidden
BUN_CFLAGS = $(MACOS_MIN_FLAG) $(MARCH_NATIVE) $(EMBED_OR_EMIT_BITCODE) $(OPTIMIZATION_LEVEL) -fno-exceptions -fvisibility=hidden -fvisibility-inlines-hidden
CFLAGS_WITHOUT_MARCH = $(MACOS_MIN_FLAG) $(OPTIMIZATION_LEVEL) -fno-exceptions -fvisibility=hidden -fvisibility-inlines-hidden
BUN_CFLAGS = $(MACOS_MIN_FLAG) $(MARCH_NATIVE) $(OPTIMIZATION_LEVEL) -fno-exceptions -fvisibility=hidden -fvisibility-inlines-hidden
BUN_TMP_DIR := /tmp/make-bun
CFLAGS=$(CFLAGS_WITHOUT_MARCH) $(MARCH_NATIVE)
@@ -153,18 +183,26 @@ DEFAULT_USE_BMALLOC := 1
USE_BMALLOC ?= DEFAULT_USE_BMALLOC
JSC_BASE_DIR ?= ${HOME}/webkit-build
# Set via postinstall
AUTO_JSX_BASE_DIR ?= $(realpath $(firstword $(wildcard bun-webkit)))
ifeq (,$(AUTO_JSX_BASE_DIR))
AUTO_JSX_BASE_DIR ?= $(HOME)/webkit-build
endif
JSC_BASE_DIR ?= $(AUTO_JSX_BASE_DIR)
DEFAULT_JSC_LIB :=
DEFAULT_JSC_LIB_DEBUG :=
ifeq ($(OS_NAME),linux)
DEFAULT_JSC_LIB = $(JSC_BASE_DIR)/lib
DEFAULT_JSC_LIB_DEBUG = $(DEFAULT_JSC_LIB)
ifneq (,$(realpath $(WEBKIT_RELEASE_DIR_LTO)/lib))
DEFAULT_JSC_LIB = $(WEBKIT_RELEASE_DIR_LTO)/lib
endif
ifeq ($(OS_NAME),darwin)
DEFAULT_JSC_LIB = $(WEBKIT_RELEASE_DIR_LTO)/lib
ifneq (,$(realpath $(WEBKIT_RELEASE_DIR)/lib))
DEFAULT_JSC_LIB_DEBUG = $(WEBKIT_RELEASE_DIR)/lib
endif
@@ -228,7 +266,7 @@ STRIP=/usr/bin/strip
endif
ifeq ($(OS_NAME),linux)
STRIP=$(shell which llvm-strip || which llvm-strip-13 || which strip || echo "Missing strip")
STRIP=$(shell which llvm-strip || which llvm-strip-15 || which strip || echo "Missing strip")
endif
@@ -300,7 +338,7 @@ LINUX_INCLUDE_DIRS := $(ALL_JSC_INCLUDE_DIRS) \
UWS_INCLUDE_DIR := -I$(BUN_DEPS_DIR)/uws/uSockets/src -I$(BUN_DEPS_DIR)/uws/src -I$(BUN_DEPS_DIR)
INCLUDE_DIRS := $(UWS_INCLUDE_DIR) -I$(BUN_DEPS_DIR)/mimalloc/include -Isrc/napi -I$(BUN_DEPS_DIR)/boringssl/include
INCLUDE_DIRS := $(UWS_INCLUDE_DIR) -I$(BUN_DEPS_DIR)/mimalloc/include -Isrc/napi -I$(BUN_DEPS_DIR)/boringssl/include -I$(BUN_DEPS_DIR)/c-ares/include
ifeq ($(OS_NAME),linux)
@@ -357,6 +395,10 @@ CLANG_FLAGS = $(INCLUDE_DIRS) \
-fvisibility=hidden \
-fvisibility-inlines-hidden
ifeq ($(OS_NAME),darwin)
CLANG_FLAGS += -DBUN_FAST_TLS=1 -DUSE_BUN_FAST_TLS=1 -DHAVE_BUN_FAST_TLS=1
endif
PLATFORM_LINKER_FLAGS =
SYMBOLS=
@@ -367,17 +409,17 @@ ifeq ($(OS_NAME), darwin)
SYMBOLS=-exported_symbols_list $(realpath src/symbols.txt)
PLATFORM_LINKER_FLAGS += -DDU_DISABLE_RENAMING=1 \
-lstdc++ \
-fno-keep-static-consts
-fno-keep-static-consts -lresolv
endif
ifeq ($(OS_NAME),linux)
SYMBOLS=-Wl,--dynamic-list $(realpath src/symbols.dyn)
SYMBOLS=-Wl,--dynamic-list $(realpath src/symbols.dyn) -Wl,--version-script=$(realpath src/linker.lds)
endif
SHARED_LIB_EXTENSION = .so
JSC_BINDINGS = $(BINDINGS_OBJ) $(JSC_FILES)
JSC_BINDINGS_DEBUG = $(DEBUG_BINDINGS_OBJ) $(JSC_FILES_DEBUG)
JSC_BINDINGS_DEBUG = $(DEBUG_BINDINGS_OBJ) $(JSC_FILES_DEBUG)
RELEASE_FLAGS=
DEBUG_FLAGS=
@@ -394,24 +436,38 @@ MINIMUM_ARCHIVE_FILES = -L$(BUN_DEPS_OUT_DIR) \
-lz \
$(BUN_DEPS_OUT_DIR)/picohttpparser.o \
$(_MIMALLOC_LINK) \
-ldecrepit \
-lssl \
-lcrypto \
-llolhtml \
-lonig \
$(BUN_DEPS_OUT_DIR)/libbacktrace.a \
-llolhtml
ARCHIVE_FILES_WITHOUT_LIBCRYPTO = $(MINIMUM_ARCHIVE_FILES) \
-larchive \
-lbase64 \
-ltcc \
-lusockets \
-lcares \
$(BUN_DEPS_OUT_DIR)/libuwsockets.o
ARCHIVE_FILES = $(ARCHIVE_FILES_WITHOUT_LIBCRYPTO)
ARCHIVE_FILES = $(ARCHIVE_FILES_WITHOUT_LIBCRYPTO)
STATIC_MUSL_FLAG ?=
WRAP_SYMBOLS_ON_LINUX =
ifeq ($(OS_NAME), linux)
WRAP_SYMBOLS_ON_LINUX = -Wl,--wrap=fcntl -Wl,--wrap=fcntl64 -Wl,--wrap=stat64 -Wl,--wrap=pow -Wl,--wrap=exp -Wl,--wrap=log -Wl,--wrap=log2 \
-Wl,--wrap=lstat \
-Wl,--wrap=stat \
-Wl,--wrap=fstat \
-Wl,--wrap=fstatat \
-Wl,--wrap=lstat64 \
-Wl,--wrap=stat64 \
-Wl,--wrap=fstat64 \
-Wl,--wrap=fstatat64 \
-Wl,--wrap=mknod \
-Wl,--wrap=mknodat \
-Wl,--wrap=statx
PLATFORM_LINKER_FLAGS = $(BUN_CFLAGS) \
-fuse-ld=lld \
-Wl,-z,now \
@@ -422,15 +478,15 @@ PLATFORM_LINKER_FLAGS = $(BUN_CFLAGS) \
-static-libgcc \
-fno-omit-frame-pointer \
-Wl,--compress-debug-sections,zlib \
-l:libatomic.a \
${STATIC_MUSL_FLAG} \
-Wl,-Bsymbolic-functions \
-fno-semantic-interposition \
-flto \
-Wl,--allow-multiple-definition \
-rdynamic
endif
@@ -443,9 +499,9 @@ BUN_LLD_FLAGS_WITHOUT_JSC = $(ARCHIVE_FILES) \
BUN_LLD_FLAGS = $(BUN_LLD_FLAGS_WITHOUT_JSC) $(JSC_FILES) $(BINDINGS_OBJ) -lwebcrypto
BUN_LLD_FLAGS_DEBUG = $(BUN_LLD_FLAGS_WITHOUT_JSC) $(JSC_FILES_DEBUG) $(DEBUG_BINDINGS_OBJ) -lwebcrypto-debug
BUN_LLD_FLAGS_FAST = $(BUN_LLD_FLAGS_WITHOUT_JSC) $(JSC_FILES_DEBUG) $(BINDINGS_OBJ) -lwebcrypto-debug
BUN_LLD_FLAGS = $(BUN_LLD_FLAGS_WITHOUT_JSC) $(WRAP_SYMBOLS_ON_LINUX) $(JSC_FILES) $(BINDINGS_OBJ) -lwebcrypto
BUN_LLD_FLAGS_DEBUG = $(BUN_LLD_FLAGS_WITHOUT_JSC) $(WRAP_SYMBOLS_ON_LINUX) $(JSC_FILES_DEBUG) $(DEBUG_BINDINGS_OBJ) -lwebcrypto-debug
BUN_LLD_FLAGS_FAST = $(BUN_LLD_FLAGS_WITHOUT_JSC) $(WRAP_SYMBOLS_ON_LINUX) $(JSC_FILES_DEBUG) $(BINDINGS_OBJ) -lwebcrypto-debug
CLANG_VERSION = $(shell $(CC) --version | awk '/version/ {for(i=1; i<=NF; i++){if($$i=="version"){split($$(i+1),v,".");print v[1]}}}')
@@ -454,16 +510,15 @@ CLANG_VERSION = $(shell $(CC) --version | awk '/version/ {for(i=1; i<=NF; i++){i
bun:
npm-install:
$(NPM_CLIENT) install
$(NPM_CLIENT) install --ignore-scripts --production
print-% : ; @echo $* = $($*)
get-% : ; @echo $($*)
print-version:
@echo $(PACKAGE_JSON_VERSION)
.PHONY: base64
base64:
cd src/base64 && \
rm -rf src/base64/*.{o,ll,bc} && \
$(CC) $(EMIT_LLVM_FOR_RELEASE) $(BUN_CFLAGS) $(OPTIMIZATION_LEVEL) -g -fPIC -c *.c -I$(SRC_DIR)/base64 && \
$(CXX) $(EMIT_LLVM_FOR_RELEASE) $(CXXFLAGS) $(BUN_CFLAGS) -c neonbase64.cc -g -fPIC && \
$(AR) rcvs $(BUN_DEPS_OUT_DIR)/libbase64.a ./*.o
# Prevent dependency on libtcc1 so it doesn't do filesystem lookups
TINYCC_CFLAGS= -DTCC_LIBTCC1=\"\0\"
@@ -475,7 +530,7 @@ TINYCC_CFLAGS= -DTCC_LIBTCC1=\"\0\"
tinycc:
cd $(TINYCC_DIR) && \
make clean && \
AR=$(AR) CC=$(CC) CFLAGS='$(CFLAGS_WITHOUT_MARCH) $(NATIVE_OR_OLD_MARCH) -mtune=native $(TINYCC_CFLAGS)' ./configure --enable-static --cc=$(CC) --ar=$(AR) --config-predefs=yes && \
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 && \
cp $(TINYCC_DIR)/*.a $(BUN_DEPS_OUT_DIR)
@@ -501,14 +556,29 @@ builtins: ## to generate builtins
.PHONY: generate-builtins
generate-builtins: builtins
.PHONY: vendor-without-check
vendor-without-check: npm-install node-fallbacks runtime_js fallback_decoder bun_error mimalloc picohttp zlib boringssl libarchive libbacktrace lolhtml usockets uws base64 tinycc oniguruma
BUN_TYPES_REPO_PATH ?= $(realpath ../bun-types)
BUN_TYPES_REPO_PATH ?= $(realpath packages/bun-types)
ifeq ($(DEBUG),true)
BUN_RELEASE_BIN = bun
endif
.PHONY: c-ares
c-ares:
rm -rf $(BUN_DEPS_DIR)/c-ares/build && \
mkdir $(BUN_DEPS_DIR)/c-ares/build && \
cd $(BUN_DEPS_DIR)/c-ares/build && \
cmake $(CMAKE_FLAGS) -DCMAKE_C_FLAGS="$(CFLAGS) -flto=full" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCARES_STATIC=ON -DCARES_STATIC_PIC=ON -DCARES_SHARED=OFF \
-G "Ninja" .. && \
ninja && cp lib/libcares.a $(BUN_DEPS_OUT_DIR)/libcares.a
.PHONY: prepare-types
prepare-types:
BUN_VERSION=$(PACKAGE_JSON_VERSION) $(BUN_RELEASE_BIN) $(BUN_TYPES_REPO_PATH)/bundle.ts $(BUN_TYPES_REPO_PATH)/dist
BUN_VERSION=$(PACKAGE_JSON_VERSION) $(BUN_RELEASE_BIN) $(BUN_TYPES_REPO_PATH)/scripts/bundle.ts $(BUN_TYPES_REPO_PATH)/dist
echo "Generated types for $(PACKAGE_JSON_VERSION) in $(BUN_TYPES_REPO_PATH)/dist"
cp $(BUN_TYPES_REPO_PATH)/dist/types.d.ts /tmp/bun-types.d.ts
cd /tmp && $(PACKAGE_DIR)/../../node_modules/.bin/tsc /tmp/bun-types.d.ts
@@ -516,12 +586,12 @@ prepare-types:
release-types:
# can be removed when/if "bun publish" is implemented
@npm --version >/dev/null 2>&1 || (echo -e "ERROR: npm is required."; exit 1)
cd $(BUN_TYPES_REPO_PATH)/dist && npm publish
cd $(BUN_TYPES_REPO_PATH)/dist && npm publish --dry-run
.PHONY: format
format: ## to format the code
$(PRETTIER) --write test/bun.js/*.js
$(PRETTIER) --write test/bun.js/solid-dom-fixtures/**/*.js
-$(PRETTIER) --write 'test/**/*.{js,jsx,ts,tsx}'
.PHONY: lolhtml
lolhtml:
@@ -530,7 +600,7 @@ lolhtml:
# no asm is not worth it!!
.PHONY: boringssl-build
boringssl-build:
cd $(BUN_DEPS_DIR)/boringssl && mkdir -p build && cd build && CFLAGS="$(CFLAGS)" cmake $(CMAKE_FLAGS) -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" -GNinja .. && ninja
cd $(BUN_DEPS_DIR)/boringssl && mkdir -p build && cd build && CFLAGS="$(CFLAGS)" cmake $(CMAKE_FLAGS) -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" -GNinja .. && ninja libcrypto.a libssl.a libdecrepit.a
.PHONY: boringssl-build-debug
boringssl-build-debug:
@@ -539,6 +609,7 @@ boringssl-build-debug:
boringssl-copy:
cp $(BUN_DEPS_DIR)/boringssl/build/ssl/libssl.a $(BUN_DEPS_OUT_DIR)/libssl.a
cp $(BUN_DEPS_DIR)/boringssl/build/crypto/libcrypto.a $(BUN_DEPS_OUT_DIR)/libcrypto.a
cp $(BUN_DEPS_DIR)/boringssl/build/decrepit/libdecrepit.a $(BUN_DEPS_OUT_DIR)/libdecrepit.a
.PHONY: boringssl
boringssl: boringssl-build boringssl-copy
@@ -547,22 +618,7 @@ boringssl-debug: boringssl-build-debug boringssl-copy
.PHONY: compile-ffi-test
compile-ffi-test:
clang $(OPTIMIZATION_LEVEL) -shared -undefined dynamic_lookup -o /tmp/bun-ffi-test.dylib -fPIC ./test/bun.js/ffi-test.c
.PHONY: libbacktrace
libbacktrace:
cd $(BUN_DEPS_DIR)/libbacktrace && \
CFLAGS="$(CFLAGS)" CC=$(CC) ./configure --disable-shared --enable-static --with-pic && \
make -j$(CPUS) && \
cp ./.libs/libbacktrace.a $(BUN_DEPS_OUT_DIR)/libbacktrace.a
.PHONY: oniguruma
oniguruma:
cd $(BUN_DEPS_DIR)/oniguruma && \
autoreconf -vfi && \
CFLAGS="$(CFLAGS)" CC=$(CC) ./configure && \
make -j${CPUS} && \
cp ./src/.libs/libonig.a $(BUN_DEPS_OUT_DIR)/libonig.a
clang $(OPTIMIZATION_LEVEL) -shared -undefined dynamic_lookup -o /tmp/bun-ffi-test.dylib -fPIC ./test/js/bun/ffi/ffi-test.c
sqlite:
@@ -573,13 +629,13 @@ libarchive:
(make clean || echo ""); \
(./build/clean.sh || echo ""); \
./build/autogen.sh; \
CFLAGS="$(CFLAGS)" CC=$(CC) ./configure --disable-shared --enable-static --with-pic --disable-bsdtar --disable-bsdcat --disable-rpath --enable-posix-regex-lib --without-xml2 --without-expat --without-openssl --without-iconv --without-zlib; \
CFLAGS="$(CFLAGS)" $(CCACHE_CC_FLAG) ./configure --disable-shared --enable-static --with-pic --disable-bsdtar --disable-bsdcat --disable-rpath --enable-posix-regex-lib --without-xml2 --without-expat --without-openssl --without-iconv --without-zlib; \
make -j${CPUS}; \
cp ./.libs/libarchive.a $(BUN_DEPS_OUT_DIR)/libarchive.a;
.PHONY: tgz
tgz:
$(ZIG) build tgz-obj -Drelease-fast
$(ZIG) build tgz-obj -Doptimize=ReleaseFast
$(CXX) $(PACKAGE_DIR)/tgz.o -g -o ./misctools/tgz $(DEFAULT_LINKER_FLAGS) -lc $(ARCHIVE_FILES)
rm -rf $(PACKAGE_DIR)/tgz.o
@@ -589,11 +645,8 @@ tgz-debug:
$(CXX) $(DEBUG_PACKAGE_DIR)/tgz.o -g -o ./misctools/tgz $(DEFAULT_LINKER_FLAGS) -lc $(ARCHIVE_FILES)
rm -rf $(DEBUG_PACKAGE_DIR)/tgz.o
vendor: require init-submodules vendor-without-check
zlib:
cd $(BUN_DEPS_DIR)/zlib; CFLAGS="$(CFLAGS)" cmake $(CMAKE_FLAGS) .; CFLAGS="$(CFLAGS)" make;
cp $(BUN_DEPS_DIR)/zlib/libz.a $(BUN_DEPS_OUT_DIR)/libz.a
cd $(BUN_DEPS_DIR)/zlib; make clean; $(CCACHE_CC_FLAG) CFLAGS="$(CFLAGS)" ./configure --static && make -j${CPUS} && cp ./libz.a $(BUN_DEPS_OUT_DIR)/libz.a
ifeq ($(POSIX_PKG_MANAGER), brew)
PKGNAME_NINJA := ninja
@@ -604,7 +657,7 @@ endif
.PHONY: require
require:
@echo "Checking if the required utilities are available..."
@if [ $(CLANG_VERSION) -lt "13" ]; then echo -e "ERROR: clang version >=13 required, found: $(CLANG_VERSION). Install with:\n\n $(POSIX_PKG_MANAGER) install llvm@13"; 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@15"; exit 1; fi
@cmake --version >/dev/null 2>&1 || (echo -e "ERROR: cmake is required."; exit 1)
@esbuild --version >/dev/null 2>&1 || (echo -e "ERROR: esbuild is required."; exit 1)
@$(NPM_CLIENT) --version >/dev/null 2>&1 || (echo -e "ERROR: NPM client (bun or npm) is required."; exit 1)
@@ -619,11 +672,11 @@ init-submodules:
.PHONY: build-obj
build-obj:
$(ZIG) build obj -Drelease-fast -Dcpu="$(CPU_TARGET)"
$(ZIG) build obj -Doptimize=ReleaseFast -Dcpu="$(CPU_TARGET)"
.PHONY: dev-build-obj-wasm
dev-build-obj-wasm:
$(ZIG) build bun-wasm -Dtarget=wasm32-freestanding --prominent-compile-errors
$(ZIG) build bun-wasm -Dtarget=wasm32-freestanding
.PHONY: dev-wasm
dev-wasm: dev-build-obj-wasm
@@ -636,7 +689,7 @@ dev-wasm: dev-build-obj-wasm
.PHONY: build-obj-wasm
build-obj-wasm:
$(ZIG) build bun-wasm -Drelease-fast -Dtarget=wasm32-freestanding --prominent-compile-errors
$(ZIG) build bun-wasm -Doptimize=ReleaseFast -Dtarget=wasm32-freestanding
emcc -sEXPORTED_FUNCTIONS="['_bun_free', '_cycleStart', '_cycleEnd', '_bun_malloc', '_scan', '_transform', '_init']" \
-g -s ERROR_ON_UNDEFINED_SYMBOLS=0 -DNDEBUG \
$(BUN_DEPS_DIR)/libmimalloc.a.wasm \
@@ -646,7 +699,7 @@ build-obj-wasm:
.PHONY: build-obj-wasm-small
build-obj-wasm-small:
$(ZIG) build bun-wasm -Drelease-small -Dtarget=wasm32-freestanding --prominent-compile-errors
$(ZIG) build bun-wasm -Doptimize=ReleaseSmall -Dtarget=wasm32-freestanding
emcc -sEXPORTED_FUNCTIONS="['_bun_free', '_cycleStart', '_cycleEnd', '_bun_malloc', '_scan', '_transform', '_init']" \
-g -s ERROR_ON_UNDEFINED_SYMBOLS=0 -DNDEBUG \
$(BUN_DEPS_DIR)/libmimalloc.a.wasm \
@@ -673,22 +726,22 @@ wasm: api build-obj-wasm-small
.PHONY: build-obj-safe
build-obj-safe:
$(ZIG) build obj -Drelease-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_CXX_FLAGS = $(UWS_CC_FLAGS) -std=$(CXX_VERSION) -fno-exceptions
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_DEPS_DIR)/uws/uSockets/
USOCKETS_SRC_DIR = $(BUN_DEPS_DIR)/uws/uSockets/src/
usockets:
rm -rf $(BUN_DEPS_DIR)/uws/uSockets/*.o $(BUN_DEPS_DIR)/uws/uSockets/**/*.o $(BUN_DEPS_DIR)/uws/uSockets/*.a $(BUN_DEPS_DIR)/uws/uSockets/*.bc
cd $(USOCKETS_DIR) && $(CC) -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) -g -c $(wildcard $(USOCKETS_SRC_DIR)/*.c) $(wildcard $(USOCKETS_SRC_DIR)/**/*.c)
cd $(USOCKETS_DIR) && $(CXX) -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) -g -c $(wildcard $(USOCKETS_SRC_DIR)/*.cpp) $(wildcard $(USOCKETS_SRC_DIR)/**/*.cpp)
cd $(USOCKETS_DIR) && $(CC_WITH_CCACHE) -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) -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}
uws: usockets
$(CXX) $(BITCODE_OR_SECTIONS) $(EMIT_LLVM_FOR_RELEASE) -fPIC -I$(BUN_DEPS_DIR)/uws/uSockets/src $(CLANG_FLAGS) $(CFLAGS) $(UWS_CXX_FLAGS) $(UWS_LDFLAGS) $(PLATFORM_LINKER_FLAGS) -c -I$(BUN_DEPS_DIR) $(BUN_DEPS_OUT_DIR)/libusockets.a $(BUN_DEPS_DIR)/libuwsockets.cpp -o $(BUN_DEPS_OUT_DIR)/libuwsockets.o
$(CXX_WITH_CCACHE) -O2 $(EMIT_LLVM_FOR_RELEASE) -fPIC -I$(BUN_DEPS_DIR)/uws/uSockets/src $(CLANG_FLAGS) $(CFLAGS) $(UWS_CXX_FLAGS) $(UWS_LDFLAGS) $(PLATFORM_LINKER_FLAGS) -c -I$(BUN_DEPS_DIR) $(BUN_DEPS_OUT_DIR)/libusockets.a $(BUN_DEPS_DIR)/libuwsockets.cpp -o $(BUN_DEPS_OUT_DIR)/libuwsockets.o
.PHONY: sign-macos-x64
sign-macos-x64:
@@ -738,8 +791,7 @@ 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) --write src/api/schema.js
$(PRETTIER) --write src/api/schema.d.ts
$(PRETTIER) --config=.prettierrc.cjs --write src/api/schema.js src/api/schema.d.ts
.PHONY: node-fallbacks
node-fallbacks:
@@ -775,14 +827,14 @@ generate-install-script:
.PHONY: fetch
fetch: $(IO_FILES)
$(ZIG) build -Drelease-fast fetch-obj
$(ZIG) build -Doptimize=ReleaseFast fetch-obj
$(CXX) $(PACKAGE_DIR)/fetch.o -g $(OPTIMIZATION_LEVEL) -o ./misctools/fetch $(IO_FILES) $(DEFAULT_LINKER_FLAGS) -lc $(MINIMUM_ARCHIVE_FILES)
rm -rf $(PACKAGE_DIR)/fetch.o
.PHONY: sha
sha:
$(ZIG) build -Drelease-fast sha-bench-obj
$(CXX) $(PACKAGE_DIR)/sha.o -g $(OPTIMIZATION_LEVEL) -o ./misctools/sha $(DEFAULT_LINKER_FLAGS) -lc $(MINIMUM_ARCHIVE_FILES)
$(ZIG) build -Doptimize=ReleaseFast sha-bench-obj
$(CXX) $(PACKAGE_DIR)/sha.o -I$(BUN_DEPS_DIR) -g $(OPTIMIZATION_LEVEL) -o ./misctools/sha $(DEFAULT_LINKER_FLAGS) -lc $(MINIMUM_ARCHIVE_FILES)
rm -rf $(PACKAGE_DIR)/sha.o
.PHONY: fetch-debug
@@ -797,7 +849,7 @@ machbench-debug: $(IO_FILES)
.PHONY: machbench
machbench: $(IO_FILES)
$(ZIG) build -Drelease-fast machbench-obj
$(ZIG) build -Doptimize=ReleaseFast machbench-obj
$(CXX) $(PACKAGE_DIR)/machbench.o -g $(OPTIMIZATION_LEVEL) -o ./misctools/machbench $(IO_FILES) $(DEFAULT_LINKER_FLAGS) -lc $(MINIMUM_ARCHIVE_FILES)
rm -rf $(PACKAGE_DIR)/machbench.o
@@ -809,7 +861,7 @@ httpbench-debug: $(IO_FILES)
.PHONY: httpbench-release
httpbench-release: $(IO_FILES)
$(ZIG) build -Drelease-fast httpbench-obj
$(ZIG) build -Doptimize=ReleaseFast httpbench-obj
$(CXX) $(PACKAGE_DIR)/httpbench.o -g $(OPTIMIZATION_LEVEL) -o ./misctools/httpbench $(IO_FILES) $(DEFAULT_LINKER_FLAGS) -lc $(MINIMUM_ARCHIVE_FILES)
rm -rf $(PACKAGE_DIR)/httpbench.o
@@ -854,7 +906,7 @@ clone-submodules:
git -c submodule."src/bun.js/WebKit".update=none submodule update --init --recursive --depth=1 --progress
.PHONY: devcontainer
devcontainer: $(OBJ_DIR) $(DEBUG_OBJ_DIR) clone-submodules libbacktrace mimalloc zlib libarchive boringssl picohttp identifier-cache node-fallbacks npm-install api analytics bun_error fallback_decoder bindings uws lolhtml usockets base64 tinycc runtime_js_dev sqlite oniguruma webcrypto-debug webcrypto
devcontainer: $(OBJ_DIR) $(DEBUG_OBJ_DIR) clone-submodules mimalloc zlib libarchive boringssl picohttp identifier-cache node-fallbacks npm-install api analytics bun_error fallback_decoder bindings uws lolhtml usockets tinycc c-ares runtime_js_dev sqlite webcrypto-debug webcrypto
.PHONY: devcontainer-build
devcontainer-build:
@@ -879,7 +931,7 @@ headers:
rm -f /tmp/build-jsc-headers src/bun.js/bindings/headers.zig
touch src/bun.js/bindings/headers.zig
$(ZIG) build headers-obj
$(CXX) $(PLATFORM_LINKER_FLAGS) $(JSC_FILES_DEBUG) ${ICU_FLAGS} $(DEBUG_IO_FILES) $(BUN_LLD_FLAGS_WITHOUT_JSC) -g $(DEBUG_BIN)/headers.o -W -o /tmp/build-jsc-headers -lc;
$(CXX) $(PLATFORM_LINKER_FLAGS) $(JSC_FILES_DEBUG) ${ICU_FLAGS} $(BUN_LLD_FLAGS_WITHOUT_JSC) -g $(DEBUG_BIN)/headers.o -W -o /tmp/build-jsc-headers -lc;
/tmp/build-jsc-headers
$(ZIG) translate-c src/bun.js/bindings/headers.h > src/bun.js/bindings/headers.zig
$(BUN_OR_NODE) misctools/headers-cleaner.js
@@ -892,7 +944,7 @@ MIMALLOC_OVERRIDE_FLAG ?=
bump:
expr 0.2.0 + 1 > build-id
expr 0.4.0 + 1 > build-id
.PHONY: identifier-cache
identifier-cache:
@@ -1030,57 +1082,20 @@ release-bin-dir:
.PHONY: dev-obj
dev-obj:
$(ZIG) build obj --prominent-compile-errors
$(ZIG) build obj -freference-trace -Dcpu="$(CPU_TARGET)"
.PHONY: dev-obj-linux
dev-obj-linux:
$(ZIG) build obj -Dtarget=x86_64-linux-gnu
$(ZIG) build obj -Dtarget=x86_64-linux-gnu -Dcpu="$(CPU_TARGET)"
.PHONY: dev
dev: mkdir-dev dev-obj bun-link-lld-debug bun-codesign-debug
dev: mkdir-dev dev-obj bun-link-lld-debug
mkdir-dev:
mkdir -p $(DEBUG_PACKAGE_DIR)/bin
test-install:
cd test/scripts && $(NPM_CLIENT) install
.PHONY: test-bun-dev
test-bun-dev:
BUN_BIN=$(RELEASE_BUN) bash test/apps/bun-dev.sh
BUN_BIN=$(RELEASE_BUN) bash test/apps/bun-dev-index-html.sh
.PHONY: test-dev-bun-dev
test-dev-bun-dev:
BUN_BIN=$(DEBUG_BUN) bash test/apps/bun-dev.sh
BUN_BIN=$(DEBUG_BUN) bash test/apps/bun-dev-index-html.sh
.PHONY: test-bun-snapshot
test-bun-snapshot:
rm -rf test/bun.js/snapshots.js
touch test/bun.js/snapshots.js
$(foreach i,$(wildcard test/bun.js/*.snapshot.*),echo "" >> test/bun.js/snapshots.js; echo "// $i" >> test/bun.js/snapshots.js; $(RELEASE_BUN) build $i --platform=bun >> test/bun.js/snapshots.js;)
.PHONY: test-dev-bun-snapshot
test-dev-bun-snapshot:
rm -rf test/bun.js/snapshots.debug.js
touch test/bun.js/snapshots.debug.js
$(foreach i,$(wildcard test/bun.js/*.snapshot.*),echo "" >> test/bun.js/snapshots.debug.js; echo "// $i" >> test/bun.js/snapshots.debug.js; $(DEBUG_BUN) build $i --platform=bun >> test/bun.js/snapshots.debug.js;)
.PHONY: test-bun-init
test-bun-init:
BUN_BIN=$(RELEASE_BUN) bash test/apps/bun-init-check.sh
.PHONY: test-dev-bun-init
test-dev-bun-init:
BUN_BIN=$(DEBUG_BUN) bash test/apps/bun-init-check.sh
.PHONY: test-bun-wiptest
test-bun-wiptest: test/wiptest/run
cd test/wiptest && BUN_BIN=$(DEBUG_BUN) ./run ./fixtures
.PHONY: test-all
test-all: test-install test-bun-snapshot test-with-hmr test-no-hmr test-create-next test-create-react test-bun-run test-bun-install test-bun-dev test-bun-init
test-all:
$(RELEASE_BUN) test
.PHONY: copy-test-node-modules
copy-test-node-modules:
@@ -1091,73 +1106,6 @@ copy-test-node-modules:
kill-bun:
-killall -9 bun bun-debug
.PHONY: test-dev-create-next
test-dev-create-next:
BUN_BIN=$(DEBUG_BUN) bash test/apps/bun-create-next.sh
.PHONY: test-dev-create-react
test-dev-create-react:
BUN_BIN=$(DEBUG_BUN) bash test/apps/bun-create-react.sh
.PHONY: test-create-next
test-create-next:
BUN_BIN=$(RELEASE_BUN) bash test/apps/bun-create-next.sh
.PHONY: test-bun-run
test-bun-run:
cd test/apps && BUN_BIN=$(RELEASE_BUN) bash ./bun-run-check.sh
.PHONY: test-bun-install
test-bun-install: test-bun-install-git-status
cd test/apps && JS_RUNTIME=$(RELEASE_BUN) NPM_CLIENT=$(RELEASE_BUN) bash ./bun-install.sh
cd test/apps && BUN_BIN=$(RELEASE_BUN) bash ./bun-install-utf8.sh
.PHONY: test-bun-install-git-status
test-bun-install-git-status:
cd test/apps && JS_RUNTIME=$(RELEASE_BUN) BUN_BIN=$(RELEASE_BUN) bash ./bun-install-lockfile-status.sh
.PHONY: test-dev-bun-install
test-dev-bun-install: test-dev-bun-install-git-status
cd test/apps && JS_RUNTIME=$(DEBUG_BUN) NPM_CLIENT=$(DEBUG_BUN) bash ./bun-install.sh
cd test/apps && BUN_BIN=$(DEBUG_BUN) bash ./bun-install-utf8.sh
.PHONY: test-dev-bun-install-git-status
test-dev-bun-install-git-status:
cd test/apps && BUN_BIN=$(DEBUG_BUN) bash ./bun-install-lockfile-status.sh
.PHONY: test-create-react
test-create-react:
BUN_BIN=$(RELEASE_BUN) bash test/apps/bun-create-react.sh
.PHONY: test-with-hmr
test-with-hmr: kill-bun copy-test-node-modules
BUN_BIN=$(RELEASE_BUN) node test/scripts/browser.js
.PHONY: test-no-hmr
test-no-hmr: kill-bun copy-test-node-modules
-killall bun -9;
DISABLE_HMR="DISABLE_HMR" BUN_BIN=$(RELEASE_BUN) node test/scripts/browser.js
.PHONY: test-dev-with-hmr
test-dev-with-hmr: copy-test-node-modules
-killall bun-debug -9;
BUN_BIN=$(DEBUG_BUN) node test/scripts/browser.js
.PHONY: test-dev-no-hmr
test-dev-no-hmr: copy-test-node-modules
-killall bun-debug -9;
DISABLE_HMR="DISABLE_HMR" BUN_BIN=$(DEBUG_BUN) node test/scripts/browser.js
.PHONY: test-dev-bun-hmr
test-dev-bun-run:
cd test/apps && BUN_BIN=$(DEBUG_BUN) bash bun-run-check.sh
.PHONY: test-dev-all
test-dev-all: test-install test-dev-bun-snapshot test-dev-with-hmr test-dev-no-hmr test-dev-create-next test-dev-create-react test-dev-bun-run test-dev-bun-install test-dev-bun-dev test-dev-bun-init
test-dev-bunjs:
test-dev: test-dev-with-hmr
jsc-copy-headers:
cp $(WEBKIT_DIR)/Source/JavaScriptCore/heap/WeakHandleOwner.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/WeakHandleOwner.h
cp $(WEBKIT_DIR)/Source/JavaScriptCore/runtime/LazyClassStructureInlines.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/LazyClassStructureInlines.h
@@ -1200,6 +1148,11 @@ jsc-copy-headers:
cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/OperandsInlines.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/OperandsInlines.h
cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/Operands.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/Operands.h
cp $(WEBKIT_DIR)/Source/JavaScriptCore/domjit/DOMJITHeapRange.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/DOMJITHeapRange.h
cp $(WEBKIT_DIR)/Source/JavaScriptCore/runtime/GeneratorPrototype.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/GeneratorPrototype.h
cp $(WEBKIT_DIR)/Source/JavaScriptCore/runtime/GeneratorFunctionPrototype.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/GeneratorFunctionPrototype.h
cp $(WEBKIT_DIR)/Source/JavaScriptCore/runtime/AsyncFunctionPrototype.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/AsyncFunctionPrototype.h
cp $(WEBKIT_DIR)/Source/JavaScriptCore/runtime/SymbolObject.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/SymbolObject.h
cp $(WEBKIT_DIR)/Source/JavaScriptCore/runtime/JSGenerator.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JSGenerator.h
find $(WEBKIT_RELEASE_DIR)/JavaScriptCore/Headers/JavaScriptCore/ -name "*.h" -exec cp {} $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/ \;
# This is a workaround for a JSC bug that impacts aarch64
@@ -1221,6 +1174,7 @@ jsc-build-mac-compile:
-DENABLE_SINGLE_THREADED_VM_ENTRY_SCOPE=ON \
-DCMAKE_BUILD_TYPE=relwithdebuginfo \
-DUSE_THIN_ARCHIVES=OFF \
-DBUN_FAST_TLS=ON \
-DENABLE_FTL_JIT=ON \
-G Ninja \
$(CMAKE_FLAGS_WITHOUT_RELEASE) \
@@ -1228,7 +1182,7 @@ jsc-build-mac-compile:
-DUSE_PTHREAD_JIT_PERMISSIONS_API=ON \
$(WEBKIT_DIR) \
$(WEBKIT_RELEASE_DIR) && \
CFLAGS="$(CFLAGS) $(BITCODE_OR_SECTIONS) -ffat-lto-objects" CXXFLAGS="$(CXXFLAGS) $(BITCODE_OR_SECTIONS) -ffat-lto-objects" \
CFLAGS="$(CFLAGS) -ffat-lto-objects" CXXFLAGS="$(CXXFLAGS) -ffat-lto-objects" \
cmake --build $(WEBKIT_RELEASE_DIR) --config Release --target jsc
.PHONY: jsc-build-mac-compile-lto
@@ -1242,6 +1196,7 @@ jsc-build-mac-compile-lto:
-DENABLE_SINGLE_THREADED_VM_ENTRY_SCOPE=ON \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_THIN_ARCHIVES=OFF \
-DBUN_FAST_TLS=ON \
-DCMAKE_C_FLAGS="-flto=full" \
-DCMAKE_CXX_FLAGS="-flto=full" \
-DENABLE_FTL_JIT=ON \
@@ -1330,6 +1285,7 @@ clean: clean-bindings
(cd $(BUN_DEPS_DIR)/boringssl && make clean) || echo "";
(cd $(BUN_DEPS_DIR)/picohttp && make clean) || echo "";
(cd $(BUN_DEPS_DIR)/zlib && make clean) || echo "";
(cd $(BUN_DEPS_DIR)/c-ares && rm -rf build && make clean) || echo "";
.PHONY: release-bindings
release-bindings: $(OBJ_DIR) $(OBJ_FILES) $(WEBCORE_OBJ_FILES) $(SQLITE_OBJ_FILES) $(NODE_OS_OBJ_FILES) $(BUILTINS_OBJ_FILES) $(IO_FILES) $(MODULES_OBJ_FILES)
@@ -1342,10 +1298,19 @@ bindings: $(DEBUG_OBJ_DIR) $(DEBUG_OBJ_FILES) $(DEBUG_WEBCORE_OBJ_FILES) $(DEBUG
.PHONY: jsc-bindings-mac
jsc-bindings-mac: bindings
# lInux only
MIMALLOC_VALGRIND_ENABLED_FLAG =
ifeq ($(OS_NAME),linux)
MIMALLOC_VALGRIND_ENABLED_FLAG = -DMI_VALGRIND=ON
endif
.PHONY: mimalloc-debug
mimalloc-debug:
rm -rf $(BUN_DEPS_DIR)/mimalloc/CMakeCache* $(BUN_DEPS_DIR)/mimalloc/CMakeFiles
cd $(BUN_DEPS_DIR)/mimalloc; make clean || echo ""; \
CFLAGS="$(CFLAGS)" cmake $(CMAKE_FLAGS_WITHOUT_RELEASE) ${MIMALLOC_OVERRIDE_FLAG} \
CFLAGS="$(CFLAGS)" cmake $(CMAKE_FLAGS_WITHOUT_RELEASE) ${MIMALLOC_OVERRIDE_FLAG} ${MIMALLOC_VALGRIND_ENABLED_FLAG} \
-DCMAKE_BUILD_TYPE=Debug \
-DMI_DEBUG_FULL=1 \
-DMI_SKIP_COLLECT_ON_EXIT=1 \
@@ -1397,6 +1362,7 @@ bun-link-lld-debug:
$(DEBUG_BIN)/bun-debug.o \
-W \
-o $(DEBUG_BIN)/bun-debug
@rm -f $(DEBUG_BIN)/bun-debug.o.o 2> /dev/null # workaround for https://github.com/ziglang/zig/issues/14080
bun-link-lld-debug-no-jsc:
$(CXX) $(BUN_LLD_FLAGS_WITHOUT_JSC) $(SYMBOLS) \
@@ -1425,6 +1391,7 @@ bun-link-lld-release:
$(OPTIMIZATION_LEVEL) $(RELEASE_FLAGS)
rm -rf $(BUN_RELEASE_BIN).dSYM
cp $(BUN_RELEASE_BIN) $(BUN_RELEASE_BIN)-profile
@rm -f $(BUN_RELEASE_BIN).o.o # workaround for https://github.com/ziglang/zig/issues/14080
bun-release-copy-obj:
cp $(BUN_RELEASE_BIN).o $(BUN_DEPLOY_DIR).o
@@ -1466,9 +1433,11 @@ wasm-return1:
generate-classes:
bun src/bun.js/scripts/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
clang-format -i src/bun.js/bindings/JSSink.cpp src/bun.js/bindings/JSSink.h
$(WEBKIT_DIR)/Source/JavaScriptCore/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
$(SED) -i -e 's/namespace JSC {//' src/bun.js/bindings/JSSinkLookupTable.h
@@ -1489,7 +1458,7 @@ $(DEBUG_OBJ_DIR):
mkdir -p $(DEBUG_OBJ_DIR)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
$(CXX) $(CLANG_FLAGS) $(UWS_INCLUDE) \
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) $(UWS_INCLUDE) \
$(MACOS_MIN_FLAG) \
$(OPTIMIZATION_LEVEL) \
-fno-exceptions \
@@ -1499,7 +1468,7 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
-c -o $@ $<
$(OBJ_DIR)/%.o: src/bun.js/modules/%.cpp
$(CXX) $(CLANG_FLAGS) $(UWS_INCLUDE) \
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) $(UWS_INCLUDE) \
$(MACOS_MIN_FLAG) \
$(OPTIMIZATION_LEVEL) \
-fno-exceptions \
@@ -1509,7 +1478,7 @@ $(OBJ_DIR)/%.o: src/bun.js/modules/%.cpp
-c -o $@ $<
$(OBJ_DIR)/%.o: $(SRC_DIR)/webcore/%.cpp
$(CXX) $(CLANG_FLAGS) \
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(OPTIMIZATION_LEVEL) \
-fno-exceptions \
@@ -1519,7 +1488,7 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/webcore/%.cpp
-c -o $@ $<
$(OBJ_DIR)/%.o: $(SRC_DIR)/sqlite/%.cpp
$(CXX) $(CLANG_FLAGS) \
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(OPTIMIZATION_LEVEL) \
-fno-exceptions \
@@ -1529,7 +1498,7 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/sqlite/%.cpp
-c -o $@ $<
$(OBJ_DIR)/%.o: src/io/%.cpp
$(CXX) $(CLANG_FLAGS) \
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(OPTIMIZATION_LEVEL) \
-fno-exceptions \
@@ -1539,7 +1508,7 @@ $(OBJ_DIR)/%.o: src/io/%.cpp
-c -o $@ $<
$(OBJ_DIR)/%.o: $(SRC_DIR)/node_os/%.cpp
$(CXX) $(CLANG_FLAGS) \
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(OPTIMIZATION_LEVEL) \
-fno-exceptions \
@@ -1549,7 +1518,7 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/node_os/%.cpp
-c -o $@ $<
$(OBJ_DIR)/%.o: src/bun.js/builtins/%.cpp
$(CXX) $(CLANG_FLAGS) \
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(OPTIMIZATION_LEVEL) \
-fno-exceptions \
@@ -1560,89 +1529,103 @@ $(OBJ_DIR)/%.o: src/bun.js/builtins/%.cpp
# $(DEBUG_OBJ_DIR) is not included here because it breaks
# detecting if a file needs to be rebuilt
.PHONY: $(SRC_DIR)/%.cpp
$(DEBUG_OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
$(CXX) $(CLANG_FLAGS) $(UWS_INCLUDE) \
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) $(UWS_INCLUDE) \
$(MACOS_MIN_FLAG) \
$(DEBUG_OPTIMIZATION_LEVEL) \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
-DBUN_DEBUG \
$(EMIT_LLVM_FOR_DEBUG) \
-g3 -c -o $@ $<
# $(DEBUG_OBJ_DIR) is not included here because it breaks
# detecting if a file needs to be rebuilt
.PHONY: $(SRC_DIR)/webcore/%.cpp
$(DEBUG_OBJ_DIR)/%.o: $(SRC_DIR)/webcore/%.cpp
$(CXX) $(CLANG_FLAGS) \
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(DEBUG_OPTIMIZATION_LEVEL) \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
$(EMIT_LLVM_FOR_DEBUG) \
-DBUN_DEBUG \
-g3 -c -o $@ $<
.PHONY: src/io/%.cpp
$(DEBUG_OBJ_DIR)/%.o: src/io/%.cpp
$(CXX) $(CLANG_FLAGS) \
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(DEBUG_OPTIMIZATION_LEVEL) \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
-DBUN_DEBUG \
$(EMIT_LLVM_FOR_DEBUG) \
-g3 -c -o $@ $<
# $(DEBUG_OBJ_DIR) is not included here because it breaks
# detecting if a file needs to be rebuilt
.PHONY: $(SRC_DIR)/sqlite/%.cpp
$(DEBUG_OBJ_DIR)/%.o: $(SRC_DIR)/sqlite/%.cpp
$(CXX) $(CLANG_FLAGS) \
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(DEBUG_OPTIMIZATION_LEVEL) \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
$(EMIT_LLVM_FOR_DEBUG) \
-DBUN_DEBUG \
-g3 -c -o $@ $<
# $(DEBUG_OBJ_DIR) is not included here because it breaks
# detecting if a file needs to be rebuilt
.PHONY: $(SRC_DIR)/node_os/%.cpp
$(DEBUG_OBJ_DIR)/%.o: $(SRC_DIR)/node_os/%.cpp
$(CXX) $(CLANG_FLAGS) \
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(DEBUG_OPTIMIZATION_LEVEL) \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
$(EMIT_LLVM_FOR_DEBUG) \
-DBUN_DEBUG \
-g3 -c -o $@ $<
# $(DEBUG_OBJ_DIR) is not included here because it breaks
# detecting if a file needs to be rebuilt
.PHONY: src/bun.js/builtins/%.cpp
$(DEBUG_OBJ_DIR)/%.o: src/bun.js/builtins/%.cpp
$(CXX) $(CLANG_FLAGS) \
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(DEBUG_OPTIMIZATION_LEVEL) \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
$(EMIT_LLVM_FOR_DEBUG) \
-DBUN_DEBUG \
-g3 -c -o $@ $<
.PHONY: src/bun.js/modules/%.cpp
$(DEBUG_OBJ_DIR)/%.o: src/bun.js/modules/%.cpp
$(CXX) $(CLANG_FLAGS) \
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(DEBUG_OPTIMIZATION_LEVEL) \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
$(EMIT_LLVM_FOR_DEBUG) \
-DBUN_DEBUG \
-g3 -c -o $@ $<
$(DEBUG_OBJ_DIR)/webcrypto/%.o: src/bun.js/bindings/webcrypto/%.cpp
$(CXX) $(CLANG_FLAGS) \
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(DEBUG_OPTIMIZATION_LEVEL) \
-fno-exceptions \
@@ -1650,9 +1633,12 @@ $(DEBUG_OBJ_DIR)/webcrypto/%.o: src/bun.js/bindings/webcrypto/%.cpp
-fno-rtti \
-ferror-limit=1000 \
$(EMIT_LLVM_FOR_DEBUG) \
-DBUN_DEBUG \
-g3 -c -o $@ $<
.PHONY: webcrypto-debug-obj
# Make all the .cpp files in the webcrypto directory into .o files using Makefile substitutions
webcrypto-debug-obj: $(patsubst src/bun.js/bindings/webcrypto/%.cpp, $(DEBUG_OBJ_DIR)/webcrypto/%.o, $(wildcard src/bun.js/bindings/webcrypto/*.cpp))
@@ -1666,7 +1652,7 @@ webcrypto-debug:
$(OBJ_DIR)/webcrypto/%.o: src/bun.js/bindings/webcrypto/%.cpp
$(CXX) $(CLANG_FLAGS) \
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(OPTIMIZATION_LEVEL) \
-fno-exceptions \
@@ -1689,7 +1675,7 @@ webcrypto:
sizegen:
mkdir -p $(BUN_TMP_DIR)
$(CXX) src/bun.js/headergen/sizegen.cpp -Wl,-dead_strip -Wl,-dead_strip_dylibs -fuse-ld=lld -o $(BUN_TMP_DIR)/sizegen $(CLANG_FLAGS) -O1
$(CXX) src/bun.js/headergen/sizegen.cpp -Wl,-dead_strip -Wl,-dead_strip_dylibs -fuse-ld=lld -o $(BUN_TMP_DIR)/sizegen $(CLANG_FLAGS) -O1
$(BUN_TMP_DIR)/sizegen > src/bun.js/bindings/sizes.zig
@@ -1850,7 +1836,14 @@ copy-to-bun-release-dir-bin:
cp -r $(PACKAGE_DIR)/bun $(BUN_RELEASE_DIR)/bun
cp -r $(PACKAGE_DIR)/bun-profile $(BUN_RELEASE_DIR)/bun-profile
PACKAGE_MAP = --pkg-begin thread_pool $(BUN_DIR)/src/thread_pool.zig --pkg-begin io $(BUN_DIR)/src/io/io_$(OS_NAME).zig --pkg-end --pkg-begin http $(BUN_DIR)/src/http_client_async.zig --pkg-begin strings $(BUN_DIR)/src/string_immutable.zig --pkg-end --pkg-begin picohttp $(BUN_DIR)/src/deps/picohttp.zig --pkg-end --pkg-begin io $(BUN_DIR)/src/io/io_darwin.zig --pkg-end --pkg-begin boringssl $(BUN_DIR)/src/boringssl.zig --pkg-end --pkg-begin thread_pool $(BUN_DIR)/src/thread_pool.zig --pkg-begin io $(BUN_DIR)/src/io/io_darwin.zig --pkg-end --pkg-begin http $(BUN_DIR)/src/http_client_async.zig --pkg-begin strings $(BUN_DIR)/src/string_immutable.zig --pkg-end --pkg-begin picohttp $(BUN_DIR)/src/deps/picohttp.zig --pkg-end --pkg-begin io $(BUN_DIR)/src/io/io_darwin.zig --pkg-end --pkg-begin boringssl $(BUN_DIR)/src/boringssl.zig --pkg-end --pkg-begin thread_pool $(BUN_DIR)/src/thread_pool.zig --pkg-end --pkg-end --pkg-end --pkg-end --pkg-end --pkg-begin picohttp $(BUN_DIR)/src/deps/picohttp.zig --pkg-end --pkg-begin io $(BUN_DIR)/src/io/io_darwin.zig --pkg-end --pkg-begin strings $(BUN_DIR)/src/string_immutable.zig --pkg-end --pkg-begin clap $(BUN_DIR)/src/deps/zig-clap/clap.zig --pkg-end --pkg-begin http $(BUN_DIR)/src/http_client_async.zig --pkg-begin strings $(BUN_DIR)/src/string_immutable.zig --pkg-end --pkg-begin picohttp $(BUN_DIR)/src/deps/picohttp.zig --pkg-end --pkg-begin io $(BUN_DIR)/src/io/io_darwin.zig --pkg-end --pkg-begin boringssl $(BUN_DIR)/src/boringssl.zig --pkg-end --pkg-begin thread_pool $(BUN_DIR)/src/thread_pool.zig --pkg-begin io $(BUN_DIR)/src/io/io_darwin.zig --pkg-end --pkg-begin http $(BUN_DIR)/src/http_client_async.zig --pkg-begin strings $(BUN_DIR)/src/string_immutable.zig --pkg-end --pkg-begin picohttp $(BUN_DIR)/src/deps/picohttp.zig --pkg-end --pkg-begin io $(BUN_DIR)/src/io/io_darwin.zig --pkg-end --pkg-begin boringssl $(BUN_DIR)/src/boringssl.zig --pkg-end --pkg-begin thread_pool $(BUN_DIR)/src/thread_pool.zig --pkg-end --pkg-end --pkg-end --pkg-end --pkg-begin boringssl $(BUN_DIR)/src/boringssl.zig --pkg-end --pkg-begin javascript_core $(BUN_DIR)/src/jsc.zig --pkg-begin http $(BUN_DIR)/src/http_client_async.zig --pkg-end --pkg-begin strings $(BUN_DIR)/src/string_immutable.zig --pkg-end --pkg-begin picohttp $(BUN_DIR)/src/deps/picohttp.zig --pkg-end --pkg-end
PACKAGE_MAP = --pkg-begin async_io $(BUN_DIR)/src/io/io_darwin.zig --pkg-begin bun $(BUN_DIR)/src/bun_redirect.zig --pkg-end --pkg-end --pkg-begin javascript_core $(BUN_DIR)/src/jsc.zig --pkg-begin bun $(BUN_DIR)/src/bun_redirect.zig --pkg-end --pkg-end --pkg-begin bun $(BUN_DIR)/src/bun_redirect.zig --pkg-end
.PHONY: vendor-without-check
vendor-without-check: npm-install node-fallbacks runtime_js fallback_decoder bun_error mimalloc picohttp zlib boringssl libarchive lolhtml sqlite usockets uws tinycc c-ares
.PHONY: vendor
vendor: require init-submodules vendor-without-check
.PHONY: bun
bun: vendor identifier-cache build-obj bun-link-lld-release bun-codesign-release-local

4731
README.md

File diff suppressed because it is too large Load Diff

BIN
bench/bun.lockb Executable file

Binary file not shown.

View File

@@ -6,7 +6,4 @@ const arg = process.argv.slice(1);
// TODO: remove Buffer.from() when readFileSync() returns Buffer
for (let i = 0; i < count; i++)
console.log(
arg.map((file) => Buffer.from(readFileSync(file, "utf8"))).join("")
);
for (let i = 0; i < count; i++) console.log(arg.map(file => Buffer.from(readFileSync(file, "utf8"))).join(""));

View File

@@ -7,14 +7,8 @@ function runner(ready) {
for (let i = 0; i < size; i++) {
rand[i] = (Math.random() * 1024 * 1024) | 0;
}
const dest = `/tmp/fs-test-copy-file-${(
(Math.random() * 10000000 + 100) |
0
).toString(32)}`;
const src = `/tmp/fs-test-copy-file-${(
(Math.random() * 10000000 + 100) |
0
).toString(32)}`;
const dest = `/tmp/fs-test-copy-file-${((Math.random() * 10000000 + 100) | 0).toString(32)}`;
const src = `/tmp/fs-test-copy-file-${((Math.random() * 10000000 + 100) | 0).toString(32)}`;
writeFileSync(src, Buffer.from(rand.buffer), { encoding: "buffer" });
const { size: fileSize } = statSync(src);
if (fileSize !== rand.byteLength) {
@@ -35,6 +29,6 @@ runner((src, dest, rand) =>
// );
// }
// }
})
}),
);
await run();

View File

@@ -0,0 +1,43 @@
# expect-to-equal
To install dependencies:
```bash
bun install
```
To run in Bun:
```bash
# so it doesn't run the vitest one
bun wiptest expect-to-equal.test.js
```
To run in Jest:
```bash
# If you remove the import the performance doesn't change much
NODE_OPTIONS="--experimental-vm-modules" ./node_modules/.bin/jest expect-to-equal.test.js
```
To run in Vitest:
```bash
./node_modules/.bin/vitest --run expect-to-equal.vitest.test.js
```
Output on my machine (M1):
bun:test (bun v0.3.0):
> [36.40ms] expect().toEqual() x 10000
jest (node v18.11.0)
> expect().toEqual() x 10000: 5053 ms
vitest (node v18.11.0)
> expect().toEqual() x 10000: 401.08ms
This project was created using `bun init` in bun v0.3.0. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.

BIN
bench/expect-to-equal/bun.lockb Executable file

Binary file not shown.

View File

@@ -0,0 +1,42 @@
// bun:test automatically rewrites this import to bun:test when run in bun
import { test, expect } from "@jest/globals";
const N = parseInt(process.env.RUN_COUNT || "10000", 10);
if (!Number.isSafeInteger(N)) {
throw new Error("Invalid RUN_COUNT");
}
const label = "expect().toEqual() x " + N;
test(label, () => {
console.time(label);
for (let runsLeft = N; runsLeft > 0; runsLeft--) {
expect("hello").toEqual("hello");
expect(123).toEqual(123);
expect({ a: 1, b: 2 }).toEqual({ b: 2, a: 1 });
expect([1, 2, 3]).toEqual([1, 2, 3]);
expect({ a: 1, b: 2 }).not.toEqual({ b: 2, a: 1, c: 3 });
expect([1, 2, 3]).not.toEqual([1, 2, 3, 4]);
expect({ a: 1, b: 2, c: 3 }).not.toEqual({ a: 1, b: 2 });
expect([1, 2, 3, 4]).not.toEqual([1, 2, 3]);
let a = [{ a: 1 }, { b: 2, c: 3, d: 4 }, { e: 5, f: 6 }];
let b = [{ a: 1 }, { b: 2, c: 3, d: 4 }, { e: 5, f: 6 }];
expect(a).toEqual(b);
expect(b).toEqual(a);
a[0].a = 2;
expect(a).not.toEqual(b);
expect(b).not.toEqual(a);
let c = { [Symbol("test")]: 1 };
let d = { [Symbol("test")]: 1 };
expect(c).not.toEqual(d);
expect(d).not.toEqual(c);
a = { a: 1, b: 2, c: 3 };
b = { a: 1, b: 2 };
expect(a).not.toEqual(b);
}
console.timeEnd(label);
});

View File

@@ -0,0 +1,41 @@
import { test, expect } from "vitest";
const N = parseInt(process.env.RUN_COUNT || "10000", 10);
if (!Number.isSafeInteger(N)) {
throw new Error("Invalid RUN_COUNT");
}
const label = "expect().toEqual() x " + N;
test(label, () => {
console.time(label);
for (let runsLeft = N; runsLeft > 0; runsLeft--) {
expect("hello").toEqual("hello");
expect(123).toEqual(123);
expect({ a: 1, b: 2 }).toEqual({ b: 2, a: 1 });
expect([1, 2, 3]).toEqual([1, 2, 3]);
expect({ a: 1, b: 2 }).not.toEqual({ b: 2, a: 1, c: 3 });
expect([1, 2, 3]).not.toEqual([1, 2, 3, 4]);
expect({ a: 1, b: 2, c: 3 }).not.toEqual({ a: 1, b: 2 });
expect([1, 2, 3, 4]).not.toEqual([1, 2, 3]);
let a = [{ a: 1 }, { b: 2, c: 3, d: 4 }, { e: 5, f: 6 }];
let b = [{ a: 1 }, { b: 2, c: 3, d: 4 }, { e: 5, f: 6 }];
expect(a).toEqual(b);
expect(b).toEqual(a);
a[0].a = 2;
expect(a).not.toEqual(b);
expect(b).not.toEqual(a);
let c = { [Symbol("test")]: 1 };
let d = { [Symbol("test")]: 1 };
expect(c).not.toEqual(d);
expect(d).not.toEqual(c);
a = { a: 1, b: 2, c: 3 };
b = { a: 1, b: 2 };
expect(a).not.toEqual(b);
}
console.timeEnd(label);
});

View File

@@ -0,0 +1,9 @@
{
"name": "expect-to-equal",
"module": "index.ts",
"type": "module",
"devDependencies": {
"jest": "^29.3.1",
"vitest": "^0.25.3"
}
}

View File

@@ -0,0 +1,20 @@
{
"compilerOptions": {
"lib": [
"ESNext"
],
"module": "esnext",
"target": "esnext",
"moduleResolution": "nodenext",
"strict": true,
"downlevelIteration": true,
"skipLibCheck": true,
"jsx": "preserve",
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"allowJs": true,
"types": [
"bun-types" // add Bun global
]
}
}

View File

@@ -6,9 +6,7 @@ bench(`fetch(https://example.com) x ${count}`, async () => {
const requests = new Array(count);
for (let i = 0; i < requests.length; i++) {
requests[i] = fetch(`https://www.example.com/?cachebust=${i}`).then((r) =>
r.text()
);
requests[i] = fetch(`https://www.example.com/?cachebust=${i}`).then(r => r.text());
}
await Promise.all(requests);

View File

@@ -6,9 +6,7 @@ bench(`fetch(https://example.com) x ${count}`, async () => {
const requests = new Array(count);
for (let i = 0; i < requests.length; i++) {
requests[i] = fetch(`https://www.example.com/?cachebust=${i}`).then((r) =>
r.text()
);
requests[i] = fetch(`https://www.example.com/?cachebust=${i}`).then(r => r.text());
}
await Promise.all(requests);

View File

@@ -6,9 +6,7 @@ bench(`fetch(https://example.com) x ${count}`, async () => {
const requests = new Array(count);
for (let i = 0; i < requests.length; i++) {
requests[i] = fetch(`https://www.example.com/?cachebust=${i}`).then((r) =>
r.text()
);
requests[i] = fetch(`https://www.example.com/?cachebust=${i}`).then(r => r.text());
}
await Promise.all(requests);

View File

@@ -1,8 +1,7 @@
import { ptr, dlopen, CString, toBuffer } from "bun:ffi";
import { run, bench, group } from "mitata";
const { napiNoop, napiHash, napiString } = require(import.meta.dir +
"/src/ffi_napi_bench.node");
const { napiNoop, napiHash, napiString } = require(import.meta.dir + "/src/ffi_napi_bench.node");
const {
symbols: {

View File

@@ -1,10 +1,7 @@
import { run, bench, group } from "../node_modules/mitata/src/cli.mjs";
const extension = "darwin" !== Deno.build.os ? "so" : "dylib";
const path = new URL(
"src/target/release/libffi_napi_bench." + extension,
import.meta.url
).pathname;
const path = new URL("src/target/release/libffi_napi_bench." + extension, import.meta.url).pathname;
const {
symbols: { ffi_noop, ffi_hash, ffi_string },

Binary file not shown.

View File

@@ -29,7 +29,7 @@ loop:
-e 'if windows is not {} then perform action "AXRaise" of item 1 of windows' \
-e 'end tell'
sleep 0.5
cd src; zig run -Drelease-fast ../color-looper.zig -- ./colors.css:0 $(SLEEP_INTERVAL)
cd src; zig run -Doptimize=ReleaseFast ../color-looper.zig -- ./colors.css:0 $(SLEEP_INTERVAL)
cp src/colors.css.blob $(PROJECT)/colors.css.blob
loop-emotion:
@@ -40,7 +40,7 @@ loop-emotion:
-e 'if windows is not {} then perform action "AXRaise" of item 1 of windows' \
-e 'end tell'
sleep 0.5
cd src; zig run -Drelease-fast ../color-looper.emotion.zig -- ./css-in-js-styles.tsx:0 $(SLEEP_INTERVAL)
cd src; zig run -Doptimize=ReleaseFast ../color-looper.emotion.zig -- ./css-in-js-styles.tsx:0 $(SLEEP_INTERVAL)
cp src/css-in-js-styles.tsx.blob $(PROJECT)/css-in-js-styles.blob
process_video:

View File

@@ -24,7 +24,7 @@ if (process.env.PROJECT === "bun") {
// bunProcess.stderr.pipe(process.stderr);
// bunProcess.stdout.pipe(process.stdout);
bunProcess.once("error", (err) => {
bunProcess.once("error", err => {
console.error("❌ bun error", err);
process.exit(1);
});
@@ -32,19 +32,15 @@ if (process.env.PROJECT === "bun") {
bunProcess?.kill(0);
});
} else if (process.env.PROJECT === "next") {
const bunProcess = child_process.spawn(
"./node_modules/.bin/next",
["--port", "8080"],
{
cwd: process.cwd(),
stdio: "ignore",
env: {
...process.env,
},
const bunProcess = child_process.spawn("./node_modules/.bin/next", ["--port", "8080"], {
cwd: process.cwd(),
stdio: "ignore",
env: {
...process.env,
},
shell: false,
}
);
shell: false,
});
}
const delay = new Promise((resolve, reject) => {
@@ -111,8 +107,8 @@ async function main() {
return runPage();
}
main().catch((error) =>
main().catch(error =>
setTimeout(() => {
throw error;
})
}),
);

Binary file not shown.

View File

@@ -1,3 +1,4 @@
// @ts-nocheck
import "../src/index.css";
import App from "next/app";

View File

@@ -3,6 +3,7 @@ export function IndexPage() {
return (
<Main
productName={
// @ts-ignore
typeof location !== "undefined" ? location.search.substring(1) : ""
}
/>

View File

@@ -4,9 +4,7 @@ const path = require("path");
const PROJECT = process.env.PROJECT || "bun";
const percentile = require("percentile");
const PACKAGE_NAME = process.env.PACKAGE_NAME;
const label = `${PACKAGE_NAME}@${
require(PACKAGE_NAME + "/package.json").version
}`;
const label = `${PACKAGE_NAME}@${require(PACKAGE_NAME + "/package.json").version}`;
const BASEFOLDER = path.resolve(PROJECT);
const OUTFILE = path.join(process.cwd(), process.env.OUTFILE);
@@ -20,10 +18,10 @@ const TOTAL_FRAMES = VALID_TIMES.length;
const timings = fs
.readFileSync(BASEFOLDER + "/frames.all.clean", "utf8")
.split("\n")
.map((a) => a.replace(/[Ran:'\.]?/gm, "").trim())
.filter((a) => parseInt(a, 10))
.filter((a) => a.length > 0 && VALID_TIMES.includes(BigInt(parseInt(a, 10))))
.map((num) => BigInt(num));
.map(a => a.replace(/[Ran:'\.]?/gm, "").trim())
.filter(a => parseInt(a, 10))
.filter(a => a.length > 0 && VALID_TIMES.includes(BigInt(parseInt(a, 10))))
.map(num => BigInt(num));
timings.sort();
@@ -47,7 +45,7 @@ const report = {
name: PACKAGE_NAME,
version: require(PACKAGE_NAME + "/package.json").version,
},
timestamps: timings.map((a) => Number(a)),
timestamps: timings.map(a => Number(a)),
frameTimes: frameTime,
percentileMs: {
50: percentile(50, frameTime) / 10,
@@ -67,12 +65,10 @@ fs.writeFileSync(
"." +
process.env.SLEEP_INTERVAL +
"ms." +
`${process.platform}-${
process.arch === "arm64" ? "aarch64" : process.arch
}` +
".json"
`${process.platform}-${process.arch === "arm64" ? "aarch64" : process.arch}` +
".json",
),
JSON.stringify(report, null, 2)
JSON.stringify(report, null, 2),
);
console.log(
@@ -99,9 +95,5 @@ console.log(
timings.length,
"/",
TOTAL_FRAMES,
"(" +
Math.round(
Math.max(Math.min(1.0, timings.length / TOTAL_FRAMES), 0) * 100
) +
"%)"
"(" + Math.round(Math.max(Math.min(1.0, timings.length / TOTAL_FRAMES), 0) * 100) + "%)",
);

View File

@@ -3,10 +3,7 @@ import classNames from "classnames";
import ReactDOM from "react-dom";
const Base = ({}) => {
const name =
typeof location !== "undefined"
? decodeURIComponent(location.search.substring(1))
: null;
const name = typeof location !== "undefined" ? decodeURIComponent(location.search.substring(1)) : null;
return <Main productName={name} />;
};

View File

@@ -1,11 +1,11 @@
export const Main = ({ productName, cssInJS }) => {
export const Main = (props: { productName: string; cssInJS?: string }) => {
return (
<>
<header>
<div className="Title">CSS HMR Stress Test!</div>
<p className="Description">
This page visually tests how quickly a bundler can update{" "}
{cssInJS ? "CSS-in-JS" : "CSS"} over Hot Module Reloading.
This page visually tests how quickly a bundler can update {props.cssInJS ? "CSS-in-JS" : "CSS"} over Hot
Module Reloading.
</p>
</header>
<main className="main">
@@ -19,9 +19,7 @@ export const Main = ({ productName, cssInJS }) => {
<div className="ProgressBar-container">
<div className="ProgressBar"></div>
</div>
<div className="SectionLabel">
The progress bar should move from left to right smoothly.
</div>
<div className="SectionLabel">The progress bar should move from left to right smoothly.</div>
</section>
<section>
@@ -42,21 +40,15 @@ export const Main = ({ productName, cssInJS }) => {
<div className="Spinner"></div>
</div>
</div>
<div className="SectionLabel">
The spinners should rotate &amp; change color smoothly.
</div>
<div className="SectionLabel">The spinners should rotate &amp; change color smoothly.</div>
</section>
</main>
<footer>
<div className="SectionLabel FooterLabel">
There are no CSS animations on this page.
</div>
<div className="SectionLabel FooterLabel">There are no CSS animations on this page.</div>
<div className="Bundler-container">
<div className="Bundler">{productName}</div>
<div className="Bundler-updateRate">
{cssInJS ? "CSS-in-JS framework: " + cssInJS : ""}
</div>
<div className="Bundler">{props.productName}</div>
<div className="Bundler-updateRate">{props.cssInJS ? "CSS-in-JS framework: " + props.cssInJS : ""}</div>
</div>
</footer>
</>

View File

@@ -1,6 +1,8 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"baseUrl": ".",
"jsx": "react-jsx",
"paths": {}
}
}
}

View File

@@ -1,12 +1,8 @@
import { bench, run } from "mitata";
bench("JSON.stringify({hello: 'world'})", () =>
JSON.stringify({ hello: "world" })
);
bench("JSON.stringify({hello: 'world'})", () => JSON.stringify({ hello: "world" }));
const otherUint8Array = new Uint8Array(1024);
bench("Uint8Array.from(otherUint8Array)", () =>
Uint8Array.from(otherUint8Array)
);
bench("Uint8Array.from(otherUint8Array)", () => Uint8Array.from(otherUint8Array));
run();

View File

@@ -23,7 +23,7 @@ export const hello${i} = "hello${i}";
${saveStack ? `globalThis.evaluationOrder.push("${file}");` : ""}
globalThis.counter++;
`,
"utf8"
"utf8",
);
var file2 = output + "/file" + i + ".js";
@@ -39,7 +39,7 @@ module.exports.hello${i} = "hello${i}";
${saveStack ? `globalThis.evaluationOrder.push("${file2}");` : ""}
globalThis.counter++;
`,
"utf8"
"utf8",
);
}
@@ -47,26 +47,18 @@ fs.writeFileSync(
output + `/file${count}.mjs`,
`
export const THE_END = true;
${
saveStack
? `globalThis.evaluationOrder.push("${output}/file${count}.mjs");`
: ""
}
${saveStack ? `globalThis.evaluationOrder.push("${output}/file${count}.mjs");` : ""}
`,
"utf8"
"utf8",
);
fs.writeFileSync(
output + `/file${count}.js`,
`
module.exports.THE_END = true;
${
saveStack
? `globalThis.evaluationOrder.push("${output}/file${count}.js");`
: ""
}
${saveStack ? `globalThis.evaluationOrder.push("${output}/file${count}.js");` : ""}
`,
"utf8"
"utf8",
);
fs.writeFileSync(
@@ -79,7 +71,7 @@ fs.writeFileSync(
console.timeEnd("import");
${saveStack ? `console.log(globalThis.evaluationOrder.join("\\n"));` : ""}
console.log("Loaded", globalThis.counter, "files", "totaling", new Intl.NumberFormat().format(globalThis.exportCounter), 'exports');`,
"utf8"
"utf8",
);
fs.writeFileSync(
@@ -92,7 +84,7 @@ export const THE_END = Foo.THE_END;
console.timeEnd("import.meta.require");
${saveStack ? `console.log(globalThis.evaluationOrder.join("\\n"));` : ""}
console.log("Loaded", globalThis.counter, "files", "totaling", new Intl.NumberFormat().format(globalThis.exportCounter), 'exports');`,
"utf8"
"utf8",
);
fs.writeFileSync(
@@ -106,7 +98,7 @@ fs.writeFileSync(
console.timeEnd("import.meta.require");
${saveStack ? `console.log(globalThis.evaluationOrder.join("\\n"));` : ""}
console.log("Loaded", globalThis.counter, "files", "totaling", new Intl.NumberFormat().format(globalThis.exportCounter), 'exports');`,
"utf8"
"utf8",
);
fs.writeFileSync(
@@ -120,7 +112,7 @@ fs.writeFileSync(
${saveStack ? `console.log(globalThis.evaluationOrder.join("\\n"));` : ""}
console.log("Loaded", globalThis.counter, "files", "totaling", new Intl.NumberFormat().format(globalThis.exportCounter), 'exports');
`,
"utf8"
"utf8",
);
console.log(`

View File

@@ -1,5 +1,24 @@
import { bench, run } from "mitata";
import { cpus, endianness, arch, uptime, networkInterfaces, getPriority, totalmem, freemem, homedir, hostname, loadavg, platform, release, setPriority, tmpdir, type, userInfo, version } from "node:os";
import {
cpus,
endianness,
arch,
uptime,
networkInterfaces,
getPriority,
totalmem,
freemem,
homedir,
hostname,
loadavg,
platform,
release,
setPriority,
tmpdir,
type,
userInfo,
version,
} from "node:os";
bench("cpus()", () => cpus());
bench("networkInterfaces()", () => networkInterfaces());

View File

@@ -1,5 +1,24 @@
import { bench, run } from "mitata";
import { cpus, endianness, arch, uptime, networkInterfaces, getPriority, totalmem, freemem, homedir, hostname, loadavg, platform, release, setPriority, tmpdir, type, userInfo, version } from "node:os";
import {
cpus,
endianness,
arch,
uptime,
networkInterfaces,
getPriority,
totalmem,
freemem,
homedir,
hostname,
loadavg,
platform,
release,
setPriority,
tmpdir,
type,
userInfo,
version,
} from "node:os";
bench("cpus()", () => cpus());
bench("networkInterfaces()", () => networkInterfaces());

View File

@@ -14,5 +14,9 @@
"async": "cd async && bun run deps && bun run build && bun run bench",
"sqlite": "cd sqlite && bun run deps && bun run build && bun run bench",
"modules:node_os": "cd modules/node_os && bun run deps &&bun run build && bun run bench"
}
},
"devDependencies": {
"fast-deep-equal": "^3.1.3"
},
"prettier": "../.prettierrc.cjs"
}

BIN
bench/react-hello-world/bun.lockb Executable file

Binary file not shown.

View File

@@ -0,0 +1,16 @@
{
"name": "react-hello-world",
"version": "1.0.0",
"description": "",
"main": "react-hello-world.node.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "Colin McDonnell",
"license": "ISC",
"dependencies": {
"react": "next",
"react-dom": "next"
}
}

View File

@@ -18,8 +18,8 @@ const headers = {
};
Deno.serve(
async (req) => {
async req => {
return new Response(await renderToReadableStream(<App />), headers);
},
{ port: 8080 }
{ port: 8080 },
);

View File

@@ -1,10 +1,9 @@
// to run this:
// bun --jsx-production react-hello-world.jsx
// NODE_ENV=production bun --jsx-production react-hello-world.jsx
// This will become the official react-dom/server.bun build a little later
// It will be the default when you import from "react-dom/server"
// That will work via the "bun" package.json export condition (which bun already supports)
import { renderToReadableStream } from "../../test/bun.js/react-dom-server.bun";
// Make sure you're using react-dom@18.3.0 or later.
// Currently that is available at react-dom@next (which is installed in this repository)
import { renderToReadableStream } from "react-dom/server";
const headers = {
headers: {
"Content-Type": "text/html",

File diff suppressed because it is too large Load Diff

View File

@@ -24,9 +24,7 @@ http
onShellError(error) {
// Something errored before we could complete the shell so we emit an alternative shell.
res.statusCode = 500;
res.send(
'<!doctype html><p>Loading...</p><script src="clientrender.js"></script>'
);
res.send('<!doctype html><p>Loading...</p><script src="clientrender.js"></script>');
},
onAllReady() {
// If you don't want streaming, use this instead of onShellReady.

Binary file not shown.

View File

@@ -8,8 +8,6 @@ const transpiler = new Bun.Transpiler({
console.time("Get exports");
const ITERATIONS = parseInt(process.env.ITERATIONS || "1") || 1;
for (let i = 0; i < ITERATIONS; i++) {
const imports = transpiler.scanImports(
readFileSync("remix-route.ts", "utf8")
);
const imports = transpiler.scanImports(readFileSync("remix-route.ts", "utf8"));
}
console.timeEnd("Get exports");

View File

@@ -0,0 +1,12 @@
import { bench, run } from "mitata";
function doIt(...args) {
// we use .at() to prevent constant folding optimizations
return args.slice().at(0);
}
bench("Array.prototype.slice.call(arguments)", () => {
return doIt(1, 2, 3, 4, 5, 6);
});
await run();

View File

@@ -1,7 +1,7 @@
// https://github.com/oven-sh/bun/issues/1096
import { bench, run } from "mitata";
const identity = (x) => x;
const identity = x => x;
for (let i = 0; i < 20; i++) {
var array = new Array(i);
@@ -22,35 +22,15 @@ bench("inline Array.map x 6", () => [1, 1, 1, 1, 1, 1].map(identity));
bench("inline Array.map x 7", () => [1, 1, 1, 1, 1, 1, 1].map(identity));
bench("inline Array.map x 8", () => [1, 1, 1, 1, 1, 1, 1, 1].map(identity));
bench("inline Array.map x 9", () => [1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity));
bench("inline Array.map x 10", () =>
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
);
bench("inline Array.map x 11", () =>
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
);
bench("inline Array.map x 12", () =>
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
);
bench("inline Array.map x 13", () =>
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
);
bench("inline Array.map x 14", () =>
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
);
bench("inline Array.map x 15", () =>
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
);
bench("inline Array.map x 16", () =>
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
);
bench("inline Array.map x 17", () =>
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
);
bench("inline Array.map x 18", () =>
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
);
bench("inline Array.map x 19", () =>
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity)
);
bench("inline Array.map x 10", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity));
bench("inline Array.map x 11", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity));
bench("inline Array.map x 12", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity));
bench("inline Array.map x 13", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity));
bench("inline Array.map x 14", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity));
bench("inline Array.map x 15", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity));
bench("inline Array.map x 16", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity));
bench("inline Array.map x 17", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity));
bench("inline Array.map x 18", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity));
bench("inline Array.map x 19", () => [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1].map(identity));
await run();

View File

@@ -0,0 +1,30 @@
import { ArrayBufferSink } from "bun";
import { bench, run } from "mitata";
var short = "Hello World!";
var shortUTF16 = "Hello World 💕💕💕";
var long = "Hello World!".repeat(1024);
var longUTF16 = "Hello World 💕💕💕".repeat(1024);
var encoder = new ArrayBufferSink({ stream: true, highWaterMark: 512 });
bench(`${short.length} ascii`, () => {
encoder.write(short);
encoder.start();
});
bench(`${short.length} utf8`, () => {
encoder.write(shortUTF16);
encoder.start();
});
bench(`${long.length} ascii`, () => {
encoder.write(long);
encoder.start();
});
bench(`${longUTF16.length} utf8`, () => {
encoder.write(longUTF16);
encoder.start();
});
await run();

12
bench/snippets/assert.mjs Normal file
View File

@@ -0,0 +1,12 @@
import { bench, group, run } from "mitata";
import * as assert from "assert";
bench("deepEqual", () => {
assert.deepEqual({ foo: "123", bar: "baz" }, { foo: "123", bar: "baz" });
});
bench("deepStrictEqual", () => {
assert.deepStrictEqual({ foo: "123", beep: "boop" }, { foo: "123", beep: "boop" });
});
await run();

View File

@@ -5,14 +5,24 @@ bench("async function(){}", async function () {});
bench("await 1", async function () {
return await 1;
});
bench("await new Promise(resolve => resolve())", async function () {
await new Promise((resolve) => resolve());
function callnextTick(resolve) {
process.nextTick(resolve);
}
function awaitNextTick() {
return new Promise(callnextTick);
}
bench("promise.nextTick", async function () {
return awaitNextTick();
});
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)));
});
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,69 @@
import { bench, run } from "mitata";
const N = parseInt(process.argv.slice(2).at(0) || "10", 10);
var isBuffer = new Buffer(0);
var isNOtBuffer = "not a buffer";
bench("Buffer.isBuffer(buffer)", () => {
return Buffer.isBuffer(isBuffer);
});
{
var j = 0;
j += 1;
j += eval("'ok'");
bench("Buffer.isBuffer(string)", () => {
return Buffer.isBuffer(j);
});
}
bench("Buffer.from('short string')", () => {
return Buffer.from("short string");
});
const loooong = "long string".repeat(9999).split("").join(" ");
bench("Buffer.byteLength('long string'.repeat(9999))", () => {
return Buffer.byteLength(loooong);
});
var hundred = new ArrayBuffer(100);
bench("Buffer.from(ArrayBuffer(100))", () => {
return Buffer.from(hundred);
});
var hundredArray = new Uint8Array(100);
bench("Buffer.from(Uint8Array(100))", () => {
return Buffer.from(hundredArray);
});
var empty = new Uint8Array(0);
bench("Buffer.from(Uint8Array(0))", () => {
return Buffer.from(empty);
});
bench("new Buffer(Uint8Array(0))", () => {
return new Buffer(empty);
});
bench(`new Buffer(${N})`, () => {
return new Buffer(N);
});
bench(`Buffer.alloc(${N})`, () => {
return Buffer.alloc(N);
});
bench(`Buffer.allocUnsafe(${N})`, () => {
return Buffer.allocUnsafe(N);
});
bench("Buffer.allocUnsafe(24_000)", () => {
return Buffer.allocUnsafe(24_000);
});
bench("Buffer.alloc(24_000)", () => {
return Buffer.alloc(24_000);
});
await run({});

View File

@@ -23,9 +23,7 @@ time("Uint8Array[]", () => array[0]);
console.log("");
time("Buffer.getBigInt64BE ", () => buf.readBigInt64BE(0));
time("DataView.getBigInt64 (BE)", () =>
view.getBigInt64(0, false).toString(10)
);
time("DataView.getBigInt64 (BE)", () => view.getBigInt64(0, false).toString(10));
console.log("");
time("Buffer.readBigInt64LE ", () => buf.readBigInt64LE(0));

View File

@@ -10,18 +10,13 @@ var time = (name, fn) => {
console.timeEnd(name.padEnd('Buffer.write(string, "latin1")'.length));
};
console.log(
`Run ${new Intl.NumberFormat().format(INTERVAL)} times with a warmup:`,
"\n"
);
console.log(`Run ${new Intl.NumberFormat().format(INTERVAL)} times with a warmup:`, "\n");
const stringToWrite = "hellooooohellooooo";
time('Buffer.write(string, "utf8")', () => buf.write(stringToWrite, "utf8"));
time('Buffer.write(string, "ascii")', () => buf.write(stringToWrite, "ascii"));
time('Buffer.write(string, "latin1")', () =>
buf.write(stringToWrite, "latin1")
);
time('Buffer.write(string, "latin1")', () => buf.write(stringToWrite, "latin1"));
time("Buffer.readBigInt64BE ", () => buf.readBigInt64BE(0));
// time("DataView.getBigInt64 (BE)", () => view.getBigInt64(0, false));
// console.log("");

BIN
bench/snippets/bun.lockb Executable file

Binary file not shown.

View File

@@ -35,40 +35,26 @@ async function test(log) {
{
const a = performance.now();
await tests.async(0);
if (log)
console.log(
`async/await: ${(report.async = (performance.now() - a).toFixed(4))}ms`
);
if (log) console.log(`async/await: ${(report.async = (performance.now() - a).toFixed(4))}ms`);
}
{
const a = performance.now();
tests.callback(0, function () {
if (log)
console.log(
`callback: ${(report.callback = (performance.now() - a).toFixed(
4
))}ms`
);
if (log) console.log(`callback: ${(report.callback = (performance.now() - a).toFixed(4))}ms`);
});
}
{
const a = performance.now();
await tests.then(0);
if (log)
console.log(
`then: ${(report.then = (performance.now() - a).toFixed(4))}ms`
);
if (log) console.log(`then: ${(report.then = (performance.now() - a).toFixed(4))}ms`);
}
{
const a = performance.now();
tests.sync(0);
if (log)
console.log(
`sync: ${(report.sync = (performance.now() - a).toFixed(4))}ms`
);
if (log) console.log(`sync: ${(report.sync = (performance.now() - a).toFixed(4))}ms`);
}
}

View File

@@ -34,33 +34,25 @@ function polyfillUninitialized(chunks) {
const chunkGroups = [
[Uint8Array.from([123]), Uint8Array.from([456]), Uint8Array.from([789])],
Array.from(readFileSync(import.meta.path)).map((a) => Uint8Array.from([a])),
Array.from(readFileSync(import.meta.path)).map(a => Uint8Array.from([a])),
[readFileSync(import.meta.path)],
Array.from({ length: 42 }, () => readFileSync(import.meta.path)),
Array.from({ length: 2 }, () =>
new TextEncoder().encode(readFileSync(import.meta.path, "utf8").repeat(100))
),
Array.from({ length: 2 }, () => new TextEncoder().encode(readFileSync(import.meta.path, "utf8").repeat(100))),
];
for (const chunks of chunkGroups) {
group(
`${chunks.reduce(
(prev, curr, i, a) => prev + curr.byteLength,
0
)} bytes for ${chunks.length} chunks`,
() => {
bench("Bun.concatArrayBuffers", () => {
Bun.concatArrayBuffers(chunks);
});
bench("Uint8Array.set", () => {
polyfill(chunks);
});
group(`${chunks.reduce((prev, curr, i, a) => prev + curr.byteLength, 0)} bytes for ${chunks.length} chunks`, () => {
bench("Bun.concatArrayBuffers", () => {
Bun.concatArrayBuffers(chunks);
});
bench("Uint8Array.set", () => {
polyfill(chunks);
});
bench("Uint8Array.set (uninitialized memory)", () => {
polyfillUninitialized(chunks);
});
}
);
bench("Uint8Array.set (uninitialized memory)", () => {
polyfillUninitialized(chunks);
});
});
}
await run();

View File

@@ -0,0 +1,48 @@
import { bench, run } from "../node_modules/mitata/src/cli.mjs";
const json = {
login: "wongmjane",
id: 1332975,
node_id: "MDQ6VXNlcjEzMzI5NzU=",
avatar_url: "https://avatars.githubusercontent.com/u/1332975?v=4",
gravatar_id: "",
url: "https://api.github.com/users/wongmjane",
html_url: "https://github.com/wongmjane",
followers_url: "https://api.github.com/users/wongmjane/followers",
following_url: "https://api.github.com/users/wongmjane/following{/other_user}",
gists_url: "https://api.github.com/users/wongmjane/gists{/gist_id}",
starred_url: "https://api.github.com/users/wongmjane/starred{/owner}{/repo}",
subscriptions_url: "https://api.github.com/users/wongmjane/subscriptions",
organizations_url: "https://api.github.com/users/wongmjane/orgs",
repos_url: "https://api.github.com/users/wongmjane/repos",
events_url: "https://api.github.com/users/wongmjane/events{/privacy}",
received_events_url: "https://api.github.com/users/wongmjane/received_events",
type: "User",
site_admin: false,
name: null,
company: null,
blog: "https://wongmjane.com",
location: null,
email: null,
hireable: null,
bio: null,
twitter_username: "wongmjane",
public_repos: 0,
public_gists: 8,
followers: 1197,
following: 135,
created_at: "2012-01-16T07:01:22Z",
updated_at: "2022-11-23T16:12:24Z",
};
const inspect =
"Bun" in globalThis ? Bun.inspect : "Deno" in globalThis ? Deno.inspect : (await import("util")).inspect;
bench("big json object", () => {
console.error(json);
});
bench("inspect big json object", () => {
console.error(inspect(json));
});
await run();

View File

@@ -0,0 +1,36 @@
// so it can run in environments without node module resolution
import { bench, run } from "mitata";
import crypto from "node:crypto";
var foo = Buffer.allocUnsafe(16384);
foo.fill(123);
// if ("Bun" in globalThis) {
// const { CryptoHasher } = Bun;
// bench("CryptoHasher Blake2b256", () => {
// var hasher = new CryptoHasher("blake2b256");
// hasher.update(foo);
// hasher.digest();
// });
// }
bench('crypto.createHash("sha512")', () => {
var hasher = crypto.createHash("sha512");
hasher.update(foo);
hasher.digest();
});
bench('crypto.createHash("sha256")', () => {
var hasher = crypto.createHash("sha256");
hasher.update(foo);
hasher.digest();
});
bench('crypto.createHash("sha1")', () => {
var hasher = crypto.createHash("sha1");
hasher.update(foo);
hasher.digest();
});
await run();

View File

@@ -0,0 +1,505 @@
import { bench, group, run } from "mitata";
import fastDeepEquals from "fast-deep-equal/es6/index";
// const Date = globalThis.Date;
function func1() {}
function func2() {}
const s = Symbol("foo");
const a1 = [1, 2, 3, 4];
a1[s] = "f00";
const a2 = [1, 2, 3, 4];
a2[s] = "f00";
const e1 = new Set();
e1.add([1, 2, 3]);
e1.add("test1");
e1.add(498);
e1.add({ a: 1, b: 2 });
e1.add({ a: 1, b: 434221 });
e1.add({ a: 1, b: 25 });
e1.add({ a: 1, b: 4 });
e1.add({ a: 1, b: 2667 });
e1.add({ a: 1, b: 2 });
e1.add({ a: 1, b: 23426 });
e1.add({ a: 1, b: 672 });
e1.add({ a: 1, b: 28465 });
const e2 = new Set();
e2.add([1, 2, 3]);
e2.add("test1");
e2.add(498);
e1.add({ a: 1, b: 2 });
e1.add({ a: 1, b: 434221 });
e1.add({ a: 1, b: 25 });
e1.add({ a: 1, b: 4 });
e1.add({ a: 1, b: 2667 });
e1.add({ a: 1, b: 2 });
e1.add({ a: 1, b: 23426 });
e1.add({ a: 1, b: 672 });
e1.add({ a: 1, b: 28465 });
const d1 = new Set();
d1.add({ a: 1, b: 2 });
const d2 = new Set();
d2.add({ a: 1, b: 2 });
const fixture = [
{
description: "scalars",
tests: [
{
description: "equal numbers",
value1: 1,
value2: 1,
equal: true,
},
{
description: "not equal numbers",
value1: 1,
value2: 2,
equal: false,
},
{
description: "number and array are not equal",
value1: 1,
value2: [],
equal: false,
},
{
description: "0 and null are not equal",
value1: 0,
value2: null,
equal: false,
},
{
description: "equal strings",
value1: "azzzz",
value2: "azzzz",
equal: true,
},
{
description: "not equal strings",
value1: "azzzz",
value2: "bzzzz",
equal: false,
},
{
description: "empty string and null are not equal",
value1: "",
value2: null,
equal: false,
},
{
description: "null is equal to null",
value1: null,
value2: null,
equal: true,
},
{
description: "equal booleans (true)",
value1: true,
value2: true,
equal: true,
},
{
description: "equal booleans (false)",
value1: false,
value2: false,
equal: true,
},
{
description: "not equal booleans",
value1: true,
value2: false,
equal: false,
},
{
description: "1 and true are not equal",
value1: 1,
value2: true,
equal: false,
},
{
description: "0 and false are not equal",
value1: 0,
value2: false,
equal: false,
},
{
description: "NaN and NaN are equal",
value1: NaN,
value2: NaN,
equal: true,
},
{
description: "0 and -0 are equal",
value1: 0,
value2: -0,
equal: true,
},
{
description: "Infinity and Infinity are equal",
value1: Infinity,
value2: Infinity,
equal: true,
},
{
description: "Infinity and -Infinity are not equal",
value1: Infinity,
value2: -Infinity,
equal: false,
},
],
},
{
description: "objects",
tests: [
{
description: "empty objects are equal",
value1: {},
value2: {},
equal: true,
},
{
description: 'equal objects (same properties "order")',
value1: { a: 1, b: "2" },
value2: { a: 1, b: "2" },
equal: true,
},
{
description: 'equal objects (different properties "order")',
value1: { a: 1, b: "2" },
value2: { b: "2", a: 1 },
equal: true,
},
{
description: "not equal objects (extra property)",
value1: { a: 1, b: "2" },
value2: { a: 1, b: "2", c: [] },
equal: false,
},
{
description: "not equal objects (different property values)",
value1: { a: 1, b: "2", c: 3 },
value2: { a: 1, b: "2", c: 4 },
equal: false,
},
{
description: "not equal objects (different properties)",
value1: { a: 1, b: "2", c: 3 },
value2: { a: 1, b: "2", d: 3 },
equal: false,
},
{
description: "equal objects (same sub-properties)",
value1: { a: [{ b: "c" }] },
value2: { a: [{ b: "c" }] },
equal: true,
},
{
description: "not equal objects (different sub-property value)",
value1: { a: [{ b: "c" }] },
value2: { a: [{ b: "d" }] },
equal: false,
},
{
description: "not equal objects (different sub-property)",
value1: { a: [{ b: "c" }] },
value2: { a: [{ c: "c" }] },
equal: false,
},
{
description: "empty array and empty object are not equal",
value1: {},
value2: [],
equal: false,
},
{
description: "object with extra undefined properties are not equal #1",
value1: {},
value2: { foo: undefined },
equal: false,
},
{
description: "object with extra undefined properties are not equal #2",
value1: { foo: undefined },
value2: {},
equal: false,
},
{
description: "object with extra undefined properties are not equal #3",
value1: { foo: undefined },
value2: { bar: undefined },
equal: false,
},
{
description: "nulls are equal",
value1: null,
value2: null,
equal: true,
},
{
description: "null and undefined are not equal",
value1: null,
value2: undefined,
equal: false,
},
{
description: "null and empty object are not equal",
value1: null,
value2: {},
equal: false,
},
{
description: "undefined and empty object are not equal",
value1: undefined,
value2: {},
equal: false,
},
{
description: "objects with different `toString` functions returning same values are equal",
value1: { toString: () => "Hello world!" },
value2: { toString: () => "Hello world!" },
equal: true,
},
{
description: "objects with `toString` functions returning different values are not equal",
value1: { toString: () => "Hello world!" },
value2: { toString: () => "Hi!" },
equal: false,
},
],
},
{
description: "arrays",
tests: [
{
description: "two empty arrays are equal",
value1: [],
value2: [],
equal: true,
},
{
description: "equal arrays",
value1: [1, 2, 3],
value2: [1, 2, 3],
equal: true,
},
{
description: "equal arrays with symbols",
value1: a1,
value2: a2,
equal: true,
},
// {
// description: "not equal arrays (different item)",
// value1: [1, 2, 3],
// value2: [1, 2, 4],
// equal: false,
// },
// {
// description: "not equal arrays (different length)",
// value1: [1, 2, 3],
// value2: [1, 2],
// equal: false,
// },
{
description: "equal arrays of objects",
value1: [
...Array.from({ length: 200000 }, i => ({
a: 1,
b: 2,
})),
],
value2: [
...Array.from({ length: 200000 }, i => ({
a: 1,
b: 2,
})),
],
equal: true,
},
{
description: "equal objects",
value1: {
a: 1,
b: 2,
c: 3,
d: 4,
// get foo() {
// return 1;
// },
},
value2: {
a: 1,
b: 2,
c: 3,
d: 4,
// get foo() {
// return 1;
// },
},
equal: true,
},
{
description: "equal sets",
value1: d1,
value2: d2,
equal: true,
},
// {
// description: "not equal arrays of objects",
// value1: [{ a: "a" }, { b: "b" }],
// value2: [{ a: "a" }, { b: "c" }],
// equal: false,
// },
// {
// description: "pseudo array and equivalent array are not equal",
// value1: { 0: 0, 1: 1, length: 2 },
// value2: [0, 1],
// equal: false,
// },
],
},
{
description: "Date objects",
tests: [
{
description: "equal date objects",
value1: new Date("2017-06-16T21:36:48.362Z"),
value2: new Date("2017-06-16T21:36:48.362Z"),
equal: true,
},
{
description: "not equal date objects",
value1: new Date("2017-06-16T21:36:48.362Z"),
value2: new Date("2017-01-01T00:00:00.000Z"),
equal: false,
},
{
description: "date and string are not equal",
value1: new Date("2017-06-16T21:36:48.362Z"),
value2: "2017-06-16T21:36:48.362Z",
equal: false,
},
{
description: "date and object are not equal",
value1: new Date("2017-06-16T21:36:48.362Z"),
value2: {},
equal: false,
},
],
},
{
description: "RegExp objects",
tests: [
{
description: "equal RegExp objects",
value1: /foo/,
value2: /foo/,
equal: true,
},
{
description: "not equal RegExp objects (different pattern)",
value1: /foo/,
value2: /bar/,
equal: false,
},
{
description: "not equal RegExp objects (different flags)",
value1: /foo/,
value2: /foo/i,
equal: false,
},
{
description: "RegExp and string are not equal",
value1: /foo/,
value2: "foo",
equal: false,
},
{
description: "RegExp and object are not equal",
value1: /foo/,
value2: {},
equal: false,
},
],
},
{
description: "functions",
tests: [
{
description: "same function is equal",
value1: func1,
value2: func1,
equal: true,
},
{
description: "different functions are not equal",
value1: func1,
value2: func2,
equal: false,
},
],
},
{
description: "sample objects",
tests: [
{
description: "big object",
value1: {
prop1: "value1",
prop2: "value2",
prop3: "value3",
prop4: {
subProp1: "sub value1",
subProp2: {
subSubProp1: "sub sub value1",
subSubProp2: [1, 2, { prop2: 1, prop: 2 }, 4, 5],
},
},
prop5: 1000,
// prop6: new Date(2016, 2, 10),
},
value2: {
prop5: 1000,
prop3: "value3",
prop1: "value1",
prop2: "value2",
// prop6: new Date(2016, 2, 10),
prop4: {
subProp2: {
subSubProp1: "sub sub value1",
subSubProp2: [1, 2, { prop2: 1, prop: 2 }, 4, 5],
},
subProp1: "sub value1",
},
},
equal: true,
},
],
},
];
for (let { tests, description } of fixture) {
// if (description === "sample objects") {
for (let { description: describe, value1, value2, equal } of tests) {
var expected;
group(describe, () => {
for (let equalsFn of [Bun.deepEquals, fastDeepEquals]) {
bench(equalsFn.name, () => {
expected = equalsFn(value1, value2);
if (expected !== equal) {
throw new Error(`Expected ${expected} to be ${equal} for ${description}`);
}
});
}
});
// }
}
}
await run();

View File

@@ -0,0 +1,138 @@
import { bench, run } from "../node_modules/mitata/src/cli.mjs";
const properties = {
closed: {
get() {
return this._writableState ? this._writableState.closed : false;
},
},
destroyed: {
get() {
return this._writableState ? this._writableState.destroyed : false;
},
set(value) {
if (this._writableState) {
this._writableState.destroyed = value;
}
},
},
writable: {
get() {
const w = this._writableState;
return !!w && w.writable !== false && !w.destroyed && !w.errored && !w.ending && !w.ended;
},
set(val) {
if (this._writableState) {
this._writableState.writable = !!val;
}
},
},
writableFinished: {
get() {
return this._writableState ? this._writableState.finished : false;
},
},
writableObjectMode: {
get() {
return this._writableState ? this._writableState.objectMode : false;
},
},
writableBuffer: {
get() {
return this._writableState && this._writableState.getBuffer();
},
},
writableEnded: {
get() {
return this._writableState ? this._writableState.ending : false;
},
},
writableNeedDrain: {
get() {
const wState = this._writableState;
if (!wState) return false;
return !wState.destroyed && !wState.ending && wState.needDrain;
},
},
writableHighWaterMark: {
get() {
return this._writableState && this._writableState.highWaterMark;
},
},
writableCorked: {
get() {
return this._writableState ? this._writableState.corked : 0;
},
},
writableLength: {
get() {
return this._writableState && this._writableState.length;
},
},
errored: {
enumerable: false,
get() {
return this._writableState ? this._writableState.errored : null;
},
},
writableAborted: {
enumerable: false,
get: function () {
return !!(
this._writableState.writable !== false &&
(this._writableState.destroyed || this._writableState.errored) &&
!this._writableState.finished
);
},
},
};
var count = 10_000;
bench("Object.defineProperty x " + count, () => {
const prop = {
enumerable: false,
get: function () {
return !!(
this._writableState.writable !== false &&
(this._writableState.destroyed || this._writableState.errored) &&
!this._writableState.finished
);
},
};
for (let i = 0; i < count; i++) {
function Hey() {
return this;
}
Object.defineProperty(Hey.prototype, "writableAborted", prop);
}
});
bench("Object.defineProperties x " + count, () => {
for (let i = 0; i < count; i++) {
function Hey() {
return this;
}
Object.defineProperties(Hey.prototype, properties);
}
});
bench("(all the keys) Object.defineProperties x " + count, () => {
var first;
{
function Hey() {
return this;
}
Object.defineProperties(Hey.prototype, properties);
first = Object.getOwnPropertyDescriptors(Hey.prototype);
}
for (let i = 0; i < count; i++) {
function Hey() {
return this;
}
Object.defineProperties(Hey.prototype, first);
}
});
await run();

View File

@@ -0,0 +1,74 @@
import { lookup, resolve } from "node:dns/promises";
import { bench, run } from "mitata";
bench("(cached) dns.lookup remote x 50", async () => {
var tld = "example.com";
const run = () => lookup(tld).catch(() => {});
const total = 50;
var remain = total;
var done;
await new Promise(resolve => {
for (var i = 0; i < total; i++)
run().finally(() => {
remain--;
if (remain === 0) {
done();
}
});
done = resolve;
});
});
bench("(cached in batch) dns.lookup remote x 50", async () => {
var tld = Math.random().toString(16) + ".example.com";
const run = () => lookup(tld).catch(() => {});
const total = 50;
var remain = total;
var done;
await new Promise(resolve => {
for (var i = 0; i < total; i++)
run().finally(() => {
remain--;
if (remain === 0) {
done();
}
});
done = resolve;
});
});
bench("dns.lookup remote x 50", async () => {
var remain = 50;
var done;
const run = () => lookup(Math.random().toString() + ".example.com").catch(() => {});
await new Promise(resolve => {
for (var i = 0; i < 50; i++)
run().finally(() => {
remain--;
if (remain === 0) {
done();
}
});
done = resolve;
});
});
bench("dns.resolve remote x 50", async () => {
var remain = 50;
var done;
const run = () => resolve(Math.random().toString() + ".example.com").catch(() => {});
await new Promise(resolve => {
for (var i = 0; i < 50; i++)
run().finally(() => {
remain--;
if (remain === 0) {
done();
}
});
done = resolve;
});
});
await run();

66
bench/snippets/dns.ts Normal file
View File

@@ -0,0 +1,66 @@
import { dns } from "bun";
import { bench, run, group } from "mitata";
async function forEachBackend(name, fn) {
group(name, () => {
for (let backend of ["libc", "c-ares", process.platform === "darwin" ? "system" : ""].filter(Boolean))
bench(backend, fn(backend));
});
}
forEachBackend("dns.lookup remote x 50", backend => async () => {
const run = () => dns.lookup(Math.random().toString(16) + ".example.com", { backend }).catch(() => {});
var remain = 16;
var done;
await new Promise(resolve => {
for (var i = 0; i < 16; i++)
run().finally(() => {
remain--;
if (remain === 0) {
done();
}
});
done = resolve;
});
});
forEachBackend("(cached) dns.lookup remote x 50", backend => {
var tld = "example.com";
const run = () => dns.lookup(tld, { backend }).catch(() => {});
return async () => {
const total = 50;
var remain = total;
var done;
await new Promise(resolve => {
for (var i = 0; i < total; i++)
run().finally(() => {
remain--;
if (remain === 0) {
done();
}
});
done = resolve;
});
};
});
forEachBackend("(cached in batch) dns.lookup remote x 50", backend => async () => {
var tld = Math.random().toString(16) + ".example.com";
const run = () => dns.lookup(tld, { backend }).catch(() => {});
const total = 50;
var remain = total;
var done;
await new Promise(resolve => {
for (var i = 0; i < total; i++)
run().finally(() => {
remain--;
if (remain === 0) {
done();
}
});
done = resolve;
});
});
await run();

View File

@@ -1,49 +0,0 @@
const EventEmitter = require("events").EventEmitter;
import { bench, run } from "mitata";
const emitter = new EventEmitter();
const event = new Event("hello");
emitter.on("hello", (event) => {
event.preventDefault();
});
var id = 0;
bench("EventEmitter.emit", () => {
emitter.emit("hello", {
preventDefault() {
id++;
},
});
});
bench("EventEmitter.on x 10_000 (handler)", () => {
var cb = () => {
event.preventDefault();
};
emitter.on("hey", cb);
for (let i = 0; i < 10_000; i++)
emitter.emit("hey", {
preventDefault() {
id++;
},
});
emitter.off("hey", cb);
});
var target = new EventTarget();
target.addEventListener("hello", (event) => {});
bench("EventTarget.dispatch", () => {
target.dispatchEvent(event);
});
var hey = new Event("hey");
bench("EventTarget.on x 10_000 (handler)", () => {
var handler = (event) => {};
target.addEventListener("hey", handler);
for (let i = 0; i < 10_000; i++) target.dispatchEvent(hey);
target.removeEventListener("hey", handler);
});
await run();

101
bench/snippets/emitter.mjs Normal file
View File

@@ -0,0 +1,101 @@
// **so this file can run in node**
import { createRequire } from "node:module";
const require = createRequire(import.meta.url);
// --
const EventEmitterNative = require("node:events").EventEmitter;
const TypedEmitter = require("tiny-typed-emitter").TypedEmitter;
const EventEmitter3 = require("eventemitter3").EventEmitter;
import { bench, run } from "../../node_modules/mitata/src/cli.mjs";
const event = new Event("hello");
var id = 0;
for (let [EventEmitter, className] of [
[EventEmitterNative, "EventEmitter"],
[TypedEmitter, "TypedEmitter"],
[EventEmitter3, "EventEmitter3"],
]) {
const emitter = new EventEmitter();
emitter.on("hello", event => {
event.preventDefault();
});
bench(`${className}.emit`, () => {
emitter.emit("hello", {
preventDefault() {
id++;
},
});
});
bench(`${className}.on x 10_000 (handler)`, () => {
var cb = event => {
event.preventDefault();
};
emitter.on("hey", cb);
var called = false;
for (let i = 0; i < 10_000; i++)
emitter.emit("hey", {
preventDefault() {
id++;
called = true;
},
});
emitter.off("hey", cb);
if (!called) throw new Error("not called");
});
if (EventEmitter !== EventEmitter3) {
var monkey = Object.assign({}, EventEmitter.prototype);
monkey.on("hello", event => {
event.preventDefault();
});
bench(`[monkey] ${className}.emit`, () => {
var called = false;
monkey.emit("hello", {
preventDefault() {
id++;
called = true;
},
});
if (!called) {
throw new Error("monkey failed");
}
});
bench(`[monkey] ${className}.on x 10_000 (handler)`, () => {
var cb = () => {
event.preventDefault();
};
monkey.on("hey", cb);
for (let i = 0; i < 10_000; i++)
monkey.emit("hey", {
preventDefault() {
id++;
},
});
monkey.off("hey", cb);
});
}
}
var target = new EventTarget();
target.addEventListener("hello", event => {});
bench("EventTarget.dispatch", () => {
target.dispatchEvent(event);
});
var hey = new Event("hey");
bench("EventTarget.on x 10_000 (handler)", () => {
var handler = event => {};
target.addEventListener("hey", handler);
for (let i = 0; i < 10_000; i++) target.dispatchEvent(hey);
target.removeEventListener("hey", handler);
});
await run();

View File

@@ -0,0 +1,10 @@
import { run, bench } from "../node_modules/mitata/src/cli.mjs";
const encoder = new TextEncoder();
const buffer = new Uint8Array(1024);
bench("encodeInto", () => {
encoder.encodeInto("Hello World!", buffer);
});
await run();

View File

@@ -8,7 +8,7 @@ var bunEscapeHTML = globalThis.escapeHTML || Bun.escapeHTML;
const FIXTURE = require("fs")
.readFileSync(import.meta.dir + "/_fixture.txt", "utf8")
.split("")
.map((a) => {
.map(a => {
if (a.charCodeAt(0) > 127) {
return "a";
}
@@ -16,10 +16,7 @@ const FIXTURE = require("fs")
})
.join("");
const FIXTURE_WITH_UNICODE = require("fs").readFileSync(
import.meta.dir + "/_fixture.txt",
"utf8"
);
const FIXTURE_WITH_UNICODE = require("fs").readFileSync(import.meta.dir + "/_fixture.txt", "utf8");
// from react-dom:
const matchHtmlRegExp = /["'&<>]/;
@@ -116,7 +113,7 @@ for (let input of [
// bench(`html-entities.encode`, () => htmlEntityEncode(input));
// bench(`he.escape`, () => heEscape(input));
bench(`Bun.escapeHTML`, () => bunEscapeHTML(input));
}
},
);
}
await run();

View File

@@ -1,13 +1,4 @@
import {
viewSource,
dlopen,
CString,
ptr,
toBuffer,
toArrayBuffer,
FFIType,
callback,
} from "bun:ffi";
import { viewSource, dlopen, CString, ptr, toBuffer, toArrayBuffer, FFIType, callback } from "bun:ffi";
import { bench, group, run } from "mitata";
const types = {
@@ -235,9 +226,7 @@ var opened;
try {
opened = dlopen("/tmp/bun-ffi-test.dylib", types);
} catch (e) {
throw new Error(
"Please run `make compile-ffi-test` to compile the ffi test library"
);
throw new Error("Please run `make compile-ffi-test` to compile the ffi test library");
}
const {
@@ -403,10 +392,10 @@ group("returns_true", () => {
group("return_a_function_ptr_to_function_that_returns_true", () => {
bench("return_a_function_ptr_to_function_that_returns_true (raw)", () =>
raw_return_a_function_ptr_to_function_that_returns_true()
raw_return_a_function_ptr_to_function_that_returns_true(),
);
bench("return_a_function_ptr_to_function_that_returns_true", () =>
return_a_function_ptr_to_function_that_returns_true()
return_a_function_ptr_to_function_that_returns_true(),
);
});
group("returns_42_float", () => {
@@ -427,8 +416,7 @@ group("identity_double", () => {
});
var raw_return_a_function_ptr_to_function_that_returns_true =
return_a_function_ptr_to_function_that_returns_true.native ??
return_a_function_ptr_to_function_that_returns_true;
return_a_function_ptr_to_function_that_returns_true.native ?? return_a_function_ptr_to_function_that_returns_true;
var raw_returns_42_float = returns_42_float.native ?? returns_42_float;
var raw_returns_42_double = returns_42_double.native ?? returns_42_double;
var raw_identity_float = identity_float.native ?? identity_float;
@@ -437,14 +425,11 @@ var raw_returns_true = returns_true.native ?? returns_true;
var raw_returns_false = returns_false.native ?? returns_false;
var raw_returns_42_char = returns_42_char.native ?? returns_42_char;
var raw_returns_42_uint8_t = returns_42_uint8_t.native ?? returns_42_uint8_t;
var raw_returns_neg_42_int8_t =
returns_neg_42_int8_t.native ?? returns_neg_42_int8_t;
var raw_returns_neg_42_int8_t = returns_neg_42_int8_t.native ?? returns_neg_42_int8_t;
var raw_returns_42_uint16_t = returns_42_uint16_t.native ?? returns_42_uint16_t;
var raw_returns_42_uint32_t = returns_42_uint32_t.native ?? returns_42_uint32_t;
var raw_returns_neg_42_int16_t =
returns_neg_42_int16_t.native ?? returns_neg_42_int16_t;
var raw_returns_neg_42_int32_t =
returns_neg_42_int32_t.native ?? returns_neg_42_int32_t;
var raw_returns_neg_42_int16_t = returns_neg_42_int16_t.native ?? returns_neg_42_int16_t;
var raw_returns_neg_42_int32_t = returns_neg_42_int32_t.native ?? returns_neg_42_int32_t;
var raw_identity_char = identity_char.native ?? identity_char;
var raw_identity_bool = identity_bool.native ?? identity_bool;
var raw_identity_bool = identity_bool.native ?? identity_bool;

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