Skip to content

Resolve TypeScript imports through tsconfig paths aliases #508

Description

@zaebee

Follow-up to #504 / #506, which resolves imports of workspace packages (names from package.json). Imports through tsconfig compilerOptions.paths aliases are still unresolved:

import { Button } from "@components/ui/Button";   // apps/web/tsconfig.json: "@components/*": ["components/*"]

On cal.com after #506: @lib.* 91 imports, @components.* 90, @server.* 23.

Why it is its own change

  • Scope is per tsconfig. paths apply to the files a tsconfig covers, and a monorepo has one per app, with different aliases. The same @lib/* can mean different directories in two apps, so the map is keyed by the importing file, not global like fix(resolver): resolve TypeScript imports of workspace packages #506's.
  • extends chains and baseUrl. Aliases are inherited and resolved relative to baseUrl of whichever config in the chain set it.
  • Several targets per alias. "@lib/*": ["a/*", "b/*"] is tried in order.

The rule from #506 carries over: rewrite only onto a node that exists, otherwise leave the edge visibly unresolved, and rebuild on an incremental run when any tsconfig in scope changes.

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions