{"id":22550,"library":"vite-dts-plugin","title":"vite-dts-plugin","description":"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.","status":"active","version":"1.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/silverwind/vite-dts-plugin","tags":["javascript","typescript"],"install":[{"cmd":"npm install vite-dts-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add vite-dts-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-dts-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; required as a Vite plugin.","package":"vite","optional":false},{"reason":"Uses the TypeScript compiler (tsc) to generate declarations.","package":"typescript","optional":false}],"imports":[{"note":"The plugin is exported as a named export. CommonJS require is possible but discouraged; ESM is preferred.","wrong":"const dtsPlugin = require('vite-dts-plugin').dtsPlugin","symbol":"dtsPlugin","correct":"import { dtsPlugin } from 'vite-dts-plugin'"},{"note":"Options is a TypeScript type, not a runtime value. Use 'import type' or 'import { type Options }'.","wrong":"import { Options } from 'vite-dts-plugin'","symbol":"Options","correct":"import type { Options } from 'vite-dts-plugin'"}],"quickstart":{"code":"// vite.config.ts\nimport { defineConfig } from 'vite';\nimport { dtsPlugin } from 'vite-dts-plugin';\n\nexport default defineConfig({\n  build: {\n    lib: {\n      entry: 'src/index.ts',\n      formats: ['es'],\n    },\n  },\n  plugins: [\n    dtsPlugin({\n      outDir: 'dist',\n      tsc: 'tsc',\n    }),\n  ],\n});","lang":"typescript","description":"Configures Vite with the dtsPlugin for a library build, generating type declarations in the dist folder."},"warnings":[{"fix":"Ensure outDir is same as Vite's build.outDir (default 'dist').","message":"The outDir option must match the directory where your built output (JS) is placed, otherwise types may reference missing paths.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Add 'typescript' as a devDependency.","message":"The plugin runs tsc under the hood; it does not run Vite's build itself. You must have TypeScript installed separately.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Pass a string filename (e.g., 'tsconfig.build.json') or leave undefined to use default tsconfig.","message":"Custom tsConfig option expects a string path, not a parsed config object. Passing an object will throw.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Only pass known tsc options, e.g., ['--declaration', '--emitDeclarationOnly'].","message":"The args option is passed as additional CLI arguments to tsc; ensure they are valid tsc flags. Invalid flags cause silent failures.","severity":"gotcha","affected_versions":">=0.0.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 --save-dev typescript'.","cause":"TypeScript is not installed.","error":"Error: Cannot find module 'typescript'"},{"fix":"Install TypeScript and ensure node_modules/.bin is in PATH, or specify a custom tsc path with the 'tsc' option.","cause":"TypeScript binary not in PATH or not installed.","error":"Error: tsc: command not found"},{"fix":"Use named import: import { dtsPlugin } from 'vite-dts-plugin'.","cause":"Importing incorrectly, e.g., default import instead of named import.","error":"TypeError: dtsPlugin is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}