Registry / devops / vite-dts-plugin

vite-dts-plugin

JSON →
library1.2.0jsnpmunverified

Vite plugin to generate TypeScript type definitions (.d.ts) for libraries and applications. Current stable version is 1.2.0, with monthly or bi-monthly releases. Zero-dependency plugin that wraps the TypeScript compiler (tsc) in a Vite plugin, generating declaration files on build. Differentiators: minimal configuration, no external dependencies, supports custom tsc binary, outDir, tsConfig, and additional tsc arguments. Ideal for library authors wanting a lightweight alternative to heavier plugins like vite-plugin-dts.

npm install vite-dts-plugin
INSTALL
IMPORT
SIG · VITE-DTS-PLUGIN
V
vite-dts-plugin
devopsjavascriptv1.2.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

dtsPlugin
import { dtsPlugin } from 'vite-dts-plugin'
const dtsPlugin = require('vite-dts-plugin').dtsPlugin
The plugin is exported as a named export. CommonJS require is possible but discouraged; ESM is preferred.
Options
import type { Options } from 'vite-dts-plugin'
import { Options } from 'vite-dts-plugin'
Options is a TypeScript type, not a runtime value. Use 'import type' or 'import { type Options }'.

Configures Vite with the dtsPlugin for a library build, generating type declarations in the dist folder.

// vite.config.ts import { defineConfig } from 'vite'; import { dtsPlugin } from 'vite-dts-plugin'; export default defineConfig({ build: { lib: { entry: 'src/index.ts', formats: ['es'], }, }, plugins: [ dtsPlugin({ outDir: 'dist', tsc: 'tsc', }), ], });
Debug
Known issues
gotchaThe outDir option must match the directory where your built output (JS) is placed, otherwise types may reference missing paths.
fix
Ensure outDir is same as Vite's build.outDir (default 'dist').
affects: >=0.0.0
gotchaThe plugin runs tsc under the hood; it does not run Vite's build itself. You must have TypeScript installed separately.
fix
Add 'typescript' as a devDependency.
affects: >=0.0.0
gotchaCustom tsConfig option expects a string path, not a parsed config object. Passing an object will throw.
fix
Pass a string filename (e.g., 'tsconfig.build.json') or leave undefined to use default tsconfig.
affects: >=0.0.0
gotchaThe args option is passed as additional CLI arguments to tsc; ensure they are valid tsc flags. Invalid flags cause silent failures.
fix
Only pass known tsc options, e.g., ['--declaration', '--emitDeclarationOnly'].
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'typescript'
TypeScript is not installed.
fix
Run 'npm install --save-dev typescript'.
Error: tsc: command not found
TypeScript binary not in PATH or not installed.
fix
Install TypeScript and ensure node_modules/.bin is in PATH, or specify a custom tsc path with the 'tsc' option.
TypeError: dtsPlugin is not a function
Importing incorrectly, e.g., default import instead of named import.
fix
Use named import: import { dtsPlugin } from 'vite-dts-plugin'.
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies
viterequiredPeer dependency; required as a Vite plugin.
typescriptrequiredUses the TypeScript compiler (tsc) to generate declarations.
Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
vite-dts-plugin — npm install vite-dts-plugin · libregistry