ISSUE DESCRIPTION False positives for pnpm package source aliases What happened? fallow…
- User
ISSUE DESCRIPTION
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:packages: - apps/* catalog: '@std/csv': jsr:1.0.6 unstorage: npm:unstorage-nightly@2.0.0-alpha.5The package manifests depend on the declared names:
{ "dependencies": { "@std/csv": "catalog:" } }{ "dependencies": { "unstorage": "catalog:" } }Source imports also use the declared names:
import { stringify } from '@std/csv/stringify';import { createStorage } from 'unstorage';But Fallow can report the declared package names as unused:
{ "package_name": "@std/csv", "location": "dependencies", "path": "apps/cli/package.json" }{ "package_name": "unstorage", "location": "dependencies", "path": "apps/native/package.json" }And report the resolved package-source names as unlisted:
{ "package_name": "@jsr/std__csv", "imported_from": [ { "path": "apps/cli/src/output.ts" } ] }{ "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:
jsr:installs from the JSR registrynpm:<name>@<version>can resolve a declared dependency through a different npm package name- package sources are part of pnpm’s supported dependency model, not separate source imports
So if
@std/csvis declared and imported, Fallow should credit@std/csv, even if pnpm resolves it to@jsr/std__csvinternally. Same forunstorageresolving tounstorage-nightly.Reproduction
Create
pnpm-workspace.yaml: - Assistant
I’ll trace pnpm dependency parsing and the dead-code matching logic, then inspect existing tests/fixtures for package-source aliases. I’ll reproduce the reported behavior if the repository tooling permits, implement the smallest canonical-name fix, run targeted and broader tests, and review the diff before submitting.
- Assistant
The repository is a Rust workspace. The initial search did not expose the relevant paths because they are likely under crate-specific source directories, so I’ll identify crates and search the full tree for resolver and dependency model types.
- Assistant
The defect is at graph accounting: resolution derives
NpmPackagefrom the physicalnode_modules/.pnpmtarget, so aliases become the resolved package name. I’ll preserve the original bare import package name for ordinary npm-package targets while retaining the target name for non-bare schemes and internal package results. This canonical name will be used both when building package usage and when locating unlisted-import sites. - Assistant
Targeted graph/core tests now pass (2,949 tests). The implementation also keeps existing path-alias and virtual-suffix behavior intact by only replacing the target name when the source’s package root is genuinely different from the resolved target, not when the target is merely a subpath representation. I’ll now inspect the final diff and run a workspace check for compile/lint-level issues.
- Assistant
The final diff is limited to resolver naming, graph accounting, and unlisted-site bookkeeping;
git diff --checkis clean andcargo check --workspacesucceeds. Existing tests all pass, including the previously sensitive path-alias and virtual-module cases. The fix handles scoped names and subpaths, and avoids changingnpm:scheme behavior. I’m submitting the verified changes now.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.