manfredsteyer / module-federation-with-angular-dynamic

Dynamic Module Federation with Angular
122 stars 68 forks source link

Singleton service all over the app #68

Open arielBarZoomInfo opened 1 year ago

arielBarZoomInfo commented 1 year ago

image according to the diagram, I tried to make some service as a singleton (service 1) all over the app (shell+remote+shared lib), service 1 is placed in shared lib. between the shell & remote it's working (there is one instance of service 1), but when I import a module from the shared lib that use service 1 Another instance of service 1 is created.

what am I missing?

pacoita commented 1 year ago

We had an issue where a new service instance in our shared library was created each time we triggered a new build of a single mfe. The problem was that we were setting a new version in the package.json, and the shared lib was taking that, resulting in a different version used by the shell and other mfes.

image

I would suggest you to double-check the bundles and see if the version used by the shared lib is the same across all mfes/shell.