我使用角度模块联合插件创建了两个角度模块联合应用程序,但在加载远程组件错误图像链接后遇到错误Uncaught (in promise): TypeError: container.init is not a function
我发现这个github问题线程有在webpack.config.js
文件的output
部分添加scriptType: 'text/javascript'
的解决方案,但它对我不起作用。
如果你需要更多关于应用程序的详细信息,这里有主机和远程存储库的链接。
@angular/cli
版本为13.0.2
@angular-architects/module-federation
版本为14.2.3
。
谢谢。
我使用的是angular v14.1.1
和"@angular-architects/module-federation": "^14.3.10", "@angular-architects/module-federation-tools": "^14.3.10", "ngx-build-plus": "^14.0.0"
。
在评论了remote mfe app
webpack.config.js
的library
属性部分后。它对我有效。
module.exports = withModuleFederationPlugin({
name: "angular14",
// library: { type: "var", name: "angular14" },
filename: "remoteEntry.js",
exposes: {
'./web-components': './src/bootstrap.ts',
},
shared: {
...shareAll({ singleton: true, strictVersion: true, requiredVersion: 'auto' }),
},
});
不知道是什么原因,但也可能帮助别人。
使模块联合为Angular独立项目工作。
刚刚作为开发依赖项安装了Webpack5.72.0
Webpack没有列在package.json
的依赖项中,我通过node_modules
文件夹查看了它的版本,它是5.64.0
。