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
| Option | Description |
|---|---|
-t, --template <template> | Template to use (basic, react) |
Examples
# Interactive template selection
bunx tsdx create mylib
# Specify template directly
bunx tsdx create mylib --template reacttsdx build
Build the package for production using bunchee.
tsdx build [options]Options
| Option | Description |
|---|---|
--no-clean | Skip cleaning the dist folder before building |
Examples
# Standard build
tsdx build
# Build without cleaning dist
tsdx build --no-cleanOutput
The build command outputs:
dist/index.js- ESM moduledist/index.cjs- CommonJS moduledist/index.d.ts- TypeScript declarationsdist/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 watchExamples
# Start development mode
tsdx devtsdx test
Run tests using vitest.
tsdx test [options]Options
| Option | Description |
|---|---|
-w, --watch | Run in watch mode |
-c, --coverage | Run with coverage |
-u, --update | Update 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.tstsdx lint
Lint the codebase using oxlint.
tsdx lint [paths...] [options]Options
| Option | Description |
|---|---|
-f, --fix | Auto-fix fixable issues |
--config <path> | Path to config file |
Arguments
| Argument | Description | Default |
|---|---|---|
paths | Paths to lint | src 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.jsontsdx format
Format the codebase using oxfmt.
tsdx format [paths...] [options]Options
| Option | Description |
|---|---|
-c, --check | Check if files are formatted without making changes |
Arguments
| Argument | Description | Default |
|---|---|---|
paths | Paths to format | . |
Examples
# Format all files
tsdx format
# Check formatting without changes
tsdx format --check
# Format specific paths
tsdx format src testtsdx typecheck
Run TypeScript type checking.
tsdx typecheck [options]Options
| Option | Description |
|---|---|
-w, --watch | Run in watch mode |
Examples
# Type check once
tsdx typecheck
# Watch mode
tsdx typecheck --watchtsdx init
Initialize TSDX configuration in an existing project.
tsdx initThis command:
- Updates
package.jsonwith tsdx scripts and exports configuration - Creates
tsconfig.jsonif it doesn't exist - Creates
vitest.config.tsif it doesn't exist
Examples
# Initialize in existing project
bunx tsdx initAfter running tsdx init, install the required dependencies:
bun add -D bunchee vitest typescript oxlint