An open API service indexing awesome lists of open source software.

https://github.com/maxgfr/typescript-swc-starter

A minimalist typescript swc starter that generate cjs and esm package
https://github.com/maxgfr/typescript-swc-starter

boilerplate cjs dotenv eslint esm jest node nodejs nodemon prettier rust-compiler starter starter-kit swc typescript unbuild

Last synced: 2 months ago
JSON representation

A minimalist typescript swc starter that generate cjs and esm package

Awesome Lists containing this project

README

          

# typescript-swc-starter

[![Build](https://github.com/maxgfr/typescript-swc-starter/actions/workflows/build.yml/badge.svg)](https://github.com/maxgfr/typescript-swc-starter/actions/workflows/build.yml)
[![Test](https://github.com/maxgfr/typescript-swc-starter/actions/workflows/test.yml/badge.svg)](https://github.com/maxgfr/typescript-swc-starter/actions/workflows/test.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

A minimalist TypeScript boilerplate using [SWC](https://swc.rs/) for blazing-fast compilation. Generates both `cjs` and `esm` modules.

## โœจ Features

- โšก **SWC** - Super-fast TypeScript/JavaScript compiler
- ๐Ÿ“ฆ **Dual package** - Outputs both CommonJS and ES Modules
- ๐Ÿงช **Jest** - Testing with SWC for speed
- ๐ŸŽจ **Biome** - Fast linting and formatting
- ๐Ÿ”„ **Nodemon** - Hot reload during development
- ๐Ÿš€ **Semantic Release** - Automated versioning and publishing
- ๐Ÿ”’ **Husky + lint-staged** - Pre-commit hooks

## ๐Ÿ“‹ Prerequisites

- Node.js >= 24
- pnpm

## ๐Ÿš€ Getting Started

```sh
# Clone the repository
git clone https://github.com/maxgfr/typescript-swc-starter
cd typescript-swc-starter

# Install dependencies
pnpm install
```

## ๐Ÿ“œ Scripts

### Development

```sh
pnpm dev # Run in development mode with hot reload
pnpm develop # Run source code with SWC register
```

### Testing

```sh
pnpm test # Run tests
pnpm test:watch # Run tests in watch mode
pnpm test:coverage # Run tests with coverage
```

### Linting & Formatting

```sh
pnpm lint # Lint code with Biome
pnpm lint:fix # Lint and fix issues
pnpm format # Check formatting
pnpm format:fix # Format code
pnpm check # Run both lint and format checks
pnpm check:fix # Fix both lint and format issues
```

### Building

```sh
pnpm build # Compile with SWC
pnpm bundle # Bundle for distribution (cjs + esm)
pnpm clean # Clean build artifacts
```

### Running Built Code

```sh
pnpm start:cjs # Run CommonJS build
pnpm start:esm # Run ES Module build
```

## ๐Ÿ“ฆ Publishing to npm

This project uses OIDC for npm publishing - no `NPM_TOKEN` required!

1. Go to your npm package's access page: `https://www.npmjs.com/package//access`
2. Set your details and trust publisher

![NPM Access Settings](https://raw.githubusercontent.com/maxgfr/typescript-swc-starter/main/.github/assets/token.png)

## ๐Ÿ“– Usage

```ts
import { sayHello } from 'typescript-swc-starter';

sayHello();
```

## ๐Ÿ“„ License

MIT ยฉ [maxgfr](https://github.com/maxgfr)