Applies the typescript compiler during vite transform build phase.
npm install --save-dev vite-plugin-typescript-transform
See the Options
interface.
As of now, vite
uses esbuild
to transpile typescript, which doesn't yet support the new ECMAScript decorators.
But typescript
added support for them in v5
.
This example transpiles the new ECMAScript decorators into code that is usable in runtimes that do not yet support it.
import { vitePluginTypescriptTransform } from 'vite-plugin-typescript-transform';
import { defineConfig } from 'vitest/config';
export default defineConfig({
// ...your vite configuration
plugins: [
vitePluginTypescriptTransform({
enfore: 'pre',
filter: {
files: {
include: /\.ts$/,
},
},
tsconfig: {
override: {
target: 'ES2021',
},
},
}),
],
});