Skip to content

graph: integrate edge modifiers #843

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2025

Conversation

ruyadorno
Copy link
Member

@ruyadorno ruyadorno commented Jun 6, 2025

Add the ability for installs to use edge modifiers by using the "modifiers" to define an object containing keys that use a subset of the Dependency Selector Syntax and a spec value to override the current value in use, e.g:

  {
    "modifiers": {
      ":root > #eslint": "^8.0.0",
      "#react": "^16"
    }
  }

Refs: https://github.com/vltpkg/statusboard/issues/64

Copy link

vercel bot commented Jun 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) Visit Preview Jun 9, 2025 10:30pm

@ruyadorno ruyadorno requested a review from Copilot June 7, 2025 01:22
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR integrates edge modifier functionality into the dependency graph, enabling installs to override current dependency values using a modifier query. Key changes include:

  • Adding a new modifier property to Node and propagating modifier values through graph-building functions.
  • Updating functions (install, addNodes, appendNodes, etc.) to load and apply a GraphModifier.
  • Introducing a new check-nodes module that evaluates node modifications based on active modifiers.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/graph/src/node.ts Adds a new "modifier" property to Node.
src/graph/src/install.ts Loads GraphModifier and passes it to the build logic.
src/graph/src/ideal/get-importer-specs.ts Extends importer specs options to include modifiers and tracks checks.
src/graph/src/ideal/check-nodes.ts Introduces node checking for modifiers and triggers dependency appends.
src/graph/src/ideal/build.ts Passes the modifiers option to the build process.
src/graph/src/ideal/build-ideal-from-starting-graph.ts Integrates modifier checks into the graph build process.
src/graph/src/ideal/append-nodes.ts Updates node appending logic to swap specs and update modifier entries.
src/graph/src/ideal/add-nodes.ts Incorporates modifiers in the add-nodes workflow.
src/graph/src/graph.ts Updates package placement to handle extra modifier information.
src/graph/src/actual/load.ts Extracts modifier extra information from depID when loading manifests.
Comments suppressed due to low confidence (2)

src/graph/src/graph.ts:345

  • [nitpick] Ensure that the semantics of the 'extra' parameter passed to getId are clearly documented, so downstream users understand how modifier information influences dependency identity.
const depId = id || (manifest && getId(spec, manifest, extra))

src/graph/src/actual/load.ts:289

  • [nitpick] Consider adding a comment to explain the logic behind choosing between 'lastExtra' and 'maybeExtra', to clarify under which conditions each is used for modifier application.
extra = type === 'registry' || type === 'git' ? lastExtra : maybeExtra

@ruyadorno ruyadorno force-pushed the ruyadorno/add-initial-support-to-graph-modifiers branch 4 times, most recently from aa209bc to 8a9fbf9 Compare June 9, 2025 22:21

Verified

This commit was signed with the committer’s verified signature.
ruyadorno Ruy Adorno
Add the ability for installs to use edge modifiers by using
the `"modifiers"` to define an object containing keys that
use a subset of the Dependency Selector Syntax and a spec
value to override the current value in use, e.g:

```
  {
    "modifiers": {
      ":root > #eslint": "^8.0.0",
      "#react": "^16"
    }
  }
```

Refs: vltpkg/statusboard#64
@ruyadorno ruyadorno force-pushed the ruyadorno/add-initial-support-to-graph-modifiers branch from 8a9fbf9 to 2d4d71a Compare June 9, 2025 22:30
@ruyadorno ruyadorno marked this pull request as ready for review June 9, 2025 22:30
@ruyadorno ruyadorno requested a review from lukekarrys June 9, 2025 22:31
Copy link
Member

@lukekarrys lukekarrys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good and I built this PR locally and used it to install some simple modifiers which all worked! :shipit:

@ruyadorno ruyadorno merged commit 9cc1c56 into main Jun 10, 2025
13 checks passed
@ruyadorno ruyadorno deleted the ruyadorno/add-initial-support-to-graph-modifiers branch June 10, 2025 14:39
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.

None yet

2 participants