feat: expand JavaScript resolver to support npm and Yarn Berry layouts#2
Open
Storm1289 wants to merge 1 commit intoSBOMit:masterfrom
Open
feat: expand JavaScript resolver to support npm and Yarn Berry layouts#2Storm1289 wants to merge 1 commit intoSBOMit:masterfrom
Storm1289 wants to merge 1 commit intoSBOMit:masterfrom
Conversation
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>
7ea42e2 to
f908aaf
Compare
This was referenced Apr 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
node_modules/{pkg}/package.jsonpaths@babel/core) and non-scoped (express) packagesYarn Berry PnP
.yarn/cache/{name}-npm-{version}-{hash}.zippaths@types-node→@types/node)pnpm — unchanged, regression tested.
Files touched
pkg/resolver/javascript.go— core extraction logic and package filter updatespkg/resolver/javascript_test.go— 20 new unit tests across all 3 layoutspkg/resolver/python_test.go— 11 new unit tests for the Python resolverTesting