Skip to content

Typescript Library Starter โ€‹

Quickly scaffold modern TypeScript library in 10 seconds. Powered by Bunup - the fastest TypeScript bundler available โšก๏ธ.

Features โ€‹

  • ๐Ÿš€ Zero Config: Get started in seconds with sensible defaults
  • ๐Ÿ“ฆ Modern Setup: ESM and CJS output formats, TypeScript declarations
  • ๐Ÿงฉ Monorepo Support: Create workspace-based projects with ease
  • ๐Ÿ”ง Complete Tooling: Testing, linting, formatting, and CI workflows included
  • ๐Ÿšฆ Git Hooks: Enforced code quality with Husky pre-commit hooks
  • ๐Ÿ“ Conventional Commits: Standardized commit messages with commitlint
  • ๐Ÿšข Release Automation: GitHub Actions for testing and publishing
  • ๐Ÿงน Modern Tooling: Biome for linting and formatting

Getting Started โ€‹

Installation โ€‹

You can create a new project without installing the package by using:

sh
bunx create-bunup@latest
sh
npx create-bunup@latest
sh
pnpx create-bunup@latest

Once you run the command, you'll be guided through an interactive process:

plaintext
$ bunx create-bunup@latest

โ„น TypeScript Library Starter

? Where would you like to create your project? โ€บ my-ts-lib

? GitHub username and repo name (username/repo): โ€บ username/my-ts-lib

? Package description: โ€บ A TypeScript library

? Select a package manager:
โฏ bun - Fast all-in-one JavaScript runtime
  pnpm - Fast, disk space efficient package manager

? Set up as a monorepo? โ€บ (y/N)

# If you chose "yes" to monorepo:

? Name for first package: โ€บ my-package

Step-by-Step Setup โ€‹

  1. Change into the created project directory:

    sh
    cd my-ts-lib
  2. Install dependencies:

    sh
    bun install
    # or
    pnpm install
  3. Enable Git hooks:

    sh
    bun run prepare
    # or
    pnpm prepare
  4. Create a GitHub repository:

    • Go to GitHub
    • Create a new repository with the same name as your project
  5. Initialize Git repository:

    The CLI automatically initializes a Git repository for you and adds the remote if you provided a GitHub repository. You only need to make your first commit:

    sh
    git add .
    git commit -m "chore: initial commit"
  6. Setup for Releases:

    • Generate an npm token:

      1. Go to npmjs.com and sign in
      2. Navigate to your profile โ†’ Access Tokens โ†’ Generate New Token (Classic)
      3. Give it a descriptive name (e.g., "Bunup Publishing")
      4. Select "Automation" as the token type
      5. Click "Generate Token" and copy it immediately
    • Add npm token to GitHub repository:

      1. Go to your GitHub repository
      2. Navigate to Settings โ†’ Secrets and variables โ†’ Actions
      3. Click "New repository secret"
      4. Name: NPM_TOKEN
      5. Value: Paste your npm token
      6. Click "Add secret"

Development Workflow โ€‹

After completing the setup, here's how to use your project:

Common Commands โ€‹

sh
bun run dev
# or
pnpm dev
sh
bun run test
# or
pnpm test
sh
bun run lint
# or
pnpm lint
sh
bun run format:fix
# or
pnpm format:fix
sh
bun run tsc
# or
pnpm tsc
sh
bun run build
# or
pnpm build

Committing Code โ€‹

The project uses Conventional Commits for standardized commit messages:

sh
# Example commit messages:
git commit -m "feat: add user authentication"
git commit -m "fix: resolve issue with data loading"
git commit -m "docs: update API documentation"
git commit -m "chore: update dependencies"

Pre-commit hooks will run automatically to check your code quality before each commit. The hooks run type checking, linting, and formatting validation.

CI/CD Workflows โ€‹

The project comes with three GitHub Actions workflows:

  1. CI: Runs on pull requests and pushes to main, validating types, linting, and tests
  2. Release: Triggered by tags, builds and publishes the package to npm with provenance
  3. Issue Management: Automatically marks issues as stale after 30 days of inactivity

๐Ÿš€ Releasing Your Package โ€‹

When you're ready to release your package, simply run:

sh
bun run release
# or
pnpm release

This will:

  1. Prompt you for a new version (patch, minor, or major)
  2. Update package.json version
  3. Create a Git tag
  4. Push changes and tag to GitHub

The GitHub Actions workflow will automatically:

  1. Build the package
  2. Generate a GitHub release with changelog
  3. Publish to npm with provenance

Happy coding!

Released under the MIT License.