Rspack TypeScript Checker Plugin

1.3.0 · active · verified Sun Apr 19

The ts-checker-rspack-plugin is an essential Rspack plugin designed to accelerate TypeScript type checking by offloading it to a separate process. This approach significantly improves build performance, especially in larger projects. Currently stable at version 1.3.0, the package maintains an active release cadence, with frequent minor and patch updates addressing bug fixes, performance enhancements, and dependency updates. Key differentiators include its robust support for modern TypeScript features like project references and incremental mode, a visually appealing code frame formatter for error messages, and its origin as a fork of the widely used `fork-ts-checker-webpack-plugin`, specifically adapted for the Rspack ecosystem. It requires Node.js >=16.0.0+, Rspack ^1.0.0 || ^2.0.0-0, and TypeScript >=3.8.0 as peer dependencies.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates a minimal Rspack configuration integrating the ts-checker-rspack-plugin for TypeScript type checking with SWC loader, showing both basic setup and common configurations like tsconfig path and async mode.

import { TsCheckerRspackPlugin } from 'ts-checker-rspack-plugin';

export default {
  entry: './src/index.ts',
  resolve: {
    extensions: ['.ts', '.tsx', '.js'],
  },
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        loader: 'builtin:swc-loader',
        options: {
          jsc: {
            parser: {
              syntax: 'typescript',
              tsx: true // Enable TSX parsing if you're using React/Preact with TypeScript
            },
            transform: {
                react: {
                    runtime: 'automatic'
                }
            }
          },
          // Optional: specify target environment for SWC to match your project's browserlist/targets
          env: {
            targets: ['chrome 90', 'safari 15', 'firefox 90']
          }
        },
      },
    ],
  },
  plugins: [
    new TsCheckerRspackPlugin({
      // Optional: specify your tsconfig.json file path if it's not at the root
      typescript: {
        configFile: './tsconfig.json'
      },
      // Optional: Enable async mode for non-blocking type checking (default is false)
      async: false
    })
  ],
  // Performance optimization: prevent the plugin from infinitely rebuilding
  output: {
    path: './dist'
  }
};

view raw JSON →