Registry / devops / vite-plugin-typescript

vite-plugin-typescript

JSON →
library1.0.4jsnpmunverified

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-typescript
INSTALL
IMPORT
SIG · VITE-PLUGIN-TYPESC
V
vite-plugin-typescript
devopsjavascriptv1.0.4
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

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

typescript
import typescript from 'vite-plugin-typescript'
const typescript = require('vite-plugin-typescript')
ESM-only; package does not provide a CommonJS export. TypeScript types are included.
default import
import typescript from 'vite-plugin-typescript'
import { typescript } from 'vite-plugin-typescript'
The plugin exports a default function only. Named import will result in undefined.

Example Vite config using vite-plugin-typescript only for build mode with proper conditional application.

import { defineConfig } from 'vite'; import typescript from 'vite-plugin-typescript'; export default defineConfig({ plugins: [ { ...typescript(), apply: 'build' } ] });
Debug
Known issues
gotchaPlugin does not work well with HMR in development mode; use only for build or Vitest.
fix
Apply plugin only in build mode using the `apply: 'build'` option, or conditionally for test environments.
affects: >=0.0.0
gotchaRequires @rollup/plugin-typescript as a peer dependency; must be installed separately.
fix
Install the peer dependency: npm install --save-dev @rollup/plugin-typescript
affects: >=0.0.0
gotchaWatch mode is disabled when running in Vitest environment; this is intentional but may surprise users expecting watch mode behavior.
fix
If you need watch mode in Vitest, do not use this plugin.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: (0 , plugin_default) is not a function
Using named import instead of default import.
fix
Use `import typescript from 'vite-plugin-typescript'` instead of `import { typescript } from 'vite-plugin-typescript'`.
Error: Cannot find module '@rollup/plugin-typescript'
Missing peer dependency @rollup/plugin-typescript.
fix
Install the peer dependency: npm install --save-dev @rollup/plugin-typescript
[vite] Internal server error: Cannot use esm in cjs mode
Trying to require an ESM-only package with require().
fix
Ensure your project is configured as ESM (type: 'module' in package.json) or use dynamic import().
Upgrade
Version history
1.0.4latest on npm
Audit
Dependencies
viterequiredPeer dependency required by the plugin to integrate with Vite
@rollup/plugin-typescriptrequiredPeer dependency; the plugin wraps and extends this rollup plugin
Agent activity
4 hits · last 30 days
node
4
Resources
vite-plugin-typescript — npm install vite-plugin-typescript · libregistry