I tried in webpack.config.ts: instead of

exposes: {
'./Module': './projects/mfe1/src/app/users/users.module.ts',
},

replaced with

exposes: {
"./Module": "./projects/mfe1/src/app/app.module.ts",
},

In app.routes.ts at main shell:

{
    path: 'users',
    loadChildren: () =>
      loadRemoteModule({
        type: 'manifest',
        remoteName: 'mfe1',
        exposedModule: './Module'
      }).then((m) => m.UsersModule), // m.AppModule
}

accessing in the main application, but i get as shown screenshot 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. 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.

enter image description here

enter image description here

1

There are 1 best solutions below

16
Eugene_Kr On

@SaKol, now your imports for UsersModulelooks so?

 @NgModule({
  imports: [
    CommonModule,
    BrowserModule,
    ...
]

Remove BrowserModule from UsersModule imports. 
 @NgModule({
  imports: [
    CommonModule
    ...
]

Try to remove BrowserModule from your new mfe module. I reproduced same error in my app (which use module federation) enter image description here