nx icon indicating copy to clipboard operation
nx copied to clipboard

Allow targetDefaults dependsOn to specify a package

Open luxaritas opened this issue 2 years ago • 1 comments

Description

I would like running a target to implicitly rely on a different target of a specific package

Motivation

Example use case: I have an eslint plugin which I consume from the workspace. Running lint on any other package should require the plugin to be built

Suggested Implementation

Allow the targetDefaults dependsOn "package" property to be a package name instead of self or dependencies

Alternate Implementations

  • (No change to Nx) Setting up an implicit dependency for every other package (though this wouldn't limit it to just the lint target)
  • (No change to Nx) Abusing inputs to also include inputs from the other package
  • Somehow using the global implicit dependencies to specify the same thing instead of targetDefaults

luxaritas avatar Jul 27 '22 19:07 luxaritas

That would be very useful.

A good use case for this one is when you only need to build some custom executor implementation that is used within the project.

Another alternative would be to allow the user to create dependency "groups".

For example:

(project.json)

{
  "$schema": "../../node_modules/nx/schemas/project-schema.json",
  "sourceRoot": "apps/project-1",
  "projectType": "application",
  "targets": {
    "my-target": {
      "executor": "my-executor",
      "options": {},
      "dependsOn": [
        {
          "projects": [
            "project-2", 
            "project-3"
          ],
          "target": "build"
        }
      ]
    }
  }
}

rnza0u avatar Aug 09 '22 13:08 rnza0u

Also a shorthand syntax would be nice:

{
  "dependsOn": ["project-2:build", "project-3:build"]
}

gund avatar Feb 24 '23 20:02 gund

@AgentEnder Should this be linked to #16100? (That PR was linked to itself)

luxaritas avatar Apr 11 '23 17:04 luxaritas

Ah, yeah it should have been. Thanks.

AgentEnder avatar Apr 11 '23 19:04 AgentEnder

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

github-actions[bot] avatar May 12 '23 00:05 github-actions[bot]