I'm using Angular 14 and module federation. I have this in my child application
module.exports = withModuleFederationPlugin({
name: 'childapp',
exposes: {
'./app1': './src/app/app.module.ts',
},
shared: {
...shareAll({ singleton: true, strictVersion: true, requiredVersion: 'auto' }),
},
});
In my shell application, I invoke the child using routes like so
{
path: 'my-child-path',
loadChildren: () =>
loadRemoteModule({
type: 'module',
remoteEntry: 'http://localhost:8001/remoteEntry.js',
exposedModule: './app1',
}).then((m) => m.AppModule),
},
However, when I load access the route from the shell application in a browser, I get the JS console error
ERROR Error: Uncaught (in promise): Error: Providers from the `BrowserModule` have already been loaded. If you need access to common directives such as NgIf and NgFor, import the `CommonModule` instead.
In my child app.module.ts file I have
@NgModule({
declarations: [AppComponent],
imports: [
BrowserModule,
BrowserAnimationsModule,
...
],
providers: [
BrowserAnimationsModule,
HttpClientModule,
...
],
bootstrap: [AppComponent],
})
export class AppModule {}
but if I remove the "BrowserModule" and "BrowserAnimationMoudle" from the child app.module, I get the JS console error
NullInjectorError: NullInjectorError: No provider for Compiler!
when I attempt to load the child application. How do I solve this madness?