Compare commits

..

308 Commits

Author SHA1 Message Date
Jarred Sumner
3d6fab6e49 📷 Snapshots 2021-11-05 01:33:09 -07:00
Jarred Sumner
d0823beef5 Update run_command.zig 2021-11-05 01:23:07 -07:00
Jarred Sumner
b0e98892e5 [bun run] Exclude .config.* files from showing up as runnable with Bun.js 2021-11-05 01:22:48 -07:00
Jarred Sumner
0006d28cbb 📷 Snapshots 2021-11-05 01:16:19 -07:00
Jarred Sumner
42dcc4e217 Bump 2021-11-05 01:15:43 -07:00
Jarred Sumner
13582981e4 Update bun.fish 2021-11-05 01:15:35 -07:00
Jarred Sumner
d4c1bf6c67 [bun run] Fix bug with yarn getting replaced for - commands 2021-11-05 01:15:24 -07:00
Jarred Sumner
3ef55d10ae [bun run] Improve fish completions by adding a description 2021-11-05 01:15:09 -07:00
Jarred Sumner
5ce171d92c [bun run][bun create] Do not follow symlinks when exec'ing a child process 2021-11-04 21:37:10 -07:00
Jarred Sumner
e409148941 [bun run] Fix bug with quotes and spaces
Fixes #53
2021-11-04 21:00:44 -07:00
Jarred Sumner
d44abd8e4d Update string_immutable.zig 2021-11-04 18:41:40 -07:00
Jarred Sumner
5c38b6c355 [internal] fmt 2021-11-04 18:33:14 -07:00
Jarred Sumner
04ecfdd794 [JS Parser] Print � for invalid WTF-8 input 2021-11-04 18:33:00 -07:00
Jarred Sumner
fc59a32b63 [JS Parser] Decode JavaScript-like input as WTF-8 instead of UTF-8 2021-11-04 18:30:43 -07:00
Jarred Sumner
fd57e2d9a6 [JSX] Match esbuild behavior for multiline JSX string literals 2021-11-04 15:27:29 -07:00
Jarred Sumner
303a5ea898 [JSX] Fix regression with JSX entities 2021-11-03 19:29:07 -07:00
Jarred Sumner
d502d0bcd6 Update install.sh 2021-11-03 15:26:06 -07:00
Jarred Sumner
2018f5020a [installer] Detect rosetta in install.sh 2021-11-03 15:25:38 -07:00
Jarred Sumner
92a7849e98 [Bun.js] Rename Bun.sleep -> Bun.sleepSync 2021-11-03 02:04:21 -07:00
Jarred Sumner
59bdb62966 Fix next version warning 2021-11-03 01:20:08 -07:00
Jarred Sumner
eab1938012 [bun create] Auto-set to Next.js v12.0.2 2021-11-03 00:27:13 -07:00
Jarred Sumner
d97bd79c86 Bump once again (bun create requires git-public versions) 2021-11-03 00:23:49 -07:00
Jarred Sumner
35c05f61e5 Bump next version 2021-11-03 00:22:37 -07:00
Jarred Sumner
a5181c8ed1 [examples] Display Next.js version in example 2021-11-02 23:43:20 -07:00
Jarred Sumner
aa545ac0dc Update README.md 2021-11-02 23:37:57 -07:00
Jarred Sumner
ac9bd094f3 [test] Make sure we curl a jsx file in react integration test 2021-11-02 23:25:31 -07:00
Jarred Sumner
becf55febc Bump examples 2021-11-02 23:25:08 -07:00
Jarred Sumner
c41cc80700 [internal] Undo workspace commits, turns out it's not necessary for now 2021-11-02 23:17:25 -07:00
Jarred Sumner
20b1a27d05 [bun-macro-relay] Temporary fix until .d.ts is handled more correctly 2021-11-02 23:16:52 -07:00
Jarred Sumner
a027e9b6bc v0.1.1 2021-11-02 23:16:33 -07:00
Jarred Sumner
3fe676e9c9 Bump versions 2021-11-02 23:13:18 -07:00
Jarred Sumner
bffe8e918b Merge branch 'jarred/package-mapper' of github.com:Jarred-Sumner/bun into jarred/package-mapper 2021-11-02 23:10:43 -07:00
Jarred Sumner
92e5fe9fd5 Next.js 12 support 2021-11-02 23:10:40 -07:00
Jarred Sumner
b107ac1659 [internal] Inline empty function 2021-11-02 22:53:53 -07:00
Jarred Sumner
5537c03569 Fixes https://github.com/Jarred-Sumner/bun/issues/28 2021-11-02 22:53:26 -07:00
Jarred Sumner
4ab7c82405 Revert "[bundler] Start detecting workspace roots"
This reverts commit e71cb5c8c9.
2021-11-02 22:53:06 -07:00
Jarred Sumner
6e8cd2e3e5 [bun bun] alwaysBundled packages should use their real paths 2021-11-02 22:52:38 -07:00
Jarred Sumner
c0c7527497 [parser] Fix undefined behavior when invalid an unicode codepoint is part of an error message 2021-11-02 22:48:48 -07:00
Jarred Sumner
e71cb5c8c9 [bundler] Start detecting workspace roots 2021-11-02 18:09:54 -07:00
Jarred Sumner
cdbb4cf68a [interla] Comment 2021-11-02 18:08:55 -07:00
Jarred Sumner
204d468ad2 [internal] Global.configureAllocator() 2021-11-02 18:07:11 -07:00
Jarred Sumner
1844212f34 [bundler] Start detecting workspace roots 2021-11-02 17:20:45 -07:00
Jarred Sumner
fbb0342511 [CLI] Fix completions auto-installer for zsh 2021-11-01 21:23:47 -07:00
Jarred Sumner
92b174b315 Add Bun.js integration tests, but don't run them yet. 2021-11-01 20:05:38 -07:00
Jarred Sumner
0ba9784be2 [cli] Hardcode some paths to install for zsh 2021-11-01 06:10:13 -07:00
Jarred Sumner
2c50cf7284 Update Makefile 2021-11-01 04:57:50 -07:00
Jarred Sumner
bea0dca55d Update Makefile 2021-11-01 04:56:30 -07:00
Jarred Sumner
1676af9de9 [cli] Slightly improve zsh completions 2021-11-01 04:41:46 -07:00
Jarred Sumner
3d48bdaad1 Delete node_modules.jsbundle 2021-11-01 04:30:59 -07:00
Jarred Sumner
1b474d4f97 [CLI] Spacing 2021-11-01 04:30:31 -07:00
Jarred Sumner
4467167f99 [cli] just open the directory, access is dumb 2021-11-01 04:27:44 -07:00
Jarred Sumner
36ec8bb99b [test] Add integration test for null byte \\0 2021-11-01 04:04:48 -07:00
Jarred Sumner
bc5f99dc43 [internal] Tiny changes that will eventually make it easier to update zig 2021-11-01 04:04:18 -07:00
Jarred Sumner
4d4966592e [upgrade] Reinstall completions on bun upgrade 2021-11-01 04:03:43 -07:00
Jarred Sumner
f1fff3af7e Bump 2021-11-01 03:59:48 -07:00
Jarred Sumner
83e553d6a9 [install] Auto-set PATH if possible 2021-11-01 03:59:36 -07:00
Jarred Sumner
173724b402 [CLI] Add zsh completions and auto-install completions 2021-11-01 03:43:27 -07:00
Jarred Sumner
64d3927879 [CLI] Add completions for Fish 2021-10-31 21:02:15 -07:00
Jarred Sumner
49ad70b11c [CLI] Print newline after --version 2021-10-31 16:19:28 -07:00
Jarred Sumner
0d0b769bcc Add -v shorthand for version 2021-10-31 16:19:15 -07:00
Jarred Sumner
fb2aa186b7 [Bun.js] Bun.sleep() lets you synchronously sleep. Thanks @evanwashere 2021-10-31 00:39:37 -07:00
Jarred Sumner
ef94826f95 [CLI] Fix spacing (thanks @KishanBagaria) 2021-10-31 00:22:03 -07:00
Jarred Sumner
d79f34e960 Update cli.zig 2021-10-30 23:15:55 -07:00
Jarred Sumner
4ce6e4a9cb [Bun.js] Ensure we print in Latin1 mode 2021-10-30 23:15:47 -07:00
Jarred Sumner
9cf2771549 Update javascript.zig 2021-10-30 23:14:58 -07:00
Jarred Sumner
daf583e4cb [Bun.js] Lazily add FORCE_COLOR environment variable for better compatibility with Node.js modules that detect whether the terminal supports colors 2021-10-30 23:14:48 -07:00
Jarred Sumner
51e55f4b6e [Bun.js] Partially fix loading Node.js fallback modules 2021-10-30 23:14:14 -07:00
Jarred Sumner
f30527b6d9 [Bun.js] Add API for detecting if ANSI colors are enabled 2021-10-30 23:13:17 -07:00
Jarred Sumner
17b186933d [Bun.js] Implement supports-color polyfill (so that chalk works) 2021-10-30 23:12:11 -07:00
Jarred Sumner
fd57edceff [Bun.js] fix node fetch polyfills 2021-10-30 23:11:43 -07:00
Jarred Sumner
1876c0e11a Fixes #34 2021-10-30 21:44:31 -07:00
Jarred Sumner
cd5c740368 [internal] Fix loading runtime code in debug builds 2021-10-30 20:53:08 -07:00
Jarred Sumner
e2eef2bb25 [internal] Makefile 2021-10-30 19:24:42 -07:00
Jarred Sumner
ad3c19a160 Linking instructions in Makefile 2021-10-30 18:20:53 -07:00
Jarred Sumner
07bb25f7b1 Update Makefile 2021-10-30 18:16:15 -07:00
Jarred Sumner
edd0223377 Update README.md 2021-10-30 18:15:31 -07:00
Jarred Sumner
34a8a623f4 Update README.md 2021-10-30 18:12:31 -07:00
Jarred Sumner
f854539ea9 Update README.md 2021-10-30 18:09:50 -07:00
Jarred Sumner
cd1b8ccde7 Update Makefile 2021-10-30 18:05:35 -07:00
Jarred Sumner
cf3f8d2bb0 Update Makefile 2021-10-30 18:04:11 -07:00
Jarred Sumner
f1a0e718b3 Update Makefile 2021-10-30 17:55:14 -07:00
Jarred Sumner
08e0a51036 Add prettier to makefile & package.json 2021-10-30 17:48:04 -07:00
Jarred Sumner
8e0f21cc91 [internal] Make zig and npm client possibly environment variables 2021-10-30 17:45:22 -07:00
Jarred Sumner
ae7843f244 Fix make require 2021-10-30 17:37:03 -07:00
Jarred Sumner
b5b47e6525 Update README.md 2021-10-30 17:24:53 -07:00
Jarred Sumner
e7a4f9f507 [internal] generate .zip for release in Linux was missing filepath 2021-10-30 16:21:37 -07:00
Jarred Sumner
658926189f Update README.md 2021-10-30 16:21:08 -07:00
Jarred Sumner
154c8372e3 [Bun.js] Call JSCInitialize() before starting 2021-10-30 05:01:47 -07:00
Jarred Sumner
a68b5eef86 [Bun.js] Enable SharedArrayBuffer 2021-10-30 04:52:15 -07:00
Jarred Sumner
65ea1e4647 [Bun.js] Fix entry point to only call default if it was a CommonJS transformed function 2021-10-30 03:11:58 -07:00
Jarred Sumner
f8f85430c0 [internal] gitignore blobs for identifier cache 2021-10-30 01:49:19 -07:00
Jarred Sumner
d8a2eb81e3 [internal] Add identifier-cache to makefile so we don't forget to run it 2021-10-30 01:48:58 -07:00
Jarred Sumner
9a9c0df6b0 [lexer] Fix crash on legacy octal literals 2021-10-30 01:28:27 -07:00
Jarred Sumner
0a86beccc7 Bump build id 2021-10-30 01:27:50 -07:00
Jarred Sumner
2fe9791127 Update CHANGELOG.md 2021-10-30 01:23:21 -07:00
Jarred Sumner
b856d50c3f Update CHANGELOG.md 2021-10-30 01:19:41 -07:00
Jarred Sumner
dde2b80e1d Update CHANGELOG.md 2021-10-30 01:19:15 -07:00
Jarred Sumner
49b954462d [Bun.js] Add performance.now() 2021-10-30 01:19:10 -07:00
Jarred Sumner
c51dac1282 [internal] Fix build issue with the JavaScriptCore bindings on macOS. GNU sed != BSD sed 2021-10-29 23:41:43 -07:00
Jarred Sumner
0d002c7057 [bun run] Support running JavaScript, TypeScript, JSX, and TSX files using Bun.js 2021-10-29 23:41:06 -07:00
Jarred Sumner
1d03e90b5c [internal] This is no longer a feature flag in JSC 2021-10-29 23:37:29 -07:00
Jarred Sumner
25ac773cf3 [Bun.js] Add support for Top Level Await! 2021-10-29 23:36:55 -07:00
Jarred Sumner
ecb069ac85 [internal] Normalize import filepaths 2021-10-29 23:36:00 -07:00
Jarred Sumner
a6cf6c4069 [Bun.js] Fix silly oversight with fetch implementation 2021-10-29 23:35:06 -07:00
Jarred Sumner
6854d83842 [internal] Fix missing symbol errors when building JavaScriptCore bindings without already having the object files 2021-10-29 23:34:19 -07:00
Jarred Sumner
4aab78f619 [internal] Improve Bun's debug build times 2021-10-29 23:32:30 -07:00
Jarred Sumner
95d2860930 Add integration test that verifies bash exported functions work in bun run 2021-10-29 19:17:44 -07:00
Jarred Sumner
70db76a798 Pass through environment variables from the process verbatim
Fixes https://github.com/Jarred-Sumner/bun/issues/40
2021-10-29 18:35:42 -07:00
Jarred Sumner
07bf3eb1e9 Merge pull request #41 from mikeroelens/mikeroelens/fix-shell-install-command 2021-10-29 15:39:36 -07:00
Mike Roelens
237e672e70 fix: add missing quotation in sample zsh config 2021-10-29 15:14:02 -04:00
Jarred Sumner
61d436c29d https:// for the URL 2021-10-29 08:21:30 -07:00
Jarred Sumner
22ea3e76f9 Update README.md 2021-10-28 21:40:25 -07:00
Jarred Sumner
0089d04459 Update README.md 2021-10-28 21:18:48 -07:00
Jarred Sumner
26ee46ad5b Bump 2021-10-28 19:05:27 -07:00
Jarred Sumner
417c4e0faa - Fix consistentcy issue with runtime hash
- Fix edgecases in strings.eqlComptime by simplifying the implementation
2021-10-28 19:03:49 -07:00
Jarred Sumner
b6675dd0ab Explicitly check content type 2021-10-28 17:33:40 -07:00
Jarred Sumner
dff40c5220 FIx webkit commit 2021-10-28 17:08:28 -07:00
Jarred Sumner
1fd426432e Fix spacing, add check that the version matches before we push 2021-10-28 17:06:42 -07:00
Jarred Sumner
97c43ef787 Don't run bun upgrade in the makefile 2021-10-28 17:02:27 -07:00
Jarred Sumner
a546e56669 Update Makefile 2021-10-28 16:55:22 -07:00
Jarred Sumner
4b52192974 Update upgrade_command.zig 2021-10-28 16:52:57 -07:00
Jarred Sumner
fb10e0c4cb Upgrade checker + polish for bun upgrade 2021-10-28 16:39:26 -07:00
Jarred Sumner
a44cb9708f New subcommand: bun upgrade. It upgrades bun to the latest version. 2021-10-28 05:34:38 -07:00
Jarred Sumner
c7fc08056a part 1 of try to fix the npm install process 2021-10-27 17:38:05 -07:00
Jarred Sumner
12ba37e43a Update build-id 2021-10-27 15:27:03 -07:00
Jarred Sumner
928346b842 Verify package installs successfully for each platform 2021-10-27 15:26:04 -07:00
Jarred SUmner
b81c895e1d Add test that verifies installing bun with yarn & npm works before publishing 2021-10-27 04:26:38 -07:00
Jarred Sumner
d434e5aeac Make the installation more careful 2021-10-27 04:12:13 -07:00
Jarred Sumner
2250db41b4 Add universal macOS build so that Bun works on rosetta builds of Node.js 2021-10-27 02:41:45 -07:00
Jarred Sumner
826db9021e Before publishing the binary to npm, verify it installs successfully and it's the expected version 2021-10-27 01:42:50 -07:00
Jarred Sumner
ad61279621 Fix aarch64 build errors 2021-10-27 01:22:02 -07:00
Jarred Sumner
5ce1b36130 Choose different clang for macOS and Linux 2021-10-26 22:57:49 -07:00
Jarred SUmner
a1f17f70eb Suggest running tests in build instructions 2021-10-26 22:38:36 -07:00
Jarred SUmner
a0f086ba85 Fix Linux x64 build 2021-10-26 22:37:03 -07:00
Jarred Sumner
8d095a235f Add test that checks JIT is enabled for JavaScriptCore and crashes if it isn't 2021-10-26 19:07:37 -07:00
Jarred Sumner
ff1417421b Simple integration test for bun run 2021-10-26 19:06:45 -07:00
Jarred Sumner
00fb04f309 Update Makefile 2021-10-26 18:47:43 -07:00
Jarred Sumner
a3cc17fbe6 Add a very simple integration test for bun create next & bun create react 2021-10-26 18:46:53 -07:00
Jarred Sumner
fd27d403d7 Aligning text in terminals is tedious 2021-10-26 17:48:33 -07:00
Jarred Sumner
6d29e314a0 Switch to using optionalDependencies for installing the packages instead of a postinstall script.
Sorry yarn v1 users :(
2021-10-26 17:37:44 -07:00
Jarred Sumner
902e438e6c Update README.md 2021-10-26 17:26:45 -07:00
Jarred Sumner
096d668d83 Bun is now a task runner as well 2021-10-26 17:24:09 -07:00
Jarred Sumner
49c5c32714 More spacing 2021-10-26 17:19:45 -07:00
Jarred Sumner
9a70d8daa2 Update README.md 2021-10-26 17:15:35 -07:00
Jarred Sumner
79eb8d9d78 Update README.md 2021-10-26 17:12:22 -07:00
Jarred Sumner
221b280856 spacing 2021-10-26 17:09:38 -07:00
Jarred Sumner
933378ab80 Update README.md 2021-10-26 16:58:57 -07:00
Jarred Sumner
bd51d194cf Add .cjs, .mts, and .cts to the list of file extensions to check for imports 2021-10-26 16:58:51 -07:00
Jarred Sumner
1e27c7d8ce [bun run] Add to README 2021-10-26 16:49:48 -07:00
Jarred Sumner
7d554ed175 [bun run] Fix passthrough behavior 2021-10-26 16:49:34 -07:00
Jarred Sumner
e72d765961 Spacing 2021-10-26 16:18:57 -07:00
Jarred Sumner
9ce38b86ab Fix edgecase with options loading attempting to create an output directory when it shouldn't 2021-10-26 16:18:51 -07:00
Jarred Sumner
05bdda7b07 Update clap.zig 2021-10-26 15:47:14 -07:00
Jarred Sumner
d68f18c77a [bun run] Add node_modules/.bin in reverse order, print failure on exit code 2021-10-26 15:47:08 -07:00
Jarred Sumner
ae6349e573 [.env loader] Fix bug with PATH values sometimes getting cut off at the end by one character 2021-10-26 15:30:26 -07:00
Jarred Sumner
0541cff2ad New subcommand: bun run run scripts in package.json really fast 2021-10-26 05:18:21 -07:00
Jarred Sumner
e69f8c36d2 [router] Don't log the route names since that's not necessary anymore 2021-10-25 17:06:38 -07:00
Jarred Sumner
e7f191c08b [HTTP] Fix error handling modal from showing when there are no errors 2021-10-25 17:06:20 -07:00
Jarred Sumner
6a2372b0b2 Fix rendering with Next.js after latest changes to route api 2021-10-25 17:05:59 -07:00
Jarred Sumner
0592515639 [HTTP Server] Add flag for disabling Bun.js 2021-10-25 17:05:10 -07:00
Jarred Sumner
a6c4bba6c2 [JSON loader] Fix importing JSON in ESM modules 2021-10-25 17:04:52 -07:00
Jarred Sumner
5691bf385b [.env loader] Add CLI flag to dump loaded environment variables as JSON 2021-10-25 17:04:32 -07:00
Jarred Sumner
a149f0abb9 Update build-id 2021-10-25 06:17:20 -07:00
Jarred Sumner
eae7051111 Add snapshots for latin1 regexp, add more codepoints to string escapes 2021-10-25 06:17:16 -07:00
Jarred Sumner
adb6be05d1 Use PNPM in Makefile 2021-10-25 06:16:31 -07:00
Jarred Sumner
4e889c7b47 Fix JSX unicode handling, slightly improve perf 2021-10-25 05:42:01 -07:00
Jarred Sumner
2ed6605cc3 [Bun.js] When Body is UTF-16 encoded, convert it to UTF-8. 2021-10-25 04:46:01 -07:00
Jarred Sumner
42c264bf7b Fix all known string encoding bugs 2021-10-25 00:52:07 -07:00
Jarred Sumner
fe6564b533 finish Expr.alloc -> Expr.init 2021-10-24 17:12:30 -07:00
Jarred Sumner
f6923f21b1 [internal] only set source for test once 2021-10-24 17:00:51 -07:00
Jarred Sumner
edfc61889c Mark all exported symbols as weak, always zig fmt the headers file to reduce diff churn 2021-10-24 17:00:21 -07:00
Jarred Sumner
08c8ca18a7 [internal] Get source URLs in C++ 2021-10-24 16:54:37 -07:00
Jarred Sumner
9e4f16ac8b ^ 2021-10-24 16:52:16 -07:00
Jarred Sumner
03ece0568d Expr.alloc -> Expr.init 2021-10-24 16:51:39 -07:00
Jarred Sumner
2dcb465d50 Upgrade to latest peechy 2021-10-24 16:48:47 -07:00
Jarred Sumner
c93655c717 Fix build error 2021-10-24 16:11:06 -07:00
Jarred Sumner
6f6510169e [JSON] Use a special lexer variant only for JSON 2021-10-24 16:09:15 -07:00
Jarred Sumner
cfe159f636 [internal] Remove more unused code and move the is_ascii_only boolean to only update for JSON parsing 2021-10-24 16:07:47 -07:00
Jarred Sumner
213f361551 [internal] Handle allocation failure 2021-10-24 15:55:27 -07:00
Jarred Sumner
3582941791 [internal] Use isPresent() instead of checking slice len 2021-10-24 15:53:27 -07:00
Jarred Sumner
a3cd9347e6 ✂️ Dead code 2021-10-24 15:53:02 -07:00
Jarred Sumner
449c8b5f36 [internal] Tweak build system to better support unit tests in Zig 2021-10-24 06:18:42 -07:00
Jarred Sumner
1f7af3754d [picohttp] failing test 2021-10-24 06:11:06 -07:00
Jarred Sumner
72df6b9be2 [.env loader] Environment variables are strings. 2021-10-24 06:10:53 -07:00
Jarred Sumner
044c0cfdc3 [internal] more inlining 2021-10-24 06:08:32 -07:00
Jarred Sumner
3c43f65234 [internal] ✂️ dead code 2021-10-24 06:08:08 -07:00
Jarred Sumner
bd2d284c53 [internal] some inlining 2021-10-24 06:07:39 -07:00
Jarred Sumner
ffea9c010b [internal] :snowflake: 2021-10-24 06:05:36 -07:00
Jarred Sumner
44351b57f7 [.env loader] Tests pass 2021-10-24 06:04:42 -07:00
Jarred Sumner
4bbb938de8 Comment out WASM test since WASM is currently unsupported 2021-10-23 22:57:01 -07:00
Jarred Sumner
437270e0af Remove very outdated tests 2021-10-23 22:56:35 -07:00
Jarred Sumner
09b7f4c95d Remove unused feature flag parallel_bun 2021-10-23 22:56:20 -07:00
Jarred Sumner
38f83c50c4 Add flag for dumping the environment variables 2021-10-23 22:55:47 -07:00
Jarred Sumner
2f06dc5755 [internal] Add easier commands for running unit tests 2021-10-23 22:55:26 -07:00
Jarred Sumner
d6b66e2155 Handle edgecase when returning errors 2021-10-23 22:54:56 -07:00
Jarred Sumner
309298fa42 Fix bug with MutableString.ensureValidIdentifier 2021-10-23 22:54:39 -07:00
Jarred Sumner
a0a2fa964b [internal] Remove more dead code, add script to find .zig files that aren't imported by other .zig files 2021-10-23 16:48:12 -07:00
Jarred Sumner
0c769d0f61 No more iguanaTLS 2021-10-23 16:15:44 -07:00
Jarred Sumner
1b90619890 [internal] ✂️ dead code 2021-10-23 16:15:36 -07:00
Jarred Sumner
0ea34216de Load environment variables into defines when possible 2021-10-23 05:04:08 -07:00
Jarred Sumner
53374ac54a [Bundler] When modules fail to resolve, continue building so that you can see many errors without re-running Bun 2021-10-23 05:03:26 -07:00
Jarred Sumner
6355ac219e [JS Parser] Parser errors should _always_ report an error location 2021-10-23 05:02:26 -07:00
Jarred Sumner
384ad96637 Support string-only defines 2021-10-23 05:00:31 -07:00
Jarred Sumner
0361b0df70 [.env loader] Parse values as JavaScript string literals instead of JSON 2021-10-23 05:00:14 -07:00
Jarred Sumner
a1b8c20c3f Add "process.env" to global object 2021-10-23 04:59:03 -07:00
Jarred Sumner
de01d581c1 Rewrite the CodepointIterator to fix some bugs 2021-10-23 04:58:20 -07:00
Jarred Sumner
f1bda194e0 [Lexer] Improve lexing performance by 2% via a bitfield for checking identifiers, inlining functions, and moving some branches to comptime 2021-10-23 04:57:34 -07:00
Jarred Sumner
a84b62452c [Bun.js] Escape unicode identifiers. This is necessary because we load source code into JavaScriptCore as latin1 to conserve memory. Loading as UTF-16 means your code uses 2x as much memory. 2021-10-23 04:56:09 -07:00
Jarred Sumner
e039ba5130 [Bun.js] Add Bun.env and support process.env for non-transpiled environment variables 2021-10-23 04:54:17 -07:00
Jarred Sumner
e67dd8947b [lexer] 0x200C and 0x200D are valid ID_Continue characters 2021-10-21 04:31:30 -07:00
Jarred Sumner
2d6a4a4956 Split tests into separate .json file 2021-10-21 04:30:50 -07:00
Jarred Sumner
f394581ed8 Add test for non-ascii latin1 characters in strings 2021-10-21 04:30:44 -07:00
Jarred Sumner
33b0c89e7c [Bun.js] Fix SyntaxError not showing source file or line number 2021-10-21 04:27:36 -07:00
Jarred Sumner
4e3aa3c289 Fix index + static route 2021-10-20 05:12:01 -07:00
Jarred Sumner
58b196c583 rewrote most of the router 2021-10-20 04:18:29 -07:00
Jarred Sumner
3dc53c3d13 Starting to rewrite the router to fix some bugs and support catch-all + optional routes 2021-10-18 23:55:17 -07:00
Jarred Sumner
4f2c1cfe85 Update README.md 2021-10-17 18:40:54 -07:00
Jarred Sumner
6e16b3cf84 Bump to latest 2021-10-17 15:36:52 -07:00
Jarred Sumner
9f0ab479b0 [bun-framework-next] Fix when the project does not define a _app page 2021-10-17 15:36:28 -07:00
Jarred Sumner
884b5e13ee Add --open flag to bun create 2021-10-17 03:42:03 -07:00
Jarred Sumner
7d4aab4cf1 Slight cleanup 2021-10-17 03:41:31 -07:00
Jarred Sumner
6bb0c03d8d Update README.md 2021-10-16 23:56:50 -07:00
Jarred Sumner
797c94b0e9 Update README.md 2021-10-16 23:52:57 -07:00
Jarred Sumner
e63fbcefe9 bump! 2021-10-16 23:49:39 -07:00
Jarred Sumner
dcc29d3db6 Improve support for Create React App 2021-10-16 23:24:23 -07:00
Jarred Sumner
be66c01829 Update js_ast.zig 2021-10-16 21:33:09 -07:00
Jarred Sumner
21b9884606 Support GitHub repositories, transform package.json to better fit Bun's usage 2021-10-16 21:33:05 -07:00
Jarred Sumner
fd6d93292c more strings 2021-10-16 20:23:37 -07:00
Jarred Sumner
9000165718 Ensure self is always defined 2021-10-16 20:23:25 -07:00
Jarred Sumner
54b313cc5a Fix edgecase in Transfer-Encoding chunked 2021-10-16 20:23:06 -07:00
Jarred Sumner
2461c11536 Cleanup 2021-10-15 23:36:30 -07:00
Jarred Sumner
f17345ffe4 Bump the version 2021-10-15 23:05:58 -07:00
Jarred Sumner
4908a63f61 Latest 2021-10-15 23:03:31 -07:00
Jarred Sumner
da7de899e1 📷 2021-10-15 23:02:40 -07:00
Jarred Sumner
44108d6a26 Fix static libarchive build 2021-10-15 22:52:24 -07:00
Jarred Sumner
c7fb978b7b Merge branch 'main' of github.com:Jarred-Sumner/bun 2021-10-15 22:37:29 -07:00
Jarred Sumner
0db94d94d6 Bump s2n-tls 2021-10-15 22:36:28 -07:00
Jarred SUmner
92e489760d Linux build fixes 2021-10-15 22:33:36 -07:00
Jarred Sumner
decee7616f Update Makefile 2021-10-15 20:33:35 -07:00
Jarred Sumner
deafd3d0d4 Cleanup makefile to get libiconv setup for linux 2021-10-15 20:25:23 -07:00
Jarred Sumner
b9bbd819be Update Makefile 2021-10-15 20:14:55 -07:00
Jarred Sumner
b956ea5a5e Update Makefile 2021-10-15 20:13:18 -07:00
Jarred Sumner
cf2e81b036 Merge branch 'jarred/gen' 2021-10-15 20:08:40 -07:00
Jarred Sumner
bf2732599c update makefile 2021-10-15 20:08:21 -07:00
Jarred Sumner
10696680ff Polish 2021-10-15 19:44:53 -07:00
Jarred Sumner
7e159cb5cd ❇️ 2021-10-14 22:10:08 -07:00
Jarred Sumner
74cda61c88 Update README.md 2021-10-14 19:17:44 -07:00
Jarred Sumner
9dfe57a3f7 Update README.md 2021-10-14 19:17:20 -07:00
Jarred Sumner
f10dcd780c Update README.md 2021-10-14 19:08:55 -07:00
Jarred Sumner
bee7efb5d9 Update README.md 2021-10-14 19:07:40 -07:00
Jarred Sumner
0039b53d21 Update README.md 2021-10-14 19:01:51 -07:00
Jarred Sumner
9f86acbe58 Update README.md 2021-10-14 18:58:50 -07:00
Jarred Sumner
bbc1bcbed1 Support local templates 2021-10-14 18:55:41 -07:00
Jarred Sumner
3ed824fe0f Update router.zig 2021-10-14 16:15:04 -07:00
Jarred Sumner
fe24b96d61 Support passing an absolute path 2021-10-14 16:14:48 -07:00
Jarred Sumner
4b6d8a152f Update bun-create.md 2021-10-14 14:51:51 -07:00
Jarred Sumner
e21b9afdf2 Update bun-create.md 2021-10-14 14:50:34 -07:00
Jarred Sumner
901d7d8759 Add doc explaining bun-create 2021-10-14 14:49:48 -07:00
Jarred Sumner
4b618f9ad1 bun create react app is almost done 2021-10-14 05:22:47 -07:00
Jarred Sumner
0f7bc76f39 v0.0.0 2021-10-13 23:13:58 -07:00
Jarred Sumner
6d997ab201 [fetch] Slight perf improvement 2021-10-13 14:29:03 -07:00
Jarred Sumner
8f7f4ae72f --turbo mode for fetch cli, which disables sending TLS shutdown 2021-10-13 14:17:23 -07:00
Jarred Sumner
c85b5f6a87 [fetch] Support Transfer-Encoding: chunked 2021-10-13 14:06:51 -07:00
Jarred Sumner
ba5f9887fb Update build.zig 2021-10-13 00:28:31 -07:00
Jarred Sumner
9e3e9a2d6d Clean up examples a little 2021-10-13 00:28:20 -07:00
Jarred Sumner
88a5e2d34d Add TLS 1.3 support, improve fetch() HTTPS performance 2021-10-13 00:27:35 -07:00
Jarred Sumner
afc346d6f1 s2n.zig 2021-10-12 16:27:32 -07:00
Jarred Sumner
4dd398ca7a ignore = dirty 2021-10-12 16:27:15 -07:00
Jarred Sumner
756bfc9077 Add fetch CLI test app 2021-10-12 16:26:57 -07:00
Jarred Sumner
f646250a91 Add s2n, remove openssl 2021-10-12 16:26:24 -07:00
Jarred Sumner
24c567086f Add OpenSSL 😢 2021-10-11 20:15:15 -07:00
Jarred Sumner
05b1696df7 Add libarchive bindings 2021-10-11 18:31:24 -07:00
Jarred Sumner
0baa3b511e Update README.md 2021-10-11 02:34:54 -07:00
Jarred Sumner
d793088575 Update README.md 2021-10-11 02:34:41 -07:00
Jarred Sumner
9aa7f9ed18 link to fork 2021-10-11 02:33:35 -07:00
Jarred Sumner
e7f6cf12a5 Update .gitmodules 2021-10-10 23:41:49 -07:00
Jarred Sumner
e2ba468924 Update .gitmodules 2021-10-10 23:41:40 -07:00
Jarred Sumner
85760c0a4c Missing fixture 2021-10-10 23:41:27 -07:00
Jarred Sumner
0db7af6166 [fetch] Add support for gzip & deflate to the http client
Powered by Cloudflare's zlib fork
2021-10-10 23:41:18 -07:00
Jarred Sumner
5e3d1dd4b5 Merge pull request #30 from alexkuz/patch-1 2021-10-09 03:47:24 -07:00
Alexander Kuznetsov
6eb9a36a22 Fetch WebKit submodule via https instead of ssh
Fetching submodule via ssh leads to auth error if SSH key is not provided in GitHub settings; all submodules left uninitialized as a result
2021-10-09 11:50:14 +03:00
Jarred Sumner
e88e9401f1 Fix bug where occasionally unary expressions would simplify incorrectly due to an undefined memory issue 2021-10-08 17:24:03 -07:00
Jarred Sumner
829b4287dd Yet Another Packed Struct Bug 2021-10-08 15:48:58 -07:00
Jarred Sumner
2bf7b5a7ab Update readme.md 2021-10-07 22:31:36 -07:00
Jarred Sumner
1c83f3091c Update README.md 2021-10-07 21:31:52 -07:00
Jarred Sumner
dfd08e7c55 Fix potential symbol collision in bun-macro-relay 2021-10-07 21:31:11 -07:00
Jarred Sumner
3b28af17db Fix edgecase when bundling JavaScript that references ESM exported functions before they're defined 2021-10-07 21:30:28 -07:00
Jarred Sumner
5a03dfb9a4 Schema 2021-10-07 21:29:16 -07:00
Jarred Sumner
fa1aa301e8 Add --port CLI flag for setting a port instead of --origin. --port has higher precedence than --origin so that proxies can work 2021-10-07 21:29:07 -07:00
Jarred Sumner
ae7b91efe2 Add CSS HMR benchmark 2021-10-07 21:27:47 -07:00
Jarred Sumner
6d9ccd9b8e Fix package.json file 2021-10-06 20:02:58 -07:00
Jarred Sumner
0d79435ce2 Snapshots 2021-10-06 20:02:40 -07:00
Jarred Sumner
4ee2fdf1c6 uname 2021-10-06 19:32:32 -07:00
Jarred Sumner
cd273daa1b Missing @TypeOf 2021-10-06 19:31:19 -07:00
Jarred Sumner
c2e9d49f69 oops 2021-10-06 19:29:50 -07:00
Jarred Sumner
38a9c92eec Bump it 2021-10-06 19:28:44 -07:00
Jarred Sumner
1d0f442718 📷 2021-10-06 19:26:43 -07:00
Jarred Sumner
1e8babe185 HTTP paths must resolve from ./$PROJECT_ROOT unless explicitly marked absolute.
This fixes the issue with deeply nested PNPM workspace packages. Happened when using @emotion/react inside a PNPM workspace when @emotion/react was hoisted to the workspace root but react was in a child node_modules folder. It would fail to resolve `"react/jsx-dev-runtime"` because it didn't exist in any node_modules folder relative to `@emotion/react`'s real path.
2021-10-06 19:26:28 -07:00
Jarred Sumner
69d3b5ca60 Update browser.js 2021-10-06 19:21:34 -07:00
Jarred Sumner
a493c18193 Fix JSX transform edgecase with static children 2021-10-06 19:21:26 -07:00
Jarred Sumner
5370ea71c0 Add support for reading JSX config from tsconfig.json 2021-10-06 16:49:26 -07:00
Jarred Sumner
0afec7739b Update README.md 2021-10-05 23:09:57 -07:00
Jarred Sumner
a7173d54ce Update README.md 2021-10-05 23:08:11 -07:00
Jarred Sumner
3b10cfae80 analytics is good enough for now 2021-10-05 23:08:06 -07:00
Jarred Sumner
bd14ad9e6e Async analytics works now
Requests are ~60 bytes and the thread mostly sleeps, so it should be pretty low overhead overall.
2021-10-05 17:50:05 -07:00
Jarred Sumner
9507cd8ed6 [fetch] Fix bug with HTTP request bodies 2021-10-05 17:45:32 -07:00
Jarred Sumner
dfe74cb5c4 Add BUN_DISABLE_ANALYTICS flag to disable analytics and automatically disable analytics when running inside hyperfine 2021-10-05 03:11:35 -07:00
Jarred Sumner
00e7b7c3d5 Simple analytics 2021-10-05 02:27:49 -07:00
353 changed files with 65241 additions and 47173 deletions

16
.gitignore vendored
View File

@@ -30,7 +30,6 @@ cover
coverage
coverv
*.trace
bench
github
out.*
out
@@ -65,6 +64,17 @@ release/
sign.*.json
packages/debug-*
packages/bun-cli/postinstall.js
packages/bun-*/bin/*
packages/bun-*/bun
packages/bun-*/bun-profile
packages/bun-*/debug-bun
packages/bun-*/*.o
packages/bun-cli/postinstall.js
packages/bun-cli/bin/*
packages/bun-cli/bin/*
bun-test-scratch
misctools/fetch
src/deps/libiconv
src/deps/openssl
src/tests.zig
*.blob

14
.gitmodules vendored
View File

@@ -7,9 +7,21 @@
ignore = dirty
[submodule "src/javascript/jsc/WebKit"]
path = src/javascript/jsc/WebKit
url = git@github.com:/Jarred-Sumner/WebKit
url = https://github.com/Jarred-Sumner/WebKit.git
ignore = dirty
[submodule "src/deps/mimalloc"]
path = src/deps/mimalloc
url = https://github.com/microsoft/mimalloc.git
ignore = dirty
[submodule "src/deps/zlib"]
path = src/deps/zlib
url = https://github.com/cloudflare/zlib.git
ignore = dirty
[submodule "src/deps/libarchive"]
path = src/deps/libarchive
url = https://github.com/libarchive/libarchive.git
ignore = dirty
[submodule "src/deps/s2n-tls"]
path = src/deps/s2n-tls
url = https://github.com/Jarred-Sumner/s2n-tls
ignore = dirty

140
.vscode/launch.json vendored
View File

@@ -4,14 +4,46 @@
{
"type": "lldb",
"request": "launch",
"name": "Transpile small",
"program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
"args": [
// "/Users/jarred/Desktop/webpack4.js"
// "/Users/jarred/Code/bun/examples/css-stress-test/nexty/node_modules/next/dist/build/utils.js"
"./dotenv-load-check.ts"
],
"cwd": "${workspaceFolder}/examples/css-stress-test",
"name": "fetch debug",
"program": "${workspaceFolder}/misctools/fetch",
"args": ["https://api.github.com/repos/hanford/trends/tarball"],
"cwd": "${workspaceFolder}",
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "bun create debug",
"program": "bun-debug",
"args": ["create", "hanford/trends", "foo"],
"cwd": "/tmp/",
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "bun run debug",
"program": "bun-debug",
"args": ["paoskdpoasdk"],
"cwd": "/tmp/",
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "bun a debug",
"program": "bun-debug",
"args": ["create", "https://github.com/ahfarmer/calculator", "--force"],
"cwd": "/tmp/",
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "bun routes",
"program": "bun-debug",
"args": [],
"cwd": "${workspaceFolder}/integration/apps/routing",
"console": "internalConsole"
},
{
@@ -32,7 +64,7 @@
"type": "lldb",
"request": "launch",
"name": ".bun",
"program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
"program": "bun-debug",
"args": [
"./examples/hello-next/node_modules.server.bun"
// "--origin=https://localhost:9000/"
@@ -44,7 +76,7 @@
"type": "lldb",
"request": "launch",
"name": "Discord",
"program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
"program": "bun-debug",
"args": [
"discord"
// "--origin=https://localhost:9000/"
@@ -69,7 +101,7 @@
"type": "lldb",
"request": "launch",
"name": "Dev Launch",
"program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
"program": "bun-debug",
"args": [
"./simple.css",
"--resolve=dev",
@@ -103,7 +135,7 @@
"type": "lldb",
"request": "launch",
"name": "Demo Serve",
"program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
"program": "bun-debug",
// "args": ["--serve", "--origin=http://localhost:3000"],
"args": ["dev", "--origin=http://localhost:3000"],
"cwd": "${workspaceFolder}/examples/hello-next",
@@ -123,7 +155,7 @@
"type": "lldb",
"request": "launch",
"name": "Demo Lazy Build",
"program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
"program": "bun-debug",
"args": [
"./src/index.tsx",
"--resolve=lazy",
@@ -137,7 +169,7 @@
"type": "lldb",
"request": "launch",
"name": "Demo Build",
"program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
"program": "bun-debug",
"args": [
"./src/index.tsx",
"--resolve=dev",
@@ -151,10 +183,28 @@
{
"type": "lldb",
"request": "launch",
"name": "Fixture serve",
"program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
"args": [],
"cwd": "${workspaceFolder}/src/test/fixtures",
"name": "Dazzle serve",
"program": "bun-debug",
"args": ["--origin=http://localhost:5000", "--disable-hmr"],
"cwd": "/Users/jarred/Build/lattice/apps/dazzle",
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "Bun",
"program": "bun-debug",
"args": ["bun", "--use=next"],
"cwd": "/Users/jarred/Build/lattice/apps/dazzle",
"console": "internalConsole"
},
{
"type": "lldb",
"request": "launch",
"name": "unicode check",
"args": ["--disable-hmr"],
"program": "bun-debug",
"cwd": "/Users/jarred/Build/app994",
"console": "internalConsole"
},
@@ -162,7 +212,7 @@
"type": "lldb",
"request": "launch",
"name": "Demo .bun",
"program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
"program": "bun-debug",
"args": ["bun", "--use=bun-framework-next"],
"cwd": "${workspaceFolder}/examples/hello-next",
"console": "internalConsole"
@@ -171,7 +221,7 @@
"type": "lldb",
"request": "launch",
"name": "PNPM .bun",
"program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
"program": "bun-debug",
"args": ["bun", "./pages/index.js"],
"cwd": "/Users/jarred/Build/pnpm-bun/packages/app",
"console": "internalConsole"
@@ -181,7 +231,7 @@
"type": "lldb",
"request": "launch",
"name": "PNPM serve",
"program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
"program": "bun-debug",
"args": [],
"cwd": "/Users/jarred/Build/pnpm-bun/packages/app",
"console": "internalConsole"
@@ -190,7 +240,7 @@
"type": "lldb",
"request": "launch",
"name": "Mixed case resolve",
"program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
"program": "bun-debug",
"args": [
"build",
"./index.js",
@@ -205,7 +255,7 @@
"type": "lldb",
"request": "launch",
"name": "Build .bun lotta-modules",
"program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
"program": "bun-debug",
"args": ["bun", "./index.js", "--platform=browser"],
"cwd": "${workspaceFolder}/examples/lotta-modules/",
"console": "internalConsole"
@@ -214,7 +264,7 @@
"type": "lldb",
"request": "launch",
"name": "Dev CRA",
"program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
"program": "bun-debug",
"args": ["dev", "--platform=browser"],
"cwd": "${workspaceFolder}/examples/hello-create-react-app/",
"console": "internalConsole"
@@ -223,7 +273,7 @@
"type": "lldb",
"request": "launch",
"name": "Fragment",
"program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
"program": "bun-debug",
"args": [],
"cwd": "${workspaceFolder}/src/test/fixtures",
"console": "internalConsole"
@@ -232,7 +282,7 @@
"type": "lldb",
"request": "launch",
"name": "Context Bun Bug",
"program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
"program": "bun-debug",
"args": ["bun", "./code.js"],
"cwd": "/Users/jarred/Build/context/www",
"console": "internalConsole"
@@ -241,7 +291,7 @@
"type": "lldb",
"request": "launch",
"name": "Context Bun",
"program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
"program": "bun-debug",
"args": ["bun", "--use=next"],
"cwd": "/Users/jarred/Build/context/www",
"console": "internalConsole"
@@ -250,7 +300,7 @@
"type": "lldb",
"request": "launch",
"name": "Bun-hello",
"program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
"program": "bun-debug",
"args": [],
"cwd": "${workspaceFolder}/packages/bun-hello",
"console": "internalConsole"
@@ -259,7 +309,7 @@
"type": "lldb",
"request": "launch",
"name": "Integration Test Dev",
"program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
"program": "bun-debug",
"args": [],
"cwd": "${workspaceFolder}/integration/snippets",
"console": "internalConsole"
@@ -268,7 +318,7 @@
"type": "lldb",
"request": "launch",
"name": "Integration Test Dev (no hmr)",
"program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
"program": "bun-debug",
"args": ["--disable-hmr"],
"cwd": "${workspaceFolder}/integration/snippets",
"console": "internalConsole"
@@ -296,7 +346,7 @@
"request": "launch",
"name": "Context Dev",
"program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
"program": "bun-debug",
"args": [],
"cwd": "/Users/jarred/Build/context/www",
"console": "internalConsole"
@@ -315,7 +365,7 @@
"type": "lldb",
"request": "launch",
"name": "Debug Dev",
"program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
"program": "bun-debug",
"args": ["dev"],
"cwd": "${workspaceFolder}/examples/hello-next",
"console": "internalConsole"
@@ -324,7 +374,7 @@
"type": "lldb",
"request": "launch",
"name": "Type-only import",
"program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
"program": "bun-debug",
"args": [
"bun",
"./src/test/fixtures/type-only-import.ts",
@@ -337,7 +387,7 @@
"type": "lldb",
"request": "launch",
"name": "Dev lotta-modules",
"program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
"program": "bun-debug",
"args": ["dev", "./index.js", "--platform=browser"],
"cwd": "${workspaceFolder}/examples/lotta-modules/",
"console": "internalConsole"
@@ -346,7 +396,7 @@
"type": "lldb",
"request": "launch",
"name": "Demo Build .bun",
"program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
"program": "bun-debug",
"args": [
"bun",
// "./index.js",
@@ -361,7 +411,7 @@
"type": "lldb",
"request": "launch",
"name": "PNPM Resolve symlink",
"program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
"program": "bun-debug",
"args": ["--resolve=dev", "test-pnpm.js", "--platform=browser"],
"cwd": "${workspaceFolder}/examples/css-stress-test",
"console": "internalConsole"
@@ -370,7 +420,7 @@
"type": "lldb",
"request": "launch",
"name": "Demo Print .bun",
"program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
"program": "bun-debug",
"args": ["./node_modules.bun"],
"cwd": "${workspaceFolder}/examples/simple-react",
"console": "internalConsole"
@@ -399,7 +449,7 @@
// "type": "lldb",
// "request": "launch",
// "name": "Dev Launch (other)",
// "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
// "program": "bun-debug",
// "args": ["./simple.jsx", "--resolve=disable"],
// "cwd": "${workspaceFolder}/src/test/fixtures",
// "console": "internalConsole"
@@ -408,7 +458,7 @@
// "type": "lldb",
// "request": "launch",
// "name": "Dev Launch",
// "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
// "program": "bun-debug",
// "preLaunchTask": "build",
// "args": [
// "--resolve=disable",
@@ -423,7 +473,7 @@
// "type": "lldb",
// "request": "launch",
// "name": "Dev Launch",
// "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
// "program": "bun-debug",
// "preLaunchTask": "build",
// "args": [
// "--resolve=dev",
@@ -440,7 +490,7 @@
// "type": "lldb",
// "request": "launch",
// "name": "Dev Launch",
// "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
// "program": "bun-debug",
// "preLaunchTask": "build",
// "args": [
// "--resolve=dev",
@@ -457,7 +507,7 @@
// "type": "lldb",
// "request": "launch",
// "name": "Dev Launch",
// "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
// "program": "bun-debug",
// // "preLaunchTask": "build",
// "args": [
// "--resolve=dev",
@@ -476,7 +526,7 @@
"type": "lldb",
"request": "launch",
"name": "Rome",
// "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
// "program": "bun-debug",
"program": "${workspaceFolder}/build/macos-x86_64/bun",
// "preLaunchTask": "build",
"args": [
@@ -498,8 +548,8 @@
"type": "lldb",
"request": "launch",
"name": "Rome Dev",
// "program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
"program": "${workspaceFolder}/packages/debug-bun-cli-darwin-x64/bin/bun-debug",
// "program": "bun-debug",
"program": "bun-debug",
// "preLaunchTask": "build",
"args": [
"--resolve=dev",

21
.vscode/settings.json vendored
View File

@@ -3,15 +3,16 @@
"search.quickOpen.includeSymbols": false,
"search.seedWithNearestWord": true,
"search.smartCase": true,
"search.exclude": {
"src/javascript/jsc/WebKit/**/*": true
},
"search.exclude": {},
"search.followSymlinks": false,
"search.useIgnoreFiles": true,
"zig.buildOnSave": false,
"[zig]": {
"editor.defaultFormatter": "tiehuis.zig"
},
"lldb.verboseLogging": true,
"zig.beforeDebugCmd": "make build-unit ${file} ${filter} ${bin}",
"zig.testCmd": "make test ${file} ${filter} ${bin}",
"files.exclude": {
"**/.git": true,
"**/.svn": true,
@@ -19,8 +20,20 @@
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"**/*.xcworkspacedata": true,
"**/*.xcscheme": true,
"**/*.pem": true,
"**/*.xcodeproj": true,
"integration/snapshots": true,
"integration/snapshots-no-hmr": true
"integration/snapshots-no-hmr": true,
"src/javascript/jsc/WebKit": true,
"src/deps/libarchive": true,
"src/deps/mimalloc": true,
"src/deps/s2n-tls": true,
"src/deps/openssl": true,
"src/deps/zlib": true,
"integration/snippets/package-json-exports/_node_modules_copy": true
},
"C_Cpp.files.exclude": {
"**/.vscode": true,

932
Makefile

File diff suppressed because it is too large Load Diff

426
README.md
View File

@@ -6,6 +6,7 @@ Bun is a new:
- JavaScript & CSS bundler
- Development server with 60fps Hot Module Reloading (& WIP support for React Fast Refresh)
- JavaScript Runtime Environment (powered by JavaScriptCore, what WebKit/Safari uses)
- Task runner for package.json scripts
All in one fast & easy-to-use tool. Instead of 1,000 node_modules for development, you only need Bun.
@@ -14,18 +15,54 @@ All in one fast & easy-to-use tool. Instead of 1,000 node_modules for develo
## Install:
```
# Global install is recommended so bun appears in your $PATH
npm install -g bun-cli
curl -fsSL https://bun.sh/install | bash
```
### Getting started
## Benchmarks
**CSS**: [Bun is 14x faster](./bench/hot-module-reloading/css-stress-test) than Next.js at hot reloading CSS. TODO: compare Vite
**JavaScript**: TODO
## Using Bun as a task runner
Instead of waiting 170ms for your npm client to start for each task, you wait 6ms for Bun.
To use bun as a task runner, run `bun run` instead of `npm run`.
```bash
# Instead of "npm run clean"
bun run clean
# This also works
bun clean
```
Assuming a package.json with a `"clean"` command in `"scripts"`:
```json
{
"name": "myapp",
"scripts": {
"clean": "rm -rf dist out node_modules"
}
}
```
## Using Bun with Next.js
In your project folder root (where `package.json` is):
To create a new Next.js app with Bun:
```bash
npm install -D bun-framework-next
bun create next ./app
cd app
bun
```
To use an existing Next.js app with Bun:
```bash
npm install bun-framework-next
bun bun --use next
bun
```
@@ -39,7 +76,8 @@ Here's what doesn't work yet:
- locales, zones, `assetPrefix` (workaround: change `--origin \"http://localhsot:3000/assetPrefixInhere\"`)
- `next/image` is polyfilled to a regular `<img src>` tag.
- `proxy` and anything else in `next.config.js`
- API, catch-all &amp; catch-all fallback routes. Dynamic routes _are_ supported.
- API routes, middleware (middleware is easier to support though! similar SSR API)
- styled-jsx (technically not Next.js but often used with it)
When using Next.js, Bun automatically reads configuration from `.env.local`, `.env.development` and `.env` (in that order). `process.env.NEXT_PUBLIC_` and `process.env.NEXT_` automatically are replaced via `--define`.
@@ -71,17 +109,24 @@ If `public/index.html` exists, it becomes the default page instead of a 404 page
#### Using Bun with Create React App
To use Bun with `create-react-app`, there are two changes you will need to make in `public/index.html`:
1. Replace `%PUBLIC_URL%` with `/`
2. Insert `<script type="module" async src="/src/index.js">` just before `</body>`
These changes are (sadly) necessary until Bun supports parsing &amp; transpiling HTML.
In your project folder root (where `package.json` is):
To create new a React app:
```bash
bun bun ./src/index.js
bun create react ./app
cd app
bun
```
To use an existing React app:
```bash
# To enable React Fast Refresh, ensure "react-refresh" is installed
npm install -D react-refresh
# Generate a bundle for your entry point(s)
bun bun ./src/index.js # jsx, tsx, ts also work. can be multiple files
# Start the dev server
bun
```
@@ -139,7 +184,6 @@ Bun is a project with incredibly large scope, and it's early days.
| Sharing `.bun` files | Bun |
| [Finish fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) | Bun.js |
| [setTimeout](https://developer.mozilla.org/en-US/docs/Web/API/setTimeout) | Bun.js |
| `bun run` command | Bun.js |
<sup>JS Transpiler == JavaScript Transpiler</sup><br/>
<sup>TS Transpiler == TypeScript Transpiler</sup><br/>
@@ -173,6 +217,9 @@ Currently, Bun implements the following loaders:
| .ts | TypeScript + JavaScript | .js |
| .tsx | TypeScript + JSX + JavaScript | .js |
| .mjs | JavaScript | .js |
| .cjs | JavaScript | .js |
| .mts | TypeScript | .js |
| .cts | TypeScript | .js |
| .css | CSS | .css |
| .env | Env | N/A |
| .\* | file | string |
@@ -405,14 +452,294 @@ type Router = {
To use a framework, you pass `bun bun --use package-name`.
Your framework's package.json `name` should start with `bun-framework-`. This is so that people can type something like `bun bun --use next` and it will check `bun-framework-next` first. This is similar to how Babel plugins tend to start with `babel-plugin-`.
Your framework's `package.json` `name` should start with `bun-framework-`. This is so that people can type something like `bun bun --use next` and it will check `bun-framework-next` first. This is similar to how Babel plugins tend to start with `babel-plugin-`.
For developing frameworks, you can also do `bun bun --use ./relative-path-to-framework`.
If you're interested in adding a framework integration, please reach out. There's a lot here and it's not entirely documented yet.
# FAQ
When running bun on an M1 (or Apple Silicon), if you see a message like this:
> [1] 28447 killed bun create next ./test
It most likely means you're running bun's x64 version on Apple Silicon. This happens if bun is running via Rosetta. Rosetta is unable to emulate AVX2 instructions, which Bun indirectly uses.
The fix is to ensure you installed a version of Bun built for Apple Silicon.
# Reference
### `bun run`
`bun run` is a fast `package.json` scripts runner. Instead of waiting 170ms for your npm client to start every time, you wait 6ms for Bun.
By default, `bun run` prints the script that will be invoked:
```bash
bun run clean
$ rm -rf node_modules/.cache dist
```
You can disable that with `--silent`
```bash
bun run --silent clean
```
To print a list of `scripts`, `bun run` without additional args:
```bash
# This command
bun run
# Prints this
hello-create-react-app scripts:
bun run start
react-scripts start
bun run build
react-scripts build
bun run test
react-scripts test
bun run eject
react-scripts eject
4 scripts
```
`bun run` automatically loads environment variables from `.env` into the shell/task. `.env` files are loaded with the same priority as the rest of Bun, so that means:
1. `.env.local` is first
2. if (`$NODE_ENV` === `"production"`) `.env.production` else `.env.development`
3. `.env`
If something is unexpected there, you can run `bun run env` to get a list of environment variables.
The default shell it uses is `bash`, but if that's not found, it tries `sh` and if still not found, it tries `zsh`. This is not configurable right now, but if you care file an issue.
`bun run` automatically adds any parent `node_modules/.bin` to `$PATH` and if no scripts match, it will load that binary instead. That means you can run executables from packages too.
```bash
# If you use Relay
bun run relay-compiler
# You can also do this, but:
# - It will only lookup packages in `node_modules/.bin` instead of `$PATH`
# - It will start Bun's dev server if the script name doesn't exist (`bun` starts the dev server by default)
bun relay-compiler
```
To pass additional flags through to the task or executable, there are two ways:
```bash
# Explicit: include "--" and anything after will be added. This is the recommended way because it is more reliable.
bun run relay-compiler -- -help
# Implicit: if you do not include "--", anything *after* the script name will be passed through
# Bun flags are parsed first, which means e.g. `bun run relay-compiler --help` will print Bun's help instead of relay-compiler's help.
bun run relay-compiler --schema foo.graphql
```
`bun run` supports lifecycle hooks like `post${task}` and `pre{task}`. If they exist, they will run matching the behavior of npm clients. If the `pre${task}` fails, the next task will not be run. There is currently no flag to skip these lifecycle tasks if they exist, if you want that file an issue.
### `bun create`
`bun create` is a fast way to create a new project from a template.
At the time of writing, `bun create react app` runs ~11x faster on my local computer than `yarn create react-app app`. `bun create` currently does no caching (though your npm client does)
#### Usage
Create a new Next.js project:
```bash
bun create next ./app
```
Create a new React project:
```bash
bun create react ./app
```
Create from a GitHub repo:
```bash
bun create ahfarmer/calculator ./app
```
To see a list of examples, run:
```bash
bun create
```
Format:
```bash
bun create github-user/repo-name destination
bun create local-example-or-remote-example destination
bun create /absolute/path/to-template-folder destination
bun create https://github.com/github-user/repo-name destination
bun create github.com/github-user/repo-name destination
```
Note: you don't need `bun create` to use Bun. You don't need any configuration at all. This command exists to make it a little easier.
##### Local templates
If you have your own boilerplate you prefer using, copy it into `$HOME/.bun-create/my-boilerplate-name`.
Before checking Bun's examples folder, `bun create` checks for a local folder matching the input in:
- `$BUN_CREATE_DIR/`
- `$HOME/.bun-create/`
- `$(pwd)/.bun-create/`
If a folder exists in any of those folders with the input, bun will use that instead of a remote template.
To create a local template, run:
```bash
mkdir -p $HOME/.bun-create/new-template-name
echo '{"name":"new-template-name"}' > $HOME/.bun-create/new-template-name/package.json
```
This lets you run:
```bash
bun create new-template-name ./app
```
Now your new template should appear when you run:
```bash
bun create
```
Warning: unlike with remote templates, **bun will delete the entire destination folder if it already exists.**
##### Flags
| Flag | Description |
| ------------ | -------------------------------------- |
| --npm | Use `npm` for tasks & install |
| --yarn | Use `yarn` for tasks & install |
| --pnpm | Use `pnpm` for tasks & install |
| --force | Overwrite existing files |
| --no-install | Skip installing `node_modules` & tasks |
| --no-git | Don't initialize a git repository |
| --open | Start & open in-browser after finish |
| Environment Variables | Description |
| --------------------- | ------------------------------------------------------------------------------------------------------ |
| GITHUB_API_DOMAIN | If you're using a GitHub enterprise or a proxy, you can change what the endpoint requests to GitHub go |
| GITHUB_API_TOKEN | This lets `bun create` work with private repositories or if you get rate-limited |
By default, `bun create` will cancel if there are existing files it would overwrite and its a remote template. You can pass `--force` to disable this behavior.
##### Publishing a new template
Clone this repository and a new folder in `examples/` with your new template. The `package.json` must have a `name` that starts with `@bun-examples/`. Do not worry about publishing it, that will happen automaticallly after the PR is merged.
Make sure to include a `.gitignore` that includes `node_modules` so that `node_modules` aren't checked in to git when people download the template.
##### Testing your new template
To test your new template, add it as a local template or pass the absolute path.
```bash
bun create /path/to/my/new/template destination-dir
```
Warning: **This will always delete everything in destination-dir**.
##### Config
The `bun-create` section of `package.json` is automatically removed from the `package.json` on disk. This lets you add create-only steps without waiting for an extra package to install.
There are currently two options:
- `postinstall`
- `preinstall`
They can be an array of strings or one string. An array of steps will be executed in order.
Here is an example:
```json
{
"name": "@bun-examples/next",
"version": "0.0.31",
"main": "index.js",
"dependencies": {
"next": "11.1.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-is": "^17.0.2"
},
"devDependencies": {
"@types/react": "^17.0.19",
"bun-framework-next": "^0.0.0-21",
"typescript": "^4.3.5"
},
"bun-create": {
"postinstall": ["bun bun --use next"]
}
}
```
By default, all commands run inside the environment exposed by the auto-detected npm client. This incurs a significant performance penalty, something like 150ms spent waiting for the npm client to start on each invocation.
Any command that starts with `"bun "` will be run without npm, relying on the first `bun` binary in `$PATH`.
##### How `bun create` works
When you run `bun create ${template} ${destination}`, here's what happens:
IF remote template
1. GET `registry.npmjs.org/@bun-examples/${template}/latest` and parse it
2. GET `registry.npmjs.org/@bun-examples/${template}/-/${template}-${latestVersion}.tgz`
3. Decompress & extract `${template}-${latestVersion}.tgz` into `${destination}`
- If there are files that would overwrite, warn and exit unless `--force` is passed
IF github repo
1. Download the tarball from GitHub's API
2. Decompress & extract into `${destination}`
- If there are files that would overwrite, warn and exit unless `--force` is passed
ELSE IF local template
1. Open local template folder
2. Delete destination directory recursively
3. Copy files recursively using the fastest system calls available (on macOS `fcopyfile` and Linux, `copy_file_range`). Do not copy or traverse into `node_modules` folder if exists (this alone makes it faster than `cp`)
4. Parse the `package.json` (again!), update `name` to be `${basename(destination)}`, remove the `bun-create` section from the `package.json` and save the updated `package.json` to disk.
- IF Next.js is detected, add `bun-framework-next` to the list of dependencies
- IF Create React App is detected, add the entry point in /src/index.{js,jsx,ts,tsx} to `public/index.html`
- IF Relay is detected, add `bun-macro-relay` so that Relay works
5. Auto-detect the npm client, preferring `pnpm`, `yarn` (v1), and lastly `npm`
6. Run any tasks defined in `"bun-create": { "preinstall" }` with the npm client
7. Run `${npmClient} install` unless `--no-install` is passed OR no dependencies are in package.json
8. Run any tasks defined in `"bun-create": { "preinstall" }` with the npm client
9. Run `git init; git add -A .; git commit -am "Initial Commit";`
- Rename `gitignore` to `.gitignore`. NPM automatically removes `.gitignore` files from appearing in packages.
- If there are dependencies, this runs in a separate thread concurrently while node_modules are being installed
- Using libgit2 if available was tested and performed 3x slower in microbenchmarks
10. Done
`misctools/publish-examples.js` publishes all examples to npm.
### `bun bun`
Run `bun bun ./path-to.js` to generate a `node_modules.bun` file containing all imported dependencies (recursively).
@@ -516,6 +843,12 @@ Is generated like this:
The implementation details of this module ID hash will vary between versions of Bun. The important part is the metadata contains the module IDs, the package paths, and the package hashes so it shouldn't really matter in practice if other tooling wants to make use of any of this.
### Environment variables
- `GOMAXPROCS`: For `bun bun`, this sets the maximum number of threads to use. If you're experiencing an issue with `bun bun`, try setting `GOMAXPROCS=1` to force bun to run single-threaded
- `DISABLE_BUN_ANALYTICS=1` this disables Bun's analytics. Bun records bundle timings (so we can answer with data, "is bun getting faster?") and feature usage (e.g. "are people actually using macros?"). The request body size is about 60 bytes, so it's not a lot of data
- `TMPDIR`: Before `bun bun` completes, it stores the new `.bun` in `$TMPDIR`. If unset, `TMPDIR` defaults to the platform-specific temporary directory (on Linux, `/tmp` and on macOS `/private/tmp`)
# Credits
- While written in Zig instead of Go, Bun's JS transpiler, CSS lexer, and node module resolver source code is based off of @evanw's esbuild project. @evanw did a fantastic job with esbuild.
@@ -545,6 +878,10 @@ Bun also statically links these libraries:
- `libicu`, which can be found here: https://github.com/unicode-org/icu/blob/main/icu4c/LICENSE
- [`picohttp`](https://github.com/h2o/picohttpparser), which is dual-licensed under the Perl License or the MIT License
- [`mimalloc`](https://github.com/microsoft/mimalloc), which is MIT licensed
- [`zlib-cloudflare`](https://github.com/cloudflare/zlib), which is zlib licensed
- [`s2n-tls`](https://github.com/aws/s2n-tls), which is MIT licensed
- [`libarchive`](https://github.com/libarchive/libarchive), which has [several licenses](https://github.com/libarchive/libarchive/blob/master/COPYING)
- [`libiconv`](https://www.gnu.org/software/libiconv/), which is LGPL2. It's a dependency of libarchive.
For compatibiltiy reasons, these NPM packages are embedded into Bun's binary and injected if imported.
@@ -576,13 +913,37 @@ Estimated: 30-90 minutes :(
## macOS
Install LLVM 12 and homebrew dependencies:
```bash
brew install llvm@12 coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed
```
Bun (& the version of Zig) need LLVM 12 and Clang 12 (clang is part of LLVM). Weird build & runtime errors will happen otherwise.
Make sure LLVM 12 is in your `$PATH`:
```bash
which clang-12
```
If it is not, you will have to run this to link it:
```bash
export PATH=$(brew --prefix llvm@12)/bin:$PATH
export LDFLAGS="$LDFLAGS -L$(brew --prefix llvm@12)/lib"
export CPPFLAGS="$CPPFLAGS -I$(brew --prefix llvm@12)/include"
```
On fish that looks like `fish_add_path (brew --prefix llvm@12)/bin`
Compile Zig:
```bash
git clone https://github.com/jarred-sumner/zig
cd zig
git checkout jarred/zig-sloppy-with-small-structs
cmake . -DCMAKE_PREFIX_PATH=$(brew --prefix llvm) -DZIG_STATIC_LLVM=ON -DCMAKE_BUILD_TYPE=Release && make -j 16
cmake . -DCMAKE_PREFIX_PATH=$(brew --prefix llvm@12) -DZIG_STATIC_LLVM=ON -DCMAKE_BUILD_TYPE=Release && make -j 16
```
You'll want to make sure `zig` is in `$PATH`. The `zig` binary wil be in the same folder as the newly-cloned `zig` repo. If you use fish, you can run `fish_add_path (pwd)`.
@@ -591,7 +952,13 @@ In `bun`:
```bash
git submodule update --init --recursive --progress --depth=1
make vendor
make vendor jsc identifier-cache dev
```
Verify it worked:
```bash
make test-dev-all
```
Note that `brew install zig` won't work. Bun uses a build of Zig with a couple patches.
@@ -633,8 +1000,29 @@ Compile Bun:
make vendor dev
```
Verify it worked:
```bash
make test-dev-all
```
Run bun:
```bash
packages/debug-bun-cli-darwin-x64/bin/bun-debug
```
## vscode-zig
You will want to install the fork of `vscode-zig` so you get a `Run test` and a `Debug test` button.
To do that:
```bash
git clone https://github.com/jarred-sumner/vscode-zig
cd vscode-zig
yarn install
yarn vsce package && code --install-extension ./zig-0.2.5.vsix
```
<a target="_blank" href="https://github.com/jarred-sumner/vscode-zig"><img src="https://pbs.twimg.com/media/FBZsKHlUcAYDzm5?format=jpg&name=large"></a>

View File

@@ -0,0 +1,5 @@
bun
next
src/*.mov
src/*.blob

View File

@@ -0,0 +1,77 @@
SLEEP_INTERVAL ?= 32
SCREEN_WIDTH ?= $(shell system_profiler -json SPDisplaysDataType 2>/dev/null | jq -r '.. | objects | select(.spdisplays_main) | ._spdisplays_pixels | split(" ")[0]')
SCREEN_HEIGHT ?= $(shell system_profiler -json SPDisplaysDataType 2>/dev/null | jq -r '.. | objects | select(.spdisplays_main) | ._spdisplays_pixels | split(" ")[2]')
PROJECT ?= bun
PACKAGE_NAME ?= bun-cli
RUN_COUNT ?= 128
ENDPOINT ?= /
ifeq ($(PROJECT),bun)
PACKAGE_NAME := bun-cli
endif
ifeq ($(PROJECT),next)
PACKAGE_NAME := next
endif
generate:
@killall -9 bun next node || echo ""
PROJECT=$(PROJECT) SCREEN_WIDTH=$(SCREEN_WIDTH) SCREEN_HEIGHT=$(SCREEN_HEIGHT) ENDPOINT=$(ENDPOINT) node browser.js
generate-css-in-js:
@killall -9 bun next node || echo ""
PROJECT=$(PROJECT) SCREEN_WIDTH=$(SCREEN_WIDTH) SCREEN_HEIGHT=$(SCREEN_HEIGHT) ENDPOINT=/css-in-js node browser.js
loop:
cp src/colors.css.0 src/colors.css
sleep 3
osascript -e 'tell application "System Events" to tell process "Chromium"' \
-e 'set frontmost to true' \
-e 'if windows is not {} then perform action "AXRaise" of item 1 of windows' \
-e 'end tell'
sleep 0.5
cd src; zig run -Drelease-fast ../color-looper.zig -- ./colors.css:0 $(SLEEP_INTERVAL)
cp src/colors.css.blob $(PROJECT)/colors.css.blob
loop-emotion:
cp src/css-in-js-styles.0 src/css-in-js-styles.tsx
sleep 3
osascript -e 'tell application "System Events" to tell process "Chromium"' \
-e 'set frontmost to true' \
-e 'if windows is not {} then perform action "AXRaise" of item 1 of windows' \
-e 'end tell'
sleep 0.5
cd src; zig run -Drelease-fast ../color-looper.emotion.zig -- ./css-in-js-styles.tsx:0 $(SLEEP_INTERVAL)
cp src/css-in-js-styles.tsx.blob $(PROJECT)/css-in-js-styles.blob
process_video:
rm -rf $(FRAMES_DIR); mkdir -p $(FRAMES_DIR); ffmpeg -i src/colors.css.mov -vf fps=120,format=gray $(FRAMES_DIR)/%d.tif
FRAMES_DIR ?= $(shell mkdir -p ./$(PROJECT)/frames; realpath ./$(PROJECT)/frames)
TIF_FILES := $(wildcard $(FRAMES_DIR)/*.tif)
TXT_FILES := $(wildcard $(FRAMES_DIR)/*.txt)
OBJ_FILES := $(patsubst $(SRC_DIR)/%.tif,$(OBJ_DIR)/%.txt,$(TIF_FILES))
TRIM_FILES := $(patsubst $(SRC_DIR)/%.txt,$(OBJ_DIR)/%.trim,$(TXT_FILES))
frames: $(OBJ_FILES)
$(FRAMES_DIR)/%.txt: $(FRAMES_DIR)/%.tif
tesseract -l eng $< $@
trim: $(TRIM_FILES) cleanup print
$(FRAMES_DIR)/%.trim: $(FRAMES_DIR)/%.txt
(grep "Ran:" $< || echo "\n") >> $(PROJECT)/frames.all
cleanup:
sed 's/^Ran: *//' $(PROJECT)/frames.all | tr -d ' ' | sort | uniq > $(PROJECT)/frames.all.clean
print:
PACKAGE_NAME=$(PACKAGE_NAME) SLEEP_INTERVAL=$(SLEEP_INTERVAL) PROJECT=$(PROJECT) OUTFILE=timings/$(PACKAGE_NAME) node read-frames.js
print-emotion:
PACKAGE_NAME=$(PACKAGE_NAME) SLEEP_INTERVAL=$(SLEEP_INTERVAL) PROJECT=$(PROJECT) OUTFILE=timings/emotion_$(PACKAGE_NAME) node read-frames.js

View File

@@ -0,0 +1,62 @@
# CSS Stress Test
This benchmarks bundler performance for CSS hot reloading.
## Results
Bun is 14x faster than Next.js at hot reloading CSS.
```
Bun v0.0.34
Saving every 16ms
Frame time:
50th percentile: 22.2ms
75th percentile: 23.9ms
90th percentile: 25.3ms
95th percentile: 43.6ms
99th percentile: 49.1ms
Rendered frames: 922 / 1024 (90%)
```
```
Next.js v11.1.2
Saving every 16ms
Frame time:
50th percentile: 312ms
75th percentile: 337.6ms
90th percentile: 387.7ms
95th percentile: 446.9ms
99th percentile: 591.7ms
Rendered frames: 64 / 1024 (6%)
```
## How it works
It times pixels instead of builds. `color-looper.zig` writes color updates and the timestamp to a css file, while simultaneously screen recording a non-headless Chromium instance. After it finishes, it OCRs the video frames and verifies the scanned timestamps against the actual data. This data measures (1) how long each update took from saving to disk up to the pixels visible on the screen and (2) what % of frames were rendered.
The intent is to be as accurate as possible. Measuring times reported client-side is simpler, but lower accuracy since those times may not correspond to pixels on the screen and do not start from when the data was written to disk (at best, they measure when the filesystem watcher detected the update, but often not that either). `color-looper.zig` must run separately from `browser.js` or the results will be innaccurate.
It works like this:
1. `browser.js` loads either Bun or Next.js and a Chromium instance opened to the correct webpage
2. `color-looper.zig` updates [`./src/colors.css`](./src/colors.css) in a loop up to `1024` times (1024 is arbitrary), sleeping every `16`ms or `32`ms (a CLI arg you can pass it). The `var(--timestamp)` CSS variable contains the UTC timestamp with precision of milliseconds and one extra decimal point
3. `color-looper.zig` automatically records the screen via `screencapture` (builtin on macOS) and saves it, along with a `BigUint64Array` containing all the expected timestamps. When it's done, it writes to a designated file on disk which `browser.js` picks up as the signal to close the browser.
4. `ffmpeg` converts each frame into a black and white `.tif` file, which `tesseract` then OCRs
5. Various cleanup scripts extract the timestamp from each of those OCR'd frames into a single file
6. Using the OCR'd data, `./read-frames.js` calculates the 50th, 75th, 90th, 95th, and 99th percentile frame time, along with how many frames were skipped. Frame time is the metric here that matters here because that's how much time elapsed between each update. It includes the artificial sleep interval, so it will not be faster than the sleep interval.
The script `run.sh` runs all the commands necessary to do this work unattended. It takes awhile though. The slow part is OCR'ing all the frames.
To run this, you need:
- `zig`
- `bun-cli`
- `node`
- `tesseract`
- `screencapture` (macOS builtin)
- `ffmpeg`
- `puppeteer` (from the package.json)
You will need to run `bun bun --use next` first, with `next@11.1.2`. It will only run on macOS due to the dependencies on `screencapture`, how it detects screen resolution (so that Chromium is maximized), and how it auto-focuses Chromium (apple script)

View File

@@ -0,0 +1,118 @@
const puppeteer = require("puppeteer");
const http = require("http");
const path = require("path");
const url = require("url");
const fs = require("fs");
const child_process = require("child_process");
const serverURL = process.env.TEST_SERVER_URL || "http://localhost:8080";
if (process.env.PROJECT === "bun") {
const bunFlags = [`--origin=${serverURL}`].filter(Boolean);
const bunExec = process.env.BUN_BIN || "bun";
const bunProcess = child_process.spawn(bunExec, bunFlags, {
cwd: process.cwd(),
stdio: "ignore",
env: {
...process.env,
DISABLE_BUN_ANALYTICS: "1",
},
shell: false,
});
console.log("$", bunExec, bunFlags.join(" "));
const isDebug = bunExec.endsWith("-debug");
// bunProcess.stderr.pipe(process.stderr);
// bunProcess.stdout.pipe(process.stdout);
bunProcess.once("error", (err) => {
console.error("❌ bun error", err);
process.exit(1);
});
process.on("beforeExit", () => {
bunProcess?.kill(0);
});
} else if (process.env.PROJECT === "next") {
const bunProcess = child_process.spawn(
"./node_modules/.bin/next",
["--port", "8080"],
{
cwd: process.cwd(),
stdio: "ignore",
env: {
...process.env,
},
shell: false,
}
);
}
const delay = new Promise((resolve, reject) => {
const watcher = fs.watch(path.resolve(process.cwd(), "src/colors.css.blob"));
watcher.once("change", () => {
setTimeout(() => {
resolve();
}, 1000);
});
});
async function main() {
const browser = await puppeteer.launch({
headless: false,
waitForInitialPage: true,
args: [
`--window-size=${parseInt(process.env.SCREEN_WIDTH || "1024", 10) / 2},${
parseInt(process.env.SCREEN_HEIGHT || "1024", 10) / 2
}`,
],
defaultViewport: {
width: parseInt(process.env.SCREEN_WIDTH || "1024", 10) / 2,
height: parseInt(process.env.SCREEN_HEIGHT || "1024", 10) / 2,
},
});
const promises = [];
let allTestsPassed = true;
async function runPage(key) {
var page;
try {
console.log("Opening page");
page = await browser.newPage();
console.log(`Navigating to "http://localhost:8080/"`);
while (true) {
try {
await page.goto("http://localhost:8080/", { waitUntil: "load" });
break;
} catch (exception) {
if (!exception.toString().includes("ERR_CONNECTION_REFUSED")) break;
}
}
await page.bringToFront();
await delay;
// runner.stdout.pipe(process.stdout);
// runner.stderr.pipe(process.stderr);
var didResolve = false;
console.log(`Completed. Done.`);
} catch (error) {
console.error(error);
} finally {
await page.close();
await browser.close();
}
}
return runPage();
}
main().catch((error) =>
setTimeout(() => {
throw error;
})
);

View File

@@ -0,0 +1,11 @@
SLEEP_INTERVAL=16 PROJECT=bun node read-frames.js
bun
--------------------------------------------------
CSS HMR FRAME TIME
50th percentile: 22.2ms
75th percentile: 23.9ms
90th percentile: 25.3ms
95th percentile: 43.6ms
99th percentile: 49.1ms
Rendered frames: 922 / 1024 (90%)

View File

@@ -0,0 +1,11 @@
SLEEP_INTERVAL=24 PROJECT=bun node read-frames.js
bun
--------------------------------------------------
CSS HMR FRAME TIME
50th percentile: 33.4ms
75th percentile: 34.5ms
90th percentile: 35.8ms
95th percentile: 65.5ms
99th percentile: 87.9ms
Rendered frames: 937 / 1024 (92%)

View File

@@ -0,0 +1,11 @@
SLEEP_INTERVAL=32 PROJECT=bun node read-frames.js
bun
--------------------------------------------------
CSS HMR FRAME TIME
50th percentile: 40.7ms
75th percentile: 42.3ms
90th percentile: 43.5ms
95th percentile: 76.4ms
99th percentile: 118.8ms
Rendered frames: 958 / 1024 (94%)

View File

@@ -0,0 +1,11 @@
SLEEP_INTERVAL=8 PROJECT=bun node read-frames.js
bun
--------------------------------------------------
CSS HMR FRAME TIME
50th percentile: 20ms
75th percentile: 24.4ms
90th percentile: 41ms
95th percentile: 53.9ms
99th percentile: 90.4ms
Rendered frames: 475 / 1024 (46%)

View File

@@ -0,0 +1,218 @@
const std = @import("std");
pub const Counter = extern struct {
timestamp: usize,
percent: f64,
rotate: u32,
color_values: [8 * 3]u32,
};
const RUN_COUNT = 1024;
var counters: [RUN_COUNT]Counter = undefined;
pub const Blob = extern struct {
run_count: u32,
interval: u64,
};
pub var all_timestamps: [RUN_COUNT + 1]usize = undefined;
// usage:
// ./file-path:0 10
// 1 2 3
// 1. file path
// 2. Byte offset in file
// 3. ms update interval
var color_buf: [8096 + SIMULATE_LONG_FILE.len]u8 = undefined;
pub fn main() anyerror!void {
var allocator = std.heap.c_allocator;
var timer = try std.time.Timer.start();
var args = std.mem.span(try std.process.argsAlloc(allocator));
var basepath_with_colon: []u8 = args[args.len - 2];
var basepath: []u8 = "";
var position_str: []u8 = "";
if (std.mem.lastIndexOfScalar(u8, basepath_with_colon, ':')) |colon| {
basepath = basepath_with_colon[0..colon];
position_str = basepath_with_colon[colon + 1 ..];
}
var position = try std.fmt.parseInt(u32, position_str, 10);
const filepath = try std.fs.path.resolve(allocator, &.{basepath});
var file = try std.fs.openFileAbsolute(filepath, .{ .write = true });
var ms = @truncate(u64, (try std.fmt.parseInt(u128, args[args.len - 1], 10)) * std.time.ns_per_ms);
std.debug.assert(ms > 0);
// std.debug.assert(std.math.isFinite(position));
var prng = std.rand.DefaultPrng.init(0);
var stdout = std.io.getStdOut();
var log = stdout.writer();
var colors = std.mem.zeroes([4][3]u32);
var progress_bar: f64 = 0.0;
var destination_count: f64 = 18.0;
// Randomize initial colors
colors[0][0] = prng.random.int(u32);
colors[0][1] = prng.random.int(u32);
colors[0][2] = prng.random.int(u32);
colors[1][0] = prng.random.int(u32);
colors[1][1] = prng.random.int(u32);
colors[1][2] = prng.random.int(u32);
colors[2][0] = prng.random.int(u32);
colors[2][1] = prng.random.int(u32);
colors[2][2] = prng.random.int(u32);
colors[3][0] = prng.random.int(u32);
colors[3][1] = prng.random.int(u32);
colors[3][2] = prng.random.int(u32);
var rotate: u32 = 0;
var counter: usize = 0;
const video = std.fmt.allocPrint(allocator, "{s}.mov", .{filepath}) catch unreachable;
std.fs.deleteFileAbsolute(video) catch {};
var screen_recorder_argv = [_][]const u8{ "screencapture", "-v", video };
var recorder = try std.ChildProcess.init(&screen_recorder_argv, allocator);
recorder.stdin_behavior = .Pipe;
try recorder.spawn();
std.time.sleep(std.time.ns_per_s);
var wrote: []u8 = undefined;
while (counter < RUN_COUNT) {
colors[0][0] += 1;
colors[0][1] += 1;
colors[0][2] += 1;
colors[1][0] += 1;
colors[1][1] += 1;
colors[1][2] += 1;
colors[2][0] += 1;
colors[2][1] += 1;
colors[2][2] += 1;
colors[3][0] += 1;
colors[3][1] += 1;
colors[3][2] += 1;
rotate += 1;
const fmtd: []const u8 = comptime brk: {
break :brk (
\\
\\import {{ Global }} from "@emotion/react";
\\export function CSSInJSStyles() {{
\\ return (
\\ <Global
\\ styles={{`
\\:root {{
\\ --timestamp: "{d}";
\\ --interval: "{s}";
\\ --progress-bar: {d}%;
\\ --spinner-1-muted: rgb({d}, {d}, {d});
\\ --spinner-1-primary: rgb({d}, {d}, {d});
\\ --spinner-2-muted: rgb({d}, {d}, {d});
\\ --spinner-2-primary: rgb({d}, {d}, {d});
\\ --spinner-3-muted: rgb({d}, {d}, {d});
\\ --spinner-3-primary: rgb({d}, {d}, {d});
\\ --spinner-4-muted: rgb({d}, {d}, {d});
\\ --spinner-4-primary: rgb({d}, {d}, {d});
\\ --spinner-rotate: {d}deg;
\\}}
++ SIMULATE_LONG_FILE ++
\\ `}}
\\ />
\\ );
\\}}
\\
);
};
counters[counter].timestamp = @truncate(u64, @intCast(u128, std.time.nanoTimestamp()) / (std.time.ns_per_ms / 10));
counters[counter].rotate = rotate % 360;
counters[counter].percent = std.math.mod(f64, std.math.round(((progress_bar + 1.0) / destination_count) * 1000) / 1000, 100) catch 0;
counters[counter].color_values[0] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[0][0] + 1) % 256)) * 0.8));
counters[counter].color_values[1] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[0][1] + 1) % 256)) * 0.8));
counters[counter].color_values[2] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[0][2] + 1) % 256)) * 0.8));
counters[counter].color_values[3] = (colors[0][0] + 1) % 256;
counters[counter].color_values[4] = (colors[0][1] + 1) % 256;
counters[counter].color_values[5] = (colors[0][2] + 1) % 256;
counters[counter].color_values[6] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[1][0] + 1) % 256)) * 0.8));
counters[counter].color_values[7] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[1][1] + 1) % 256)) * 0.8));
counters[counter].color_values[8] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[1][2] + 1) % 256)) * 0.8));
counters[counter].color_values[9] = (colors[1][0] + 1) % 256;
counters[counter].color_values[10] = (colors[1][1] + 1) % 256;
counters[counter].color_values[11] = (colors[1][2] + 1) % 256;
counters[counter].color_values[12] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[2][0] + 1) % 256)) * 0.8));
counters[counter].color_values[13] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[2][1] + 1) % 256)) * 0.8));
counters[counter].color_values[14] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[2][2] + 1) % 256)) * 0.8));
counters[counter].color_values[15] = (colors[2][0] + 1) % 256;
counters[counter].color_values[16] = (colors[2][1] + 1) % 256;
counters[counter].color_values[17] = (colors[2][2] + 1) % 256;
counters[counter].color_values[18] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[3][0] + 1) % 256)) * 0.8));
counters[counter].color_values[19] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[3][1] + 1) % 256)) * 0.8));
counters[counter].color_values[20] = @floatToInt(u32, std.math.round(@intToFloat(f64, ((colors[3][2] + 1) % 256)) * 0.8));
counters[counter].color_values[21] = (colors[3][0] + 1) % 256;
counters[counter].color_values[22] = (colors[3][1] + 1) % 256;
counters[counter].color_values[23] = (colors[3][2] + 1) % 256;
file = try std.fs.createFileAbsolute(filepath, .{ .truncate = true });
wrote = try std.fmt.bufPrint(&color_buf, fmtd, .{
counters[counter].timestamp,
args[args.len - 1],
counters[counter].percent,
counters[counter].color_values[0],
counters[counter].color_values[1],
counters[counter].color_values[2],
counters[counter].color_values[3],
counters[counter].color_values[4],
counters[counter].color_values[5],
counters[counter].color_values[6],
counters[counter].color_values[7],
counters[counter].color_values[8],
counters[counter].color_values[9],
counters[counter].color_values[10],
counters[counter].color_values[11],
counters[counter].color_values[12],
counters[counter].color_values[13],
counters[counter].color_values[14],
counters[counter].color_values[15],
counters[counter].color_values[16],
counters[counter].color_values[17],
counters[counter].color_values[18],
counters[counter].color_values[19],
counters[counter].color_values[20],
counters[counter].color_values[21],
counters[counter].color_values[22],
counters[counter].color_values[23],
counters[counter].rotate,
});
progress_bar += 1.0;
_ = try file.writeAll(wrote);
try log.print("[{d}] \"{s}\":{d}\n", .{
std.time.nanoTimestamp(),
filepath,
position,
});
counter += 1;
// If we don't close the file, Parcel seems to never recognize it
file.close();
std.time.sleep(ms);
}
try recorder.stdin.?.writeAll(&[_]u8{ 3, ';' });
_ = try recorder.wait();
all_timestamps[0] = wrote.len;
for (counters) |count, i| {
all_timestamps[i + 1] = count.timestamp;
}
std.time.sleep(std.time.ns_per_s);
var blob_file = try std.fs.createFileAbsolute(std.fmt.allocPrint(std.heap.c_allocator, "{s}.blob", .{filepath}) catch unreachable, .{ .truncate = true });
try blob_file.writeAll(std.mem.asBytes(&all_timestamps));
blob_file.close();
}
const SIMULATE_LONG_FILE =
\\
;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,5 @@
module.exports = {
experimental: {
swcLoader: true,
},
};

View File

@@ -0,0 +1,11 @@
SLEEP_INTERVAL=16 PROJECT=next node read-frames.js
next
--------------------------------------------------
CSS HMR FRAME TIME
50th percentile: 312ms
75th percentile: 337.6ms
90th percentile: 387.7ms
95th percentile: 446.9ms
99th percentile: 591.7ms
Rendered frames: 64 / 1024 (6%)

View File

@@ -0,0 +1,11 @@
SLEEP_INTERVAL=24 PROJECT=next node read-frames.js
next
--------------------------------------------------
CSS HMR FRAME TIME
50th percentile: 310.1ms
75th percentile: 360.3ms
90th percentile: 461.6ms
95th percentile: 660.4ms
99th percentile: 1009.9ms
Rendered frames: 78 / 1024 (8%)

View File

@@ -0,0 +1,11 @@
SLEEP_INTERVAL=32 PROJECT=next node read-frames.js
next
--------------------------------------------------
CSS HMR FRAME TIME
50th percentile: 306.7ms
75th percentile: 324.7ms
90th percentile: 380ms
95th percentile: 483.6ms
99th percentile: 933.6ms
Rendered frames: 116 / 1024 (11%)

View File

@@ -0,0 +1,11 @@
SLEEP_INTERVAL=8 PROJECT=next node read-frames.js
next
--------------------------------------------------
CSS HMR FRAME TIME
50th percentile: 320.4ms
75th percentile: 368.8ms
90th percentile: 527.2ms
95th percentile: 532.4ms
99th percentile: 532.4ms
Rendered frames: 32 / 1024 (3%)

View File

@@ -3,13 +3,19 @@
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"@emotion/core": "^11.0.0",
"@emotion/css": "^11.1.3",
"@emotion/react": "^11.4.1",
"@vitejs/plugin-react-refresh": "^1.3.3",
"antd": "^4.16.1",
"bun-framework-next": "^0.0.0-21",
"left-pad": "^1.3.0",
"next": "^11.0.1",
"next": "canary",
"parcel": "2.0.0-beta.3",
"path-browserify": "^1.0.1",
"percentile": "^1.5.0",
"puppeteer": "^10.4.0",
"puppeteer-video-recorder": "^1.0.5",
"react": "^17.0.2",
"react-bootstrap": "^1.6.1",
"react-dom": "^17.0.2",
@@ -32,6 +38,7 @@
"devDependencies": {
"@microsoft/fetch-event-source": "^2.0.1",
"@snowpack/plugin-react-refresh": "^2.5.0",
"bun-cli": "^0.0.34",
"typescript": "^4.3.4"
}
}

View File

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

View File

@@ -0,0 +1,19 @@
import { CSSInJSStyles } from "src/css-in-js-styles";
import { Main } from "src/main";
export function CSSInJS() {
return (
<>
<CSSInJSStyles />
<Main
productName={
typeof location !== "undefined"
? decodeURIComponent(location.search.substring(1))
: ""
}
cssInJS="Emotion"
/>
</>
);
}
export default CSSInJS;

View File

@@ -0,0 +1,12 @@
import { Main } from "src/main";
export function IndexPage() {
return (
<Main
productName={
typeof location !== "undefined" ? location.search.substring(1) : ""
}
/>
);
}
export default IndexPage;

View File

@@ -0,0 +1,107 @@
const fs = require("fs");
const path = require("path");
const PROJECT = process.env.PROJECT || "bun";
const percentile = require("percentile");
const PACKAGE_NAME = process.env.PACKAGE_NAME;
const label = `${PACKAGE_NAME}@${
require(PACKAGE_NAME + "/package.json").version
}`;
const BASEFOLDER = path.resolve(PROJECT);
const OUTFILE = path.join(process.cwd(), process.env.OUTFILE);
const buf = fs.readFileSync(BASEFOLDER + "/colors.css.blob");
const VALID_TIMES = new BigUint64Array(buf.buffer).subarray(1);
const cssFileSize = new BigUint64Array(buf.buffer)[0];
const TOTAL_FRAMES = VALID_TIMES.length;
const timings = fs
.readFileSync(BASEFOLDER + "/frames.all.clean", "utf8")
.split("\n")
.map((a) => a.replace(/[Ran:'\.]?/gm, "").trim())
.filter((a) => parseInt(a, 10))
.filter((a) => a.length > 0 && VALID_TIMES.includes(BigInt(parseInt(a, 10))))
.map((num) => BigInt(num));
timings.sort();
const frameTimesCount = timings.length;
var frameTime = new Array(Math.floor(frameTimesCount / 2));
for (let i = 0; i < frameTime.length; i++) {
const i1 = i * 2;
const i2 = i * 2 + 1;
frameTime[i] = Math.max(Number(timings[i2] - timings[i1]), 0);
}
const report = {
label,
cssFileSize: Number(cssFileSize),
at: new Date().toISOString(),
sleep: process.env.SLEEP_INTERVAL,
package: {
name: PACKAGE_NAME,
version: require(PACKAGE_NAME + "/package.json").version,
},
timestamps: timings.map((a) => Number(a)),
frameTimes: frameTime,
percentileMs: {
50: percentile(50, frameTime) / 10,
75: percentile(75, frameTime) / 10,
90: percentile(90, frameTime) / 10,
95: percentile(95, frameTime) / 10,
99: percentile(99, frameTime) / 10,
},
};
fs.writeFileSync(
path.join(
path.dirname(OUTFILE),
path.basename(OUTFILE) +
"@" +
report.package.version +
"." +
process.env.SLEEP_INTERVAL +
"ms." +
`${process.platform}-${
process.arch === "arm64" ? "aarch64" : process.arch
}` +
".json"
),
JSON.stringify(report, null, 2)
);
console.log(
label + "\n",
"-".repeat(50) + "\n",
"CSS HMR FRAME TIME\n" + "\n",
"50th percentile:",
percentile(50, frameTime) / 10 + "ms",
"\n",
"75th percentile:",
percentile(75, frameTime) / 10 + "ms",
"\n",
"90th percentile:",
percentile(90, frameTime) / 10 + "ms",
"\n",
"95th percentile:",
percentile(95, frameTime) / 10 + "ms",
"\n",
"99th percentile:",
percentile(99, frameTime) / 10 + "ms",
"\n",
"Rendered frames:",
timings.length,
"/",
TOTAL_FRAMES,
"(" +
Math.round(
Math.max(Math.min(1.0, timings.length / TOTAL_FRAMES), 0) * 100
) +
"%)"
);

View File

@@ -0,0 +1,83 @@
#!/bin/bash
echo "Running next at 24ms"
PROJECT=next SLEEP_INTERVAL=24 make generate &
PROJECT=next SLEEP_INTERVAL=24 make loop
killall Chromium || echo "";
PROJECT=next SLEEP_INTERVAL=24 make process_video
PROJECT=next SLEEP_INTERVAL=24 make frames -j$(nproc)
PROJECT=next SLEEP_INTERVAL=24 make trim
cp src/colors.css.blob next/colors.css.blob
PROJECT=next SLEEP_INTERVAL=24 make print > "next.latest.24ms.txt"
echo "Running bun at 24ms"
PROJECT=bun SLEEP_INTERVAL=24 make generate &
PROJECT=bun SLEEP_INTERVAL=24 make loop
killall Chromium || echo "";
PROJECT=bun SLEEP_INTERVAL=24 make process_video
PROJECT=bun SLEEP_INTERVAL=24 make frames -j$(nproc)
PROJECT=bun SLEEP_INTERVAL=24 make trim
cp src/colors.css.blob bun/colors.css.blob
PROJECT=bun SLEEP_INTERVAL=24 make print > "bun.latest.24ms.txt"
echo "Running next at 16ms"
PROJECT=next SLEEP_INTERVAL=16 make generate &
PROJECT=next SLEEP_INTERVAL=16 make loop
killall Chromium || echo "";
PROJECT=next SLEEP_INTERVAL=16 make process_video
PROJECT=next SLEEP_INTERVAL=16 make frames -j$(nproc)
PROJECT=next SLEEP_INTERVAL=16 make trim
cp src/colors.css.blob next/colors.css.blob
PROJECT=next SLEEP_INTERVAL=16 make print > "next.latest.16ms.txt"
echo "Running bun at 16ms"
PROJECT=bun SLEEP_INTERVAL=16 make generate &
PROJECT=bun SLEEP_INTERVAL=16 make loop
killall Chromium || echo "";
PROJECT=bun SLEEP_INTERVAL=16 make process_video
PROJECT=bun SLEEP_INTERVAL=16 make frames -j$(nproc)
PROJECT=bun SLEEP_INTERVAL=16 make trim
cp src/colors.css.blob bun/colors.css.blob
PROJECT=bun SLEEP_INTERVAL=16 make print > "bun.latest.16ms.txt"
echo "Running bun at 8ms"
PROJECT=bun SLEEP_INTERVAL=8 make generate &
PROJECT=bun SLEEP_INTERVAL=8 make loop
killall Chromium || echo "";
PROJECT=bun SLEEP_INTERVAL=8 make process_video
PROJECT=bun SLEEP_INTERVAL=8 make frames -j$(nproc)
PROJECT=bun SLEEP_INTERVAL=8 make trim
cp src/colors.css.blob bun/colors.css.blob
PROJECT=bun SLEEP_INTERVAL=8 make print > "bun.latest.8ms.txt"
echo "Running next at 8ms"
PROJECT=next SLEEP_INTERVAL=8 make generate &
PROJECT=next SLEEP_INTERVAL=8 make loop
killall Chromium || echo "";
PROJECT=next SLEEP_INTERVAL=8 make process_video
PROJECT=next SLEEP_INTERVAL=8 make frames -j$(nproc)
PROJECT=next SLEEP_INTERVAL=8 make trim
cp src/colors.css.blob next/colors.css.blob
PROJECT=next SLEEP_INTERVAL=8 make print > "next.latest.8ms.txt"
echo "Running bun at 32ms"
PROJECT=bun SLEEP_INTERVAL=32 make generate &
PROJECT=bun SLEEP_INTERVAL=32 make loop
killall Chromium || echo "";
PROJECT=bun SLEEP_INTERVAL=32 make process_video
PROJECT=bun SLEEP_INTERVAL=32 make frames -j$(nproc)
PROJECT=bun SLEEP_INTERVAL=32 make trim
cp src/colors.css.blob bun/colors.css.blob
PROJECT=bun SLEEP_INTERVAL=32 make print > "bun.latest.32ms.txt"
echo "Running next at 32ms"
PROJECT=next SLEEP_INTERVAL=32 make generate &
PROJECT=next SLEEP_INTERVAL=32 make loop
killall Chromium || echo "";
PROJECT=next SLEEP_INTERVAL=32 make process_video
PROJECT=next SLEEP_INTERVAL=32 make frames -j$(nproc)
PROJECT=next SLEEP_INTERVAL=32 make trim
cp src/colors.css.blob next/colors.css.blob
PROJECT=next SLEEP_INTERVAL=32 make print > "next.latest.32ms.txt"

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,14 @@
:root {
--timestamp: "0";
--interval: "8";
--progress-bar: 0%;
--spinner-1-muted: rgb(179, 6, 202);
--spinner-1-primary: rgb(224, 8, 253);
--spinner-2-muted: rgb(22, 188, 124);
--spinner-2-primary: rgb(27, 235, 155);
--spinner-3-muted: rgb(89, 72, 0);
--spinner-3-primary: rgb(111, 90, 0);
--spinner-4-muted: rgb(18, 84, 202);
--spinner-4-primary: rgb(23, 105, 253);
--spinner-rotate: 304deg;
}

View File

@@ -0,0 +1,23 @@
import { Global } from "@emotion/react";
export function CSSInJSStyles() {
return (
<Global
styles={`
:root {
--timestamp: "0";
--interval: "8";
--progress-bar: 11.83299999999997%;
--spinner-1-muted: rgb(142, 6, 182);
--spinner-1-primary: rgb(177, 8, 227);
--spinner-2-muted: rgb(110, 148, 190);
--spinner-2-primary: rgb(138, 185, 238);
--spinner-3-muted: rgb(75, 45, 64);
--spinner-3-primary: rgb(94, 56, 80);
--spinner-4-muted: rgb(155, 129, 108);
--spinner-4-primary: rgb(194, 161, 135);
--spinner-rotate: 213deg;
}
`}
/>
);
}

View File

@@ -0,0 +1,23 @@
import { Global } from "@emotion/react";
export function CSSInJSStyles() {
return (
<Global
styles={`
:root {
--timestamp: "16336621338281";
--interval: "16";
--progress-bar: 56.889%;
--spinner-1-muted: rgb(179, 6, 202);
--spinner-1-primary: rgb(224, 8, 253);
--spinner-2-muted: rgb(22, 188, 124);
--spinner-2-primary: rgb(27, 235, 155);
--spinner-3-muted: rgb(89, 72, 0);
--spinner-3-primary: rgb(111, 90, 0);
--spinner-4-muted: rgb(18, 84, 202);
--spinner-4-primary: rgb(23, 105, 253);
--spinner-rotate: 304deg;
} `}
/>
);
}

View File

@@ -112,15 +112,26 @@ section {
flex-direction: column;
}
.ran,
.timer {
font-weight: normal;
white-space: nowrap;
font-weight: bold;
-webkit-text-stroke: white;
-webkit-text-stroke-width: 2px;
color: white;
font-size: 100px;
}
.ran {
}
.ProgressBar-container {
width: 100%;
display: block;
position: relative;
border: 1px solid var(--color-brand-muted);
border-left: 10px solid red;
border-right: 10px solid pink;
border-top: 10px solid yellow;
border-bottom: 10px solid orange;
border-radius: 4px;
height: 92px;

View File

@@ -7,7 +7,7 @@ const Base = ({}) => {
typeof location !== "undefined"
? decodeURIComponent(location.search.substring(1))
: null;
return <Main productName={name || "asdasdasdasdasdasd"} />;
return <Main productName={name} />;
};
function startReact() {

View File

@@ -1,17 +1,17 @@
export const Main = ({ productName }) => {
export const Main = ({ productName, cssInJS }) => {
return (
<>
<header>
<div className="Title">CSS HMR Stress Test!</div>
<p className="Description">
This page visually tests how quickly a bundler can update CSS over Hot
Module Reloading.
This page visually tests how quickly a bundler can update{" "}
{cssInJS ? "CSS-in-JS" : "CSS"} over Hot Module Reloading.
</p>
</header>
<main className="main">
<section className="ProgressSection">
<p className="Subtitle">
<span className="Subtitle-part">
<span className="Subtitle-part ran">
Ran: <span className="timer"></span>
</span>
</p>
@@ -55,10 +55,7 @@ export const Main = ({ productName }) => {
<div className="Bundler-container">
<div className="Bundler">{productName}</div>
<div className="Bundler-updateRate">
{/* This should loose all the styles
<span className="highlight">
<span className="interval"></span>ms
</span> */}
{cssInJS ? "CSS-in-JS framework: " + cssInJS : ""}
</div>
</div>
</footer>

View File

@@ -0,0 +1,292 @@
{
"label": "bun-cli@0.0.34",
"at": "2021-10-08T01:01:18.129Z",
"sleep": "32",
"package": {
"name": "bun-cli",
"version": "0.0.34"
},
"timestamps": [
16336202536562, 16336202536908, 16336202537294, 16336202537705,
16336202538114, 16336202538534, 16336202538941, 16336202539323,
16336202539742, 16336202540159, 16336202540877, 16336202541310,
16336202541749, 16336202542159, 16336202542565, 16336202542996,
16336202543333, 16336202543761, 16336202544159, 16336202544534,
16336202544944, 16336202545345, 16336202545744, 16336202546159,
16336202546573, 16336202546986, 16336202547399, 16336202547781,
16336202548202, 16336202548564, 16336202548949, 16336202549329,
16336202549762, 16336202550168, 16336202550534, 16336202550887,
16336202551305, 16336202551659, 16336202552060, 16336202552449,
16336202552854, 16336202553270, 16336202553609, 16336202554034,
16336202554437, 16336202554783, 16336202555191, 16336202555623,
16336202556034, 16336202556449, 16336202556890, 16336202557283,
16336202557669, 16336202558084, 16336202558496, 16336202558863,
16336202559271, 16336202559659, 16336202560051, 16336202560452,
16336202560873, 16336202561290, 16336202561659, 16336202562035,
16336202562440, 16336202562862, 16336202563284, 16336202563659,
16336202564034, 16336202564444, 16336202564853, 16336202565245,
16336202565659, 16336202566034, 16336202566455, 16336202566873,
16336202567284, 16336202567659, 16336202568034, 16336202568386,
16336202568790, 16336202569204, 16336202569620, 16336202570384,
16336202570768, 16336202571188, 16336202571551, 16336202572327,
16336202572717, 16336202573116, 16336202573541, 16336202573959,
16336202574319, 16336202574682, 16336202575040, 16336202575375,
16336202577001, 16336202577342, 16336202577680, 16336202578066,
16336202578451, 16336202579166, 16336202579534, 16336202579960,
16336202580370, 16336202580789, 16336202581159, 16336202581576,
16336202581949, 16336202582294, 16336202583087, 16336202583496,
16336202583858, 16336202584203, 16336202584606, 16336202585034,
16336202585386, 16336202585788, 16336202586211, 16336202586604,
16336202587034, 16336202587459, 16336202587869, 16336202588295,
16336202588668, 16336202589092, 16336202589452, 16336202589831,
16336202590197, 16336202590608, 16336202591034, 16336202591460,
16336202591880, 16336202592295, 16336202592727, 16336202593172,
16336202593567, 16336202593994, 16336202594397, 16336202594795,
16336202595224, 16336202595659, 16336202596058, 16336202596463,
16336202596890, 16336202597322, 16336202597732, 16336202598159,
16336202598534, 16336202598951, 16336202599365, 16336202599785,
16336202600159, 16336202600593, 16336202601005, 16336202601402,
16336202601807, 16336202602214, 16336202602556, 16336202602895,
16336202603307, 16336202603661, 16336202604075, 16336202604491,
16336202604853, 16336202605268, 16336202605670, 16336202606034,
16336202606393, 16336202606748, 16336202607170, 16336202607568,
16336202607982, 16336202608411, 16336202608836, 16336202609197,
16336202609596, 16336202609965, 16336202610333, 16336202610740,
16336202611159, 16336202611573, 16336202611975, 16336202612317,
16336202612691, 16336202613060, 16336202613474, 16336202613903,
16336202614341, 16336202614707, 16336202615094, 16336202615534,
16336202615883, 16336202616296, 16336202616671, 16336202617034,
16336202617391, 16336202617727, 16336202618159, 16336202618534,
16336202618937, 16336202619360, 16336202619770, 16336202620179,
16336202620716, 16336202621143, 16336202621534, 16336202622303,
16336202622659, 16336202623085, 16336202623498, 16336202623850,
16336202624220, 16336202624606, 16336202625034, 16336202625387,
16336202625805, 16336202626210, 16336202626599, 16336202627034,
16336202627386, 16336202627748, 16336202628159, 16336202628534,
16336202628954, 16336202629373, 16336202629809, 16336202630197,
16336202630535, 16336202630916, 16336202631290, 16336202631666,
16336202632034, 16336202632369, 16336202633152, 16336202633534,
16336202633883, 16336202634309, 16336202634717, 16336202635106,
16336202635871, 16336202636253, 16336202636671, 16336202637070,
16336202637434, 16336202637798, 16336202638184, 16336202638539,
16336202638938, 16336202639307, 16336202639666, 16336202640095,
16336202640534, 16336202640962, 16336202641307, 16336202641659,
16336202642087, 16336202642521, 16336202642886, 16336202643309,
16336202643662, 16336202644067, 16336202644491, 16336202644853,
16336202645226, 16336202645659, 16336202646074, 16336202646497,
16336202646890, 16336202647311, 16336202647749, 16336202648169,
16336202648976, 16336202649378, 16336202649810, 16336202650165,
16336202650534, 16336202650875, 16336202651250, 16336202651659,
16336202652093, 16336202652516, 16336202652921, 16336202653332,
16336202653722, 16336202654142, 16336202654534, 16336202654880,
16336202655221, 16336202655562, 16336202655997, 16336202656378,
16336202656811, 16336202657161, 16336202657588, 16336202657944,
16336202658360, 16336202658708, 16336202659089, 16336202659428,
16336202659849, 16336202660273, 16336202660685, 16336202661105,
16336202661534, 16336202661873, 16336202662228, 16336202662658,
16336202663438, 16336202663843, 16336202664219, 16336202664646,
16336202665050, 16336202665487, 16336202665838, 16336202666211,
16336202666573, 16336202666927, 16336202667334, 16336202667746,
16336202668158, 16336202668563, 16336202668980, 16336202669406,
16336202669753, 16336202670192, 16336202670554, 16336202670903,
16336202671324, 16336202671734, 16336202672159, 16336202672573,
16336202672982, 16336202673346, 16336202673680, 16336202674087,
16336202674499, 16336202674909, 16336202675260, 16336202676110,
16336202676535, 16336202676913, 16336202677312, 16336202677658,
16336202678044, 16336202678413, 16336202678793, 16336202679208,
16336202679604, 16336202680034, 16336202680385, 16336202680799,
16336202681213, 16336202681595, 16336202682004, 16336202682346,
16336202682726, 16336202683158, 16336202683586, 16336202683990,
16336202684323, 16336202684742, 16336202685175, 16336202685578,
16336202685979, 16336202686805, 16336202687206, 16336202687614,
16336202688038, 16336202688473, 16336202688848, 16336202689221,
16336202689559, 16336202689971, 16336202690368, 16336202690776,
16336202691159, 16336202691585, 16336202692010, 16336202692373,
16336202692780, 16336202693179, 16336202693580, 16336202693991,
16336202694324, 16336202694727, 16336202695159, 16336202695588,
16336202695991, 16336202696335, 16336202697160, 16336202697542,
16336202697929, 16336202698323, 16336202698674, 16336202699060,
16336202699492, 16336202699835, 16336202700238, 16336202700658,
16336202701059, 16336202701420, 16336202701815, 16336202702229,
16336202702659, 16336202703857, 16336202704256, 16336202704659,
16336202705497, 16336202706309, 16336202706660, 16336202707085,
16336202707511, 16336202707866, 16336202708210, 16336202708552,
16336202708925, 16336202709287, 16336202709670, 16336202710045,
16336202710402, 16336202710802, 16336202711167, 16336202711533,
16336202712249, 16336202712660, 16336202713088, 16336202713519,
16336202713936, 16336202714355, 16336202714740, 16336202715160,
16336202715533, 16336202715878, 16336202716290, 16336202716708,
16336202717102, 16336202718290, 16336202718699, 16336202719052,
16336202719388, 16336202719808, 16336202720225, 16336202720659,
16336202721052, 16336202721414, 16336202721828, 16336202722925,
16336202723664, 16336202724063, 16336202724405, 16336202726003,
16336202726736, 16336202727158, 16336202727543, 16336202727930,
16336202728336, 16336202728703, 16336202729061, 16336202729483,
16336202729832, 16336202730222, 16336202730659, 16336202731084,
16336202731500, 16336202731911, 16336202732326, 16336202733158,
16336202733585, 16336202734001, 16336202734691, 16336202735042,
16336202735442, 16336202735863, 16336202736255, 16336202736671,
16336202737043, 16336202737884, 16336202738671, 16336202739110,
16336202739533, 16336202739886, 16336202740283, 16336202740706,
16336202741143, 16336202741534, 16336202741942, 16336202742352,
16336202742697, 16336202743103, 16336202743940, 16336202745172,
16336202745542, 16336202745937, 16336202746339, 16336202746758,
16336202747531, 16336202747877, 16336202748232, 16336202748658,
16336202749055, 16336202749468, 16336202749859, 16336202750416,
16336202750839, 16336202751178, 16336202751572, 16336202752002,
16336202752419, 16336202753269, 16336202753678, 16336202754086,
16336202754432, 16336202754835, 16336202755260, 16336202755683,
16336202756059, 16336202756402, 16336202756837, 16336202758084,
16336202758507, 16336202758879, 16336202759270, 16336202759674,
16336202760044, 16336202760400, 16336202760801, 16336202761659,
16336202762053, 16336202762397, 16336202763199, 16336202763547,
16336202763948, 16336202764714, 16336202765113, 16336202765947,
16336202766329, 16336202766664, 16336202767085, 16336202768233,
16336202769056, 16336202769758, 16336202770178, 16336202770585,
16336202770929, 16336202771325, 16336202772158, 16336202772594,
16336202773033, 16336202773403, 16336202773801, 16336202774179,
16336202774555, 16336202774989, 16336202775393, 16336202775809,
16336202776209, 16336202776618, 16336202777033, 16336202777421,
16336202777845, 16336202778246, 16336202778658, 16336202779055,
16336202779411, 16336202779761, 16336202780175, 16336202780594,
16336202781002, 16336202781848, 16336202782658, 16336202783033,
16336202783857, 16336202784211, 16336202784557, 16336202784972,
16336202785377, 16336202785810, 16336202786172, 16336202786934,
16336202787343, 16336202787765, 16336202788201, 16336202788563,
16336202788970, 16336202789329, 16336202789672, 16336202790055,
16336202790456, 16336202790802, 16336202791580, 16336202791920,
16336202792326, 16336202793158, 16336202793953, 16336202794368,
16336202795187, 16336202795622, 16336202796033, 16336202796393,
16336202796777, 16336202797173, 16336202797540, 16336202797975,
16336202798317, 16336202798739, 16336202799158, 16336202799567,
16336202799966, 16336202800378, 16336202800803, 16336202801232,
16336202801658, 16336202802033, 16336202802374, 16336202802759,
16336202803158, 16336202803533, 16336202803947, 16336202804354,
16336202804729, 16336202805158, 16336202805534, 16336202805950,
16336202806390, 16336202806805, 16336202807219, 16336202807643,
16336202808033, 16336202808377, 16336202808790, 16336202809211,
16336202809560, 16336202809920, 16336202810355, 16336202810758,
16336202811187, 16336202811596, 16336202811943, 16336202812348,
16336202812710, 16336202813060, 16336202813398, 16336202813791,
16336202814158, 16336202814533, 16336202814878, 16336202815246,
16336202815658, 16336202816079, 16336202816851, 16336202817202,
16336202817540, 16336202817905, 16336202818244, 16336202818663,
16336202819068, 16336202819418, 16336202819777, 16336202820193,
16336202820599, 16336202821033, 16336202821395, 16336202821745,
16336202822158, 16336202822590, 16336202822996, 16336202823396,
16336202823804, 16336202824210, 16336202824581, 16336202824991,
16336202825406, 16336202825806, 16336202826210, 16336202826598,
16336202827033, 16336202827446, 16336202827839, 16336202828201,
16336202828577, 16336202828968, 16336202829362, 16336202829709,
16336202830096, 16336202830533, 16336202830917, 16336202831290,
16336202831699, 16336202832035, 16336202832406, 16336202832804,
16336202833200, 16336202833604, 16336202834033, 16336202834386,
16336202834759, 16336202835190, 16336202835621, 16336202836033,
16336202836405, 16336202837191, 16336202837613, 16336202838033,
16336202838374, 16336202838798, 16336202839200, 16336202839603,
16336202840034, 16336202840389, 16336202840783, 16336202841200,
16336202841617, 16336202842034, 16336202842390, 16336202842737,
16336202843158, 16336202843585, 16336202843923, 16336202844313,
16336202844724, 16336202845158, 16336202845576, 16336202845939,
16336202846368, 16336202846728, 16336202847158, 16336202847568,
16336202847911, 16336202848291, 16336202848695, 16336202849103,
16336202849533, 16336202849942, 16336202850368, 16336202850747,
16336202851158, 16336202851549, 16336202851978, 16336202852383,
16336202852725, 16336202853158, 16336202853554, 16336202853961,
16336202854308, 16336202854704, 16336202855060, 16336202855418,
16336202855776, 16336202856203, 16336202856617, 16336202857036,
16336202857455, 16336202857884, 16336202858262, 16336202858658,
16336202859071, 16336202859847, 16336202860237, 16336202860658,
16336202861037, 16336202861452, 16336202861869, 16336202862218,
16336202862590, 16336202863001, 16336202863422, 16336202863857,
16336202864219, 16336202864658, 16336202865047, 16336202865404,
16336202865789, 16336202866210, 16336202866624, 16336202867033,
16336202867380, 16336202867797, 16336202868227, 16336202868658,
16336202869083, 16336202869500, 16336202869906, 16336202870246,
16336202870658, 16336202871086, 16336202871441, 16336202871820,
16336202872204, 16336202872546, 16336202872943, 16336202873380,
16336202873811, 16336202874213, 16336202874566, 16336202874918,
16336202875261, 16336202875655, 16336202876047, 16336202876771,
16336202877202, 16336202877612, 16336202878033, 16336202878412,
16336202878846, 16336202879241, 16336202879658, 16336202880072,
16336202880508, 16336202880901, 16336202881308, 16336202881725,
16336202882158, 16336202882579, 16336202882945, 16336202883286,
16336202883657, 16336202884048, 16336202884404, 16336202884752,
16336202885158, 16336202885533, 16336202885938, 16336202886364,
16336202886759, 16336202887175, 16336202887585, 16336202887929,
16336202888345, 16336202888743, 16336202889157, 16336202889570,
16336202889970, 16336202890382, 16336202890761, 16336202891187,
16336202891600, 16336202892033, 16336202892454, 16336202892794,
16336202893178, 16336202893533, 16336202893903, 16336202894264,
16336202894668, 16336202895049, 16336202895400, 16336202895774,
16336202896157, 16336202896537, 16336202896883, 16336202897232,
16336202897658, 16336202898065, 16336202898493, 16336202898884,
16336202899251, 16336202899673, 16336202900047, 16336202900467,
16336202900883, 16336202901300, 16336202901676, 16336202902068,
16336202902479, 16336202902902, 16336202903260, 16336202903675,
16336202904094, 16336202904476, 16336202904824, 16336202905158,
16336202905533, 16336202905934, 16336202906289, 16336202906717,
16336202907158, 16336202907547, 16336202907904, 16336202908294,
16336202908717, 16336202909157, 16336202909582, 16336202910005,
16336202910399, 16336202910800, 16336202911220, 16336202911657,
16336202912064, 16336202912405, 16336202912779, 16336202913158,
16336202913553, 16336202913966, 16336202914376, 16336202914719,
16336202915091, 16336202915515, 16336202915887, 16336202916293,
16336202916649, 16336202917438, 16336202917869, 16336202918221,
16336202919053, 16336202919425, 16336202919833, 16336202920234,
16336202920658, 16336202921033, 16336202921433, 16336202921801,
16336202922161, 16336202922589, 16336202923017, 16336202923418,
16336202923804, 16336202924199, 16336202924593, 16336202925033,
16336202925449, 16336202925818, 16336202926223, 16336202926662,
16336202927431, 16336202927812, 16336202928227, 16336202928658,
16336202929061, 16336202929473, 16336202929891, 16336202930241,
16336202930657, 16336202931057, 16336202931396, 16336202931811,
16336202932225, 16336202932657, 16336202933058, 16336202933445,
16336202933790, 16336202934157, 16336202934562, 16336202934988,
16336202935391, 16336202935777, 16336202936160, 16336202936562,
16336202936986, 16336202937396, 16336202937751, 16336202938158,
16336202938578, 16336202938985, 16336202939396, 16336202939752,
16336202940157, 16336202940585
],
"frameTimes": [
346, 411, 420, 382, 417, 433, 410, 431, 428, 375, 401, 415, 413, 382, 362,
380, 406, 353, 354, 389, 416, 425, 346, 432, 415, 393, 415, 367, 388, 401,
417, 376, 422, 375, 410, 392, 375, 418, 375, 352, 414, 764, 420, 776, 399,
418, 363, 335, 341, 386, 715, 426, 419, 417, 345, 409, 345, 428, 402, 393,
425, 426, 424, 379, 411, 426, 415, 445, 427, 398, 435, 405, 432, 427, 417,
420, 434, 397, 407, 339, 354, 416, 415, 364, 355, 398, 429, 361, 369, 407,
414, 342, 369, 429, 366, 440, 413, 363, 336, 375, 423, 409, 427, 769, 426,
352, 386, 353, 405, 435, 362, 375, 419, 388, 381, 376, 335, 382, 426, 389,
382, 399, 364, 355, 369, 429, 428, 352, 434, 423, 405, 362, 433, 423, 421,
420, 402, 355, 341, 409, 423, 411, 420, 346, 341, 381, 350, 356, 348, 339,
424, 420, 339, 430, 405, 427, 437, 373, 354, 412, 405, 426, 439, 349, 410,
414, 364, 407, 410, 850, 378, 346, 369, 415, 430, 414, 382, 342, 432, 404,
419, 403, 826, 408, 435, 373, 412, 408, 426, 363, 399, 411, 403, 429, 344,
382, 394, 386, 343, 420, 361, 414, 1198, 403, 812, 425, 355, 342, 362, 375,
400, 366, 411, 431, 419, 420, 345, 418, 1188, 353, 420, 434, 362, 1097, 399,
1598, 422, 387, 367, 422, 390, 425, 411, 832, 416, 351, 421, 416, 841, 439,
353, 423, 391, 410, 406, 1232, 395, 419, 346, 426, 413, 557, 339, 430, 850,
408, 403, 423, 343, 1247, 372, 404, 356, 858, 344, 348, 766, 834, 335, 1148,
702, 407, 396, 436, 370, 378, 434, 416, 409, 388, 401, 397, 350, 419, 846,
375, 354, 415, 433, 762, 422, 362, 359, 383, 346, 340, 832, 415, 435, 360,
396, 435, 422, 409, 412, 429, 375, 385, 375, 407, 429, 416, 415, 424, 344,
421, 360, 403, 409, 405, 350, 393, 375, 368, 421, 351, 365, 419, 350, 416,
434, 350, 432, 400, 406, 410, 400, 388, 413, 362, 391, 347, 437, 373, 336,
398, 404, 353, 431, 412, 786, 420, 424, 403, 355, 417, 417, 347, 427, 390,
434, 363, 360, 410, 380, 408, 409, 379, 391, 405, 433, 407, 396, 358, 427,
419, 429, 396, 776, 421, 415, 349, 411, 435, 439, 357, 421, 409, 417, 431,
417, 340, 428, 379, 342, 437, 402, 352, 394, 724, 410, 379, 395, 414, 393,
417, 421, 341, 391, 348, 375, 426, 416, 344, 398, 413, 412, 426, 433, 340,
355, 361, 381, 374, 380, 349, 407, 391, 422, 420, 417, 392, 423, 415, 382,
334, 401, 428, 389, 390, 440, 423, 401, 437, 341, 379, 413, 343, 424, 406,
789, 352, 372, 401, 375, 368, 428, 401, 395, 440, 369, 439, 381, 431, 412,
350, 400, 415, 432, 387, 367, 426, 386, 402, 410, 407, 407, 356, 428
],
"percentileMs": {
"50": 40.7,
"75": 42.3,
"90": 43.5,
"95": 76.4,
"99": 118.8
}
}

View File

@@ -0,0 +1,15 @@
# Benchmarking hot module reloading
## Methodology
How do you benchmark hot module reloading? What do you call "done" and what do you call "start"?
The answer for "done" is certainly not compilation time. Compilation time is one step.
I think the answer should be different depending on the type of content loaded.
For CSS, the answer should be "when the updated stylesheet was drawn on the screen"
For JavaScript, the answer should be "when the rebuilt code completed execution such that any changes are applied"
For images & assets, the answer should be "when the updated asset finished loading"
The start time should be defined as "the timestamp the filesystem set as the write time". As in, the time the developer pressed save in their editor.

View File

@@ -1 +1 @@
32
45

274
build.zig
View File

@@ -7,11 +7,6 @@ pub fn addPicoHTTP(step: *std.build.LibExeObjStep, comptime with_obj: bool) void
.path = .{ .path = "src/deps/picohttp.zig" },
});
_ = step.addPackage(.{
.name = "iguanaTLS",
.path = .{ .path = "src/deps/iguanaTLS/src/main.zig" },
});
step.addIncludeDir("src/deps");
if (with_obj) {
@@ -39,7 +34,7 @@ pub fn build(b: *std.build.Builder) !void {
const cwd: []const u8 = b.pathFromRoot(".");
var exe: *std.build.LibExeObjStep = undefined;
var output_dir_buf = std.mem.zeroes([4096]u8);
var bin_label = if (mode == std.builtin.Mode.Debug) "packages/debug-bun-cli-" else "packages/bun-cli-";
var bin_label = if (mode == std.builtin.Mode.Debug) "packages/debug-bun-" else "packages/bun-";
var triplet_buf: [64]u8 = undefined;
var os_tagname = @tagName(target.getOs().tag);
@@ -65,7 +60,7 @@ pub fn build(b: *std.build.Builder) !void {
var triplet = triplet_buf[0 .. osname.len + cpuArchName.len + 1];
const output_dir_base = try std.fmt.bufPrint(&output_dir_buf, "{s}{s}/bin", .{ bin_label, triplet });
const output_dir_base = try std.fmt.bufPrint(&output_dir_buf, "{s}{s}", .{ bin_label, triplet });
const output_dir = b.pathFromRoot(output_dir_base);
const bun_executable_name = if (mode == std.builtin.Mode.Debug) "bun-debug" else "bun";
@@ -133,25 +128,26 @@ pub fn build(b: *std.build.Builder) !void {
exe.setOutputDir(output_dir);
var cwd_dir = std.fs.cwd();
if (std.builtin.is_test) {
var walker = cwd_dir.walk(std.heap.c_allocator) catch unreachable;
while (walker.next() catch unreachable) |entry| {
if (std.mem.endsWith(u8, entry.basename, "_test.zig")) {
std.debug.print("[test] Added {s}", .{entry.basename});
_ = b.addTest(entry.path);
}
}
}
const runtime_hash = std.hash.Wyhash.hash(0, @embedFile("./src/runtime.out.js"));
const runtime_version_file = std.fs.cwd().openFile("src/runtime.version", .{ .write = true }) catch unreachable;
runtime_version_file.writer().print("{x}", .{runtime_hash}) catch unreachable;
var runtime_out_file = try std.fs.cwd().openFile("src/runtime.out.js", .{ .read = true });
const runtime_hash = std.hash.Wyhash.hash(
0,
try runtime_out_file.readToEndAlloc(b.allocator, try runtime_out_file.getEndPos()),
);
const runtime_version_file = std.fs.cwd().createFile("src/runtime.version", .{ .truncate = true }) catch unreachable;
defer runtime_version_file.close();
runtime_version_file.writer().print("{x}", .{runtime_hash}) catch unreachable;
var fallback_out_file = try std.fs.cwd().openFile("src/fallback.out.js", .{ .read = true });
const fallback_hash = std.hash.Wyhash.hash(
0,
try fallback_out_file.readToEndAlloc(b.allocator, try fallback_out_file.getEndPos()),
);
const fallback_version_file = std.fs.cwd().createFile("src/fallback.version", .{ .truncate = true }) catch unreachable;
const fallback_hash = std.hash.Wyhash.hash(0, @embedFile("./src/fallback.out.js"));
const fallback_version_file = std.fs.cwd().openFile("src/fallback.version", .{ .write = true }) catch unreachable;
fallback_version_file.writer().print("{x}", .{fallback_hash}) catch unreachable;
defer fallback_version_file.close();
exe.setTarget(target);
@@ -211,97 +207,115 @@ pub fn build(b: *std.build.Builder) !void {
// if (target.getOsTag() == .macos) "-DUSE_FOUNDATION=1" else "",
// if (target.getOsTag() == .macos) "-DUSE_CF_RETAIN_PTR=1" else "",
// };
const headers_step = b.step("headers", "JSC headers");
var headers_exec: *std.build.LibExeObjStep = b.addExecutable("headers", "src/javascript/jsc/bindings/bindings-generator.zig");
var headers_runner = headers_exec.run();
headers_exec.setMainPkgPath(javascript.main_pkg_path.?);
headers_step.dependOn(&headers_runner.step);
var translate_c: *std.build.TranslateCStep = b.addTranslateC(.{ .path = b.pathFromRoot("src/javascript/jsc/bindings/headers.h") });
translate_c.out_basename = "headers";
translate_c.output_dir = b.pathFromRoot("src/javascript/jsc/bindings/");
headers_step.dependOn(&translate_c.step);
headers_zig_file = b.pathFromRoot("src/javascript/jsc/bindings/headers.zig");
const headers_step = b.step("headers-obj", "JSC headers Step #1");
var headers_obj: *std.build.LibExeObjStep = b.addObject("headers", "src/javascript/jsc/bindings/bindings-generator.zig");
headers_obj.setMainPkgPath(javascript.main_pkg_path.?);
headers_step.dependOn(&headers_obj.step);
original_make_fn = headers_step.makeFn;
headers_step.makeFn = HeadersMaker.make;
b.default_step.dependOn(&exe.step);
var steps = [_]*std.build.LibExeObjStep{ exe, javascript, typings_exe, headers_exec };
{
var steps = [_]*std.build.LibExeObjStep{ exe, javascript, typings_exe };
// const single_threaded = b.option(bool, "single-threaded", "Build single-threaded") orelse false;
// const single_threaded = b.option(bool, "single-threaded", "Build single-threaded") orelse false;
for (steps) |step, i| {
step.linkLibC();
step.linkLibCpp();
addPicoHTTP(
step,
true,
);
step.addObjectFile("src/deps/libJavaScriptCore.a");
step.addObjectFile("src/deps/libWTF.a");
if (target.getOs().tag != .linux) {
step.addObjectFile("src/deps/libbmalloc.a");
}
step.addObjectFile("src/deps/mimalloc/libmimalloc.a");
step.addLibPath("src/deps/mimalloc");
step.addIncludeDir("src/deps/mimalloc");
// step.single_threaded = single_threaded;
if (target.getOsTag() == .macos) {
const homebrew_prefix = comptime if (std.Target.current.cpu.arch == .aarch64)
"/opt/homebrew/"
else
"/usr/local/";
// We must link ICU statically
step.addObjectFile(homebrew_prefix ++ "opt/icu4c/lib/libicudata.a");
step.addObjectFile(homebrew_prefix ++ "opt/icu4c/lib/libicui18n.a");
step.addObjectFile(homebrew_prefix ++ "opt/icu4c/lib/libicuuc.a");
// icucore is a weird macOS only library
step.linkSystemLibrary("icucore");
step.addLibPath(homebrew_prefix ++ "opt/icu4c/lib");
step.addIncludeDir(homebrew_prefix ++ "opt/icu4c/include");
} else {
step.linkSystemLibrary("icuuc");
step.linkSystemLibrary("icudata");
step.linkSystemLibrary("icui18n");
}
for (bindings_files.items) |binding| {
step.addObjectFile(
binding,
for (steps) |step, i| {
step.linkLibC();
step.linkLibCpp();
addPicoHTTP(
step,
true,
);
step.addObjectFile("src/deps/libJavaScriptCore.a");
step.addObjectFile("src/deps/libWTF.a");
step.addObjectFile("src/deps/libcrypto.a");
step.addObjectFile("src/deps/libbmalloc.a");
step.addObjectFile("src/deps/libarchive.a");
step.addObjectFile("src/deps/libs2n.a");
step.addObjectFile("src/deps/zlib/libz.a");
step.addObjectFile("src/deps/mimalloc/libmimalloc.a");
step.addLibPath("src/deps/mimalloc");
step.addIncludeDir("src/deps/mimalloc");
// step.single_threaded = single_threaded;
if (target.getOsTag() == .macos) {
const homebrew_prefix = comptime if (std.Target.current.cpu.arch == .aarch64)
"/opt/homebrew/"
else
"/usr/local/";
// We must link ICU statically
step.addObjectFile(homebrew_prefix ++ "opt/icu4c/lib/libicudata.a");
step.addObjectFile(homebrew_prefix ++ "opt/icu4c/lib/libicui18n.a");
step.addObjectFile(homebrew_prefix ++ "opt/icu4c/lib/libicuuc.a");
step.addObjectFile(homebrew_prefix ++ "opt/libiconv/lib/libiconv.a");
// icucore is a weird macOS only library
step.linkSystemLibrary("icucore");
step.addLibPath(homebrew_prefix ++ "opt/icu4c/lib");
step.addIncludeDir(homebrew_prefix ++ "opt/icu4c/include");
} else {
step.linkSystemLibrary("icuuc");
step.linkSystemLibrary("icudata");
step.linkSystemLibrary("icui18n");
step.addObjectFile("src/deps/libiconv.a");
}
for (bindings_files.items) |binding| {
step.addObjectFile(
binding,
);
}
}
}
var obj_step = b.step("obj", "Build Bun as a .o file");
var obj = b.addObject(bun_executable_name, exe.root_src.?.path);
obj.setTarget(target);
addPicoHTTP(obj, false);
obj.addPackage(.{
.name = "clap",
.path = .{ .path = "src/deps/zig-clap/clap.zig" },
});
{
var obj_step = b.step("obj", "Build Bun as a .o file");
var obj = b.addObject(bun_executable_name, exe.root_src.?.path);
obj.setTarget(target);
addPicoHTTP(obj, false);
obj.addPackage(.{
.name = "clap",
.path = .{ .path = "src/deps/zig-clap/clap.zig" },
});
obj_step.dependOn(&obj.step);
obj.setOutputDir(output_dir);
obj.setBuildMode(mode);
obj.linkLibC();
obj.linkLibCpp();
obj_step.dependOn(&obj.step);
obj.setOutputDir(output_dir);
obj.setBuildMode(mode);
obj.linkLibC();
obj.linkLibCpp();
obj.bundle_compiler_rt = true;
obj.strip = false;
obj.bundle_compiler_rt = true;
if (target.getOsTag() == .linux) {
// obj.want_lto = tar;
obj.link_emit_relocs = true;
obj.link_function_sections = true;
}
if (target.getOsTag() == .linux) {
// obj.want_lto = tar;
obj.link_emit_relocs = true;
obj.link_function_sections = true;
}
}
{
headers_obj.setTarget(target);
headers_obj.addPackage(.{
.name = "clap",
.path = .{ .path = "src/deps/zig-clap/clap.zig" },
});
headers_obj.setOutputDir(output_dir);
headers_obj.setBuildMode(mode);
headers_obj.linkLibC();
headers_obj.linkLibCpp();
headers_obj.bundle_compiler_rt = true;
if (target.getOsTag() == .linux) {
// obj.want_lto = tar;
headers_obj.link_emit_relocs = true;
headers_obj.link_function_sections = true;
}
}
} else {
b.default_step.dependOn(&exe.step);
}
@@ -342,59 +356,3 @@ pub fn build(b: *std.build.Builder) !void {
}
pub var original_make_fn: ?fn (step: *std.build.Step) anyerror!void = null;
pub var headers_zig_file: ?[]const u8 = null;
const HeadersMaker = struct {
pub fn make(self: *std.build.Step) anyerror!void {
try original_make_fn.?(self);
var headers_zig: std.fs.File = try std.fs.openFileAbsolute(headers_zig_file.?, .{ .write = true });
var contents = try headers_zig.readToEndAlloc(std.heap.page_allocator, headers_zig.getEndPos() catch unreachable);
const last_extern_i = std.mem.lastIndexOf(u8, contents, "pub extern fn") orelse @panic("Expected contents");
const last_newline = std.mem.indexOf(u8, contents[last_extern_i..], "\n") orelse @panic("Expected newline");
const to_splice = "usingnamespace @import(\"./headers-replacements.zig\");\n";
var new_contents = try std.heap.page_allocator.alloc(u8, contents.len + to_splice.len);
std.mem.copy(u8, new_contents, to_splice);
std.mem.copy(u8, new_contents[to_splice.len..], contents);
var i: usize = to_splice.len;
var remainder = new_contents[i..];
while (remainder.len > 0) {
i = std.mem.indexOf(u8, remainder, "\npub const struct_b") orelse break + "\npub const struct_b".len;
var begin = remainder[i..];
const end_line = std.mem.indexOf(u8, begin, "extern struct {") orelse break;
const end_struct = std.mem.indexOf(u8, begin, "\n};\n") orelse break + "\n};\n".len;
std.mem.set(u8, begin[1 .. end_struct + 3], ' ');
remainder = begin[end_struct..];
}
i = to_splice.len;
remainder = new_contents[i..];
while (remainder.len > 0) {
i = std.mem.indexOf(u8, remainder, "\npub const struct_") orelse break + "\npub const struct_".len;
var begin = remainder[i..];
var end_struct = std.mem.indexOf(u8, begin, "opaque {};") orelse break;
end_struct += std.mem.indexOf(u8, begin[end_struct..], "\n") orelse break;
i = 0;
std.mem.set(u8, begin[1..end_struct], ' ');
remainder = begin[end_struct..];
}
const HARDCODE = [_][]const u8{
"[*c][*c]JSC__Exception",
"*?*JSC__Exception ",
"[*c]?*c_void",
"[*c]*c_void",
};
i = 0;
while (i < HARDCODE.len) : (i += 2) {
_ = std.mem.replace(u8, new_contents, HARDCODE[i], HARDCODE[i + 1], new_contents);
}
const js_value_start = std.mem.indexOf(u8, new_contents, "pub const JSC__JSValue") orelse unreachable;
const js_value_end = std.mem.indexOf(u8, new_contents[js_value_start..], "\n") orelse unreachable;
std.mem.set(u8, new_contents[js_value_start..][0..js_value_end], ' ');
try headers_zig.seekTo(0);
try headers_zig.writeAll(new_contents);
try headers_zig.setEndPos(last_newline + last_extern_i + to_splice.len);
}
};

8
completions/bun.bash Normal file
View File

@@ -0,0 +1,8 @@
#/usr/bin/env bash
# This is not implemented yet.
# But a PR implementing it would be very welcome!
_bun_completions() {
}
complete -F _bun_completions bun

90
completions/bun.fish Normal file
View File

@@ -0,0 +1,90 @@
function __fish__get_bun_bins
string split ' ' (bun getcompletes b)
end
function __fish__get_bun_scripts
set -lx SHELL bash
set -lx MAX_DESCRIPTION_LEN 40
string trim (string split '\n' (string split '\t' (bun getcompletes z)))
end
function __fish__get_bun_bun_js_files
string split ' ' (bun getcompletes j)
end
function bun_fish_is_nth_token --description 'Test if current token is on Nth place' --argument-names n
set -l tokens (commandline -poc)
set -l tokens (string replace -r --filter '^([^-].*)' '$1' -- $tokens)
test (count $tokens) -eq "$n"
end
function __bun_command_count --argument-names n
set -l cmds (commandline -poc)
test (count cmds) -eq "$n"
end
function __bun_last_cmd --argument-names n
set -l cmds (commandline -poc)
test "(cmds[-1])" = "$n"
end
set -l bun_builtin_cmds dev create help bun upgrade discord run
set -l bun_builtin_cmds_without_run dev create help bun upgrade discord
set -l bun_builtin_cmds_without_bun dev create help upgrade run discord
set -l bun_builtin_cmds_without_create dev help bun upgrade discord run
complete -c bun \
-n "not __fish_seen_subcommand_from $bun_builtin_cmds_without_run; and not __fish_seen_subcommand_from (__fish__get_bun_bins); and not __fish_seen_subcommand_from (__fish__get_bun_scripts); and __fish_use_subcommand" -a '(__fish__get_bun_scripts)' -d 'script'
complete -c bun \
-n "not __fish_seen_subcommand_from $bun_builtin_cmds_without_run; and not __fish_seen_subcommand_from (__fish__get_bun_bins); and not __fish_seen_subcommand_from (__fish__get_bun_scripts); and __fish_seen_subcommand_from run" -a '(__fish__get_bun_bins)' -d 'package bin'
complete -c bun \
-n "not __fish_seen_subcommand_from $bun_builtin_cmds_without_run; and not __fish_seen_subcommand_from (__fish__get_bun_bins); and not __fish_seen_subcommand_from (__fish__get_bun_scripts); and __fish_seen_subcommand_from run" -a '(__fish__get_bun_scripts)' -d 'script'
complete -c bun \
-n "not __fish_seen_subcommand_from $bun_builtin_cmds_without_run; and not __fish_seen_subcommand_from (__fish__get_bun_bins); and not __fish_seen_subcommand_from (__fish__get_bun_scripts); and __fish_seen_subcommand_from run" -a '(__fish__get_bun_bun_js_files)' -d 'Bun.js'
complete -c bun \
-n "bun_fish_is_nth_token 1; and not __fish_seen_subcommand_from $bun_builtin_cmds; and not __fish_seen_subcommand_from (__fish__get_bun_bins); and not __fish_seen_subcommand_from (__fish__get_bun_scripts) and __fish_use_subcommand" -a 'run' -f -d 'Run a script or bin'
complete -c bun \
-n "not __fish_seen_subcommand_from (__fish__get_bun_bins); and not __fish_seen_subcommand_from (__fish__get_bun_scripts);" --no-files -s 'u' -l 'origin' -r -d 'Server URL. Rewrites import paths'
complete -c bun \
-n "not __fish_seen_subcommand_from (__fish__get_bun_bins); and not __fish_seen_subcommand_from (__fish__get_bun_scripts);" --no-files -s 'p' -l 'port' -r -d 'Port number to start server from'
complete -c bun \
-n "not __fish_seen_subcommand_from (__fish__get_bun_bins); and not __fish_seen_subcommand_from (__fish__get_bun_scripts);" --no-files -s 'd' -l 'define' -r -d 'Substitute K:V while parsing, e.g. --define process.env.NODE_ENV:\"development\"'
complete -c bun \
-n "not __fish_seen_subcommand_from (__fish__get_bun_bins); and not __fish_seen_subcommand_from (__fish__get_bun_scripts);" --no-files -s 'e' -l 'external' -r -d 'Exclude module from transpilation (can use * wildcards). ex: -e react'
complete -c bun \
-n "not __fish_seen_subcommand_from (__fish__get_bun_bins); and not __fish_seen_subcommand_from (__fish__get_bun_scripts);" --no-files -l 'use' -r -d 'Use a framework (ex: next)'
complete -c bun \
-n "bun_fish_is_nth_token 1; and not __fish_seen_subcommand_from $bun_builtin_cmds; and not __fish_seen_subcommand_from (__fish__get_bun_bins); and not __fish_seen_subcommand_from (__fish__get_bun_scripts) and __fish_use_subcommand" -a 'dev' -d 'Start dev server'
complete -c bun \
-n "bun_fish_is_nth_token 1; and not __fish_seen_subcommand_from $bun_builtin_cmds; and not __fish_seen_subcommand_from (__fish__get_bun_bins); and not __fish_seen_subcommand_from (__fish__get_bun_scripts) and __bun_command_count 1 and __fish_use_subcommand" -a 'create' -f -d 'Create a new project'
complete -c bun \
-n "not __fish_seen_subcommand_from $bun_builtin_cmds_without_create next react; and not __fish_seen_subcommand_from (__fish__get_bun_bins); and not __fish_seen_subcommand_from (__fish__get_bun_scripts); and __fish_seen_subcommand_from create;" -a 'next' -d 'new Next.js project'
complete -c bun \
-n "not __fish_seen_subcommand_from $bun_builtin_cmds_without_create next react; and not __fish_seen_subcommand_from (__fish__get_bun_bins); and not __fish_seen_subcommand_from (__fish__get_bun_scripts); and __fish_seen_subcommand_from create;" -a 'react' -d 'new React project'
complete -c bun \
-n "not __fish_seen_subcommand_from $bun_builtin_cmds; and not __fish_seen_subcommand_from (__fish__get_bun_bins); and not __fish_seen_subcommand_from (__fish__get_bun_scripts); and __fish_use_subcommand" -a 'upgrade' -d 'Upgrade Bun to the latest version' -x
complete -c bun \
-n "not __fish_seen_subcommand_from $bun_builtin_cmds; and not __fish_seen_subcommand_from (__fish__get_bun_bins); and not __fish_seen_subcommand_from (__fish__get_bun_scripts); and __fish_use_subcommand" -a '--help' -d 'See all commands and flags' -x
complete -c bun \
-n "not __fish_seen_subcommand_from $bun_builtin_cmds; and not __fish_seen_subcommand_from (__fish__get_bun_bins); and not __fish_seen_subcommand_from (__fish__get_bun_scripts); and __fish_use_subcommand" -l "version" -s "v" -a '--version' -d 'Bun\'s version' -x
complete -c bun \
-n "not __fish_seen_subcommand_from $bun_builtin_cmds; and not __fish_seen_subcommand_from (__fish__get_bun_bins); and not __fish_seen_subcommand_from (__fish__get_bun_scripts); and __fish_use_subcommand" -a 'discord' -d 'Open Bun\'s Discord server' -x
complete -c bun \
-n "not __fish_seen_subcommand_from $bun_builtin_cmds_without_bun; and not __fish_seen_subcommand_from (__fish__get_bun_bins); and not __fish_seen_subcommand_from (__fish__get_bun_scripts); __fish_use_subcommand" -a 'bun' -d 'Generate a new bundle'
complete -c bun \
-n "not __fish_seen_subcommand_from $bun_builtin_cmds_without_bun; and not __fish_seen_subcommand_from (__fish__get_bun_bins); and not __fish_seen_subcommand_from (__fish__get_bun_scripts); and __fish_seen_subcommand_from bun" -F -d 'Bundle this'
complete -c bun \
-n "not __fish_seen_subcommand_from $bun_builtin_cmds_without_create; and not __fish_seen_subcommand_from (__fish__get_bun_bins); and not __fish_seen_subcommand_from (__fish__get_bun_scripts); and __fish_seen_subcommand_from react; or __fish_seen_subcommand_from next" -F -d "Create in directory"
complete -c bun --no-files

66
completions/bun.zsh Normal file
View File

@@ -0,0 +1,66 @@
__bun_first_cmd() {
echo "${words[2]}"
}
__bun_first_cmd_arg() {
echo "${words[3]}"
}
__bun_arg_count() {
echo "$#words"
}
_bun_run() {
if [[ ("$(__bun_arg_count)" = "2") ]]; then
local -a options
options=(${(f)"$(SHELL=zsh bun getcompletes)"})
_describe 'values' options
elif [[ ("$(__bun_arg_count)" = "3") ]]; then
local -a run
run=("${(f)"$(SHELL=zsh bun getcompletes g)"}")
compadd $run
else
_files
return
fi
# Make sure we don't run default completion
custom_completion=true
}
_bun() {
# Store custom completion status
local custom_completion=false
# Load custom completion commands
case "$(__bun_first_cmd)" in
create)
_files
return;
;;
dev)
return;
;;
bun)
_files
return;
;;
upgrade)
return;
;;
discord)
return;
;;
run)
_bun_run
return;
;;
esac
# Fall back to default completion if we haven't done a custom one
[[ $custom_completion = false ]] && _bun_run
}
compdef _bun bun

View File

@@ -2,13 +2,15 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
<true/>
<key>com.apple.security.cs.disable-executable-page-protection</key>
<true/>
</dict>
</plist>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.disable-executable-page-protection</key>
<true/>
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
</dict>
</plist>

1
examples/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
bun-examples-all

View File

@@ -1,11 +0,0 @@
import { Main } from "../../src/main";
function IndexRoute() {
return (
<div>
<Main productName={"Boom id"} />
</div>
);
}
export { IndexRoute as default };

View File

@@ -1,7 +0,0 @@
import { Main } from "src/main";
export function IndexPage() {
return <Main />;
}
export default IndexPage;

View File

@@ -1,9 +0,0 @@
import { Main } from "../../src/main";
export default function IndexRoute() {
return (
<div>
<Main productName={"nested!"} />
</div>
);
}

View File

@@ -1,13 +0,0 @@
import { Main } from "../src/main";
export function getInitialProps() {
return {};
}
export default function IndexRoute() {
return (
<div>
<Main productName={"Page 2! Next.js (Webpack 5)"} />
</div>
);
}

View File

@@ -1,21 +0,0 @@
// Snowpack Configuration File
// See all supported options: https://www.snowpack.dev/reference/configuration
/** @type {import("snowpack").SnowpackUserConfig } */
module.exports = {
root: "src",
mount: {
public: "/",
src: "/",
},
plugins: ["@snowpack/plugin-react-refresh"],
packageOptions: {
/* ... */
},
devOptions: {
/* ... */
},
buildOptions: {
/* ... */
},
};

File diff suppressed because it is too large Load Diff

View File

@@ -1 +0,0 @@
export const Button = ({ children }) => <div>asdasasd{children}</div>;

View File

@@ -1,14 +0,0 @@
:root {
--timestamp: "596";
--interval: "64";
--progress-bar: 33.167%;
--spinner-1-muted: rgb(42, 74, 66);
--spinner-1-primary: rgb(53, 93, 82);
--spinner-2-muted: rgb(90, 51, 192);
--spinner-2-primary: rgb(112, 64, 240);
--spinner-3-muted: rgb(157, 140, 68);
--spinner-3-primary: rgb(196, 175, 85);
--spinner-4-muted: rgb(86, 152, 66);
--spinner-4-primary: rgb(108, 190, 82);
--spinner-rotate: 237deg;
}

View File

@@ -1,3 +0,0 @@
body {
filter: sepia(50%) brightness(200%);
}

View File

@@ -1,27 +0,0 @@
import React from "react";
import { NewComponent } from "./new-comp";
const Toast = () => {
const [baconyes, baconno] = useBacon();
return <div>false</div>;
};
const Button = ({ label, label2, onClick }) => {
const useCustomHookInsideFunction = (what, arr) => {
return [true, false];
};
const [on, setOn] = React.useState(false);
React.useEffect(() => {
console.log({ on });
}, [on]);
// const [foo1, foo2] = useCustomHookInsideFunction(() => {}, [on]);
return (
<div className="Button" onClick={onClick}>
<Toast>f</Toast>
<div className="Button-label">{label}12</div>
<NewComponent />
</div>
);
};

View File

@@ -1,3 +0,0 @@
export const NewComponent = () => {
return <div>NEW!</div>;
};

View File

@@ -1 +0,0 @@
/* @import "https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;700&family=Space+Mono:wght@400;700&display=swap"; */

View File

@@ -1 +0,0 @@
import jsx from "/Users/jarred/Code/bun/demos/css-stress-test/node_modules/react/cjs/react-jsx-dev-runtime.development.js";

View File

@@ -1,23 +0,0 @@
{
"compilerOptions": {
"target": "esnext",
"lib": ["dom", "dom.iterable", "esnext", "WebWorker"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"baseUrl": ".",
"paths": {
"path": ["node_modules/path-browserify"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}

View File

@@ -1 +0,0 @@
export const yep = true;

File diff suppressed because it is too large Load Diff

View File

@@ -1,25 +0,0 @@
{
"name": "hello-next",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"@jarred/react-static-tweets": "0.5.8",
"@jarred/static-tweets": "^0.5.8",
"date-fns": "^2.23.0",
"isomorphic-fetch": "^3.0.0",
"next": "^11.1.0",
"parcel": "2.0.0-rc.0",
"path-browserify": "^1.0.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-is": "^17.0.2",
"whatwg-url": "^9.1.0"
},
"devDependencies": {
"@babel/standalone": "^7.15.3",
"@types/react": "^17.0.19",
"bun-framework-next": "^0.0.0-21",
"typescript": "^4.3.5"
}
}

View File

@@ -1,5 +0,0 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
export default function handler(req, res) {
res.status(200).json({ name: 'John Doe' })
}

View File

@@ -1,26 +0,0 @@
import Link from "next/link";
export default function Baz({}) {
return (
<div style={{ padding: 16 }}>
<h1>Third</h1>
<ul>
<li>
<Link href="/">
<a>Root page</a>
</Link>
</li>
<li>
<Link href="/second">
<a>Second page</a>
</Link>
</li>
<li>
<Link href="/posts/123">
<a>Post page 123</a>
</Link>
</li>
</ul>
</div>
);
}

View File

@@ -1,81 +0,0 @@
import Head from "next/head";
import Link from "next/link";
import React from "react";
import styles from "../styles/Home.module.css";
export async function getStaticProps(ctx) {
return {
props: {},
};
}
export default function Home({}) {
return (
<div className={styles.container}>
<Head>
<title>Fo</title>
<meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" />
</Head>
<main className={styles.main}>
<h1 className={styles.title}>
Welcome!!to <a href="https://nextjs.org">Next.js!</a>
</h1>
<p className={styles.description}>
Get started by editing{" "}
<code className={styles.code}>pages/index.js</code>
</p>
<div className={styles.grid}>
<Link href="/second">
<div className={styles.card}>
<h2>Second Page &rarr;</h2>
<p>Link</p>
</div>
</Link>
<a
onClick={() => router.push("/foo/bar/third")}
className={styles.card}
>
<h2>Third Page &rarr;</h2>
<p>button, router.push()</p>
</a>
<a
href="https://github.com/vercel/next.js/tree/master/examples"
className={styles.card}
>
<h2>Examples &rarr;</h2>
<p>Discover and deploy boilerplate example Next.js projects.</p>
</a>
<a
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
className={styles.card}
>
<h2>Deploy &rarr;</h2>
<p>
Instantly deploy your Next.js site to a public URL with Vercel.
</p>
</a>
</div>
</main>
<footer className={styles.footer}>
<a
href="https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
Powered by{" "}
<span className={styles.logo}>
<img src="/vercel.svg" alt="Vercel Logo" width={72} height={16} />
</span>
</a>
</footer>
</div>
);
}

View File

@@ -1,19 +0,0 @@
import { useRouter } from "next/router";
import Link from "next/link";
export default function Post({}) {
const router = useRouter();
return (
<div style={{ padding: 16 }}>
<h1>Post: {router.query.id}</h1>
<ul>
<li>
<Link href="/">
<a>Root page</a>
</Link>
</li>
</ul>
</div>
);
}

View File

@@ -1,11 +0,0 @@
import "three/three1.js";
import "three/three2.js";
import "three/three3.js";
import "three/three4.js";
import "three/three5.js";
import "three/three6.js";
import "three/three7.js";
import "three/three8.js";
import "three/three9.js";
import "three/three10.js";
// import "@babel/standalone/babel";

View File

@@ -1,30 +0,0 @@
{
"name": "lotta-modules",
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"@babel/standalone": "^7.15.3",
"lodash": "^4.17.21",
"three.js": "^0.77.1",
"underscore": "^1.13.1",
"webpack": "^5.56.0"
},
"type": "module",
"browserslist": [
"last 1 version"
],
"scripts": {
"generate": "cp node_modules/three/three.js node_modules/three/three1.js; cp node_modules/three/three.js node_modules/three/three2.js; cp node_modules/three/three.js node_modules/three/three3.js; cp node_modules/three/three.js node_modules/three/three4.js; cp node_modules/three/three.js node_modules/three/three5.js; cp node_modules/three/three.js node_modules/three/three6.js; cp node_modules/three/three.js node_modules/three/three7.js; cp node_modules/three/three.js node_modules/three/three8.js; cp node_modules/three/three.js node_modules/three/three9.js; cp node_modules/three/three.js node_modules/three/three10.js",
"bench": "hyperfine \"bun bun ./index.js\" \"GOMAXPROCS=1 bun bun ./index.js\" \"esbuild --bundle ./index.js --platform=browser --format=esm > /dev/null\" \"swc ./node_modules/three/three1.js ./node_modules/three/three2.js ./node_modules/three/three3.js ./node_modules/three/three4.js ./node_modules/three/three5.js ./node_modules/three/three6.js ./node_modules/three/three7.js ./node_modules/three/three8.js ./node_modules/three/three9.js ./node_modules/three/three10.js -C \"module.type=es6\" --no-swcrc -s false -o /tmp/out.swc.js\" \"node_modules/.bin/parcel build --no-optimize --no-source-maps --no-content-hash --no-cache --no-autoinstall ./index.js\" --prepare=\"rm -rf dist *.bun .parcel-cache;\"",
"bench-sync": "hyperfine \"GOMAXPROCS=1 bun bun ./index.js\" \"GOMAXPROCS=1 esbuild --bundle ./index.js --platform=browser --format=esm > /dev/null\" \"swc ./node_modules/three/three1.js ./node_modules/three/three2.js ./node_modules/three/three3.js ./node_modules/three/three4.js ./node_modules/three/three5.js ./node_modules/three/three6.js ./node_modules/three/three7.js ./node_modules/three/three8.js ./node_modules/three/three9.js ./node_modules/three/three10.js -C \"module.type=es6\" --sync --no-swcrc -s false -o /tmp/out.swc.js\" --prepare=\"rm -rf *.bun\" ",
"bench-all": "hyperfine \"bun bun ./index.js\" \"esbuild --bundle ./index.js --platform=browser --format=esm > /dev/null\" \"esbuild --bundle ./index.js --platform=browser --format=esm > /dev/null\" \"swc ./node_modules/three/three1.js ./node_modules/three/three2.js ./node_modules/three/three3.js ./node_modules/three/three4.js ./node_modules/three/three5.js ./node_modules/three/three6.js ./node_modules/three/three7.js ./node_modules/three/three8.js ./node_modules/three/three9.js ./node_modules/three/three10.js -C \"module.type=es6\" --no-swcrc -s false -o /tmp/out.swc.js\" \"GOMAXPROCS=1 bun bun ./index.js\" \"GOMAXPROCS=1 esbuild --bundle ./index.js --platform=browser --format=esm > /dev/null\" \"swc ./node_modules/three/three1.js ./node_modules/three/three2.js ./node_modules/three/three3.js ./node_modules/three/three4.js ./node_modules/three/three5.js ./node_modules/three/three6.js ./node_modules/three/three7.js ./node_modules/three/three8.js ./node_modules/three/three9.js ./node_modules/three/three10.js -C \"module.type=es6\" --sync --no-swcrc -s false -o /tmp/out.swc.js\" --prepare=\"rm -rf *.bun\""
},
"devDependencies": {
"@babel/core": "^7.15.5",
"@babel/preset-env": "^7.15.6",
"@parcel/core": "^2.0.0-rc.0",
"babel-loader": "^8.2.2",
"parcel": "^2.0.0-rc.0",
"webpack-cli": "^4.8.0"
}
}

View File

@@ -1,6 +0,0 @@
<html>
<head> </head>
<body>
<script src="/index.js"></script>
</body>
</html>

View File

@@ -32,3 +32,11 @@ yarn-error.log*
# vercel
.vercel
**/*.trace
**/*.zip
**/*.tar.gz
**/*.tgz
**/*.log
package-lock.json
**/*.bun

42
examples/next/.npmignore Normal file
View File

@@ -0,0 +1,42 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local
# vercel
.vercel
**/*.trace
**/*.zip
**/*.tar.gz
**/*.tgz
**/*.log
package-lock.json
**/*.bun

42
examples/next/gitignore Normal file
View File

@@ -0,0 +1,42 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local
# vercel
.vercel
**/*.trace
**/*.zip
**/*.tar.gz
**/*.tgz
**/*.log
package-lock.json
**/*.bun

View File

@@ -0,0 +1,21 @@
{
"name": "@bun-examples/next",
"version": "0.0.47",
"main": "index.js",
"dependencies": {
"next": "12.0.2",
"react": "alpha",
"react-dom": "alpha",
"react-is": "^17.0.2"
},
"devDependencies": {
"@types/react": "^17.0.19",
"bun-framework-next": "^12",
"typescript": "^4.4.0"
},
"bun-create": {
"postinstall": [
"bun bun --use next"
]
}
}

View File

@@ -0,0 +1,36 @@
import Head from "next/head";
import Link from "next/link";
import React from "react";
import styles from "../styles/Home.module.css";
import nextPackage from "next/package.json";
export async function getStaticProps(ctx) {
return {
props: {},
};
}
export default function Home({}) {
return (
<div className={styles.container}>
<Head>
<title>Next.js</title>
<meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" />
</Head>
<main className={styles.main}>
<h1 className={styles.title}>
Welcome to <a href="https://nextjs.org">Next.js!</a> v
{nextPackage.version}
</h1>
<p className={styles.description}>
Get started by editing{" "}
<code className={styles.code}>pages/index.tsx</code>
</p>
</main>
<footer className={styles.footer}></footer>
</div>
);
}

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -1,5 +1,3 @@
@import url("./2.css");
.container {
min-height: 99vh;
padding: 0 0.5rem;

View File

@@ -14,8 +14,3 @@ a {
* {
box-sizing: border-box;
}
body {
background-image: url(https://wompampsupport.azureedge.net/fetchimage?siteId=7575&v=2&jpgQuality=100&width=700&url=https%3A%2F%2Fi.kym-cdn.com%2Fentries%2Ficons%2Foriginal%2F000%2F013%2F564%2Fdoge.jpg);
background-size: cover;
}

View File

@@ -1,5 +1,5 @@
:root {
--timestamp: "12812";
--timestamp: "0";
--interval: "8";
--progress-bar: 11.83299999999997%;
--spinner-1-muted: rgb(142, 6, 182);
@@ -11,4 +11,4 @@
--spinner-4-muted: rgb(155, 129, 108);
--spinner-4-primary: rgb(194, 161, 135);
--spinner-rotate: 213deg;
}
}

32
examples/react/.gitignore vendored Normal file
View File

@@ -0,0 +1,32 @@
**/*.trace
**/*.zip
**/*.tar.gz
**/*.tgz
**/*.log
package-lock.json
**/*.bun
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*

View File

@@ -1,3 +1,11 @@
**/*.trace
**/*.zip
**/*.tar.gz
**/*.tgz
**/*.log
package-lock.json
**/*.bun
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies

32
examples/react/gitignore Normal file
View File

@@ -0,0 +1,32 @@
**/*.trace
**/*.zip
**/*.tar.gz
**/*.tgz
**/*.log
package-lock.json
**/*.bun
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*

View File

@@ -1,14 +1,12 @@
{
"name": "hello-create-react-app",
"version": "0.1.0",
"private": true,
"name": "@bun-examples/react",
"version": "0.0.41",
"dependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"web-vitals": "^1.0.1"
},
"scripts": {
@@ -36,6 +34,12 @@
]
},
"devDependencies": {
"typescript": "^4.4.2"
"typescript": "^4.4.2",
"react-refresh": "^0.10.0"
},
"bun-create": {
"postinstall": [
"bun bun ./src/index.jsx"
]
}
}

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

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