vite-plugin-typescript-transform
v1.3.1
Published
Applies the TypeScript compiler during Vite transform build phase.
Downloads
3,300
Maintainers
Readme
vite-plugin-typescript-transform
Applies the TypeScript compiler during Vite transform build phase.
This plugin may allow the use of language features not yet supported by vite's
default compiler, esbuild
.
Install
npm install --save-dev vite-plugin-typescript-transform
Options
See the Options
interface and its inline documentation.
Warning
This plugin does not change or disable any of vite's
compiler/features/options. It only transpiles the code using the typescript
compiler and lets vite
move on with the transpiled code.
Transform ECMAScript decorators
The new ECMAScript decorators are not supported by esbuild
(yet), but they are supported by typescript
since v5
(see the announcement). This example down-levels the new decorators into code that is usable in runtimes that do not yet support it.
import ts from 'typescript';
import { defineConfig } from 'vite';
import { vitePluginTypescriptTransform } from 'vite-plugin-typescript-transform';
export default defineConfig({
// ...your vite configuration
plugins: [
vitePluginTypescriptTransform({
enforce: 'pre',
filter: {
files: {
include: /\.ts$/,
},
},
tsconfig: {
override: {
target: ts.ScriptTarget.ES2021,
},
},
}),
],
});