Compare commits

..

726 Commits

Author SHA1 Message Date
Colin McDonnell
7c9352392d Update readme and regen 2023-06-09 19:21:49 -07:00
Jarred Sumner
fef9853d5a wip 2023-06-05 02:02:13 -07:00
Jarred Sumner
7dae496847 wip 2023-06-04 19:59:22 -07:00
Jarred Sumner
92b060c6e2 fix some CLI things 2023-06-04 19:06:02 -07:00
Jarred Sumner
2a64e8b3bb fixup 2023-06-04 19:05:42 -07:00
Jarred Sumner
fde3b7fbb6 Fix build 2023-06-04 18:54:26 -07:00
Ashcon Partovi
c16e769383 Add types and sample heapsnapshot for JSC and V8 2023-06-04 18:54:26 -07:00
Ashcon Partovi
5badc728d0 Add a DevTools client 2023-06-04 18:54:26 -07:00
Jarred Sumner
c4b3b321c2 slightly more progress 2023-06-04 18:54:26 -07:00
Jarred Sumner
cf599e77d9 Fix C++ compile errors 2023-06-04 18:54:26 -07:00
Jarred Sumner
b727689a9b pushing this but it doesn't fix anything 2023-06-04 18:54:26 -07:00
Ashcon Partovi
4a36470588 Add script to generate DevTools protocol types for JSC and V8 2023-06-04 18:54:26 -07:00
Jarred Sumner
ca08cf6b0a Update BunInspector.cpp 2023-06-04 18:54:26 -07:00
Jarred Sumner
10bd0fac3a WIP support inspector 2023-06-04 18:54:26 -07:00
Jarred Sumner
c4e31551f3 Update .gitattributes 2023-06-03 17:44:28 -07:00
dave caruso
52d11ce845 Add test case (#3186) 2023-06-03 16:38:49 -07:00
dave caruso
7d8b6d487b make hardcoded -> make esm + document needing bun to build bun (#3188) 2023-06-03 16:38:33 -07:00
Jarred Sumner
583c6d3644 Bump 2023-06-03 16:37:53 -07:00
Ciro Spaciari
aabb0b77ce [tests] prisma tests (#3197) 2023-06-03 15:04:19 -07:00
Jarred Sumner
59d7c47e3f Fix crash with path parse in win32 (#3187)
* Update CommonJSModuleRecord.cpp

* smaller

* [node:path] Fix crash, mark TODO

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-06-03 00:14:27 -07:00
Dylan Conway
21bc3a9c39 [bundler] fix json imports, undo some todos 2023-06-02 22:44:19 -07:00
dave caruso
cfd73cec81 fixes with hardcoded modules (#3182)
* fixes with hardcoded modules

* add make hardcoded to make dev

* adjust this message

* remove debugging logs

* this

* restore2
2023-06-02 21:36:05 -07:00
Dylan Conway
3e437a6ae0 check package name length in shouldUnwrapRequire() (#3183)
* make sure length is equal

* add and use `indexEqualAny`
2023-06-02 20:45:48 -07:00
Dylan Conway
d8e7436db0 use NODE_ENV for react-jsx or react-jsxdev (#3184) 2023-06-02 20:35:00 -07:00
dave caruso
f798a0cfe8 fix readableStreamToArrayBuffer (#3181)
* fix discord.js again

* remove one of the async hooks warnings

* clarify hardcoded modules docs
2023-06-02 19:03:16 -07:00
Ciro Spaciari
51846d0277 [napi] some fixes for prisma (#3176)
* patch create object, so it can be used on wrap

* cleanup

* cleanup

* dont override napiRef

* make wrap strong ref

* workaround tests

* remove work around
2023-06-02 17:56:16 -07:00
Colin McDonnell
c4f237572d Update macro/test docs (#3180)
* Add test and fix plugin type

* Update docs and config pages
2023-06-02 17:43:51 -07:00
Dylan Conway
e20e695775 continue if import is standalone (#3178) 2023-06-02 17:07:16 -07:00
Jarred Sumner
132ab63a32 Add comment 2023-06-02 16:39:16 -07:00
Ashcon Partovi
bfd315fc72 Support NO_COLOR environment variable (#3055) 2023-06-02 14:24:16 -07:00
Jarred Sumner
72c2123e07 Maybe we don't need to do this anymore? (#3169) 2023-06-02 14:22:39 -07:00
Colin McDonnell
1f7d62bfd5 Support NodeJS.ProcessEnv 2023-06-02 12:49:31 -07:00
Jozef Steinhübl
4d1c900cac types: expose Bun.Env (#3111)
* expose Bun.Env

* export bun.Env

* fix: use import instead namespace access

* fix(child_process): use import

* tests(env): use module instead namespace
2023-06-02 12:48:19 -07:00
Jarred Sumner
97c522517c Fixes #3161 (#3174)
* Fixes #3161

* Fix the error message

* woops

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-06-02 04:01:25 -07:00
Ashcon Partovi
4c6245b2e5 Add concurrency to workflows, enable cancel-in-progress 2023-06-01 18:38:40 -07:00
Ashcon Partovi
b21a58e564 Fix github annotation when using inspect() (#3166) 2023-06-01 18:25:06 -07:00
dave caruso
4df1d37ddc Bundle and minify .exports.js files. (#3036)
* move all exports.js into src/js

* finalize the sort of this

* and it works

* add test.ts to gitignore

* okay

* convert some to ts just to show

* finish up

* fixup makefile

* minify syntax in dev

* finish rebase

* dont minify all modules

* merge

* finish rebase merge

* flaky test that hangs
2023-06-01 18:16:47 -07:00
Ashcon Partovi
03ffd1c732 Disable typecheck workflow for now 2023-06-01 18:04:45 -07:00
Jarred Sumner
3e84f18cc0 Implement __dirname and __filename, allow direct eval in CommonJS (#3164)
* Implement `__dirname` and `__filename`, allow direct eval in CommonJS

* Fixup dirname and add test

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-06-01 18:04:09 -07:00
Jarred Sumner
42606d6aed Rename ptr to _unsafe_ptr_do_not_use (#3163)
* Rename `ptr` to `_unsafe_ptr_do_not_use`

* Fixup

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-06-01 18:02:41 -07:00
Derrick Farris
c366b62160 Update macros.md (#3165)
Fix a repeated "for"
2023-06-01 17:25:28 -07:00
dave caruso
42d8b7183c random fixes that help vite/sveltekit (#3140)
* existsSync with invalid paths should return false

* partially support file urls (does not do percent encoding)

* add utf16 support for Path.isAbsoluteString

* Update src/resolver/resolver.zig

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

* fixups

* revert

* prettier format

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-06-01 16:48:37 -07:00
Ciro Spaciari
f9809f0044 [napi] fix thread safe function callback (#3162)
* fixup

* add debug log message to event loop unexpected tag

* fix fmt
2023-06-01 15:19:06 -07:00
dave caruso
4378ef8e97 mark currently known test fails as .todo (#3052)
* start this

* commit

* mark all failing tests as todo

* fasdfad

* bundler tests

* tests

* adjust failing tests to todo

* comment out some more tests

* png as test
2023-06-01 14:37:35 -07:00
dave caruso
2c1694f63b Fix streams breaking on reverted EventEmitter / Make Discord.js work (#2913)
* Revert "Revert "use a lazyily initialized stream for `node:crypto` `createHash` (#2652)""

This reverts commit 613bb4822e.

* Revert "Revert "implement `node:events` in javascript (#2604)""

This reverts commit a4d0a1961a.

* oops

* fix entrypoints stuff

* fix hash copy

* use native events for node streams and crypto

* requested changes

* oops

* make discord.js work

* fix webkit hash

* headers tojson
2023-06-01 14:31:36 -07:00
Jarred Sumner
ae277a0dec Update build-id 2023-06-01 13:58:50 -07:00
Dylan Conway
473b219a37 only add cjs export name if it is assigned (#3159) 2023-06-01 13:57:51 -07:00
Noah Chase
be1833898e fix typo in documentation ("the today" -> "today") (#3160) 2023-06-01 13:34:09 -07:00
Jozef Steinhübl
a64da8f0cb ci: dont run builds in forks (#3156) 2023-06-01 12:35:26 -07:00
Dylan Conway
689434e012 don't rewrite module.exports if assign target is update or replace (#3147)
* don't rewrite `module.exports` if assign target is `update` or `replace`

* missing `is_delete_target`, check de-opt before rewriting
2023-05-31 23:51:32 -07:00
Jarred Sumner
a73a4d1e0b Fix test failure due to cloudflare changing dns ttl 2023-05-31 23:19:32 -07:00
Jarred Sumner
457f325773 slightly clean up this test 2023-05-31 23:18:58 -07:00
Jarred Sumner
5f80681295 [TCP] Ensure we keep the handlers functions alive when an error callback needs to be called
This can cause test failures due to GC'ing the handlers when we are *just* about to call them.
2023-05-31 23:17:18 -07:00
Jarred Sumner
fdcfcce9e7 Clean-up some option parsing in Bun.spawn 2023-05-31 23:15:21 -07:00
Jarred Sumner
1ca70b855c Update launch.json 2023-05-31 23:13:50 -07:00
Ashcon Partovi
e632941c52 Small improvements to bun test (#3071)
* Change status icon for skipped tests from "-" to "»"

* Show file path instead of filename in `bun test`

* Emit collapsable logs when running `bun test` in Github Actions

https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#grouping-log-lines

* Add fallback for test icons when emojis are not available

* Only check for GITHUB_ACTIONS when running `bun test`

* Emit error annotations when running `bun test` in Github Actions

https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-error-message

* Remove ANSI output from Github annotation, it doesn't work

* Remove outdated code from internal test runner

* Add GithubActionFormatter to handle cases where error name or message is already ANSI

* Fix formatting of test

* Fix #3070

* Implement `bun test --run-todo`

By default, `test.todo()` is no longer run, unless `--run-todo` is specified.

* Fix test that relies on test.todo() being run

* Support vitest-style test options

* Disable GITHUB_ACTION in test harness

* Add types for TestOptions

* Fix bug where test.skip() actually ran

* Implement `test.skipIf()` and `describe.skipIf()`

* Implement `test.runIf()`

* Move DiffFormatter to its own file

* Fix bug where Bun.inspect() would emit a Github annotation

* Introduce `bun test --only`, rename `--run-todo` to `--todo`

* Implement `test.if()`, `describe.if()`, and other test fixes

* Remove unwanted files from last commit

* Fix last reference to --run-todo

* Fix memory issues with printing github actions text

* Update bindings.zig

* Fix bug with `test.only()`

* Remove debug test

* Make the github annotations better

* Improve .vscode/launch.json

* Implement `expect().toBeNil()`

* Remove .only() from test

* Implement toBeBoolean(), toBeTrue(), toBeFalse()

* Add lots of matchers
* toBeNil()
* toBeBoolean()
* toBeTrue()
* toBeFalse()
* toBeNumber()
* toBeInteger()
* toBeFinite()
* toBePositive()
* toBeNegative()
* toBeWithin()
* toBeSymbol()
* toBeFunction()
* toBeDate()
* toBeString()
* toInclude()
* toStartWith()
* toEndWith()

* Fix #3135

* Reduce verbosity of test

* Fix snapshot bug

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-31 23:12:04 -07:00
Colin McDonnell
176fade220 Remove bun-macro-relay and update docs (#3145)
* Update macro docs

* Remove bun-macro-relay
2023-05-31 19:51:08 -07:00
Jarred Sumner
110d0752f3 Add "macro" package.json exports condition 2023-05-31 19:01:59 -07:00
Ciro Spaciari
e24d579a32 isolated version of Path compatible with nodejs (#3143) 2023-05-31 18:20:50 -07:00
Mike Roelens
a7c7128cd7 Fix typo in macro docs (#3144) 2023-05-31 18:15:49 -07:00
Jarred Sumner
4c01454376 Make uploading files with fetch()fast (#3125)
* Make file uploads fast

* Add benchmark

* Update README.md

* defaults

* print

* prettier

* smaller

* fix(path) fix parse behavior (#3134)

* Add macro docs (#3139)

* Add macro doc

* Updates

* Tweaks

* Update doc

* Update macro serialization doc

* Update macro doc

* `--no-macros` flag, disable macros in node_modules

* invert base/filename internally (#3141)

* always false

* Fix broken test

* Add a test sendfile() test with large file

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Ciro Spaciari <ciro.spaciari@gmail.com>
Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
2023-05-31 17:20:30 -07:00
Dylan Conway
611f1d0e24 set optional_chain instead of optional_start (#3142) 2023-05-31 16:13:24 -07:00
Ciro Spaciari
52c6609792 invert base/filename internally (#3141) 2023-05-31 15:13:37 -07:00
Jarred Sumner
7057cb1982 --no-macros flag, disable macros in node_modules 2023-05-31 15:05:49 -07:00
Colin McDonnell
68c1568075 Update macro doc 2023-05-31 13:58:38 -07:00
Colin McDonnell
4b34a7ce2a Update macro serialization doc 2023-05-31 13:43:08 -07:00
Colin McDonnell
b284e09ce5 Update doc 2023-05-31 13:35:11 -07:00
Colin McDonnell
8f55f05871 Add macro docs (#3139)
* Add macro doc

* Updates

* Tweaks
2023-05-31 13:34:35 -07:00
Ciro Spaciari
58fcb60831 fix(path) fix parse behavior (#3134) 2023-05-31 12:07:52 -07:00
Jarred Sumner
557aac6a34 Support FormData & file uploads in fetch body (#3123)
* Fixes #2264

* fixup

* Don't leak HTTP headers

* Include the mime type. It's cleaner

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-31 00:43:59 -07:00
Jarred Sumner
0aab11a95d always clone these 2023-05-30 19:39:12 -07:00
Jarred Sumner
7376ae6980 Update modules.md 2023-05-30 15:52:21 -07:00
Jarred Sumner
148c6e7551 Fix wasi 2023-05-30 15:41:27 -07:00
Jarred Sumner
b0c38a3c15 Update ZigGeneratedClasses.h 2023-05-30 13:13:42 -07:00
Jarred Sumner
756e15f6e2 Add another comment 2023-05-30 02:53:28 -07:00
Jarred Sumner
10be26f011 [CommonJS] Handle this better 2023-05-30 02:51:50 -07:00
Jarred Sumner
12a0e2bfdd Fixes #3115 2023-05-30 02:51:27 -07:00
Jarred Sumner
481f916f3f More comments 2023-05-30 00:30:47 -07:00
Jarred Sumner
85565d95d5 Add a comment 2023-05-30 00:26:30 -07:00
Jarred Sumner
fdbf8a5184 Handle Object.defineProperty(module, "exports", {get: getter}) 2023-05-30 00:24:18 -07:00
Jarred Sumner
8e911d38c4 Bump 2023-05-30 00:19:15 -07:00
Jarred Sumner
052df7d48c Cleanup CommonJS changes (#3112)
* Add more GC in test

* Fix handling of functions and re-assignments in CommonJS

* Increase timeout

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-29 21:01:39 -07:00
Jarred Sumner
5990a9528f Rename this file so we know what it is 2023-05-29 19:58:40 -07:00
Jarred Sumner
aa6801d5df Update index.md 2023-05-29 12:22:13 -07:00
Jarred Sumner
d0185925ff Update modules.md 2023-05-29 12:15:33 -07:00
Colin McDonnell
9b6913e1a6 More/better docs for JSX, utils, binary data, streams, hashing, bun test, Bun.serve (#3005)
* WIP

* Updates

* Document deepEquals

* WIP

* Update typeS

* Update TLS docs for Bun.serve

* Update types for tls

* Draft binary data page. Add Streams page.

* Update test runner docs

* Add hashing, flesh out utils

* Grammar

* Update types

* Fix

* Add import.meta docs

* Tee
2023-05-29 11:49:51 -07:00
Jarred Sumner
e2de1f5c13 Natively support CommonJS at runtime (#3104)
* Natively support CommonJS at runtime

* cleanup how getters are handled, add fast path

* more consistent with node

* use * As

* Remove thrown modules on exception

* Handle exception better

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-29 11:23:10 -07:00
Jarred Sumner
2b04ef4fae Convert module.exports = { foo: 'bar'} to ESM in bun build (#3103)
* Convert `module.exports = { foo: 'bar'}` to ESM in `bun build`

* De-opt for `module.exports = {}`

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-28 21:02:51 -07:00
Jarred Sumner
8dfd3dbdbc Add query string to express integration test 2023-05-28 13:30:25 -07:00
Ciro Spaciari
63e2d78e76 [node:net] fix createConnection options passing (#3101)
* fixup createConnection

* fix comment

* fixup comment

* also fix it on tls
2023-05-28 13:20:32 -07:00
Jarred Sumner
1388ec0d60 Fixes #2356 (#3098) 2023-05-27 23:33:47 -07:00
Tiramify (A.K. Daniel)
4ba3ed512a Implement process.env.npm_lifecycle_event (#3097)
* Update run_command.zig

* Update env.test.ts

* Add files via upload

* Update run-process-env.test.ts

* Update env.test.ts

* Update harness.ts
2023-05-27 20:43:08 -07:00
Jarred Sumner
f870f97a94 Fixes #3091 (#3092)
* Fixes #3091

* Update build-id

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-27 00:21:54 -07:00
Jarred Sumner
7094997eec Fix crash in Server.prototype.fetch() helper function
cc @cirospaciari, if you use `mimalloc-debug` it catches things like this
2023-05-26 21:18:31 -07:00
Jarred Sumner
79907fe84c Add more debug safety checks 2023-05-26 21:17:10 -07:00
Ashcon Partovi
1a30b4fe29 Implement expect().toBeEmpty() (#3060)
* Implement `expect().toBeEmpty()`

* Fix formatting on test

* Finish up expect().toBeEmpty()

* Update expect.test.ts

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-26 19:24:20 -07:00
Jarred Sumner
4298f36fc9 fixup 2023-05-26 16:29:44 -07:00
Jarred Sumner
3a0735e164 Pretty formatter for Headers & URLSearchParams (#3081)
* Pretty formatter for `Headers` & `URLSearchParams`

* cleanup

* console.log on Headers, FormData, URLSearchParams will always quote the keys now

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-26 16:28:09 -07:00
Ciro Spaciari
42125b4351 [fetch] change response allocator (#3086)
* change allocator

* cleanup
2023-05-26 15:07:03 -07:00
Jarred Sumner
0f2a79b9c1 Fix crash in test.todo + remove JSC C API usages in bun:test (#3079)
* Fix crash in test.todo

* remove usages of JSC C API in bun:test

* Remove additional JSC-C API usages

* fix `make headers`

* URLSearchParams.length

* FormData length

* URLSearchParams length

* Fix `make headers`

* very fancy length

* Fix bug with exceptions being ignored sometimes

* Add tests for extension toHaveLength

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-26 03:32:28 -07:00
Dylan Conway
62f05ec103 avoid using null value 2023-05-25 23:07:18 -07:00
Jiri Spac
1f7ad0cc37 add a bit more info on Elysia (#3062) 2023-05-25 22:04:07 -07:00
Alex Lam S.L
4c566f56c1 [install] fix .bin linking (#3067)
- causes intermittent `bun install` failures on `bun-types`
2023-05-25 21:58:30 -07:00
Dylan Conway
b395836080 jsx runtime from env (#3076)
* use `NODE_ENV` for jsx mode

* check env after `configureRouter`

* get `NODE_ENV` from `options.production`
2023-05-25 21:39:01 -07:00
Dylan Conway
801881dd7d update jsx test for classic runtime 2023-05-25 20:54:39 -07:00
Jarred Sumner
7b4bba787d prettier 2023-05-25 18:14:01 -07:00
Ciro Spaciari
e95f9c6daa [stream] fix flush (#3073)
* fix flush

* remove logs
2023-05-25 16:41:00 -07:00
Jarred Sumner
50bad43dbe Remove paragraph that has incorrect information in the docs 2023-05-25 16:16:16 -07:00
Dialga
48997eaeba Update sqlite.md (#3063)
fix serialize example
2023-05-25 10:14:29 -07:00
Jarred Sumner
f02561530f Bump 2023-05-24 19:54:00 -07:00
Jarred Sumner
88d9bac5ec Support with { type: "macro"} in bun build (#3059)
* [bun macro] Support `assert { type: "macro" }` and `with {type: "macro"}`

* [bun macro] Pass through input as arguments instead of a JSNode

* Fix hang when loading many entry points simultaneously with macros

* do not clone

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-24 19:37:57 -07:00
Jarred Sumner
63740a382b Load .env.test, set NODE_ENV=test in bun test, load .env.{test,production,development}.local (#3037)
* Support `.env.test` & `.env.{test,production,development}.local`

* Fix bug preventing inlining of process.env.NODE_ENV by default

* Update env_loader.zig

* add env tests

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: dave caruso <me@paperdave.net>
2023-05-24 18:52:50 -07:00
Ciro Spaciari
ed1f62ffff [server.fetch] call when using Request object (#3051)
* patch server.fetch

* add tests and fix types
2023-05-24 18:52:13 -07:00
Dylan Conway
4972934189 fix setting jsxImportSource, jsxFactory, and jsxFragmentFactory (#3057)
* default automatic, merge jsx flags from multiple tsconfigs

* use entire package name

* some tests

* more tests
2023-05-24 18:33:28 -07:00
Jarred Sumner
d73bce058a don't do MMD in CI 2023-05-24 18:31:33 -07:00
Ciro Spaciari
10c018df8e [bun:FileSystemRouter] add more validations on parameters (#3053)
* add validations and allow relative path on  dir

* remove unneed things

* add origin/dir validation tests

* remove workaround

* add back relative path resolution
2023-05-24 16:36:20 -07:00
Jarred Sumner
29969bc130 Add comment 2023-05-24 15:45:39 -07:00
Jarred Sumner
1ea74238cd Remove that field 2023-05-24 15:44:22 -07:00
Jarred Sumner
3361814cab Fix string check 2023-05-24 15:44:02 -07:00
Jarred Sumner
cc84c689ea Fixes #3031 (#3041)
* Fixes #3031

* Leave original input in there

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-24 12:02:33 -07:00
Jarred Sumner
b3d5f37598 Implement require.cache (#3045)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-24 12:01:59 -07:00
Alex Lam S.L
31c967206a extend test time-outs (#3048)
- avoid intermittent failures due to network latencies
2023-05-24 08:33:18 -07:00
Ashcon Partovi
c3d402ce47 Implement bun test --timeout (#3040)
You can change the default per-test timeout in `bun test`:
 > bun test --timeout 10

The default timeout is 5000.
2023-05-23 22:33:32 -07:00
Kruithne
d9bdfcf131 Fix incorrect URL in loaders.md (#3025) 2023-05-23 18:08:24 -07:00
Jarred Sumner
6074d4e378 workaround 2023-05-23 18:07:23 -07:00
Jarred Sumner
57d341f390 too noisy 2023-05-23 16:57:02 -07:00
Bill Mill
bf759b62c6 Add pkg-config as a build requirement (#3027)
Without pkg-config, the libarchive build fails in autogen.sh[1]

1: https://github.com/libarchive/libarchive/issues/742
2023-05-23 16:06:35 -07:00
dave caruso
5b0fea7093 fix bun init and update node vm docs (#3014) 2023-05-23 15:02:39 -07:00
Dylan Conway
21002ed405 check if key from exports can be printed as an identifier (#3032)
* check if key can be printed as an identifier

* possibly escape
2023-05-23 14:56:03 -07:00
Ashcon Partovi
2a669a657a Support test.todo() in ecosystem runner 2023-05-23 13:39:58 -07:00
Jarred Sumner
f71eb39b14 [bun:test] Don't schedule the GC aggressively on every file
We already run the GC automatically whenever heap size grows, so this is mostly unnecessary

In one benchmark, this is an 83% performance improvement at a cost of 9% more memory
2023-05-23 00:44:56 -07:00
Jarred Sumner
de185bdc05 Skip failing tests 2023-05-23 00:42:02 -07:00
Jarred Sumner
1e3476ee08 [bun:test] Fix async/done-based test.todo (#3015)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-23 00:40:41 -07:00
Jarred Sumner
5b38c55c3d Support setting a timezone with process.env.TZ and Bun.env.TZ (#3018)
* Support setting a timezone via `process.env.TZ`

* Implement `setTimeZone` in `bun:jsc` module

* [breaking] `bun:test` now defaults to `Etc/UTC` timezone

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-23 00:40:12 -07:00
dave caruso
83e7b9e198 fix extra/ArbitraryModuleNamespaceIdentifiers2 (#3016)
* fix extra/ArbitraryModuleNamespaceIdentifiers2

* remove assert
2023-05-22 20:59:25 -07:00
Jarred Sumner
879fd45ea2 Update .prettierignore 2023-05-22 20:10:00 -07:00
dave caruso
e5501551f4 add some connect test and type changes (#3013) 2023-05-22 19:48:07 -07:00
Ciro Spaciari
e57dcdfcf1 fix marking requestCert (#3012) 2023-05-22 19:44:32 -07:00
Jarred Sumner
5cfa5edd63 [node:http] Fix return type for getHeader() (#3007)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-22 19:44:21 -07:00
dave caruso
fc40c690ea Write out builtins with TypeScript + Minify them (#2999)
* start work drafting how builtins will work

* work on ts builtin

* builtins stuff so far

* builtins

* done for today

* continue work

* working on it

* bindings so far

* well, it builds. doesnt run

* IT RUNS

* still lots of ts errors but it is functional

* sloppy mode
2023-05-22 18:51:05 -07:00
Ciro Spaciari
23d42dc237 443 should default to https when no protocol is informed (#3008) 2023-05-22 17:58:32 -07:00
Jarred Sumner
e869fc092f [node:buffer] Add missing inspect function
cc @paperdave
2023-05-22 13:53:24 -07:00
Jarred Sumner
2a6a5cf6d9 [node:vm] Accept undefined in createContext 2023-05-22 13:53:24 -07:00
Ciro Spaciari
eebf44c709 fixup (#3001) 2023-05-22 13:07:51 -07:00
Jarred Sumner
05e98ed5d1 Skip test 2023-05-22 12:29:22 -07:00
Jarred Sumner
b71fa2b6d7 Skip more tests 2023-05-22 12:29:15 -07:00
Jarred Sumner
82e762fe2f [breaking] ServerWebSocket.publish no longer publishes to self by default
This changes `publishToSelf` to be `false` by default instead of `true`.

This is a breaking change because it means that `ws.publish("foo", "bar")` will exclude `ws` from the list of websockets to broadcast.

We are making this change because many people asked for this and were confused by the status quo - that `w.publish` publishes to self.
2023-05-22 12:29:10 -07:00
Jarred Sumner
a5acf7bfa0 [ServerWebSocket] binaryType now defaults to "nodebuffer"
Previously, this defaulted to "uint8array", so this shouldn't be a breaking change unless you make use of `.slice()` in which case it will now be a reference to the same ArrayBuffer rather than a clone.

The rationale for this change is most usages of Uint8Array on the server need a little more than just the bytes. Many npm packages expect Buffer rather than Uint8Array. Directly returning it for binary websocket messages is faster than creating another one.
2023-05-22 11:46:39 -07:00
Dylan Conway
3de350b24d only merge if kind is var 2023-05-22 11:33:01 -07:00
dave caruso
2e54601a2d document arch linux workaround, see #2664 (#2997) 2023-05-22 10:10:04 -07:00
Jarred Sumner
1f0dfacc0d Fix memory leak in fetch(url) (#2989)
* Fix memory leak in `fetch(url)`

* Bump those numbers up

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-22 10:09:30 -07:00
Jarred Sumner
7e17a91a1c Update WebKit 2023-05-22 10:08:33 -07:00
Jarred Sumner
3cbb1a429c Skip hanging tests 2023-05-21 23:28:02 -07:00
Jarred Sumner
8b3952baf9 Fix test 2023-05-21 21:31:38 -07:00
Jarred Sumner
24e0c269d2 [internal] Even more logging 2023-05-21 21:30:05 -07:00
Jarred Sumner
9f935c4683 [internal] Use HiveArray instead of bespoke memory allocator in Bun.serve()
No performance or memory usage change

Just removing some duplicate code
2023-05-21 21:29:17 -07:00
Jarred Sumner
3c57911b59 Fix assertion failure 2023-05-21 21:27:33 -07:00
Jarred Sumner
1a2a52b3f3 oopsie 2023-05-21 20:13:40 -07:00
Ciro Spaciari
fd21243efd WS send with callback (#2986)
* WS send with callback

* add opts.compress support

* fmt

* compress is the only option we care

* add ws client options

* only change ws client when using blob

* fmt

* fix errors

* fixup

* fixup

* fmt
2023-05-21 19:36:42 -07:00
Jarred Sumner
d90f7c7bf6 [Bun.serve] Support "nodebuffer" binaryType in ServerWebSocket 2023-05-21 19:20:40 -07:00
Jarred Sumner
91c9bd9dcc [WebSocket] Implement "nodebuffer" binaryType 2023-05-21 18:34:00 -07:00
Jarred Sumner
7d682c0fe7 [ws client] Make it a little more type safe 2023-05-21 15:23:02 -07:00
Jarred Sumner
b6007a860e [internal] Add more debug logs for uws 2023-05-21 14:30:36 -07:00
Jarred Sumner
eb3765ef93 [internal] Add a 0 byte to EOF read files as a precaution 2023-05-21 14:30:17 -07:00
Jarred Sumner
b33f20d51b [internal] Make AbortSIgnal usage slightly safer 2023-05-21 14:29:02 -07:00
Jarred Sumner
1e307e7690 Add extra flag just to be sure 2023-05-21 14:28:09 -07:00
Jarred Sumner
6e6d34eca7 [internal] Fix potential missing callbacks in AbortSignal 2023-05-21 14:00:32 -07:00
Jarred Sumner
9834cba762 Add node:vm types 2023-05-21 12:41:15 -07:00
Ciro Spaciari
3870f674f9 fix(tls.connect) fix SNI on tls sockets and also servername (mongodb) (#2934)
* fixes SNI on tls sockets and also servername

* 💅

* 💅

* add support for https and wss

* fix bun types

* support Bun.file on ca, key and cert

* 💅

* add setTimeout (makes fastify run)

* fix httpVersion

* fix WebSocketServer and add listen event

* fix ws exports and http listening

* fix default import

* bump uws

* add nodebuffer compatibility

* fix drain and allow more passing tests to run

* fix enqueud messages

* default to arraybuffer

* fix constructor binaryType

* fmt

* fixup

* skip some tests

* skip more

* skip fault tests

* reuse encoder instance

* fix handshake WS Client

* temporary revert handshake fix

* fix handshake

* disable all socket.io test temp

* fixup

* add back socket.io tests

* use node_fs to read cert, ca and key on server.zig

* throw the error returned by NodeFS

* 💅
2023-05-21 09:50:53 -07:00
Jarred Sumner
12b34c6258 Add watch mode page 2023-05-21 01:29:57 -07:00
Jarred Sumner
34af34db9f Update extending.md 2023-05-21 01:21:13 -07:00
Jarred Sumner
a29ee9f9a2 Update extending.md 2023-05-21 01:20:21 -07:00
Jarred Sumner
7ad1fc4f8f Update extending.md 2023-05-21 01:18:43 -07:00
Jarred Sumner
40ee435a4b More documentation 2023-05-21 01:17:21 -07:00
Jarred Sumner
ae8fc25b58 Update extending.md 2023-05-21 00:57:44 -07:00
Jarred Sumner
ef9555b9e1 Update extending.md 2023-05-21 00:56:13 -07:00
Jarred Sumner
3c2ac63d6e Update extending.md 2023-05-21 00:56:05 -07:00
Jarred Sumner
fdd5d49fe3 Update extending.md 2023-05-21 00:55:03 -07:00
Jarred Sumner
b27f4ceb9c Update extending.md 2023-05-21 00:53:50 -07:00
Jarred Sumner
1888c2df22 Update extending.md 2023-05-21 00:53:00 -07:00
Jarred Sumner
08043c5274 Update extending.md 2023-05-21 00:50:25 -07:00
Jarred Sumner
40de6d8cda Update extending.md 2023-05-21 00:49:55 -07:00
Jarred Sumner
d5c9e5ee79 Add --preload docs 2023-05-21 00:48:25 -07:00
Jarred Sumner
def8824bc2 Upgrade WebKit (#2980)
* [internal] Show the file path to the calling function from JS

* [internal] Make `JSC.NewFunction` more type safe

* Upgrade WebKit

* Finish

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-21 00:20:04 -07:00
Jarred Sumner
5a38c4bc0a Fixes #2976 2023-05-20 23:46:46 -07:00
Jarred Sumner
7a91d40a24 [bun:test] Add tests for --preload with beforeAll, afterAll, afterEach, beforeEach 2023-05-20 23:22:58 -07:00
Jarred Sumner
b16ddd95d9 [bun:test] preload now supports beforeAll, beforeEach, afterAll, afterEach hooks
Towards #198
2023-05-20 23:22:12 -07:00
Jarred Sumner
76e92abc7e Fix missing arg 2023-05-20 22:57:05 -07:00
Jarred Sumner
db062a7c30 [bun:jsc] Rewrite describe -> jscDescribe to not confuse them in autocomplete 2023-05-20 22:56:53 -07:00
Jarred Sumner
5959418605 Bun.inspect gets a max depth of 32 2023-05-20 22:02:09 -07:00
Jarred Sumner
ee40d9c3b4 [bun:test] Make forEachPropertyOrdered behave closer to forEachProperty
When diffing, we were missing some properties due to not calling getters and other types of properties

This led to situations where Bun.deepEquals would report false and then display no difference

This aligns the behavior closer to forEachProperty

cc @dylan-conway please let me know if this is going to break anything
2023-05-20 22:02:09 -07:00
Jarred Sumner
cd28c2cd2b [console.log] Set depth limit to 8
Towards #198
2023-05-20 22:02:09 -07:00
Jarred Sumner
50bb4749af [internal] Make JSC.NewFunction more type safe 2023-05-20 22:02:09 -07:00
Jarred Sumner
ff4df6b600 [internal] Show the file path to the calling function from JS 2023-05-20 22:02:09 -07:00
Degreat
0e97f91f9f Implement test.todo (#2961)
* Implement `test.todo`

* remove skip condition

* Allow callbacks in .todo

* Add descriptive comment

* Log todos

* Include tests in title

* edit test.todo tests

---------

Co-authored-by: dave caruso <me@paperdave.net>
2023-05-20 22:03:55 -04:00
Jarred Sumner
367f3a9c81 [bun:test] Fix bug where indexed properties would print "undefined" in diffs 2023-05-20 17:14:48 -07:00
Jarred Sumner
89e87a9050 [bun:test] Fix bug where indexed properties would print "undefined" in diffs 2023-05-20 17:12:50 -07:00
Jarred Sumner
7cf674a253 Support test timeouts in bun:test (#2969)
* [bun:test] Support timeouts in `test`

* make this test more resilient

* ✂️

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-20 17:04:51 -07:00
Jarred Sumner
e453b0e7c1 smol 2023-05-19 22:41:37 -07:00
e3dio
1973975ce0 fix #2964 (#2965) 2023-05-19 20:44:59 -07:00
Jarred Sumner
4db3d793cf console.log changes (#2966)
* [breaking] Don't quote property names of identifiers in console.log

* Make UTF-16 strings green

* always quote for jest

* update tests

* Update this

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-19 19:50:06 -07:00
Jarred Sumner
0b6a32269f ensure unused variable is not eliminated 2023-05-19 19:36:27 -07:00
Jarred Sumner
a3841a7de9 Fix failing node:vm tests 2023-05-19 19:35:05 -07:00
Ashcon Partovi
386ac374d5 Add tests for node:vm 2023-05-19 18:40:01 -07:00
Dylan Conway
9306103949 make sure key is added to args (#2968) 2023-05-19 18:22:54 -07:00
Jarred Sumner
12d841a3f5 [node:vm] Fix crash in syntax error in runinThisContext 2023-05-19 18:21:42 -07:00
Jarred Sumner
deeccb0dc4 [node:vm] Handle exceptions in runInThisContext and runInContext 2023-05-19 17:08:20 -07:00
Dylan Conway
aa34529b5b resolve rope string for multipart template (#2963)
* resolve rope for multipart template

* fix tests

* clone template part if it is `e_string` and folded

* clone string only

* don't clone data again
2023-05-19 16:04:38 -07:00
e3dio
4101eeabde update docs hot.md (#2954)
* Update hot.md

* Update hot.md
2023-05-19 15:23:24 -07:00
dave caruso
0036c3d8f5 Add tests for --compile tests (#2901)
* add compile test support

* add react ssr test

* add tests

* Fix flaky compile test

@paperdave we can't pass a non-zero port or it will be flaky

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-19 12:18:14 -07:00
Jarred Sumner
bf0f5c9b3d Make node-fetch polyfill better (#2962)
* Make `node-fetch` polyfill better

* fixup

* Test using localhost

* Add comment

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-19 12:12:54 -07:00
Jarred Sumner
9b28d2009d Add snippet for node:vm 2023-05-19 12:12:13 -07:00
Jarred Sumner
f910d791f9 [node:vm] Make vm.runInThisContext 10x faster 2023-05-19 11:18:11 -07:00
Zbyszek Tenerowicz
d6223c7f73 Fix typo (#2959) 2023-05-19 12:53:00 -04:00
Dylan Conway
c3233f1b21 set node_allocator for sourcemap joiner (#2953) 2023-05-18 19:39:31 -07:00
Jarred Sumner
a3e53b025e Make node:vm 12x faster 2023-05-18 19:27:02 -07:00
Jarred Sumner
f862ae4050 [node:vm] Propagate global properties defined on the new context object 2023-05-18 18:45:13 -07:00
Jarred Sumner
958f5f8b99 clang-format 2023-05-18 18:37:53 -07:00
Silver
ac64eb420d Implement node:vm (#2785)
* feat: begin implementing node:vm Script object

* refactor: clean up and address review comments

* refactor: rename Script to VMModuleScript

* fix: expose VMModuleScript.prototype

also oops I forgot to commit the new files last time

* feat(vm): Implement contexts and scripts

* feat(vm): implement globalThis

* feat(vm): expose node:vm module with global helper functions

* refactor(vm): rename VMModuleScript to NodeVMScript

* feat: implement script options

* doc: add TODOs for runIn*Context options
2023-05-18 16:45:18 -07:00
Jarred Sumner
b76974a2a8 Fixes #2924 2023-05-18 14:41:50 -07:00
Jarred Sumner
5bec0252a0 handle when cwd is not writable, attempt to use tmp dir explicitly
Fixes https://github.com/oven-sh/bun/issues/2944
2023-05-18 14:21:19 -07:00
Jarred Sumner
f7f0acbcd3 Bump 2023-05-18 13:41:16 -07:00
Jarred Sumner
f3a1a3bb2b Fixes #2946 (#2949)
* Fixes #2946

* Update string_mutable.zig

* Fixes #2948

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-18 13:27:05 -07:00
Jarred Sumner
755c0d62c4 Fixes #2942 (#2947)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-18 12:35:34 -07:00
Degreat
228ca3269a Implement expect().toBeCloseTo() (#2870) 2023-05-18 11:32:31 -07:00
Dylan Conway
621232c197 use raw template contents for tagged templates (#2937)
* use raw template contents when tagged

* use union for template contents

* pointer to cooked contents

* raw if suffix

* fix and don't skip test
2023-05-18 10:52:34 -07:00
Jarred Sumner
642b3978a6 Fixes #2928 (#2939)
* Fixes #2928

* another case

* Fix console.log with utf-16 string mismatched quotes

* Fix issue with json

* Even more cases

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-18 10:38:50 -07:00
Jarred Sumner
17c258eb34 Update fs.test.ts 2023-05-17 20:51:38 -07:00
Jarred Sumner
aacbef3cf9 Mention setting target to "node" or "bun" when a ResolveMessage occurs for a Node.js builtin 2023-05-17 20:29:35 -07:00
Jarred Sumner
4f7198f780 Fixes https://github.com/oven-sh/bun/issues/2931 2023-05-17 20:19:31 -07:00
Jarred Sumner
21086c3a78 Update benchmarking.md 2023-05-17 18:52:29 -07:00
Jarred Sumner
206b85e5db Support static string values in our class bindings generator 2023-05-17 18:52:23 -07:00
Jarred Sumner
25447426f1 Make BuildError and ResolveError use C++ instead of JSC C API
Fixes memory leak with private data never being cleared
Fixes a case where a ResolveError could actually be a BuildError
2023-05-17 18:51:50 -07:00
Jarred Sumner
67f543daa7 Update json-parse-stringify.mjs 2023-05-17 12:25:19 -07:00
Jarred Sumner
6c847f638f microbenchmark for json.parse / stringify 2023-05-17 12:12:42 -07:00
Jarred Sumner
8d90d79587 Bump 2023-05-17 12:06:43 -07:00
Jarred Sumner
59adc6cb78 Merge branch 'jarred/webkit-upgrade-may-17' 2023-05-17 11:36:24 -07:00
Jarred Sumner
bff465a2a2 Finish bumping 2023-05-17 11:34:37 -07:00
Bryce Kalow
fb7fb0a537 fix: bun-plugin-server-components name (#2919) 2023-05-17 11:04:40 -07:00
dave caruso
f1b16cd36a do not fail bundles on warnings (#2920) 2023-05-17 10:25:56 -07:00
Jarred Sumner
84fd6a514a Do the WebKit upgrade 2023-05-17 09:55:24 -07:00
Dylan Conway
bf1216021e resolve rope before pushing to previous string (#2909) 2023-05-16 17:19:56 -07:00
Harry Yep
2f4162e692 fix: broken link (#2897) 2023-05-16 17:08:45 -07:00
dave caruso
ad20b13985 Fix segfault on passing undefined to bun.build (#2902) 2023-05-16 17:08:00 -07:00
Dylan Conway
1ad8c54c90 fix asset naming output paths (#2904)
* rename to `src_path` and `dest_path`, use `dest_path` for output

* format

* option for compile
2023-05-16 17:07:40 -07:00
Jarred Sumner
78229da760 Bump 2023-05-16 11:44:03 -07:00
Jarred Sumner
3adadffc0e Fixes #2895 2023-05-16 11:43:09 -07:00
Colin McDonnell
366eba78f0 Tweaks to bundler docs (#2867)
* WIP

* Fix typo

* Updates

* Document --compile

* Add bundler benchmark

* Remove esbuild

* Add bench to docs

* Add buttons

* Updates
2023-05-16 10:47:00 -07:00
Jarred Sumner
60bc804c58 Bump 2023-05-16 09:31:04 -07:00
Jarred Sumner
65237b3054 Update run-cjs.test.ts 2023-05-16 08:52:14 -07:00
dave caruso
c842f5bfe3 Fix running commonjs modules as entry point (#2885)
* fix cjs run issue

* use a primordial

* fix behavior

* fix it again

* fix tste
2023-05-16 08:49:35 -07:00
Ciro Spaciari
fe74c948cd feat(WebSocketServer) WebSocketServer wrapper + socket.io initial support (#2880)
* WebSocketServer wrapper + socket.io initial support

* fix up backpressure

* fix up backpressure

* fix http address

* add socket.io tests

* add closing tests

* add connection state recovery tests for socket.io

* add handshake test

* add middeware tests for socket.io

* added socket.io socket middleware tests

* add more socket.io test comment/skip  hang tests

* add pending package for tests

* add server attachment servers for socket.io

* add utility-methods tests for socket.io

* rename

* rename

* add messaging-many socket.io tests

* add namespaces tests to socket.io

* skip some tests

* fmt

* add packages to general package.json
2023-05-16 08:48:17 -07:00
Dylan Conway
9c85483a81 handle printing missing expressions and add tests (#2872)
* handle missing expressions and add tests

* minify missing expression blocks in parser
2023-05-15 21:50:44 -07:00
dave caruso
29572737ab bundler testing (#2886)
* bundler testing

* add requireVarThenExport test

* work towards adding more esbuild tests

* tests

* remove this file
2023-05-15 21:18:52 -07:00
dave caruso
dce4a15e69 Change the debug id suffix to hex encoded "bun!bun!" (#2890) 2023-05-15 21:15:32 -07:00
Colin McDonnell
a52715597a Add plugins for yaml & RSC (#2888)
* WIP

* WIP

* Add yaml plugin

* Publish v0.0.1

* Updates

* Start RSC plugin - not finished

* Add readme

* Updates

* Add shell dirs for a few other plugins
2023-05-15 20:37:03 -07:00
Jarred Sumner
b2a750e186 remove incorrect comment 2023-05-15 10:55:35 -07:00
Jarred Sumner
dd11f02a45 [bun build] builds w/ sourcemaps get 15% faster
parallelize quoting source contents
2023-05-15 08:49:54 -07:00
Jarred Sumner
1088a22802 Add TODO 2023-05-15 06:33:20 -07:00
Jarred Sumner
9076a981e8 Set files with #! as executable 2023-05-15 06:31:21 -07:00
Jarred Sumner
8eaf30c022 [bun build] Automatically set target to bun when a hashbang is provided 2023-05-15 06:30:55 -07:00
Jarred Sumner
0a879be328 [bun build --compile] Avoid creating holes 2023-05-15 05:57:46 -07:00
Jarred Sumner
ddb6de2fe6 [bun build --compile] Add some retry logic for opening the files 2023-05-15 05:57:27 -07:00
Jarred Sumner
8a68f3aa71 Remove unused dockerfile 2023-05-15 05:19:24 -07:00
Jarred Sumner
386eec31ac More error message cleanup 2023-05-15 05:17:15 -07:00
Jarred Sumner
9c19383843 Fix crash when importing a file with an unknown extension 2023-05-15 04:35:59 -07:00
Jarred Sumner
47d2e2cb19 Make bun build --compile a little more resilient, output better errors, and clean up files 2023-05-15 04:35:21 -07:00
Jarred Sumner
4d751db27a More DCE 2023-05-15 02:36:43 -07:00
Jarred Sumner
4ec2ed4f6c Fix broken test 2023-05-15 01:56:59 -07:00
Jarred Sumner
e7e4030299 Fix bug with req.url set incorrectly (#2881)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-15 01:52:51 -07:00
Jarred Sumner
d3a72a1254 Set more things to const 2023-05-15 00:00:13 -07:00
Jarred Sumner
44417e9d1e github actions doesn't like SSH submodules 2023-05-14 23:51:24 -07:00
Jarred Sumner
9acf854f5b Workaround https://github.com/ziglang/zig/issues/15715 2023-05-14 23:38:55 -07:00
Jarred Sumner
8cce69e7c2 wip 2023-05-14 23:14:45 -07:00
Jarred Sumner
a425376c3d Fix process.argv with standalone 2023-05-14 23:09:19 -07:00
Jarred Sumner
c367408233 a little less inline 2023-05-14 21:15:35 -07:00
Jarred Sumner
328d09129a Fix scope chain bug 2023-05-14 20:56:06 -07:00
Ciro Spaciari
e096a03e3e fix(spawn) add Uint8Array support for stdout (#2866)
* add array_buffer support for stdout

* fix comment

* fix param name on baby_list

* keep test names consistent

* add more test cases
2023-05-14 10:22:02 -07:00
Ciro Spaciari
bf9e40d5b4 feat(Timer.refresh) add refresh support on Timer (#2874)
* add refresh support on Timer

* fix this return

* add refresh setTimeout tests

* fix tests and add setInterval test

* use setCached for arguments and callback

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-05-14 10:18:56 -07:00
Jarred Sumner
2a66229b0f fixup 2023-05-14 06:31:17 -07:00
Jarred Sumner
688637d835 fix flags 2023-05-14 06:30:47 -07:00
Jarred Sumner
893f70fee4 Single-file standalone Bun executables (#2879)
* Add LIEF

* Compile LIEF

* Implement support for embedding files on macOS

* proof of concept

* Add zstd

* Implement runtime support

* Move some code around

* Update .gitmodules

* Upgrade zig

https://github.com/ziglang/zig/pull/15278

* leftover

* leftover

* delete dead code

* Fix extname

* Revert "Upgrade zig"

This reverts commit dd968f30bf.

* Revert "leftover"

This reverts commit 7664de7686.

* Revert "leftover"

This reverts commit 498005be06.

* various fixes

* it works!

* leftover

* Make `zig build` a little faster

* give up on code signing support

* Support Linux & macOS

* Finish removing LIEF

* few more

* Add zstd to list of deps

* make it pretty

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-14 06:13:39 -07:00
dave caruso
7f25aa9e08 windows path compatibility (#2869)
* winndows path compatibility

* change * to "star" and fix import

---------

Co-authored-by: cirospaciari <ciro.spaciari@gmail.com>
2023-05-12 17:39:28 -03:00
Ciro Spaciari
f48f48795b proper stub for sockets (#2868) 2023-05-12 09:27:17 -07:00
Jarred Sumner
8f3b648602 finish #2864 2023-05-12 08:53:23 -07:00
Dylan Conway
5f897589fc disable sloppy mode block level functions when not bundling (#2864)
* enable only during bundling

* add `willUseNumberRenamer()`
2023-05-12 08:32:24 -07:00
Dylan Conway
4d5d0d075a root bundle option (#2859)
* handle multiple output files and `[dir]`

* get the realpath of `root_dir`

* duplicate output paths

* add `rootdir` to `JSBundler`

* use realpath of input file

* add tests for naming and root

---------

Co-authored-by: Dave Caruso <me@paperdave.net>
2023-05-12 07:33:07 -07:00
Jarred Sumner
c815716899 [bundler] Don't wait on sourcmaps that don't exist 2023-05-12 07:28:56 -07:00
Jarred Sumner
6f0f506e95 [bundler] De-optimize import defaultIdentifier from './foo.cjs' 2023-05-12 07:28:40 -07:00
Jarred Sumner
da10cd6010 [bundler] Empty ESM gets undefined, empty CJS gets {} 2023-05-12 07:27:53 -07:00
Jarred Sumner
a46d3162ae Fix importstar_ts/ReExportTypeOnlyFileES6 2023-05-12 07:27:25 -07:00
Jarred Sumner
02a8f99629 sort more 2023-05-12 07:27:15 -07:00
Jarred Sumner
20f1057a7d Fix a couple tests 2023-05-12 07:27:09 -07:00
Jarred Sumner
f6bbfb16fd Add a couple tests 2023-05-12 07:27:03 -07:00
Jarred Sumner
b5c70814e5 handle errors + sort things 2023-05-12 07:21:57 -07:00
Jarred Sumner
8340b98352 [bundler] Disable export star redirect code size optimization 2023-05-12 07:14:48 -07:00
Jarred Sumner
d2e09ce519 [bundler] Fix export * from ./my-cjs-file.cjs' 2023-05-12 04:11:21 -07:00
Jarred Sumner
1e450dbcab [bundler] Implement export * from code size optimization 2023-05-12 04:11:21 -07:00
Jarred Sumner
231da81528 [bundler] Fix --transpile --outfile 2023-05-12 04:11:21 -07:00
Ciro Spaciari
6070e135e9 fix proxy status return (#2860) 2023-05-12 08:06:17 -03:00
Ciro Spaciari
f8c840aec7 fix large stdout output (#2850)
* fix large stdout output

* remove skip from #2674 for testing

* add big stdout test using spawnSync

* add bunEnv on big stdout test
2023-05-12 08:05:46 -03:00
Jarred Sumner
273ccbc241 [bundler] Fix bug with export default TypeScriptType 2023-05-12 02:02:35 -07:00
Jarred Sumner
3f01e2a519 alphabetize 2023-05-12 01:49:17 -07:00
Jarred Sumner
b0908b7b13 Fix test 2023-05-12 01:49:07 -07:00
Jarred Sumner
5b3e18e028 Fix regression 2023-05-12 01:49:00 -07:00
Jarred Sumner
155110a03a Fix our tree shaking optimization 2023-05-11 23:19:21 -07:00
Jarred Sumner
3bb5c45385 Fix require() on a converted file 2023-05-11 23:18:36 -07:00
Jarred Sumner
e785b0872a Fix tree shaking flag 2023-05-11 23:17:06 -07:00
Jarred Sumner
99cce67d61 enable tree shaking 2023-05-11 21:40:47 -07:00
dave caruso
4381204cdb oops (#2863)
* oops

* oops part 2
2023-05-11 21:25:03 -07:00
Jarred Sumner
0cee7c028a woops 2023-05-11 20:05:46 -07:00
Jarred Sumner
bfcc0b8960 handle module.exports.foo = class {} in the entry point in the runtime
Related to https://github.com/oven-sh/bun/issues/2862, but does not fix it
2023-05-11 20:01:10 -07:00
dave caruso
dfd0f3e252 Allow reading config from within plugins, and partially implement esbuild initialOptions (#2861)
* Implement plugin build.config and initialOptions

* update types

* default initialoptions entrypoints
2023-05-11 22:58:41 -04:00
Jarred Sumner
136b50c746 formatting 2023-05-11 19:31:55 -07:00
Jarred Sumner
5bb42c81e4 give up on this optimization so we can ship 2023-05-11 19:31:39 -07:00
Jarred Sumner
a008e49a40 forgot to commit this 2023-05-11 15:14:43 -07:00
Jarred Sumner
56b8458c62 call stop before emit 2023-05-11 15:10:40 -07:00
Jarred Sumner
7141e19a10 fixup 2023-05-11 15:10:06 -07:00
Jarred Sumner
5c08200b18 [node:http] handle errors generated by fetch 2023-05-11 15:09:30 -07:00
Jarred Sumner
d67bdb7e9b [node:http] Fix close() to accept a callback and implement closeAllConnections 2023-05-11 15:09:14 -07:00
Jarred Sumner
77eb61a1fe Fix OutputKind, add "use client" and "use server" 2023-05-11 15:08:18 -07:00
dave caruso
6a163cf933 bundler tests and improve Bun.build return type (#2833)
* importstar_ts

* tests

* run acorn test suite

* bench tweaks

* test

* bun.build tests very incomplete

* remove dataurl and base64 loaders from tests since they dont work yet

* tests

* stuff

* stuff

* add errors and array of blobs

* work so far

* docs

* requested changes

* fix overwrite docs

* remove this file
2023-05-11 14:42:54 -07:00
Dylan Conway
02cad591f8 fix child process tests (#2584)
* always handle exit on next tick

* emit spawn immediately
2023-05-11 14:39:44 -07:00
Ciro Spaciari
3530cfac68 fix redirect: \'manual\' and setTimeout on node:http request (#2848) 2023-05-11 14:25:21 -07:00
Ciro Spaciari
bc7d0adcf9 fix(fs) mkdtemp and mkdtempSync errors (#2851)
* fix mkdtemp

* fmt

* fix errno
2023-05-11 14:23:33 -07:00
Ciro Spaciari
d032b73b10 add tests for ws.close (#2844)
* add tests for ws.close

* add timeout on ws.close tests
2023-05-11 02:30:48 -07:00
Ciro Spaciari
9c166a1bdf add support for { all: true } option on dns.lookup (#2846) 2023-05-11 02:30:20 -07:00
Jarred Sumner
e125ed2aa3 Report timings for failing tests too 2023-05-11 01:16:46 -07:00
Jarred Sumner
5ffee9477c [bun test] Add timings to successful tests 2023-05-11 00:55:41 -07:00
Degreat
4b79b37a99 Implement describe.skip (#2836)
* Implement describe.skip

* Add more tests to cover hooks
2023-05-10 23:57:30 -07:00
Ciro Spaciari
f9831e1f6f feat(fetch) add redirect: 'error' support (#2845)
* add redirect: 'error' support

* fix typo

* fix typo

* refactor FetchRedirect enum

* fix FetchRedirect

* updated
2023-05-10 23:55:39 -07:00
Dylan Conway
8f4a5903ab make sure vars can be hoisted in catch scope (#2847) 2023-05-10 23:55:27 -07:00
Jarred Sumner
0e5f0940ee serialize 2023-05-10 23:30:30 -07:00
Jarred Sumner
9d3a95ed96 Add version 2023-05-10 23:03:37 -07:00
Jarred Sumner
2abfa84db7 Implement the benchmark snippet runner minus the sqlite serialization step 2023-05-10 22:50:56 -07:00
Dylan Conway
53fe8d61e7 object empty ast 2023-05-10 21:53:38 -07:00
Jarred Sumner
e1c6adc737 Prepare to run these automatically 2023-05-10 21:37:08 -07:00
Jarred Sumner
5e0eedccb0 Fix test failure in scope order verification 2023-05-10 20:07:12 -07:00
Jarred Sumner
06a03df9a6 Fix assertion 2023-05-10 17:59:55 -07:00
Jarred Sumner
ed5dd3fee1 Fix incorrect assertion 2023-05-10 17:50:02 -07:00
Jarred Sumner
96dc0471ff Clean-up 85b4be5f71
- We don't need to make `Bun__fetch` exported in every C++ header file
- We shouldn't return JSObjectRef, its an unnecessary wrapper
- The version of `fetch` on the Bun global should be non-configurable so that it is safe for anyone who wants to use that without a user-modifiable one
2023-05-10 16:55:13 -07:00
Ciro Spaciari
85b4be5f71 fix(fetch) fix fetch inheritance (#2842)
* patch fetch function inheritance

* fmt

* fix reserveCapacity and number of arguments for fetch

* change Bun.fetch to use Fetch.jsFunction

* merge Fetch.jsFunction and Fetch.call

* remove commented code
2023-05-10 16:38:52 -07:00
Ciro Spaciari
643aa27a03 fix closing WS with code and reason (#2843) 2023-05-10 14:37:29 -07:00
Dylan Conway
e7d4f5fb16 use member from parent scope when hoisting (#2840) 2023-05-10 13:12:16 -07:00
Alex Lam S.L
5fd838b9e4 bun add from root folder when call within workspaces (#2841)
- ignore invalid `package.json` from parent directories
- `echo` new lines from `make` targets correctly
2023-05-10 17:22:01 +03:00
Jarred Sumner
5b2c3fe440 clarify the types more 2023-05-10 05:08:22 -07:00
Jarred Sumner
53a198f2f7 Update test 2023-05-10 04:22:03 -07:00
Jarred Sumner
982dc0b441 Implement BuildArtifact 2023-05-10 04:21:53 -07:00
Dylan Conway
1f8c60123d fix catch scope var declarations (#2839)
* use `catch_binding` kind and report errors

* make hash optional
2023-05-09 23:52:40 -07:00
Alex Lam S.L
4ccca13001 [install] operator on root package of workspaces (#2834)
- parse `bunfig.toml` from same directory as `package.json`
- handle `--cwd` correctly

fixes #2592
2023-05-10 08:26:29 +03:00
Jarred Sumner
1e8b9258b2 Expose bindings for Map 2023-05-09 21:47:18 -07:00
Jarred Sumner
c7c5dc1438 Add name property 2023-05-09 21:44:05 -07:00
Jarred Sumner
a5b3056c76 Fix extra semicolon 2023-05-09 21:41:05 -07:00
Jarred Sumner
e8989f9a60 Fix make headers (May 9th 2023 edition) 2023-05-09 21:05:33 -07:00
Jarred Sumner
4346f6afc0 RSC 2023-05-09 20:38:26 -07:00
Dylan Conway
38e72a528d code splitting option 2023-05-09 20:38:02 -07:00
Dylan Conway
eb2510170f resolve rope string before returning (#2838) 2023-05-09 20:33:26 -07:00
Dylan Conway
1d72bbe96c space before label (#2837) 2023-05-09 20:27:20 -07:00
Dylan Conway
a47e2c6021 add WebAssemblyInstance and WebAssemblyGCObject js types (#2835)
* add `WebAssemblyInstance` and `WebAssemblyGCObject`

* update c api
2023-05-09 18:37:50 -07:00
Jarred Sumner
5a18d24a96 Re-run builtins generator 2023-05-09 16:17:42 -07:00
Jarred Sumner
d1dd7a7ebb Add a comment 2023-05-09 15:40:51 -07:00
Jarred Sumner
65eb6db7fa Fix a memory leak in module resolution 2023-05-09 15:29:32 -07:00
Jarred Sumner
ce3c7d2961 bun build --transform should not run the module resolver 2023-05-09 15:27:04 -07:00
Jarred Sumner
ff1edca9ee Fix regression with bun test not recursively scanning the directory tree 2023-05-09 14:56:39 -07:00
Jarred Sumner
ffd48dc7a7 fix tracy i think 2023-05-09 14:32:26 -07:00
Dylan Conway
b3dc14ef0f don't replace with there isn't a star (#2825) 2023-05-09 14:20:46 -07:00
dave caruso
22b801bb89 fix #2820 (#2832) 2023-05-09 14:20:12 -07:00
Dylan Conway
c35518e6d6 Fixes #2807
we will look at the minify tests for uglifyjs too
2023-05-08 23:39:02 -07:00
Dylan Conway
232a25b77f add the class name to the current scope 2023-05-08 23:34:36 -07:00
Dylan Conway
e74207650b Fix bug with float minification 2023-05-08 23:07:14 -07:00
Dylan Conway
aa85d7af92 Fix incorrect fd usage 2023-05-08 22:54:25 -07:00
Jarred Sumner
0b52f9210a Add a couple helpers 2023-05-08 22:36:52 -07:00
Jarred Sumner
69ea6fd54f Fix memory issues with loader and define in JSBundler 2023-05-08 22:35:13 -07:00
Jarred Sumner
73b0d8a51c Make the enum serializer more flexible 2023-05-08 22:34:01 -07:00
Jarred Sumner
b874d0b387 ✂️ dead code 2023-05-08 22:32:04 -07:00
dave caruso
5e366872f6 implement build api define and loaders (#2805)
* parse error logs

* clean up types

* remove --jsx-production. use NODE_ENV instead

* add define to js api

* add loaders to js api

* fixups

* sourcemap

* typo fix

* remove label, comment dir just for now

* test tweaks

* test work

* make optional enums actually optional.
allows `sourcemap: undefined`

* overload host ram test

* string tests

* tests

* test for 2815

* requested changes

* sort this list

* remove this test file now that it passes

* oops

* add --format

* finish ts tests

* doc typos related to define and loader
2023-05-08 21:55:21 -07:00
Jarred Sumner
1a411e201b Add some comments 2023-05-08 21:32:17 -07:00
Jarred Sumner
4a2d89d865 ✂️ some dead code 2023-05-08 21:29:19 -07:00
Jarred Sumner
e422c849d5 Fix bug in Bun.build() where it wouldn't pick up changes to directories on rebuilds (#2824)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-08 21:14:56 -07:00
Ciro Spaciari
c6c21eeba7 added some improvements on server (#2803)
* added some improvements on server

* undo unintended change

* clean data handler before end calls

* refactor

* make ctx.resp nullable

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-05-08 14:10:40 -07:00
Jarred Sumner
14597dbcdc Don't leak file handles 2023-05-08 02:43:17 -07:00
Jarred Sumner
f9d6a61676 [fs] Add an extra byte to files we read 2023-05-08 01:45:10 -07:00
Jarred Sumner
3f895085a0 [fs] More logging 2023-05-08 01:44:50 -07:00
Jarred Sumner
81e4203efe [bundler] Make module resolution single-threaded 2023-05-08 01:44:08 -07:00
Jarred Sumner
db44f41dd0 Possibly fix the linux perf issue 2023-05-07 23:53:45 -07:00
Jarred Sumner
56bd410044 Reduce over-allocation 2023-05-07 23:52:05 -07:00
Jarred Sumner
35685bbc86 Reduce the size of the JS AST to attempt to resolve the linux performance issue 2023-05-07 22:33:59 -07:00
Jarred Sumner
af1cd23b8c Add tracy (#2817)
* Add tracy

* RTLD

* Linux needs LD_PRELOAD

* More tracing

* Inline this

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-05-07 21:08:32 -07:00
Jarred Sumner
d3ae9ac7ce experiment to try to fix linux bundler perf regression 2023-05-07 01:51:05 -07:00
Jarred Sumner
1fbfaa5ca1 Use dwarf v4 2023-05-07 01:50:20 -07:00
Jarred Sumner
243847f992 Add alignment feature flag 2023-05-07 01:04:38 -07:00
Jarred Sumner
25eecc3e07 Add latin1 identifier fast path 2023-05-06 23:36:37 -07:00
Jarred Sumner
0e1b934e27 Fix overflow 2023-05-06 19:52:46 -07:00
Jarred Sumner
2aa4fba99d 💅 2023-05-06 19:09:14 -07:00
Jarred Sumner
cf4d13dcc0 Fixes #2811 2023-05-06 19:06:52 -07:00
Jarred Sumner
4708835ae6 [minifier] Rewrite equality check logic 2023-05-06 18:23:37 -07:00
Jarred Sumner
8975717bc3 Fix several transpiler tests 2023-05-06 18:20:19 -07:00
Jarred Sumner
5327940132 Fixes https://github.com/oven-sh/bun/issues/2810 2023-05-06 18:16:21 -07:00
Jarred Sumner
54d5f59f09 Cleanup some of the log-related code 2023-05-06 16:32:29 -07:00
Jarred Sumner
46a0a4d984 [Bun.build] Add error when an onResolve plugin returns a namespace which has no loader 2023-05-06 16:32:06 -07:00
Jarred Sumner
70e850bf76 fix crash when there are lots of build errors 2023-05-06 16:31:46 -07:00
Jarred Sumner
d4b35d9ae6 Fix make headers 2023-05-06 13:19:41 -07:00
Jarred Sumner
f523b2187a Fix make headers 2023-05-06 13:19:23 -07:00
Jarred Sumner
41a59d0d03 Fix a memory leak 2023-05-06 13:19:11 -07:00
Jarred Sumner
9c9425bc8c Another .isFile() 2023-05-06 13:18:38 -07:00
Jarred Sumner
01ce690a01 Clone the logs more 2023-05-06 13:18:13 -07:00
Jarred Sumner
1da75791da Use isFile() helper 2023-05-06 12:52:55 -07:00
Jarred Sumner
3bc02e48ca Comment out buchta from docs
The repo is archived, so it should not appear in our docs
2023-05-06 12:41:03 -07:00
Jarred Sumner
9d7ecf7909 [misctools] Add cold jsc start test 2023-05-05 20:01:26 -07:00
Jarred Sumner
31cb49a026 [ci] Fix broken test runner
cc @Electroid we need `@actions/core` to be installed in node_modules
2023-05-05 18:34:43 -07:00
Jarred Sumner
f95a81e05d [napi] Fix crash in napi_create_external_buffer
This impacted LightningCSS when garbage collection ran. cc @devongovett
2023-05-05 17:16:47 -07:00
Jarred Sumner
c3d512f27e Fix valgrind tracking flag 2023-05-05 15:48:27 -07:00
Jarred Sumner
9a09f9f532 Fix bug where the Bun.file() returned by Bun.build() would have an incorrect path 2023-05-05 15:48:26 -07:00
Jarred Sumner
3a01316707 Cleanup how some of the server components stuff works 2023-05-05 15:48:26 -07:00
Kruithne
e00017f7b8 Add missing JSON API to Web APIs page (#2799)
* Add missing JSON API to Web APIs page

Unless I'm missing something obvious, it appears that Bun has the JSON API (`stringify`/`parse`) but is not listed anywhere in the documentation.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON

* Include JSON in global docs
2023-05-05 12:54:54 -07:00
Colin McDonnell
386639a4c5 Start esbuild migration guide. More docs. (#2787)
* Bundler docs updates. Start esbuild migration guide.

* Updates

* Add JS API comp

* Tweaks

* Updates

* Updates

* Updates
2023-05-05 12:53:38 -07:00
Dylan Conway
d9386a68a4 fix source map line offsets (#2791)
* find codepoint at `i`

* fix allocator usage

* missing comment

* switch to `Cursor` iterator
2023-05-04 22:44:02 -07:00
Jarred Sumner
945d069290 Add UNLIKELY 2023-05-04 17:09:59 -07:00
Jarred Sumner
7cb1404511 Revert "Add setNoDelay"
This reverts commit 8b6dd0c7e1.
2023-05-04 17:09:24 -07:00
Jarred Sumner
8e4f777d35 Throw error on non-file url 2023-05-04 17:09:10 -07:00
Jarred Sumner
8b6dd0c7e1 Add setNoDelay 2023-05-04 17:09:10 -07:00
Ashcon Partovi
c43c1b50ff Add no-op for ClientRequest.{setNoDelay,setTimeout} 2023-05-04 16:09:45 -07:00
Ashcon Partovi
1574ac7896 Only checkout test folder for ecosystem tests 2023-05-04 15:55:12 -07:00
Ashcon Partovi
a66137bdce Actually fix the git clone URL 2023-05-04 15:36:56 -07:00
Ashcon Partovi
b2abf82494 Use HTTPS instead of SSH for git clone in ecosystem tests 2023-05-04 15:35:58 -07:00
Ashcon Partovi
d68786909c Fix working directory of GitHub action 2023-05-04 15:33:33 -07:00
Ashcon Partovi
1183dd1a3f Add initial ecosystem tests (#2801)
* Add initial ecosystem tests

* Run ecosystem tests every morning, after canary release
2023-05-04 15:27:12 -07:00
Dylan Conway
8e18229d5d parse and visit catch body scope (#2796) 2023-05-04 08:21:33 -07:00
Jarred Sumner
243dfc177a Fix code splitting for server components 2023-05-03 23:48:18 -07:00
Jarred Sumner
f114e88bee Clean up edgecase causing plugins to be called too many times 2023-05-03 15:35:11 -07:00
Jarred Sumner
2d0eaf9842 Fix broken test 2023-05-03 15:32:15 -07:00
Jarred Sumner
101f0ee6ba re-enable our CJS optimization 2023-05-03 10:35:55 -07:00
Jarred Sumner
9b5caf7467 Implement synthetic default export 2023-05-03 00:55:06 -07:00
Jarred Sumner
b2a50671ab add deoptimization 2023-05-02 23:03:39 -07:00
Dylan Conway
ca776326cf entry_point_kinds only at source_index 2023-05-02 22:16:46 -07:00
Jarred Sumner
1346293619 Add missing function 2023-05-02 22:12:56 -07:00
Jarred Sumner
bc4a8bf595 Small refactor 2023-05-02 22:02:19 -07:00
Jarred Sumner
2bc449656e Visit the runtime 2023-05-02 22:02:19 -07:00
Jarred Sumner
6a74651eb4 Add helper fn 2023-05-02 22:02:19 -07:00
Dylan Conway
755874a9ea Fix checking for dynamic exports (#2792)
* only look at import records for the current source index

* skip `source_index` when it is invalid

* iterate `export_star_records` at `source_index`

* comment
2023-05-02 21:57:57 -07:00
Jarred Sumner
082bc62589 alignment 2023-05-02 19:57:44 -07:00
Jarred Sumner
2250f7a0c0 Add __ulock_wait2 polyfill
cc @kzc
2023-05-02 18:33:03 -07:00
Jarred Sumner
fe52627dea fix spacing 2023-05-02 11:58:24 -07:00
Jarred Sumner
6bdc158e9c Use pretty 2023-05-02 11:58:14 -07:00
Jarred Sumner
7a699c1ac2 Fix a couple spltiting bugs 2023-05-01 22:23:07 -07:00
Jarred Sumner
c5df4e9477 Compress let f; f=123 => let f = 123; 2023-05-01 21:00:51 -07:00
Jarred Sumner
b3c7d0ea23 Small improvement to minifier 2023-05-01 21:00:31 -07:00
Jarred Sumner
1af4e1dce1 Fixes #2783 2023-05-01 16:55:50 -07:00
Jarred Sumner
5d8027cd5a Fix test 2023-05-01 16:55:11 -07:00
Jarred Sumner
69b767fadc Update bundle_v2.zig 2023-05-01 15:24:10 -07:00
Jarred Sumner
44fbd7719e Fix some splitting bugs 2023-05-01 15:04:46 -07:00
Jarred Sumner
0b2422b1f3 Fix another crash 2023-05-01 13:01:30 -07:00
Jarred Sumner
331a3cec8c Fix crash 2023-05-01 12:24:28 -07:00
Revenity
c2a223802b Add StricJS to ecosystem (#2747)
* Create stric.md

* Update nav.ts

* Update stric.md

Add codetabs for ArrowJS

* Update stric.md

* Update stric.md
2023-05-01 10:37:39 -07:00
Ashcon Partovi
c19c522744 Fix error links in markdown summary 2023-05-01 09:01:41 -07:00
Ashcon Partovi
1fc8639177 Condense errors in test runner script 2023-05-01 08:48:40 -07:00
Jarred Sumner
fe57932dfb Add missing type for sqlite (#2764)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-04-30 23:36:32 -07:00
Will Richards 2
59b3556fab Bun Test matchers even/odd. Also, .toContains fix and truthy (#2754)
* bun test matcher tests for even/odd, few more truthy tests, and fix for contains empty string

* implementation of even/odd matchers

* didn't add the codegen bindings

* linted
2023-04-30 23:36:08 -07:00
Jarred Sumner
8b53b3ed88 FIx esm -> cjs require interop with converted CJS
TODO: make `default` namespace object for these not load the entire wrapper
2023-04-30 23:17:25 -07:00
Jarred Sumner
c0a1c76edb Fix garbled line text in some errors 2023-04-30 23:16:23 -07:00
Jarred Sumner
f26fef1010 Update options.zig 2023-04-30 22:41:07 -07:00
Jarred Sumner
f8b0730231 Fix missing imports in DCE tests 2023-04-30 22:34:23 -07:00
Jarred Sumner
fe14b7244d Fix missing "default" export condition 2023-04-30 22:34:13 -07:00
Dylan Conway
0490bd3d2e Implement source maps (#2770)
* wip

* Begin computing source map tables

* source map progress

* external source maps

* fix merge

* remove `@as` coercion

* inline source maps and output source map shifts

* fix `codeWithSourceMapShifts()` after merge

* remove second call to `findReachableFiles()`

* use `worker.allocator`, remove comment

* don't reuse memory for source and sourceContents

* don't reuse `quote_buf`

* fix writing to stdout

* Add comment

* Don't include a sourcemap if the text was empty

* Make the parser faster

* +16% faster sourcemap generation

@dylan-conway I'll need you to look this over to make sure I didn't mess anything up

Though it currently doesn't generate the offsets in the right order...

* 30% performance improvement to Bun.build()

* Print `debugId` in source maps

cc @mitsuhiko @notzeeg

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-04-30 22:09:40 -07:00
dave caruso
137dc6e19f test default condition (#2776) 2023-04-30 21:16:32 -07:00
Alex Lam S.L
c05a6744bb [install] handle devDependencies of local folders (#2781)
fixes #2653
2023-05-01 06:41:33 +03:00
Jarred Sumner
f54fbaf3ba prevent crash 2023-04-30 09:50:37 -07:00
Alex Lam S.L
dd03a4f95d [install] handle repeated install of GitHub dependency correctly (#2780)
fixes #2602
2023-04-30 09:45:08 -07:00
Jarred Sumner
4be3548829 add to symbols.txt 2023-04-30 00:55:09 -07:00
Jarred Sumner
c3dc64d468 Fix a load order issue 2023-04-29 21:37:04 -07:00
Jarred Sumner
bd1f9d8370 Fix some runtime issues caused by bundler 2023-04-29 21:14:21 -07:00
Jarred Sumner
0cb090f118 Fix garbled text in errors 2023-04-29 19:42:47 -07:00
Jarred Sumner
5fb014876b Fix plugin namespaces always being set to "flie" 2023-04-29 19:42:38 -07:00
Jarred Sumner
e7ff65ce2c [Transpiler] Fix crash in scanImports when the text is empty 2023-04-29 18:59:22 -07:00
Jarred Sumner
e321e1c5f8 Fix debug mode crash with trailing slash in import specifier 2023-04-29 18:58:43 -07:00
Jarred Sumner
737822b2ba Put transpiler tests in a separate folder 2023-04-29 18:47:52 -07:00
Jarred Sumner
9a929ff873 Update bun.zig 2023-04-29 18:16:57 -07:00
Jarred Sumner
3b6fb37497 Clean up args parsing with --loader 2023-04-29 18:12:55 -07:00
Jarred Sumner
229f5f7770 Export 4 missing napi symbols on macOS 2023-04-29 16:04:08 -07:00
dave caruso
96e113f41c bundler tests: rest of default.test.ts and starting jsx tests (#2765) 2023-04-28 21:08:48 -07:00
Jarred Sumner
bc0c0f7d20 fix several memory issues related to plugins 2023-04-28 18:59:12 -07:00
Jarred Sumner
98583972df cargo cult some code from JSC 2023-04-28 18:57:00 -07:00
Jarred Sumner
994c715700 Fix race condition 2023-04-28 17:46:43 -07:00
Jarred Sumner
e3a0c4e06d Update bun-test.yml 2023-04-28 17:12:01 -07:00
Jarred Sumner
bc43d33be9 move this 2023-04-28 17:10:24 -07:00
Jarred Sumner
73d499ed22 Add a comment 2023-04-28 17:02:12 -07:00
Ashcon Partovi
912ae8d2b5 Improve test runner markdown 2023-04-28 14:58:16 -07:00
Jarred Sumner
26d81fc5ba [resolver] Propagate module type from package.json "exports" when possible 2023-04-28 14:21:18 -07:00
Jarred Sumner
396416a91f Fix crash with invalid input in fetch() 2023-04-28 13:54:22 -07:00
Ciro Spaciari
4515a6373e Improves Body.Value life cycle and Signal life cycle on server.zig (#2752)
* reestruct request body value and signal

* revert react-hello-world

* fix constructInto and test

* fmt

* fix body nullable

* Request can outlive RequestContext

* fmt

* BodyValue is now HiveRef

* hasDecl for Ref and HiveRef

* fix deinit call on Ref/HiveRef

* adds InlineBlob

* fix Bun.inspect when using InlineBlob

* revert InlineBlob

* Fix mimalloc-debug

* Add TODO note

* fix: make node:crypto Hash.copy work correctly (#2761)

This commit will also:
- add a CryptoHasher.copy function
- make CryptoHasher.digest reset the hasher so it can be reused

Resolves #2651

* 💅

* address unicode issue (#2763)

* Fix an oopsie

* Another oopsie

* use inline for

* Fixup

---------

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

* Request can outlive RequestContext

* fmt

* garantee to have the abort signnal attached to the server before abort the client on bun-server test

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Silver <14016168+silversquirl@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2023-04-28 13:40:44 -07:00
Jarred Sumner
c383638ddd Use global allocator tsconfig.json 2023-04-28 10:35:50 -07:00
Ashcon Partovi
af02b75f79 Use setup-bun instead 2023-04-28 10:13:36 -07:00
Ashcon Partovi
a06e90eec3 Fix path of bun in workflow, try 3 2023-04-28 09:58:56 -07:00
Ashcon Partovi
35d470d98a Fix path of bun in workflow, try 2 2023-04-28 09:54:31 -07:00
Ashcon Partovi
05abe8eabe Fix path of bun in workflow 2023-04-28 09:52:15 -07:00
Ashcon Partovi
48671b77be Use GITHUB_PATH instead of cp 2023-04-28 09:44:44 -07:00
Ashcon Partovi
b7c13f2ccc Maybe fix test runner on macOS 2023-04-28 09:41:36 -07:00
Ashcon Partovi
64b9967fe6 Improve test workflow 2023-04-28 09:35:44 -07:00
Ashcon Partovi
ef894c57cf Fix typo in runner 2023-04-28 09:17:06 -07:00
Ashcon Partovi
5734889cc7 Use bun x instead of bunx 2023-04-28 09:13:14 -07:00
Ashcon Partovi
59daabb6e7 Fix manual test workflow 2023-04-28 09:11:55 -07:00
Ashcon Partovi
36df170348 Use Node.js APIs for test runner 2023-04-28 09:07:48 -07:00
Ashcon Partovi
6cf4cabab1 New test runner with better Github integration 2023-04-28 08:42:25 -07:00
Colin McDonnell
1483d73c3a Bundler docs updates + support for naming string (#2767)
* Bundler docs updates

* Remove comments

* Updates

* Fix bunx usages

* Add info about metafile
2023-04-28 08:35:20 -07:00
Jarred Sumner
52c50e3737 address unicode issue (#2763)
* Fix an oopsie

* Another oopsie

* use inline for

* Fixup

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-04-27 08:37:37 -07:00
Jarred Sumner
3ee22065f0 💅 2023-04-27 07:51:30 -07:00
Silver
0060e49923 fix: make node:crypto Hash.copy work correctly (#2761)
This commit will also:
- add a CryptoHasher.copy function
- make CryptoHasher.digest reset the hasher so it can be reused

Resolves #2651
2023-04-27 07:45:32 -07:00
Jarred Sumner
87921520e4 Add TODO note 2023-04-27 05:35:11 -07:00
Jarred Sumner
73467a5736 Fix mimalloc-debug 2023-04-27 05:35:11 -07:00
B. Burt
5a8a418ef4 Remove extra word in docs/index.md (#2758) 2023-04-27 04:00:35 -07:00
Jarred Sumner
df59fe2843 Implement outdir in Bun.build 2023-04-27 03:45:49 -07:00
Jarred Sumner
990f53f986 Don't preallocate unless its profitable 2023-04-27 03:45:09 -07:00
Jarred Sumner
9383333799 Add microbenchmark 2023-04-27 03:44:23 -07:00
Jarred Sumner
4558ea712a very slightly faster open() and writeFileSync() (#2759)
* Make open() slightly faster on macOS

* Support using `writeFileSync` from native code

* Add `openat$NOCANCEL` symbol

* fixups for linux

* do benchmark

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-04-27 03:35:46 -07:00
Jarred Sumner
f1c1f556a3 more esbuild compat 2023-04-26 22:36:56 -07:00
Jarred Sumner
6142f6eb61 Wrap some things in minify_syntax flag 2023-04-26 22:32:48 -07:00
Jarred Sumner
316a75005b Inline spreads of array literals 2023-04-26 22:32:31 -07:00
dave caruso
5b76ee769e bundler tests! (#2741)
* bundler tests!

* tests
2023-04-26 21:57:49 -07:00
Silver
3a203abc10 Use Ninja to build mimalloc and gitignore test/bun.lockb (#2750)
* build: use ninja to build mimalloc

This is both faster than make, and ensures the same generator is
always used, even when CMAKE_GENERATOR exists in the environment.

* chore: gitignore test/bun.lockb
2023-04-26 21:57:25 -07:00
Dylan Conway
75e3546f3a ensure super() is not merged with adjacent statements (#2757)
* ensure `super()` is not merged with adjacent statements

* add TODO
2023-04-26 21:46:35 -07:00
Jarred Sumner
6c6118e210 Fixes #2746 (#2748)
* Fixes #2746

* add test

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-04-26 21:07:40 -07:00
dave caruso
55c05c0a1f fix (#2756) 2023-04-26 20:45:27 -07:00
dave caruso
7d7748f69f docs hotfix (#2755) 2023-04-26 20:27:24 -07:00
Colin McDonnell
8ba13f273c Add bundler documentation (#2753)
* WIP

* WIP

* WIP

* Document API

* Updates

* Polish bundler docs

* Tweaks

* Tweak
2023-04-26 20:07:30 -07:00
Colin McDonnell
68ab71eb13 Basic types for Bun.build (#2713)
* Basic types for Bun.build

* Tweaks

* Updates
2023-04-26 14:54:05 -07:00
Jarred Sumner
ab447e4ff7 Implement file loader in Bun.build (#2745)
* Update bundle_v2.zig

* Implement `file` loader

* Hash in parallel

* Implement `publicPath`

* simplify

* Update bundle_v2.zig

* Implement `#!`

* Remove unnecessary optional

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-04-26 07:22:29 -07:00
Jarred Sumner
149f097ffd Update outdated help 2023-04-25 22:21:40 -07:00
Jarred Sumner
3e374c0ee4 Fix assertion failure
reproduces if building Three.js 10 times in runtime
2023-04-25 22:21:24 -07:00
Jarred Sumner
f42663ce9a Avoid unnecessary copies 2023-04-25 22:11:15 -07:00
Jarred Sumner
c48f7e2663 Fix error with --jsx-production in runtime 2023-04-25 22:10:59 -07:00
dave caruso
0846a4fa80 bundler tests, testing plugins (#2740)
* add cjs2esm stuff

* tests

* plugin testing
2023-04-25 19:13:39 -07:00
Jarred Sumner
2256d43a32 now it works 2023-04-25 08:19:40 -07:00
Jarred Sumner
947634c9ed typo 2023-04-25 07:57:00 -07:00
Jarred Sumner
126885e1fe Implement onResolve plugins in Bun.build(), support multiple onLoad and onResolve plugins (#2739)
* its 2023

* WIP `onResolve` plugins

* more progress

* it compiles

* Lots of small fixes

* Seems to work excluding entry points

* Update BundlerPluginBuiltins.cpp

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-04-25 07:27:18 -07:00
Jarred Sumner
5353d41014 Fixes #2738 2023-04-25 07:25:00 -07:00
Alex Lam S.L
460563ee89 fix make setup (#2731)
- minor clean-ups
2023-04-25 15:13:57 +03:00
Jarred Sumner
3c4f0920b9 Log HTTP requests and responses by default when log level is debug or verbose 2023-04-25 04:01:26 -07:00
Alex Lam S.L
6e16bb67eb [install] fix bun add on non-aliased dependency (#2728) 2023-04-24 17:56:43 -07:00
Jarred Sumner
e9e7645048 In bun run, rewrite usages of npx to bun x instead of bunx to workaround missing symlink 2023-04-24 17:55:34 -07:00
dave caruso
f2112fc0de Continue bundler tests (#2691)
* start refine + skipping some packagejson tests

* some more tests

* stuff

* tests for minify branch

* pkgjson

* add minify/MergeAdjacentVars

* add test for #2699

* more tests!

* more tests

* finish splitting tests

* all but 2 import star tests are good

* test
2023-04-24 14:12:21 -07:00
Jarred Sumner
923ac39c0b Support plugins in Bun.build (#2720)
* wip

* Implement `onLoad` plugins

* Support exceptions and async `onLoad` plugins

* Fix filtering

* Handle empty files

* Fix JSON loader

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-04-24 14:11:59 -07:00
Plecra
98209b8e10 Reduce friction for building with npm (#2723)
This was the only dependency on bun that I encountered while building the
project, and the change to the gitignore ensures that it's easy to
make changes after an npm based build
2023-04-24 04:23:38 -07:00
Jarred Sumner
4b24bb464c Make Bun.build more reliable (#2718)
* One possible implementation to make `Bun.build` work better

* Pass allocator in

* Make our temporary buffers a little safer

* rename

* Fix memory corruption in symbol table

* Add support for deferred idle events in ThreadPool

* Free more memory

* Use a global allocator FS cache

* more `inline`

* Make duping keys optional in StringMap

* Close file handles more often

* Update router.zig

* wip possibly delete this commit

* Fix memory issues and reduce memory usage

* > 0.8

* Switch to AsyncIO.Waker and fix memory leak in JSBundleCompletionTask

* We don't need to clone this actually

* Fix error

* Format

* Fixup

* Fixup

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-04-22 19:44:23 -07:00
Jarred Sumner
7d6b5f5358 Fix minify: true not applying to identifiers 2023-04-21 18:03:27 -07:00
Jarred Sumner
9423693a6e [breaking] In Bun.Transpiler, don't wrap CommonJS modules in export default 2023-04-21 18:03:07 -07:00
Jarred Sumner
8b9462fde5 Add minify option to Bun.Transpiler 2023-04-21 18:02:29 -07:00
Colin McDonnell
caa90ba98e Update TS docs for bun-types changes (#2590)
* Update TS docs for bun-types changes

* Update typescript, remove extends guidance

* Updates

* Tweaks

* Tweaks
2023-04-21 11:35:42 -07:00
Colin McDonnell
55d50565a5 Add tsconfig.json to bun-types (#2587)
* Add tsconfig.json to bun-types. Document 'extends' pattern.

* Updates

* Update bun init to use extends:bun-types

* Update type:module recommendation

* Add note about transpilation. Closes #2553

* Make typescript a peer dep

* Revert changes to docs

* Revert tsconfig extends

* Update readme

* FMC

* Undo changed
2023-04-21 11:34:05 -07:00
Jarred Sumner
dc55e11714 Keep the node crypt otest 2023-04-21 07:25:51 -07:00
Jarred Sumner
613bb4822e Revert "use a lazyily initialized stream for node:crypto createHash (#2652)"
This reverts commit 3a2fd65f20.
2023-04-21 07:18:32 -07:00
Jarred Sumner
a4d0a1961a Revert "implement node:events in javascript (#2604)"
This reverts commit 96a2ed1040.
2023-04-21 07:16:23 -07:00
Jarred Sumner
143ccdbeb6 Fix order 2023-04-21 05:10:03 -07:00
Jarred Sumner
b98f90fc6e Bun.build() partial implementation 2023-04-21 01:04:55 -07:00
Jarred Sumner
281b810664 slightly better minified 2023-04-21 01:04:06 -07:00
Jarred Sumner
ffdac249ae Add comment 2023-04-21 00:52:31 -07:00
Jarred Sumner
541d16f8be Fix bug with merging adjacent vars 2023-04-20 23:57:44 -07:00
Emmanuel Vazquez
b609f9be28 chore(docs): add xcode runtime install to docs (#2706) 2023-04-20 20:03:12 -07:00
Jarred Sumner
b473a0022d Fix whitespace edgecase with export * from 2023-04-20 19:51:20 -07:00
Dylan Conway
94cd68d7a6 append if the previous part is not UTF8 (#2705) 2023-04-20 16:35:01 -07:00
Jarred Sumner
6d5378566a Fix template string folding test
@paperdave --minify-syntax now causes `true` to print as `!0` and `false` to print as `!1`

`undefined` is now `void 0`
2023-04-20 05:44:50 -07:00
Jarred Sumner
c33df9e99f Increase timeouts :( 2023-04-20 05:40:20 -07:00
Jarred Sumner
4dc0364201 Update runner.node.mjs 2023-04-20 05:40:11 -07:00
Jarred Sumner
aa4d47fe2d Improve error message when failing to read a file 2023-04-20 05:30:35 -07:00
Jarred Sumner
3a68ca775f Fix bug with invalid character at the end of comment path 2023-04-20 05:24:29 -07:00
Dylan Conway
d78ecc76c8 Symbol minification (#2695)
* minify

* Update renamer.zig

* --minify-whitespace

* Speed up minification a little

* handle private names

* 5% faster minification

* use helper function

* fix nested scope slots

* `bun build --minify` gets another +8% faster

* print semicolons afterwards

* print semicolon after checking error

* after all error checking

* Delete code for generating legacy bundes

* remove extra whitespace around if statements

* print space before import identifier

* Use `@constCast`

* Make `S.Local#decls` use `BabyList(Decl)`

* Add `fromSlice` helper to `BabyList`

* Remove unnecessary optional chains

* minify `undefined, true, false`

* Another @constCast

* Implement merge adjacent local var

* Support --minify in `bun build --transform`

* skip comments when counting character frequencies

* Don't wrap commonjs with --transform on (unless targeting bun)

* Support --minify in the runtime

* Fix edgecase with import * as

* don't infinite loop

* --trnasform shouldn't mess with require

* Only track comments when minifying

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-04-20 05:23:12 -07:00
Dylan Conway
9e7bfdec8c with body can be an expression 2023-04-20 01:03:38 -07:00
flakey5
f0dd5b8a43 Fix typo in benchmarking docs (#2702) 2023-04-19 19:16:45 -07:00
Jarred Sumner
ea47ed0ee5 Fix broken autocomplete 2023-04-19 00:01:27 -07:00
Alex Lam S.L
36f9fd607a fix make setup (#2693)
- properly reset `JSC_BASE_DIR` after installing `bun-webkit`
2023-04-19 04:55:00 +03:00
dave caruso
96a2ed1040 implement node:events in javascript (#2604)
* initial event emitter reimplementation

* implement most of node:events. tests passing

* work on emitter

* fix importing node:events

* work on event emitter tests

* event work

* event work

* event stuff and experimenting with a lazy createHash

* cleanup crypto stuff i had on this branch

* finish event stuff up

* fix error monitor

* validate listeners are functions

* changes requested
2023-04-18 14:59:51 -07:00
dave caruso
76deb51c29 clarify file io docs (#2689) 2023-04-18 11:09:41 -07:00
Dylan Conway
5712fbd5b9 use properties length instead of capacity (#2687) 2023-04-18 04:13:04 -07:00
Jarred Sumner
b5b4356d52 Prepare for JavaScript Bundler API 2023-04-18 01:01:48 -07:00
Jarred Sumner
d1de291b2a Fix the extremely annoying ./ requirement in bun build 2023-04-18 01:01:31 -07:00
Jarred Sumner
af96e8fcdd Remove spin loop in bun build 2023-04-17 23:03:58 -07:00
Jarred Sumner
9e1745ee1f Fixes #2676 2023-04-17 20:07:08 -07:00
Jarred Sumner
05cb5bb659 Make bun dev CLI flags only show in --help for bun dev --help
This impacts:

--disable-bun.js
--disable-react-fast-refresh
--bunfile <STR>
--server-bunfile <STR>
--public-dir <STR>
--disable-hmr
--use <STR>
2023-04-17 19:20:39 -07:00
Jarred Sumner
dec5b07782 Fix template string folding bug 2023-04-17 18:01:38 -07:00
Jarred Sumner
b758779c49 Fix missing should_fold_typescript_constant_expressions 2023-04-17 17:33:21 -07:00
Jarred Sumner
3a63fe457d Fix DCE bug with new Foo() when pure without arguments 2023-04-17 17:16:57 -07:00
Dylan Conway
a17624942e make sure with is parsed as a block (#2680) 2023-04-17 15:54:02 -07:00
Dylan Conway
1ce60275d0 fix typescript decorators with index and number keys (#2677)
* handle index property key case

* non-method number property

* tests for property keys
2023-04-17 15:26:18 -07:00
Simon Legner
93a43c8fc1 docs: fix code block (#2662) 2023-04-17 13:01:08 -07:00
Jarred Sumner
bffe5e820b more 2023-04-17 08:01:03 -07:00
Jarred Sumner
983d9428a6 Get axios working (#2673)
* Revive node:http tests

* Fix a couple bugs in node:http

* possibly breaking: use `"browser"` exports condition last

* Make URL validation error better

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-04-17 07:13:01 -07:00
Jarred Sumner
fc539c278e cleanup 2023-04-17 05:47:20 -07:00
Jarred Sumner
d19005aa76 Fix access of inactive union field 2023-04-17 05:46:44 -07:00
Jarred Sumner
d2c64300f6 Fixup options parsing 2023-04-17 05:46:29 -07:00
Jarred Sumner
4cb739a8c5 enable minify syntax by default in the runtime 2023-04-17 03:56:52 -07:00
Jarred Sumner
01a03bcce4 Prepare for Bun.build 2023-04-17 03:56:38 -07:00
Jarred Sumner
6b758c809f Fix dynamic require() 2023-04-17 03:45:54 -07:00
Jarred Sumner
746940d21e Fixes #2634 2023-04-17 01:20:38 -07:00
Jarred Sumner
07b4b4ced0 Don't record named exports for deoptimized CJS 2023-04-17 01:18:05 -07:00
Jarred Sumner
e624dd6d4d Deoptimize CJS more 2023-04-17 00:54:03 -07:00
Jarred Sumner
ed2f24e409 Update bun.zig 2023-04-17 00:34:54 -07:00
Jarred Sumner
c650b0b848 bun build should write to stdout instead of stderr
@paperdave this probably breaks all your tests
2023-04-17 00:34:49 -07:00
Jarred Sumner
0514f59288 DCE for some global constructor calls 2023-04-17 00:32:21 -07:00
Jarred Sumner
5a8cfd8390 Deoptimize CJS -> ESM transform on computed property access of exports object
Example:
```js
for (var k in constants) {
    exports[k] = constants[k];
}
```
2023-04-17 00:30:40 -07:00
Jarred Sumner
a2d5e7c570 Update bundle_v2.zig 2023-04-16 23:42:45 -07:00
Jarred Sumner
af0a4c5638 Mark builtins as external for node and bun 2023-04-16 22:48:32 -07:00
Jarred Sumner
eec1a07907 Attempt to automatically handle some cyclical import issues with ESM
Fixes https://github.com/kysely-org/kysely/issues/412
2023-04-16 22:20:22 -07:00
Jarred Sumner
30b0d006fe Fix for ReferenceError: Cannot access uninitialized variable. 2023-04-16 21:49:33 -07:00
Jarred Sumner
413ce0c7a5 Add some comments 2023-04-16 21:04:07 -07:00
Jarred Sumner
c916a55ead Lazily wrap 2023-04-16 20:15:47 -07:00
Jarred Sumner
31319c0177 Add temporary fix 2023-04-16 19:31:45 -07:00
Jarred Sumner
255a805e00 Fix some edgecases with CJS -> ESM unwrapping 2023-04-16 19:31:45 -07:00
dave caruso
eff48cd95c more bundler tests (#2670)
* tests!

* run formatters
2023-04-16 18:57:56 -07:00
Jarred Sumner
338565eea4 Fix test 2023-04-16 07:33:30 -07:00
Jozef Steinhübl
264f3b91b6 fix: replace unknown link with bun docs (#2669) 2023-04-16 07:13:08 -07:00
Jarred Sumner
06dab241ef Unwrap, but we broke code splitting 2023-04-16 06:51:07 -07:00
Jarred Sumner
29cacb7da7 Update cli.zig 2023-04-16 01:56:37 -07:00
Jarred Sumner
e05cc8db90 prepare for unwrapping 2023-04-16 01:56:14 -07:00
Jarred Sumner
09357f55f9 Fix bugs with loading jsxDEV when it should be jsx or vice versa 2023-04-16 01:31:01 -07:00
Jarred Sumner
33049fa6fd Rename E.Require -> E.RequireString and E.RequireOrRequireResolve -> E.RequireResolveString 2023-04-16 01:30:01 -07:00
Jarred Sumner
be5d21a4f1 Delete some legacy bundling code 2023-04-15 18:45:29 -07:00
dave caruso
2dc3f4e030 more work on bundler tests (#2667)
* Fix `make dev` reusing old .o file

* more bundler tests

* document capture

* bundler tests

* bundler tests

* bundler tests

* finish up

* remove bad thing to merge on main
2023-04-15 18:28:21 -07:00
Colin McDonnell
1a7c3cdf3b Add .txt loader docs 2023-04-15 11:52:39 -07:00
Will Richards 2
f1f7369897 toBeFalsy expect counter and test scope check (#2661) 2023-04-15 08:52:46 -07:00
Jarred Sumner
4b3c483cd4 Handle more cases in length 2023-04-15 05:17:37 -07:00
Jarred Sumner
df88b998d6 Mostly implement cross-module constant inlining, but disable it
There are some test failures
2023-04-15 05:17:12 -07:00
Jarred Sumner
b687c3ab88 Implement template string folding
@paperdave can you help write tests for this if not already covered?

example:
```js
if (
  `${1}-${2}-${3}-${null}-${undefined}-${true}-${false}` === "1-2-3-null-undefined-true-false"
) {
  if (
    "\uD83D\uDE0B \uD83D\uDCCB \uD83D\uDC4C".length === 8 &&
    "😋📋👌".length === 6
  ) {
    console.log(`such fold. very inline. wow.`);
  }
}
```
2023-04-15 05:15:46 -07:00
Jarred Sumner
d4436f278c Fix failing to log error with --transform 2023-04-15 02:41:32 -07:00
Jarred Sumner
530f5ef82c Add error for assigning to a constant 2023-04-15 02:32:11 -07:00
Jarred Sumner
9e5efe61a3 Add unset function 2023-04-15 02:31:01 -07:00
Jarred Sumner
82b2c5221b Update bun.zig 2023-04-14 23:09:20 -07:00
Jarred Sumner
e977bfb5a7 Implement --transform CLI flag 2023-04-14 23:09:14 -07:00
Jarred Sumner
81e11ae586 Include the error return trace 2023-04-14 23:08:29 -07:00
Jarred Sumner
0d248568f6 Fix string concat 2023-04-14 23:08:17 -07:00
Jarred Sumner
96d522a7db +6 more passing tests 2023-04-14 22:09:48 -07:00
Jarred Sumner
b4989a316b Support importing .txt files as strings (#2660)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-04-14 17:45:16 -07:00
Jarred Sumner
8b897e1a6b Fix bug with mjs 2023-04-14 04:16:38 -07:00
Kruithne
730074b75d [nit] minor typo in tcp.md (#2657) 2023-04-14 04:00:02 -07:00
Jarred Sumner
f6a4516d66 Upgrade Zig (#2656)
* Upgrade Zig

* Don't add `d` files in github actions

* Revert "Don't add `d` files in github actions"

This reverts commit 446e2dd674.

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-04-14 03:58:38 -07:00
Jarred Sumner
6c69c2b364 Implement @bun annotation 2023-04-14 03:44:41 -07:00
Jarred Sumner
ba057e50c3 Update bun.zig 2023-04-14 03:12:40 -07:00
Jarred Sumner
1e6dcef0c5 fixup pragma parsing 2023-04-14 03:12:33 -07:00
Jarred Sumner
889462a891 Support @jsx, @jsxRuntime, @jsxImportSource, and @jsxFragment pragmas (#2655)
* Support parsing @pragma comments

* Support `@jsx`, `@jsxRuntime`, `@jsxImportSource`, `@jsxFragment`

* Fix bug where NODE_ENV would be development in certain places and production in others

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-04-14 01:49:29 -07:00
dave caruso
3a2fd65f20 use a lazyily initialized stream for node:crypto createHash (#2652)
* lazy hash

* finish up crypto stuff

* remove lockfiles

* ok

* add pipe test

* update this lockfile

* remove unrelated crypto benchmark from this file
2023-04-13 21:55:01 -07:00
Colin McDonnell
267a38f6fc Remove Bun.dns docs 2023-04-13 18:32:22 -07:00
Colin McDonnell
011e157cac Docs restructuring (#2638)
* Restructure

* Update nav

* Reorg

* Reshuffle ecosystem pages

* Split up runtime/runtime

* Back to runtime/index

* Fix issue

* Split up runtime/index

* Add Writing Tests page

* Prettier matcher table

* More updates
2023-04-13 18:26:45 -07:00
Jarred Sumner
0cc56e8efc Update default.test.ts 2023-04-13 18:02:49 -07:00
Jarred Sumner
54ef58db48 Fix default/ReExportDefaultExternalES6 2023-04-13 18:00:39 -07:00
Dylan Conway
476ab24081 fix ambiguous import (#2654)
* check all files before

* better error/warning

* update todo
2023-04-13 17:41:07 -07:00
Jarred Sumner
8a2545a172 Fix default/ReExportCommonJSAsES6 2023-04-13 17:00:24 -07:00
Jarred Sumner
e9016415bc Only set is_web_browser_navigation in debug mode server 2023-04-13 16:33:11 -07:00
Dylan Conway
242aa0be12 Update import-meta.test.js 2023-04-13 16:03:11 -07:00
Ciro Spaciari
041231d7ca fix node-net-test hang (#2649)
* fix tests

* fix fmt

* fix fmt
2023-04-13 15:14:58 -07:00
Ciro Spaciari
bee743fd61 fix(server) fixes UAF of uWS headers (#2648)
* fixes UAF of uWS headers

* fix transfer encoding condition
2023-04-13 15:14:34 -07:00
Jarred Sumner
d7a8037899 Fixes #2645 2023-04-13 14:42:35 -07:00
Nilan Marktanner
d226a054ae Update development.md (#2647) 2023-04-13 09:07:44 -07:00
Jarred Sumner
aeb3bb949b Upgrade WebKit (#2643)
* Missing export

* Regenerate builtins

* Fix crash in require()

* Various breaking JSC changes

* hopefully speed up C++ compilation a little

* Skip failing test fo rnow

* Update WebKit

* Add a comment

* Fix error in postinstall

* Update WebKit

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-04-13 04:11:12 -07:00
Dylan Conway
db15a23a63 import file path and fix disabled browser require (#2642)
* print disabled `require`

* bundle file paths

* update tests
2023-04-13 00:20:59 -07:00
dave caruso
1cc4eb0e3f fix expectBundled precheck (#2641) 2023-04-12 19:30:55 -07:00
Dylan Conway
a03ee18262 fix bundling many entry points (#2640)
* fix going out of bounds when length is over 8

* remove
2023-04-12 19:25:39 -07:00
Ciro Spaciari
108c54134c fix types and add more reliable tests (#2621) 2023-04-12 18:41:40 -07:00
dave caruso
73216b10ce bundler tests (#2635) 2023-04-12 18:41:04 -07:00
Dylan Conway
ff5c522712 bundler bug fixes (#2637)
* append import to outer wrapper prefix

* print space

* require text loader

* import empty esm and cjs

* add text to schema
2023-04-12 18:40:21 -07:00
hiroki osame
14f87156a2 fix(fs): remove readfile (#2630) 2023-04-12 18:40:02 -07:00
Dylan Conway
d8d4abb58e don't increment i if escaped (#2639) 2023-04-12 17:42:56 -07:00
Dylan Conway
4b9b648f8a could include /private/ on macos 2023-04-12 15:22:04 -07:00
dave caruso
519f9aac80 finish refining bundler tests (#2623)
* bundler tests

* test refining, 257/847

* bundler tests, 298/849

* more bundler tests

* finish dce
2023-04-11 18:18:49 -07:00
Ryan Morey
a744f5369d Update development.md (#2625)
* Update development.md

adds the `bash` language specifier to `which clang-15` so that when you click the copy button, it doesn't include the `$`

* Update development.md

* Update development.md

* Update development.md
2023-04-11 13:19:24 -07:00
hiroki osame
14c6023e15 docs: remove dev container section (#2610) 2023-04-11 01:52:54 -07:00
Ciro Spaciari
f91dc8c0d3 always safe deinit socket context (#2611) 2023-04-10 15:05:16 -07:00
Dylan Conway
f4ab79d6bb add original name to list (#2613) 2023-04-10 15:03:27 -07:00
Jarred Sumner
373248ce9c Implement TOML & JSON support in Bun's new bundler (#2609)
* Implement JSON & TOML support in the bundler

* Fix failing to bind namespace imports

* Support namespace exports better

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-04-10 06:35:41 -07:00
Jarred Sumner
5c37d0f2a5 Parse import attributes
https://github.com/tc39/proposal-import-attributes#import-attributes
2023-04-09 07:49:08 -07:00
Jarred Sumner
7bd6a1f86d Remove usages of void{} in favor of {}
See https://github.com/ziglang/zig/issues/15213
2023-04-09 05:39:05 -07:00
Jarred Sumner
1e717dd941 Add some test coverage for instantiation expressions
Related to #2203
2023-04-09 05:07:44 -07:00
Jarred Sumner
e9d6a4042f Fix another case with instantiation expressions
Related to #2203
2023-04-09 05:07:28 -07:00
Jarred Sumner
c97cb4ec1e Lower for-in variable initializers 2023-04-09 05:07:07 -07:00
Jarred Sumner
21acc50d88 Fixes #2594 (#2600)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-04-09 03:43:04 -07:00
Jarred Sumner
b34f0da499 Fixes #2599 2023-04-09 03:18:26 -07:00
Jarred Sumner
eb18101d84 Update TypeScript parsing to 5.0 (#2593)
* update syntax

* seems to work, needs tests

* This test wasn't supposed to be added

* Many bugfixes to TypeScript parser

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-04-09 03:16:11 -07:00
dave caruso
2117723642 Fix callout tag on development docs (#2595)
* fix callout tag on development docs

* add notes on cmakeconfig.h

* Update Makefile
2023-04-08 20:05:05 -07:00
dave caruso
461ae27d31 Rewrite Developer Docs, Improve DX for new users, moving away from Devcontainer (#2588)
* new docs starting point. missing alot of information

* very experimental idea: make setup

* run on ubuntu 20

* builds on ubuntu 20 (wsl) now

* add release instructions

* add valgrind note from jarred/new-bundler branch, just in case it gets lost when rebasing

* changes requested
2023-04-08 02:23:11 -07:00
Jarred Sumner
ba7a8a9cb5 Fix node: prefix when --platform=node 2023-04-07 23:15:19 -07:00
Jarred Sumner
c764543af5 Fix sort 2023-04-07 22:33:33 -07:00
Jarred Sumner
60fc80d4c4 Workaround crash
https://github.com/ziglang/zig/issues/15204
2023-04-07 22:12:19 -07:00
Jarred Sumner
6362414d65 Bun gets a new bundler (#2312)
* alright now just gotta try running it

* fix a gajillion compiler errors

* even more code

* okay i fixed more errors

* wip

* Update launch.json

* Update string_builder.zig

* `fast_debug_build_mode` makes debug build 2x faster

* Update bundle_v2.zig

* more code!

* It bundles!

* Rename `Bun.Transpiler` to `Bun.Bundler`

* `import()` expressions almost work

* wip attempt to get import() expr to work

* Bundle namespace imports

* Attempt to fix the issue with import() unsuccessfully

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

* support `expect().toThrow(/pattern/)` (#2314)

- fix time-zone-dependent test failure

* fix missing `Blob` error messages on Linux (#2315)

* fix & clean up tests (#2318)

- skip flaky tests when running as `root`
- use `expect().toThrow()`
- clean up temporary files after tests

* 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

* Fix docker install command

* `bun test` on macOS in GitHub Actions (#2322)

* Fixes #2323

* throw invalid parameter errors in `crypto.scryptSync` (#2331)

* throw invalid parameter errors

* remove comptime, add empty buffer function

* remove error_name comptime

* Add reference documentation for bun:test (#2327)

* Reorganize tests (#2332)

* Fix html-rewriter.test.js

* fix the wrong thing being incremented in hmr example (#2334)

* Add more test harness

* Improve Benchmarking page, small fixes (#2339)

* Improve benchmarking page

* WIP

* Add typescript instructions to hot

* Document preload in Plugins. Fix loader in plugin types.

* Fix typo

* Fix links

* run prettier

* Document openInEditor

* improve `Buffer` compatibility with Node.js (#2341)

* improve `Buffer` compatibility with Node.js

* use `memmove()`
allow `encoding` to be `undefined`

* run `bun test` after macOS builds (#2343)

* "binary" is an alias of "latin1"

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

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

* Fix bug in test runner

* Support `import()` expressions

* Implement `require()`

* clean up bit_set.zig slightly

* Move some things around

* misc cleanup

* Cleanup some things

* Fix a lot of stuff

* Fix `module.exports.fn = fn;` in ESM entry point

* Fix crash due when printing file

* Fix issue with class names

* Fix issue with `export default identifier`

* Update js_parser.zig

* optimization: inline single-property object acceses and arrays

* Fix undefined memory in renamed symbols list

* Handle call target

* wip

* Inline it

* Fix undefined memory issue when reclaiming blocks in ast

* Halt linking on any parse errors

* alias

* Rename `enable_bundling` to `enable_legacy_bundling`

* Workaround anonymous struct literal zig bug

* Use slower approach (without bitset) because it doesn't break after 8 symbols

* Fix incorrectly-renaming statically defined symbols

* Handle more edgecases in our bit_set fork

* Reduce number of allocations for `define`

* Do not rename unbound symbols

* Clean up dot defines a little more

* Make the generated names prettier

* Workaround runtime symbol missing issue

* Fail the build on errors

* Support export * from

* Support `--outfile`

* partially fix renaming

* fanicer symbol renaming impl

* misc, extremely revertible cleanup

* Fix up some bugs with symbol renaming

* formatting

* Update launch.json

* Parse `__PURE__` comments

* clean up simd code for pure comments

* changes to merge

* workaround runtime issue

* Fix issue with `export * as` not propagating correctly

* Make all top-level declarations `var` when bundling

* Fix missing prefix

* Fix assigning to stack copy

* Fix missing runtime symbol

* Fix bug with namespace exports

* Dramatically reduce allocations

* Update launch.json

* Add missing flags

* Update js_parser.zig

* small cleanup

* Make the export name better

* Fix unnecessary `var foo = foo`

* Implement CommonJS -> ESM conversion

* Implement module redirects

* Port esbuild bundler tests for new bundler (#2380)

* started porting esbuild tests

* clean up test names and api before moving on

* port tests using a program i wrote

* replace todo generated comment

* fix generated tests not including some files

* work on tests

* [github web editor] add define, external, inject, minifySyntax, minifyWhitespace options.

* get most of the todo comments out of the way, but expectBundled does not handle most of the cases

* continue working on esbuild tests

* use test.skip for unsupported tests

* Fixups for test runner

* Hoist imports & exports

* Fix test

* Hoist classes

* bundler test refining, 51/835

* Fix runtime require

* bundler test refining, 81/835

* bundler test refining, 93/835

* Make the test work in any timezone

* feat(expect): update toBeInstanceOf (#2396)

* feat: update instanceof binding

* fix: according to PR comments

* Rename `expectObjectTypeCount` to `expectMaxObjectTypeCount`

* Fix socket tests with connection errors (#2403)

* release pending activity with connection error handler

* unref poll_ref

* remove trailing comma

* Organize Dockerfiles for official status

* Remove test Dockerfile

* Remove old Docker workflow

* Feat(test): add toMatch (#2404)

* 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

* 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

* 💅

* docs: Use correct url in the 'Issues' link in README header (#2420)

* Fix crash when rendering error page and the server or network is slow

* [fetch] Make the default body value `null` when unspecified

This is better aligned with the fetch spec

* Make node-net tests less flaky

* [node:net] Fix issue with `listen` callback firing before it's listening

* Always clear timers in node test harness

* Fix out of bounds access

Repro'd in Buffer tests

* Update UWS

cc @cirospaciari

* Make this test more thorough

* Hanging abort test

* 0 length body is a null stream

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

* Remove usages of port numbers in tests

* Set -O2 and -fno-rtti

* Remove -g

* Prevent undefined memory access

* [bun test] Implement `--rerun-each` flag to run each test N times

* Reduce number of module scopes created

* 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

* remove unnecessary check (#2432)

* Fix bug with scoped aliased dependencies in bun install on macOS

* remove `addLog`, remove `--prominent-compile-errors`

* Finish the upgrade

* Optional chaining flag

* Implement same_target_becomes_destructuring optimization

* bundler test refining, 109/835

* Reset bindings

* Support multiple entry points

* Implement `--entry-names` flag

* Use a tempdir with a better name

* prettier

* Log file name

* Update js_parser.zig

* Mark all bun builtins as external

* Make resolve errors actually errors

* Update bundler_default.test.ts

* Fix `await import(foo)`

* WIP react server components

* Do more stuff at runtime

* ✂️

* Support automatic JSX imports

* Use a module cache for now

* Update tsconfig.base.json

* Fix ThisOutsideFunctionNotRenamed

* woopsie

* moar cpu

* clamp it

* fixup

* Add a bunch of assertions

* Bun uses automatic runtime by default

* Parse Import Attributes

* Add a note about Valgrind

* Update developing.md

* Fix up code splitting for React Server Components

* Implement client component manifest

* Fix crash with --react-server-components and no client components

* Backport 4d31e3c917

* Update launch.json

* Fix for latest zig

* Workaround bug with ?[]const string

Occasionally saw alignment errors in this code

Workaround https://github.com/ziglang/zig/issues/15085

related: https://github.com/ziglang/zig/pull/15089

* switch to regular slice

* Avoid initializing named_imports and named_exports as undefined

* Reduce usages of `undefined`

* Add more assertions

* --watch wip

* Update javascript.zig

* Possibly fix the race condition

* Faster `do`

* bump allocator

* Reduce the size of `Symbol` slightly

* Alphabetically sort runtime import symbols, for determinism

* Prepare for code splitting

* handle overlapping stdout

* pure

* clean up some things

* Fix bug with `$$typeof`

* Address CommonJS -> ESM hoisting bug

* Support `"use server"` in manifest

* Implement `"use server"`

* Fix importing bun builtins when bundling

* Make `commonjs_to_esm` a feature flag, fix some splitting bugs

* ✂️

* fixme remove this

* Fix crash in longestCommonPath

* Chunking! Just need to do import paths now.

* Import paths work...now trying to figure out how to make runtime symbols work

* add workaround

* Replace `bun bun` with `bun build`

* Fix crash with dual package hazard

* Fix many CommonJS <> ESM interop bugs

* Support package.json `"sideEffects"`

also skip loading unnecessary package.json data in `bun run`

* add a not good --watch implementation

* bundler test refining, 140/831

* remove accidentally committed file

* do not return status code 1 on successful bundles

* bundler test refining, 159/830

* pass exit code to exitOrWatch

* clean up help menu

-remove two spaces to line up bun build
-moved all <r> tags to the end of the text they are colorizing
-moved other colors to the start of the text they colorize
-removed unneeded <r> tags, keeping only one at the start of the block

* importstar is fully ported

* wip

* you can run code in this branch now

* Disable this transform

* organize and document bundler tests

* Fix double import

* Fix sloppy mode function declarations

* Disable our CommonJS transform for now

* add `assertNotPresent` to make splitting cases easier

* Bump!

* Update bun.d.ts

* use import.meta.require in runtime code

* Disable this again

* Fix dirname

* Fix ESM -> CJS wrapper

* 💅

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Alex Lam S.L <alexlamsl@gmail.com>
Co-authored-by: Derrick Farris <mr.dcfarris@gmail.com>
Co-authored-by: Ashcon Partovi <ashcon@partovi.net>
Co-authored-by: Dylan Conway <35280289+dylan-conway@users.noreply.github.com>
Co-authored-by: pfg <pfg@pfg.pw>
Co-authored-by: Colin McDonnell <colinmcd94@gmail.com>
Co-authored-by: dave caruso <me@paperdave.net>
Co-authored-by: zhiyuan <32867472+zhiyuang@users.noreply.github.com>
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
Co-authored-by: Kamil Ogórek <kamil.ogorek@gmail.com>
Co-authored-by: Ciro Spaciari <ciro.spaciari@gmail.com>
2023-04-07 20:08:01 -07:00
Ashcon Partovi
c0c5f07218 Fix trailing slash bug in upload script 2023-04-07 16:05:47 -07:00
Ashcon Partovi
0a91dd9f71 Fix environment variables in workflow 2023-04-07 15:42:41 -07:00
Ashcon Partovi
bed56ab406 Upload releases to S3 2023-04-07 15:38:38 -07:00
Jake Boone
4978a6b74d Add TSConfig object type to TranspilerOptions interface (#2545) 2023-04-07 15:16:21 -07:00
hiroki osame
35b279a4bb chore: simplify prettier command and cache (#2589) 2023-04-07 09:11:23 -07:00
Colin McDonnell
c8e09f563f FileBlob -> BunFile, add BunFile.lastModified (#2581)
* Improve BunPlugin types

* FileBlob -> BunFile

* Update Bun.env types. Fixes #2481

* Add lastModified to BunFile
2023-04-07 04:03:06 -07:00
Ciro Spaciari
6baedd27bc feat(tls.Server) basic support (cert, key, rejectUnauthorized, requestCert, ca) #2412 (#2552)
* cherry picked

* add StringOrBuffer parameter

* Format and adds types

* update uws

* fix tests

* more types

* fix typing

* add timeouts, clean some stuff

* move tests to describe

* fixes SSL hostname when Host is provided

* cleanup on tests

* change 127.0.0.1 to 0.0.0.0

* try another listening parameter

* test timings and update uws

* remove unnecessary comment

* move listening event around

* always await Bun.connect

* do not fail if the tests already passed when using Bun.connect

* regenerate classes

* undo generated classes

* generate classes

* fix merge

---------

Co-authored-by: cirospaciari <cirospaciari@MiWiFi-RA82-srv.cirospaciari>
2023-04-07 04:02:05 -07:00
Jarred Sumner
5465a3980a Proactively add these to the list 2023-04-06 19:30:50 -07:00
Jarred Sumner
b6bd7e24d7 Bump 2023-04-06 19:30:38 -07:00
dave caruso
e4e81bc49e fix: export constants from fs/promises (#2567)
* fix: export `constants` from `fs/promises`

* fix type tests

* third time's the charm fixing the typedef

* run fmt

* remove injected constant from fs, re-exporting from fs/promises
2023-04-06 15:55:23 -07:00
dave caruso
b8aca35b76 docs: add a section on uninstalling bun (#2560) 2023-04-06 15:12:59 -07:00
Jozef Steinhübl
68670eeb7b docs(cli/bunx): add notice (#2574)
* docs(cli/bunx): add notice bunx alias bun x

* docs: grammar
2023-04-06 15:09:20 -07:00
Dylan Conway
2b170c9d13 Fix toEqual when the second array has extra array holes (#2580)
* iterate through remaining indexes, keep prop identifier

* tests

* format
2023-04-06 14:49:07 -07:00
Zhongwei Yao
1d138057cb Add last modify field "mtime" for FileBlob (#1431) (#2491)
* Add lastModified field for FileBlob (#1431)

lastModified value is epoch timestamp in millisecond unit.

* update according to review comment.
2023-04-06 14:01:49 -07:00
dave caruso
f788519263 bun-types: infer strict Subprocess from Bun.spawn() options, part 2 (#2573) 2023-04-06 13:59:06 -07:00
Dylan Conway
8a73c2a453 cache needs to update, move to another process (#2578) 2023-04-06 13:58:01 -07:00
hiroki osame
21978dabe5 fix(ws): export Server (#2575) 2023-04-06 04:18:17 -07:00
hiroki osame
aa4c4a9b22 docs(CONTRIBUTING): referece development guide (#2576) 2023-04-06 04:18:02 -07:00
dave caruso
569d4940bb rebase (#1501) 2023-04-05 19:15:06 -07:00
Colin McDonnell
4af78c7d5a Update typecheck (#2572)
* Update typecheck

* Test ci

* Test ci

* Prettify files
2023-04-05 18:31:13 -07:00
Jarred Sumner
cfb1c661d5 prepend 2023-04-05 18:29:41 -07:00
Jake Boone
864302a634 Add tests for bun test with preload scripts (#2566)
* Use zsh-compatible syntax in cowsay example

zsh interprets the string !" differently than bash or sh, but we can use single quotes in all of them. See https://unix.stackexchange.com/a/497335/548905.

* Add tests for bun:test with preload scripts

* Look at `stderr` in `bun test --preload` tests
2023-04-05 18:28:41 -07:00
Jarred Sumner
b50f3d3f6f Disable buffering when we clear terminal
hopefully fixes an issue reported in Discord
2023-04-05 18:27:43 -07:00
Jarred Sumner
65d646bc68 Prettier 2023-04-05 18:27:02 -07:00
Ciro Spaciari
d8c467be42 fix(fetch.proxy) fix proxy authentication (#2554)
* fix proxy authentication

* add auth tests

* remove unused
2023-04-05 17:48:18 -07:00
hiroki osame
fd680d6c1d fix: build warnings (#2562) 2023-04-05 17:38:47 -07:00
Lawlzer
f7d0eee0ac In Documentation, move --watch before the script name (#2569)
Related message by Jarred: https://discord.com/channels/876711213126520882/876711213126520885/1093286199369682944
If you put `--watch` after the script name, it will not work.
2023-04-05 15:02:08 -07:00
Dylan Conway
ac092a1e04 fix deepEquals with array holes and accessors (#2557)
* `deepEqual` handles slow array indexes

* another test

* oops

* remove bad test

* compare indexes in non-strict mode

* more tests
2023-04-05 13:39:51 -07:00
hiroki osame
fd5bb6b201 fix: modules to have null prototype (#2561) 2023-04-05 00:31:58 -07:00
Jarred Sumner
d8360ab3cf 🕐 🕑 🕒 2023-04-04 16:50:03 -07:00
Jarred Sumner
a369fc8c89 Implement import.meta.main (#2556)
* Implement `import.meta.main`

* Update main-test-1.js

* Update fs.test.ts

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-04-04 16:49:33 -07:00
Jarred Sumner
54d6f95f43 Dylan/fix some failing tests (#2544)
* handle `umask()` invalid arguments

* move `bktree-fast` to test root, fix postinstall

* fix fs test

* could be baseline

* handle different timezones

* accidentally deleted tests

* fix hang in `AbortSignal.timeout`

* bring abort tests back

* Revert "bring abort tests back"

This reverts commit 0ff2ad5bf4.

* bunx node-gyp

* bun x

* fix typecheck

* test

* Update inspect.test.js

---------

Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
2023-04-04 16:47:57 -07:00
Colin McDonnell
76adc5be8a Add npm benchmark (#2555)
* Add install bench

* Update scripts and readme

* remove lockfiles

* Format bench

* Add dev instructions
2023-04-04 16:26:40 -07:00
Jarred Sumner
f3ab445c3f Use absolute paths more 2023-04-03 18:12:51 -07:00
Jarred Sumner
ae849528b8 Fix test failure 2023-04-03 18:11:14 -07:00
Colin McDonnell
6a66fffd39 Add rfcs under docs dir 2023-04-03 17:06:40 -07:00
Alex Lam S.L
9b0f12883c [install] reduce parallel HTTP requests under heavy load (#2536)
* [install] reduce parallel HTTP requests under heavy load

* make `max_simultaneous_requests` atomic
2023-04-02 22:32:19 -07:00
Jarred Sumner
fcd8b82864 Add stubs for missing node builtins (#2534)
* Stub `node:v8`

* Stub `node:trace_events`

* Stub `node:repl`

* Stub `node:inspector`

* Stub `node:http2`

* Stub `node:diagnostics_channel`

* Stub `node:dgram`

* Stub `node:cluster`

* Link stubs

* cleanup

* Clean up the test

* Implement `node:vm` stub

* Cleanup `v8` module stub

* Add missing `promises` export to node:stream

* Implement `node:stream/promise`

* Implement `node:assert/strict`

* cleanup

* better errors

* Increaase timeout

* Update inspector.exports.js

* Make the version consistent

* Implement `process.binding("constants")`

* Update runner.node.mjs

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-04-01 21:13:27 -07:00
Jake Boone
63d138b046 Update NodeJS LTS version in run_command.zig (#2533) 2023-04-01 17:49:56 -07:00
Dylan Conway
8904398619 remove debug symbols (#2527) 2023-03-31 19:20:11 -07:00
Alex Lam S.L
685e298146 report timed-out test as failure (#2523) 2023-03-31 07:14:55 -07:00
Alex Lam S.L
74cacffb0c [install] fix stale pointer with tarball URLs (#2520)
* [install] fix stale pointer with tarball URLs

fixes #2512

* `alloc()` & `free()` instead of fixed-size buffer
2023-03-30 21:54:56 -07:00
Alex Lam S.L
977446ef3c [install] fix re-install of git dependency (#2519)
- add tests for re-install of npm alias & GitHub URL
2023-03-30 19:50:23 -07:00
Dylan Conway
1fa7c1f79e Generate dependency files in make bindings (#2510)
* generate dependency files, include in makefile

* move `make webcrypto` to `make bindings`

* update more references to `make webcrypto`

* remove `-lwebcrypto`
2023-03-30 19:34:20 -07:00
Alex Lam S.L
758daa7367 [install] fix re-run of tarball URL from lockfile (#2507) 2023-03-29 20:38:19 -07:00
Adrien Zinger
95cb2b2ac2 Fix date format (#2422) (#2474)
* Fix date format (#2422)

* Add unit tests for #2422
2023-03-29 17:41:11 -07:00
994 changed files with 204242 additions and 73672 deletions

View File

@@ -1,28 +0,0 @@
# Bun's Dev Container
To get started, login to GitHub and clone bun's GitHub repo into `/build/bun`
# First time setup
```bash
gh auth login # if it fails to open a browser, use Personal Access Token instead
gh repo clone oven-sh/bun . -- --depth=1 --progress -j8
```
# Compile bun dependencies (zig is already compiled)
```bash
make devcontainer
```
# Build bun for development
```bash
make dev
```
# Run bun
```bash
bun-debug help
```

View File

@@ -1,70 +0,0 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/docker-existing-dockerfile
{
"name": "bun (Ubuntu)",
// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",
"hostRequirements": { "memory": "16gb" },
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerFile": "../Dockerfile.devcontainer",
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/zsh",
"zigLanguageClient.path": "/home/ubuntu/zls/zig-out/bin/zls",
"zig.zigPath": "/build/zig/zig",
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"AugusteRame.zls-vscode",
"ms-vscode.cpptools",
"/home/ubuntu/vscode-zig.vsix",
"vadimcn.vscode-lldb",
"esbenp.prettier-vscode",
"xaver.clang-format"
],
"postCreateCommand": "cd /build/bun; bash /build/getting-started.sh; cat /build/README.md",
"build": {
"target": "bun.devcontainer",
"cacheFrom": ["ghcr.io/oven-sh/bun.devcontainer:latest"],
"args": {
"BUILDARCH": "${localEnv:DOCKER_BUILDARCH:amd64}",
"--platform": "linux/${localEnv:DOCKER_BUILDARCH:amd64}",
"--tag": "ghcr.io/oven-sh/bun.devcontainer:latest"
}
},
"runArgs": [
"--ulimit",
"memlock=-1:-1",
"--ulimit",
"nofile=65536:65536",
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined"
],
"workspaceMount": "source=bun,target=/build/bun,type=volume",
"workspaceFolder": "/build/bun",
"mounts": [
"source=bun-install,target=/home/ubuntu/.bun,type=volume",
"source=bun-config,target=/home/ubuntu/.config,type=volume"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [3000, 8081, 8080]
// Uncomment the next line to run commands after the container is created - for example installing curl.
// "postCreateCommand": "apt-get update && apt-get install -y curl",
// Uncomment when using a ptrace-based debugger like C++, Go, and Rust
// Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker.
// "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],
// Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root.
// "remoteUser": "vscode"
}

View File

@@ -1,61 +0,0 @@
# /etc/security/limits.conf
#
#Each line describes a limit for a user in the form:
#
#<domain> <type> <item> <value>
#
#Where:
#<domain> can be:
# - a user name
# - a group name, with @group syntax
# - the wildcard *, for default entry
# - the wildcard %, can be also used with %group syntax,
# for maxlogin limit
# - NOTE: group and wildcard limits are not applied to root.
# To apply a limit to the root user, <domain> must be
# the literal username root.
#
#<type> can have the two values:
# - "soft" for enforcing the soft limits
# - "hard" for enforcing hard limits
#
#<item> can be one of the following:
# - core - limits the core file size (KB)
# - data - max data size (KB)
# - fsize - maximum filesize (KB)
# - memlock - max locked-in-memory address space (KB)
# - nofile - max number of open file descriptors
# - rss - max resident set size (KB)
# - stack - max stack size (KB)
# - cpu - max CPU time (MIN)
# - nproc - max number of processes
# - as - address space limit (KB)
# - maxlogins - max number of logins for this user
# - maxsyslogins - max number of logins on the system
# - priority - the priority to run user process with
# - locks - max number of file locks the user can hold
# - sigpending - max number of pending signals
# - msgqueue - max memory used by POSIX message queues (bytes)
# - nice - max nice priority allowed to raise to values: [-20, 19]
# - rtprio - max realtime priority
# - chroot - change root to directory (Debian-specific)
#
#<domain> <type> <item> <value>
#
* soft memlock 33554432
* hard memlock 33554432
* soft nofile 33554432
* hard nofile 33554432
#* soft core 0
#root hard core 100000
#* hard rss 10000
#@student hard nproc 20
#@faculty soft nproc 20
#@faculty hard nproc 50
#ftp hard nproc 0
#ftp - chroot /ftp
#@student - maxlogins 4
# End of file

View File

@@ -1,454 +0,0 @@
#!/usr/bin/env bash
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------
#
# Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/common.md
# Maintainer: The VS Code and Codespaces Teams
#
# Syntax: ./common-debian.sh [install zsh flag] [username] [user UID] [user GID] [upgrade packages flag] [install Oh My Zsh! flag] [Add non-free packages]
set -e
INSTALL_ZSH=${1:-"true"}
USERNAME=${2:-"automatic"}
USER_UID=${3:-"automatic"}
USER_GID=${4:-"automatic"}
UPGRADE_PACKAGES=${5:-"true"}
INSTALL_OH_MYS=${6:-"true"}
ADD_NON_FREE_PACKAGES=${7:-"false"}
SCRIPT_DIR="$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)"
MARKER_FILE="/usr/local/etc/vscode-dev-containers/common"
if [ "$(id -u)" -ne 0 ]; then
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
exit 1
fi
# Ensure that login shells get the correct path if the user updated the PATH using ENV.
rm -f /etc/profile.d/00-restore-env.sh
echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" > /etc/profile.d/00-restore-env.sh
chmod +x /etc/profile.d/00-restore-env.sh
# If in automatic mode, determine if a user already exists, if not use vscode
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
USERNAME=""
POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)")
for CURRENT_USER in ${POSSIBLE_USERS[@]}; do
if id -u ${CURRENT_USER} > /dev/null 2>&1; then
USERNAME=${CURRENT_USER}
break
fi
done
if [ "${USERNAME}" = "" ]; then
USERNAME=vscode
fi
elif [ "${USERNAME}" = "none" ]; then
USERNAME=root
USER_UID=0
USER_GID=0
fi
# Load markers to see which steps have already run
if [ -f "${MARKER_FILE}" ]; then
echo "Marker file found:"
cat "${MARKER_FILE}"
source "${MARKER_FILE}"
fi
# Ensure apt is in non-interactive to avoid prompts
export DEBIAN_FRONTEND=noninteractive
# Function to call apt-get if needed
apt_get_update_if_needed()
{
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
echo "Running apt-get update..."
apt-get update
else
echo "Skipping apt-get update."
fi
}
# Run install apt-utils to avoid debconf warning then verify presence of other common developer tools and dependencies
if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then
package_list="apt-utils \
openssh-client \
gnupg2 \
dirmngr \
iproute2 \
procps \
lsof \
htop \
net-tools \
psmisc \
curl \
wget \
rsync \
ca-certificates \
unzip \
zip \
nano \
vim-tiny \
less \
jq \
lsb-release \
apt-transport-https \
dialog \
libc6 \
libgcc1 \
libkrb5-3 \
libgssapi-krb5-2 \
libicu[0-9][0-9] \
liblttng-ust[0-9] \
libstdc++6 \
zlib1g \
locales \
sudo \
ncdu \
man-db \
strace \
manpages \
manpages-dev \
init-system-helpers"
# Needed for adding manpages-posix and manpages-posix-dev which are non-free packages in Debian
if [ "${ADD_NON_FREE_PACKAGES}" = "true" ]; then
# Bring in variables from /etc/os-release like VERSION_CODENAME
. /etc/os-release
sed -i -E "s/deb http:\/\/(deb|httpredir)\.debian\.org\/debian ${VERSION_CODENAME} main/deb http:\/\/\1\.debian\.org\/debian ${VERSION_CODENAME} main contrib non-free/" /etc/apt/sources.list
sed -i -E "s/deb-src http:\/\/(deb|httredir)\.debian\.org\/debian ${VERSION_CODENAME} main/deb http:\/\/\1\.debian\.org\/debian ${VERSION_CODENAME} main contrib non-free/" /etc/apt/sources.list
sed -i -E "s/deb http:\/\/(deb|httpredir)\.debian\.org\/debian ${VERSION_CODENAME}-updates main/deb http:\/\/\1\.debian\.org\/debian ${VERSION_CODENAME}-updates main contrib non-free/" /etc/apt/sources.list
sed -i -E "s/deb-src http:\/\/(deb|httpredir)\.debian\.org\/debian ${VERSION_CODENAME}-updates main/deb http:\/\/\1\.debian\.org\/debian ${VERSION_CODENAME}-updates main contrib non-free/" /etc/apt/sources.list
sed -i "s/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}\/updates main/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}\/updates main contrib non-free/" /etc/apt/sources.list
sed -i "s/deb-src http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}\/updates main/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}\/updates main contrib non-free/" /etc/apt/sources.list
sed -i "s/deb http:\/\/deb\.debian\.org\/debian ${VERSION_CODENAME}-backports main/deb http:\/\/deb\.debian\.org\/debian ${VERSION_CODENAME}-backports main contrib non-free/" /etc/apt/sources.list
sed -i "s/deb-src http:\/\/deb\.debian\.org\/debian ${VERSION_CODENAME}-backports main/deb http:\/\/deb\.debian\.org\/debian ${VERSION_CODENAME}-backports main contrib non-free/" /etc/apt/sources.list
# Handle bullseye location for security https://www.debian.org/releases/bullseye/amd64/release-notes/ch-information.en.html
sed -i "s/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}-security main/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}-security main contrib non-free/" /etc/apt/sources.list
sed -i "s/deb-src http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}-security main/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}-security main contrib non-free/" /etc/apt/sources.list
echo "Running apt-get update..."
apt-get update
package_list="${package_list} manpages-posix manpages-posix-dev"
else
apt_get_update_if_needed
fi
# Install libssl1.1 if available
if [[ ! -z $(apt-cache --names-only search ^libssl1.1$) ]]; then
package_list="${package_list} libssl1.1"
fi
# Install appropriate version of libssl1.0.x if available
libssl_package=$(dpkg-query -f '${db:Status-Abbrev}\t${binary:Package}\n' -W 'libssl1\.0\.?' 2>&1 || echo '')
if [ "$(echo "$LIlibssl_packageBSSL" | grep -o 'libssl1\.0\.[0-9]:' | uniq | sort | wc -l)" -eq 0 ]; then
if [[ ! -z $(apt-cache --names-only search ^libssl1.0.2$) ]]; then
# Debian 9
package_list="${package_list} libssl1.0.2"
elif [[ ! -z $(apt-cache --names-only search ^libssl1.0.0$) ]]; then
# Ubuntu 18.04, 16.04, earlier
package_list="${package_list} libssl1.0.0"
fi
fi
echo "Packages to verify are installed: ${package_list}"
apt-get -y install --no-install-recommends ${package_list} 2> >( grep -v 'debconf: delaying package configuration, since apt-utils is not installed' >&2 )
# Install git if not already installed (may be more recent than distro version)
if ! type git > /dev/null 2>&1; then
apt-get -y install --no-install-recommends git
fi
PACKAGES_ALREADY_INSTALLED="true"
fi
# Get to latest versions of all packages
if [ "${UPGRADE_PACKAGES}" = "true" ]; then
apt_get_update_if_needed
apt-get -y upgrade --no-install-recommends
apt-get autoremove -y
fi
# Ensure at least the en_US.UTF-8 UTF-8 locale is available.
# Common need for both applications and things like the agnoster ZSH theme.
if [ "${LOCALE_ALREADY_SET}" != "true" ] && ! grep -o -E '^\s*en_US.UTF-8\s+UTF-8' /etc/locale.gen > /dev/null; then
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
locale-gen
LOCALE_ALREADY_SET="true"
fi
# Create or update a non-root user to match UID/GID.
group_name="${USERNAME}"
if id -u ${USERNAME} > /dev/null 2>&1; then
# User exists, update if needed
if [ "${USER_GID}" != "automatic" ] && [ "$USER_GID" != "$(id -g $USERNAME)" ]; then
group_name="$(id -gn $USERNAME)"
groupmod --gid $USER_GID ${group_name}
usermod --gid $USER_GID $USERNAME
fi
if [ "${USER_UID}" != "automatic" ] && [ "$USER_UID" != "$(id -u $USERNAME)" ]; then
usermod --uid $USER_UID $USERNAME
fi
else
# Create user
if [ "${USER_GID}" = "automatic" ]; then
groupadd $USERNAME
else
groupadd --gid $USER_GID $USERNAME
fi
if [ "${USER_UID}" = "automatic" ]; then
useradd -s /bin/bash --gid $USERNAME -m $USERNAME
else
useradd -s /bin/bash --uid $USER_UID --gid $USERNAME -m $USERNAME
fi
fi
# Add sudo support for non-root user
if [ "${USERNAME}" != "root" ] && [ "${EXISTING_NON_ROOT_USER}" != "${USERNAME}" ]; then
echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME
chmod 0440 /etc/sudoers.d/$USERNAME
EXISTING_NON_ROOT_USER="${USERNAME}"
fi
# ** Shell customization section **
if [ "${USERNAME}" = "root" ]; then
user_rc_path="/root"
else
user_rc_path="/home/${USERNAME}"
fi
# Restore user .bashrc defaults from skeleton file if it doesn't exist or is empty
if [ ! -f "${user_rc_path}/.bashrc" ] || [ ! -s "${user_rc_path}/.bashrc" ] ; then
cp /etc/skel/.bashrc "${user_rc_path}/.bashrc"
fi
# Restore user .profile defaults from skeleton file if it doesn't exist or is empty
if [ ! -f "${user_rc_path}/.profile" ] || [ ! -s "${user_rc_path}/.profile" ] ; then
cp /etc/skel/.profile "${user_rc_path}/.profile"
fi
# .bashrc/.zshrc snippet
rc_snippet="$(cat << 'EOF'
if [ -z "${USER}" ]; then export USER=$(whoami); fi
if [[ "${PATH}" != *"$HOME/.local/bin"* ]]; then export PATH="${PATH}:$HOME/.local/bin"; fi
# Display optional first run image specific notice if configured and terminal is interactive
if [ -t 1 ] && [[ "${TERM_PROGRAM}" = "vscode" || "${TERM_PROGRAM}" = "codespaces" ]] && [ ! -f "$HOME/.config/vscode-dev-containers/first-run-notice-already-displayed" ]; then
if [ -f "/usr/local/etc/vscode-dev-containers/first-run-notice.txt" ]; then
cat "/usr/local/etc/vscode-dev-containers/first-run-notice.txt"
elif [ -f "/workspaces/.codespaces/shared/first-run-notice.txt" ]; then
cat "/workspaces/.codespaces/shared/first-run-notice.txt"
fi
mkdir -p "$HOME/.config/vscode-dev-containers"
# Mark first run notice as displayed after 10s to avoid problems with fast terminal refreshes hiding it
((sleep 10s; touch "$HOME/.config/vscode-dev-containers/first-run-notice-already-displayed") &)
fi
# Set the default git editor if not already set
if [ -z "$(git config --get core.editor)" ] && [ -z "${GIT_EDITOR}" ]; then
if [ "${TERM_PROGRAM}" = "vscode" ]; then
if [[ -n $(command -v code-insiders) && -z $(command -v code) ]]; then
export GIT_EDITOR="code-insiders --wait"
else
export GIT_EDITOR="code --wait"
fi
fi
fi
EOF
)"
# code shim, it fallbacks to code-insiders if code is not available
cat << 'EOF' > /usr/local/bin/code
#!/bin/sh
get_in_path_except_current() {
which -a "$1" | grep -A1 "$0" | grep -v "$0"
}
code="$(get_in_path_except_current code)"
if [ -n "$code" ]; then
exec "$code" "$@"
elif [ "$(command -v code-insiders)" ]; then
exec code-insiders "$@"
else
echo "code or code-insiders is not installed" >&2
exit 127
fi
EOF
chmod +x /usr/local/bin/code
# systemctl shim - tells people to use 'service' if systemd is not running
cat << 'EOF' > /usr/local/bin/systemctl
#!/bin/sh
set -e
if [ -d "/run/systemd/system" ]; then
exec /bin/systemctl "$@"
else
echo '\n"systemd" is not running in this container due to its overhead.\nUse the "service" command to start services instead. e.g.: \n\nservice --status-all'
fi
EOF
chmod +x /usr/local/bin/systemctl
# Codespaces bash and OMZ themes - partly inspired by https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/robbyrussell.zsh-theme
codespaces_bash="$(cat \
<<'EOF'
# Codespaces bash prompt theme
__bash_prompt() {
local userpart='`export XIT=$? \
&& [ ! -z "${GITHUB_USER}" ] && echo -n "\[\033[0;32m\]@${GITHUB_USER} " || echo -n "\[\033[0;32m\]\u " \
&& [ "$XIT" -ne "0" ] && echo -n "\[\033[1;31m\]➜" || echo -n "\[\033[0m\]➜"`'
local gitbranch='`\
if [ "$(git config --get codespaces-theme.hide-status 2>/dev/null)" != 1 ]; then \
export BRANCH=$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD 2>/dev/null); \
if [ "${BRANCH}" != "" ]; then \
echo -n "\[\033[0;36m\](\[\033[1;31m\]${BRANCH}" \
&& if git ls-files --error-unmatch -m --directory --no-empty-directory -o --exclude-standard ":/*" > /dev/null 2>&1; then \
echo -n " \[\033[1;33m\]✗"; \
fi \
&& echo -n "\[\033[0;36m\]) "; \
fi; \
fi`'
local lightblue='\[\033[1;34m\]'
local removecolor='\[\033[0m\]'
PS1="${userpart} ${lightblue}\w ${gitbranch}${removecolor}\$ "
unset -f __bash_prompt
}
__bash_prompt
EOF
)"
codespaces_zsh="$(cat \
<<'EOF'
# Codespaces zsh prompt theme
__zsh_prompt() {
local prompt_username
if [ ! -z "${GITHUB_USER}" ]; then
prompt_username="@${GITHUB_USER}"
else
prompt_username="%n"
fi
PROMPT="%{$fg[green]%}${prompt_username} %(?:%{$reset_color%}➜ :%{$fg_bold[red]%}➜ )" # User/exit code arrow
PROMPT+='%{$fg_bold[blue]%}%(5~|%-1~/…/%3~|%4~)%{$reset_color%} ' # cwd
PROMPT+='$([ "$(git config --get codespaces-theme.hide-status 2>/dev/null)" != 1 ] && git_prompt_info)' # Git status
PROMPT+='%{$fg[white]%}$ %{$reset_color%}'
unset -f __zsh_prompt
}
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[cyan]%}(%{$fg_bold[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg_bold[yellow]%}✗%{$fg_bold[cyan]%})"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[cyan]%})"
__zsh_prompt
EOF
)"
# Add RC snippet and custom bash prompt
if [ "${RC_SNIPPET_ALREADY_ADDED}" != "true" ]; then
echo "${rc_snippet}" >> /etc/bash.bashrc
echo "${codespaces_bash}" >> "${user_rc_path}/.bashrc"
echo 'export PROMPT_DIRTRIM=4' >> "${user_rc_path}/.bashrc"
if [ "${USERNAME}" != "root" ]; then
echo "${codespaces_bash}" >> "/root/.bashrc"
echo 'export PROMPT_DIRTRIM=4' >> "/root/.bashrc"
fi
chown ${USERNAME}:${group_name} "${user_rc_path}/.bashrc"
RC_SNIPPET_ALREADY_ADDED="true"
fi
# Optionally install and configure zsh and Oh My Zsh!
if [ "${INSTALL_ZSH}" = "true" ]; then
if ! type zsh > /dev/null 2>&1; then
apt_get_update_if_needed
apt-get install -y zsh
fi
if [ "${ZSH_ALREADY_INSTALLED}" != "true" ]; then
echo "${rc_snippet}" >> /etc/zsh/zshrc
ZSH_ALREADY_INSTALLED="true"
fi
# Adapted, simplified inline Oh My Zsh! install steps that adds, defaults to a codespaces theme.
# See https://github.com/ohmyzsh/ohmyzsh/blob/master/tools/install.sh for official script.
oh_my_install_dir="${user_rc_path}/.oh-my-zsh"
if [ ! -d "${oh_my_install_dir}" ] && [ "${INSTALL_OH_MYS}" = "true" ]; then
template_path="${oh_my_install_dir}/templates/zshrc.zsh-template"
user_rc_file="${user_rc_path}/.zshrc"
umask g-w,o-w
mkdir -p ${oh_my_install_dir}
git clone --depth=1 \
-c core.eol=lf \
-c core.autocrlf=false \
-c fsck.zeroPaddedFilemode=ignore \
-c fetch.fsck.zeroPaddedFilemode=ignore \
-c receive.fsck.zeroPaddedFilemode=ignore \
"https://github.com/ohmyzsh/ohmyzsh" "${oh_my_install_dir}" 2>&1
echo -e "$(cat "${template_path}")\nDISABLE_AUTO_UPDATE=true\nDISABLE_UPDATE_PROMPT=true" > ${user_rc_file}
sed -i -e 's/ZSH_THEME=.*/ZSH_THEME="codespaces"/g' ${user_rc_file}
mkdir -p ${oh_my_install_dir}/custom/themes
echo "${codespaces_zsh}" > "${oh_my_install_dir}/custom/themes/codespaces.zsh-theme"
# Shrink git while still enabling updates
cd "${oh_my_install_dir}"
git repack -a -d -f --depth=1 --window=1
# Copy to non-root user if one is specified
if [ "${USERNAME}" != "root" ]; then
cp -rf "${user_rc_file}" "${oh_my_install_dir}" /root
chown -R ${USERNAME}:${group_name} "${user_rc_path}"
fi
fi
fi
# Persist image metadata info, script if meta.env found in same directory
meta_info_script="$(cat << 'EOF'
#!/bin/sh
. /usr/local/etc/vscode-dev-containers/meta.env
# Minimal output
if [ "$1" = "version" ] || [ "$1" = "image-version" ]; then
echo "${VERSION}"
exit 0
elif [ "$1" = "release" ]; then
echo "${GIT_REPOSITORY_RELEASE}"
exit 0
elif [ "$1" = "content" ] || [ "$1" = "content-url" ] || [ "$1" = "contents" ] || [ "$1" = "contents-url" ]; then
echo "${CONTENTS_URL}"
exit 0
fi
#Full output
echo
echo "Development container image information"
echo
if [ ! -z "${VERSION}" ]; then echo "- Image version: ${VERSION}"; fi
if [ ! -z "${DEFINITION_ID}" ]; then echo "- Definition ID: ${DEFINITION_ID}"; fi
if [ ! -z "${VARIANT}" ]; then echo "- Variant: ${VARIANT}"; fi
if [ ! -z "${GIT_REPOSITORY}" ]; then echo "- Source code repository: ${GIT_REPOSITORY}"; fi
if [ ! -z "${GIT_REPOSITORY_RELEASE}" ]; then echo "- Source code release/branch: ${GIT_REPOSITORY_RELEASE}"; fi
if [ ! -z "${BUILD_TIMESTAMP}" ]; then echo "- Timestamp: ${BUILD_TIMESTAMP}"; fi
if [ ! -z "${CONTENTS_URL}" ]; then echo && echo "More info: ${CONTENTS_URL}"; fi
echo
EOF
)"
if [ -f "${SCRIPT_DIR}/meta.env" ]; then
mkdir -p /usr/local/etc/vscode-dev-containers/
cp -f "${SCRIPT_DIR}/meta.env" /usr/local/etc/vscode-dev-containers/meta.env
echo "${meta_info_script}" > /usr/local/bin/devcontainer-info
chmod +x /usr/local/bin/devcontainer-info
fi
# Write marker file
mkdir -p "$(dirname "${MARKER_FILE}")"
echo -e "\
PACKAGES_ALREADY_INSTALLED=${PACKAGES_ALREADY_INSTALLED}\n\
LOCALE_ALREADY_SET=${LOCALE_ALREADY_SET}\n\
EXISTING_NON_ROOT_USER=${EXISTING_NON_ROOT_USER}\n\
RC_SNIPPET_ALREADY_ADDED=${RC_SNIPPET_ALREADY_ADDED}\n\
ZSH_ALREADY_INSTALLED=${ZSH_ALREADY_INSTALLED}" > "${MARKER_FILE}"
echo "Done!"

View File

@@ -1,16 +0,0 @@
#!/bin/bash
echo "To get started, login to GitHub and clone bun's GitHub repo into /build/bun"
echo "If it fails to open a browser, login with a Personal Access Token instead"
echo "# First time setup"
echo "gh auth login"
echo "gh repo clone oven-sh/bun . -- --depth=1 --progress -j8"
echo ""
echo "# Compile bun dependencies (zig is already compiled)"
echo "make devcontainer"
echo ""
echo "# Build bun for development"
echo "make dev"
echo ""
echo "# Run bun"
echo "bun-debug"

View File

@@ -1,207 +0,0 @@
#!/usr/bin/env bash
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------
#
# Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/github.md
# Maintainer: The VS Code and Codespaces Teams
#
# Syntax: ./github-debian.sh [version]
CLI_VERSION=${1:-"latest"}
GITHUB_CLI_ARCHIVE_GPG_KEY=C99B11DEB97541F0
GPG_KEY_SERVERS="keyserver hkp://keyserver.ubuntu.com:80
keyserver hkps://keys.openpgp.org
keyserver hkp://keyserver.pgp.com"
set -e
if [ "$(id -u)" -ne 0 ]; then
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
exit 1
fi
# Get central common setting
get_common_setting() {
if [ "${common_settings_file_loaded}" != "true" ]; then
curl -sfL "https://aka.ms/vscode-dev-containers/script-library/settings.env" -o /tmp/vsdc-settings.env 2>/dev/null || echo "Could not download settings file. Skipping."
common_settings_file_loaded=true
fi
if [ -f "/tmp/vsdc-settings.env" ]; then
local multi_line=""
if [ "$2" = "true" ]; then multi_line="-z"; fi
local result="$(grep ${multi_line} -oP "$1=\"?\K[^\"]+" /tmp/vsdc-settings.env | tr -d '\0')"
if [ ! -z "${result}" ]; then declare -g $1="${result}"; fi
fi
echo "$1=${!1}"
}
# Import the specified key in a variable name passed in as
receive_gpg_keys() {
get_common_setting $1
local keys=${!1}
get_common_setting GPG_KEY_SERVERS true
# Use a temporary locaiton for gpg keys to avoid polluting image
export GNUPGHOME="/tmp/tmp-gnupg"
mkdir -p ${GNUPGHOME}
chmod 700 ${GNUPGHOME}
echo -e "disable-ipv6\n${GPG_KEY_SERVERS}" >${GNUPGHOME}/dirmngr.conf
# GPG key download sometimes fails for some reason and retrying fixes it.
local retry_count=0
local gpg_ok="false"
set +e
until [ "${gpg_ok}" = "true" ] || [ "${retry_count}" -eq "5" ]; do
echo "(*) Downloading GPG key..."
(echo "${keys}" | xargs -n 1 gpg --recv-keys) 2>&1 && gpg_ok="true"
if [ "${gpg_ok}" != "true" ]; then
echo "(*) Failed getting key, retring in 10s..."
((retry_count++))
sleep 10s
fi
done
set -e
if [ "${gpg_ok}" = "false" ]; then
echo "(!) Failed to get gpg key."
exit 1
fi
}
# Figure out correct version of a three part version number is not passed
find_version_from_git_tags() {
local variable_name=$1
local requested_version=${!variable_name}
if [ "${requested_version}" = "none" ]; then return; fi
local repository=$2
local prefix=${3:-"tags/v"}
local separator=${4:-"."}
local last_part_optional=${5:-"false"}
if [ "$(echo "${requested_version}" | grep -o "." | wc -l)" != "2" ]; then
local escaped_separator=${separator//./\\.}
local last_part
if [ "${last_part_optional}" = "true" ]; then
last_part="(${escaped_separator}[0-9]+)?"
else
last_part="${escaped_separator}[0-9]+"
fi
local regex="${prefix}\\K[0-9]+${escaped_separator}[0-9]+${last_part}$"
local version_list="$(git ls-remote --tags ${repository} | grep -oP "${regex}" | tr -d ' ' | tr "${separator}" "." | sort -rV)"
if [ "${requested_version}" = "latest" ] || [ "${requested_version}" = "current" ] || [ "${requested_version}" = "lts" ]; then
declare -g ${variable_name}="$(echo "${version_list}" | head -n 1)"
else
set +e
declare -g ${variable_name}="$(echo "${version_list}" | grep -E -m 1 "^${requested_version//./\\.}([\\.\\s]|$)")"
set -e
fi
fi
if [ -z "${!variable_name}" ] || ! echo "${version_list}" | grep "^${!variable_name//./\\.}$" >/dev/null 2>&1; then
echo -e "Invalid ${variable_name} value: ${requested_version}\nValid values:\n${version_list}" >&2
exit 1
fi
echo "${variable_name}=${!variable_name}"
}
# Import the specified key in a variable name passed in as
receive_gpg_keys() {
get_common_setting $1
local keys=${!1}
get_common_setting GPG_KEY_SERVERS true
local keyring_args=""
if [ ! -z "$2" ]; then
keyring_args="--no-default-keyring --keyring $2"
fi
# Use a temporary locaiton for gpg keys to avoid polluting image
export GNUPGHOME="/tmp/tmp-gnupg"
mkdir -p ${GNUPGHOME}
chmod 700 ${GNUPGHOME}
echo -e "disable-ipv6\n${GPG_KEY_SERVERS}" >${GNUPGHOME}/dirmngr.conf
# GPG key download sometimes fails for some reason and retrying fixes it.
local retry_count=0
local gpg_ok="false"
set +e
until [ "${gpg_ok}" = "true" ] || [ "${retry_count}" -eq "5" ]; do
echo "(*) Downloading GPG key..."
(echo "${keys}" | xargs -n 1 gpg -q ${keyring_args} --recv-keys) 2>&1 && gpg_ok="true"
if [ "${gpg_ok}" != "true" ]; then
echo "(*) Failed getting key, retring in 10s..."
((retry_count++))
sleep 10s
fi
done
set -e
if [ "${gpg_ok}" = "false" ]; then
echo "(!) Failed to get gpg key."
exit 1
fi
}
# Function to run apt-get if needed
apt_get_update_if_needed() {
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
echo "Running apt-get update..."
apt-get update
else
echo "Skipping apt-get update."
fi
}
# Checks if packages are installed and installs them if not
check_packages() {
if ! dpkg -s "$@" >/dev/null 2>&1; then
apt_get_update_if_needed
apt-get -y install --no-install-recommends "$@"
fi
}
# Fall back on direct download if no apt package exists
# Fetches .deb file to be installed with dpkg
install_deb_using_github() {
check_packages wget
arch=$(dpkg --print-architecture)
find_version_from_git_tags CLI_VERSION https://github.com/cli/cli
cli_filename="gh_${CLI_VERSION}_linux_${arch}.deb"
mkdir -p /tmp/ghcli
pushd /tmp/ghcli
wget https://github.com/cli/cli/releases/download/v${CLI_VERSION}/${cli_filename}
dpkg -i /tmp/ghcli/${cli_filename}
popd
rm -rf /tmp/ghcli
}
export DEBIAN_FRONTEND=noninteractive
# Install curl, apt-transport-https, curl, gpg, or dirmngr, git if missing
check_packages curl ca-certificates apt-transport-https dirmngr gnupg2
if ! type git >/dev/null 2>&1; then
apt_get_update_if_needed
apt-get -y install --no-install-recommends git
fi
# Soft version matching
if [ "${CLI_VERSION}" != "latest" ] && [ "${CLI_VERSION}" != "lts" ] && [ "${CLI_VERSION}" != "stable" ]; then
find_version_from_git_tags CLI_VERSION "https://github.com/cli/cli"
version_suffix="=${CLI_VERSION}"
else
version_suffix=""
fi
# Install the GitHub CLI
echo "Downloading github CLI..."
install_deb_using_github
# Method below does not work until cli/cli#6175 is fixed
# # Import key safely (new method rather than deprecated apt-key approach) and install
# . /etc/os-release
# receive_gpg_keys GITHUB_CLI_ARCHIVE_GPG_KEY /usr/share/keyrings/githubcli-archive-keyring.gpg
# echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" >/etc/apt/sources.list.d/github-cli.list
# apt-get update
# apt-get -y install "gh${version_suffix}"
# rm -rf "/tmp/gh/gnupg"
echo "Done!"

View File

@@ -1,7 +0,0 @@
#!/bin/bash
chsh -s $(which zsh)
sh -c "$(curl -fsSL https://starship.rs/install.sh) -- --platform linux_musl" -- --yes
echo "eval \"$(starship init zsh)\"" >>~/.zshrc
curl https://github.com/Jarred-Sumner/vscode-zig/releases/download/march18/zig-0.2.5.vsix >/home/ubuntu/vscode-zig.vsix

View File

@@ -1,7 +0,0 @@
#!/bin/bash
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 -Doptimize=ReleaseFast

View File

@@ -1,9 +0,0 @@
{
"folders": [
{
// Source code
"name": "bun",
"path": "bun"
},
]
}

View File

@@ -1,9 +0,0 @@
{
"zig_exe_path": "/build/zig/zig",
"enable_snippets": true,
"warn_style": false,
"enable_semantic_tokens": true,
"operator_completions": true,
"include_at_in_builtins": false,
"max_detail_length": 1048576
}

23
.gitattributes vendored
View File

@@ -8,3 +8,26 @@ src/bun.js/bindings/sqlite/sqlite3_local.h linguist-vendored
*.zig text eol=lf
src/bun.js/bindings/simdutf.cpp linguist-vendored
src/bun.js/bindings/simdutf.h linguist-vendored
src/js/out/WebCoreJSBuiltins.cpp linguist-generated
src/js/out/WebCoreJSBuiltins.h linguist-generated
src/js/out/WebCoreJSBuiltins.d.ts linguist-generated
src/bun.js/bindings/ZigGeneratedClasses.h linguist-generated
src/bun.js/bindings/ZigGeneratedClasses.cpp linguist-generated
src/bun.js/bindings/ZigGeneratedCode.h linguist-generated
src/bun.js/bindings/ZigGeneratedCode.cpp linguist-generated
src/bun.js/bindings/headers.h linguist-generated
src/bun.js/bindings/headers.zig linguist-generated
src/bun.js/bindings/JSSink.h linguist-generated
src/bun.js/bindings/JSSink.zig linguist-generated
src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h linguist-generated
src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h linguist-generated
src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h linguist-generated
src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h linguist-generated
docs/**/* linguist-documentation

View File

@@ -12,6 +12,7 @@ jobs:
deploy:
name: Deploy site
runs-on: ubuntu-latest
if: github.repository_owner == 'oven-sh'
steps:
- name: Trigger Vercel build
run: curl ${{ secrets.VERCEL_DEPLOY_HOOK }}
run: curl ${{ secrets.VERCEL_DEPLOY_HOOK }}

View File

@@ -0,0 +1,50 @@
name: bun-ecosystem-test
on:
schedule:
- cron: "0 15 * * *" # every day at 7am PST
workflow_dispatch:
inputs:
version:
description: "The version of Bun to run"
required: true
default: "canary"
type: string
jobs:
test:
name: ${{ matrix.tag }}
runs-on: ${{ matrix.os }}
if: github.repository_owner == 'oven-sh'
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
tag: linux-x64
url: linux/x64?avx2=true
- os: ubuntu-latest
tag: linux-x64-baseline
url: linux/x64?baseline=true
# FIXME: runner fails with "No tests found"?
#- os: macos-latest
# tag: darwin-x64
# url: darwin/x64?avx2=true
- os: macos-latest
tag: darwin-x64-baseline
url: darwin/x64?baseline=true
steps:
- id: checkout
name: Checkout
uses: Bhacaz/checkout-files@v2
with:
files: packages/bun-internal-test
- id: setup
name: Setup
uses: oven-sh/setup-bun@v1
with:
bun-download-url: https://bun.sh/download/${{ github.event.inputs.version }}/${{ matrix.url }}
- id: test
name: Test
working-directory: packages/bun-internal-test
run: bun run test:ecosystem

View File

@@ -1,4 +1,9 @@
name: bun-linux
concurrency:
group: bun-linux-aarch64-${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
@@ -21,6 +26,7 @@ jobs:
linux:
name: ${{matrix.tag}}
runs-on: ${{matrix.runner}}
if: github.repository_owner == 'oven-sh'
timeout-minutes: 90
strategy:
matrix:
@@ -30,7 +36,7 @@ jobs:
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_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-linux-arm64-lto.tar.gz"
webkit_basename: "bun-webkit-linux-arm64-lto"
build_machine_arch: aarch64

View File

@@ -1,4 +1,9 @@
name: bun-linux
concurrency:
group: bun-linux-build-${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
@@ -30,6 +35,7 @@ jobs:
linux:
name: ${{matrix.tag}}
runs-on: ${{matrix.runner}}
if: github.repository_owner == 'oven-sh'
timeout-minutes: 90
strategy:
fail-fast: false
@@ -40,7 +46,7 @@ jobs:
arch: x86_64
build_arch: amd64
runner: big-ubuntu
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-linux-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-linux-amd64-lto.tar.gz"
webkit_basename: "bun-webkit-linux-amd64-lto"
build_machine_arch: x86_64
- cpu: nehalem
@@ -48,7 +54,7 @@ jobs:
arch: x86_64
build_arch: amd64
runner: big-ubuntu
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-linux-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-linux-amd64-lto.tar.gz"
webkit_basename: "bun-webkit-linux-amd64-lto"
build_machine_arch: x86_64
@@ -152,7 +158,7 @@ jobs:
runs-on: ubuntu-latest
needs: [linux]
if: github.event_name == 'pull_request'
timeout-minutes: 10
timeout-minutes: 20
outputs:
failing_tests: ${{ steps.test.outputs.failing_tests }}
failing_tests_count: ${{ steps.test.outputs.failing_tests_count }}

View File

@@ -1,4 +1,9 @@
name: bun-macOS-aarch64
concurrency:
group: bun-macOS-aarch64-${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
@@ -28,6 +33,7 @@ jobs:
macos-object-files:
name: macOS Object
runs-on: med-ubuntu
if: github.repository_owner == 'oven-sh'
strategy:
matrix:
include:
@@ -100,6 +106,7 @@ jobs:
macOS-cpp:
name: macOS C++
runs-on: ${{ matrix.runner }}
if: github.repository_owner == 'oven-sh'
timeout-minutes: 90
strategy:
matrix:
@@ -110,7 +117,7 @@ jobs:
# 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/feb25/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: true
# compile_obj: false
# - cpu: haswell
@@ -119,7 +126,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/feb25/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: true
# compile_obj: false
# - cpu: nehalem
@@ -128,7 +135,7 @@ jobs:
# 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/feb25/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: false
# compile_obj: true
# - cpu: haswell
@@ -137,7 +144,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/feb25/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: false
# compile_obj: true
- cpu: native
@@ -145,7 +152,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/feb25/bun-webkit-macos-arm64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-arm64-lto.tar.gz"
runner: macos-arm64
dependencies: true
compile_obj: true
@@ -237,6 +244,7 @@ jobs:
macOS:
name: macOS Link
runs-on: ${{ matrix.runner }}
if: github.repository_owner == 'oven-sh'
needs: [macOS-cpp, macos-object-files]
timeout-minutes: 90
strategy:
@@ -249,7 +257,7 @@ jobs:
# package: bun-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64-baseline
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz"
# - cpu: haswell
# arch: x86_64
# tag: bun-darwin-x64
@@ -257,14 +265,14 @@ jobs:
# package: bun-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/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/feb25/bun-webkit-macos-arm64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-arm64-lto.tar.gz"
runner: macos-arm64
steps:
- uses: actions/checkout@v3
@@ -333,7 +341,7 @@ jobs:
rm -rf packages/${{ matrix.package }}
mkdir -p packages/${{ matrix.package }}
mv ${{ runner.temp }}/release/* packages/${{ matrix.package }}/
make webcrypto bun-link-lld-release copy-to-bun-release-dir-bin
make bun-link-lld-release copy-to-bun-release-dir-bin
- name: Zip
env:
CPU_TARGET: ${{ matrix.cpu }}
@@ -388,7 +396,7 @@ jobs:
name: Tests ${{matrix.tag}}
runs-on: ${{ matrix.runner }}
needs: [macOS]
if: github.event_name == 'pull_request'
if: github.event_name == 'pull_request' && github.repository_owner == 'oven-sh'
timeout-minutes: 10
outputs:
failing_tests: ${{ steps.test.outputs.failing_tests }}

View File

@@ -1,4 +1,9 @@
name: bun-macOS-x64-baseline
concurrency:
group: bun-macOS-x64-baseline-${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
@@ -28,6 +33,7 @@ jobs:
macos-object-files:
name: macOS Object
runs-on: med-ubuntu
if: github.repository_owner == 'oven-sh'
strategy:
matrix:
include:
@@ -100,6 +106,7 @@ jobs:
macOS-cpp:
name: macOS C++
runs-on: ${{ matrix.runner }}
if: github.repository_owner == 'oven-sh'
timeout-minutes: 90
strategy:
matrix:
@@ -110,7 +117,7 @@ jobs:
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/feb25/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz"
dependencies: true
compile_obj: false
# - cpu: haswell
@@ -119,7 +126,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/feb25/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: true
# compile_obj: false
- cpu: nehalem
@@ -128,7 +135,7 @@ jobs:
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/feb25/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz"
dependencies: false
compile_obj: true
# - cpu: haswell
@@ -137,7 +144,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/feb25/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: false
# compile_obj: true
# - cpu: native
@@ -145,7 +152,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/feb25/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz"
# runner: macos-arm64
# dependencies: true
# compile_obj: true
@@ -238,6 +245,7 @@ jobs:
macOS:
name: macOS Link
runs-on: ${{ matrix.runner }}
if: github.repository_owner == 'oven-sh'
needs: [macOS-cpp, macos-object-files]
timeout-minutes: 90
strategy:
@@ -250,7 +258,7 @@ jobs:
package: bun-darwin-x64
runner: macos-11
artifact: bun-obj-darwin-x64-baseline
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz"
# - cpu: haswell
# arch: x86_64
# tag: bun-darwin-x64
@@ -258,14 +266,14 @@ jobs:
# package: bun-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/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/feb25/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz"
# runner: macos-arm64
steps:
- uses: actions/checkout@v3
@@ -337,7 +345,7 @@ jobs:
rm -rf packages/${{ matrix.package }}
mkdir -p packages/${{ matrix.package }}
mv ${{ runner.temp }}/release/* packages/${{ matrix.package }}/
make webcrypto bun-link-lld-release copy-to-bun-release-dir-bin
make bun-link-lld-release copy-to-bun-release-dir-bin
- name: Zip
env:
CPU_TARGET: ${{ matrix.cpu }}
@@ -392,8 +400,8 @@ jobs:
name: Tests ${{matrix.tag}}
runs-on: ${{ matrix.runner }}
needs: [macOS]
if: github.event_name == 'pull_request'
timeout-minutes: 10
if: github.event_name == 'pull_request' && github.repository_owner == 'oven-sh'
timeout-minutes: 30
outputs:
failing_tests: ${{ steps.test.outputs.failing_tests }}
failing_tests_count: ${{ steps.test.outputs.failing_tests_count }}

View File

@@ -1,4 +1,9 @@
name: bun-macOS-x64
concurrency:
group: bun-macOS-x64-${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
@@ -28,6 +33,7 @@ jobs:
macos-object-files:
name: macOS Object
runs-on: med-ubuntu
if: github.repository_owner == 'oven-sh'
strategy:
matrix:
include:
@@ -100,6 +106,7 @@ jobs:
macOS-cpp:
name: macOS C++
runs-on: ${{ matrix.runner }}
if: github.repository_owner == 'oven-sh'
timeout-minutes: 90
strategy:
matrix:
@@ -110,7 +117,7 @@ jobs:
# 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/feb25/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: true
# compile_obj: false
- cpu: haswell
@@ -119,7 +126,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/feb25/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz"
dependencies: true
compile_obj: false
# - cpu: nehalem
@@ -128,7 +135,7 @@ jobs:
# 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/feb25/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz"
# dependencies: false
# compile_obj: true
- cpu: haswell
@@ -137,7 +144,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/feb25/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz"
dependencies: false
compile_obj: true
# - cpu: native
@@ -145,7 +152,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/feb25/bun-webkit-macos-arm64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-arm64-lto.tar.gz"
# runner: macos-arm64
# dependencies: true
# compile_obj: true
@@ -240,6 +247,7 @@ jobs:
macOS:
name: macOS Link
runs-on: ${{ matrix.runner }}
if: github.repository_owner == 'oven-sh'
needs: [macOS-cpp, macos-object-files]
timeout-minutes: 90
strategy:
@@ -252,7 +260,7 @@ jobs:
# package: bun-darwin-x64
# runner: macos-11
# artifact: bun-obj-darwin-x64-baseline
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-macos-amd64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz"
- cpu: haswell
arch: x86_64
tag: bun-darwin-x64
@@ -260,14 +268,14 @@ jobs:
package: bun-darwin-x64
runner: macos-11
artifact: bun-obj-darwin-x64
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/feb25/bun-webkit-macos-amd64-lto.tar.gz"
webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/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/feb25/bun-webkit-macos-arm64-lto.tar.gz"
# webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-arm64-lto.tar.gz"
# runner: macos-arm64
steps:
- uses: actions/checkout@v3
@@ -339,7 +347,7 @@ jobs:
rm -rf packages/${{ matrix.package }}
mkdir -p packages/${{ matrix.package }}
mv ${{ runner.temp }}/release/* packages/${{ matrix.package }}/
make webcrypto bun-link-lld-release copy-to-bun-release-dir-bin
make bun-link-lld-release copy-to-bun-release-dir-bin
- name: Zip
env:
CPU_TARGET: ${{ matrix.cpu }}
@@ -394,8 +402,8 @@ jobs:
name: Tests ${{matrix.tag}}
runs-on: ${{ matrix.runner }}
needs: [macOS]
if: github.event_name == 'pull_request'
timeout-minutes: 10
if: github.event_name == 'pull_request' && github.repository_owner == 'oven-sh'
timeout-minutes: 30
outputs:
failing_tests: ${{ steps.test.outputs.failing_tests }}
failing_tests_count: ${{ steps.test.outputs.failing_tests_count }}

View File

@@ -8,6 +8,7 @@ jobs:
sign:
name: Sign Release
runs-on: ubuntu-latest
if: github.repository_owner == 'oven-sh'
defaults:
run:
working-directory: packages/bun-release
@@ -39,6 +40,8 @@ jobs:
npm:
name: Release to NPM
runs-on: ubuntu-latest
needs: sign
if: github.repository_owner == 'oven-sh'
defaults:
run:
working-directory: packages/bun-release
@@ -107,6 +110,7 @@ jobs:
name: Release to Dockerhub
runs-on: ubuntu-latest
needs: sign
if: github.repository_owner == 'oven-sh'
steps:
- id: checkout
name: Checkout
@@ -144,3 +148,32 @@ jobs:
labels: ${{ steps.metadata.outputs.labels }}
build-args: |
BUN_VERSION=canary
s3:
name: Upload to S3
runs-on: ubuntu-latest
needs: sign
if: github.repository_owner == 'oven-sh'
defaults:
run:
working-directory: packages/bun-release
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
- id: setup-bun
name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: canary
- id: bun-install
name: Install Dependencies
run: bun install
- id: bun-run
name: Release
run: bun upload-s3 -- canary
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
AWS_ENDPOINT: ${{ secrets.AWS_ENDPOINT }}
AWS_BUCKET: bun

View File

@@ -11,6 +11,7 @@ jobs:
npm-types:
name: Release types to NPM
runs-on: ubuntu-latest
if: github.repository_owner == 'oven-sh'
defaults:
run:
working-directory: packages/bun-types

View File

@@ -14,6 +14,7 @@ jobs:
sign:
name: Sign Release
runs-on: ubuntu-latest
if: github.repository_owner == 'oven-sh'
defaults:
run:
working-directory: packages/bun-release
@@ -52,6 +53,8 @@ jobs:
npm:
name: Release to NPM
runs-on: ubuntu-latest
needs: sign
if: github.repository_owner == 'oven-sh'
defaults:
run:
working-directory: packages/bun-release
@@ -83,6 +86,8 @@ jobs:
npm-types:
name: Release types to NPM
runs-on: ubuntu-latest
needs: sign
if: github.repository_owner == 'oven-sh'
defaults:
run:
working-directory: packages/bun-types
@@ -125,6 +130,7 @@ jobs:
name: Release to Dockerhub
runs-on: ubuntu-latest
needs: sign
if: github.repository_owner == 'oven-sh'
steps:
- id: checkout
name: Checkout
@@ -174,6 +180,8 @@ jobs:
homebrew:
name: Release to Homebrew
runs-on: ubuntu-latest
needs: sign
if: github.repository_owner == 'oven-sh'
steps:
- id: checkout
name: Checkout
@@ -211,3 +219,39 @@ jobs:
commit_user_name: robobun
commit_user_email: robobun@oven.sh
commit_author: robobun <robobun@oven.sh>
s3:
name: Upload to S3
runs-on: ubuntu-latest
needs: sign
if: github.repository_owner == 'oven-sh'
defaults:
run:
working-directory: packages/bun-release
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v3
- id: setup-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-s3 -- "${{ env.TAG }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
AWS_ENDPOINT: ${{ secrets.AWS_ENDPOINT }}
AWS_BUCKET: bun

View File

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

View File

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

View File

@@ -1,7 +1,7 @@
name: zig-fmt
env:
ZIG_VERSION: 0.11.0-dev.1783+436e99d13
ZIG_VERSION: 0.11.0-dev.2571+31738de28
on:
pull_request:

11
.gitignore vendored
View File

@@ -13,7 +13,7 @@ dist
*.log
*.out.js
*.out.refresh.js
/package-lock.json
**/package-lock.json
build
*.wat
zig-out
@@ -45,6 +45,7 @@ outcss
txt.js
.idea
.vscode/cpp*
.vscode/clang*
node_modules_*
*.jsb
@@ -109,8 +110,14 @@ misctools/machbench
bun-webkit
src/deps/c-ares/build
src/bun.js/bindings-obj
src/bun.js/debug-bindings-obj
failing-tests.txt
test.txt
myscript.sh
myscript.sh
cold-jsc-start
cold-jsc-start.d
/test.ts

4
.gitmodules vendored
View File

@@ -65,3 +65,7 @@ fetchRecurseSubmodules = false
[submodule "src/deps/c-ares"]
path = src/deps/c-ares
url = https://github.com/c-ares/c-ares.git
[submodule "src/deps/zstd"]
path = src/deps/zstd
url = https://github.com/facebook/zstd.git
ignore = dirty

View File

@@ -1,6 +1,6 @@
src/fallback.html
src/bun.js/WebKit
src/bun.js/builtins/js
src/js/out
src/*.out.js
src/*out.*.js
src/deps
@@ -10,3 +10,4 @@ test/snapshots
test/snapshots-no-hmr
test/js/deno/*.test.ts
test/js/deno/**/*.test.ts
bench/react-hello-world/react-hello-world.node.js

View File

@@ -7,3 +7,7 @@ if [ -d ./node_modules/bun-webkit ]; then
# get the first matching bun-webkit-* directory name
ln -s ./node_modules/$(ls ./node_modules | grep bun-webkit- | head -n 1) ./bun-webkit
fi
# sets up vscode C++ intellisense
rm -f .vscode/clang++
ln -s $(which clang++-15 || which clang++) .vscode/clang++ 2>/dev/null

View File

@@ -2,9 +2,7 @@
"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/",
@@ -17,15 +15,15 @@
"${workspaceFolder}/src/bun.js/bindings/webcore/",
"${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/js/builtins/",
"${workspaceFolder}/src/js/out",
"${workspaceFolder}/src/deps/boringssl/include/",
"${workspaceFolder}/src/deps",
"${workspaceFolder}/src/deps/uws/uSockets/src"
"${workspaceFolder}/src/deps/uws/uSockets/src",
"${workspaceFolder}/src/deps/uws/src"
],
"browse": {
"path": [
"${workspaceFolder}/../webkit-build/include/",
"${workspaceFolder}/bun-webkit/include/",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/",
"${workspaceFolder}/src/bun.js/WebKit/WebKitBuild/Release/ICU/Headers/",
@@ -35,12 +33,14 @@
"${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/bindings/webcore/",
"${workspaceFolder}/src/js/builtins/*",
"${workspaceFolder}/src/js/out/*",
"${workspaceFolder}/src/bun.js/modules/*",
"${workspaceFolder}/src/deps",
"${workspaceFolder}/src/deps/boringssl/include/",
"${workspaceFolder}/src/deps/uws/uSockets/src"
"${workspaceFolder}/src/deps/uws/uSockets/src",
"${workspaceFolder}/src/deps/uws/src"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ".vscode/cppdb"
@@ -57,7 +57,7 @@
"DU_DISABLE_RENAMING=1"
],
"macFrameworkPath": [],
"compilerPath": "/opt/homebrew/opt/llvm/bin/clang++",
"compilerPath": "${workspaceFolder}/.vscode/clang++",
"cStandard": "c17",
"cppStandard": "c++20"
}

View File

@@ -1,3 +1,10 @@
{
"recommendations": ["ziglang.vscode-zig", "esbenp.prettier-vscode", "xaver.clang-format", "vadimcn.vscode-lldb"]
"recommendations": [
"ziglang.vscode-zig",
"esbenp.prettier-vscode",
"xaver.clang-format",
"vadimcn.vscode-lldb",
"bierner.comment-tagged-templates",
"ms-vscode.cpptools"
]
}

265
.vscode/launch.json generated vendored
View File

@@ -1,129 +1,209 @@
{
// The usage of BUN_GARBAGE_COLLECTOR_LEVEL=2 is important for debugging
// It will force the garbage collector to run after every test and every call to expect()
// it makes our tests very slow
// But it helps catch memory bugs
// SIGHUP must be ignored or the debugger will pause when a spawned subprocess exits:
// { "initCommands": ["process handle -p false -s false -n false SIGHUP"] }
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "bun test",
"name": "bun test [file]",
"program": "bun-debug",
"args": ["wiptest", "${file}"],
"cwd": "${workspaceFolder}",
"args": ["test", "${file}"],
"cwd": "${fileDirname}",
"env": {
"FORCE_COLOR": "1"
"FORCE_COLOR": "1",
"BUN_DEBUG_QUIET_LOGS": "1",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2"
},
"initCommands": ["process handle -p false -s false -n false SIGHUP"],
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "bun test --watch",
"name": "bun test [file] (fast)",
"program": "bun-debug",
"args": ["--watch", "test", "${file}"],
"cwd": "${workspaceFolder}",
"args": ["test", "${file}"],
"cwd": "${fileDirname}",
"env": {
"FORCE_COLOR": "1",
"BUN_DEBUG_QUIET_LOGS": "1"
},
"initCommands": ["process handle -p false -s false -n false SIGHUP"],
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "bun test [file] (verbose)",
"program": "bun-debug",
"args": ["test", "${file}"],
"cwd": "${fileDirname}",
"env": {
"FORCE_COLOR": "1"
},
"initCommands": ["process handle -p false -s false -n false SIGHUP"],
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "bun test (all)",
"name": "bun test [file] --watch",
"program": "bun-debug",
"args": ["wiptest"],
"args": ["test", "--watch", "${file}"],
"cwd": "${fileDirname}",
"env": {
"FORCE_COLOR": "1",
"BUN_DEBUG_QUIET_LOGS": "1"
},
"initCommands": ["process handle -p false -s false -n false SIGHUP"],
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "bun test [file] --only",
"program": "bun-debug",
"args": ["test", "--only", "${file}"],
"cwd": "${fileDirname}",
"env": {
"FORCE_COLOR": "1",
"BUN_DEBUG_QUIET_LOGS": "1"
},
"initCommands": ["process handle -p false -s false -n false SIGHUP"],
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "bun test [*]",
"program": "bun-debug",
"args": ["test"],
"cwd": "${workspaceFolder}/test",
"env": {
"FORCE_COLOR": "1",
"BUN_DEBUG_QUIET_LOGS": "1",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2"
},
"initCommands": ["process handle -p false -s false -n false SIGHUP"],
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "bun run current file",
"name": "bun test [*] (fast)",
"program": "bun-debug",
"args": ["${file}"],
"cwd": "${file}/../../",
"args": ["test"],
"cwd": "${workspaceFolder}/test",
"env": {
"FORCE_COLOR": "1"
"FORCE_COLOR": "1",
"BUN_DEBUG_QUIET_LOGS": "1"
},
"initCommands": ["process handle -p false -s false -n false SIGHUP"],
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "bun run (watch)",
"name": "bun test [*] --only",
"program": "bun-debug",
"args": ["--watch", "${file}"],
"cwd": "${file}/../../",
"args": ["test", "--only"],
"cwd": "${workspaceFolder}/test",
"env": {
"FORCE_COLOR": "1"
"FORCE_COLOR": "1",
"BUN_DEBUG_QUIET_LOGS": "1"
},
"initCommands": ["process handle -p false -s false -n false SIGHUP"],
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "bun run (hot)",
"name": "bun run [file]",
"program": "bun-debug",
"args": ["--hot", "${file}"],
"cwd": "${file}/../../",
"args": ["run", "${file}"],
"cwd": "${fileDirname}",
"env": {
"FORCE_COLOR": "1"
"FORCE_COLOR": "1",
"BUN_DEBUG_QUIET_LOGS": "1"
},
"initCommands": ["process handle -p false -s false -n false SIGHUP"],
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "bun run",
"name": "bun run [Inspect]",
"program": "bun-debug",
"args": ["check.tsx", "-c"],
"cwd": "${env:HOME}/Build/react-ssr",
"args": ["--inspect-brk", "${file}"],
"cwd": "${fileDirname}",
"env": {
"FORCE_COLOR": "1"
},
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "bun http example",
"program": "bun-debug",
"args": ["run", "examples/http.ts"],
"cwd": "${workspaceFolder}",
"env": {
"FORCE_COLOR": "1"
"FORCE_COLOR": "1",
"BUN_DEBUG_QUIET_LOGS": "1"
},
"initCommands": ["process handle -p false -s false -n false SIGHUP"],
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "bun http file example",
"name": "bun run [file] (gc)",
"program": "bun-debug",
"args": ["run", "examples/bun/http-file.ts"],
"cwd": "${workspaceFolder}",
"args": ["run", "${file}"],
"cwd": "${fileDirname}",
"env": {
"FORCE_COLOR": "1"
"FORCE_COLOR": "1",
"BUN_DEBUG_QUIET_LOGS": "1",
"BUN_GARBAGE_COLLECTOR_LEVEL": "2"
},
"initCommands": ["process handle -p false -s false -n false SIGHUP"],
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "bun html-rewriter example",
"name": "bun run [file] (verbose)",
"program": "bun-debug",
"args": ["run", "examples/bun/html-rewriter.ts"],
"cwd": "${workspaceFolder}",
"args": ["run", "${file}"],
"cwd": "${fileDirname}",
"env": {
"FORCE_COLOR": "1"
},
"initCommands": ["process handle -p false -s false -n false SIGHUP"],
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "bun run [file] --watch",
"program": "bun-debug",
"args": ["run", "--watch", "${file}"],
"cwd": "${fileDirname}",
"env": {
"FORCE_COLOR": "1"
},
"initCommands": ["process handle -p false -s false -n false SIGHUP"],
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "bun run [file] --hot",
"program": "bun-debug",
"args": ["run", "--hot", "${file}"],
"cwd": "${fileDirname}",
"env": {
"FORCE_COLOR": "1"
},
"initCommands": ["process handle -p false -s false -n false SIGHUP"],
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
@@ -138,11 +218,100 @@
"request": "launch",
"name": "bun build debug",
"program": "bun-debug",
"args": ["build", "--platform=bun", "--outdir=/tmp/testout", "${file}"],
"cwd": "${file}/../../",
"args": ["bun", "${file}"],
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"env": {
"BUN_CONFIG_MINIFY_WHITESPACE": "1"
},
// SIGHUP must be ignored or the debugger will pause when a spawned subprocess exits.
"initCommands": ["process handle -p false -s false -n false SIGHUP"]
},
{
"type": "lldb",
"request": "launch",
"name": "bun build debug out.js",
"program": "bun-debug",
"args": ["--outfile=out.js", "bun", "${file}"],
"cwd": "${file}/../",
"console": "internalConsole",
"env": {
"BUN_CONFIG_MINIFY_WHITESPACE": "1"
}
},
{
"type": "lldb",
"request": "launch",
"name": "bun build debug STDOUT",
"program": "bun-debug",
"args": ["bun", "${file}"],
"cwd": "${file}/../",
"console": "internalConsole",
"env": {}
},
{
"type": "lldb",
"request": "launch",
"name": "bun build debug (no splitting, browser entry)",
"program": "bun-debug",
"args": [
"--entry-names=./[name].[ext]",
"--outdir=/Users/jarred/Code/bun-rsc/.rsc-no-split",
"--platform=browser",
"bun",
"./quick.tsx"
],
"cwd": "/Users/jarred/Code/bun-rsc",
"console": "internalConsole",
"env": {
"NODE_ENV": "production"
// "BUN_DEBUG_QUIET_LOGS": "1"
// "BUN_DUMP_SYMBOLS": "1"
}
},
{
"type": "lldb",
"request": "launch",
"name": "bun build debug (splitting, rsc)",
"program": "bun-debug",
"args": [
"--entry-names=./[name].[ext]",
"--outdir=/Users/jarred/Code/bun-rsc/.rsc-split",
"--server-components",
"--platform=bun",
"--splitting",
"bun",
"/Users/jarred/Code/bun-rsc/components/Message.tsx",
"/Users/jarred/Code/bun-rsc/components/Button.tsx"
],
"cwd": "/Users/jarred/Code/bun-rsc",
"console": "internalConsole",
"env": {
"NODE_ENV": "production"
// "BUN_DEBUG_QUIET_LOGS": "1"
// "BUN_DUMP_SYMBOLS": "1"
}
},
{
"type": "lldb",
"request": "launch",
"name": "bun build debug (NO splitting, rsc)",
"program": "bun-debug",
"args": [
"--entry-names=./[name].[ext]",
"--outdir=/Users/jarred/Code/bun-rsc/.rsccheck",
"--server-components",
"--platform=bun",
"bun",
"/Users/jarred/Code/bun-rsc/pages/index.js"
],
"cwd": "/Users/jarred/Code/bun-rsc",
"console": "internalConsole",
"env": {
"NODE_ENV": "production"
// "BUN_DEBUG_QUIET_LOGS": "1"
// "BUN_DUMP_SYMBOLS": "1"
}
},
{

38
.vscode/settings.json vendored
View File

@@ -7,10 +7,7 @@
"search.followSymlinks": false,
"search.useIgnoreFiles": true,
"zig.buildOnSave": false,
"zig.buildArgs": [
"obj",
"-Dfor-editor"
],
"zig.buildArgs": ["obj", "-Dfor-editor"],
"zig.buildOption": "build",
"zig.buildFilePath": "${workspaceFolder}/build.zig",
"[zig]": {
@@ -27,6 +24,8 @@
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"zig.zls.enableInlayHints": false,
"[jsx]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
@@ -38,13 +37,11 @@
"[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.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.wordWrap": "on",
"editor.quickSuggestions": {
@@ -78,7 +75,9 @@
"src/deps/lol-html": true,
"src/deps/c-ares": true,
"src/deps/tinycc": true,
"test/snippets/package-json-exports/_node_modules_copy": true
"src/deps/zstd": true,
"test/snippets/package-json-exports/_node_modules_copy": true,
"src/js/out": true
},
"C_Cpp.files.exclude": {
"**/.vscode": true,
@@ -205,12 +204,21 @@
"compare": "cpp",
"concepts": "cpp",
"typeindex": "cpp",
"__verbose_abort": "cpp"
"__verbose_abort": "cpp",
"__std_stream": "cpp",
"any": "cpp",
"charconv": "cpp",
"csignal": "cpp",
"format": "cpp",
"forward_list": "cpp",
"future": "cpp",
"regex": "cpp",
"span": "cpp",
"valarray": "cpp",
"codecvt": "cpp"
},
"cmake.configureOnOpen": false,
"C_Cpp.errorSquiggles": "Enabled",
"eslint.workingDirectories": [
"packages/bun-types"
],
"files.insertFinalNewline": true
}
"C_Cpp.errorSquiggles": "enabled",
"eslint.workingDirectories": ["packages/bun-types"],
"typescript.tsdk": "node_modules/typescript/lib"
}

View File

@@ -1,6 +1,6 @@
# 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.
> **Important:** 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
@@ -16,6 +16,10 @@ Today (February 2023), Bun's codebase has five distinct parts:
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.
## Getting started
Please refer to [Bun's Development Guide](https://bun.sh/docs/project/development) to get your dev environment setup!
## Memory management in Bun
For the Zig code, please:
@@ -55,7 +59,9 @@ The module loader is in [`src/bun.js/module_loader.zig`](src/bun.js/module_loade
### JavaScript Builtins
JavaScript builtins are located in [`src/bun.js/builtins/*.js`](src/bun.js/builtins).
TODO: update this with the new build process that uses TypeScript and `$` instead of `@`.
JavaScript builtins are located in [`src/js/builtins/*.ts`](src/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).

View File

@@ -10,9 +10,9 @@ ARG ARCH=x86_64
ARG BUILD_MACHINE_ARCH=x86_64
ARG TRIPLET=${ARCH}-linux-gnu
ARG BUILDARCH=amd64
ARG WEBKIT_TAG=feb9
ARG WEBKIT_TAG=may20
ARG ZIG_TAG=jul1
ARG ZIG_VERSION="0.11.0-dev.1783+436e99d13"
ARG ZIG_VERSION="0.11.0-dev.2571+31738de28"
ARG WEBKIT_BASENAME="bun-webkit-linux-$BUILDARCH"
ARG ZIG_FOLDERNAME=zig-linux-${BUILD_MACHINE_ARCH}-${ZIG_VERSION}
@@ -20,7 +20,7 @@ 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://ziglang.org/builds/${ZIG_FILENAME}"
ARG GIT_SHA=""
ARG BUN_BASE_VERSION=0.5
ARG BUN_BASE_VERSION=0.6
FROM bitnami/minideb:bullseye as bun-base
@@ -468,13 +468,13 @@ WORKDIR $BUN_DIR
ENV JSC_BASE_DIR=${WEBKIT_DIR}
ENV LIB_ICU_PATH=${WEBKIT_DIR}/lib
# Required for `make webcrypto`
# Required for webcrypto bindings
COPY src/deps/boringssl/include ${BUN_DIR}/src/deps/boringssl/include
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
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 release-bindings -j10 && mv src/bun.js/bindings-obj/* /tmp
FROM bun-base as sqlite
@@ -503,10 +503,36 @@ ENV LIB_ICU_PATH=${WEBKIT_DIR}/lib
RUN --mount=type=cache,target=/ccache cd $BUN_DIR && make sqlite
FROM bun-base as zstd
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
COPY Makefile ${BUN_DIR}/Makefile
COPY src/deps/zstd ${BUN_DIR}/src/deps/zstd
COPY .prettierrc.cjs ${BUN_DIR}/.prettierrc.cjs
WORKDIR $BUN_DIR
ENV JSC_BASE_DIR=${WEBKIT_DIR}
ENV LIB_ICU_PATH=${WEBKIT_DIR}/lib
RUN --mount=type=cache,target=/ccache cd $BUN_DIR && make zstd
FROM scratch as build_release_cpp
COPY --from=compile_cpp /tmp/*.o /
COPY --from=compile_cpp /tmp/libwebcrypto.a /
FROM prepare_release as build_release
@@ -536,6 +562,7 @@ 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=picohttp ${BUN_DEPS_OUT_DIR}/*.o ${BUN_DEPS_OUT_DIR}/
COPY --from=sqlite ${BUN_DEPS_OUT_DIR}/*.o ${BUN_DEPS_OUT_DIR}/
COPY --from=zstd ${BUN_DEPS_OUT_DIR}/*.a ${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}/

View File

@@ -1,126 +0,0 @@
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
ARG DEBIAN_FRONTEND
ARG GITHUB_WORKSPACE
ARG BUILDARCH
ARG ZIG_PATH
ARG WEBKIT_DIR
ARG BUN_RELEASE_DIR
ARG BUN_DEPS_OUT_DIR
ARG BUN_DIR
ARG BUN_PACKAGES_DIR
ENV WEBKIT_OUT_DIR ${WEBKIT_DIR}
ENV PATH "$ZIG_PATH:$PATH"
ENV JSC_BASE_DIR $WEBKIT_OUT_DIR
ENV LIB_ICU_PATH ${WEBKIT_OUT_DIR}/lib
ENV BUN_RELEASE_DIR ${BUN_RELEASE_DIR}
ENV PATH "${BUN_PACKAGES_DIR}/bun-linux-x64:${BUN_PACKAGES_DIR}/bun-linux-aarch64:${BUN_PACKAGES_DIR}/debug-bun-linux-x64:${BUN_PACKAGES_DIR}/debug-bun-linux-aarch64:$PATH"
ENV PATH "/home/ubuntu/zls/zig-out/bin:$PATH"
ENV BUN_INSTALL /home/ubuntu/.bun
ENV XDG_CONFIG_HOME /home/ubuntu/.config
WORKDIR ${GITHUB_WORKSPACE}
RUN apt-get update && \
apt-get install --no-install-recommends -y wget gnupg2 curl lsb-release wget software-properties-common && \
add-apt-repository ppa:longsleep/golang-backports && \
wget https://apt.llvm.org/llvm.sh --no-check-certificate && \
chmod +x llvm.sh && \
./llvm.sh 15 && \
curl -fsSL https://deb.nodesource.com/setup_16.x | bash - && \
apt-get update && \
apt-get install --no-install-recommends -y \
ca-certificates \
curl \
gnupg2 \
software-properties-common \
cmake \
build-essential \
git \
libssl-dev \
ruby \
liblld-15-dev \
libclang-15-dev \
nodejs \
gcc \
g++ \
clang-15 \
clang-format-15 \
libc++-15-dev \
libc++abi-15-dev \
lld-15 \
libicu-dev \
wget \
rustc \
cargo \
unzip \
tar \
golang-go ninja-build pkg-config automake autoconf libtool curl && \
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-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
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/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-15 90
COPY .devcontainer/workspace.code-workspace $GITHUB_WORKSPACE/workspace.code-workspace
COPY .devcontainer/zls.json $GITHUB_WORKSPACE/workspace.code-workspace
COPY .devcontainer/limits.conf /etc/security/limits.conf
COPY ".devcontainer/scripts/" /scripts/
COPY ".devcontainer/scripts/getting-started.sh" $GITHUB_WORKSPACE/getting-started.sh
COPY ".devcontainer/README.md" $GITHUB_WORKSPACE/README.md
ENV JSC_BASE_DIR=$WEBKIT_DIR
ENV WEBKIT_RELEASE_DIR=$WEBKIT_DIR
ENV WEBKIT_DEBUG_DIR=$WEBKIT_DIR
ENV WEBKIT_RELEASE_DIR_LTO=$WEBKIT_DIR
RUN mkdir -p /home/ubuntu/.bun /home/ubuntu/.config $GITHUB_WORKSPACE/bun && \
bash /scripts/common-debian.sh && \
bash /scripts/github.sh && \
bash /scripts/nice.sh && \
bash /scripts/zig-env.sh
COPY .devcontainer/zls.json /home/ubuntu/.config/zls.json

334
Makefile
View File

@@ -1,4 +1,4 @@
SHELL := $(shell which bash) # Use bash syntax to be consistent
SHELL := $(shell which bash) # Use bash syntax to be consistent
OS_NAME := $(shell uname -s | tr '[:upper:]' '[:lower:]')
ARCH_NAME_RAW := $(shell uname -m)
@@ -20,6 +20,7 @@ CPU_TARGET ?= native
MARCH_NATIVE = -mtune=$(CPU_TARGET)
NATIVE_OR_OLD_MARCH =
MMD_IF_LOCAL =
DEFAULT_MIN_MACOS_VERSION=
ARCH_NAME :=
DOCKER_BUILDARCH =
@@ -39,11 +40,17 @@ NATIVE_OR_OLD_MARCH = -march=nehalem
endif
MIN_MACOS_VERSION ?= $(DEFAULT_MIN_MACOS_VERSION)
BUN_BASE_VERSION = 0.5
BUN_BASE_VERSION = 0.6
CI ?= false
AR=
BUN_OR_NODE = $(shell which bun || which node)
ifeq ($(CI), false)
MMD_IF_LOCAL = -MMD
endif
BUN_OR_NODE = $(shell which bun 2>/dev/null || which node 2>/dev/null)
CXX_VERSION=c++2a
TRIPLET = $(OS_NAME)-$(ARCH_NAME)
@@ -52,30 +59,32 @@ PACKAGES_REALPATH = $(realpath packages)
PACKAGE_DIR = $(PACKAGES_REALPATH)/$(PACKAGE_NAME)
DEBUG_PACKAGE_DIR = $(PACKAGES_REALPATH)/debug-$(PACKAGE_NAME)
RELEASE_BUN = $(PACKAGE_DIR)/bun
DEBUG_BIN = $(DEBUG_PACKAGE_DIR)/
DEBUG_BIN = $(DEBUG_PACKAGE_DIR)
DEBUG_BUN = $(DEBUG_BIN)/bun-debug
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-15)
PRETTIER ?= $(shell which prettier 2>/dev/null || echo "./node_modules/.bin/prettier")
ESBUILD = $(shell which esbuild 2>/dev/null || echo "./node_modules/.bin/esbuild")
DSYMUTIL ?= $(shell which dsymutil 2>/dev/null || which dsymutil-15 2>/dev/null)
WEBKIT_DIR ?= $(realpath src/bun.js/WebKit)
WEBKIT_RELEASE_DIR ?= $(WEBKIT_DIR)/WebKitBuild/Release
WEBKIT_DEBUG_DIR ?= $(WEBKIT_DIR)/WebKitBuild/Debug
WEBKIT_RELEASE_DIR_LTO ?= $(WEBKIT_DIR)/WebKitBuild/ReleaseLTO
NPM_CLIENT ?= $(shell which bun || which npm)
ZIG ?= $(shell which zig || echo -e "error: Missing zig. Please make sure zig is in PATH. Or set ZIG=/path/to-zig-executable")
NPM_CLIENT ?= $(shell which bun 2>/dev/null || which npm 2>/dev/null)
ZIG ?= $(shell which zig 2>/dev/null || echo -e "error: Missing zig. Please make sure zig is in PATH. Or set ZIG=/path/to-zig-executable")
# We must use the same compiler version for the JavaScriptCore bindings and JavaScriptCore
# If we don't do this, strange memory allocation failures occur.
# This is easier to happen than you'd expect.
# Using realpath here causes issues because clang uses clang++ as a symlink
# so if that's resolved, it won't build for C++
REAL_CC = $(shell which clang-15 || which clang)
REAL_CXX = $(shell which clang++-15 || which clang++)
REAL_CC = $(shell which clang-15 2>/dev/null || which clang 2>/dev/null)
REAL_CXX = $(shell which clang++-15 2>/dev/null || which clang++ 2>/dev/null)
CLANG_FORMAT = $(shell which clang-format-15 2>/dev/null || which clang-format 2>/dev/null)
CC = $(REAL_CC)
CXX = $(REAL_CXX)
@@ -85,7 +94,7 @@ CCACHE_PATH := $(shell which ccache 2>/dev/null)
CCACHE_CC_FLAG = CC=$(CCACHE_CC_OR_CC)
ifeq (,$(findstring,$(shell which ccache),ccache))
ifeq (,$(findstring,$(shell which ccache 2>/dev/null),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
@@ -117,7 +126,7 @@ ifeq ($(OS_NAME),darwin)
endif
# macOS sed is different
SED = $(shell which gsed || which sed)
SED = $(shell which gsed 2>/dev/null || which sed 2>/dev/null)
BUN_DIR ?= $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
BUN_DEPS_DIR ?= $(shell pwd)/src/deps
@@ -146,7 +155,7 @@ CMAKE_FLAGS_WITHOUT_RELEASE = -DCMAKE_C_COMPILER=$(CC) \
-DCMAKE_OSX_DEPLOYMENT_TARGET=$(MIN_MACOS_VERSION) \
$(CMAKE_CXX_COMPILER_LAUNCHER_FLAG) \
-DCMAKE_AR=$(AR) \
-DCMAKE_RANLIB=$(which llvm-15-ranlib || which llvm-ranlib)
-DCMAKE_RANLIB=$(which llvm-15-ranlib 2>/dev/null || which llvm-ranlib 2>/dev/null)
@@ -168,11 +177,11 @@ endif
ifeq ($(OS_NAME),linux)
LIBICONV_PATH =
AR = $(shell which llvm-ar-15 || which llvm-ar || which ar)
AR = $(shell which llvm-ar-15 2>/dev/null || which llvm-ar 2>/dev/null || which ar 2>/dev/null)
endif
OPTIMIZATION_LEVEL=-O3 $(MARCH_NATIVE)
DEBUG_OPTIMIZATION_LEVEL= -O1 $(MARCH_NATIVE)
DEBUG_OPTIMIZATION_LEVEL= -O1 $(MARCH_NATIVE) -gdwarf-4
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
@@ -184,14 +193,13 @@ DEFAULT_USE_BMALLOC := 1
USE_BMALLOC ?= DEFAULT_USE_BMALLOC
# Set via postinstall
AUTO_JSX_BASE_DIR ?= $(realpath $(firstword $(wildcard bun-webkit)))
ifeq (,$(AUTO_JSX_BASE_DIR))
AUTO_JSX_BASE_DIR ?= $(HOME)/webkit-build
ifeq (,$(realpath $(JSC_BASE_DIR)))
JSC_BASE_DIR = $(realpath $(firstword $(wildcard bun-webkit)))
ifeq (,$(JSC_BASE_DIR))
JSC_BASE_DIR = $(HOME)/webkit-build
endif
endif
JSC_BASE_DIR ?= $(AUTO_JSX_BASE_DIR)
DEFAULT_JSC_LIB :=
DEFAULT_JSC_LIB_DEBUG :=
@@ -266,7 +274,7 @@ STRIP=/usr/bin/strip
endif
ifeq ($(OS_NAME),linux)
STRIP=$(shell which llvm-strip || which llvm-strip-15 || which strip || echo "Missing strip")
STRIP=$(shell which llvm-strip 2>/dev/null || which llvm-strip-15 2>/dev/null || which strip 2>/dev/null || echo "Missing strip")
endif
@@ -285,26 +293,32 @@ SRC_WEBCORE_FILES := $(wildcard $(SRC_DIR)/webcore/*.cpp)
SRC_SQLITE_FILES := $(wildcard $(SRC_DIR)/sqlite/*.cpp)
SRC_NODE_OS_FILES := $(wildcard $(SRC_DIR)/node_os/*.cpp)
SRC_IO_FILES := $(wildcard src/io/*.cpp)
SRC_BUILTINS_FILES := $(wildcard src/bun.js/builtins/*.cpp)
SRC_BUILTINS_FILES := $(wildcard src/js/out/*.cpp)
SRC_WEBCRYPTO_FILES := $(wildcard $(SRC_DIR)/webcrypto/*.cpp)
OBJ_FILES := $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SRC_FILES))
WEBCORE_OBJ_FILES := $(patsubst $(SRC_DIR)/webcore/%.cpp,$(OBJ_DIR)/%.o,$(SRC_WEBCORE_FILES))
SQLITE_OBJ_FILES := $(patsubst $(SRC_DIR)/sqlite/%.cpp,$(OBJ_DIR)/%.o,$(SRC_SQLITE_FILES))
NODE_OS_OBJ_FILES := $(patsubst $(SRC_DIR)/node_os/%.cpp,$(OBJ_DIR)/%.o,$(SRC_NODE_OS_FILES))
BUILTINS_OBJ_FILES := $(patsubst src/bun.js/builtins/%.cpp,$(OBJ_DIR)/%.o,$(SRC_BUILTINS_FILES))
BUILTINS_OBJ_FILES := $(patsubst src/js/out/%.cpp,$(OBJ_DIR)/%.o,$(SRC_BUILTINS_FILES))
IO_FILES := $(patsubst src/io/%.cpp,$(OBJ_DIR)/%.o,$(SRC_IO_FILES))
MODULES_OBJ_FILES := $(patsubst $(MODULES_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(MODULES_FILES))
WEBCRYPTO_OBJ_FILES := $(patsubst $(SRC_DIR)/webcrypto/%.cpp,$(OBJ_DIR)/%.o,$(SRC_WEBCRYPTO_FILES))
DEBUG_OBJ_FILES := $(patsubst $(SRC_DIR)/%.cpp,$(DEBUG_OBJ_DIR)/%.o,$(SRC_FILES))
DEBUG_WEBCORE_OBJ_FILES := $(patsubst $(SRC_DIR)/webcore/%.cpp,$(DEBUG_OBJ_DIR)/%.o,$(SRC_WEBCORE_FILES))
DEBUG_SQLITE_OBJ_FILES := $(patsubst $(SRC_DIR)/sqlite/%.cpp,$(DEBUG_OBJ_DIR)/%.o,$(SRC_SQLITE_FILES))
DEBUG_NODE_OS_OBJ_FILES := $(patsubst $(SRC_DIR)/node_os/%.cpp,$(DEBUG_OBJ_DIR)/%.o,$(SRC_NODE_OS_FILES))
DEBUG_BUILTINS_OBJ_FILES := $(patsubst src/bun.js/builtins/%.cpp,$(DEBUG_OBJ_DIR)/%.o,$(SRC_BUILTINS_FILES))
DEBUG_BUILTINS_OBJ_FILES := $(patsubst src/js/out/%.cpp,$(DEBUG_OBJ_DIR)/%.o,$(SRC_BUILTINS_FILES))
DEBUG_IO_FILES := $(patsubst src/io/%.cpp,$(DEBUG_OBJ_DIR)/%.o,$(SRC_IO_FILES))
DEBUG_MODULES_OBJ_FILES := $(patsubst $(MODULES_DIR)/%.cpp,$(DEBUG_OBJ_DIR)/%.o,$(MODULES_FILES))
DEBUG_WEBCRYPTO_OBJ_FILES := $(patsubst $(SRC_DIR)/webcrypto/%.cpp, $(DEBUG_OBJ_DIR)/%.o, $(SRC_WEBCRYPTO_FILES))
BINDINGS_OBJ := $(OBJ_FILES) $(WEBCORE_OBJ_FILES) $(SQLITE_OBJ_FILES) $(NODE_OS_OBJ_FILES) $(BUILTINS_OBJ_FILES) $(IO_FILES) $(MODULES_OBJ_FILES)
DEBUG_BINDINGS_OBJ := $(DEBUG_OBJ_FILES) $(DEBUG_WEBCORE_OBJ_FILES) $(DEBUG_SQLITE_OBJ_FILES) $(DEBUG_NODE_OS_OBJ_FILES) $(DEBUG_BUILTINS_OBJ_FILES) $(DEBUG_IO_FILES) $(DEBUG_MODULES_OBJ_FILES)
BINDINGS_OBJ := $(OBJ_FILES) $(WEBCORE_OBJ_FILES) $(SQLITE_OBJ_FILES) $(NODE_OS_OBJ_FILES) $(BUILTINS_OBJ_FILES) $(IO_FILES) $(MODULES_OBJ_FILES) $(WEBCRYPTO_OBJ_FILES)
DEBUG_BINDINGS_OBJ := $(DEBUG_OBJ_FILES) $(DEBUG_WEBCORE_OBJ_FILES) $(DEBUG_SQLITE_OBJ_FILES) $(DEBUG_NODE_OS_OBJ_FILES) $(DEBUG_BUILTINS_OBJ_FILES) $(DEBUG_IO_FILES) $(DEBUG_MODULES_OBJ_FILES) $(DEBUG_WEBCRYPTO_OBJ_FILES)
-include $(BINDINGS_OBJ:.o=.d)
-include $(DEBUG_BINDINGS_OBJ:.o=.d)
ALL_JSC_INCLUDE_DIRS := -I$(WEBKIT_RELEASE_DIR)/WTF/Headers \
-I$(WEBKIT_RELEASE_DIR)/ICU/Headers \
@@ -316,12 +330,12 @@ ALL_JSC_INCLUDE_DIRS := -I$(WEBKIT_RELEASE_DIR)/WTF/Headers \
-I$(WEBKIT_RELEASE_DIR)/WTF/PrivateHeaders
SHARED_INCLUDE_DIR = -I$(realpath src/bun.js/bindings)/ \
-I$(realpath src/bun.js/builtins/) \
-I$(realpath src/js/builtins/) \
-I$(realpath src/js/out/) \
-I$(realpath src/bun.js/bindings) \
-I$(realpath src/bun.js/bindings/webcore) \
-I$(realpath src/bun.js/bindings/webcrypto) \
-I$(realpath src/bun.js/bindings/sqlite) \
-I$(realpath src/bun.js/builtins/cpp) \
-I$(realpath src/bun.js/bindings/node_os) \
-I$(realpath src/bun.js/modules) \
-I$(JSC_INCLUDE_DIR)
@@ -338,7 +352,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 -I$(BUN_DEPS_DIR)/c-ares/include
INCLUDE_DIRS := $(UWS_INCLUDE_DIR) -I$(BUN_DEPS_DIR)/mimalloc/include -I$(BUN_DEPS_DIR)/zstd/include -Isrc/napi -I$(BUN_DEPS_DIR)/boringssl/include -I$(BUN_DEPS_DIR)/c-ares/include
ifeq ($(OS_NAME),linux)
@@ -446,6 +460,7 @@ ARCHIVE_FILES_WITHOUT_LIBCRYPTO = $(MINIMUM_ARCHIVE_FILES) \
-ltcc \
-lusockets \
-lcares \
-lzstd \
$(BUN_DEPS_OUT_DIR)/libuwsockets.o
ARCHIVE_FILES = $(ARCHIVE_FILES_WITHOUT_LIBCRYPTO)
@@ -499,9 +514,9 @@ BUN_LLD_FLAGS_WITHOUT_JSC = $(ARCHIVE_FILES) \
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
BUN_LLD_FLAGS = $(BUN_LLD_FLAGS_WITHOUT_JSC) $(WRAP_SYMBOLS_ON_LINUX) $(JSC_FILES) $(BINDINGS_OBJ)
BUN_LLD_FLAGS_DEBUG = $(BUN_LLD_FLAGS_WITHOUT_JSC) $(WRAP_SYMBOLS_ON_LINUX) $(JSC_FILES_DEBUG) $(DEBUG_BINDINGS_OBJ)
BUN_LLD_FLAGS_FAST = $(BUN_LLD_FLAGS_WITHOUT_JSC) $(WRAP_SYMBOLS_ON_LINUX) $(JSC_FILES_DEBUG) $(BINDINGS_OBJ)
CLANG_VERSION = $(shell $(CC) --version | awk '/version/ {for(i=1; i<=NF; i++){if($$i=="version"){split($$(i+1),v,".");print v[1]}}}')
@@ -512,14 +527,16 @@ bun:
npm-install:
$(NPM_CLIENT) install --ignore-scripts --production
npm-install-dev:
$(NPM_CLIENT) install
cd test && $(NPM_CLIENT) install
cd packages/bun-types && $(NPM_CLIENT) install --production
print-% : ; @echo $* = $($*)
get-% : ; @echo $($*)
print-version:
@echo $(PACKAGE_JSON_VERSION)
# Prevent dependency on libtcc1 so it doesn't do filesystem lookups
TINYCC_CFLAGS= -DTCC_LIBTCC1=\"\0\"
@@ -534,24 +551,15 @@ tinycc:
make -j10 && \
cp $(TINYCC_DIR)/*.a $(BUN_DEPS_OUT_DIR)
PYTHON=$(shell which python 2>/dev/null || which python3 2>/dev/null || which python2 2>/dev/null)
.PHONY: builtins
builtins: ## to generate builtins
rm -f src/bun.js/bindings/*Builtin*.cpp src/bun.js/bindings/*Builtin*.h src/bun.js/bindings/*Builtin*.cpp
rm -rf src/bun.js/builtins/cpp
mkdir -p src/bun.js/builtins/cpp
$(shell which python || which python2) $(realpath $(WEBKIT_DIR)/Source/JavaScriptCore/Scripts/generate-js-builtins.py) -i $(realpath src)/bun.js/builtins/js -o $(realpath src)/bun.js/builtins/cpp --framework WebCore --force
$(shell which python || which python2) $(realpath $(WEBKIT_DIR)/Source/JavaScriptCore/Scripts/generate-js-builtins.py) -i $(realpath src)/bun.js/builtins/js -o $(realpath src)/bun.js/builtins/cpp --framework WebCore --wrappers-only
rm -rf /tmp/1.h src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.h.1
echo -e '// clang-format off\nnamespace Zig { class GlobalObject; }\n#include "root.h"\n' >> /tmp/1.h
cat /tmp/1.h src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.h > src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.h.1
mv src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.h.1 src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.h
rm -rf /tmp/1.h src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.h.1
echo -e '// clang-format off\nnamespace Zig { class GlobalObject; }\n#include "root.h"\n' >> /tmp/1.h
cat /tmp/1.h src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.cpp > src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.cpp.1
mv src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.cpp.1 src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.cpp
$(SED) -i -e 's/class JSDOMGlobalObject/using JSDOMGlobalObject = Zig::GlobalObject/' src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.h
# this is the one we actually build
mv src/bun.js/builtins/cpp/*JSBuiltin*.cpp src/bun.js/builtins
builtins:
NODE_ENV=production bun src/js/builtins/codegen/index.ts --minify
.PHONY: esm
esm:
NODE_ENV=production bun src/js/build-esm.ts
.PHONY: generate-builtins
generate-builtins: builtins
@@ -622,6 +630,9 @@ compile-ffi-test:
sqlite:
.PHONY: zstd
zstd:
cd $(BUN_DEPS_DIR)/zstd && rm -rf build-cmake-debug && cmake $(CMAKE_FLAGS) -DZSTD_BUILD_STATIC=ON -B build-cmake-debug -S build/cmake -G Ninja && ninja -C build-cmake-debug && cp build-cmake-debug/lib/libzstd.a $(BUN_DEPS_OUT_DIR)/libzstd.a
.PHONY: libarchive
libarchive:
@@ -659,21 +670,27 @@ require:
@echo "Checking if the required utilities are available..."
@if [ $(CLANG_VERSION) -lt "15" ]; then echo -e "ERROR: clang version >=15 required, found: $(CLANG_VERSION). Install with:\n\n $(POSIX_PKG_MANAGER) install llvm@15"; exit 1; fi
@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)
@$(PYTHON) --version >/dev/null 2>&1 || (echo -e "ERROR: python is required."; exit 1)
@$(ESBUILD) --version >/dev/null 2>&1 || (echo -e "ERROR: esbuild is required."; exit 1)
@$(NPM_CLIENT) --version >/dev/null 2>&1 || (echo -e "ERROR: NPM client (bun or npm) is required."; exit 1)
@go version >/dev/null 2>&1 || (echo -e "ERROR: go is required."; exit 1)
@which aclocal > /dev/null || (echo -e "ERROR: automake is required. Install with:\n\n $(POSIX_PKG_MANAGER) install automake"; exit 1)
@which $(LIBTOOL) > /dev/null || (echo -e "ERROR: libtool is required. Install with:\n\n $(POSIX_PKG_MANAGER) install libtool"; exit 1)
@which ninja > /dev/null || (echo -e "ERROR: Ninja is required. Install with:\n\n $(POSIX_PKG_MANAGER) install $(PKGNAME_NINJA)"; exit 1)
@which pkg-config > /dev/null || (echo -e "ERROR: pkg-config is required. Install with:\n\n $(POSIX_PKG_MANAGER) install pkg-config"; exit 1)
@echo "You have the dependencies installed! Woo"
init-submodules:
git submodule update --init --recursive --progress --depth=1
git submodule update --init --recursive --progress --depth=1 --checkout
.PHONY: build-obj
build-obj:
$(ZIG) build obj -Doptimize=ReleaseFast -Dcpu="$(CPU_TARGET)"
.PHONY: build-obj-small
build-obj-small:
$(ZIG) build obj -Doptimize=ReleaseSmall -Dcpu="$(CPU_TARGET)"
.PHONY: dev-build-obj-wasm
dev-build-obj-wasm:
$(ZIG) build bun-wasm -Dtarget=wasm32-freestanding
@@ -714,10 +731,10 @@ wasm: api build-obj-wasm-small
@cp src/api/schema.d.ts packages/bun-wasm/schema.d.ts
@cp src/api/schema.js packages/bun-wasm/schema.js
@cd packages/bun-wasm && $(NPM_CLIENT) run tsc -- -p .
@esbuild --sourcemap=external --external:fs --define:process.env.NODE_ENV='"production"' --outdir=packages/bun-wasm --target=esnext --bundle packages/bun-wasm/index.ts --format=esm --minify 2> /dev/null
@$(ESBUILD) --sourcemap=external --external:fs --define:process.env.NODE_ENV='"production"' --outdir=packages/bun-wasm --target=esnext --bundle packages/bun-wasm/index.ts --format=esm --minify 2> /dev/null
@mv packages/bun-wasm/index.js packages/bun-wasm/index.mjs
@mv packages/bun-wasm/index.js.map packages/bun-wasm/index.mjs.map
@esbuild --sourcemap=external --external:fs --define:process.env.NODE_ENV='"production"' --outdir=packages/bun-wasm --target=esnext --bundle packages/bun-wasm/index.ts --format=cjs --minify --platform=node 2> /dev/null
@$(ESBUILD) --sourcemap=external --external:fs --define:process.env.NODE_ENV='"production"' --outdir=packages/bun-wasm --target=esnext --bundle packages/bun-wasm/index.ts --format=cjs --minify --platform=node 2> /dev/null
@mv packages/bun-wasm/index.js packages/bun-wasm/index.cjs
@mv packages/bun-wasm/index.js.map packages/bun-wasm/index.cjs.map
@rm -rf packages/bun-wasm/*.tsbuildinfo
@@ -752,10 +769,10 @@ sign-macos-aarch64:
gon sign.macos-aarch64.json
cls:
@echo "\n\n---\n\n"
@echo -e "\n\n---\n\n"
jsc-check:
@ls $(JSC_BASE_DIR) >/dev/null 2>&1 || (echo "Failed to access WebKit build. Please compile the WebKit submodule using the Dockerfile at $(shell pwd)/src/javascript/WebKit/Dockerfile and then copy from /output in the Docker container to $(JSC_BASE_DIR). You can override the directory via JSC_BASE_DIR. \n\n DOCKER_BUILDKIT=1 docker build -t bun-webkit $(shell pwd)/src/bun.js/WebKit -f $(shell pwd)/src/bun.js/WebKit/Dockerfile --progress=plain\n\n docker container create bun-webkit\n\n # Get the container ID\n docker container ls\n\n docker cp DOCKER_CONTAINER_ID_YOU_JUST_FOUND:/output $(JSC_BASE_DIR)" && exit 1)
@ls $(JSC_BASE_DIR) >/dev/null 2>&1 || (echo -e "Failed to access WebKit build. Please compile the WebKit submodule using the Dockerfile at $(shell pwd)/src/javascript/WebKit/Dockerfile and then copy from /output in the Docker container to $(JSC_BASE_DIR). You can override the directory via JSC_BASE_DIR. \n\n DOCKER_BUILDKIT=1 docker build -t bun-webkit $(shell pwd)/src/bun.js/WebKit -f $(shell pwd)/src/bun.js/WebKit/Dockerfile --progress=plain\n\n docker container create bun-webkit\n\n # Get the container ID\n docker container ls\n\n docker cp DOCKER_CONTAINER_ID_YOU_JUST_FOUND:/output $(JSC_BASE_DIR)" && exit 1)
@ls $(JSC_INCLUDE_DIR) >/dev/null 2>&1 || (echo "Failed to access WebKit include directory at $(JSC_INCLUDE_DIR)." && exit 1)
@ls $(JSC_LIB) >/dev/null 2>&1 || (echo "Failed to access WebKit lib directory at $(JSC_LIB)." && exit 1)
@@ -778,7 +795,7 @@ release-safe: prerelease release-safe-only
.PHONY: fmt-cpp
fmt-cpp:
cd src/bun.js/bindings && clang-format *.cpp *.h -i
cd src/bun.js/bindings && $(CLANG_FORMAT) *.cpp *.h -i
.PHONY: fmt-zig
fmt-zig:
@@ -800,21 +817,21 @@ node-fallbacks:
.PHONY: fallback_decoder
fallback_decoder:
@esbuild --target=esnext --bundle src/fallback.ts --format=iife --platform=browser --minify > src/fallback.out.js
@$(ESBUILD) --target=esnext --bundle src/fallback.ts --format=iife --platform=browser --minify > src/fallback.out.js
.PHONY: runtime_js
runtime_js:
@NODE_ENV=production esbuild --define:process.env.NODE_ENV="production" --target=esnext --bundle src/runtime/index.ts --format=iife --platform=browser --global-name=BUN_RUNTIME --minify --external:/bun:* > src/runtime.out.js; cat src/runtime.footer.js >> src/runtime.out.js
@NODE_ENV=production esbuild --define:process.env.NODE_ENV="production" --target=esnext --bundle src/runtime/index-with-refresh.ts --format=iife --platform=browser --global-name=BUN_RUNTIME --minify --external:/bun:* > src/runtime.out.refresh.js; cat src/runtime.footer.with-refresh.js >> src/runtime.out.refresh.js
@NODE_ENV=production esbuild --define:process.env.NODE_ENV="production" --target=esnext --bundle src/runtime/index-without-hmr.ts --format=iife --platform=node --global-name=BUN_RUNTIME --minify --external:/bun:* > src/runtime.node.pre.out.js; cat src/runtime.node.pre.out.js src/runtime.footer.node.js > src/runtime.node.out.js
@NODE_ENV=production esbuild --define:process.env.NODE_ENV="production" --target=esnext --bundle src/runtime/index-without-hmr.ts --format=iife --platform=node --global-name=BUN_RUNTIME --minify --external:/bun:* > src/runtime.bun.pre.out.js; cat src/runtime.bun.pre.out.js src/runtime.footer.bun.js > src/runtime.bun.out.js
@NODE_ENV=production $(ESBUILD) --define:process.env.NODE_ENV="production" --target=esnext --bundle src/runtime/index.ts --format=iife --platform=browser --global-name=BUN_RUNTIME --minify --external:/bun:* > src/runtime.out.js; cat src/runtime.footer.js >> src/runtime.out.js
@NODE_ENV=production $(ESBUILD) --define:process.env.NODE_ENV="production" --target=esnext --bundle src/runtime/index-with-refresh.ts --format=iife --platform=browser --global-name=BUN_RUNTIME --minify --external:/bun:* > src/runtime.out.refresh.js; cat src/runtime.footer.with-refresh.js >> src/runtime.out.refresh.js
@NODE_ENV=production $(ESBUILD) --define:process.env.NODE_ENV="production" --target=esnext --bundle src/runtime/index-without-hmr.ts --format=iife --platform=node --global-name=BUN_RUNTIME --minify --external:/bun:* > src/runtime.node.pre.out.js; cat src/runtime.node.pre.out.js src/runtime.footer.node.js > src/runtime.node.out.js
@NODE_ENV=production $(ESBUILD) --define:process.env.NODE_ENV="production" --target=esnext --bundle src/runtime/index-without-hmr.ts --format=iife --platform=node --global-name=BUN_RUNTIME --minify --external:/bun:* > src/runtime.bun.pre.out.js; cat src/runtime.bun.pre.out.js src/runtime.footer.bun.js > src/runtime.bun.out.js
.PHONY: runtime_js_dev
runtime_js_dev:
@NODE_ENV=development esbuild --define:process.env.NODE_ENV="development" --target=esnext --bundle src/runtime/index.ts --format=iife --platform=browser --global-name=BUN_RUNTIME --external:/bun:* > src/runtime.out.js; cat src/runtime.footer.js >> src/runtime.out.js
@NODE_ENV=development esbuild --define:process.env.NODE_ENV="development" --target=esnext --bundle src/runtime/index-with-refresh.ts --format=iife --platform=browser --global-name=BUN_RUNTIME --external:/bun:* > src/runtime.out.refresh.js; cat src/runtime.footer.with-refresh.js >> src/runtime.out.refresh.js
@NODE_ENV=development esbuild --define:process.env.NODE_ENV="development" --target=esnext --bundle src/runtime/index-without-hmr.ts --format=iife --platform=node --global-name=BUN_RUNTIME --external:/bun:* > src/runtime.node.pre.out.js; cat src/runtime.node.pre.out.js src/runtime.footer.node.js > src/runtime.node.out.js
@NODE_ENV=development esbuild --define:process.env.NODE_ENV="development" --target=esnext --bundle src/runtime/index-without-hmr.ts --format=iife --platform=node --global-name=BUN_RUNTIME --external:/bun:* > src/runtime.bun.pre.out.js; cat src/runtime.bun.pre.out.js src/runtime.footer.bun.js > src/runtime.bun.out.js
@NODE_ENV=development $(ESBUILD) --define:process.env.NODE_ENV="development" --target=esnext --bundle src/runtime/index.ts --format=iife --platform=browser --global-name=BUN_RUNTIME --external:/bun:* > src/runtime.out.js; cat src/runtime.footer.js >> src/runtime.out.js
@NODE_ENV=development $(ESBUILD) --define:process.env.NODE_ENV="development" --target=esnext --bundle src/runtime/index-with-refresh.ts --format=iife --platform=browser --global-name=BUN_RUNTIME --external:/bun:* > src/runtime.out.refresh.js; cat src/runtime.footer.with-refresh.js >> src/runtime.out.refresh.js
@NODE_ENV=development $(ESBUILD) --define:process.env.NODE_ENV="development" --target=esnext --bundle src/runtime/index-without-hmr.ts --format=iife --platform=node --global-name=BUN_RUNTIME --external:/bun:* > src/runtime.node.pre.out.js; cat src/runtime.node.pre.out.js src/runtime.footer.node.js > src/runtime.node.out.js
@NODE_ENV=development $(ESBUILD) --define:process.env.NODE_ENV="development" --target=esnext --bundle src/runtime/index-without-hmr.ts --format=iife --platform=node --global-name=BUN_RUNTIME --external:/bun:* > src/runtime.bun.pre.out.js; cat src/runtime.bun.pre.out.js src/runtime.footer.bun.js > src/runtime.bun.out.js
.PHONY: bun_error
bun_error:
@@ -823,7 +840,7 @@ bun_error:
.PHONY: generate-install-script
generate-install-script:
@rm -f $(PACKAGES_REALPATH)/bun/install.js
@esbuild --log-level=error --define:BUN_VERSION="\"$(PACKAGE_JSON_VERSION)\"" --define:process.env.NODE_ENV="\"production\"" --platform=node --format=cjs $(PACKAGES_REALPATH)/bun/install.ts > $(PACKAGES_REALPATH)/bun/install.js
@$(ESBUILD) --log-level=error --define:BUN_VERSION="\"$(PACKAGE_JSON_VERSION)\"" --define:process.env.NODE_ENV="\"production\"" --platform=node --format=cjs $(PACKAGES_REALPATH)/bun/install.ts > $(PACKAGES_REALPATH)/bun/install.js
.PHONY: fetch
fetch: $(IO_FILES)
@@ -893,38 +910,17 @@ bun-codesign-release-local:
bun-codesign-release-local-debug:
.PHONY: jsc
jsc: jsc-build jsc-copy-headers jsc-bindings
.PHONY: jsc-build
jsc-build: $(JSC_BUILD_STEPS)
.PHONY: jsc-bindings
jsc-bindings: headers bindings webcrypto-debug webcrypto
jsc-bindings: headers bindings
.PHONY: clone-submodules
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 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:
DOCKER_BUILDARCH="$(DOCKER_BUILDARCH)" devcontainer build --workspace-folder .
.PHONY: devcontainer-up
devcontainer-up:
DOCKER_BUILDARCH="$(DOCKER_BUILDARCH)" devcontainer up --workspace-folder .
.PHONY: devcontainer-rebuild
devcontainer-rebuild:
DOCKER_BUILDARCH="$(DOCKER_BUILDARCH)" devcontainer up --workspace-folder . --remove-existing-container
.PHONY: devcontainer-sh
devcontainer-sh:
DOCKER_BUILDARCH="$(DOCKER_BUILDARCH)" devcontainer exec --workspace-folder . zsh
CLANG_FORMAT := $(shell command -v clang-format 2> /dev/null)
.PHONY: headers
headers:
@@ -1089,10 +1085,10 @@ dev-obj-linux:
$(ZIG) build obj -Dtarget=x86_64-linux-gnu -Dcpu="$(CPU_TARGET)"
.PHONY: dev
dev: mkdir-dev dev-obj bun-link-lld-debug
dev: mkdir-dev esm dev-obj bun-link-lld-debug
mkdir-dev:
mkdir -p $(DEBUG_PACKAGE_DIR)/bin
mkdir -p $(DEBUG_PACKAGE_DIR)
test-all:
$(RELEASE_BUN) test
@@ -1115,11 +1111,10 @@ jsc-copy-headers:
cp $(WEBKIT_DIR)/Source/JavaScriptCore/runtime/JSModuleNamespaceObject.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JSModuleNamespaceObject.h
cp $(WEBKIT_DIR)/Source/JavaScriptCore/jit/JIT.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JIT.h
cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/StructureStubInfo.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/StructureStubInfo.h
cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/PolymorphicAccess.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/PolymorphicAccess.h
cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/AccessCase.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/AccessCase.h
cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/ObjectPropertyConditionSet.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/ObjectPropertyConditionSet.h
cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/PolyProtoAccessChain.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/PolyProtoAccessChain.h
cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/PutKind.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/PutKind.h
cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/InlineCacheCompiler.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/InlineCacheCompiler.h
cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/StructureStubClearingWatchpoint.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/StructureStubClearingWatchpoint.h
cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/AdaptiveInferredPropertyValueWatchpointBase.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/AdaptiveInferredPropertyValueWatchpointBase.h
cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/StubInfoSummary.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/StubInfoSummary.h
@@ -1153,6 +1148,9 @@ jsc-copy-headers:
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
cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/UnlinkedFunctionCodeBlock.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/UnlinkedFunctionCodeBlock.h
cp $(WEBKIT_DIR)/Source/JavaScriptCore/runtime/AggregateError.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/AggregateError.h
cp $(WEBKIT_DIR)/Source/JavaScriptCore/API/JSWeakValue.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JSWeakValue.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
@@ -1275,7 +1273,7 @@ jsc-build-mac-copy:
clean-jsc:
cd src/bun.js/WebKit && rm -rf **/CMakeCache.txt **/CMakeFiles && rm -rf src/bun.js/WebKit/WebKitBuild
clean-bindings:
rm -rf $(OBJ_DIR)/*.o $(DEBUG_OBJ_DIR)/*.o $(DEBUG_OBJ_DIR)/webcore/*.o $(DEBUG_BINDINGS_OBJ) $(OBJ_DIR)/webcore/*.o $(BINDINGS_OBJ)
rm -rf $(OBJ_DIR)/*.o $(DEBUG_OBJ_DIR)/*.o $(DEBUG_OBJ_DIR)/webcore/*.o $(DEBUG_BINDINGS_OBJ) $(OBJ_DIR)/webcore/*.o $(BINDINGS_OBJ) $(OBJ_DIR)/*.d $(DEBUG_OBJ_DIR)/*.d
.PHONY: clean
clean: clean-bindings
@@ -1288,12 +1286,12 @@ clean: clean-bindings
(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)
release-bindings: $(OBJ_DIR) $(OBJ_FILES) $(WEBCORE_OBJ_FILES) $(SQLITE_OBJ_FILES) $(NODE_OS_OBJ_FILES) $(BUILTINS_OBJ_FILES) $(IO_FILES) $(MODULES_OBJ_FILES) $(WEBCRYPTO_OBJ_FILES)
# Do not add $(DEBUG_DIR) to this list
# It will break caching, causing you to have to wait for every .cpp file to rebuild.
.PHONY: bindings
bindings: $(DEBUG_OBJ_DIR) $(DEBUG_OBJ_FILES) $(DEBUG_WEBCORE_OBJ_FILES) $(DEBUG_SQLITE_OBJ_FILES) $(DEBUG_NODE_OS_OBJ_FILES) $(DEBUG_BUILTINS_OBJ_FILES) $(DEBUG_IO_FILES) $(DEBUG_MODULES_OBJ_FILES)
bindings: $(DEBUG_OBJ_DIR) $(DEBUG_OBJ_FILES) $(DEBUG_WEBCORE_OBJ_FILES) $(DEBUG_SQLITE_OBJ_FILES) $(DEBUG_NODE_OS_OBJ_FILES) $(DEBUG_BUILTINS_OBJ_FILES) $(DEBUG_IO_FILES) $(DEBUG_MODULES_OBJ_FILES) $(DEBUG_WEBCRYPTO_OBJ_FILES)
.PHONY: jsc-bindings-mac
jsc-bindings-mac: bindings
@@ -1302,7 +1300,7 @@ jsc-bindings-mac: bindings
MIMALLOC_VALGRIND_ENABLED_FLAG =
ifeq ($(OS_NAME),linux)
MIMALLOC_VALGRIND_ENABLED_FLAG = -DMI_VALGRIND=ON
MIMALLOC_VALGRIND_ENABLED_FLAG = -DMI_TRACK_VALGRIND=ON
endif
@@ -1324,8 +1322,9 @@ mimalloc-debug:
-DMI_OVERRIDE=OFF \
-DCMAKE_C_FLAGS="$(CFLAGS)" \
-DCMAKE_CXX_FLAGS="$(CFLAGS)" \
-GNinja \
. \
&& make -j $(CPUS);
&& ninja
cp $(BUN_DEPS_DIR)/mimalloc/$(_MIMALLOC_DEBUG_FILE) $(BUN_DEPS_OUT_DIR)/$(MIMALLOC_FILE)
@@ -1347,8 +1346,9 @@ mimalloc:
-DMI_OVERRIDE=OFF \
-DMI_OSX_ZONE=OFF \
-DCMAKE_C_FLAGS="$(CFLAGS)" \
.\
&& make -j $(CPUS);
-GNinja \
. \
&& ninja;
cp $(BUN_DEPS_DIR)/mimalloc/$(MIMALLOC_INPUT_PATH) $(BUN_DEPS_OUT_DIR)/$(MIMALLOC_FILE)
@@ -1383,6 +1383,19 @@ bun-relink-copy:
mkdir -p $(PACKAGE_DIR)
cp $(BUN_DEPLOY_DIR).o $(BUN_RELEASE_BIN).o
.PHONY: bun-link-lld-profile profile
bun-link-lld-profile:
$(CXX) $(BUN_LLD_FLAGS) $(SYMBOLS) -g -gdwarf-4 -fno-omit-frame-pointer \
$(BUN_RELEASE_BIN).o \
-o $(BUN_RELEASE_BIN) \
-W \
$(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
build-profile: build-obj bun-link-lld-profile bun-codesign-release-local
bun-link-lld-release:
$(CXX) $(BUN_LLD_FLAGS) $(SYMBOLS) \
$(BUN_RELEASE_BIN).o \
@@ -1433,11 +1446,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
$(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
$(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
@@ -1461,6 +1474,7 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) $(UWS_INCLUDE) \
$(MACOS_MIN_FLAG) \
$(OPTIMIZATION_LEVEL) \
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
@@ -1471,6 +1485,7 @@ $(OBJ_DIR)/%.o: src/bun.js/modules/%.cpp
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) $(UWS_INCLUDE) \
$(MACOS_MIN_FLAG) \
$(OPTIMIZATION_LEVEL) \
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
@@ -1481,6 +1496,7 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/webcore/%.cpp
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(OPTIMIZATION_LEVEL) \
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
@@ -1491,6 +1507,7 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/sqlite/%.cpp
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(OPTIMIZATION_LEVEL) \
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
@@ -1501,6 +1518,7 @@ $(OBJ_DIR)/%.o: src/io/%.cpp
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(OPTIMIZATION_LEVEL) \
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
@@ -1511,16 +1529,30 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/node_os/%.cpp
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(OPTIMIZATION_LEVEL) \
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
$(EMIT_LLVM) \
-c -o $@ $<
$(OBJ_DIR)/%.o: src/bun.js/builtins/%.cpp
$(OBJ_DIR)/%.o: src/js/out/%.cpp
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(OPTIMIZATION_LEVEL) \
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
$(EMIT_LLVM) \
-c -o $@ $<
$(OBJ_DIR)/%.o: src/bun.js/bindings/webcrypto/%.cpp
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(OPTIMIZATION_LEVEL) \
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
@@ -1534,6 +1566,7 @@ $(DEBUG_OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) $(UWS_INCLUDE) \
$(MACOS_MIN_FLAG) \
$(DEBUG_OPTIMIZATION_LEVEL) \
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
@@ -1548,6 +1581,7 @@ $(DEBUG_OBJ_DIR)/%.o: $(SRC_DIR)/webcore/%.cpp
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(DEBUG_OPTIMIZATION_LEVEL) \
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
@@ -1560,6 +1594,7 @@ $(DEBUG_OBJ_DIR)/%.o: src/io/%.cpp
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(DEBUG_OPTIMIZATION_LEVEL) \
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
@@ -1575,6 +1610,7 @@ $(DEBUG_OBJ_DIR)/%.o: $(SRC_DIR)/sqlite/%.cpp
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(DEBUG_OPTIMIZATION_LEVEL) \
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
@@ -1589,6 +1625,7 @@ $(DEBUG_OBJ_DIR)/%.o: $(SRC_DIR)/node_os/%.cpp
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(DEBUG_OPTIMIZATION_LEVEL) \
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
@@ -1598,11 +1635,12 @@ $(DEBUG_OBJ_DIR)/%.o: $(SRC_DIR)/node_os/%.cpp
# $(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
.PHONY: src/js/out/builtins/%.cpp
$(DEBUG_OBJ_DIR)/%.o: src/js/out/%.cpp
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(DEBUG_OPTIMIZATION_LEVEL) \
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
@@ -1615,6 +1653,7 @@ $(DEBUG_OBJ_DIR)/%.o: src/bun.js/modules/%.cpp
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(DEBUG_OPTIMIZATION_LEVEL) \
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
@@ -1623,11 +1662,12 @@ $(DEBUG_OBJ_DIR)/%.o: src/bun.js/modules/%.cpp
-g3 -c -o $@ $<
$(DEBUG_OBJ_DIR)/webcrypto/%.o: src/bun.js/bindings/webcrypto/%.cpp
.PHONY: src/bun.js/bindings/webcrypto/%.cpp
$(DEBUG_OBJ_DIR)/%.o: src/bun.js/bindings/webcrypto/%.cpp
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(DEBUG_OPTIMIZATION_LEVEL) \
${MMD_IF_LOCAL} \
-fno-exceptions \
-I$(SRC_DIR) \
-fno-rtti \
@@ -1636,43 +1676,6 @@ $(DEBUG_OBJ_DIR)/webcrypto/%.o: src/bun.js/bindings/webcrypto/%.cpp
-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))
.PHONY: webcrypto-debug
webcrypto-debug:
rm -rf $(DEBUG_OBJ_DIR)/webcrypto $(BUN_DEPS_OUT_DIR)/libwebcrypto-debug.a
mkdir -p $(DEBUG_OBJ_DIR)/webcrypto
make webcrypto-debug-obj -j$(CPUS)
$(AR) rcs $(BUN_DEPS_OUT_DIR)/libwebcrypto-debug.a $(DEBUG_OBJ_DIR)/webcrypto/*.o
$(OBJ_DIR)/webcrypto/%.o: src/bun.js/bindings/webcrypto/%.cpp
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(OPTIMIZATION_LEVEL) \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
$(EMIT_LLVM_FOR_RELEASE) \
-g3 -c -o $@ $<
.PHONY: webcrypto-obj
# Make all the .cpp files in the webcrypto directory into .o files using Makefile substitutions
webcrypto-obj: $(patsubst src/bun.js/bindings/webcrypto/%.cpp, $(OBJ_DIR)/webcrypto/%.o, $(wildcard src/bun.js/bindings/webcrypto/*.cpp))
.PHONY: webcrypto
webcrypto:
rm -rf $(OBJ_DIR)/webcrypto $(BUN_DEPS_OUT_DIR)/libwebcrypto.a
mkdir -p $(OBJ_DIR)/webcrypto
make webcrypto-obj -j$(CPUS)
$(AR) rcs $(BUN_DEPS_OUT_DIR)/libwebcrypto.a $(OBJ_DIR)/webcrypto/*.o
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
@@ -1839,12 +1842,47 @@ copy-to-bun-release-dir-bin:
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: cold-jsc-start
cold-jsc-start:
$(CXX_WITH_CCACHE) $(CLANG_FLAGS) \
$(MACOS_MIN_FLAG) \
$(OPTIMIZATION_LEVEL) \
${MMD_IF_LOCAL} \
-fno-exceptions \
-fno-rtti \
-ferror-limit=1000 \
$(LIBICONV_PATH) \
$(DEFAULT_LINKER_FLAGS) \
$(PLATFORM_LINKER_FLAGS) \
$(ICU_FLAGS) \
$(JSC_FILES) \
misctools/cold-jsc-start.cpp -o cold-jsc-start
.PHONY: vendor-without-npm
vendor-without-npm: node-fallbacks runtime_js fallback_decoder bun_error mimalloc picohttp zlib boringssl libarchive lolhtml sqlite usockets uws tinycc c-ares zstd
.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
vendor-without-check: npm-install vendor-without-npm
.PHONY: vendor
vendor: require init-submodules vendor-without-check
.PHONY: vendor-dev
vendor-dev: require init-submodules npm-install-dev vendor-without-npm
.PHONY: bun
bun: vendor identifier-cache build-obj bun-link-lld-release bun-codesign-release-local
.PHONY: regenerate-bindings
regenerate-bindings:
@make clean-bindings builtins
@make bindings -j$(CPU_COUNT)
.PHONY: setup
setup: vendor-dev identifier-cache clean-bindings
make jsc-check
make bindings -j$(CPU_COUNT)
@echo ""
@echo "Development environment setup complete"
@echo "Run \`make dev\` to build \`bun-debug\`"
@echo ""

View File

@@ -40,7 +40,7 @@ bun run index.tsx # TS and JSX supported out of the box
bun test # run tests
bun run start # run the `start` script in `package.json`
bun install <pkg> # install a package
bunx cowsay "Hello, world!" # execute a package
bunx cowsay 'Hello, world!' # execute a package
```
## Install
@@ -48,7 +48,7 @@ bunx cowsay "Hello, world!" # execute a package
Bun supports Linux (x64 & arm64) and macOS (x64 & Apple Silicon).
> **Linux users** — Kernel version 5.6 or higher is strongly recommended, but the minimum is 5.1.
>
>
> **Windows users** — Bun does not currently provide a native Windows build. We're working on this; progress can be tracked at [this issue](https://github.com/oven-sh/bun/issues/43). In the meantime, use one of the installation methods below for Windows Subsystem for Linux.
```sh
@@ -67,7 +67,6 @@ docker pull oven/bun
docker run --rm --init --ulimit memlock=-1:-1 oven/bun
```
### Upgrade
To upgrade to the latest version of Bun, run:
@@ -100,7 +99,7 @@ bun upgrade --canary
- [Runtime](https://bun.sh/docs/runtime/index)
- [Module resolution](https://bun.sh/docs/runtime/modules)
- [Hot &amp; live reloading](https://bun.sh/docs/runtime/hot)
- [Plugins](https://bun.sh/docs/runtime/plugins)
- [Plugins](https://bun.sh/docs/bundler/plugins)
- Ecosystem
- [Node.js](https://bun.sh/docs/ecosystem/nodejs)
- [TypeScript](https://bun.sh/docs/ecosystem/typescript)
@@ -127,10 +126,9 @@ bun upgrade --canary
- [DNS](https://bun.sh/docs/api/dns)
- [Node-API](https://bun.sh/docs/api/node-api)
## Contributing
Refer to the [Project > Contributing](https://bun.sh/docs/project/developing) guide to start contributing to Bun.
Refer to the [Project > Development](https://bun.sh/docs/project/development) guide to start contributing to Bun.
## License

Binary file not shown.

171
bench/bundle/.gitignore vendored Normal file
View File

@@ -0,0 +1,171 @@
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
# Logs
logs
_.log
npm-debug.log_
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
# Runtime data
pids
_.pid
_.seed
\*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
\*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
\*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional stylelint cache
.stylelintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
\*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# vuepress v2.x temp and cache directory
.temp
.cache
# Docusaurus cache and generated files
.docusaurus
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.\*
esbuild

40
bench/bundle/README.md Normal file
View File

@@ -0,0 +1,40 @@
# Bundler benchmark
This is a performance benchmark of the following bundlers:
- Bun
- esbuild
- Parcel 2
- Rollup + Terser
- Webpack
It is an exact copy of [`esbuild`'s benchmark](https://github.com/evanw/esbuild/blob/main/Makefile), aside from the fact that Bun [has been added](https://github.com/colinhacks/esbuild/commit/1b928b7981aa7edfadf77fcf8931bb8d6f38cd96). The benchmark bundles 10 copies of the large [three.js](https://threejs.org/), with minification and source maps enabled.
To run the benchmark:
```sh
$ chmod +x run-bench.sh
$ ./run-bench.sh
```
Various output will be written to the console by each bundler. Scan through the results for lines that look like this underneath each bundler output:
```sh
real <number>
user <number>
sys <number>
```
These lines are generated by the `time` command which is used to benchmark each build.
## Results
The `real` results, as run on a 16-inch M1 Macbook Pro:
| Bundler | Time |
| ------- | ------ |
| Bun | 0.17s |
| esbuild | 0.33s |
| Rollup | 18.82s |
| Webpack | 26.21 |
| Parcel | 17.95s |

BIN
bench/bundle/bun.lockb Executable file

Binary file not shown.

1
bench/bundle/index.ts Normal file
View File

@@ -0,0 +1 @@
console.log("Hello via Bun!");

View File

@@ -0,0 +1,8 @@
{
"name": "bundle",
"module": "index.ts",
"type": "module",
"devDependencies": {
"bun-types": "^0.5.0"
}
}

3
bench/bundle/run-bench.sh Executable file
View File

@@ -0,0 +1,3 @@
git clone git@github.com:colinhacks/esbuild.git
cd esbuild
make bench-three

View File

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

View File

@@ -0,0 +1,31 @@
import EventEmitter3 from "eventemitter3";
import { group } from "mitata";
import EventEmitterNative from "node:events";
export const implementations = [
{
EventEmitter: EventEmitterNative,
name: process.isBun ? (EventEmitterNative.init ? "bun" : "C++") : "node:events",
monkey: true,
},
// { EventEmitter: EventEmitter3, name: "EventEmitter3" },
].filter(Boolean);
for (const impl of implementations) {
impl.EventEmitter?.setMaxListeners?.(Infinity);
}
export function groupForEmitter(name, cb) {
if (implementations.length === 1) {
return cb({
...implementations[0],
name: `${name}: ${implementations[0].name}`,
});
} else {
return group(name, () => {
for (let impl of implementations) {
cb(impl);
}
});
}
}

View File

@@ -0,0 +1,96 @@
import { bench, run } from "mitata";
import { groupForEmitter } from "./implementations.mjs";
var id = 0;
groupForEmitter("single emit", ({ EventEmitter, name }) => {
const emitter = new EventEmitter();
emitter.on("hello", event => {
event.preventDefault();
});
bench(name, () => {
emitter.emit("hello", {
preventDefault() {
id++;
},
});
});
});
groupForEmitter("on x 10_000 (handler)", ({ EventEmitter, name }) => {
const emitter = new EventEmitter();
bench(name, () => {
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;
},
});
if (!called) throw new Error("not called");
});
});
// for (let { impl: EventEmitter, name, monkey } of []) {
// if (monkey) {
// var monkeyEmitter = Object.assign({}, EventEmitter.prototype);
// monkeyEmitter.on("hello", event => {
// event.preventDefault();
// });
// bench(`[monkey] ${className}.emit`, () => {
// var called = false;
// monkeyEmitter.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();
// };
// monkeyEmitter.on("hey", cb);
// for (let i = 0; i < 10_000; i++)
// monkey.emit("hey", {
// preventDefault() {
// id++;
// },
// });
// monkeyEmitter.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,40 @@
import { bench, run } from "mitata";
import { groupForEmitter } from "./implementations.mjs";
var id = 0;
groupForEmitter("test 1", ({ EventEmitter, name }) => {
const emitter = new EventEmitter();
emitter.on("hello", event => {
event.preventDefault();
});
bench(name, () => {
emitter.once("hello", event => {
event.preventDefault();
});
emitter.emit("hello", {
preventDefault() {
id++;
},
});
});
});
groupForEmitter("test 2", ({ EventEmitter, name }) => {
const emitter = new EventEmitter();
bench(name, () => {
emitter.once("hello", event => {
event.preventDefault();
});
emitter.emit("hello", {
preventDefault() {
id++;
},
});
});
});
await run();

View File

@@ -0,0 +1,63 @@
import { bench, run } from "mitata";
import { groupForEmitter } from "./implementations.mjs";
// Psuedo RNG is derived from https://stackoverflow.com/a/424445
let rngState = 123456789;
function nextInt() {
const m = 0x80000000; // 2**31;
const a = 1103515245;
const c = 12345;
rngState = (a * rngState + c) % m;
return rngState;
}
function nextRange(start, end) {
// returns in range [start, end): including start, excluding end
// can't modulu nextInt because of weak randomness in lower bits
const rangeSize = end - start;
const randomUnder1 = nextInt() / 0x7fffffff; // 2**31 - 1
return start + Math.floor(randomUnder1 * rangeSize);
}
const chunks = new Array(1024).fill(null).map((_, j) => {
const arr = new Uint8Array(1024);
for (let i = 0; i < arr.length; i++) {
arr[i] = nextRange(0, 256);
}
return arr;
});
groupForEmitter("stream simulation", ({ EventEmitter, name }) => {
bench(name, () => {
let id = 0;
const stream = new EventEmitter();
stream.on("start", res => {
if (res.status !== 200) throw new Error("not 200");
});
const recived = [];
stream.on("data", req => {
recived.push(req);
});
stream.on("end", ev => {
ev.preventDefault();
});
// simulate a stream
stream.emit("start", { status: 200 });
for (let chunk of chunks) {
stream.emit("data", chunk);
}
stream.emit("end", {
preventDefault() {
id++;
},
});
if (id !== 1) throw new Error("not implemented right");
if (recived.length !== 1024) throw new Error("not implemented right");
});
});
await run();

View File

@@ -0,0 +1,4 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
extends: ["@remix-run/eslint-config", "@remix-run/eslint-config/node"],
};

10
bench/install/.gitignore vendored Normal file
View File

@@ -0,0 +1,10 @@
node_modules
/.cache
/build
/public/build
.env
package-lock.json
yarn.lock
pnpm-lock.yaml
bun.lockb

18
bench/install/README.md Normal file
View File

@@ -0,0 +1,18 @@
# `install` benchmark
Requires [`hyperfine`](https://github.com/sharkdp/hyperfine)
```
$ hyperfine --prepare 'rm -rf node_modules' --warmup 1 --runs 3 'bun install' 'pnpm install' 'yarn' 'npm install'
```
To check that the app is working as expected:
```
$ bun run dev
$ npm run dev
$ yarn dev
$ pnpm dev
```
Then visit [http://localhost:3000](http://localhost:3000).

View File

@@ -0,0 +1,18 @@
/**
* By default, Remix will handle hydrating your app on the client for you.
* You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨
* For more information, see https://remix.run/docs/en/main/file-conventions/entry.client
*/
import { RemixBrowser } from "@remix-run/react";
import { startTransition, StrictMode } from "react";
import { hydrateRoot } from "react-dom/client";
startTransition(() => {
hydrateRoot(
document,
<StrictMode>
<RemixBrowser />
</StrictMode>,
);
});

View File

@@ -0,0 +1,101 @@
/**
* By default, Remix will handle generating the HTTP Response for you.
* You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨
* For more information, see https://remix.run/docs/en/main/file-conventions/entry.server
*/
import { PassThrough } from "node:stream";
import type { EntryContext } from "@remix-run/node";
import { Response } from "@remix-run/node";
import { RemixServer } from "@remix-run/react";
import isbot from "isbot";
import { renderToPipeableStream } from "react-dom/server";
const ABORT_DELAY = 5_000;
export default function handleRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext,
) {
return isbot(request.headers.get("user-agent"))
? handleBotRequest(request, responseStatusCode, responseHeaders, remixContext)
: handleBrowserRequest(request, responseStatusCode, responseHeaders, remixContext);
}
function handleBotRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext,
) {
return new Promise((resolve, reject) => {
const { pipe, abort } = renderToPipeableStream(
<RemixServer context={remixContext} url={request.url} abortDelay={ABORT_DELAY} />,
{
onAllReady() {
const body = new PassThrough();
responseHeaders.set("Content-Type", "text/html");
resolve(
new Response(body, {
headers: responseHeaders,
status: responseStatusCode,
}),
);
pipe(body);
},
onShellError(error: unknown) {
reject(error);
},
onError(error: unknown) {
responseStatusCode = 500;
console.error(error);
},
},
);
setTimeout(abort, ABORT_DELAY);
});
}
function handleBrowserRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext,
) {
return new Promise((resolve, reject) => {
const { pipe, abort } = renderToPipeableStream(
<RemixServer context={remixContext} url={request.url} abortDelay={ABORT_DELAY} />,
{
onShellReady() {
const body = new PassThrough();
responseHeaders.set("Content-Type", "text/html");
resolve(
new Response(body, {
headers: responseHeaders,
status: responseStatusCode,
}),
);
pipe(body);
},
onShellError(error: unknown) {
reject(error);
},
onError(error: unknown) {
console.error(error);
responseStatusCode = 500;
},
},
);
setTimeout(abort, ABORT_DELAY);
});
}

View File

@@ -0,0 +1,20 @@
import { Links, LiveReload, Meta, Outlet, Scripts, ScrollRestoration } from "@remix-run/react";
export default function App() {
return (
<html lang="en">
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<Meta />
<Links />
</head>
<body>
<Outlet />
<ScrollRestoration />
<Scripts />
<LiveReload />
</body>
</html>
);
}

View File

@@ -0,0 +1,30 @@
import type { V2_MetaFunction } from "@remix-run/node";
export const meta: V2_MetaFunction = () => {
return [{ title: "New Remix App" }];
};
export default function Index() {
return (
<div style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.4" }}>
<h1>Welcome to Remix</h1>
<ul>
<li>
<a target="_blank" href="https://remix.run/tutorials/blog" rel="noreferrer">
15m Quickstart Blog Tutorial
</a>
</li>
<li>
<a target="_blank" href="https://remix.run/tutorials/jokes" rel="noreferrer">
Deep Dive Jokes App Tutorial
</a>
</li>
<li>
<a target="_blank" href="https://remix.run/docs" rel="noreferrer">
Remix Docs
</a>
</li>
</ul>
</div>
);
}

View File

@@ -0,0 +1,31 @@
{
"private": true,
"sideEffects": false,
"scripts": {
"build": "remix build",
"dev": "remix dev",
"start": "remix-serve build",
"typecheck": "tsc",
"clean": "rm -rf node_modules",
"bench": "hyperfine --prepare 'rm -rf node_modules' --warmup 1 --runs 3 'bun install' 'pnpm install' 'yarn' 'npm install'"
},
"dependencies": {
"@remix-run/node": "^1.15.0",
"@remix-run/react": "^1.15.0",
"@remix-run/serve": "^1.15.0",
"isbot": "^3.6.5",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@remix-run/dev": "^1.15.0",
"@remix-run/eslint-config": "^1.15.0",
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.8",
"eslint": "^8.27.0",
"typescript": "^4.8.4"
},
"engines": {
"node": ">=14"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@@ -0,0 +1,14 @@
/** @type {import('@remix-run/dev').AppConfig} */
module.exports = {
ignoredRouteFiles: ["**/.*"],
// appDirectory: "app",
// assetsBuildDirectory: "public/build",
// serverBuildPath: "build/index.js",
// publicPath: "/build/",
future: {
v2_errorBoundary: true,
v2_meta: true,
v2_normalizeFormMethod: true,
v2_routeConvention: true,
},
};

2
bench/install/remix.env.d.ts vendored Normal file
View File

@@ -0,0 +1,2 @@
/// <reference types="@remix-run/dev" />
/// <reference types="@remix-run/node" />

View File

@@ -0,0 +1,22 @@
{
"include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"],
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2019"],
"isolatedModules": true,
"esModuleInterop": true,
"jsx": "react-jsx",
"moduleResolution": "node",
"resolveJsonModule": true,
"target": "ES2019",
"strict": true,
"allowJs": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": ".",
"paths": {
"~/*": ["./app/*"]
},
// Remix takes care of building everything in `remix build`.
"noEmit": true
}
}

1986
bench/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +1,13 @@
{
"name": "bench",
"dependencies": {
"mitata": "^0.1.6",
"esbuild": "^0.14.12",
"@swc/core": "^1.2.133",
"@babel/core": "^7.16.10",
"@babel/preset-react": "^7.16.7"
"@babel/preset-react": "^7.16.7",
"@swc/core": "^1.2.133",
"benchmark": "^2.1.4",
"esbuild": "^0.14.12",
"eventemitter3": "^5.0.0",
"mitata": "^0.1.6"
},
"scripts": {
"ffi": "cd ffi && bun run deps && bun run build && bun run bench",

View File

@@ -1,5 +1,5 @@
// to run this:
// NODE_ENV=production bun --jsx-production react-hello-world.jsx
// NODE_ENV=production bun react-hello-world.jsx
// 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)

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,4 @@
import { bench, run } from "mitata";
import { bench, run } from "./runner.mjs";
function doIt(...args) {
// we use .at() to prevent constant folding optimizations

View File

@@ -1,5 +1,5 @@
// https://github.com/oven-sh/bun/issues/1096
import { bench, run } from "mitata";
import { bench, run } from "./runner.mjs";
const identity = x => x;

View File

@@ -1,4 +1,4 @@
import { bench, run } from "mitata";
import { bench, run } from "./runner.mjs";
var myArray = new Array(5);
bench("[1, 2, 3, 4, 5].shift()", () => {

View File

@@ -1,5 +1,6 @@
// @runtime bun
import { ArrayBufferSink } from "bun";
import { bench, run } from "mitata";
import { bench, run } from "./runner.mjs";
var short = "Hello World!";
var shortUTF16 = "Hello World 💕💕💕";

View File

@@ -1,4 +1,4 @@
import { bench, group, run } from "mitata";
import { bench, group, run } from "./runner.mjs";
import * as assert from "assert";
bench("deepEqual", () => {

View File

@@ -1,6 +1,9 @@
import { bench, run } from "mitata";
// @runtime bun,node,deno
import { bench, run } from "./runner.mjs";
import process from "node:process";
import { Buffer } from "node:buffer";
const N = parseInt(process.argv.slice(2).at(0) || "10", 10);
const N = parseInt(process.env.RUN_COUNTER ?? "10000", 10);
var isBuffer = new Buffer(0);
var isNOtBuffer = "not a buffer";

Binary file not shown.

View File

@@ -1,4 +1,4 @@
import { bench, group, run } from "mitata";
import { bench, group, run } from "./runner.mjs";
import { readFileSync } from "fs";
import { allocUnsafe } from "bun";

View File

@@ -0,0 +1,29 @@
// https://github.com/oven-sh/bun/issues/2190
import { bench, run } from "mitata";
import { createHash } from "node:crypto";
const data =
"Delightful remarkably mr on announcing themselves entreaties favourable. About to in so terms voice at. Equal an would is found seems of. The particular friendship one sufficient terminated frequently themselves. It more shed went up is roof if loud case. Delay music in lived noise an. Beyond genius really enough passed is up.";
const scenarios = [
{ alg: "md5", digest: "hex" },
{ alg: "md5", digest: "base64" },
{ alg: "sha1", digest: "hex" },
{ alg: "sha1", digest: "base64" },
{ alg: "sha256", digest: "hex" },
{ alg: "sha256", digest: "base64" },
];
for (const { alg, digest } of scenarios) {
bench(`${alg}-${digest}`, () => {
createHash(alg).update(data).digest(digest);
});
if ("Bun" in globalThis) {
bench(`${alg}-${digest} (Bun.CryptoHasher)`, () => {
new Bun.CryptoHasher(alg).update(data).digest(digest);
});
}
}
run();

View File

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

View File

@@ -0,0 +1,26 @@
// https://github.com/oven-sh/bun/issues/2190
import { bench, run } from "mitata";
import { createHash } from "node:crypto";
const data =
"Delightful remarkably mr on announcing themselves entreaties favourable. About to in so terms voice at. Equal an would is found seems of. The particular friendship one sufficient terminated frequently themselves. It more shed went up is roof if loud case. Delay music in lived noise an. Beyond genius really enough passed is up.";
const scenarios = [
{ alg: "md5", digest: "hex" },
{ alg: "md5", digest: "base64" },
{ alg: "sha1", digest: "hex" },
{ alg: "sha1", digest: "base64" },
{ alg: "sha256", digest: "hex" },
{ alg: "sha256", digest: "base64" },
];
for (const { alg, digest } of scenarios) {
bench(`${alg}-${digest}`, () => {
const hasher = createHash(alg);
hasher.write(data);
hasher.end();
hasher.read();
});
}
run();

View File

@@ -1,4 +1,4 @@
import { bench, group, run } from "mitata";
import { bench, group, run } from "./runner.mjs";
import fastDeepEquals from "fast-deep-equal/es6/index";
// const Date = globalThis.Date;

View File

@@ -1,5 +1,5 @@
import { lookup, resolve } from "node:dns/promises";
import { bench, run } from "mitata";
import { bench, run } from "./runner.mjs";
bench("(cached) dns.lookup remote x 50", async () => {
var tld = "example.com";

View File

@@ -1,5 +1,5 @@
import { dns } from "bun";
import { bench, run, group } from "mitata";
import { bench, run, group } from "./runner.mjs";
async function forEachBackend(name, fn) {
group(name, () => {

View File

@@ -1,101 +0,0 @@
// **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

@@ -1,5 +1,5 @@
import { group } from "mitata";
import { bench, run } from "mitata";
import { group } from "./runner.mjs";
import { bench, run } from "./runner.mjs";
import { encode as htmlEntityEncode } from "html-entities";
import { escape as heEscape } from "he";

View File

@@ -1,5 +1,5 @@
import { viewSource, dlopen, CString, ptr, toBuffer, toArrayBuffer, FFIType, callback } from "bun:ffi";
import { bench, group, run } from "mitata";
import { bench, group, run } from "./runner.mjs";
const types = {
returns_true: {

View File

@@ -1,4 +1,4 @@
import { bench, run } from "mitata";
import { bench, run } from "./runner.mjs";
const input =
"Hello, World! foo bar baz qux quux corge grault garply waldo fred plugh xyzzy thud z a b c d e f g h i j k l m n o p q r s t u v w x y z".split(

View File

@@ -0,0 +1,57 @@
import { bench, run } from "./runner.mjs";
var obj = {
"restApiRoot": "/api",
"host": "0.0.0.0",
"port": 3000,
"remoting": {
"context": false,
"rest": {
"handleErrors": false,
"normalizeHttpPath": false,
"xml": false,
},
"json": {
"strict": false,
"limit": "100kb",
},
"urlencoded": {
"extended": true,
"limit": "100kb",
boop: {
"restApiRoot": "/api",
"host": "0.0.0.0",
"port": 3000,
"remoting": {
"context": false,
"rest": {
"handleErrors": false,
"normalizeHttpPath": false,
"xml": false,
},
"json": {
"strict": false,
"limit": "100kb",
},
"urlencoded": {
"extended": true,
"limit": "100kb",
},
"cors": false,
},
},
},
"cors": false,
},
};
var big = JSON.stringify(obj);
bench("JSON.parse(obj)", () => {
globalThis.foo = JSON.parse(big);
});
bench("JSON.stringify(obj)", () => {
globalThis.bar = JSON.stringify(obj);
});
await run();

View File

@@ -1,4 +1,4 @@
import { bench, run } from "mitata";
import { bench, run } from "./runner.mjs";
// These are no-op C++ functions that are exported to JS.
const lazy = globalThis[Symbol.for("Bun.lazy")];

View File

@@ -0,0 +1,42 @@
// @runtime node, bun
import { bench, run } from "./runner.mjs";
import * as vm from "node:vm";
const context = {
animal: "cat",
count: 2,
};
const script = new vm.Script("animal = 'hey'");
vm.createContext(context);
bench("vm.Script.runInContext", () => {
script.runInContext(context);
});
bench("vm.Script.runInThisContext", () => {
script.runInThisContext(context);
});
bench("vm.Script.runInNewContext", () => {
script.runInNewContext(context);
});
bench("vm.runInContext", () => {
vm.runInContext("animal = 'hey'", context);
});
bench("vm.runInNewContext", () => {
vm.runInNewContext("animal = 'hey'", context);
});
bench("vm.runInThisContext", () => {
vm.runInThisContext("animal = 'hey'", context);
});
bench("vm.createContext", () => {
vm.createContext({ yo: 1 });
});
await run();

View File

@@ -1,4 +1,4 @@
import { bench, run } from "mitata";
import { bench, run } from "./runner.mjs";
var noop = globalThis[Symbol.for("Bun.lazy")]("noop");
var { function: noopFn, callback } = noop;

View File

@@ -24,7 +24,7 @@ const obj = {
w: 23,
};
import { bench, group, run } from "mitata";
import { bench, group, run } from "./runner.mjs";
var val = 0;
bench("Object.values(literal)", () => {

View File

@@ -1,7 +0,0 @@
{
"dependencies": {
"eventemitter3": "^5.0.0",
"tiny-typed-emitter": "latest"
},
"prettier": "../../.prettierrc.cjs"
}

View File

@@ -1,5 +1,5 @@
import { group } from "mitata";
import { bench, run } from "mitata";
import { group } from "./runner.mjs";
import { bench, run } from "./runner.mjs";
bench("performance.now x 1000", () => {
for (let i = 0; i < 1000; i++) {
performance.now();

View File

@@ -1,4 +1,4 @@
import { bench, run } from "mitata";
import { bench, run } from "./runner.mjs";
bench("process.stderr.write('hey')", () => {
process.stderr.write("hey");

View File

@@ -1,4 +1,4 @@
import { bench, group, run } from "mitata";
import { bench, group, run } from "./runner.mjs";
import { renderToReadableStream } from "react-dom/server.browser";
import { renderToReadableStream as renderToReadableStreamBun } from "react-dom/server";

View File

@@ -1,5 +1,5 @@
import { readFileSync, writeFileSync } from "node:fs";
import { bench, run } from "mitata";
import { bench, run } from "./runner.mjs";
var short = (function () {
const text = "Hello World!";

View File

@@ -1,5 +1,5 @@
import { readdirSync } from "fs";
import { bench, run } from "mitata";
import { bench, run } from "./runner.mjs";
import { argv } from "process";
const dir = argv.length > 2 ? argv[2] : "/tmp";

View File

@@ -0,0 +1,244 @@
// note: this isn't done yet
// we look for `// @runtime` in the file to determine which runtimes to run the benchmark in
import { spawnSync } from "bun";
import { readdirSync, readFileSync } from "node:fs";
import { Database } from "bun:sqlite";
import { extname, basename } from "path";
const exts = [".js", ".ts", ".mjs", ".tsx"];
const runtimes = {
bun: process.execPath,
node: process.env.NODE ?? Bun.which("node"),
deno: process.env.DENO ?? Bun.which("deno"),
};
if (process.env.BUN_ONLY) {
delete runtimes.node;
delete runtimes.deno;
}
function getEntry(sourceContents, file) {
const targetLineStart = sourceContents.indexOf("// @runtime ");
if (targetLineStart === -1) {
return;
}
const targetLineEnd = sourceContents.indexOf("\n", targetLineStart);
if (targetLineEnd === -1) {
return;
}
const targetLine = sourceContents.slice(targetLineStart, targetLineEnd);
const targets = targetLine
.slice("// @runtime ".length)
.split(/[,\s]+/gm)
.map(a => a.trim().toLowerCase())
.filter(Boolean)
.sort();
if (targets.length === 0) {
throw new TypeError("No targets specified in " + JSON.stringify(file) + "\n> " + JSON.stringify(targetLine) + "\n");
}
var cmds = {};
for (let target of targets) {
if (!(target in runtimes)) {
throw new TypeError(
"Unknown target " + JSON.stringify(target) + "\n> " + targetLine + "\n file:" + JSON.stringify(file),
);
}
switch (target) {
case "bun": {
if (!runtimes.bun) {
continue;
}
cmds.bun = [runtimes.bun, "run", file];
break;
}
case "node": {
if (!runtimes.node) {
continue;
}
cmds.node = [runtimes.node, file];
break;
}
case "deno": {
if (!runtimes.deno) {
continue;
}
cmds.deno = [runtimes.deno, "run", "-A", "--unstable", file];
break;
}
default: {
throw new Error("This should not be reached.");
break;
}
}
}
if (Object.keys(cmds).length === 0) {
return;
}
return cmds;
}
function scan() {
const queue = [];
for (let file of readdirSync(import.meta.dir)) {
if (!exts.includes(extname(file))) continue;
if (file.includes("runner")) continue;
const cmds = getEntry(readFileSync(file, "utf8"), file);
if (!cmds) continue;
queue.push({ file, cmds });
}
return queue;
}
const env = {
...process.env,
BENCHMARK_RUNNER: "1",
NODE_NO_WARNINGS: "1",
NODE_OPTIONS: "--no-warnings",
BUN_DEBUG_QUIET_LOGS: "1",
NO_COLOR: "1",
DISABLE_COLORS: "1",
};
function* run({ cmds, file }) {
const benchmarkID = basename(file)
.toLowerCase()
.replace(/\.m?js$/, "")
.replace(/\.tsx?$/, "")
.replace(".node", "")
.replace(".deno", "")
.replace(".bun", "");
// if benchmarkID doesn't contain only words, letters or numbers or dashes or underscore, throw
if (!/^[a-z0-9_-]+$/i.test(benchmarkID)) {
throw new Error(
"Benchmark files must only contain /a-zA-Z0-9-_/ " +
JSON.stringify(benchmarkID) +
" in file " +
JSON.stringify(file),
);
}
for (let runtime in cmds) {
const timestamp = Date.now();
const spawnStart = performance.now();
var { stdout, exitCode } = spawnSync({
cmd: cmds[runtime],
env,
stderr: "inherit",
stdout: "pipe",
});
const spawnElapsed = performance.now() - spawnStart;
stdout = stdout.toString();
try {
const json = JSON.parse(stdout.trim());
yield {
file: file,
benchmarkID,
result: json,
runtime: runtime,
timestamp,
elapsed: spawnElapsed,
runtimeVersion: (runtime === "bun"
? `${Bun.version}-${Bun.revision}`
: String(json?.runtime).split(" ").at(1)
).replace(/^v/, ""),
};
} catch (e) {
console.error("Failing file", file);
console.error(JSON.stringify(cmds[runtime]));
console.error(stdout.toString());
throw e;
}
if (exitCode !== 0) {
throw new Error("Non-zero exit code in file " + JSON.stringify(file) + ", runtime: " + JSON.stringify(runtime));
}
}
}
const db = Database.open(process.RUNNER_DB_PATH ?? `runs-${process.platform}-${process.arch}.db`);
db.run(`CREATE TABLE IF NOT EXISTS benchmarkResults (
id INTEGER PRIMARY KEY AUTOINCREMENT,
results TEXT NOT NULL
);`);
db.run(`
CREATE TABLE IF NOT EXISTS runs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
runtime TEXT NOT NULL,
runtimeVersion TEXT NOT NULL,
benchmarkID TEXT NOT NULL,
timestamp INTEGER NOT NULL,
elapsed REAL NOT NULL,
benchmarkResultID INTEGER NOT NULL
);
`);
db.run(`CREATE INDEX IF NOT EXISTS runs_benchmarkID ON runs (benchmarkID);`);
db.run(`CREATE INDEX IF NOT EXISTS runs_timestamp ON runs (timestamp);`);
db.run(`CREATE INDEX IF NOT EXISTS runs_runtime ON runs (runtime);`);
db.run(`CREATE INDEX IF NOT EXISTS runs_runtimeVersion ON runs (runtimeVersion);`);
db.run(`CREATE INDEX IF NOT EXISTS runs_benchmarkResultID ON runs (benchmarkResultID);`);
// TODO: finish this
for (let result of scan()) {
var prevBenchmarkID = null;
for (let {
runtime,
benchmarkID,
runtimeVersion,
timestamp,
elapsed,
file,
result: { benchmarks },
} of run(result)) {
if (prevBenchmarkID !== benchmarkID) {
console.log("\n" + `${benchmarkID}:`);
prevBenchmarkID = benchmarkID;
}
console.log(
" ",
`[${Math.round(elapsed)}ms]`,
"Executed",
JSON.stringify(benchmarkID),
"in",
runtime,
runtimeVersion,
"(" + file + ")",
);
const { id: benchmarkResultID } = db
.query(
`
INSERT INTO benchmarkResults (results) VALUES (?) RETURNING id
`,
)
.get(JSON.stringify(benchmarks));
db.run(
`
INSERT INTO runs (runtime, runtimeVersion, benchmarkID, timestamp, elapsed, benchmarkResultID) VALUES (
?, ?, ?, ?, ?, ?)`,
runtime,
runtimeVersion,
benchmarkID,
timestamp,
elapsed,
benchmarkResultID,
);
}
}

22
bench/snippets/runner.mjs Normal file
View File

@@ -0,0 +1,22 @@
import * as Mitata from "../node_modules/mitata/src/cli.mjs";
import process from "node:process";
const asJSON = !!process?.env?.BENCHMARK_RUNNER;
export function run(opts = {}) {
opts ??= {};
if (asJSON) {
opts.json = true;
}
return Mitata.run(opts);
}
export function bench(name, fn) {
return Mitata.bench(name, fn);
}
export function group(name, fn) {
return Mitata.group(name, fn);
}

View File

@@ -1,4 +1,4 @@
import { bench, run } from "mitata";
import { bench, run } from "./runner.mjs";
import { SHA512 } from "bun";
bench('SHA512.hash("hello world")', () => {

View File

@@ -1,4 +1,4 @@
import { bench, run } from "mitata";
import { bench, run } from "./runner.mjs";
import { createHash } from "crypto";
bench('createHash("sha256").update("hello world").digest()', () => {

View File

@@ -1,5 +1,5 @@
import { spawnSync } from "bun";
import { bench, run } from "mitata";
import { bench, run } from "./runner.mjs";
var memory = new Uint8Array(128 * 1024 * 1024);
memory.fill(10);

View File

@@ -1,5 +1,5 @@
import { spawnSync } from "child_process";
import { bench, run } from "mitata";
import { bench, run } from "./runner.mjs";
var memory = new Uint8Array(128 * 1024 * 1024);
memory.fill(10);

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