@module-federation/runtime 0.0.0-next-20240815093707 → 0.0.0-next-20240815094326
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +137 -149
- package/dist/index.esm.js +143 -155
- package/dist/package.json +1 -1
- package/dist/share.cjs.js +1 -1
- package/dist/share.esm.js +1 -1
- package/dist/src/core.d.ts +0 -1
- package/dist/src/plugins/snapshot/SnapshotHandler.d.ts +0 -5
- package/dist/src/remote/index.d.ts +1 -6
- package/dist/src/utils/load.d.ts +18 -4
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -142,80 +142,29 @@ async function loadEntryScript({ name, globalName, entry, createScriptHook }) {
|
|
|
142
142
|
if (remoteEntryExports) {
|
|
143
143
|
return remoteEntryExports;
|
|
144
144
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
const res = createScriptHook.emit({
|
|
149
|
-
url,
|
|
150
|
-
attrs
|
|
151
|
-
});
|
|
152
|
-
if (!res) return;
|
|
153
|
-
if (res instanceof HTMLScriptElement) {
|
|
154
|
-
return res;
|
|
155
|
-
}
|
|
156
|
-
if ('script' in res || 'timeout' in res) {
|
|
157
|
-
return res;
|
|
158
|
-
}
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
}).then(()=>{
|
|
162
|
-
const { remoteEntryKey, entryExports } = share.getRemoteEntryExports(name, globalName);
|
|
163
|
-
share.assert(entryExports, `
|
|
164
|
-
Unable to use the ${name}'s '${entry}' URL with ${remoteEntryKey}'s globalName to get remoteEntry exports.
|
|
165
|
-
Possible reasons could be:\n
|
|
166
|
-
1. '${entry}' is not the correct URL, or the remoteEntry resource or name is incorrect.\n
|
|
167
|
-
2. ${remoteEntryKey} cannot be used to get remoteEntry exports in the window object.
|
|
168
|
-
`);
|
|
169
|
-
return entryExports;
|
|
170
|
-
}).catch((e)=>{
|
|
171
|
-
throw e;
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
async function loadEntryDom({ remoteInfo, remoteEntryExports, createScriptHook }) {
|
|
175
|
-
const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
|
|
176
|
-
switch(type){
|
|
177
|
-
case 'esm':
|
|
178
|
-
case 'module':
|
|
179
|
-
return loadEsmEntry({
|
|
180
|
-
entry,
|
|
181
|
-
remoteEntryExports
|
|
182
|
-
});
|
|
183
|
-
case 'system':
|
|
184
|
-
return loadSystemJsEntry({
|
|
185
|
-
entry,
|
|
186
|
-
remoteEntryExports
|
|
187
|
-
});
|
|
188
|
-
default:
|
|
189
|
-
return loadEntryScript({
|
|
190
|
-
entry,
|
|
191
|
-
globalName,
|
|
145
|
+
if (typeof document === 'undefined') {
|
|
146
|
+
return sdk.loadScriptNode(entry, {
|
|
147
|
+
attrs: {
|
|
192
148
|
name,
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
149
|
+
globalName
|
|
150
|
+
},
|
|
151
|
+
createScriptHook
|
|
152
|
+
}).then(()=>{
|
|
153
|
+
const { remoteEntryKey, entryExports } = share.getRemoteEntryExports(name, globalName);
|
|
154
|
+
share.assert(entryExports, `
|
|
155
|
+
Unable to use the ${name}'s '${entry}' URL with ${remoteEntryKey}'s globalName to get remoteEntry exports.
|
|
156
|
+
Possible reasons could be:\n
|
|
157
|
+
1. '${entry}' is not the correct URL, or the remoteEntry resource or name is incorrect.\n
|
|
158
|
+
2. ${remoteEntryKey} cannot be used to get remoteEntry exports in the window object.
|
|
159
|
+
`);
|
|
160
|
+
return entryExports;
|
|
161
|
+
}).catch((e)=>{
|
|
162
|
+
throw e;
|
|
163
|
+
});
|
|
202
164
|
}
|
|
203
|
-
return sdk.
|
|
204
|
-
attrs: {
|
|
205
|
-
|
|
206
|
-
globalName
|
|
207
|
-
},
|
|
208
|
-
createScriptHook: (url, attrs)=>{
|
|
209
|
-
const res = createScriptHook.emit({
|
|
210
|
-
url,
|
|
211
|
-
attrs
|
|
212
|
-
});
|
|
213
|
-
if (!res) return;
|
|
214
|
-
if ('url' in res) {
|
|
215
|
-
return res;
|
|
216
|
-
}
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
165
|
+
return sdk.loadScript(entry, {
|
|
166
|
+
attrs: {},
|
|
167
|
+
createScriptHook
|
|
219
168
|
}).then(()=>{
|
|
220
169
|
const { remoteEntryKey, entryExports } = share.getRemoteEntryExports(name, globalName);
|
|
221
170
|
share.assert(entryExports, `
|
|
@@ -233,33 +182,33 @@ function getRemoteEntryUniqueKey(remoteInfo) {
|
|
|
233
182
|
const { entry, name } = remoteInfo;
|
|
234
183
|
return sdk.composeKeyWithSeparator(name, entry);
|
|
235
184
|
}
|
|
236
|
-
async function getRemoteEntry({
|
|
185
|
+
async function getRemoteEntry({ remoteEntryExports, remoteInfo, createScriptHook }) {
|
|
186
|
+
const { entry, name, type, entryGlobalName } = remoteInfo;
|
|
237
187
|
const uniqueKey = getRemoteEntryUniqueKey(remoteInfo);
|
|
238
188
|
if (remoteEntryExports) {
|
|
239
189
|
return remoteEntryExports;
|
|
240
190
|
}
|
|
241
191
|
if (!share.globalLoading[uniqueKey]) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
192
|
+
if ([
|
|
193
|
+
'esm',
|
|
194
|
+
'module'
|
|
195
|
+
].includes(type)) {
|
|
196
|
+
share.globalLoading[uniqueKey] = loadEsmEntry({
|
|
197
|
+
entry,
|
|
198
|
+
remoteEntryExports
|
|
199
|
+
});
|
|
200
|
+
} else if (type === 'system') {
|
|
201
|
+
share.globalLoading[uniqueKey] = loadSystemJsEntry({
|
|
202
|
+
entry,
|
|
247
203
|
remoteEntryExports
|
|
248
|
-
})
|
|
204
|
+
});
|
|
249
205
|
} else {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
} else {
|
|
257
|
-
share.globalLoading[uniqueKey] = loadEntryDom({
|
|
258
|
-
remoteInfo,
|
|
259
|
-
remoteEntryExports,
|
|
260
|
-
createScriptHook
|
|
261
|
-
});
|
|
262
|
-
}
|
|
206
|
+
share.globalLoading[uniqueKey] = loadEntryScript({
|
|
207
|
+
name,
|
|
208
|
+
globalName: entryGlobalName,
|
|
209
|
+
entry,
|
|
210
|
+
createScriptHook
|
|
211
|
+
});
|
|
263
212
|
}
|
|
264
213
|
}
|
|
265
214
|
return share.globalLoading[uniqueKey];
|
|
@@ -294,9 +243,26 @@ let Module = class Module {
|
|
|
294
243
|
}
|
|
295
244
|
// Get remoteEntry.js
|
|
296
245
|
const remoteEntryExports = await getRemoteEntry({
|
|
297
|
-
origin: this.host,
|
|
298
246
|
remoteInfo: this.remoteInfo,
|
|
299
|
-
remoteEntryExports: this.remoteEntryExports
|
|
247
|
+
remoteEntryExports: this.remoteEntryExports,
|
|
248
|
+
createScriptHook: (url, attrs)=>{
|
|
249
|
+
const res = this.host.loaderHook.lifecycle.createScript.emit({
|
|
250
|
+
url,
|
|
251
|
+
attrs
|
|
252
|
+
});
|
|
253
|
+
if (!res) return;
|
|
254
|
+
if (typeof document === 'undefined') {
|
|
255
|
+
//todo: needs real fix
|
|
256
|
+
return res;
|
|
257
|
+
}
|
|
258
|
+
if (res instanceof HTMLScriptElement) {
|
|
259
|
+
return res;
|
|
260
|
+
}
|
|
261
|
+
if ('script' in res || 'timeout' in res) {
|
|
262
|
+
return res;
|
|
263
|
+
}
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
300
266
|
});
|
|
301
267
|
share.assert(remoteEntryExports, `remoteEntryExports is undefined \n ${share.safeToString(this.remoteInfo)}`);
|
|
302
268
|
this.remoteEntryExports = remoteEntryExports;
|
|
@@ -334,9 +300,6 @@ let Module = class Module {
|
|
|
334
300
|
remoteInfo: this.remoteInfo,
|
|
335
301
|
origin: this.host
|
|
336
302
|
});
|
|
337
|
-
if (typeof (remoteEntryExports == null ? void 0 : remoteEntryExports.init) === 'undefined') {
|
|
338
|
-
console.error('The remote entry interface does not contain "init"', '\n', 'Ensure the name of this remote is not reserved or in use. Check if anything already exists on window[nameOfRemote]', '\n', 'Ensure that window[nameOfRemote] is returning a {get,init} object.');
|
|
339
|
-
}
|
|
340
303
|
await remoteEntryExports.init(initContainerOptions.shareScope, initContainerOptions.initScope, initContainerOptions.remoteEntryInitOptions);
|
|
341
304
|
await this.host.hooks.lifecycle.initContainer.emit(_extends$6({}, initContainerOptions, {
|
|
342
305
|
remoteEntryExports
|
|
@@ -632,33 +595,65 @@ useLinkPreload = true) {
|
|
|
632
595
|
const module = host.moduleCache.get(remoteInfo.name);
|
|
633
596
|
if (module) {
|
|
634
597
|
getRemoteEntry({
|
|
635
|
-
origin: host,
|
|
636
598
|
remoteInfo: moduleInfo,
|
|
637
|
-
remoteEntryExports: module.remoteEntryExports
|
|
599
|
+
remoteEntryExports: module.remoteEntryExports,
|
|
600
|
+
createScriptHook: (url, attrs)=>{
|
|
601
|
+
const res = host.loaderHook.lifecycle.createScript.emit({
|
|
602
|
+
url,
|
|
603
|
+
attrs
|
|
604
|
+
});
|
|
605
|
+
if (!res) return;
|
|
606
|
+
if (typeof document === 'undefined') {
|
|
607
|
+
//todo: needs real fix
|
|
608
|
+
return res;
|
|
609
|
+
}
|
|
610
|
+
if (res instanceof HTMLScriptElement) {
|
|
611
|
+
return res;
|
|
612
|
+
}
|
|
613
|
+
if ('script' in res || 'timeout' in res) {
|
|
614
|
+
return res;
|
|
615
|
+
}
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
638
618
|
});
|
|
639
619
|
} else {
|
|
640
620
|
getRemoteEntry({
|
|
641
|
-
origin: host,
|
|
642
621
|
remoteInfo: moduleInfo,
|
|
643
|
-
remoteEntryExports: undefined
|
|
622
|
+
remoteEntryExports: undefined,
|
|
623
|
+
createScriptHook: (url, attrs)=>{
|
|
624
|
+
const res = host.loaderHook.lifecycle.createScript.emit({
|
|
625
|
+
url,
|
|
626
|
+
attrs
|
|
627
|
+
});
|
|
628
|
+
if (!res) return;
|
|
629
|
+
if (typeof document === 'undefined') {
|
|
630
|
+
//todo: needs real fix
|
|
631
|
+
return res;
|
|
632
|
+
}
|
|
633
|
+
if (res instanceof HTMLScriptElement) {
|
|
634
|
+
return res;
|
|
635
|
+
}
|
|
636
|
+
if ('script' in res || 'timeout' in res) {
|
|
637
|
+
return res;
|
|
638
|
+
}
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
644
641
|
});
|
|
645
642
|
}
|
|
646
643
|
});
|
|
647
644
|
if (useLinkPreload) {
|
|
648
|
-
const defaultAttrs = {
|
|
649
|
-
rel: 'preload',
|
|
650
|
-
as: 'style',
|
|
651
|
-
crossorigin: 'anonymous'
|
|
652
|
-
};
|
|
653
645
|
cssAssets.forEach((cssUrl)=>{
|
|
654
646
|
const { link: cssEl, needAttach } = sdk.createLink({
|
|
655
647
|
url: cssUrl,
|
|
656
648
|
cb: ()=>{},
|
|
657
|
-
attrs:
|
|
658
|
-
|
|
649
|
+
attrs: {
|
|
650
|
+
rel: 'preload',
|
|
651
|
+
as: 'style',
|
|
652
|
+
crossorigin: 'anonymous'
|
|
653
|
+
},
|
|
654
|
+
createLinkHook: (url)=>{
|
|
659
655
|
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
660
|
-
url
|
|
661
|
-
attrs
|
|
656
|
+
url
|
|
662
657
|
});
|
|
663
658
|
if (res instanceof HTMLLinkElement) {
|
|
664
659
|
return res;
|
|
@@ -669,19 +664,17 @@ useLinkPreload = true) {
|
|
|
669
664
|
needAttach && document.head.appendChild(cssEl);
|
|
670
665
|
});
|
|
671
666
|
} else {
|
|
672
|
-
const defaultAttrs = {
|
|
673
|
-
rel: 'stylesheet',
|
|
674
|
-
type: 'text/css'
|
|
675
|
-
};
|
|
676
667
|
cssAssets.forEach((cssUrl)=>{
|
|
677
668
|
const { link: cssEl, needAttach } = sdk.createLink({
|
|
678
669
|
url: cssUrl,
|
|
679
670
|
cb: ()=>{},
|
|
680
|
-
attrs:
|
|
681
|
-
|
|
671
|
+
attrs: {
|
|
672
|
+
rel: 'stylesheet',
|
|
673
|
+
type: 'text/css'
|
|
674
|
+
},
|
|
675
|
+
createLinkHook: (url)=>{
|
|
682
676
|
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
683
|
-
url
|
|
684
|
-
attrs
|
|
677
|
+
url
|
|
685
678
|
});
|
|
686
679
|
if (res instanceof HTMLLinkElement) {
|
|
687
680
|
return res;
|
|
@@ -694,20 +687,18 @@ useLinkPreload = true) {
|
|
|
694
687
|
});
|
|
695
688
|
}
|
|
696
689
|
if (useLinkPreload) {
|
|
697
|
-
const defaultAttrs = {
|
|
698
|
-
rel: 'preload',
|
|
699
|
-
as: 'script',
|
|
700
|
-
crossorigin: 'anonymous'
|
|
701
|
-
};
|
|
702
690
|
jsAssetsWithoutEntry.forEach((jsUrl)=>{
|
|
703
691
|
const { link: linkEl, needAttach } = sdk.createLink({
|
|
704
692
|
url: jsUrl,
|
|
705
693
|
cb: ()=>{},
|
|
706
|
-
attrs:
|
|
707
|
-
|
|
694
|
+
attrs: {
|
|
695
|
+
rel: 'preload',
|
|
696
|
+
as: 'script',
|
|
697
|
+
crossorigin: 'anonymous'
|
|
698
|
+
},
|
|
699
|
+
createLinkHook: (url)=>{
|
|
708
700
|
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
709
|
-
url
|
|
710
|
-
attrs
|
|
701
|
+
url
|
|
711
702
|
});
|
|
712
703
|
if (res instanceof HTMLLinkElement) {
|
|
713
704
|
return res;
|
|
@@ -718,15 +709,14 @@ useLinkPreload = true) {
|
|
|
718
709
|
needAttach && document.head.appendChild(linkEl);
|
|
719
710
|
});
|
|
720
711
|
} else {
|
|
721
|
-
const defaultAttrs = {
|
|
722
|
-
fetchpriority: 'high',
|
|
723
|
-
type: (remoteInfo == null ? void 0 : remoteInfo.type) === 'module' ? 'module' : 'text/javascript'
|
|
724
|
-
};
|
|
725
712
|
jsAssetsWithoutEntry.forEach((jsUrl)=>{
|
|
726
713
|
const { script: scriptEl, needAttach } = sdk.createScript({
|
|
727
714
|
url: jsUrl,
|
|
728
715
|
cb: ()=>{},
|
|
729
|
-
attrs:
|
|
716
|
+
attrs: {
|
|
717
|
+
fetchpriority: 'high',
|
|
718
|
+
type: (remoteInfo == null ? void 0 : remoteInfo.type) === 'module' ? 'module' : 'text/javascript'
|
|
719
|
+
},
|
|
730
720
|
createScriptHook: (url, attrs)=>{
|
|
731
721
|
const res = host.loaderHook.lifecycle.createScript.emit({
|
|
732
722
|
url,
|
|
@@ -1123,8 +1113,6 @@ class SnapshotHandler {
|
|
|
1123
1113
|
remoteSnapshot,
|
|
1124
1114
|
globalSnapshot
|
|
1125
1115
|
});
|
|
1126
|
-
let mSnapshot;
|
|
1127
|
-
let gSnapshot;
|
|
1128
1116
|
// global snapshot includes manifest or module info includes manifest
|
|
1129
1117
|
if (globalRemoteSnapshot) {
|
|
1130
1118
|
if (sdk.isManifestProvider(globalRemoteSnapshot)) {
|
|
@@ -1136,8 +1124,10 @@ class SnapshotHandler {
|
|
|
1136
1124
|
// Therefore, set the snapshot key to the global address of the actual request
|
|
1137
1125
|
entry: remoteEntry
|
|
1138
1126
|
}), moduleSnapshot);
|
|
1139
|
-
|
|
1140
|
-
|
|
1127
|
+
return {
|
|
1128
|
+
remoteSnapshot: moduleSnapshot,
|
|
1129
|
+
globalSnapshot: globalSnapshotRes
|
|
1130
|
+
};
|
|
1141
1131
|
} else {
|
|
1142
1132
|
const { remoteSnapshot: remoteSnapshotRes } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1143
1133
|
options: this.HostInstance.options,
|
|
@@ -1145,8 +1135,10 @@ class SnapshotHandler {
|
|
|
1145
1135
|
remoteSnapshot: globalRemoteSnapshot,
|
|
1146
1136
|
from: 'global'
|
|
1147
1137
|
});
|
|
1148
|
-
|
|
1149
|
-
|
|
1138
|
+
return {
|
|
1139
|
+
remoteSnapshot: remoteSnapshotRes,
|
|
1140
|
+
globalSnapshot: globalSnapshotRes
|
|
1141
|
+
};
|
|
1150
1142
|
}
|
|
1151
1143
|
} else {
|
|
1152
1144
|
if (share.isRemoteInfoWithEntry(moduleInfo)) {
|
|
@@ -1160,8 +1152,10 @@ class SnapshotHandler {
|
|
|
1160
1152
|
remoteSnapshot: moduleSnapshot,
|
|
1161
1153
|
from: 'global'
|
|
1162
1154
|
});
|
|
1163
|
-
|
|
1164
|
-
|
|
1155
|
+
return {
|
|
1156
|
+
remoteSnapshot: remoteSnapshotRes,
|
|
1157
|
+
globalSnapshot: globalSnapshotRes
|
|
1158
|
+
};
|
|
1165
1159
|
} else {
|
|
1166
1160
|
share.error(`
|
|
1167
1161
|
Cannot get remoteSnapshot with the name: '${moduleInfo.name}', version: '${moduleInfo.version}' from __FEDERATION__.moduleInfo. The following reasons may be causing the problem:\n
|
|
@@ -1171,10 +1165,6 @@ class SnapshotHandler {
|
|
|
1171
1165
|
`);
|
|
1172
1166
|
}
|
|
1173
1167
|
}
|
|
1174
|
-
return {
|
|
1175
|
-
remoteSnapshot: mSnapshot,
|
|
1176
|
-
globalSnapshot: gSnapshot
|
|
1177
|
-
};
|
|
1178
1168
|
}
|
|
1179
1169
|
getGlobalRemoteInfo(moduleInfo) {
|
|
1180
1170
|
return getGlobalRemoteInfo(moduleInfo, this.HostInstance);
|
|
@@ -1227,8 +1217,7 @@ class SnapshotHandler {
|
|
|
1227
1217
|
this.hooks = new PluginSystem({
|
|
1228
1218
|
beforeLoadRemoteSnapshot: new AsyncHook('beforeLoadRemoteSnapshot'),
|
|
1229
1219
|
loadSnapshot: new AsyncWaterfallHook('loadGlobalSnapshot'),
|
|
1230
|
-
loadRemoteSnapshot: new AsyncWaterfallHook('loadRemoteSnapshot')
|
|
1231
|
-
afterLoadSnapshot: new AsyncWaterfallHook('loadRemoteSnapshot')
|
|
1220
|
+
loadRemoteSnapshot: new AsyncWaterfallHook('loadRemoteSnapshot')
|
|
1232
1221
|
});
|
|
1233
1222
|
this.manifestLoading = share.Global.__FEDERATION__.__MANIFEST_LOADING__;
|
|
1234
1223
|
this.HostInstance = HostInstance;
|
|
@@ -1951,8 +1940,7 @@ class RemoteHandler {
|
|
|
1951
1940
|
beforePreloadRemote: new AsyncHook('beforePreloadRemote'),
|
|
1952
1941
|
generatePreloadAssets: new AsyncHook('generatePreloadAssets'),
|
|
1953
1942
|
// not used yet
|
|
1954
|
-
afterPreloadRemote: new AsyncHook()
|
|
1955
|
-
loadEntry: new AsyncHook()
|
|
1943
|
+
afterPreloadRemote: new AsyncHook()
|
|
1956
1944
|
});
|
|
1957
1945
|
this.host = host;
|
|
1958
1946
|
this.idToRemoteMap = {};
|
|
@@ -2078,7 +2066,7 @@ class FederationHost {
|
|
|
2078
2066
|
// maybe will change, temporarily for internal use only
|
|
2079
2067
|
initContainer: new AsyncWaterfallHook('initContainer')
|
|
2080
2068
|
});
|
|
2081
|
-
this.version = "0.
|
|
2069
|
+
this.version = "0.3.5";
|
|
2082
2070
|
this.moduleCache = new Map();
|
|
2083
2071
|
this.loaderHook = new PluginSystem({
|
|
2084
2072
|
// FIXME: may not be suitable , not open to the public yet
|
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { g as getGlobalHostPlugins, a as globalLoading, D as DEFAULT_REMOTE_TYPE, b as DEFAULT_SCOPE, c as getRemoteEntryExports, d as assert, s as safeToString, e as getFMId, i as isObject, f as error, w as warn, h as isPlainObject, j as isRemoteInfoWithEntry, k as isPureRemoteEntry, l as getRemoteEntryInfoFromSnapshot, m as isBrowserEnv
|
|
1
|
+
import { g as getGlobalHostPlugins, a as globalLoading, D as DEFAULT_REMOTE_TYPE, b as DEFAULT_SCOPE, c as getRemoteEntryExports, d as assert, s as safeToString, e as getFMId, i as isObject, f as error, w as warn, h as isPlainObject, j as isRemoteInfoWithEntry, k as isPureRemoteEntry, l as getRemoteEntryInfoFromSnapshot, m as isBrowserEnv, n as getInfoWithoutType, o as getPreloaded, p as setPreloaded, q as getRegisteredShare, r as arrayOptions, t as getGlobalSnapshotInfoByModuleInfo, u as addGlobalSnapshot, v as setGlobalSnapshotInfoByModuleInfo, G as Global, x as getGlobalSnapshot, y as formatShareConfigs, z as getTargetSharedOptions, A as getGlobalShareScope, B as addUniqueItem, C as getBuilderId, E as setGlobalFederationConstructor, F as getGlobalFederationInstance, H as getGlobalFederationConstructor, I as setGlobalFederationInstance } from './share.esm.js';
|
|
2
2
|
export { J as registerGlobalPlugins } from './share.esm.js';
|
|
3
|
-
import {
|
|
3
|
+
import { loadScriptNode, loadScript, composeKeyWithSeparator, createLink, createScript, getResourceUrl, isManifestProvider, generateSnapshotFromManifest, warn as warn$1, isBrowserEnv as isBrowserEnv$1 } from '@module-federation/sdk';
|
|
4
4
|
export { loadScript, loadScriptNode } from '@module-federation/sdk';
|
|
5
5
|
|
|
6
6
|
// Function to match a remote with its name and expose
|
|
@@ -140,80 +140,29 @@ async function loadEntryScript({ name, globalName, entry, createScriptHook }) {
|
|
|
140
140
|
if (remoteEntryExports) {
|
|
141
141
|
return remoteEntryExports;
|
|
142
142
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const res = createScriptHook.emit({
|
|
147
|
-
url,
|
|
148
|
-
attrs
|
|
149
|
-
});
|
|
150
|
-
if (!res) return;
|
|
151
|
-
if (res instanceof HTMLScriptElement) {
|
|
152
|
-
return res;
|
|
153
|
-
}
|
|
154
|
-
if ('script' in res || 'timeout' in res) {
|
|
155
|
-
return res;
|
|
156
|
-
}
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
}).then(()=>{
|
|
160
|
-
const { remoteEntryKey, entryExports } = getRemoteEntryExports(name, globalName);
|
|
161
|
-
assert(entryExports, `
|
|
162
|
-
Unable to use the ${name}'s '${entry}' URL with ${remoteEntryKey}'s globalName to get remoteEntry exports.
|
|
163
|
-
Possible reasons could be:\n
|
|
164
|
-
1. '${entry}' is not the correct URL, or the remoteEntry resource or name is incorrect.\n
|
|
165
|
-
2. ${remoteEntryKey} cannot be used to get remoteEntry exports in the window object.
|
|
166
|
-
`);
|
|
167
|
-
return entryExports;
|
|
168
|
-
}).catch((e)=>{
|
|
169
|
-
throw e;
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
async function loadEntryDom({ remoteInfo, remoteEntryExports, createScriptHook }) {
|
|
173
|
-
const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
|
|
174
|
-
switch(type){
|
|
175
|
-
case 'esm':
|
|
176
|
-
case 'module':
|
|
177
|
-
return loadEsmEntry({
|
|
178
|
-
entry,
|
|
179
|
-
remoteEntryExports
|
|
180
|
-
});
|
|
181
|
-
case 'system':
|
|
182
|
-
return loadSystemJsEntry({
|
|
183
|
-
entry,
|
|
184
|
-
remoteEntryExports
|
|
185
|
-
});
|
|
186
|
-
default:
|
|
187
|
-
return loadEntryScript({
|
|
188
|
-
entry,
|
|
189
|
-
globalName,
|
|
143
|
+
if (typeof document === 'undefined') {
|
|
144
|
+
return loadScriptNode(entry, {
|
|
145
|
+
attrs: {
|
|
190
146
|
name,
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
147
|
+
globalName
|
|
148
|
+
},
|
|
149
|
+
createScriptHook
|
|
150
|
+
}).then(()=>{
|
|
151
|
+
const { remoteEntryKey, entryExports } = getRemoteEntryExports(name, globalName);
|
|
152
|
+
assert(entryExports, `
|
|
153
|
+
Unable to use the ${name}'s '${entry}' URL with ${remoteEntryKey}'s globalName to get remoteEntry exports.
|
|
154
|
+
Possible reasons could be:\n
|
|
155
|
+
1. '${entry}' is not the correct URL, or the remoteEntry resource or name is incorrect.\n
|
|
156
|
+
2. ${remoteEntryKey} cannot be used to get remoteEntry exports in the window object.
|
|
157
|
+
`);
|
|
158
|
+
return entryExports;
|
|
159
|
+
}).catch((e)=>{
|
|
160
|
+
throw e;
|
|
161
|
+
});
|
|
200
162
|
}
|
|
201
|
-
return
|
|
202
|
-
attrs: {
|
|
203
|
-
|
|
204
|
-
globalName
|
|
205
|
-
},
|
|
206
|
-
createScriptHook: (url, attrs)=>{
|
|
207
|
-
const res = createScriptHook.emit({
|
|
208
|
-
url,
|
|
209
|
-
attrs
|
|
210
|
-
});
|
|
211
|
-
if (!res) return;
|
|
212
|
-
if ('url' in res) {
|
|
213
|
-
return res;
|
|
214
|
-
}
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
163
|
+
return loadScript(entry, {
|
|
164
|
+
attrs: {},
|
|
165
|
+
createScriptHook
|
|
217
166
|
}).then(()=>{
|
|
218
167
|
const { remoteEntryKey, entryExports } = getRemoteEntryExports(name, globalName);
|
|
219
168
|
assert(entryExports, `
|
|
@@ -231,33 +180,33 @@ function getRemoteEntryUniqueKey(remoteInfo) {
|
|
|
231
180
|
const { entry, name } = remoteInfo;
|
|
232
181
|
return composeKeyWithSeparator(name, entry);
|
|
233
182
|
}
|
|
234
|
-
async function getRemoteEntry({
|
|
183
|
+
async function getRemoteEntry({ remoteEntryExports, remoteInfo, createScriptHook }) {
|
|
184
|
+
const { entry, name, type, entryGlobalName } = remoteInfo;
|
|
235
185
|
const uniqueKey = getRemoteEntryUniqueKey(remoteInfo);
|
|
236
186
|
if (remoteEntryExports) {
|
|
237
187
|
return remoteEntryExports;
|
|
238
188
|
}
|
|
239
189
|
if (!globalLoading[uniqueKey]) {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
190
|
+
if ([
|
|
191
|
+
'esm',
|
|
192
|
+
'module'
|
|
193
|
+
].includes(type)) {
|
|
194
|
+
globalLoading[uniqueKey] = loadEsmEntry({
|
|
195
|
+
entry,
|
|
196
|
+
remoteEntryExports
|
|
197
|
+
});
|
|
198
|
+
} else if (type === 'system') {
|
|
199
|
+
globalLoading[uniqueKey] = loadSystemJsEntry({
|
|
200
|
+
entry,
|
|
245
201
|
remoteEntryExports
|
|
246
|
-
})
|
|
202
|
+
});
|
|
247
203
|
} else {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
} else {
|
|
255
|
-
globalLoading[uniqueKey] = loadEntryDom({
|
|
256
|
-
remoteInfo,
|
|
257
|
-
remoteEntryExports,
|
|
258
|
-
createScriptHook
|
|
259
|
-
});
|
|
260
|
-
}
|
|
204
|
+
globalLoading[uniqueKey] = loadEntryScript({
|
|
205
|
+
name,
|
|
206
|
+
globalName: entryGlobalName,
|
|
207
|
+
entry,
|
|
208
|
+
createScriptHook
|
|
209
|
+
});
|
|
261
210
|
}
|
|
262
211
|
}
|
|
263
212
|
return globalLoading[uniqueKey];
|
|
@@ -292,9 +241,26 @@ let Module = class Module {
|
|
|
292
241
|
}
|
|
293
242
|
// Get remoteEntry.js
|
|
294
243
|
const remoteEntryExports = await getRemoteEntry({
|
|
295
|
-
origin: this.host,
|
|
296
244
|
remoteInfo: this.remoteInfo,
|
|
297
|
-
remoteEntryExports: this.remoteEntryExports
|
|
245
|
+
remoteEntryExports: this.remoteEntryExports,
|
|
246
|
+
createScriptHook: (url, attrs)=>{
|
|
247
|
+
const res = this.host.loaderHook.lifecycle.createScript.emit({
|
|
248
|
+
url,
|
|
249
|
+
attrs
|
|
250
|
+
});
|
|
251
|
+
if (!res) return;
|
|
252
|
+
if (typeof document === 'undefined') {
|
|
253
|
+
//todo: needs real fix
|
|
254
|
+
return res;
|
|
255
|
+
}
|
|
256
|
+
if (res instanceof HTMLScriptElement) {
|
|
257
|
+
return res;
|
|
258
|
+
}
|
|
259
|
+
if ('script' in res || 'timeout' in res) {
|
|
260
|
+
return res;
|
|
261
|
+
}
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
298
264
|
});
|
|
299
265
|
assert(remoteEntryExports, `remoteEntryExports is undefined \n ${safeToString(this.remoteInfo)}`);
|
|
300
266
|
this.remoteEntryExports = remoteEntryExports;
|
|
@@ -332,9 +298,6 @@ let Module = class Module {
|
|
|
332
298
|
remoteInfo: this.remoteInfo,
|
|
333
299
|
origin: this.host
|
|
334
300
|
});
|
|
335
|
-
if (typeof (remoteEntryExports == null ? void 0 : remoteEntryExports.init) === 'undefined') {
|
|
336
|
-
console.error('The remote entry interface does not contain "init"', '\n', 'Ensure the name of this remote is not reserved or in use. Check if anything already exists on window[nameOfRemote]', '\n', 'Ensure that window[nameOfRemote] is returning a {get,init} object.');
|
|
337
|
-
}
|
|
338
301
|
await remoteEntryExports.init(initContainerOptions.shareScope, initContainerOptions.initScope, initContainerOptions.remoteEntryInitOptions);
|
|
339
302
|
await this.host.hooks.lifecycle.initContainer.emit(_extends$6({}, initContainerOptions, {
|
|
340
303
|
remoteEntryExports
|
|
@@ -630,33 +593,65 @@ useLinkPreload = true) {
|
|
|
630
593
|
const module = host.moduleCache.get(remoteInfo.name);
|
|
631
594
|
if (module) {
|
|
632
595
|
getRemoteEntry({
|
|
633
|
-
origin: host,
|
|
634
596
|
remoteInfo: moduleInfo,
|
|
635
|
-
remoteEntryExports: module.remoteEntryExports
|
|
597
|
+
remoteEntryExports: module.remoteEntryExports,
|
|
598
|
+
createScriptHook: (url, attrs)=>{
|
|
599
|
+
const res = host.loaderHook.lifecycle.createScript.emit({
|
|
600
|
+
url,
|
|
601
|
+
attrs
|
|
602
|
+
});
|
|
603
|
+
if (!res) return;
|
|
604
|
+
if (typeof document === 'undefined') {
|
|
605
|
+
//todo: needs real fix
|
|
606
|
+
return res;
|
|
607
|
+
}
|
|
608
|
+
if (res instanceof HTMLScriptElement) {
|
|
609
|
+
return res;
|
|
610
|
+
}
|
|
611
|
+
if ('script' in res || 'timeout' in res) {
|
|
612
|
+
return res;
|
|
613
|
+
}
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
636
616
|
});
|
|
637
617
|
} else {
|
|
638
618
|
getRemoteEntry({
|
|
639
|
-
origin: host,
|
|
640
619
|
remoteInfo: moduleInfo,
|
|
641
|
-
remoteEntryExports: undefined
|
|
620
|
+
remoteEntryExports: undefined,
|
|
621
|
+
createScriptHook: (url, attrs)=>{
|
|
622
|
+
const res = host.loaderHook.lifecycle.createScript.emit({
|
|
623
|
+
url,
|
|
624
|
+
attrs
|
|
625
|
+
});
|
|
626
|
+
if (!res) return;
|
|
627
|
+
if (typeof document === 'undefined') {
|
|
628
|
+
//todo: needs real fix
|
|
629
|
+
return res;
|
|
630
|
+
}
|
|
631
|
+
if (res instanceof HTMLScriptElement) {
|
|
632
|
+
return res;
|
|
633
|
+
}
|
|
634
|
+
if ('script' in res || 'timeout' in res) {
|
|
635
|
+
return res;
|
|
636
|
+
}
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
642
639
|
});
|
|
643
640
|
}
|
|
644
641
|
});
|
|
645
642
|
if (useLinkPreload) {
|
|
646
|
-
const defaultAttrs = {
|
|
647
|
-
rel: 'preload',
|
|
648
|
-
as: 'style',
|
|
649
|
-
crossorigin: 'anonymous'
|
|
650
|
-
};
|
|
651
643
|
cssAssets.forEach((cssUrl)=>{
|
|
652
644
|
const { link: cssEl, needAttach } = createLink({
|
|
653
645
|
url: cssUrl,
|
|
654
646
|
cb: ()=>{},
|
|
655
|
-
attrs:
|
|
656
|
-
|
|
647
|
+
attrs: {
|
|
648
|
+
rel: 'preload',
|
|
649
|
+
as: 'style',
|
|
650
|
+
crossorigin: 'anonymous'
|
|
651
|
+
},
|
|
652
|
+
createLinkHook: (url)=>{
|
|
657
653
|
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
658
|
-
url
|
|
659
|
-
attrs
|
|
654
|
+
url
|
|
660
655
|
});
|
|
661
656
|
if (res instanceof HTMLLinkElement) {
|
|
662
657
|
return res;
|
|
@@ -667,19 +662,17 @@ useLinkPreload = true) {
|
|
|
667
662
|
needAttach && document.head.appendChild(cssEl);
|
|
668
663
|
});
|
|
669
664
|
} else {
|
|
670
|
-
const defaultAttrs = {
|
|
671
|
-
rel: 'stylesheet',
|
|
672
|
-
type: 'text/css'
|
|
673
|
-
};
|
|
674
665
|
cssAssets.forEach((cssUrl)=>{
|
|
675
666
|
const { link: cssEl, needAttach } = createLink({
|
|
676
667
|
url: cssUrl,
|
|
677
668
|
cb: ()=>{},
|
|
678
|
-
attrs:
|
|
679
|
-
|
|
669
|
+
attrs: {
|
|
670
|
+
rel: 'stylesheet',
|
|
671
|
+
type: 'text/css'
|
|
672
|
+
},
|
|
673
|
+
createLinkHook: (url)=>{
|
|
680
674
|
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
681
|
-
url
|
|
682
|
-
attrs
|
|
675
|
+
url
|
|
683
676
|
});
|
|
684
677
|
if (res instanceof HTMLLinkElement) {
|
|
685
678
|
return res;
|
|
@@ -692,20 +685,18 @@ useLinkPreload = true) {
|
|
|
692
685
|
});
|
|
693
686
|
}
|
|
694
687
|
if (useLinkPreload) {
|
|
695
|
-
const defaultAttrs = {
|
|
696
|
-
rel: 'preload',
|
|
697
|
-
as: 'script',
|
|
698
|
-
crossorigin: 'anonymous'
|
|
699
|
-
};
|
|
700
688
|
jsAssetsWithoutEntry.forEach((jsUrl)=>{
|
|
701
689
|
const { link: linkEl, needAttach } = createLink({
|
|
702
690
|
url: jsUrl,
|
|
703
691
|
cb: ()=>{},
|
|
704
|
-
attrs:
|
|
705
|
-
|
|
692
|
+
attrs: {
|
|
693
|
+
rel: 'preload',
|
|
694
|
+
as: 'script',
|
|
695
|
+
crossorigin: 'anonymous'
|
|
696
|
+
},
|
|
697
|
+
createLinkHook: (url)=>{
|
|
706
698
|
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
707
|
-
url
|
|
708
|
-
attrs
|
|
699
|
+
url
|
|
709
700
|
});
|
|
710
701
|
if (res instanceof HTMLLinkElement) {
|
|
711
702
|
return res;
|
|
@@ -716,15 +707,14 @@ useLinkPreload = true) {
|
|
|
716
707
|
needAttach && document.head.appendChild(linkEl);
|
|
717
708
|
});
|
|
718
709
|
} else {
|
|
719
|
-
const defaultAttrs = {
|
|
720
|
-
fetchpriority: 'high',
|
|
721
|
-
type: (remoteInfo == null ? void 0 : remoteInfo.type) === 'module' ? 'module' : 'text/javascript'
|
|
722
|
-
};
|
|
723
710
|
jsAssetsWithoutEntry.forEach((jsUrl)=>{
|
|
724
711
|
const { script: scriptEl, needAttach } = createScript({
|
|
725
712
|
url: jsUrl,
|
|
726
713
|
cb: ()=>{},
|
|
727
|
-
attrs:
|
|
714
|
+
attrs: {
|
|
715
|
+
fetchpriority: 'high',
|
|
716
|
+
type: (remoteInfo == null ? void 0 : remoteInfo.type) === 'module' ? 'module' : 'text/javascript'
|
|
717
|
+
},
|
|
728
718
|
createScriptHook: (url, attrs)=>{
|
|
729
719
|
const res = host.loaderHook.lifecycle.createScript.emit({
|
|
730
720
|
url,
|
|
@@ -763,7 +753,7 @@ function assignRemoteInfo(remoteInfo, remoteSnapshot) {
|
|
|
763
753
|
error(`The attribute remoteEntry of ${remoteInfo.name} must not be undefined.`);
|
|
764
754
|
}
|
|
765
755
|
let entryUrl = getResourceUrl(remoteSnapshot, remoteEntryInfo.url);
|
|
766
|
-
if (!isBrowserEnv
|
|
756
|
+
if (!isBrowserEnv() && !entryUrl.startsWith('http')) {
|
|
767
757
|
entryUrl = `https:${entryUrl}`;
|
|
768
758
|
}
|
|
769
759
|
remoteInfo.type = remoteEntryInfo.type;
|
|
@@ -1121,12 +1111,10 @@ class SnapshotHandler {
|
|
|
1121
1111
|
remoteSnapshot,
|
|
1122
1112
|
globalSnapshot
|
|
1123
1113
|
});
|
|
1124
|
-
let mSnapshot;
|
|
1125
|
-
let gSnapshot;
|
|
1126
1114
|
// global snapshot includes manifest or module info includes manifest
|
|
1127
1115
|
if (globalRemoteSnapshot) {
|
|
1128
1116
|
if (isManifestProvider(globalRemoteSnapshot)) {
|
|
1129
|
-
const remoteEntry = isBrowserEnv
|
|
1117
|
+
const remoteEntry = isBrowserEnv() ? globalRemoteSnapshot.remoteEntry : globalRemoteSnapshot.ssrRemoteEntry || globalRemoteSnapshot.remoteEntry || '';
|
|
1130
1118
|
const moduleSnapshot = await this.getManifestJson(remoteEntry, moduleInfo, {});
|
|
1131
1119
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
1132
1120
|
const globalSnapshotRes = setGlobalSnapshotInfoByModuleInfo(_extends$3({}, moduleInfo, {
|
|
@@ -1134,8 +1122,10 @@ class SnapshotHandler {
|
|
|
1134
1122
|
// Therefore, set the snapshot key to the global address of the actual request
|
|
1135
1123
|
entry: remoteEntry
|
|
1136
1124
|
}), moduleSnapshot);
|
|
1137
|
-
|
|
1138
|
-
|
|
1125
|
+
return {
|
|
1126
|
+
remoteSnapshot: moduleSnapshot,
|
|
1127
|
+
globalSnapshot: globalSnapshotRes
|
|
1128
|
+
};
|
|
1139
1129
|
} else {
|
|
1140
1130
|
const { remoteSnapshot: remoteSnapshotRes } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
|
|
1141
1131
|
options: this.HostInstance.options,
|
|
@@ -1143,8 +1133,10 @@ class SnapshotHandler {
|
|
|
1143
1133
|
remoteSnapshot: globalRemoteSnapshot,
|
|
1144
1134
|
from: 'global'
|
|
1145
1135
|
});
|
|
1146
|
-
|
|
1147
|
-
|
|
1136
|
+
return {
|
|
1137
|
+
remoteSnapshot: remoteSnapshotRes,
|
|
1138
|
+
globalSnapshot: globalSnapshotRes
|
|
1139
|
+
};
|
|
1148
1140
|
}
|
|
1149
1141
|
} else {
|
|
1150
1142
|
if (isRemoteInfoWithEntry(moduleInfo)) {
|
|
@@ -1158,8 +1150,10 @@ class SnapshotHandler {
|
|
|
1158
1150
|
remoteSnapshot: moduleSnapshot,
|
|
1159
1151
|
from: 'global'
|
|
1160
1152
|
});
|
|
1161
|
-
|
|
1162
|
-
|
|
1153
|
+
return {
|
|
1154
|
+
remoteSnapshot: remoteSnapshotRes,
|
|
1155
|
+
globalSnapshot: globalSnapshotRes
|
|
1156
|
+
};
|
|
1163
1157
|
} else {
|
|
1164
1158
|
error(`
|
|
1165
1159
|
Cannot get remoteSnapshot with the name: '${moduleInfo.name}', version: '${moduleInfo.version}' from __FEDERATION__.moduleInfo. The following reasons may be causing the problem:\n
|
|
@@ -1169,10 +1163,6 @@ class SnapshotHandler {
|
|
|
1169
1163
|
`);
|
|
1170
1164
|
}
|
|
1171
1165
|
}
|
|
1172
|
-
return {
|
|
1173
|
-
remoteSnapshot: mSnapshot,
|
|
1174
|
-
globalSnapshot: gSnapshot
|
|
1175
|
-
};
|
|
1176
1166
|
}
|
|
1177
1167
|
getGlobalRemoteInfo(moduleInfo) {
|
|
1178
1168
|
return getGlobalRemoteInfo(moduleInfo, this.HostInstance);
|
|
@@ -1225,8 +1215,7 @@ class SnapshotHandler {
|
|
|
1225
1215
|
this.hooks = new PluginSystem({
|
|
1226
1216
|
beforeLoadRemoteSnapshot: new AsyncHook('beforeLoadRemoteSnapshot'),
|
|
1227
1217
|
loadSnapshot: new AsyncWaterfallHook('loadGlobalSnapshot'),
|
|
1228
|
-
loadRemoteSnapshot: new AsyncWaterfallHook('loadRemoteSnapshot')
|
|
1229
|
-
afterLoadSnapshot: new AsyncWaterfallHook('loadRemoteSnapshot')
|
|
1218
|
+
loadRemoteSnapshot: new AsyncWaterfallHook('loadRemoteSnapshot')
|
|
1230
1219
|
});
|
|
1231
1220
|
this.manifestLoading = Global.__FEDERATION__.__MANIFEST_LOADING__;
|
|
1232
1221
|
this.HostInstance = HostInstance;
|
|
@@ -1796,7 +1785,7 @@ class RemoteHandler {
|
|
|
1796
1785
|
}
|
|
1797
1786
|
// Set the remote entry to a complete path
|
|
1798
1787
|
if ('entry' in remote) {
|
|
1799
|
-
if (isBrowserEnv() && !remote.entry.startsWith('http')) {
|
|
1788
|
+
if (isBrowserEnv$1() && !remote.entry.startsWith('http')) {
|
|
1800
1789
|
remote.entry = new URL(remote.entry, window.location.origin).href;
|
|
1801
1790
|
}
|
|
1802
1791
|
}
|
|
@@ -1949,8 +1938,7 @@ class RemoteHandler {
|
|
|
1949
1938
|
beforePreloadRemote: new AsyncHook('beforePreloadRemote'),
|
|
1950
1939
|
generatePreloadAssets: new AsyncHook('generatePreloadAssets'),
|
|
1951
1940
|
// not used yet
|
|
1952
|
-
afterPreloadRemote: new AsyncHook()
|
|
1953
|
-
loadEntry: new AsyncHook()
|
|
1941
|
+
afterPreloadRemote: new AsyncHook()
|
|
1954
1942
|
});
|
|
1955
1943
|
this.host = host;
|
|
1956
1944
|
this.idToRemoteMap = {};
|
|
@@ -2076,7 +2064,7 @@ class FederationHost {
|
|
|
2076
2064
|
// maybe will change, temporarily for internal use only
|
|
2077
2065
|
initContainer: new AsyncWaterfallHook('initContainer')
|
|
2078
2066
|
});
|
|
2079
|
-
this.version = "0.
|
|
2067
|
+
this.version = "0.3.5";
|
|
2080
2068
|
this.moduleCache = new Map();
|
|
2081
2069
|
this.loaderHook = new PluginSystem({
|
|
2082
2070
|
// FIXME: may not be suitable , not open to the public yet
|
|
@@ -2097,7 +2085,7 @@ class FederationHost {
|
|
|
2097
2085
|
],
|
|
2098
2086
|
remotes: [],
|
|
2099
2087
|
shared: {},
|
|
2100
|
-
inBrowser: isBrowserEnv
|
|
2088
|
+
inBrowser: isBrowserEnv()
|
|
2101
2089
|
};
|
|
2102
2090
|
this.name = userOptions.name;
|
|
2103
2091
|
this.options = defaultOptions;
|
package/dist/package.json
CHANGED
package/dist/share.cjs.js
CHANGED
|
@@ -212,7 +212,7 @@ function getGlobalFederationConstructor() {
|
|
|
212
212
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
|
|
213
213
|
if (isDebug) {
|
|
214
214
|
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
215
|
-
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.
|
|
215
|
+
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.3.5";
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
package/dist/share.esm.js
CHANGED
|
@@ -210,7 +210,7 @@ function getGlobalFederationConstructor() {
|
|
|
210
210
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
|
|
211
211
|
if (isDebug) {
|
|
212
212
|
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
213
|
-
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.
|
|
213
|
+
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.3.5";
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
package/dist/src/core.d.ts
CHANGED
|
@@ -32,11 +32,6 @@ export declare class SnapshotHandler {
|
|
|
32
32
|
remoteSnapshot: ModuleInfo;
|
|
33
33
|
from: "global" | "manifest";
|
|
34
34
|
}>;
|
|
35
|
-
afterLoadSnapshot: AsyncWaterfallHook<{
|
|
36
|
-
options: Options;
|
|
37
|
-
moduleInfo: Remote;
|
|
38
|
-
remoteSnapshot: ModuleInfo;
|
|
39
|
-
}>;
|
|
40
35
|
}>;
|
|
41
36
|
loaderHook: FederationHost['loaderHook'];
|
|
42
37
|
manifestLoading: Record<string, Promise<ModuleInfo>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ModuleInfo, GlobalModuleInfo } from '@module-federation/sdk';
|
|
2
|
-
import { Options, UserOptions, PreloadAssets, PreloadOptions, PreloadRemoteArgs, Remote, RemoteInfo
|
|
2
|
+
import { Options, UserOptions, PreloadAssets, PreloadOptions, PreloadRemoteArgs, Remote, RemoteInfo } from '../type';
|
|
3
3
|
import { FederationHost } from '../core';
|
|
4
4
|
import { PluginSystem, AsyncHook, AsyncWaterfallHook, SyncHook, SyncWaterfallHook } from '../utils/hooks';
|
|
5
5
|
import { Module, ModuleOptions } from '../module';
|
|
@@ -78,11 +78,6 @@ export declare class RemoteHandler {
|
|
|
78
78
|
options: Options;
|
|
79
79
|
origin: FederationHost;
|
|
80
80
|
}, false | void | Promise<false | void>>;
|
|
81
|
-
loadEntry: AsyncHook<[{
|
|
82
|
-
createScriptHook: FederationHost["loaderHook"]["lifecycle"]["createScript"];
|
|
83
|
-
remoteInfo: RemoteInfo;
|
|
84
|
-
remoteEntryExports?: RemoteEntryExports;
|
|
85
|
-
}], Promise<RemoteEntryExports>>;
|
|
86
81
|
}>;
|
|
87
82
|
constructor(host: FederationHost);
|
|
88
83
|
formatAndRegisterRemote(globalOptions: Options, userOptions: UserOptions): Remote[];
|
package/dist/src/utils/load.d.ts
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CreateScriptHookReturn } from '@module-federation/sdk';
|
|
2
2
|
import { Remote, RemoteEntryExports, RemoteInfo } from '../type';
|
|
3
|
+
export declare function loadEsmEntry({ entry, remoteEntryExports, }: {
|
|
4
|
+
entry: string;
|
|
5
|
+
remoteEntryExports: RemoteEntryExports | undefined;
|
|
6
|
+
}): Promise<RemoteEntryExports>;
|
|
7
|
+
export declare function loadSystemJsEntry({ entry, remoteEntryExports, }: {
|
|
8
|
+
entry: string;
|
|
9
|
+
remoteEntryExports: RemoteEntryExports | undefined;
|
|
10
|
+
}): Promise<RemoteEntryExports>;
|
|
11
|
+
export declare function loadEntryScript({ name, globalName, entry, createScriptHook, }: {
|
|
12
|
+
name: string;
|
|
13
|
+
globalName: string;
|
|
14
|
+
entry: string;
|
|
15
|
+
createScriptHook?: (url: string, attrs?: Record<string, any> | undefined) => CreateScriptHookReturn;
|
|
16
|
+
}): Promise<RemoteEntryExports>;
|
|
3
17
|
export declare function getRemoteEntryUniqueKey(remoteInfo: RemoteInfo): string;
|
|
4
|
-
export declare function getRemoteEntry({
|
|
5
|
-
origin: FederationHost;
|
|
18
|
+
export declare function getRemoteEntry({ remoteEntryExports, remoteInfo, createScriptHook, }: {
|
|
6
19
|
remoteInfo: RemoteInfo;
|
|
7
20
|
remoteEntryExports?: RemoteEntryExports | undefined;
|
|
8
|
-
|
|
21
|
+
createScriptHook?: (url: string, attrs?: Record<string, any> | undefined) => CreateScriptHookReturn;
|
|
22
|
+
}): Promise<RemoteEntryExports | void>;
|
|
9
23
|
export declare function getRemoteInfo(remote: Remote): RemoteInfo;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/runtime",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20240815094326",
|
|
4
4
|
"author": "zhouxiao <codingzx@gmail.com>",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -45,6 +45,6 @@
|
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@module-federation/sdk": "0.0.0-next-
|
|
48
|
+
"@module-federation/sdk": "0.0.0-next-20240815094326"
|
|
49
49
|
}
|
|
50
50
|
}
|