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.
npm install vite-plugin-typescriptVerified import paths — ran on the pinned version, not inferred.
Example Vite config using vite-plugin-typescript only for build mode with proper conditional application.
Apply plugin only in build mode using the `apply: 'build'` option, or conditionally for test environments.
Install the peer dependency: npm install --save-dev @rollup/plugin-typescript
If you need watch mode in Vitest, do not use this plugin.
Use `import typescript from 'vite-plugin-typescript'` instead of `import { typescript } from 'vite-plugin-typescript'`.Install the peer dependency: npm install --save-dev @rollup/plugin-typescript
Ensure your project is configured as ESM (type: 'module' in package.json) or use dynamic import().