File tree Expand file tree Collapse file tree 3 files changed +28
-3
lines changed
libs/native-federation-runtime/src/lib/model Expand file tree Collapse file tree 3 files changed +28
-3
lines changed Original file line number Diff line number Diff line change 1
1
import { SharedInfo } from './federation-info' ;
2
+ import { globalCache } from './global-cache' ;
2
3
3
- const externals = new Map < string , string > ( ) ;
4
+ const externals = globalCache . externals ;
4
5
5
6
function getExternalKey ( shared : SharedInfo ) {
6
7
return `${ shared . packageName } @${ shared . version } ` ;
Original file line number Diff line number Diff line change
1
+ import { Remote } from './remotes' ;
2
+
3
+ export const nfNamespace = '__NATIVE_FEDERATION__' ;
4
+
5
+ export type NfCache = {
6
+ externals : Map < string , string > ;
7
+ remoteNamesToRemote : Map < string , Remote > ;
8
+ baseUrlToRemoteNames : Map < string , string > ;
9
+ } ;
10
+
11
+ export type Global = {
12
+ [ nfNamespace ] : NfCache ;
13
+ } ;
14
+
15
+ const global = globalThis as unknown as Global ;
16
+
17
+ global [ nfNamespace ] ??= {
18
+ externals : new Map < string , string > ( ) ,
19
+ remoteNamesToRemote : new Map < string , Remote > ( ) ,
20
+ baseUrlToRemoteNames : new Map < string , string > ( ) ,
21
+ } ;
22
+
23
+ export const globalCache = global [ nfNamespace ] ;
Original file line number Diff line number Diff line change 1
1
import { FederationInfo } from './federation-info' ;
2
+ import { globalCache } from './global-cache' ;
2
3
3
4
export type Remote = FederationInfo & {
4
5
baseUrl : string ;
5
6
} ;
6
7
7
- const remoteNamesToRemote = new Map < string , Remote > ( ) ;
8
- const baseUrlToRemoteNames = new Map < string , string > ( ) ;
8
+ const remoteNamesToRemote = globalCache . remoteNamesToRemote ;
9
+ const baseUrlToRemoteNames = globalCache . baseUrlToRemoteNames ;
9
10
10
11
export function addRemote ( remoteName : string , remote : Remote ) : void {
11
12
remoteNamesToRemote . set ( remoteName , remote ) ;
You can’t perform that action at this time.
0 commit comments