{"id":22901,"library":"vite-plugin-typescript","title":"vite-plugin-typescript","description":"A thin wrapper around @rollup/plugin-typescript that improves compatibility with Vite and Vitest. Current stable version 1.0.4. Designed to fix watch mode issues when running Vitest, ensuring proper cleanup and type-safe compilation. Key differentiator: it disables esbuild for Vitest and prevents unsafe watch mode behavior, addressing a specific gap in the Vite ecosystem. Recommended for use in build mode only, not for development due to poor HMR. Depends on vite and @rollup/plugin-typescript as peer dependencies.","status":"active","version":"1.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/wight554/vite-plugin-typescript","tags":["javascript","typescript"],"install":[{"cmd":"npm install vite-plugin-typescript","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-typescript","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-typescript","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required by the plugin to integrate with Vite","package":"vite","optional":false},{"reason":"Peer dependency; the plugin wraps and extends this rollup plugin","package":"@rollup/plugin-typescript","optional":false}],"imports":[{"note":"ESM-only; package does not provide a CommonJS export. TypeScript types are included.","wrong":"const typescript = require('vite-plugin-typescript')","symbol":"typescript","correct":"import typescript from 'vite-plugin-typescript'"},{"note":"The plugin exports a default function only. Named import will result in undefined.","wrong":"import { typescript } from 'vite-plugin-typescript'","symbol":"default import","correct":"import typescript from 'vite-plugin-typescript'"}],"quickstart":{"code":"import { defineConfig } from 'vite';\nimport typescript from 'vite-plugin-typescript';\n\nexport default defineConfig({\n  plugins: [\n    {\n      ...typescript(),\n      apply: 'build'\n    }\n  ]\n});","lang":"typescript","description":"Example Vite config using vite-plugin-typescript only for build mode with proper conditional application."},"warnings":[{"fix":"Apply plugin only in build mode using the `apply: 'build'` option, or conditionally for test environments.","message":"Plugin does not work well with HMR in development mode; use only for build or Vitest.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Install the peer dependency: npm install --save-dev @rollup/plugin-typescript","message":"Requires @rollup/plugin-typescript as a peer dependency; must be installed separately.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"If you need watch mode in Vitest, do not use this plugin.","message":"Watch mode is disabled when running in Vitest environment; this is intentional but may surprise users expecting watch mode behavior.","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":"Use `import typescript from 'vite-plugin-typescript'` instead of `import { typescript } from 'vite-plugin-typescript'`.","cause":"Using named import instead of default import.","error":"TypeError: (0 , plugin_default) is not a function"},{"fix":"Install the peer dependency: npm install --save-dev @rollup/plugin-typescript","cause":"Missing peer dependency @rollup/plugin-typescript.","error":"Error: Cannot find module '@rollup/plugin-typescript'"},{"fix":"Ensure your project is configured as ESM (type: 'module' in package.json) or use dynamic import().","cause":"Trying to require an ESM-only package with require().","error":"[vite] Internal server error: Cannot use esm in cjs mode"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}