Skip to content

Commit

Permalink
feat(react): support setRemoteDefinition api
Browse files Browse the repository at this point in the history
  • Loading branch information
Guilherme Prezzi committed Jul 22, 2024
1 parent 4aceafa commit e81fe21
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/react/mf/dynamic-federation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ declare const document: {

declare const __webpack_init_sharing__: (scope: 'default') => Promise<void>;
declare const __webpack_share_scopes__: { default: unknown };
let remoteUrlDefinitions: Record<string, string>;
let remoteUrlDefinitions: Record<string, string> = {};
let resolveRemoteUrl: ResolveRemoteUrlFunction;
const remoteModuleMap = new Map<string, unknown>();
const remoteContainerMap = new Map<string, unknown>();
Expand All @@ -31,6 +31,10 @@ export function setRemoteDefinitions(definitions: Record<string, string>) {
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)) {
Expand Down

0 comments on commit e81fe21

Please sign in to comment.