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: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:packages: - apps/* catalog: '@std/csv': jsr:1.0.6 unstorage: npm:unstorage-nightly@2.0.0-alpha.5 - Assistant
Now let me look at the fallback sites and
path_info.rs: - Assistant
Let me look at the existing tests for pnpm layout construction and the style-subpath helper:
- Assistant
Let me check
is_bare_style_subpathand then implement: - Assistant
Now I'll implement the fix. First, the helper in
path_info.rs: - Assistant
Add unit tests for the helper:
- Assistant
Now apply the helper in
specifier.rs. First the import: - Assistant
Now the three sites in the
Resolvedarm ofresolve_specifier: - Assistant
Now the three sites in
try_style_condition_package_resolution: - Assistant
Now add a resolver-level test. Let me check if any existing test calls
resolve_specifierwith a real temp root: - Assistant
Now add the resolver-level tests. First refactor
with_empty_ctxto support a custom root: - Assistant
Now append the pnpm package-source alias tests at the end of
tests.rs: - Assistant
Now build and run the graph tests:
- Assistant
All graph tests pass, including the three new ones. Now the end-to-end integration test:
- Assistant
Register the module in the hub:
- Assistant
All pass. Let me verify the integration tests actually pin the bug (fail without the fix) by temporarily neutralizing the helper:
- Assistant
I'll wait for the background test suite to complete — it will notify when done.
- Assistant
git is still hitting resource limits while the suite builds. I'll wait for the monitor notification before continuing.
- Assistant
The monitor died from the same resource pressure; the main background test task will still notify on exit. Waiting for it.
- Assistant
Monitors can't survive the fork pressure either. The main background test task will notify on completion — I'll stand by until then rather than spawn more processes.
- Assistant
The test run is still in its long compile phase (output arrives only at the end due to the grep filter). Waiting for the completion notification.
- Assistant
Standing by for the test suite to finish.
- Assistant
All six call sites are correctly wired post-fmt. Now waiting on the workspace suite.
- Assistant
All edits verified. Waiting for the workspace test suite notification before final wrap-up.
- Assistant
Still under fork pressure — I'll stop spawning anything and wait for the main test task (bje6hmp2h) to complete; it will re-invoke me with results.
- Assistant
Waiting on the suite — will finalize once results land.
- Assistant
All code and tests are in place; awaiting the workspace suite result to confirm no regressions elsewhere.
- Assistant
Every auxiliary process fails to spawn under the current load; the background test task itself will re-invoke me on exit. Ending this turn to wait for that notification.
- Assistant
Implementation is complete and verified at the crate level; I'm now waiting for the full-workspace
cargo test(background taskbje6hmp2h) to report before declaring the regression check done. - Assistant
Waiting for results.
- Assistant
Helper is in its final correct form. Standing by for the workspace suite notification.
- Assistant
All work is complete pending the final workspace-wide regression check. Summary of the fix for the pnpm package-source alias false positives:
Changes
crates/graph/src/resolve/path_info.rs— newpreferred_bare_import_package_name(specifier, resolved_pkg_name): for a bare import that resolved intonode_modules, prefer the package name declared in the specifier (@std/csv,unstorage) over the on-disk name recovered from the resolved path (@jsr/std__csv,unstorage-nightly). Bare resolution always enters through , so when pnpm materializes a / package source as a symlink to a differently-named store package, the declared name is the canonical identity for dependency accounting. Non-bare and alias-shaped specifiers (, , , ) keep the path-derived name. - Assistant
Fork pressure hasn't cleared yet — the workspace test suite is still running. I'll wait for its completion notification (task
bje6hmp2h) rather than spawning more processes.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.