Skip to content
TheChatArchiveThe Chat Archive
composer-2.5· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

False positives for pnpm package source aliases What happened? fallow dead-code reports…

  1. User

    False positives for pnpm package source aliases

    What happened?

    fallow dead-code reports 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.5
    

    The 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 registry
    • npm:<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/csv is declared and imported, Fallow should credit @std/csv, even if pnpm resolves it to @jsr/std__csv internally. Same for unstorage resolving to unstorage-nightly.

    Reproduction

    Create pnpm-workspace.yaml:

    packages:
      - apps/*
    
    catalog:
      '@std/csv': jsr:1.0.6
      unstorage: npm:unstorage-nightly@2.0.0-alpha.5
    

    Create apps/cli/package.json:

    {
      "name": "@example/cli",
      "type": "module",
      "dependencies": {
        "@std/csv": "catalog:"
      }
    }
    

    Create apps/cli/src/output.ts:

    import { stringify } from '@std/csv/stringify';
    
    console.log(stringify);
    

    Create apps/native/package.json:

    {
      "name": "@example/native",
      "type": "module",
      "dependencies": {
        "unstorage": "catalog:"
      }
    }
    

    Create apps/native/src/storage.ts:

    import { createStorage } from 'unstorage';
    
    console.log(createStorage);
    

    Run:

    fallow dead-code --format json
    

    Expected behavior

    Fallow should treat the package name used in package.json/imports as canonical for dependency analysis.

    Expected:

    • @std/csv should not be reported as unused
    • @jsr/std__csv should not be reported as unlisted
    • unstorage should not be reported as unused
    • unstorage-nightly should not be reported as unlisted

    The resolver may need to preserve both names for pnpm package-source entries:

    • declared/import name: @std/csv, unstorage
    • resolved source name: @jsr/std__csv, unstorage-nightly

    Dependency usage should match against the declared/import name, not only the resolved source package name.

    Fallow version

    2.85.0

    Operating system

    macOS

    Configuration

    Interface

    No new interfaces are introduced.

  2. Assistant

    Investigating how Fallow resolves pnpm catalog entries and package-source aliases so we can fix the false positives.

  3. Assistant

    Implementing a fix: when a bare import resolves via node_modules, credit the import specifier's package name (as declared in package.json) instead of the physical pnpm-installed name.

  4. Assistant

    Implementing the helper and updating resolver call sites.

  5. Assistant

    Fixed. When a bare import resolved through node_modules, Fallow was crediting the physical package name from the resolved path (e.g. @jsr/std__csv, unstorage-nightly) instead of the name used in imports and package.json (e.g. @std/csv, unstorage). That mismatch caused false unused and unlisted dependency reports for pnpm package-source catalog entries.

    Root cause: extract_package_name_from_node_modules_path reads the installed directory name. pnpm package sources (jsr:, npm:alias@ver) can install under a different name than the declared catalog key.

    Fix: Added package_usage_name_for_node_modules_import in crates/graph/src/resolve/path_info.rs. For bare specifiers, dependency usage now credits the import-side package name rather than the physical node_modules name. The resolver uses this everywhere it maps a resolved node_modules path to NpmPackage.

    Tests added:

    • Unit tests for the helper in path_info.rs
    • Resolver test simulating pnpm virtual-store layout with JSR and npm alias packages
    • Integration test (issue_pnpm_package_sources.rs) matching your reproduction scenario

    With this change, @std/csv and unstorage are credited when imported, and @jsr/std__csv / unstorage-nightly are no longer reported as unlisted.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.