Skip to content

Bizarre tsconfig hijacking  #359

@echocrow

Description

@echocrow

Describe the bug

We experienced some head-scratching confusion when our SvelteKit app suddenly started complaining about missing route files. After some commit and VSCode extension bisecting, we came across a bizarre behaviour that was causing SvelteKit's internal tsconfig.json to be overridden (seemingly by the Vitest VSCode extension) when a combination of criteria are met.

Specifically, various paths in compilerOptions.paths and compilerOptions.rootDirs get updated, whenever any package.json file is modified in any way, replacing those paths with invalid paths to another package (that happens to also have Vite config) in the same monorepo. This happens seemingly "magically", even when no dev or other scripts are running.

Charlie from It's Always Sunny in Philadelphia going crazy

Reproduction

Repro, along with demo steps, can be found in this repo:

This repro uses SvelteKit for demoing purposes. I believe this issue is not specific to SvelteKit, however.

The issue goes away as soon as any one of the following steps are taken:

  • disable this VSCode extension, or
  • remove the root vitest.workspace.js file, or
  • remove the vite.config.ts file of sibling packages, or
  • uninstall the vitest package at the root package

Weirder still, most of these steps will also "reset"/restore the hijacked tsconfig.json file to its original, expected state.

Output

[INFO 2:36:55 PM] [API] Vitest process 33901 closed successfully
[INFO 2:36:55 PM] [API] Running Vitest: v1.5.0 (vitest.workspace.js)
[INFO 2:36:55 PM] [API] Starting Vitest process with Node.js: /path/to/library/pnpm/node
[INFO 2:36:55 PM] [API] Vitest process 33977 created

Version

v0.8.4

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions