fix: make dependency traversal single-pass #66
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.
I believe we should follow this to an extent https://nodejs.org/api/modules.html#all-together
This currently is a simplified subset for dependency graph analysis. We build an index of
package.jsonfiles and resolve each dep by climbing parent directories tonode_modules/<dep>/package.json. We do not implement package exports/imports, file/directory/index fallbacks, core modules,NODE_PATH/globalfolders, or proper realpath-based resolution; for symlinks we add a name-based alias. There may still be edge cases, but this should be more reliable and standardized than the previous two-pass approach. Drafting this to gather feedback.UPD: I'll prepare a PR on the side to improve coverage. This should help to test this properly
UPD: https://github.com/npm/cli/tree/latest/workspaces/arborist - this is how npm handles same sort of operations. Way too smart for our case, but I'll see if we can adapt algo from there to our case and perhaps introduce a simple file cache