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's the problem this PR addresses?
Constraints can only operate on the workspaces' listed dependencies, but have no idea about the shape of the global dependency tree. In general it's enough, but I wanted to write a constraint autofixing missing peer dependencies, and this wasn't possible without knowing the dependencies of our dependencies.
How did you fix it?
I added a concept of "package" to the constraint API. Some of their characteristics:
They are based on the resolved dependency tree; as a result, there is no direct concept of devDependency / dependency (just like in the core
Package
type).They somewhat look like the
Package
type, but with fewer information (just the dependencies & peer dependencies, at the moment), and with a slightly different format (no need for serialization, so it directly references other data structure rather than go through string hashes).They don't provide any autofix (or even reporting) capability at the moment. Perhaps later I'll add an
error
API, like regular dependencies, but that'll probably require to enhance them so they are able to access the packages' filesystems, so it'll have to be a follow-up.Testing is currently lacking ... like the rest of the JS constraints engine 😶🌫️
Checklist