🍃 Leaf

Bun

Installation

curl -fsSL https://bun.sh/install | bash
# On Windows (not WSL)
powershell -c "irm bun.sh/install.ps1 | iex"

More at (bun.sh):

Usage

bun create <template>         # As a project initializer
bun run index.tsx             # As a runtime (Node, TS, and JSX-compatible)
bun install <package-name>    # As a package manager (npm-compatible)
bun build <in> --outdir <out> # As a bundler/builder
bun test                      # As a test runner (Jest-compatible)
bun add -d @types/bun         # To use with TypeScript
bunx --bun <package>          # As a package runner (npx-like)*

*The --bun flag is used to substitute node by bun in the shebang #!/usr/bin/env node.

More at (bun.sh):

Configuration

Some configuration options recommended by Bun:

// tsconfig.json e.g.:
{
  "compilerOptions": {
    // Basic
    "lib": ["ESNext"],
    "target": "ESNext",
    "module": "ESNext",
    "moduleDetection": "force",
    "jsx": "react-jsx",
    "allowJs": true, // Not sure about this

    // Bundler
    "moduleResolution": "bundler"
    "allowImporting": true,
    "verbatimModuleSyntax": true,
    "noEmit": true,

    // Best practices
    "strict": true,
    "skipLibCheck": true,
    "noFallthroughCasesInSwitch": true,

    // Stricter
    "noUnusedLocals": true,
    "noUnusedParameters": true,
  }
}

More at Suggested compilerOptions (bun.sh).