I have a federated micro frontend remote component consumed in my main application, that works when it's consumed in the application routes:
path: 'panel',
loadChildren: () => loadRemoteModule({
type: 'module',
remoteEntry: 'http://localhost:4201/remoteEntry.js',
exposedModule: './Module',
}).then(m => m.MainPanelModule)
Here is the MFE/remote webpack config:
module.exports = withModuleFederationPlugin({
name: 'mainPanel',
exposes: {
'./Module': './src/main-panel/main-panel.module.ts',
},
shared: {
...shareAll({ singleton: true, strictVersion: true, requiredVersion: 'auto', eager: true }),
},
});
And here is the main application webpack config:
new ModuleFederationPlugin({
remotes: {
mainPanel: 'http://localhost:4201/remoteEntry.js'
},
shared: share({
"@angular/core": { requiredVersion: 'auto', eager: true },
"@angular/common": { requiredVersion: 'auto', eager: true },
"@angular/common/http": { requiredVersion: 'auto', eager: true },
"@angular/router": { requiredVersion: 'auto', eager: true },
})
}),
These configs work just fine - when I go to http://localhost:4200/panel I can see the remote mfe component. However, I need to consume it directly from another component in the application, not from the routes. For example, in the html, like so:
<main-panel></main-panel>
How can I do that? I am on Angular 14, just upgraded, and I can't go to the next version yet.
I have read various articles on the topic of Micro Frontend Implementation with Module Federation in Angular, but almost all of them are providing an example of consuming the remote from the routes. I found one article where they discuss a potential solution, but they are using another library, and I need to do it without adding any new libraries (if possible). Can this be done?