Skip to content
TheChatArchiveThe Chat Archive
x-ai/grok-4.5· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION False positives for pnpm package source aliases What happened? fallow…

  1. User

    ISSUE DESCRIPTION

    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.

    ADDITIONAL ADVICE

    Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use git checkout <file> to restore the file to its original state. You can also reset all changes in the repository using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to get the changes that need to be submitted.

    CHECKLIST

    Before submitting your solution, please go over the following checklist and make sure you've done everything:

    • If an error was reported in the issue description, I have successfully reproduced it.
    • If an error was reported in the issue description, I have confirmed that my fix resolves the error.
    • I have thought about edge cases and made sure my fix handles them as well.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.

    Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!

    (Current directory: /fallow, current file: none) bash-$

  2. Assistant

    I'll start by exploring the repository structure and understanding how fallow handles pnpm package sources and dependency resolution.

  3. Assistant

    Let me search for pnpm catalog and package source handling in the codebase.

  4. Assistant

    rg is not available, let me use grep instead.

  5. Assistant

    There's existing pnpm catalog support. Let me inspect the relevant modules for how declared vs resolved package names are handled.

  6. Assistant

    Let me look at the pnpm catalog related code and graph resolution more carefully.

  7. Assistant

    I'll inspect how unused/unlisted dependencies are computed and how package names are resolved from node_modules.

  8. Assistant

    I'll inspect how package_usage is built and how resolved package names are mapped back to declared names.

  9. Assistant

    Looking at how package names are extracted from resolved paths — that is likely where the alias mismatch happens.

  10. Assistant

    The issue appears to be snapshotting the resolved package path name; next I'll inspect how import specifiers map to package usage names.

  11. Assistant

    Let me continue reading the resolve_specifier function.

  12. Assistant

    I'll look at extract_package_name and any existing alias handling.

  13. Assistant

    Let me read path_info.rs for extract_package_name.

  14. Assistant

    There's existing related logic around line 897 in fallbacks.rs — let me inspect it.

  15. Assistant

    I'll search for existing tests and history related to pnpm aliases and JSR package sources.

  16. Assistant

    Let me check how package_usage is recorded during graph building.

  17. Assistant

    Checking package.json dependency parsing and any existing alias map handling.

  18. Assistant

    I'll inspect existing pnpm catalog tests and fixtures, then reproduce the issue.

  19. Assistant

    I'll scan unit tests around node_modules package name extraction and review the resolve helpers more carefully.

  20. Assistant

    I'll craft a minimal reproduction that mirrors pnpm package-source alias layouts.

  21. Assistant

    I'll write a temporary unit test that simulates a pnpm alias layout and shows how the package name is credited.

  22. Assistant

    I need to fix the reproduction layout — the symlinks were set up incorrectly.

  23. Assistant

    The virtual store should live under node_modules/.pnpm in a real pnpm layout — fixing that.

  24. Assistant

    I'll build fallow and run it against the reproduction project.

  25. Assistant

    Need to fix the package name and rebuild.

  26. Assistant

    Running fallow against the reproduction fixture.

  27. Assistant

    Let me check the CLI flags.

  28. Assistant

    Maybe it uses cwd or a positional path.

  29. Assistant

    Use -r flag

  30. Assistant

    I've reproduced the issue. Next I'll add a helper that prefers the import specifier's package name and wire it into the resolve path.

  31. Assistant

    Let me check the fallbacks call sites for available specifier context.

  32. Assistant

    I'll add a helper to prefer the bare import name and apply it wherever NpmPackage is created from a resolved path.

  33. Assistant

    I'll add unit tests and update the call sites next.

  34. Assistant

    Updating specifier.rs to use the helper.

  35. Assistant

    I'll update the import and all the sites that create NpmPackagefrom path.

  36. Assistant

    Updating each place in specifier.rs that builds NpmPackage.

  37. Assistant

    I'll replace the three blocks in try_style_condition_package_resolution and then the main resolve_specifier blocks.

  38. Assistant

    Updating the main resolve_specifierpath extraction sites next.

  39. Assistant

    I'll replace the three NpmPackage(pkg_name) usages in this section.

  40. Assistant

    Updating the SCSS node_modules fallback to prefer the bare package name.

  41. Assistant

    Update fallbacks for scss_node_modules. For path alias that resolves to node_modules, using path Treg is more correct for plugin aliases that map to packages.

  42. Assistant

    The first replace worked; I'll re-read the SCSS block and update it.

  43. Assistant

    Let me try replace again with exact content.

  44. Assistant

    Checking for other NpmPackage construction sites and whether the helper should be exported.

  45. Assistant

    I'll inspect the remaining NpmPackage construction sites that still need the helper.

  46. Assistant

    Rebuilding and verifying the fix against the reproduction.

  47. Assistant

    False positives are gone. I'll run the graph unit tests and a basic dependency fixture to check for regressions.

  48. Assistant

    All graph tests passed. Next I'll run the dependency-related core integration tests.

  49. Assistant

    Need to use a filter pattern properly.

  50. Assistant

    Repository rules forbid adding tests, so I'll remove the unit tests I added in path_info.rs.

  51. Assistant

    I need to open the file around those lines first.

  52. Assistant

    I'll check .claude/rules/detection.md for where this behavior should be documented.

  53. Assistant

    I'll document this under the Resolution-level section in detection.md.

  54. Assistant

    Verifying npm protocolaliases work without catalogs as well.

  55. Assistant

    I'll quickly check that ordinary non-aliased packages still report correctly.

  56. Assistant

    Final review of the changes before submitting:

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