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
Duplicate entry component rendering for standalone ng component served as independent frontend #14551
Comments
…onents modify entry.routes template to sources app.routes remove entry.routes lazy loading in app.routes closed nrwl#14551
…onents modify entry.routes template to sources app.routes remove entry.routes lazy loading in app.routes closed nrwl#14551
…onents modify entry.routes template to sources app.routes remove entry.routes lazy loading in app.routes closed nrwl#14551
|
When served as independent app, the app should act like a standard Angular application, following the same expected patterns and structures. main -> app component -> app.routes -> entry.routes -> entry.component The reason this wasn’t the case during generation is because Module Federation !== Micro Frontends. The remote apps do not NEED to be independently operable. Module Federation’s core concept is to allow JS modules to be fetched at runtime from a different location than the host. It just enables Micro Frontends. With Nx, we focus purely on the Module Federation aspect, as Micro Frontends themselves come with their own slew of issues. A more correct solution will be to have the remote apps generate a closer structure to a normal angular app. We don’t do it by default, because in most cases of Module Federation, we do not care about having a full app, and rather just the Entry Component that is exposed by Module Federation. If we’re to add this more independent app setup, we should probably place it behind a flag. |
|
I thought MFE was took in account looking at the non-standalone generator. |
|
If you're willing to give it a go, where we:
Then feel free to submit a new PR. But if it's too much work and you don't have the time, I can do it :) Just let me know |
|
Yes, I'm fine with the flow. If you're ok I could give it a shot. |
|
Yeah no problem 🙂 If you need any help feel free to reach out to me again. |
add AppComponent as bootstrap component remove NxWelcome from EntryComponent closed nrwl#14551
|
Not my proudest string manipulation, but I didn't find any The ideal solution would have been to avoid the import and projection of NxWelcomeComponent from the beginning, but unfortunately its logic is part of generic |
|
Not really, the application should be independent of the remote generator. Remote depends on application theres a PR that might help with it, to add a minimal flag that skips the generation of the NxComponentTemplate, so it might be worth waiting until that gets merged, then you can rebase your branch and use that |
|
If that flag can be passed as Schema property to |
|
There has been no movement on this for over a month now, so I'm going to close this issue for now. If this is something that you still feel strongly about, feel free to tag me and we can re-evaluate it. |
|
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. |
Current Behavior
When generating angular standalone component as remote, the entry component is listed inside
entry.routesfor root path''.That's fine when module is lazy loaded by shell app, but gives a problem when served as independent microfrontend.
In that case the entry component is declared into
index.htmltoo, so if arouter-outletgets added somewhere in the tree, the component will be rendered twice.Expected Behavior
When served as independent app, entry.routes should be ignored, and inner routes should be defined into remote's
app.routesdirectly.Github Repo
https://github.com/4javier/monotest
Steps to Reproduce
nx serve shelllocalhost:4200click on "remote" link: a blue square is renderedlocalhost:4201: two squares get renderedNx Report
Failure Logs
No response
Additional Information
I explained extensively the issue and my suggested solution here.
https://dev.to/this-is-angular/nx-module-federation-bad-angular-routing-1ac9
The text was updated successfully, but these errors were encountered: