Setting up new Node.js TypeScript projects can often be tedious and convoluted. That's when I heard about Bun - a streamlined alternative for Node.js that essentially combines Node, ts-node, npm, and jest in a single package.
I recently gave Bun a test run in a Proof of Concept project, and so far, it's impressed me considerably.
1# Installation is an absolute breeze 2curl -fsSL https://bun.sh/install | bash 3 4# Initiates a new project in the existing directory 5# Creates package.json, index.ts, .gitignore, README.md and tsconfig.json (only required for the IDE) 6bun init 7 8# TypeScript files can be directly executed with Bun 9bun run index.ts 10 11# Bun also doubles up as a test runner 12# Executes tests in, say, index.test.ts 13bun test 14 15# Additionally, Bun serves as a package manager 16bun add express 17 18# There's a React template available for Bun 19# However, this part didn't work well for us so we're currently using Vite with Bun (npm create vite@latest && bun install && bun dev) 20bun create react ./myapp
While it's recommended to use tools like NX for larger TypeScript projects, I see myself opting for Bun more frequently in the future for quickly setting up new TypeScript ventures. It must be noted that Bun also supports npm workspaces for monorepos.
Alternatively, I'm keen on giving Deno another go as well.