[英]Does not work in the production assembly remoteEntry.mjs from nx (Module Federation)
With local development, MF works, however, with a production build of remoteEntry.js from the host to the remote port returns the Failed to fetch dynamically imported module error: http://localhost:2000/remoteEntry.mjs.
但是,对于本地开发,MF 可以使用从主机到远程端口的 remoteEntry.js 生产构建返回Failed to fetch dynamically imported module error: http://localhost:2000/remoteEntry.mjs.
Although it is true.虽然这是真的。 The error is most likely due to the fact that the browser does not process it as a script.该错误很可能是由于浏览器没有将其作为脚本处理。 And I looked at the sources, the js option is not described anywhere.而且我查看了来源,js选项没有在任何地方描述。 What can be done?可以做什么?
tsconfig example: tsconfig 示例:
"target": "esnext",
"module": "esnext",
"lib": ["esnext", "dom"],
Env: Angular 13, NX Monorepo, @nrwl/angular/module-federation(libs)环境:Angular 13、NX Monorepo、@nrwl/angular/module-federation(libs)
Solved.解决了。 The problem turned out to be in the nginx configuration.问题出在 nginx 配置中。 We need to add nginx to mime.types我们需要将 nginx 添加到 mime.types
server
{
include mime.types;
types
{
application/javascript mjs;
}
...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.