'Angular module federation: How to share classes/components from shell to MFE
I am working through a module federation PoC in angular (essentially Manfred's example) and am hoping to find a way to expose utility classes/directives/individual components, and any other code that doesn't necessarily rely on routing to components.
The module federation package @angular-architects/module-federation for angular seems to strictly load in modules based on routing.
I'm hoping to be able to load in and use 'federated module' code , ideally from a 'shared module' (or, on the first pass, from our app 'shell'), without necessarily just loading in components for use in routing. I believe I saw some things involving bidirectional module federation that could answer it but I wasn't seeing anything built into the angular architects package.
What I want to avoid is using something like npm for library management, but I'm not sure module federation is at that point yet (perhaps at least not for angular?).
Solution 1:[1]
One way to load remote module is "statically" on a route as you mentioned. The other way is dynamically. You can call loadRemoteModule anytime anywhere. Manfred Steyer has an example called module-federation-with-angular-dynamic.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | JanBrus |
