File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ export function prodRemotePlugin(
49
49
} )
50
50
}
51
51
52
+ const shareScope = options . shareScope || 'default'
52
53
return {
53
54
name : 'originjs:remote-production' ,
54
55
virtualFile : options . remotes
@@ -73,11 +74,21 @@ export function prodRemotePlugin(
73
74
return module
74
75
})
75
76
}
77
+
78
+ function merge(obj1, obj2) {
79
+ const mergedObj = Object.assign(obj1, obj2);
80
+ for (const key of Object.keys(mergedObj)) {
81
+ if (typeof mergedObj[key] === 'object' && typeof obj2[key] === 'object') {
82
+ mergedObj[key] = merge(mergedObj[key], obj2[key]);
83
+ }
84
+ }
85
+ return mergedObj;
86
+ }
76
87
77
88
const wrapShareModule = ${ REMOTE_FROM_PARAMETER } => {
78
- return {
79
- ${ getModuleMarker ( 'shareScope' ) }
80
- }
89
+ return merge( {
90
+ ${ getModuleMarker ( 'shareScope' ) }
91
+ }, (globalThis.__federation_shared__ || {})[' ${ shareScope } '] || {});
81
92
}
82
93
83
94
async function __federation_import(name) {
@@ -109,7 +120,7 @@ export function prodRemotePlugin(
109
120
getUrl().then(url => {
110
121
import(/* @vite-ignore */ url).then(lib => {
111
122
if (!remote.inited) {
112
- const shareScope = wrapShareModule(remote.from)
123
+ const shareScope = wrapShareModule(remote.from);
113
124
lib.init(shareScope);
114
125
remote.lib = lib;
115
126
remote.lib.init(shareScope);
You can’t perform that action at this time.
0 commit comments