Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions libs/mf-runtime/src/lib/loader/dynamic-federation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ type Scope = unknown;
type Factory = () => any;

type Container = {
init(shareScope: Scope): void;
get(module: string): Factory;
init(shareScope: Scope): void | Promise<void>;
get(module: string): Factory | Promise<Factory>;
};

let config: Manifest = {};
Expand Down Expand Up @@ -113,8 +113,8 @@ async function loadRemoteModuleEntry(remoteEntry: string): Promise<void> {
return Promise.resolve();
}
return await import(/* webpackIgnore:true */ remoteEntry).then(
(container) => {
initRemote(container, remoteEntry);
async (container) => {
await initRemote(container, remoteEntry);
containerMap[remoteEntry] = container;
},
);
Expand All @@ -140,11 +140,15 @@ async function loadRemoteScriptEntry(

script.onerror = reject;

script.onload = () => {
script.onload = async () => {
const container = (window as unknown as Record<string, unknown>)[
remoteName
] as Container;
initRemote(container, remoteName);
try {
await initRemote(container, remoteName);
} catch (error) {
reject(error);
}
containerMap[remoteName] = container;
resolve();
};
Expand Down
Loading