简体   繁体   English

不适用于来自 nx(模块联合)的生产程序集 remoteEntry.mjs

[英]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.

相关问题 Nx 模块与 Angular 联合 - 没有 HttpClient 提供程序 - Nx Module Federation with Angular - No provider for HttpClient 如何在 nx 模块联合中使用 BehaviorSubject? - How to use BehaviorSubject in nx module federation? angular 中的模块联邦准备好生产了吗? - Module federation in angular ready for production? 如何在 Angular 和 Nx monorepo 上使用 Module Federation 托管资产 - How to host assets with Module Federation on Angular and Nx monorepo Webpack 5 Module Federation 微前端和 Nx monorepos 是否相互排斥? - Are Webpack 5 Module Federation micro frontends and Nx monorepos mutually exclusive? Angular、Nx 工作区、Webpack 5 模块联合:您提供了一个预期流的无效对象 - Angular, Nx Workspace, Webpack 5 Module Federation: You provided an invalid object where a stream was expected 如何使用带有模块联合和 NX 的通用 shell 创建基于不同技术的微前端? - How to create micro frontends based on different technologies using a common shell with module federation and NX? 使用Nrwl提供的Nx中的数据持久性模块,悲观更新的实现与乐观更新有何不同 - Using the data persistence module in Nx from Nrwl, how does the implementation of a pessimistic update differ from an optimistic update 模块联合 - 没有 AngularFireAuth 的提供者 - Module Federation - No provider for AngularFireAuth Angular 模块联合:如何将类/组件从 shell 共享到 MFE - Angular module federation: How to share classes/components from shell to MFE
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM