Getting Started
Overview
Dtsbuild is a bundler for TypeScript declaration files. It can bundle .d.ts files (emitted by tsc) into a single file or multiple chunks for multiple entry points.
Bundling helps libraries that generate types to strip out internal and non-public types, resulting in smaller package sizes and less unnecessary types being exposed. It can also bundle types from external dependencies if only a subset of types are used.
See how dtsbuild compares with other existing toolings.
Project status
Beta. Not production ready, but usable for testing and feedback.
- Bundles most project types correctly, however bugs are expected.
- Missing features such as sourcemaps, good error reporting, and plugin support (with .e.g.
vue-tsc,svelte2tsx, etc). - Supports few popular OS architectures only for now:
x86_64-apple-darwinaarch64-apple-darwinx86_64-pc-windows-msvcx86_64-unknown-linux-gnuwasm32-wasip1-threads
Installation
$ npm install -D @dtsbuild/core$ yarn add -D @dtsbuild/core$ pnpm add -D @dtsbuild/coreRun the dtsbuild CLI command:
$ npx dtsbuild ./index.d.ts$ yarn dtsbuild ./index.d.ts$ pnpm dtsbuild ./index.d.tsTo invoke programmatically, create a new build script file, e.g. build-dts.mjs:
import { build } from '@dtsbuild/core'
await build({
entryPoints: ['./index.d.ts'],
})And run the script with Node.js:
$ node build-dts.mjsTo bundle .ts files, check out the usage guide for setup details and other common usage examples.