iamaword
iamaword

Reputation: 1509

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?).

Upvotes: 3

Views: 3480

Answers (1)

JanBrus
JanBrus

Reputation: 1510

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.

Upvotes: 0

Related Questions