File tree Expand file tree Collapse file tree 3 files changed +31
-22
lines changed Expand file tree Collapse file tree 3 files changed +31
-22
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @module-federation/runtime ' : patch
3
+ ---
4
+
5
+ Register globalFederationInstance from createInstance
Original file line number Diff line number Diff line change @@ -30,7 +30,9 @@ export function createInstance(options: UserOptions) {
30
30
// Retrieve debug constructor
31
31
const ModuleFederationConstructor =
32
32
getGlobalFederationConstructor ( ) || ModuleFederation ;
33
- return new ModuleFederationConstructor ( options ) ;
33
+ const instance = new ModuleFederationConstructor ( options ) ;
34
+ setGlobalFederationInstance ( instance ) ;
35
+ return instance ;
34
36
}
35
37
36
38
let FederationInstance : ModuleFederation | null = null ;
Original file line number Diff line number Diff line change 1
- import { ModuleFederation } from '@module-federation/runtime-core' ;
1
+ import type { ModuleFederation } from '@module-federation/runtime-core' ;
2
2
import { CurrentGlobal } from '@module-federation/runtime-core' ;
3
3
4
4
// injected by bundler, so it can not use runtime-core stuff
@@ -15,26 +15,28 @@ export function getGlobalFederationInstance(
15
15
version : string | undefined ,
16
16
) : ModuleFederation | undefined {
17
17
const buildId = getBuilderId ( ) ;
18
- return CurrentGlobal . __FEDERATION__ . __INSTANCES__ . find ( ( GMInstance ) => {
19
- if ( buildId && GMInstance . options . id === buildId ) {
20
- return true ;
21
- }
18
+ return CurrentGlobal . __FEDERATION__ . __INSTANCES__ . find (
19
+ ( GMInstance : ModuleFederation ) => {
20
+ if ( buildId && GMInstance . options . id === buildId ) {
21
+ return true ;
22
+ }
22
23
23
- if (
24
- GMInstance . options . name === name &&
25
- ! GMInstance . options . version &&
26
- ! version
27
- ) {
28
- return true ;
29
- }
24
+ if (
25
+ GMInstance . options . name === name &&
26
+ ! GMInstance . options . version &&
27
+ ! version
28
+ ) {
29
+ return true ;
30
+ }
30
31
31
- if (
32
- GMInstance . options . name === name &&
33
- version &&
34
- GMInstance . options . version === version
35
- ) {
36
- return true ;
37
- }
38
- return false ;
39
- } ) ;
32
+ if (
33
+ GMInstance . options . name === name &&
34
+ version &&
35
+ GMInstance . options . version === version
36
+ ) {
37
+ return true ;
38
+ }
39
+ return false ;
40
+ } ,
41
+ ) ;
40
42
}
You can’t perform that action at this time.
0 commit comments