@wroud/vite-plugin-tsc brings the TypeScript compiler (tsc) to Vite. Vite's default esbuild pipeline skips type checking, so this plugin can run tsc to surface type errors during development or builds. It can also transpile TypeScript files that Vite then bundles, keeping all Vite features intact. The plugin supports TypeScript project references.
- Type checking: Run
tscin the background to catch type errors that esbuild ignores. - Transpilation: Transpile TypeScript files with
tscand let Vite bundle the output.
- Transpilation: Automatically transpiles TypeScript code using
tsc. - Project References: Supports TypeScript project references.
- Background Type Checking: Performs type checking in the background without blocking Vite, allowing for a smoother development experience.
- Watch Mode: Supports watch mode for continuous development.
- Easy Integration: Simple to add to your Vite project.
Install via npm:
npm install @wroud/vite-plugin-tscInstall via yarn:
yarn add @wroud/vite-plugin-tscFor detailed usage and API reference, visit the documentation site.
import { defineConfig } from "vite";
import { tscPlugin } from "@wroud/vite-plugin-tsc";
export default defineConfig({
plugins: [
tscPlugin({
tscArgs: ["-b"],
// Enable prebuild to ensure dependencies are built before Vite starts bundling
prebuild: true, // Recommended for projects with TypeScript project references
}),
],
});import { defineConfig } from "vite";
import { tscPlugin } from "@wroud/vite-plugin-tsc";
export default defineConfig({
plugins: [
tscPlugin({
tscArgs: ["--project", "tsconfig.json"],
// Prebuild is not needed for type checking only
prebuild: false, // Skip prebuilding for faster startup
enableOverlay: true, // Show errors in Vite overlay
}),
],
});All notable changes to this project will be documented in the CHANGELOG file.
This project is licensed under the MIT License. See the LICENSE file for details.