Skip to content

feat: expand JavaScript resolver to support npm and Yarn Berry layouts#2

Open
Storm1289 wants to merge 1 commit intoSBOMit:masterfrom
Storm1289:feat/expand-js-resolver-npm-yarn
Open

feat: expand JavaScript resolver to support npm and Yarn Berry layouts#2
Storm1289 wants to merge 1 commit intoSBOMit:masterfrom
Storm1289:feat/expand-js-resolver-npm-yarn

Conversation

@Storm1289
Copy link
Copy Markdown

@Storm1289 Storm1289 commented Mar 28, 2026

Expand JavaScript resolver to support npm, Yarn Berry PnP, and pnpm

Problem

The JavaScript file-path resolver only recognized pnpm directory layouts, leaving npm and Yarn Berry projects with unresolved package metadata.

Solution

Added two new extraction strategies alongside the existing pnpm support:

npm / Yarn classic

  • Matches node_modules/{pkg}/package.json paths
  • Handles both scoped (@babel/core) and non-scoped (express) packages
  • Version populated by the network resolver when trace data is available

Yarn Berry PnP

  • Matches .yarn/cache/{name}-npm-{version}-{hash}.zip paths
  • Extracts full version directly from the filename
  • Decodes scoped package names (@types-node@types/node)

pnpm — unchanged, regression tested.

Files touched

pkg/resolver/javascript.go — core extraction logic and package filter updates
pkg/resolver/javascript_test.go — 20 new unit tests across all 3 layouts
pkg/resolver/python_test.go — 11 new unit tests for the Python resolver

Testing

  • All 31 tests pass
  • Full project build is clean

The JavaScript file-path resolver previously only recognized pnpm
directory layouts. This expands it to support:

- Standard npm/Yarn classic: detects packages from
  node_modules/{pkg}/package.json paths
- Yarn Berry PnP: detects packages from
  .yarn/cache/{name}-npm-{version}-{hash}.zip paths
- Scoped package support (@scope/name) for all three layouts

Also updates the package file filter to handle standard npm
node_modules paths, and adds comprehensive unit tests for both
the JavaScript resolver (20 tests) and Python resolver (11 tests).

Signed-off-by: Storm1289 <divakarsharma2934@gmail.com>
@Storm1289 Storm1289 force-pushed the feat/expand-js-resolver-npm-yarn branch from 7ea42e2 to f908aaf Compare March 29, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant