gle*_*erp 15 webpack angular webpack-5 webpack-module-federation
我正在尝试让我相当复杂的整体应用程序与模块联合一起使用。我的 webpack 配置看起来像这样
plugins: [
new ModuleFederationPlugin({
remotes: {
"mfe1": "mfe1@http://localhost:3000/remoteEntry.js",
},
shared: {
"@angular/core": { singleton: true, strictVersion: true },
"@angular/common": { singleton: true, strictVersion: true },
"@angular/router": { singleton: true, strictVersion: true },
...sharedMappings.getDescriptors()
}
}),
sharedMappings.getPlugin(),
],
Run Code Online (Sandbox Code Playgroud)
微前端方面的共享是相同的。当我尝试运行该应用程序时,我得到:
错误:共享单例模块@angular/common的版本11.2.1不满足(需要^7.2.0)
在此之前,我收到了类似的错误消息,但针对的是角度/核心。我通过重新运行纱线并修复库根据不同的角度/核心版本产生的所有警告来解决这个问题。
但由于错误 fpr Angular/common 我陷入困境。我不知道如何找出哪个库可能会产生该错误。
您可能应该指定requiredVersion 每个共享项目。如果您没有指定它,webpack 将尝试不仅从您的主 package.json 中确定版本,而且还会从使用 node_modules 中的这些角度库的任何 npm 包中确定版本。
每当您导入使用 Angular 的第三方模块时,它都会扫描 package.json 中的该模块,并基于该模块添加另一个条目版本范围映射。这可能会导致不必要的行为,并且可能是您所看到的内容的原因。