Skip to content
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

Add Ignore dependencies CLI option #18053

Closed
1 task
lucasvieirasilva opened this issue Jul 10, 2023 · 12 comments · Fixed by #27137
Closed
1 task

Add Ignore dependencies CLI option #18053

lucasvieirasilva opened this issue Jul 10, 2023 · 12 comments · Fixed by #27137
Assignees
Labels

Comments

@lucasvieirasilva
Copy link
Contributor

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

@tylerwalts
Copy link

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

@AgentEnder AgentEnder added the scope: core core nx functionality label Jul 18, 2023
@szpak
Copy link

szpak commented Sep 21, 2023

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)?

@mklueh
Copy link

mklueh commented Nov 26, 2023

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

@charlesRMD
Copy link

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

@VitProg
Copy link

VitProg commented Feb 2, 2024

Any news about this issue??
+1

@cmark1302
Copy link

+1
do we have any update on this ?

@mrfelton
Copy link

+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.

@VitProg
Copy link

VitProg commented May 1, 2024

Any news about this issue?? 👋

@d-pylypenko
Copy link

Any news about this issue??
+1

@kochetkovSergeY
Copy link

+1

1 similar comment
@JamesGrom
Copy link

+1

ZackDeRose pushed a commit to ZackDeRose/nx that referenced this issue Aug 8, 2024
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
There is no option to exclude dependent tasks when running Nx.

## Expected Behavior
There is a flag, `--exclude-task-dependencies`, to exclude task deps
from running. This is inline with other tools:

- [dotnet
cli](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-build#:~:text=%2D%2Dno%2D-,dependencies,-Ignores%20project%2Dto)

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes nrwl#18053
Copy link

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 github-actions bot locked as resolved and limited conversation to collaborators Aug 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.