feat: [OSM-1122] improve workspaces parsing #234
Merged
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.
What this does
Added specific parser for a workspace.
It takes projects belonging to the workspace from the lockfile importers. This way, several path computations are avoided (that were performed here: https://github.com/snyk/snyk-nodejs-plugin/pull/16/files)
extractPackages function should perform parsing of packages only once per parser. This was a problem for workspaces before these changes, it was called for every package.json in the workspace.
Removed some code that is not needed anymore (e.g. specifier in the package that's added to dep graph).
Next changes: add a cache for workspaces for the cases where a local package is referenced by another one. We should keep a map of every top "importer" local package and its dependencies, to not compute them every time they are referenced.