angular-architects / module-federation-plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Native Federation in angular 17

rtorricov94 opened this issue · comments

I'm working on a project in Angular 17 which will use the micro frontend concept, and we've decided to work with Native Federation.
I followed the official website's manual, and everything works correctly, but I'm encountering an error in the terminal. Can someone help me? I detail my code as follows:
project shell:
//federation.manifest.json
{ "mfe1": "http://localhost:4201/remoteEntry.json" }

//main.ts
`
import { initFederation } from '@angular-architects/native-federation';

initFederation('/assets/federation.manifest.json')
.catch(err => console.error(err))
.then(_ => import('./bootstrap'))
.catch(err => console.error(err));
`

//app.routes.ts
`
import { Routes } from '@angular/router';
import { FormExampleComponent } from './main/components/form-example/form-example.component';
import { loadRemoteModule } from '@angular-architects/native-federation';

export const routes: Routes = [
{path: '', component: FormExampleComponent},
{
path: 'flights',
loadComponent: () => loadRemoteModule('mfe1', './Component').then((m) => m.RequestGuarenteeComponent),
}

] ;
`

mfe1:
//federation.config.js
`
const { withNativeFederation, shareAll } = require('@angular-architects/native-federation/config');

module.exports = withNativeFederation({

name: 'mfe1',

exposes: {
'./Component': './src/app/main/guarentee-plataform/request-guarentee/request-guarentee.component.ts',
},

shared: {
...shareAll({ singleton: true, strictVersion: true, requiredVersion: 'auto' }),
},
skip: [
'rxjs/ajax',
'rxjs/fetch',
'rxjs/testing',
'rxjs/webSocket',
// Add further packages you don't need at runtime
]
});
and I encounter this error in the terminal, even though it works correctly and doesn't generate any errors in the browser:
ERROR Error: unknown remote mfe1
at eval (f:/RodrigoTV/project/MicorFrontEnd-beco/main-shell/shellbeco/node_modules/@softarc/native-federation-runtime/fesm2022/softarc-native-federation-runtime.mjs:156:15)
at Generator.next ()
`

idem error

Would be possible to share this in a repo to have a look at it? It might be there's maybe something wrong with the setup of the mfe project.

Here I share with you the repository for the shellbeco and mfe1 projects:
https://github.com/rtorricov94/mfe1.git
https://github.com/rtorricov94/shellbeco.git