From 561591707ee126bb13c12c3d9397ba2c94e50328 Mon Sep 17 00:00:00 2001 From: Manfred Steyer Date: Sat, 4 Jun 2022 20:17:38 +0200 Subject: [PATCH] feat(mf-runtime): load remotes in parallel --- libs/mf-runtime/src/lib/loader/dynamic-federation.ts | 8 ++++++-- libs/mf/src/utils/share-utils.ts | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libs/mf-runtime/src/lib/loader/dynamic-federation.ts b/libs/mf-runtime/src/lib/loader/dynamic-federation.ts index 04969b80..ef31c9ea 100644 --- a/libs/mf-runtime/src/lib/loader/dynamic-federation.ts +++ b/libs/mf-runtime/src/lib/loader/dynamic-federation.ts @@ -233,14 +233,18 @@ function parseConfig(config: DynamicMfConfigFile): ParsedMfConfigFile { } async function loadRemoteEntries() { + const promises: Promise[] = []; + for (let key in config) { const entry = config[key]; if (entry.type === 'module') { - await loadRemoteEntry({ type: 'module', remoteEntry: entry.remoteEntry }); + promises.push(loadRemoteEntry({ type: 'module', remoteEntry: entry.remoteEntry })); } else { - await loadRemoteEntry({ type: 'script', remoteEntry: entry.remoteEntry, remoteName: key }); + promises.push(loadRemoteEntry({ type: 'script', remoteEntry: entry.remoteEntry, remoteName: key })); } } + + await Promise.all(promises); } \ No newline at end of file diff --git a/libs/mf/src/utils/share-utils.ts b/libs/mf/src/utils/share-utils.ts index ae5005b8..b35599db 100644 --- a/libs/mf/src/utils/share-utils.ts +++ b/libs/mf/src/utils/share-utils.ts @@ -244,6 +244,7 @@ export function share(shareObjects: Config, packageJsonPath = ''): Config { return result; } + function addSecondaries(secondaries: Record, result: {}) { for (const key in secondaries) { result[key] = secondaries[key];