I am working on angular module fedration for micro-frontend, most of the setup is done both Shell and MFE is parally working fine, But when I try to use the path for MFE I am getting below error:
ERROR Error: Uncaught (in promise): Error: NG05100: 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: NG05100: Providers from the `BrowserModule` have already been loaded. If you need access to common directives such as NgIf and NgFor, import the `CommonModule` instead.
Not sure what is gone wrong. My MFE webpack config file:
const {
shareAll,
withModuleFederationPlugin,
} = require("@angular-architects/module-federation/webpack");
module.exports = withModuleFederationPlugin({
name: "identity",
exposes: {
"./Module": "./projects/identity/src/app/app.module.ts",
},
shared: {
...shareAll({
singleton: true,
strictVersion: true,
requiredVersion: "auto",
}),
},
});
My webpack config for Shell:
const {
shareAll,
withModuleFederationPlugin,
} = require("@angular-architects/module-federation/webpack");
module.exports = withModuleFederationPlugin({
remotes: {
identity: "http://localhost:4201/remoteEntry.js",
},
shared: {
...shareAll({
singleton: true,
strictVersion: true,
requiredVersion: "auto",
}),
},
});
Everything was auto generated because I used the CLI, Here's the route in Shell App:
import { Routes } from '@angular/router';
export const APP_ROUTES: Routes = [
{
path: 'identity',
loadChildren: () => import('identity/Module').then((m) => m.AppModule),
},
];