Skip to content

turbo boundaries does not understand tsconfig path aliases, incorrectly flags local imports as undeclared dependencies #11906

@charlottea98

Description

@charlottea98

Verify canary release

  • I verified that the issue exists in the latest Turborepo canary release.

Link to code that reproduces this issue

https://github.com/mentimeter/turborepo-boundaries-example

Which canary version will you have in your reproduction?

turbo@2.8.11-canary.4

Environment information

CLI:
   Version: 2.8.11-canary.4
   Path to executable: /Users/charlotte.andersson/workspace/my-turborepo/node_modules/turbo-darwin-arm64/bin/turbo
   Daemon status: Running
   Package manager: yarn

Platform:
   Architecture: aarch64
   Operating system: macos
   WSL: false
   Available memory (MB): 2943
   Available CPU cores: 10

Environment:
   CI: None
   Terminal (TERM): xterm-256color
   Terminal program (TERM_PROGRAM): iTerm.app
   Terminal program version (TERM_PROGRAM_VERSION): 3.5.14
   Shell (SHELL): /bin/zsh
   stdin: false

Expected behavior

turbo boundaries should either:

  • Read and respect tsconfig.json path aliases when resolving imports, or
  • Provide a config option in turbo.json to declare known path prefixes as local (e.g. ignoredImports: ["features/*"])

Actual behavior

turbo boundaries reports violations for imports that use TypeScript path aliases resolving to local source folders, treating them as undeclared package dependencies.

Example:
tsconfig.json in apps/app-a:

{
  "compilerOptions": {
    "paths": {
      "*": [
        "./src/*"
      ],
    },
    
  }
}

A source file importing:
import { feature_A } from "features/feature-a";

This resolves to ./src/features/feature-a -> it is entirely local to the workspace. TypeScript resolves it correctly. However, turbo boundaries flags it as:

Checking packages...
  × cannot import package `features` because it is not a dependency
   ╭─[/Users/charlotte.andersson/workspace/my-turborepo/apps/app-a/src/index.ts:1:
add workflow run
1]
 1 │ import { feature_A } from "features/feature-a";
   · ───────────────────────┬───────────────────────
   ·                        ╰── package imported here
 2 │
   ╰────

Checked 2 files in 5 packages, 1 issue found

To Reproduce

  1. Clone the example repo.
  2. Install dependencies.
  3. Open apps/app-a/src/index.ts.
  4. Note the import from "features/..." which resolves to a local src folder via tsconfig path alias.
  5. Run yarn turbo boundaries
  6. Observe the error: “cannot import package features because it is not a dependency” even though the import is local and resolvable by TypeScript.

Also runs in CI: https://github.com/mentimeter/turborepo-boundaries-example/actions/workflows/boundaries.yml

Additional context

Upgrading version by version, it seems it was introduced in turbo@v2.8.7, since turbo@v2.8.6 shows no issues found.

Current workaround: npx @turbo/codemod migrate --to 2.8.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions