{"id":22642,"library":"vite-plugin-dts-build","title":"vite-plugin-dts-build","description":"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.","status":"active","version":"0.2.3","language":"javascript","source_language":"en","source_url":"https://github.com/black7375/vite-plugin-dts-build","tags":["javascript","vite","plugin","vite-plugin","dts","typescript","tsc","build","incremental"],"install":[{"cmd":"npm install vite-plugin-dts-build","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-dts-build","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-dts-build","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; used for type checking and declaration generation","package":"typescript","optional":false},{"reason":"peer dependency; the plugin integrates with Vite's build pipeline","package":"vite","optional":false}],"imports":[{"note":"Default export; CJS require works for v0.2.x but ESM is preferred","wrong":"const vitePluginDtsBuild = require('vite-plugin-dts-build')","symbol":"vitePluginDtsBuild","correct":"import vitePluginDtsBuild from 'vite-plugin-dts-build'"},{"note":"Named import is not available; use default import","wrong":"import { vitePluginDtsBuild } from 'vite-plugin-dts-build'","symbol":"vitePluginDtsBuild","correct":"import { default as vitePluginDtsBuild } from 'vite-plugin-dts-build'"},{"note":"Only type import for TypeScript users","wrong":null,"symbol":"type PluginOptions","correct":"import type { PluginOptions } from 'vite-plugin-dts-build'"}],"quickstart":{"code":"// vite.config.ts\nimport { defineConfig } from 'vite';\nimport vitePluginDtsBuild from 'vite-plugin-dts-build';\n\nexport default defineConfig({\n  plugins: [\n    vitePluginDtsBuild({\n      // Enable for library dual output (ESM + CJS)\n      rollupTypes: true,\n      dtsForCjs: true,\n    }),\n  ],\n});","lang":"typescript","description":"Configure vite-plugin-dts-build in a Vite project with dual ESM/CJS declaration output enabled."},"warnings":[{"fix":"Update CI to handle multiple errors or set `onError: 'fail'` if available (check docs).","message":"In 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.","severity":"breaking","affected_versions":">=0.2.0"},{"fix":"Monitor changelog and migrate to new option name when released.","message":"In future versions, the `rollupTypes` option may be renamed. See changelog for v0.2.0.","severity":"deprecated","affected_versions":">=0.2.0"},{"fix":"Ensure Node.js >=12 or disable dtsForCjs.","message":"Dual 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.","severity":"gotcha","affected_versions":">=0.2.0"},{"fix":"Use Node.js 12+ or add fallback worker polyfill.","message":"The plugin uses a worker thread. Ensure your build environment supports worker_threads (Node >=12).","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run `npm install vite-plugin-dts-build --save-dev` and ensure it's in devDependencies.","cause":"Package not installed or missing from dependencies.","error":"Error: Cannot find module 'vite-plugin-dts-build'"},{"fix":"Use default import: `import vitePluginDtsBuild from 'vite-plugin-dts-build'`","cause":"Incorrect import (named instead of default) or CJS require with wrong name.","error":"TypeError: vitePluginDtsBuild is not a function"},{"fix":"Set `rollupTypes: true` when using `dtsForCjs: true`.","cause":"Incompatible plugin options: dtsForCjs without rollupTypes.","error":"Error: The 'dtsForCjs' option requires 'rollupTypes' to be true"},{"fix":"Check TypeScript configuration and ensure no syntax errors; set `onError: 'warn'` for debugging.","cause":"TypeScript or plugin error causing worker crash.","error":"Error: Worker thread exited unexpectedly"},{"fix":"Configure path aliases in Vite's resolve.alias and ensure they match tsconfig paths.","cause":"Path alias not resolved in type declarations.","error":"Module not found: Can't resolve '@/components/...' in ..."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}