unplugin-dts

unplugin-dts
18,163,029 1,531
Install
npm install unplugin-dts
Latest Version:1.1.2
License:MIT
Last Updated:Oct 3, 2026
Links: GitHub  ·  npm
Maintainer: qmhc

unplugin-dts

An unplugin that generates declaration files (*.d.ts) from .ts(x) or .vue source files when using library mode.

version version license

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.

When moduleFormat is omitted, the plugin preserves TypeScript's declaration extensions: .ts → .d.ts, .mts → .d.mts, and .cts → .d.cts, including declaration maps.

Declaration maps preserve absolute file:// source URLs, including Windows cross-drive paths, across all output directories.

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!

contributors

A real project using this plugin: Vexip UI.

License

MIT License.

Related Packages

unplugin-lightningcss

Lightning CSS integration for Vite, Rollup, esbuild, Webpack, Vue CLI, and more.

1,880,181 29
unplugin-time-stat

Build time stat reporting for unplugin

194,430 13
unplugin-strip-whitespace

Unplugin to strip inter-node whitespace in Astro and Svelte templates (Vite/Roll...

787 0
vite-plugin-dts

vite-plugin-dts

147,380,553 1,531

Version History

Version Released License
1.1.2 MIT
1.1.1 MIT
1.1.0 MIT
1.0.3 MIT
1.0.2 MIT
Pre-releases (7)
Version Released License
1.0.0-beta.6 MIT
1.0.0-beta.5 MIT
1.0.0-beta.4 MIT
1.0.0-beta.3 MIT
1.0.0-beta.2 MIT