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

Migrating 14.5.10 to >=14.6.0 Ignores Nx Configuration in package.json #12735

Closed
rhermes62 opened this issue Oct 21, 2022 · 5 comments
Closed

Comments

@rhermes62
Copy link

rhermes62 commented Oct 21, 2022

Current Behavior

We use Lerna with Nx for an NPM monorepo (btw, thanks for taking stewardship of Lerna!).

While trying to upgrade to nx 15 and Lerna 6 from nx 14.4.2 and Lerna 5.1.8, we found our project graph stopped being produced causing tasks to no longer run any of their dependent tasks.

This surfaced itself to us via:

Running target test for 4 project(s)

Compared to the original:

Running target test for 4 project(s) and 14 task(s) they depend on

We eventually narrowed it down to occurring due to changes between 14.5.10->14.6.0 of Nx.

The problem seemed to occur regardless of which version of Lerna we are running and we simulated it all the way up to Lerna 6.0.1 (current).

Whenever attempting to update to any version of Nx >=14.6.0, all of those targets in all child package.json's nx configuration are suddenly ignored which has blocked us from migrating to newer versions of Nx.

I checked the release notes of 14.6.0 and nothing immediately jumped out as a root cause for this behavior except potentially(?) this change and maybe something with the executor context getting messed up when using Nx via Lerna.

Expected Behavior

The nx properties of package.json files are not ignored when using Nx with Lerna.

Steps to Reproduce

Using Lerna 6.0.1 (version doesn't matter from what we tested as long as its >=5.x when Lerna started to support Nx)

We use the following nx.json in the root directory:

{
  "tasksRunnerOptions": {
    "default": {
      "runner": "nx/tasks-runners/default",
      "options": {
        "cacheDirectory": "cache",
        "cacheableOperations": ["build", "lint", "test"]
      }
    }
  }
}

And a child package with the package.json whose nx config of:

{
  ...other package.json properties...
  "nx": {
    "targets": {
      "test": {
        "dependsOn": [
          "build",
          "lint"
        ]
      }
    }
  }
}

Running lerna run test from the root directory used to run build and lint followed by test in Nx <=14.5.10 but after 14.6.0 it only runs test ignoring all of the target dependencies defined in the child package's package.json>nx>targets.

Should be enough info to reproduce given we debugged this for awhile. I will also work on spinning up a repo to replicate the issue. Edit: Created a repo with steps to reproduce https://github.com/rhermes62/nx-14.6.0-ignores-package.json-config

Failure Logs

Up to and including Nx 14.5.10

Running target test for 4 project(s) and 14 task(s) they depend on

= Nx 14.6.0

Running target test for 4 project(s)

Environment

   Node : 12.16.3
   OS   : darwin x64
   npm  : 8.5.3
   
   nx : 15.0.0
   @nrwl/angular : Not Found
   @nrwl/cypress : Not Found
   @nrwl/detox : Not Found
   @nrwl/devkit : 15.0.0
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : Not Found
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 15.0.0
   @nrwl/js : 15.0.0
   @nrwl/linter : 15.0.0
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/rollup : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : Not Found
   @nrwl/web : Not Found
   @nrwl/webpack : Not Found
   @nrwl/workspace : 15.0.0
   typescript : 4.7.4
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:
         lerna: 6.0.1

Thanks for any/all help!

@rhermes62
Copy link
Author

Added a repo to easily reproduce to regression in behavior https://github.com/rhermes62/nx-14.6.0-ignores-package.json-config

@rhermes62
Copy link
Author

rhermes62 commented Oct 28, 2022

Lerna documentation is still referencing using these package.json nx configurations which are not respected in nx >=14.6.0 btw

@rhermes62
Copy link
Author

I was looking more through the 14.6.0 release notes, and I think it may be due to this PR.

@rhermes62
Copy link
Author

rhermes62 commented Nov 4, 2022

I was looking more into how lerna uses nx and it appears to actually be a lerna issue.

Lerna is not taking the nx configurations in nested package.json files into consideration when they set excludeTaskDependencies here.

They only look for an nx.json and targetDefaults opposed to nx.json and (targetDefaults OR nested targets).

This had appeared to be an nx bug originally because nx 14.6.0 added a excludeTaskDependencies that uses that lerna uses.

In reality, the issue was introduced in this commit in lerna 5.6.0.

Reported to lerna instead lerna/lerna#3407

@github-actions
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 Mar 21, 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