angulartypescriptmonorepoangular-module-federation

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.

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. What can be done?

tsconfig example:

"target": "esnext",
"module": "esnext",
"lib": ["esnext", "dom"],

Env: Angular 13, NX Monorepo, @nrwl/angular/module-federation(libs)


Solution

  • Solved. The problem turned out to be in the nginx configuration. We need to add nginx to mime.types

    server
    {
       include mime.types;
       types
       {
          application/javascript mjs;
       }
    
    ...
    
    }