Open alexUXUI opened 1 month ago
Hey Alex. This angular example is likely quite old, since it was backported from v1 federation doc site and since then angular has largely gone off into the esbuild tooling ecosystem.
What i would suggest is we loop in @zackarychapple and @Coly010 who both have vastly more experience in angular + federaiton. I know @Coly010 just got angular builds working with rspack, and NX team most likely knows how what needs to be done in modern angular etc, and of course would love an update the information on this page as well.
The import bootstrap should no longer be needed if you set experiments.federationRuntime = hoisted
on the plugin. https://module-federation.io/configure/experiments.html - this feature was added last week i think.
That said we should include it in the docs like it is elsewhere
Just do
npx create-nx-workspace acme
select none and integrated repocd acme
then npx nx add @nx/angular
npx nx g @nx/angular:host shell —remotes=remote1,remote2
And you’ll have an Angular MF setup using @module-federation/enhanced
.
It’ll still be Webpack for now until I get https://github.com/coly010/ng-rspack-build more stable
thats fine, as long as he has a angular + federation v2 reference. Where could he see the ejected configs if he needs to for instance if he not in nx already and has debt repo that needs manual implementation - where could he go to see how you apply the plugin, what you share be default etc for angular to actuallty work?
Here: https://github.com/nrwl/nx/blob/master/packages/angular/src/utils/mf/with-module-federation.ts
But it's not so simple when it comes to the shared packages.
We use the Nx project graph to figure out the packages that need to be shared and the version at which to share them.
General rule of thumb if doing it manually with Angular is to share all angular runtime packages that exist in the package.json, including any secondary entrypoints, at the version currently installed.
use npm ls @angular/core
to find the actual installed version, or dig through your lock
file.
Then these packages at the very least need to be shared:
@angular/animations
@angular/core
@angular/common
@angular/common/http
@angular/localize
@angular/platform-browser
zone.js
someone shipped a example with federation/vite package. I have not tried it tho
Clear and concise description of the problem
As a dev using
@module-federation/enhanced
, I would love an example repo showing the set up I need to use@module-federation/enhanced
in my angular projects.Currently, I am following the truly wonderful documentation page on angular and mf enhanced.
It is a fantastic resource and I am loving all the new documentation sites.
I notice there is one step missing from this page that is on the previous example here, which is adding the
bootstrap.ts
async boundary.I think maybe there could be some other steps missing because I cannot seem to follow the guide and make it work on my own.
Suggested solution
One idea we could collaborate on is:
@module-federation/enhanced
in the MF Examples repo, based on the guide in the doc siteAlternative
One alternative approach could be:
Update the documentation page with the complete source code needed, using collapsable blocks of content to prevent the documentation from becoming too verbose.
Additional context
I am so deeply appreciative of all the OSS work the Byte infra and MF teams do.
Thank you so much for your consideration and support on this request.
If there is interest in this request, I would love to help however I can, just need some guidance on properly configuring
@module-federation/enhanced
+ Angular.Validations