- Node team is klein team en onbetaald
- Voortgang Node versies gaat vooral over niet te veel breaken met voorgaande versies
- Hierdoor blijven kritisch perfomance issues liggen
- Gebouwd op de V8 engine. Kijk bv naar de code van de shell
- Het Bun team zet in op performance
- Heeft links met React en Vue
- Probeert het hele eco systeem van Node te kunnen draaien
- Kort gezegd een snellere Node
- single threaded & concurrency
- callbacks
- Loops
- Limited standard Libs
- CPU perfomant tasks & Memory consumption
- debugging
- gemopper over update cycle en deprecations
Safari engine voordelen:
- batterij
- performance webkit
- security
- CJS and ES6 and beyond support
- cross-platform
- kleiner en sneller
- voor de browser
het staat op : Bun Home Page Op Youtube zeggen ze zelf:
- Bun is still under development.
- Use it to speed up your development workflows or run simpler production code in resource-constrained environments like serverless functions.
- We're working on more complete Node.js compatibility and integration with existing frameworks.
- Bun is an all-in-one toolkit for JavaScript and TypeScript apps. It ships as a single executable called
bun
. - At its core is the Bun runtime, a fast JavaScript runtime designed as a drop-in replacement for Node.js.
- It's written in Zig and powered by JavaScriptCore under the hood, dramatically reducing startup times and memory usage.
- Werkt (nog) niet op Windows
Op Linux achtige machines:
# with install script (recommended)
curl -fsSL https://bun.sh/install | bash
# with npm
npm install -g bun
# with Homebrew
brew tap oven-sh/bun
brew install bun
# with Docker
docker pull oven/bun
docker run --rm --init --ulimit memlock=-1:-1 oven/bun
Na de check of bun t doet:
bun --version
Kan je:
bun init
Net zoals npm
bun upgrade
bun install
bun i
branche 01_init na
bun init
bevat de folder
.gitignore
README.md
bun.lockb
index.ts
node_modules
package.json
tsconfig.json
bun run index.ts
branche 02_say_hello
import van andere ts file
branch 03_bun_serve
start een server op zoals in bv express
branch 04 bun run start
"scripts": {
"start": "bun run index.ts"
},
{
// ... other fields
"scripts": {
"clean": "rm -rf dist && echo 'Done.'",
"dev": "bun server.ts"
}
}
bun run clean
bun run dev
branch 5 dom en tsconfig
rare errors van mn lsp kon ik oplossen met:
/// <reference lib="dom" />
/// <reference lib="dom.iterable" />
bun run index.ts
To run a file in watch mode, use the --watch
flag.
bun --watch run index.tsx
{
// ... other fields
"scripts": {
"clean": "rm -rf dist && echo 'Done.'",
"dev": "bun server.ts"
}
}
bun run clean
bun run dev
bun test
Tests are written in JavaScript or TypeScript with a Jest-like API. Refer to Writing tests for full documentation.
The runner recursively searches the working directory for files that match the following patterns:
*.test.{js|jsx|ts|tsx}
*_test.{js|jsx|ts|tsx}
*.spec.{js|jsx|ts|tsx}
*_spec.{js|jsx|ts|tsx}
You can filter the set of test files to run by passing additional positional arguments to bun test
.
- 06_test branche* math.test.ts
import { expect, test } from "bun:test";
test("2 + 2", () => {
expect(2 + 2).toBe(4);
});
Elisia De Express van / met Bun
bun create elysia app
- Performance : You shall not worry about the underlying performance
- Simplicity : Simple building blocks to create an abstraction, not repeating yourself
- Flexibility : You shall be able to customize most of the library to fits your need
eenvoudig integratie met swagger
branche 07 for loops
node forloop.js
bun start
express bun en elysia
met artillery
ontloopt elkaar niet heel veel
voordelen op openshift?
toon results
toon crm project
voordeel alles wordt razend snel door bun gecompileerd
Bun runt project en de bundle
css wordt gegenereerd door Tailwind
youtube en bun pagina vol met voorbeelden.
Node en Bun zullen voorlopig naast elkaar bestaan
Bun is nog niet productie klaar
Geen Windows versie