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) {
3030 // Retrieve debug constructor
3131 const ModuleFederationConstructor =
3232 getGlobalFederationConstructor ( ) || ModuleFederation ;
33- return new ModuleFederationConstructor ( options ) ;
33+ const instance = new ModuleFederationConstructor ( options ) ;
34+ setGlobalFederationInstance ( instance ) ;
35+ return instance ;
3436}
3537
3638let 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' ;
22import { CurrentGlobal } from '@module-federation/runtime-core' ;
33
44// injected by bundler, so it can not use runtime-core stuff
@@ -15,26 +15,28 @@ export function getGlobalFederationInstance(
1515 version : string | undefined ,
1616) : ModuleFederation | undefined {
1717 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+ }
2223
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+ }
3031
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+ ) ;
4042}
You can’t perform that action at this time.
0 commit comments