F-H
F-H

Reputation: 1085

Why does this nx executor ignore its dependsOn setting?

tl;dr: I am trying to chain two nx targets using the dependsOn property, but it seems to be ignored.


In my project.json file, there are the following targets (among others):

Concretely, the (simplified versions of the) tasks look like this:

"targets": {
    "build": {
        "executor": "@angular-devkit/build-angular:browser",
        // ...
        "options": {
            // ...
        },
        "configurations": {
            "development": {
                // ...
            }
        }
        "defaultConfiguration": "development"
    },
    // ...
    "serve": {
        "executor": "@angular-devkit/build-angular:dev-server",
        "configurations": {
            "development": {
                "buildTarget": "myProject:build:development"
            }
        },
        "defaultConfiguration": "development"
    },
    // ...
    "mytest": {
        "command": "echo 'TEST'"
    }

Now, I'd like to always run the mytest target right before each build triggered by the live-reload from the dev-server executor. I figure that for this purpose, I must add mytest as a dependency for the build task:

"targets": {
    "build": {
        "executor": "@angular-devkit/build-angular:browser",
        "dependsOn": ["mytest"],

Now, when I run nx serve ... nothing new happens. The application is built as usual, but the TEST output text is nowhere to be seen.


Conversely, if I try this in a minimal example, it works as expected:

"mytest": {
    "command": "echo 'Test 1'"
},
"outertest":  {
    "dependsOn": ["mytest"],
    "command": "echo 'Test 2'"
}

Running nx outertest will display Test 1, then Test 2.


Why is my dependency target not run?

Is there anything special about the @angular-devkit/build-angular:browser executor that prevents dependencies from being run, and should I be using some other way to prepend my command to the build?

Upvotes: 0

Views: 351

Answers (0)

Related Questions