0

How to extract the Component from module federation remote module

At present I am having the below code

Remote code:

exposes: {
        './TodoModule': './src/todo/todo.module.ts',
        './TodoComponent': './src/todo/todo.component.ts'
    },

Shell Code:

const {TodoComponent} = await loadRemoteModule({
  type: 'module',
  remoteEntry: 'http://localhost:4300/remoteEntry.js',
  exposedModule: './TodoComponent',
});
this.ref.createComponent(TodoComponent);

So its working as expected.

Now I want to do the same without exposing the component

Remote Code:

exposes: { './TodoModule': './src/todo/todo.module.ts' },

Shell Code:

const {TodoModule} = await loadRemoteModule({
  type: 'module',
  remoteEntry: 'http://localhost:4300/remoteEntry.js',
  exposedModule: './TodoModule',
});

I need to extract a particular component from it and add it in the below code

this.ref.createComponent(TodoComponent);

Do we have any way to extract the Component from the above Module?

2
  • Could you please provide further details for the use case and explain why you don't want to expose the component from the remote MFE?
    – Amer
    Commented Jul 3 at 22:10
  • Because I have lot of components are there. Also when we load the application module, it will bootstrap all the required configs. For eg: Routing, NgRx etc.
    – Gnik
    Commented Jul 4 at 6:15

0