Skip to content

Commit 589a3bd

Browse files
authored
fix(runtime): runtime should not pre-register shared while strategy is 'loaded-first' (#2056)
1 parent 7ed1cc0 commit 589a3bd

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

.changeset/hip-cars-drop.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/runtime': patch
3+
---
4+
5+
fix(runtime): runtime should not pre-register shared while strategy is 'loaded-first'

packages/runtime/src/core.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,8 @@ export class FederationHost {
671671
);
672672
if (
673673
!activeVersion ||
674-
(!activeVersion.loaded &&
674+
(activeVersion.strategy !== 'loaded-first' &&
675+
!activeVersion.loaded &&
675676
(Boolean(!eager) !== !activeVersionEager
676677
? eager
677678
: hostName > activeVersion.from))
@@ -699,7 +700,6 @@ export class FederationHost {
699700
register(shareName, shared);
700701
}
701702
});
702-
703703
if (strategy === 'version-first') {
704704
this.options.remotes.forEach((remote) => {
705705
if (remote.shareScope === shareScopeName) {

packages/runtime/src/module/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class Module {
9191
origin: this.host,
9292
});
9393

94-
remoteEntryExports.init(
94+
await remoteEntryExports.init(
9595
initContainerOptions.shareScope,
9696
initContainerOptions.initScope,
9797
initContainerOptions.remoteEntryInitOptions,

packages/runtime/src/type/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,5 +130,5 @@ export type RemoteEntryExports = {
130130
shareScope: ShareScopeMap[string],
131131
initScope?: InitScope,
132132
remoteEntryInitOPtions?: RemoteEntryInitOptions,
133-
) => void;
133+
) => void | Promise<void>;
134134
};

0 commit comments

Comments
 (0)