0

I am following the below links to create the MFE using Angular Module Federation.

https://github.com/benorama/mfe-basic-demo

https://www.angulararchitects.io/en/aktuelles/the-microfrontend-revolution-part-2-module-federation-with-angular/

After running the project,

ng serve mfe1

I can see the chunk files are generated in the terminal but actually no files when I see in the file explorer, I could not locate the mfe1RemoteEntry.js

enter image description here

Here is my webpack file,

const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin");
const mf = require("@angular-architects/module-federation/webpack");
const path = require("path");
const share = mf.share;

const sharedMappings = new mf.SharedMappings();
sharedMappings.register(
  path.join(__dirname, '../../tsconfig.json'),
  [/* mapped paths to share */]);

module.exports = {
  output: {
    uniqueName: "mfe1",
    publicPath: "auto"
  },
  optimization: {
    runtimeChunk: false
  },   
  resolve: {
    alias: {
      ...sharedMappings.getAliases(),
    }
  },
  plugins: [
    new ModuleFederationPlugin({
      
        name: "mfe1",
        filename: "mfe1RemoteEntry.js",
        exposes: {
            './TodoModule': './projects/mfe1/src/app/todo/todo.module.ts',
        },    
        shared: share({
          "@angular/core": { singleton: true, strictVersion: true, requiredVersion: 'auto' }, 
          "@angular/common": { singleton: true, strictVersion: true, requiredVersion: 'auto' }, 
          "@angular/common/http": { singleton: true, strictVersion: true, requiredVersion: 'auto' }, 
          "@angular/router": { singleton: true, strictVersion: true, requiredVersion: 'auto' },

          ...sharedMappings.getDescriptors()
        })
        
    }),
    sharedMappings.getPlugin()
  ],
};

Any Ideas, please?

Hary
  • 5,690
  • 7
  • 42
  • 79

1 Answers1

1

When you run 'ng serve', the generated chunks will be only in memory and not on disk. After building your project with 'ng build', the files will be on disk.