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

@nx/devkit runExecutor doesn't properly run if task depends on another task #19531

Closed
1 of 4 tasks
mpsanchis opened this issue Oct 10, 2023 · 2 comments
Closed
1 of 4 tasks

Comments

@mpsanchis
Copy link
Contributor

Current Behavior

If:

context: ExecutorContext
const targetDescription = { project: 'my-module', target: 'my-target' }

When running

await runExecutor(targetDescription, {}, context)

Then the equivalent of nx run my-module:my-target is run, but does not take into consideration target dependencies. It ignores dependsOn (at least for the cases I have tried).

For instance, if my-module has the following targets in the project.json:

"build": {
  "executor": "nx:noop",
  "dependsOn": "build-webpack"
},
"build-webpack": {
 "executor": "@nx/webpack:webpack"
 "options": { ... }
}

then the module is not built. However, if it has directly:

"build": {
 "executor": "@nx/webpack:webpack"
 "options": { ... }
 }

then it is built correctly.

Expected Behavior

If running await runExecutor(targetDescription, {}, context) and the target dependsOn some other target, then that target should run as well.
I expect the devkit to work equivalently to running the NX CLI.

GitHub Repo

https://github.com/mpsanchis/nx-devkit-runExecutor-bug

Steps to Reproduce

  1. Run npx nx run cart:build-me. Verify that the dist/ folder is empty
  2. Change the apps/cart/project.json: remove the build target and rename build-webpack to build.
  3. Run npx nx run cart:build-me. Verify that the dist/ folder is not empty

Note that I added a simple library in the repo, called nx-builder-lib, which basically has one executor (buildme) which delegates to the build target of the module. This was inspired by the source code of ngx-deploy-npm, where Diego runs the build target before deploying the NPM package here.

Nx Report

Node   : 20.3.1
   OS     : darwin-arm64
   yarn   : 1.22.19
   
   nx                 : 16.10.0-beta.2
   @nx/js             : 16.10.0-beta.2
   @nx/jest           : 16.10.0-beta.2
   @nx/linter         : 16.10.0-beta.2
   @nx/workspace      : 16.10.0-beta.2
   @nx/angular        : 16.10.0-beta.2
   @nx/cypress        : 16.10.0-beta.2
   @nx/devkit         : 16.10.0-beta.2
   @nx/eslint-plugin  : 16.10.0-beta.2
   @nx/react          : 16.10.0-beta.2
   @nrwl/tao          : 16.10.0-beta.2
   @nx/web            : 16.10.0-beta.2
   @nx/webpack        : 16.10.0-beta.2
   nx-cloud           : 16.4.0
   typescript         : 5.1.3
   ---------------------------------------
   Community plugins:
   @ngrx/component-store : 16.0.0
   @ngrx/effects         : 16.0.0
   @ngrx/entity          : 16.0.0
   @ngrx/router-store    : 16.0.0
   @ngrx/store           : 16.0.0
   @ngrx/store-devtools  : 16.0.0
   ---------------------------------------
   Local workspace plugins:
         @mpsanchis/nx-builder-lib

Failure Logs

None. Runs without warning the end user that the target was not run.

Package Manager Version

any

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@AgentEnder
Copy link
Member

This is expected behavior, runExecutor runs a specific executor. It doesn't spawn the task orchestrator or any of that, so dependencies are not ran and caching is not considered.

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 Nov 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants