TSDX
TSDX is a zero-configuration command-line interface (CLI) for modern TypeScript package development, currently stable at version 2.0.0. It aims to simplify the creation, testing, and publication of TypeScript libraries by abstracting away complex build configurations. Version 2.0.0 represents a complete rewrite, transitioning to high-performance Rust-based tooling, including bunchee for bundling, Vitest for testing, OXLint for linting, and OXFmt for formatting. While it doesn't adhere to a fixed release cadence, major updates like v2.0.0 introduce significant architectural shifts and toolchain changes. Its key differentiators include the 'zero-config' philosophy, the integration of lightning-fast Rust tools for improved developer experience, built-in support for dual ESM/CommonJS outputs, and robust TypeScript declaration generation.
Common errors
-
(typescript) Error: ENOENT: no such file or directory, rename '[...]/my-lib/node_modules/.cache/rollup-plugin-typescript2/rpt2_4c61ae4392b9bd24f4d43d13a3f56419b8b5805d/code/cache_' -> '[...]/my-lib/node_modules/.cache/rollup-plugin-typescript2/rpt2_4c61ae4392b9bd24f4d43d13a3f56419b8b5805d/code/cache'
cause An upstream cache bug in `rollup-plugin-typescript2` affecting certain build formats in older TSDX versions.fixUpgrade TSDX to version 0.14.1 or newer to resolve this caching issue. -
Error: Your current Node.js version (X) does not meet the minimum requirement of >=20 for TSDX v2.x. Please upgrade your Node.js version.
cause Running TSDX v2.x with an unsupported Node.js version.fixUpgrade your Node.js installation to version 20 or higher. You can use a version manager like `nvm` or `fnm` to manage multiple Node.js versions. -
TSDX Build Warning: Your tsconfig.json `rootDir` is set to `./`. Please consider changing it to `./src` for optimal build performance and consistent behavior.
cause Using the deprecated `rootDir: './'` setting in `tsconfig.json`.fixEdit your `tsconfig.json` file and set `"rootDir": "./src"`.
Warnings
- breaking TSDX v2.0.0 is a complete rewrite using a new toolchain (bunchee, Vitest, oxlint, oxfmt) that requires Node.js 20+. This represents a significant breaking change from previous 0.x versions.
- breaking Starting with TSDX v0.14.0, Node.js 8 is no longer supported; the minimum required Node.js version was updated to 10. Later, v2.0.0 increased this requirement to Node.js 20+.
- deprecated The `rootDir: './'` setting in `tsconfig.json` was deprecated in v0.13.0. Projects should use `rootDir: './src'` instead to ensure correct compilation and avoid warnings.
- gotcha An upstream cache bug in `rollup-plugin-typescript2` could lead to `ENOENT: no such file or directory, rename '[...]/node_modules/.cache/rollup-plugin-typescript2/...'` errors during builds, particularly with certain build format combinations.
- gotcha Faulty `tsconfig.json` `include` arrays, specifically including `test` files, could lead to type declarations being generated in `dist/` for test files and slowing down builds.
Install
-
npm install tsdx -
yarn add tsdx -
pnpm add tsdx
Quickstart
# Create a new package interactively bunx tsdx create mylib # Navigate to the project cd mylib # Install dependencies and start development server bun install bun run dev // In src/index.ts (example content): export const sum = (a: number, b: number): number => a + b; export const multiply = (a: number, b: number): number => a * b; console.log(sum(1, 2)); // Should output 3