我目前正在开发一个使用Webpack5模块联盟和Angular的微前端架构的项目。我正在处理一个有点奇怪的问题。事实上,我所有的微前端(远程)都可以单独工作,但在将它们集成到shell (主机)中时。我有一个错误出现,并显示了一些错误的应用程序。
ERROR TypeError: You provided an invalid object where a stream was expected.
You can provide an Observable, Promise, Array, or Iterable.此错误来自Angular Core,尤其是当存在集成的Angular材质组件时。
关于这个问题最疯狂的事情是,当我激活chrome扩展"Redux Dev Tools“时,它已经不存在了。你有什么想法吗?
共享库可能有问题,但我不知道在哪里?
我对主机和远程的各种配置。
Shell:
new ModuleFederationPlugin({
remotes: {
// all remotes that will be used in the shell
'designer': "designer@http://localhost:4201/remoteEntry.js",
'library':"library@http://localhost:4202/remoteEntry.js"
},
shared: {
// all libraries that will be shared with microfrontends
"@angular/core": { singleton: true, strictVersion: false },
"@angular/common": { singleton: true, strictVersion: false },
"@angular/router": { singleton: true, strictVersion: false },
"@angular/forms":{ singleton: true, strictVersion: false },
"@angular/cdk":{ singleton: true, strictVersion: false },
"@angular/material":{ singleton: true, strictVersion: false },
//"@ngx-translate/core":{ singleton: true, strictVersion: false },
"@bl/auth-token": { singleton: true, strictVersion: false },
//"@bl/elements": { singleton: true, strictVersion: false },
"@bl/theme": { singleton: true, strictVersion: false },
"@bl/shared": { singleton: true, strictVersion: false },
"@bl/bl-app-layout": { singleton: true, strictVersion: false },
}
})远程1:
new ModuleFederationPlugin({
// For remotes (please adjust)
name: "library",
filename: "remoteEntry.js",
exposes: {
'./web-components': './src/bootstrap.ts',
},
shared: {
"@angular/core": { singleton: true, strictVersion: false },
"@angular/common": { singleton: true, strictVersion: false },
"@angular/router": { singleton: true, strictVersion: false },
"@angular/forms":{ singleton: true, strictVersion: false },
"@angular/cdk":{ singleton: true, strictVersion: false },
"@angular/material":{ singleton: true, strictVersion: false },
//"@ngx-translate/core":{ singleton: true, strictVersion: false },
"@bl/auth-token": { singleton: true, strictVersion: false },
//"@bl/elements": { singleton: true, strictVersion: false },
"@bl/theme": { singleton: true, strictVersion: false },
"@bl/shared": { singleton: true, strictVersion: false },
"@bl/bl-app-layout": { singleton: true, strictVersion: false },
}
}),远程2:
new ModuleFederationPlugin({
// For remotes (please adjust)
name: "designer",
filename: "remoteEntry.js",
exposes: {
'./web-components': './src/bootstrap.ts',
},
shared: {
"@angular/core": { singleton: true, strictVersion: false },
"@angular/common": { singleton: true, strictVersion: false },
"@angular/router": { singleton: true, strictVersion: false },
"@angular/forms":{ singleton: true, strictVersion: false },
"@angular/cdk":{ singleton: true, strictVersion: false },
"@angular/material":{ singleton: true, strictVersion: false },
//"@ngx-translate/core":{ singleton: true, strictVersion: false },
"@bl/auth-token": { singleton: true, strictVersion: false },
//"@bl/elements": { singleton: true, strictVersion: false },
"@bl/theme": { singleton: true, strictVersion: false },
"@bl/shared": { singleton: true, strictVersion: false },
"@bl/bl-app-layout": { singleton: true, strictVersion: false },
}
}),发布于 2021-07-29 20:25:43
我刚遇到了和你一样的问题。对我来说,向ModuleFederationPlugin中的共享库添加rxjs和rxjs/操作符解决了这个问题。我为shell和远程应用程序添加了以下库:
'rxjs': { singleton: true, strictVersion: true, requiredVersion: 'auto' },
'rxjs/operators': { singleton: true, strictVersion: true, requiredVersion: '~6.6.0' }有必要显式地共享rxjs/运算符,并给出一个固定的版本号来使用,如示例所示。
https://stackoverflow.com/questions/67018041
复制相似问题