bun create
bun create is a new subcommand that lets you quickly create a project from a template.

To create a new React project (based on Create React App)
bun create react ./app
11x faster than yarn create react app on my Macbook Pro (both installing dependencies via yarn)
<img width="1614" alt="CleanShot 2021-10-15 at 23 37 07@2x" src="https://user-images.githubusercontent.com/709451/137576706-7d2a2bcd-695c-4a24-80c0-2c7464d2a4b7.png">
To create a new Next.js project (based on Create Next App)
bun create next ./app
To create from a GitHub repository:
bun create jarred-sumner/calculator calc
To see a list of templates:
bun create
Right now, there are only two "official" templates (and they're mostly empty) β but you can add more. bun create fetches from packages published in the examples folder of Bun's GitHub repo. PRs are very welcome!
<img width="788" alt="CleanShot 2021-10-15 at 23 45 49@2x" src="https://user-images.githubusercontent.com/709451/137576930-793bf67c-39eb-404e-a3cf-0a81b9554aa0.png">
Local templates
Many developers have boilerplate code copied for new projects.
That's why bun create also searches $HOME/.bun-create for local templates.
Add a folder with a package.json in $HOME/.bun-create/my-local-template and then you can run:
bun create my-local-template ./foo
This copies the contents of my-local-template, initializes a git repository, runs any preinstall steps, installs dependencies (if any exist), runs any postinstall steps and rewrites the name field in package.json to foo.
It uses the fastest system calls available for copying files. bun create copies files faster than cp. Here is a stupid microbenchmark
<img width="1273" alt="CleanShot 2021-10-17 at 05 00 12@2x" src="https://user-images.githubusercontent.com/709451/137626341-200263ce-c093-431b-8c4e-e7e4e1e7663f.png">
Performance
The slowest part is running your NPM client to install node_modules. The second slowest part is downloading the tarball from GitHub (or NPM if it's from Bun's examples folder). Third is git.
Other stuff
fetch now supports gzip
- https support in
fetch was completely rewritten to be more reliable. TLS is now powered by s2n-tls
fetch now supports Transfer-Encoding: chunked. It didn't before, which was embarrassing.
- Set
self to globalThis in Bun.js. This improves compatibility with some npm packages
- There are two new test binaries in
misctools/, tgz and fetch. tgz is like gunzip except harder to use and fetch is sort of like curl? These are really just to help me test some things in isolation from the rest of Bun