Registry / web-framework / vite-plugin-typescript-transform

vite-plugin-typescript-transform

JSON →
library1.3.1jsnpmunverified

vite-plugin-typescript-transform is a Vite plugin designed to integrate the full TypeScript compiler into the Vite build transform phase. Its primary purpose is to enable advanced TypeScript features, such as the new ECMAScript decorators, that Vite's default transpiler, esbuild, might not yet support. The plugin operates by transpiling code using the TypeScript compiler before esbuild processes it, allowing developers to leverage the latest TypeScript syntax without waiting for esbuild updates. Currently at version 1.3.1, the package demonstrates active maintenance with several releases in the past year addressing bug fixes and feature enhancements, such as improved tsconfig parsing. It functions as an augmentation to Vite's pipeline, rather than a replacement, and requires careful configuration of plugin order to ensure correct operation.

npm install vite-plugin-typescript-transform
INSTALL
IMPORT
SIG · VITE-PLUGIN-TYPESC
V
vite-plugin-typescript-transform
web-frameworkjavascriptv1.3.1
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

vitePluginTypescriptTransform
import { vitePluginTypescriptTransform } from 'vite-plugin-typescript-transform';
const vitePluginTypescriptTransform = require('vite-plugin-typescript-transform');
This plugin is designed for ESM contexts within Vite configurations.
defineConfig
import { defineConfig } from 'vite';
Standard Vite utility for defining configuration, commonly used with this plugin.
ts
import ts from 'typescript';
Often imported to access TypeScript's enums (e.g., ScriptTarget) for plugin options, as seen in the examples.

Demonstrates how to configure the plugin in `vite.config.ts` to apply TypeScript transformation, specifically highlighting the use of `enforce: 'pre'` and `tsconfig.override` for features like ECMAScript decorators.

import ts from 'typescript'; import { defineConfig } from 'vite'; import { vitePluginTypescriptTransform } from 'vite-plugin-typescript-transform'; export default defineConfig({ plugins: [ vitePluginTypescriptTransform({ enforce: 'pre', filter: { files: { include: /\.ts$/, }, }, tsconfig: { override: { target: ts.ScriptTarget.ES2021, // Enable new ECMAScript decorators support if needed // 'experimentalDecorators' is for legacy decorators // 'useDefineForClassFields' often needed for new decorators // For new decorators, ensure TypeScript version is >=5.0 }, }, }), ], // ... other vite configuration });
Debug
Known issues
breakingThe initial v1.0.0 release introduced the core plugin functionality. While not a breaking change from a previous version of this plugin, it established the first stable API, meaning any significant changes in subsequent major versions would be considered breaking against this baseline.
fix
Refer to the plugin's documentation for any specific migration paths when upgrading from 1.x to future major versions.
affects: 1.0.0
gotchaThis plugin must be configured to run before Vite's default esbuild transpilation to properly apply TypeScript transformations for features not supported by esbuild. Failing to do so can result in syntax errors or incorrect output.
fix
Always include `enforce: 'pre'` in the plugin configuration within your `vite.config.ts` file.
affects: >=1.0.0
gotchaThe plugin does not disable or replace Vite's built-in esbuild compiler. It only pre-processes code using the TypeScript compiler. Esbuild will still process the output from this plugin. Ensure your TypeScript `target` and `tsconfig.override` options align with what esbuild can ultimately handle after the initial TS compilation step.
fix
Carefully consider your `tsconfig` options (especially `target`) within the `tsconfig.override` to produce output compatible with esbuild and your target runtime environment.
affects: >=1.0.0
gotchaEarlier versions had issues correctly parsing `tsconfig.json` files that used the `extends` property or respecting the `tsconfig.override` option.
fix
Upgrade to `v1.3.1` or later to ensure proper handling of `tsconfig.json` extends and `tsconfig.override` functionality. If unable to upgrade, flatten your `tsconfig.json` or manually apply all relevant compiler options.
affects: <1.3.1
Errors
Common errors & fixes
Syntax Error: Unexpected token '@'
Using new ECMAScript decorators (or legacy decorators with improper configuration) that esbuild does not support, and `vite-plugin-typescript-transform` either isn't configured correctly or is running too late.
fix
Ensure `vite-plugin-typescript-transform` is installed, correctly imported, and configured with `enforce: 'pre'` in your `vite.config.ts`. Additionally, set appropriate TypeScript `target` and `compilerOptions` (e.g., for new decorators, `"target": "ES2021"` or higher in `tsconfig.override`).
Error: Plugin 'vite-plugin-typescript-transform' is not processing files, or TypeScript features are not being transpiled as expected.
The plugin's configuration is incorrect, or its execution order is clashing with other Vite plugins or Vite's default behavior.
fix
Verify that `enforce: 'pre'` is set in the plugin configuration. Check the `filter` options to ensure the correct file types (e.g., `.ts` files) are being included for transformation. Review `tsconfig.override` for desired `compilerOptions`.
Failed to parse tsconfig.json: 'extends' is not supported (or similar error regarding tsconfig structure).
Using `extends` in `tsconfig.json` with an older version of the plugin that did not fully support this feature.
fix
Upgrade to `vite-plugin-typescript-transform` version 1.3.0 or higher, which introduced support for the `extends` property in `tsconfig.json`.
Upgrade
Version history
1.3.1latest on npm
Audit
Dependencies
typescriptrequiredRequired as a peer dependency to perform TypeScript compilation.
viterequiredRequired as a peer dependency, as this is a Vite plugin.
Agent activity
5 hits · last 30 days
node
4
OpenAI (training)
1
Resources
vite-plugin-typescript-transform — npm install vite-plugin-typescript-transform · libregistry