TSDX

Commands

TSDX provides a set of commands to help you develop, test, and build your TypeScript packages.

tsdx create

Create a new TypeScript package from a template.

tsdx create <name> [options]

Options

OptionDescription
-t, --template <template>Template to use (basic, react)

Examples

# Interactive template selection
bunx tsdx create mylib

# Specify template directly
bunx tsdx create mylib --template react

tsdx build

Build the package for production using bunchee.

tsdx build [options]

Options

OptionDescription
--no-cleanSkip cleaning the dist folder before building

Examples

# Standard build
tsdx build

# Build without cleaning dist
tsdx build --no-clean

Output

The build command outputs:

  • dist/index.js - ESM module
  • dist/index.cjs - CommonJS module
  • dist/index.d.ts - TypeScript declarations
  • dist/index.d.cts - CJS TypeScript declarations

tsdx dev / tsdx watch

Start development mode with file watching. Rebuilds automatically when files change.

tsdx dev
# or
tsdx watch

Examples

# Start development mode
tsdx dev

tsdx test

Run tests using vitest.

tsdx test [options]

Options

OptionDescription
-w, --watchRun in watch mode
-c, --coverageRun with coverage
-u, --updateUpdate snapshots

All additional options are passed through to vitest.

Examples

# Run tests once
tsdx test

# Watch mode
tsdx test --watch

# With coverage
tsdx test --coverage

# Update snapshots
tsdx test --update

# Run specific test file
tsdx test src/utils.test.ts

tsdx lint

Lint the codebase using oxlint.

tsdx lint [paths...] [options]

Options

OptionDescription
-f, --fixAuto-fix fixable issues
--config <path>Path to config file

Arguments

ArgumentDescriptionDefault
pathsPaths to lintsrc test

Examples

# Lint src and test directories (default)
tsdx lint

# Lint specific paths
tsdx lint src lib

# Auto-fix issues
tsdx lint --fix

# Use custom config
tsdx lint --config .oxlintrc.json

tsdx format

Format the codebase using oxfmt.

tsdx format [paths...] [options]

Options

OptionDescription
-c, --checkCheck if files are formatted without making changes

Arguments

ArgumentDescriptionDefault
pathsPaths to format.

Examples

# Format all files
tsdx format

# Check formatting without changes
tsdx format --check

# Format specific paths
tsdx format src test

tsdx typecheck

Run TypeScript type checking.

tsdx typecheck [options]

Options

OptionDescription
-w, --watchRun in watch mode

Examples

# Type check once
tsdx typecheck

# Watch mode
tsdx typecheck --watch

tsdx init

Initialize TSDX configuration in an existing project.

tsdx init

This command:

  • Updates package.json with tsdx scripts and exports configuration
  • Creates tsconfig.json if it doesn't exist
  • Creates vitest.config.ts if it doesn't exist

Examples

# Initialize in existing project
bunx tsdx init

After running tsdx init, install the required dependencies:

bun add -D bunchee vitest typescript oxlint

On this page