> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# source

Options for input source code.

## source.decorators [![source.decorators](https://assets.rspack.rs/rsbuild/rsbuild-logo.svg)source.decorators](https://rsbuild.rs/config/source/decorators)
Used to configure the decorators syntax.

If you are using TypeScript's [experimentalDecorators](https://www.typescriptlang.org/tsconfig/#experimentalDecorators), you should set `source.decorators.version` to `legacy` in this case.

## source.assetsInclude [![source.assetsInclude](https://assets.rspack.rs/rsbuild/rsbuild-logo.svg)source.assetsInclude](https://rsbuild.rs/config/source/assets-include)

[Added in v0.9.6](https://github.com/web-infra-dev/rstest/releases/tag/v0.9.6)

Specify additional files that should be treated as static assets.

This is useful when your tests import file types that are not included in Rsbuild's default asset handling, such as `.txt` or `.md`.

```ts
import { defineConfig } from '@rstest/core';

export default defineConfig({
  source: {
    assetsInclude: /\.(txt|md)$/,
  },
});
```

If you already reuse Rsbuild or Rslib config through `@rstest/adapter-rsbuild` or `@rstest/adapter-rslib`, `source.assetsInclude` will be inherited automatically.

## source.define [![source.define](https://assets.rspack.rs/rsbuild/rsbuild-logo.svg)source.define](https://rsbuild.rs/config/source/define)
Replaces variables in your code with other values or expressions at compile time. This can be useful for injecting env variables and other information to the code during build time.

## source.exclude [![source.exclude](https://assets.rspack.rs/rsbuild/rsbuild-logo.svg)source.exclude](https://rsbuild.rs/config/source/exclude)
Exclude JavaScript or TypeScript files that do not need to be transformed by [SWC](https://rsbuild.rs/guide/configuration/swc).

::: note

Files configured in `source.exclude` will not be transformed by SWC, but the referenced files will still be bundled into the outputs.

If you want certain files not to be bundled into the outputs, you can use [output.externals](/config/build/output.md#outputexternals) or Rspack's [IgnorePlugin](https://rspack.rs/plugins/webpack/ignore-plugin).

:::

## source.include [![source.include](https://assets.rspack.rs/rsbuild/rsbuild-logo.svg)source.include](https://rsbuild.rs/config/source/include)
Specify additional JavaScript files that need to be compiled.

## source.transformImport [![source.transformImport](https://assets.rspack.rs/rsbuild/rsbuild-logo.svg)source.transformImport](https://rsbuild.rs/config/source/transform-import)

[Added in v0.9.6](https://github.com/web-infra-dev/rstest/releases/tag/v0.9.6)

Configure on-demand import transforms.

```ts title="rstest.config.ts"
import { defineConfig } from '@rstest/core';

export default defineConfig({
  source: {
    transformImport: [
      {
        libraryName: 'demo-lib',
        libraryDirectory: '.',
        camelToDashComponentName: false,
      },
    ],
  },
});
```

:::caution

`source.transformImport` rewrites the final module request at compile time.

In the current implementation, module-level mocking APIs that still use the original specifier, such as `rs.mock('pkg')`, `rs.doMock('pkg')`, `rs.importActual('pkg')`, and `rs.requireActual('pkg')`, may no longer target the transformed module request.

:::

## source.tsconfigPath [![source.tsconfigPath](https://assets.rspack.rs/rsbuild/rsbuild-logo.svg)source.tsconfigPath](https://rsbuild.rs/config/source/tsconfig-path)
- **CLI:** `--source.tsconfigPath <path>`

Configure a custom `tsconfig.json` file path to use, can be a relative or absolute path.

When this option is not set, Rstest detects `tsconfig.json` in each project's root. Its `compilerOptions.paths` mappings are used for module resolution.

Rstest does not automatically turn other `compilerOptions` into code transformation settings. Configure the relevant Rstest build options when they are needed, including [`source.decorators`](#sourcedecorators) for decorator syntax and [`tools.swc`](/config/build/tools.md#toolsswc) for SWC options such as output-target requirements. An adapter may map or infer additional build options; refer to the documentation for the [adapter you use](/guide/advanced/adapters.md). For example, a directly configured project that uses legacy decorators can use:

```ts title="rstest.config.ts"
import { defineConfig } from '@rstest/core';

export default defineConfig({
  source: {
    decorators: {
      version: 'legacy',
    },
  },
});
```
