deno
53caf047 - fix(resolver): better hint when importing a linked package by the wrong name (#35319)

Commit
104 days ago
fix(resolver): better hint when importing a linked package by the wrong name (#35319) When a bare import fails to resolve, Deno appends a hint suggesting `deno add npm:<name>`. That hint sends people the wrong way when the project actually has a matching workspace member or a package linked via the `links` field: the package is importable, just by its declared `name`. The common case, seen in #35300, is a local package that declares `"name": "@scope/my-pkg"` but is imported as `"my-pkg"`, which fails with "not a dependency and not in import map" plus the npm hint. This threads the set of bare-importable package names (workspace members and linked packages) into the resolution-error enhancement. When the failing specifier matches the unscoped tail of a known package name, the hint now points at the full name to import instead of suggesting an npm install. The hint is wired through all the paths that surface resolution errors: the primary `deno run` / `deno check` path, the LSP diagnostics, and the tsc diagnostics. The package-name collection is lazy on the `deno run` / `deno check` path, so it is only built when a resolution error is actually encountered and the happy path pays nothing. Ref #35300
Author
Parents
Loading