nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.22k stars 2.31k forks source link

nx doesn't build the deps projects when they change #15113

Open wizardnet972 opened 1 year ago

wizardnet972 commented 1 year ago

Current Behavior

I build a repo nx-swc with cli and utils swc libs (both buildable).

When I change this file in utils project cli doesn't affect by this change.

In the cli I add serve executor target (@nrwl/js:node) and I run it yarn nx serve cli, when I change the file in utils the cli not build again.

The cli is depended on utils by this import I would expect from nx to know that dependency has changed.

Expected Behavior

When repo dependency change, should rebuild the project.

GitHub Repo

https://github.com/wizardnet972/nx-swc

Steps to Reproduce

  1. clone the project.
  2. run yarn install
  3. run yarn nx serve cli
  4. make some change in packages/utils/src/lib/utils.ts and then save the file. you can see the cli doesn't rebuild.

-- another scenario --

  1. run yarn nx run-many --target build --all
  2. run yarn nx serve cli
  3. check for the console
  4. change the output of the console in packages/utils/src/lib/utils.ts and then save the file.
  5. run yarn nx serve cli again and you can see that nothing change.

Nx Report

>  NX   Report complete - copy this into the issue template

   Node : 18.13.0
   OS   : darwin arm64
   npm  : 9.3.0

   nx                      : 15.7.2
   @nrwl/jest              : 15.7.2
   @nrwl/linter            : 15.7.2
   @nrwl/workspace         : 15.7.2
   @nrwl/cli               : 15.7.2
   @nrwl/devkit            : 15.7.2
   @nrwl/eslint-plugin-nx  : 15.7.2
   @nrwl/js                : 15.7.2
   @nrwl/tao               : 15.7.2
   typescript              : 4.8.4

✨  Done in 0.97s.


### Failure Logs

_No response_

### Additional Information

_No response_
owl-app commented 1 year ago

@wizardnet972 the same problem

pawelkeska commented 1 year ago

@wizardnet972 and when i remove package from node_modules everything works

wizardnet972 commented 1 year ago

My package is located in the libs directory, rather than the node_modules directory, so this cannot be the solution.

jon9090 commented 1 year ago

@FrozenPandaz I am encountering the same issue where Nx fails to rebuild the package even when its library dependencies have changed.

This poses a challenge for utilizing Nx with interconnected multiple packages. This problem is of utmost importance for anyone utilizing Nx.

SebasG22 commented 1 year ago

I'm getting the same error on the latest version. It's weird because this was working in previous versions and now the most simple example does not work.

Also, this can be related to #16030.

Any help would be greatly appreciated. @FrozenPandaz @AgentEnder @mandarini

jon9090 commented 1 year ago

@SebasG22 you can vote in the @wizardnet972 post to promote the issue

wizardnet972 commented 1 year ago

I am encountering an issue where projects that were upgraded to v15.9.2 are experiencing the same problem, as the application fails to re-run after changes are made in the library (node/express). This has resulted in a significant amount of work and frustration. I am curious if this issue is present in other projects as well. @FrozenPandaz @AgentEnder Could you kindly offer your perspective on this matter? Are you familiar with it?

ikosta commented 1 year ago

Yeah... just tried to upgrade from 15.8.5 to 15.9.2 and the build fails. If there are dependencies between two @nrwl:js libs, the lib that depends on the other can't be build: error TS6059: File '/nx/libs/auth/src/index.ts' is not under 'rootDir' 'libs/core-events'. 'rootDir' is expected to contain all source files.

jaysoo commented 1 year ago

@ikosta Can you open a new issue to track that, with a reproduction repo? It's a separate issue.

It looks like file change events are not working for dependencies, which is why the process is not reloaded. We'll look into this.

jaysoo commented 1 year ago

Took a closer look, and the problem is two-fold:

  1. File change events are not watching for changes in dependencies (as noted above).
  2. When running re-compiling the parent project (cli in the example), dependencies are not re-compiled.

(1) is a relatively simple fix if we ask the Nx daemon to also notify on dependency changes. (2) needs some work to make sure the dependency is also built during watch.

wizardnet972 commented 1 year ago

@jaysoo, I greatly appreciate your efforts in looking into this matter. I was wondering if the issue I reported at https://github.com/nrwl/nx/issues/16530 is connected to the current problem we are facing. My suspicion stems from the way nx handles dependency resolution.

jaysoo commented 1 year ago

@wizardnet972 Thats' a different issue. This issue is about the watch mode not rebuilding dependencies and re-launching the process. I'll take a look at the other issue.

wizardnet972 commented 1 year ago

@jaysoo Could you please suggest a possible solution for this issue? Additionally, I would appreciate it if you could provide an update on when the resolution is expected

alxrodav commented 1 year ago

Any update here?

AshHeskes commented 1 year ago

I'm seeing this too. It seems the logical order of how commands are ran is backwards from expectation..

e.g. for a project like:

+ app1
+ lib1
+ lib2

Where:

Then starting e.g. nx watch --all -- nx run \$NX_PROJECT_NAME:build:

You expect it to work the other way. Where:

In other words the current behaviour seems to run commands on a fan in basis, where people expect it to fan out.

bobalazek commented 1 year ago

I have started experiencing the same issue. For me it seem to have worked fine in v16.5.0, but when I upgraded to v16.7.2 it stopped working. Any solutions for that, besides a downgrade?

biz812 commented 1 year ago

We have also begun to experience this issue, like the previous post we went from v16.5.4 to v16.7.4. This issue has been open since well before the release of 16.5.x but we haven't experienced it until now... I wonder if this is a regression somewhere?

a-c-m commented 9 months ago

I'm not sure if I don't have things configured correctly or if this bug is still present in 17.1.3 ?

I seem to be able to have app depend on the build of lib1, but when i change lib1, its not re-triggering the build of lib1.

erikshestopal commented 9 months ago

@jaysoo any suggestions on how to proceed here?

erikshestopal commented 7 months ago

@jaysoo sorry for the ping - is this a known limitation -- dependencies not being rebuilt?

jonlambert commented 5 months ago

Apologies for the ping too, but this is a huge issue to encounter after dedicating time to moving to Nx. I'm noticing this specifically in a release process – when a dependency is updated, I would hope that the dependant would have the new version referenced and be rebuilt/released too?

I thought this was something we were doing wrong with configuration. Is there any acknowledgement of this issue?

jellebrouwer commented 3 months ago

In the options of the serve target: "runBuildTargetDependencies": true

noelsoong commented 2 weeks ago

updated from 18.3.3 to 19.6.3 and got this issue.