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

in MFE Change in code trigger the build for all the apps(static-served and devRemotes) #16118

Closed
ak274 opened this issue Apr 5, 2023 · 10 comments · Fixed by #16542
Closed

in MFE Change in code trigger the build for all the apps(static-served and devRemotes) #16118

ak274 opened this issue Apr 5, 2023 · 10 comments · Fixed by #16542
Assignees
Labels
outdated scope: angular Issues related to Angular support in Nx type: bug

Comments

@ak274
Copy link

ak274 commented Apr 5, 2023

Current Behavior

When Dev makes a change in one of the library which has dependency on only one app (passed in --devRemotes) instead of building only that app it retrigger the build for all the remote apps statically served one too.

Expected Behavior

It should only build the app whose dependency has updated with new changes.

GitHub Repo

https://github.com/ak274/mfe-issue

Steps to Reproduce

  1. nx serve host --devRemotes=remote-one
  2. try update ui-form library which is dependency of remote-one App only you will see that change will trigger the build for remote-two also which is static-served.

Note: Because its an empty project the rebuild of both the apps is still fast but in my production app only a small change took ages to reflect on screen as We have 6-7 huge apps.

Nx Report

Node : 18.15.0
   OS   : win32 x64
   npm  : 9.5.0

   nx (global)             : 15.9.2
   nx                      : 15.9.2
   @nrwl/js                : 15.9.2
   @nrwl/jest              : 15.9.2
   @nrwl/linter            : 15.9.2
   @nrwl/workspace         : 15.9.2
   @nrwl/angular           : 15.9.2
   @nrwl/cli               : 15.9.2
   @nrwl/cypress           : 15.9.2
   @nrwl/devkit            : 15.9.2
   @nrwl/eslint-plugin-nx  : 15.9.2
   @nrwl/tao               : 15.9.2
   @nrwl/web               : 15.9.2
   @nrwl/webpack           : 15.9.2
   typescript              : 4.9.5

Failure Logs

No response

Additional Information

No response

@ak274 ak274 added the type: bug label Apr 5, 2023
@AgentEnder AgentEnder added the scope: angular Issues related to Angular support in Nx label Apr 5, 2023
@ak274
Copy link
Author

ak274 commented Apr 10, 2023

@AgentEnder @Coly010 Its really a blocker for a dev who use command nx serve host --devRemotes=remote-app because while updating the code it retrigger the build for all the remotes in the host app.

Please let me know if you were able to reproduce it in the repo?
Or if there's a workaround for this until its fixed.

@Coly010 Coly010 self-assigned this Apr 18, 2023
@Coly010
Copy link
Contributor

Coly010 commented Apr 18, 2023

Hi @ak274, From your example repo, I can see that is doing a rebuild of remote-two. However, it's pulling it from cache, it's not actually rebuilding.

What I can say, is that the repo you've provided appears to have some kind of graphing issue. At least when I run nx graph the graph I'm presented with does not appear to have the edges drawn between the projects correctly. This could be why you're seeing weird behaviour. I'll need to investigate this more to understand what is going on in the workspace.

@ak274
Copy link
Author

ak274 commented Apr 18, 2023

@Coly010 Thanks for looking into it!

Yes I agree that it takes from the cache and its fine. But it should only rebuild or pick from the cache those projects which are dependent of a lib where you make change and should not start picking all the apps from cache. In my actual project because I have around 10 remote apps. Even caching is not good DX.

And it used to work fine in the older versions. I have updated my actual workspace from v15.2.0 to v15.9.2

The repro repository is newly created workspace with v15.9.2

@ak274
Copy link
Author

ak274 commented Apr 25, 2023

Hi @Coly010, Were you able to figure out what's wrong here?

@Coly010
Copy link
Contributor

Coly010 commented Apr 25, 2023

@ak274 Not yet, still looking into. Nx v16 will fix the graphing issues when it's released, but I'll need to look further into why remote-two is still triggering

@Coly010
Copy link
Contributor

Coly010 commented Apr 25, 2023

@ak274 Yep, I've figured out the problem!

Before, the static file server was not watching for changes by default, but when we switched to a common static file server to be used across all frameworks supported by Nx, that one does watch for changes by default.

The fix is to add watch: false to the options of your remote's serve static target:
image

I'll create a PR that adds this when we generate new remotes.

I can't write a migration to do this as it's expected functionality for some serve-static targets

@ak274
Copy link
Author

ak274 commented Apr 27, 2023

@Coly010

Adding watch:false has introduce a new issue now build is not triggering for --devRemotes also.

I added watch:false to all the remotes and made a change to a lib which is dependency for only one remote app and its not triggering the build for the app. App was served with --devRemotes .

Lets say if my remote app's name is remote-one. So I serve it with the following command making changes to a lib which is only dependency for remote-one should rebuild the remote-one.

nx serve host --devRemotes=remote-one

@Coly010
Copy link
Contributor

Coly010 commented Apr 27, 2023

watch:false should only be added to serve-static targets.

It shouldn’t be affecting devRemotes as they use a different target. Can you push your changes to your repo so I can take a look?

@ak274
Copy link
Author

ak274 commented Apr 27, 2023

@Coly010 My bad, its working fine. I was just looking in my terminal when I hit ctrl+s its not showing if something is building.. but browser reload with new changes. So its fine. Sorry to bother you on this! Thanks!

@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 May 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: angular Issues related to Angular support in Nx type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants