I have angular 12 microfrontend applications which works fine if I share core components like this
shared: {
'@angular/core': { eager: true, singleton: true },
'@angular/common': { eager: true, singleton: true },
'@angular/router': { eager: true, singleton: true },
},
but if I remove sharing and define both host and child with empty 'shared' like this child:
plugins: [
new ModuleFederationPlugin({
name: 'profile',
library: { type: 'var', name: 'profile' },
filename: 'remoteEntry.js',
exposes: {
ProfileModule: './projects/mdmf-profile/src/app/profile/profile.module.ts',
},
shared: {
},
}),
],
host:
plugins: [
new ModuleFederationPlugin({
shared: {
},
}),
],
I get this error in runtime:
ERROR Error: Uncaught (in promise): Error: inject() must be called from an injection context
Error: inject() must be called from an injection context
at yD (441.js:1:26044)
at Object.gt (441.js:1:26219)
at d.ɵfac [as factory] (441.js:1:168088)
at AE.hydrate (main.js:1:201332)
at AE.get (main.js:1:199395)
at main.js:1:199708
at Set.forEach (<anonymous>)
at AE._resolveInjectorDefTypes (main.js:1:199692)
at new iS (main.js:1:230293)
at hd.create (main.js:1:230989)
at Ge (polyfills.js:1:162723)
at Ge (polyfills.js:1:162219)
at polyfills.js:1:163611
at ce.invokeTask (polyfills.js:1:153753)
at Object.onInvokeTask (main.js:1:235279)
at ce.invokeTask (polyfills.js:1:153672)
at _e.runTask (polyfills.js:1:149032)
at Q (polyfills.js:1:155855)
I tried include angular libraries with 'paths' setting in tsconfig, but it didn't help
"paths": {
"@angular/*": [
"node_modules/@angular/*"
]
},
what should I configure to make it work?