Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sharing a service between sell and remote apps #643

Open
amiraghelan opened this issue Sep 15, 2024 · 0 comments
Open

Sharing a service between sell and remote apps #643

amiraghelan opened this issue Sep 15, 2024 · 0 comments

Comments

@amiraghelan
Copy link

Hi,
In my module federation app, I want to expose a service from my remotes to the shell app.
The reason I'm doing this is that I want to call this service at the start for all my remote apps. (some of them never be used, but the service is needed)
currently I am doing something like this:

//webpack:
exposes: {
    './Service': './mfe1/src/app/exposed/remote.service.ts',

  }
//usage:
 async loadeRemoteService(){
            let service: IRemoteService;
            await loadRemoteModule(
            {
                type: 'manifest',
                remoteName: "mfe1",
                exposedModule: './Service'
            }).then(m => {
                service = new m.RemoteService(this.http);
            })
        }
    }

But this approach is causing problems like the name of the service should be the same in all remote apps or I can't use dependency injection(I should pass the dependencies myself and for some of them I can't do that) and overall doesn't look like a good practice.
what is the best way to achieve this? is sharing a whole module the way to go? if it is, how it is implemented.
any help, sample or reference is very much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant