Skip to content

tsconfigRaw using rolldown vitest #10176

Closed
Closed

Description

@rubnogueira

Describe the bug

I want to use a different tsconfig.json depending on the context. But since 4.1, vitest uses rolldown or esbuild.

plugins: [tsconfigPaths({
  projects: [isProd ? './tsconfig.prod.json' : './tsconfig.json'],
})],
esbuild: {
  tsconfigRaw: isProd ? JSON.stringify(tsconfigProd) : JSON.stringify(tsconfigDev),
},

Until now I was using this technique to inject the contents of the file and enable the resolution of the paths, but now tsconfigRaw is no longer available.

Reproduction

esbuild no longer contains the key tsconfigRaw.

System Info

System:
    OS: macOS 26.4.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 109.69 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.15.0 - /Users/rubnogueira/.local/share/mise/installs/node/24/bin/node
    Yarn: 4.14.1 - /Users/rubnogueira/.local/share/mise/installs/yarn/4.14.1/bin/yarn
    npm: 11.12.1 - /Users/rubnogueira/.local/share/mise/installs/node/24/bin/npm
    pnpm: 10.33.1 - /Users/rubnogueira/.local/share/mise/installs/pnpm/10.33.1/pnpm
    bun: 1.3.13 - /Users/rubnogueira/.local/share/mise/installs/bun/latest/bin/bun
  npmPackages:
    @vitest/coverage-v8: ^4.0.18 => 4.1.4
    vitest: ^4.0.18 => 4.1.4

Used Package Manager

pnpm

Validations

Activity

  1. added theissue type on Apr 23, 2026
  2. hi-ogawa commented on Apr 23, 2026

    @hi-ogawa
    Collaborator

    Vite 8 should make tsconfig handling more automatic for example with builtin paths support through resolve.tsconfigPaths #10054, but not sure how esbuild.tsconfigRaw can be migrated. Probably it's better asked on https://github.com/vitejs/vite/issues.

  3. hi-ogawa commented on Apr 23, 2026

    @hi-ogawa
    Collaborator

    Related vitejs/vite#22112
    The discussion on supporting non default tsconfig.json is happening there. Please comment on that issue with concrete use case to help the decision.

  4. rubnogueira commented on May 26, 2026

    @rubnogueira
    Author

    @hi-ogawa

    I implemented the proper fixes here:

    vitejs/vite#22533
    rolldown/rolldown#9571

  5. hi-ogawa commented on Jun 24, 2026

    @hi-ogawa
    Collaborator

    @rubnogueira Can you provide actual contents of what configuration you switch between prod and dev? You still haven't provided the actual use case and motivations.

    For example, esbuild. tsconfigRaw is for transform ts files and it would help what you intend to transform differently. Then tsconfigPaths for swapping relevant paths for two cases. We are interested to know how this split is effective in practice.

  6. rubnogueira commented on Jun 24, 2026

    @rubnogueira
    Author

    For our use case we have two different tsconfig.json, for example: tsconfig.json and tsconfig.prod.json that is used in our CI pipeline.

    tsconfig.prod.json extends tsconfig.json and overrides 3 properties:

    • composite => true => false
    • paths => multiple @company/* to empty {}
    • references => multiple @company/* to [].

    We have a monorepo where some "packages" are git submodules. For those packages that are git submodules, instead of us using the workspace * reference in the package.json, we use the published registry lets say 1.2.345 because they are not truly in the context of the workspace. So as part of the DX, we override the project references/paths to behave like a true monorepo, while in our CI we restore the original behavior.

    Those git submodules have their CI and imagine them like subcontracted packages, where they make sense in the codebase but they don't 100% belong to the codebase.

    With the vite esbuild config, we can use the tsconfigRaw and simply include the contents of tsconfig.prod.json there, and with tsconfigPaths we change the "path" of that tsconfig.

    I'm happy to follow an alternative path if I manage to override those properties.

  7. hi-ogawa commented on Jun 24, 2026

    @hi-ogawa
    Collaborator

    @rubnogueira Thanks for the follow up. Looking at the three properties you override in tsconfig.prod.json (composite, references, paths), none of them actually affect the typescript transform that esbuild.tsconfigRaw controls. So it's possible that esbuild.tsconfigRaw customization isn't necessary.

    Could you confirm if you drop esbuild.tsconfigRaw entirely and only switch tsconfigPaths between tsconfig.json / tsconfig.prod.json, does everything still work? If something does break without tsconfigRaw, please share that specific failure that would point to a real transform-level need and help justify the upstream changes.

  8. rubnogueira commented on Jun 24, 2026

    @rubnogueira
    Author

    Unfortunately I don't have a chance/time right now to test it, but I will test it asap and potentially create a repro of that structure and I will report back. Thank you!

  9. sapphi-red commented on Jul 21, 2026

    @sapphi-red
    Contributor

    From what I understand from #10176 (comment), I guess setting resolve.tsconfigPaths: isDev (assuming isDev is true for dev and false for build) would work.

  10. sapphi-red commented on Sep 29, 2026

    @sapphi-red
    Contributor

    vitejs/vite#23310 is released in Vite 8.3 so this is probably solved

  11. locked and limited conversation to collaborators on Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions