False positives for pnpm package source aliases What happened? fallow dead-code reports…
- User
False positives for pnpm package source aliases
What happened?
fallow dead-codereports incorrect unused/unlisted dependency findings when pnpm package sources are used through catalogs.Example
pnpm-workspace.yaml:yamlpackages: - apps/* catalog: '@std/csv': jsr:1.0.6 unstorage: npm:unstorage-nightly@2.0.0-alpha.5The package manifests depend on the declared names:
json{ "dependencies": { "@std/csv": "catalog:" } }json{ "dependencies": { "unstorage": "catalog:" } }Source imports also use the declared names:
tsimport { stringify } from '@std/csv/stringify';tsimport { createStorage } from 'unstorage';But Fallow can report the declared package names as unused:
json{ "package_name": "@std/csv", "location": "dependencies", "path": "apps/cli/package.json" }json{ "package_name": "unstorage", "location": "dependencies", "path": "apps/native/package.json" }And report the resolved package-source names as unlisted:
json{ "package_name": "@jsr/std__csv", "imported_from": [ { "path": "apps/cli/src/output.ts" } ] }json{ "package_name": "unstorage-nightly", "imported_from": [ { "path": "apps/native/src/storage.ts" } ] }This seems to conflate the manifest/import package name with pnpm’s resolved package-source name.
pnpm documents that packages can be installed from alternate sources:
- Assistant
Investigating how Fallow resolves pnpm catalog dependencies and matches them against imports.
- Assistant
Implementing a fix: when a bare import resolves via
node_modules, credit the specifier's package name instead of the on-disk pnpm alias. - Assistant
Fixed. Fallow was crediting the on-disk package name from
node_modules(e.g.@jsr/std__csv,unstorage-nightly) instead of the name used inpackage.jsonand imports when pnpm package sources resolve to a different installed package.Root cause
When a bare import like
@std/csv/stringifyorunstorageresolved through pnpm’s virtual store,extract_package_name_from_node_modules_pathreturned the installed package name. That led to:- declared deps (
@std/csv,unstorage) being reported as unused - resolved names (
@jsr/std__csv,unstorage-nightly) being reported as unlisted
Fix
Added
package_usage_name_for_resolution()incrates/graph/src/resolve/path_info.rs. For bare import specifiers, it always credits the import’s package name (the canonical name for dependency analysis). The on-disk name is only used for relative imports into (e.g. SCSS). - declared deps (
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.