nx: nx doesn't build the deps projects when they change
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
- clone the project.
- run yarn install
- run yarn nx serve cli
- make some change in
packages/utils/src/lib/utils.tsand then save the file. you can see the cli doesn’t rebuild.
– another scenario –
- run yarn nx run-many --target build --all
- run yarn nx serve cli
- check for the console
- change the output of the console in
packages/utils/src/lib/utils.tsand then save the file. - 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_
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 23
- Comments: 21 (8 by maintainers)
@jaysoo sorry for the ping - is this a known limitation – dependencies not being rebuilt?
@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.
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.
@wizardnet972 the same problem
@jaysoo any suggestions on how to proceed here?
Took a closer look, and the problem is two-fold:
cliin 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.
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:
Where:
app1depends onlib2andlib1lib2depends onlib1.Then starting e.g.
nx watch --all -- nx run \$NX_PROJECT_NAME:build:lib1onlylib1gets rebuilt even thoughlib2andapp1depend on it.app1thenlib2gets rebuilt, thenapp1gets rebuilt.You expect it to work the other way. Where:
lib1thenlib1gets rebuilt, thenlib2gets rebuilt, thenapp1gets rebuilt.app1then onlyapp1gets rebuilt as nothing depends on it.In other words the current behaviour seems to run commands on a fan in basis, where people expect it to fan out.
@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.
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?
@SebasG22 you can vote in the @wizardnet972 post to promote the issue
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