角度 17 中的原生联邦

问题描述 投票:0回答:1

我正在 Angular 17 中开发一个项目,该项目将使用微前端概念,我们决定与 Native Federation 合作。 我按照官方网站的手册进行操作,一切正常,但我在终端中遇到错误。有人能帮我吗?我详细说明我的代码如下: 项目外壳:

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
]
});

我在终端中遇到此错误,即使它工作正常并且不会在浏览器中生成任何错误:

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 菜单上下文

删除该错误消息

angular micro-frontend webpack-module-federation
1个回答
0
投票

我遇到了同样的问题,当我停用站点预渲染时,它对我有用。我刚开始创建该项目,所以我只是创建了一个新项目,而没有激活站点预渲染。

希望有帮助!

© www.soinside.com 2019 - 2024. All rights reserved.