README.md
September 8, 2026 · View on GitHub
unplugin-dts
An unplugin that generates declaration files (*.d.ts) from .ts(x) or .vue source files when using library mode.
It evolved from vite-plugin-dts, and after being rewritten with unplugin, it has become more versatile.
English | 中文
Installation
Requires Node.js >= 20.
pnpm i -D unplugin-dts
Previous only for Vite (not recommend):
pnpm i -D vite-plugin-dts
Quick Start
import dts from 'unplugin-dts/vite'
export default defineConfig({
plugins: [dts()],
})
Supports Vite, Rollup, Rolldown, Webpack, Rspack and Esbuild. See Usage for detailed bundler setup.
To publish declarations for both ESM and CommonJS, configure both formats explicitly:
dts({
outDirs: [
{ dir: 'dist', moduleFormat: 'esm' },
{ dir: 'dist', moduleFormat: 'cjs' },
],
bundleTypes: true,
})
moduleFormat is not inferred from the bundler's JavaScript formats. The plugin writes the
configured declaration variants, while conditional exports.types entries remain package
metadata that you configure in package.json.
Documentation
- Usage - Installation and bundler configuration
- Options - Full plugin options reference
- FAQ - Frequently asked questions and solutions
- Migration (v4 → v5) - Migrating from vite-plugin-dts v4
Contributors
Thanks for all the contributions!
A real project using this plugin: Vexip UI.
License
MIT License.