gitmyhub

tsdx

TypeScript ★ 11k updated 4mo ago

Zero-config CLI for TypeScript package development

A command-line tool that sets up and builds TypeScript packages for npm publishing, handling bundling, testing, linting, and formatting automatically so you can start writing code right away.

TypeScriptBunRollupSWCVitestoxlintsetup: easycomplexity 2/5

TSDX is a command-line tool that handles the setup and build process for TypeScript packages that you want to publish to npm. The idea is that starting a new TypeScript library involves a lot of boilerplate: configuring a bundler, setting up tests, deciding on code formatting and linting rules, and making sure the package output works for both modern and older JavaScript environments. TSDX does all of that for you so you can start writing code immediately.

Version 2.0 is a rewrite that swaps out the original tooling for faster alternatives. Bundling is handled by bunchee, which is built on top of Rollup and SWC. Testing uses vitest instead of Jest. Linting uses oxlint, described in the README as 50 to 100 times faster than ESLint. Formatting uses oxfmt. Package management relies on Bun. These are all Rust-based or Bun-native tools chosen for speed.

When you create a new project with TSDX, it generates a standard folder structure with source files in src/, tests in test/, and build output in dist/. The build command produces two output formats automatically: ESM for modern bundlers and module-aware Node.js, and CommonJS for older environments. TypeScript declaration files are included in the output as well, so consumers of your library get type information without extra steps. The package.json exports field is configured automatically to point to the right file for each use case.

Two project templates are available: a basic TypeScript library and a React component library. The React template includes a small demo application powered by Vite so you can develop and preview the component locally.

Requirements are Node.js 20 or newer and Bun installed. People upgrading from the original version of TSDX need to follow a migration guide, since the tooling changed significantly between v0.x and v2.0.

Where it fits