From e81fe21fa377ea15e86cbe6d6b686c42cb723c70 Mon Sep 17 00:00:00 2001 From: Guilherme Prezzi Date: Mon, 22 Jul 2024 16:34:30 -0300 Subject: [PATCH] feat(react): support setRemoteDefinition api --- packages/react/mf/dynamic-federation.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/react/mf/dynamic-federation.ts b/packages/react/mf/dynamic-federation.ts index 4584452c2d171..5f5e60eeec7e2 100644 --- a/packages/react/mf/dynamic-federation.ts +++ b/packages/react/mf/dynamic-federation.ts @@ -15,7 +15,7 @@ declare const document: { declare const __webpack_init_sharing__: (scope: 'default') => Promise; declare const __webpack_share_scopes__: { default: unknown }; -let remoteUrlDefinitions: Record; +let remoteUrlDefinitions: Record = {}; let resolveRemoteUrl: ResolveRemoteUrlFunction; const remoteModuleMap = new Map(); const remoteContainerMap = new Map(); @@ -31,6 +31,10 @@ export function setRemoteDefinitions(definitions: Record) { remoteUrlDefinitions = definitions; } +export function setRemoteDefinition(remoteName: string, remoteUrl: string) { + remoteUrlDefinitions[remoteName] = remoteUrl; +} + export async function loadRemoteModule(remoteName: string, moduleName: string) { const remoteModuleKey = `${remoteName}:${moduleName}`; if (remoteModuleMap.has(remoteModuleKey)) {