angular-architects / module-federation-plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when removing shareall to only share angular libs

sdubourdieu opened this issue · comments

Hello everybody,

today i'm facing an issue. In order to manage Library sharing in my mùicro frontend architecture more precisely i remove the shareAll function from my webpack config to move to a specific sharing :

   shared: share({
       "@angular/core": { singleton: true, strictVersion: true, requiredVersion: 'auto' }, 
        "@angular/common": { singleton: true, strictVersion: true, requiredVersion: 'auto' }, 
        "@angular/common/http": { singleton: true, strictVersion: true, requiredVersion: 'auto' },                     
        "@angular/router": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
    }),

With this change when i try to load my mfe in my shell, i've an injection issue about a class used by the mfe but inject by the shell.

ERROR Error: Uncaught (in promise): NullInjectorError: R3InjectorError
NullInjectorError: No provider for classX

To fix it i'va added a / after @angular/core to include sub package but a new issue appear about injection made outside of injection scope...

core.mjs:10614 ERROR Error: Uncaught (in promise): Error: NG0203: inject() must be called from an injection context such as a constructor, a factory function, a field initializer, or a function used with runInInjectionContext``

do you known how to shared injected class of the shell with the mfe?
(it was working very well with share all)

Thanks in advance for your help.

Best regards

In fact the issue was coming a version mismatch between shell and mfe but only when 'auto' is used in my webpack config files. If i put the same version directly in the settings it works...
this warning appear with auto :
Unsatisfied version 16.2.12 from shell of shared singleton module @angular/core (required ^auto)

do you know why?

Thanks for your help

I guess you need to share further angular-based libs like platform-browser.