Skip to content

scanner: tsconfig alias target "./*" (create-next-app default) never resolves; whole Next.js graph reads as standalone #173

Description

@JordanCoin

Symptom

On a stock Next.js project (create-next-app default tsconfig.json), codemap --importers reports no importers for files that are imported everywhere, and codemap --deps . shows nearly every file as standalone. No coverage warning is emitted; the JSON output carries no coverage field at all.

Reproduced 2026-09-04 on JordanCoin/importsentry (Next 16, 86 files) with a dev build of main at 8cda6ae:

$ codemap --importers lib/a1.ts
No files import lib/a1.ts.

$ codemap --importers lib/a1.ts --json
{"root":"...","mode":"importers","file":"lib/a1.ts","importers":null,"importer_count":0,"is_hub":false}

Reality (grep): 7 files import it via @/lib/a1.

Cause

create-next-app writes:

"paths": { "@/*": ["./*"] }

resolvePathAlias (scanner/filegraph.go:816) substitutes the wildcard into the target, producing ./lib/a1, and hands that to tryExactMatch / trySuffixMatch. The file index has no ./ prefix, so nothing matches. The ./ trim at scanner/filegraph.go:537 only runs on the relative-import path, not on alias targets.

Proof

Same repo copy, one edit to tsconfig, "@/*": ["*"]:

$ codemap --importers lib/a1.ts
⚠️  HUB FILE: lib/a1.ts
   Imported by 7 files - changes have wide impact!

--deps . goes from 28 standalone files to 2.

Why this matters

./* is the default that Next.js has shipped for years, so this is the most common TypeScript layout in the wild, and the failure is silent: the answer looks complete. It compounds #132 (ESM specifiers) and #148 (coverage reports complete). This repo's own README promises tsconfig path aliases are resolved.

Fix

Normalize alias targets with path.Clean (and strip a leading ./) before matching, and add a fixture under testdata/ with "@/*": ["./*"] that asserts the importer list exactly. Also emit coverage in the --importers JSON so a zero-importer answer on an aliased project cannot read as complete.

Milestone: Graph accuracy. Tracked in #172. Related: #20 (closed, same symptom, different cause), #132, #148.

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

    bugSomething isn't working

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions