{"id":12374,"library":"vite-plugin-typescript-transform","title":"Vite TypeScript Transform Plugin","description":"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.","status":"active","version":"1.3.1","language":"javascript","source_language":"en","source_url":"https://github.com/herberttn/vite-plugin-typescript-transform","tags":["javascript","code","compiler","decorators","es","esm","js","module","typescript"],"install":[{"cmd":"npm install vite-plugin-typescript-transform","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-typescript-transform","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-typescript-transform","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required as a peer dependency to perform TypeScript compilation.","package":"typescript","optional":false},{"reason":"Required as a peer dependency, as this is a Vite plugin.","package":"vite","optional":false}],"imports":[{"note":"This plugin is designed for ESM contexts within Vite configurations.","wrong":"const vitePluginTypescriptTransform = require('vite-plugin-typescript-transform');","symbol":"vitePluginTypescriptTransform","correct":"import { vitePluginTypescriptTransform } from 'vite-plugin-typescript-transform';"},{"note":"Standard Vite utility for defining configuration, commonly used with this plugin.","symbol":"defineConfig","correct":"import { defineConfig } from 'vite';"},{"note":"Often imported to access TypeScript's enums (e.g., ScriptTarget) for plugin options, as seen in the examples.","symbol":"ts","correct":"import ts from 'typescript';"}],"quickstart":{"code":"import ts from 'typescript';\nimport { defineConfig } from 'vite';\nimport { vitePluginTypescriptTransform } from 'vite-plugin-typescript-transform';\n\nexport default defineConfig({\n  plugins: [\n    vitePluginTypescriptTransform({\n      enforce: 'pre',\n      filter: {\n        files: {\n          include: /\\.ts$/,\n        },\n      },\n      tsconfig: {\n        override: {\n          target: ts.ScriptTarget.ES2021,\n          // Enable new ECMAScript decorators support if needed\n          // 'experimentalDecorators' is for legacy decorators\n          // 'useDefineForClassFields' often needed for new decorators\n          // For new decorators, ensure TypeScript version is >=5.0\n        },\n      },\n    }),\n  ],\n  // ... other vite configuration\n});","lang":"typescript","description":"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."},"warnings":[{"fix":"Refer to the plugin's documentation for any specific migration paths when upgrading from 1.x to future major versions.","message":"The 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.","severity":"breaking","affected_versions":"1.0.0"},{"fix":"Always include `enforce: 'pre'` in the plugin configuration within your `vite.config.ts` file.","message":"This 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Carefully consider your `tsconfig` options (especially `target`) within the `tsconfig.override` to produce output compatible with esbuild and your target runtime environment.","message":"The 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"Earlier versions had issues correctly parsing `tsconfig.json` files that used the `extends` property or respecting the `tsconfig.override` option.","severity":"gotcha","affected_versions":"<1.3.1"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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`).","cause":"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.","error":"Syntax Error: Unexpected token '@'"},{"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`.","cause":"The plugin's configuration is incorrect, or its execution order is clashing with other Vite plugins or Vite's default behavior.","error":"Error: Plugin 'vite-plugin-typescript-transform' is not processing files, or TypeScript features are not being transpiled as expected."},{"fix":"Upgrade to `vite-plugin-typescript-transform` version 1.3.0 or higher, which introduced support for the `extends` property in `tsconfig.json`.","cause":"Using `extends` in `tsconfig.json` with an older version of the plugin that did not fully support this feature.","error":"Failed to parse tsconfig.json: 'extends' is not supported (or similar error regarding tsconfig structure)."}],"ecosystem":"npm"}