Native Federation in angular 17

Discussão em 'Angular' iniciado por Rodrigo Torrico, Fevereiro 14, 2025.

  1. 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

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


    app.routes.ts

    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 ()


    tiene menú contextual

    remove that error message

    Continue reading...

Compartilhe esta Página