For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /integration/rspack/index.md.
close
  • English
  • Rspack

    Rspack is a high-performance JavaScript bundler written in Rust. It provides a webpack-compatible API and supports reusing webpack loaders and plugins.

    If your project uses Rspack, you can use Rstest to test it and reuse compatible compiler options from your Rspack configuration through an adapter. This reduces duplicate configuration and helps keep test compilation consistent with your project build.

    Quick start

    To add Rstest to an existing Rspack project, follow the Quick Start to install and set up test scripts.

    Reuse Rspack config

    @rstest/adapter-rspack loads your Rspack config and maps compatible options into the Rstest test compiler.

    Install adapter

    npm
    yarn
    pnpm
    bun
    deno
    npm add @rstest/adapter-rspack -D

    Extend your config

    rstest.config.ts
    import { defineConfig } from '@rstest/core';
    import { withRspackConfig } from '@rstest/adapter-rspack';
    
    export default defineConfig({
      extends: withRspackConfig(),
    });

    The adapter loads rspack.config.ts, merges compatible compiler options with the generated test build, and adds the loaded config file to forceRerunTriggers, so --changed runs the full test suite when that config changes.

    Warning

    Rstest uses Rsbuild internally, so the adapter keeps Rstest-owned test structure and always removes the built-in CSS plugins rsbuild:css, rsbuild:less, and rsbuild:sass. As a result, some Rsbuild-specific CSS options, such as output.cssModules, are unavailable.

    Use cwd, configPath, configName, or the environment options when the default Rspack config does not match your project. See the configuration reference for option details, mapping behavior, and debug instructions.

    Example project

    See the Rspack adapter example for a complete React project.