Skip to content

Monorepo support for Find File Reference #2975

@BlackySoul

Description

@BlackySoul

I've used this template to initialize a monorepo project with Turborepo.

When I click on MyCounterButton (used in apps/docs/src/routes/+page.svelte) or run "Go to Definition", the source file for MyCounterButton does not open.

Also, when I run "Svelte: Find File References" from MyCounterButton.svelte (located in packages/ui/src/MyCounterButton.svelte), only references inside the current package are found. References from apps/docs/src/routes/+page.svelte are not detected.

Partial workaround

"Go to Definition" can be fixed by adding the following configuration to tsconfig.json in apps/docs and apps/web:

{
  "extends": [
    "@repo/typescript-config/svelte.json",
    "./.svelte-kit/tsconfig.json"
  ],
  "compilerOptions": {
    "strictNullChecks": true,
    "paths": {
      "@repo/ui": ["../../packages/ui"],
      "@repo/ui/*": ["../../packages/ui/*"]
    }
  }
}

Attempt to fix "Find File References"

To try to fix "Svelte: Find File References", I created a root tsconfig.json like this:

{
  "files": [],
  "references": [
    { "path": "./apps/docs" },
    { "path": "./apps/web" },
    { "path": "./packages/ui" }
  ]
}

However, this did not help. Also, the Turborepo documentation discourages this approach:

https://turborepo.dev/docs/guides/tools/typescript#you-likely-dont-need-a-tsconfigjson-file-in-the-root-of-your-project

Question

Is this a known issue with the Svelte language tools in a Turborepo monorepo setup?

Is there any additional configuration required to make "Find File References" and "Go to Definition" work correctly across packages?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions