nx icon indicating copy to clipboard operation
nx copied to clipboard

Parallel targets

Open YonatanKra opened this issue 1 year ago • 7 comments

Description

When running serve command for a library with implicitDepndencies I'd sometimes want to use dependsOn: ["^serve"] in order to serve the implicit deps for a smooth developer experience. The problem is that the serve of the implicit deps is also watching, so it never stops, hence the original serve doesn't run. Adding a parallel functionality to dependencies can solve this issue.

Motivation

Running multiple serve levels for implicitDepndencies.

Suggested Implementation

Add a targetDependenciesInParallel option that will trigger the other targets in parallel.

Alternate Implementations

Build a dedicated serve mechanism that will do the following:

  1. Run the dependable targets in parallel with the dependent target
  2. Optionally allow to state an output that marks "waiting for changes" in the dependable target that the dependent target will wait for before starting its own script.

YonatanKra avatar Aug 14 '23 12:08 YonatanKra

Here's the workaround we currently use:

#on foo.project

{
    "watch": {
      "executor": "nx:run-commands",
      "options": {
        "command": "nx run foo:serve",
        "readyWhen": "Started on http://localhost:4015/foo",
        "parallel": true
      }
}

Then in the main project, I change "^serve" to ^watch`. But we do have problems with parallel processes terminating at times.

LongLiveCHIEF avatar Aug 22 '23 14:08 LongLiveCHIEF

As such, I would also be willing to collaborate with @YonatanKra in developing and testing of this feature.

LongLiveCHIEF avatar Aug 22 '23 17:08 LongLiveCHIEF

Another alternative would be to biuld a "parallel" executor, that allows you to define child targets:

{
   "targets": {
     "foo": {
       "executor": "@nx/parallel",
       "options": {
         "childTargets" : [{
           "target": "bar:serve:development",
            "reloadIfrunning": true,
            "killOnExit": true
            },
            { 
              "target": "baz:watch:production"
              }
         ],

LongLiveCHIEF avatar Aug 23 '23 13:08 LongLiveCHIEF

@LongLiveCHIEF It's actually what I started building locally :) Before committing to a PR on Nx, I'd like feedback from maintainers to know what would be the best course of action for this (if any).

YonatanKra avatar Aug 23 '23 13:08 YonatanKra

I'm interested in their thoughts as well. This has to have come up before.

LongLiveCHIEF avatar Aug 23 '23 13:08 LongLiveCHIEF

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

github-actions[bot] avatar Apr 30 '24 00:04 github-actions[bot]

This should still be in scope right?

LongLiveCHIEF avatar Apr 30 '24 18:04 LongLiveCHIEF

I think this may be what you're looking for? #23273 Please contribute to the discussion there.

FrozenPandaz avatar May 15 '24 22:05 FrozenPandaz

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 Jun 15 '24 00:06 github-actions[bot]