Registry / devops / vite-plugin-dts-build

vite-plugin-dts-build

JSON →
library0.2.3jsnpmunverified

A Vite plugin for building .d.ts declaration files using a worker thread with incremental compilation for performance. Currently at v0.2.3, released January 2025. It supports optional dual ESM/CJS output for libraries, source maps, and improved error reporting. Compared to alternatives like vite-plugin-dts, it focuses on speed via worker-based incremental builds and explicit control over format redirection. Requires TypeScript and Vite as peer dependencies. The plugin is under active development with frequent updates.

npm install vite-plugin-dts-build
INSTALL
IMPORT
SIG · VITE-PLUGIN-DTS-BU
V
vite-plugin-dts-build
devopsjavascriptv0.2.3
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

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

vitePluginDtsBuild
✓ import vitePluginDtsBuild from 'vite-plugin-dts-build'
✗ const vitePluginDtsBuild = require('vite-plugin-dts-build')
Default export; CJS require works for v0.2.x but ESM is preferred
vitePluginDtsBuild
✓ import { default as vitePluginDtsBuild } from 'vite-plugin-dts-build'
✗ import { vitePluginDtsBuild } from 'vite-plugin-dts-build'
Named import is not available; use default import
type PluginOptions
✓ import type { PluginOptions } from 'vite-plugin-dts-build'
Only type import for TypeScript users

Configure vite-plugin-dts-build in a Vite project with dual ESM/CJS declaration output enabled.

// vite.config.ts import { defineConfig } from 'vite'; import vitePluginDtsBuild from 'vite-plugin-dts-build'; export default defineConfig({ plugins: [ vitePluginDtsBuild({ // Enable for library dual output (ESM + CJS) rollupTypes: true, dtsForCjs: true, }), ], });
Debug
Known issues
breakingIn v0.2.0, error behavior changed: instead of stopping on first error, all errors are printed. This may break CI scripts that expect immediate exit.
fix
Update CI to handle multiple errors or set `onError: 'fail'` if available (check docs).
affects: >=0.2.0
deprecatedIn future versions, the `rollupTypes` option may be renamed. See changelog for v0.2.0.
fix
Monitor changelog and migrate to new option name when released.
affects: >=0.2.0
gotchaDual mode (dtsForCjs) creates a package.json redirect for Node10 resolution. This may cause unexpected behavior if your project uses older Node.js or custom resolution.
fix
Ensure Node.js >=12 or disable dtsForCjs.
affects: >=0.2.0
gotchaThe plugin uses a worker thread. Ensure your build environment supports worker_threads (Node >=12).
fix
Use Node.js 12+ or add fallback worker polyfill.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'vite-plugin-dts-build'
Package not installed or missing from dependencies.
fix
Run `npm install vite-plugin-dts-build --save-dev` and ensure it's in devDependencies.
TypeError: vitePluginDtsBuild is not a function
Incorrect import (named instead of default) or CJS require with wrong name.
fix
Use default import: `import vitePluginDtsBuild from 'vite-plugin-dts-build'`
Error: The 'dtsForCjs' option requires 'rollupTypes' to be true
Incompatible plugin options: dtsForCjs without rollupTypes.
fix
Set `rollupTypes: true` when using `dtsForCjs: true`.
Error: Worker thread exited unexpectedly
TypeScript or plugin error causing worker crash.
fix
Check TypeScript configuration and ensure no syntax errors; set `onError: 'warn'` for debugging.
Module not found: Can't resolve '@/components/...' in ...
Path alias not resolved in type declarations.
fix
Configure path aliases in Vite's resolve.alias and ensure they match tsconfig paths.
Upgrade
Version history
0.2.3latest on npm
Audit
Dependencies
typescriptrequiredpeer dependency; used for type checking and declaration generation
viterequiredpeer dependency; the plugin integrates with Vite's build pipeline
Agent activity
10 hits · last 30 days
node
10
Resources
vite-plugin-dts-build — npm install vite-plugin-dts-build · libregistry