docs: clarify tsconfig transform settings - #1698
Conversation
Deploying rstest with
|
| Latest commit: |
49ee3a6
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://4d2daf35.rstest.pages.dev |
| Branch Preview URL: | https://9aoy-docs-tsconfig-transform.rstest.pages.dev |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9242ad7bac
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| 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 use other `compilerOptions` to configure code transformation. Configure the output target with [`tools.swc`](/config/build/tools#toolsswc), and configure decorator syntax explicitly with [`source.decorators`](#sourcedecorators). For example, a project that uses a legacy decorator transform and ES2020 output can use: |
There was a problem hiding this comment.
Account for the Rslib adapter's decorator inference
When users reuse an Rslib configuration through @rstest/adapter-rslib, this blanket statement is incorrect: withRslibConfig loads the configured/default tsconfig and maps compilerOptions.experimentalDecorators to source.decorators.version = 'legacy' when neither the Rstest nor Rslib config specifies a decorator version. Clarify that explicit configuration is required for the default core path while documenting this adapter exception; otherwise Rslib users are told that a setting already inferred by their integration must be migrated manually.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a94715a35d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| jsc: { | ||
| target: 'es2020', |
There was a problem hiding this comment.
Avoid combining
jsc.target with Rsbuild's env target
In a normal direct Rstest project, Rsbuild already supplies env.targets: ['node >= 20'] to builtin:swc-loader (see packages/core/tests/core/__snapshots__/rsbuild.test.ts.snap lines 203–216), so merging this object leaves both env and jsc.target in the SWC options even though those target mechanisms are mutually exclusive. A user following this exact migration example can therefore get a compilation error instead of ES2020 output; configure env.targets or explicitly remove env before setting jsc.target.
Useful? React with 👍 / 👎.
|
|
||
| Rstest uses Rsbuild as the default test build tool instead of Vite. You can view all available build configuration options in [Build Configurations](/config/#build-configurations). | ||
|
|
||
| Vite reads selected `tsconfig.json` compiler options when transforming TypeScript. When configuring Rstest directly, it automatically uses `compilerOptions.paths` for module resolution, but does not use `target`, `experimentalDecorators`, or other compiler options to configure its transform. Move those settings to `tools.swc` and `source.decorators`; adapters can inherit or infer additional settings, so refer to the documentation for the [adapter you use](/guide/integration/adapters). See [source.tsconfigPath](/config/build/source#sourcetsconfigpath). If your Vitest config enables Vite's TypeScript paths support or uses a `vite-tsconfig-paths` plugin, remove that Vite-specific setup after confirming the Rstest project uses the intended `tsconfig.json`. |
There was a problem hiding this comment.
Do not migrate TypeScript target as a Vite transform setting
For Vitest projects whose only target setting is compilerOptions.target, Vite's esbuild transform does not use that field to select its output target; Vite controls this through esbuild.target (and build.target for builds). Grouping target with compiler options such as experimentalDecorators and telling users to move it therefore introduces downleveling that was not present in their Vitest run and can change emitted syntax or runtime behavior. Limit this instruction to tsconfig options Vite actually honors and map Vite's real target option separately.
Useful? React with 👍 / 👎.
Summary
Rstest resolves
compilerOptions.pathsfrom the activetsconfig.json, but transform-related compiler options are not imported automatically. This updates the source configuration reference and Jest/Vitest migration guides with the explicittools.swcandsource.decoratorssetup needed for target and decorator behavior.Checklist