I'm trying to share a module, with a component with two services, a business service, and a state service created with rxjs. I'm have two applications as a multi repo and want to share this module with the state to those two applications with module federation.
X SHELL
module.exports = withModuleFederationPlugin({
name: "X",
filename: "oneApp.js",
remotes: {
"X": "http://localhost:4200/xApp.js",
},
exposes: {
"./XHeader': "./x/index",
},
shared: share({
MFE
module.exports = withModuleFederationPlugin({
name: 'mfe-app',
remotes: {
'X': 'http://localhost:4200/xApp.js',
},
exposes: {
'./Module': './src/app/main/main.module.ts',
},
I tried exposing this module with the module federation, but trying to import in the AppModule of those applications is returning "Value at position X in the NgModule.imports of AppModule is not a reference. Value could not be determined statically."
What do you think is the best way to do this? All the tutorials do this with a library, but all of those are monorepos using the tsconfig path approach.
Thank you all.
UPDATE
I found a solution using the global injectors, you can set in your shell app a provider like:
{
provide: 'GLOBAL_SERVICE',
useClass: Service
}
And then you can use in the MFE your service doing the injection from this global service.
@Inject('GLOBAL_SERVICE') private service: Service