nx icon indicating copy to clipboard operation
nx copied to clipboard

Add Ignore dependencies CLI option

Open lucasvieirasilva opened this issue 1 year ago • 11 comments

Description

Currently, when you run an Nx command, like build or any other custom target that has the following configuration:

{
    ...
    "targets": {
        "mytask": {
            "executor": "nx:run-commands",
            "options": {
                "command": "do something"
            },
            "dependsOn": ["build"]
        }
    }
    ...
}

There is no way to ignore the dependsOn

Motivation

Sometimes we don't need to run the entire dependency tree when we are testing something, or doing something repetitively, of course, I can have a second target for the same task with the same configuration, but it is not ideal, because you need to maintain 2 versions of the same thing.

Suggested Implementation

Have a CLI option --ignore-dependencies or --no-deps (personally like --no-deps more) and when the option is detected ignore all the task dependencies.

nx run <project>:mytask --ignore-dependencies

Or

nx run <project>:mytask --no-deps

In this way, the default always runs the entire dependency graph for the task, but if the developer provides the CLI option, Nx bypasses them.

Alternate Implementations

lucasvieirasilva avatar Jul 10 '23 15:07 lucasvieirasilva

+1 This would be very practical and save some work making redundant task definitions

tylerwalts avatar Jul 11 '23 17:07 tylerwalts

We've recently bumped into that case and while completely ignoring dependencies is some solution, but in Gradle (a build tool originally for Java/JVM), there is also a switch to disable/ignore just particular test, e.g.

nx run <project>:mytask --ignore-dependencies build2

That would ignore the dependent build2 task, but assuming there were both build1 and build2 provided as dependencies, build1 would still be executed.

Maybe that variant could also be available (together with the "total" dependencies ignoring)?

szpak avatar Sep 21 '23 12:09 szpak

Same here. I need to trigger tasks individually without triggering the whole chain of tasks.

mklueh avatar Nov 26 '23 21:11 mklueh

Same pb for me. I have to duplicate tasks to add a variant without dependencies just to skip the chain.

charlesRMD avatar Nov 28 '23 19:11 charlesRMD

Any news about this issue?? +1

VitProg avatar Feb 02 '24 17:02 VitProg

+1 do we have any update on this ?

cmark1302 avatar Feb 20 '24 15:02 cmark1302

+1. With a large repo with lot of projects, running all of the task dependencies takes a lot of time, even when they are cached. Would like to be able to just execute the test task without running the dependent tasks. We build all our code upfront beforehand, as this is much faster than letting nx build everything.

mrfelton avatar Feb 25 '24 23:02 mrfelton

Any news about this issue?? 👋

VitProg avatar May 01 '24 21:05 VitProg

Any news about this issue?? +1

d-pylypenko avatar May 31 '24 12:05 d-pylypenko

+1

kochetkovSergeY avatar Jun 07 '24 09:06 kochetkovSergeY

+1

JamesGrom avatar Jun 25 '24 19:06 JamesGrom

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 Aug 26 '24 00:08 github-actions[bot]