@module-federation/runtime-core 0.0.0-next-20250623065058 → 0.0.0-next-20250626022312
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.cjs +196 -191
- package/dist/index.esm.js +197 -192
- package/dist/src/helpers.d.ts +7 -0
- package/package.json +3 -3
package/dist/index.cjs.cjs
CHANGED
|
@@ -943,34 +943,6 @@ function getTargetSharedOptions(options) {
|
|
|
943
943
|
return Object.assign({}, resolver(shareInfos[pkgName]), extraOptions == null ? void 0 : extraOptions.customShareInfo);
|
|
944
944
|
}
|
|
945
945
|
|
|
946
|
-
const ShareUtils = {
|
|
947
|
-
getRegisteredShare,
|
|
948
|
-
getGlobalShareScope
|
|
949
|
-
};
|
|
950
|
-
const GlobalUtils = {
|
|
951
|
-
Global,
|
|
952
|
-
nativeGlobal,
|
|
953
|
-
resetFederationGlobalInfo,
|
|
954
|
-
setGlobalFederationInstance,
|
|
955
|
-
getGlobalFederationConstructor,
|
|
956
|
-
setGlobalFederationConstructor,
|
|
957
|
-
getInfoWithoutType,
|
|
958
|
-
getGlobalSnapshot,
|
|
959
|
-
getTargetSnapshotInfoByModuleInfo,
|
|
960
|
-
getGlobalSnapshotInfoByModuleInfo,
|
|
961
|
-
setGlobalSnapshotInfoByModuleInfo,
|
|
962
|
-
addGlobalSnapshot,
|
|
963
|
-
getRemoteEntryExports,
|
|
964
|
-
registerGlobalPlugins,
|
|
965
|
-
getGlobalHostPlugins,
|
|
966
|
-
getPreloaded,
|
|
967
|
-
setPreloaded
|
|
968
|
-
};
|
|
969
|
-
var helpers = {
|
|
970
|
-
global: GlobalUtils,
|
|
971
|
-
share: ShareUtils
|
|
972
|
-
};
|
|
973
|
-
|
|
974
946
|
function getBuilderId() {
|
|
975
947
|
//@ts-ignore
|
|
976
948
|
return typeof FEDERATION_BUILD_IDENTIFIER !== 'undefined' ? FEDERATION_BUILD_IDENTIFIER : '';
|
|
@@ -1240,6 +1212,202 @@ function getRemoteInfo(remote) {
|
|
|
1240
1212
|
});
|
|
1241
1213
|
}
|
|
1242
1214
|
|
|
1215
|
+
function defaultPreloadArgs(preloadConfig) {
|
|
1216
|
+
return polyfills._extends({
|
|
1217
|
+
resourceCategory: 'sync',
|
|
1218
|
+
share: true,
|
|
1219
|
+
depsRemote: true,
|
|
1220
|
+
prefetchInterface: false
|
|
1221
|
+
}, preloadConfig);
|
|
1222
|
+
}
|
|
1223
|
+
function formatPreloadArgs(remotes, preloadArgs) {
|
|
1224
|
+
return preloadArgs.map((args)=>{
|
|
1225
|
+
const remoteInfo = matchRemote(remotes, args.nameOrAlias);
|
|
1226
|
+
assert(remoteInfo, `Unable to preload ${args.nameOrAlias} as it is not included in ${!remoteInfo && sdk.safeToString({
|
|
1227
|
+
remoteInfo,
|
|
1228
|
+
remotes
|
|
1229
|
+
})}`);
|
|
1230
|
+
return {
|
|
1231
|
+
remote: remoteInfo,
|
|
1232
|
+
preloadConfig: defaultPreloadArgs(args)
|
|
1233
|
+
};
|
|
1234
|
+
});
|
|
1235
|
+
}
|
|
1236
|
+
function normalizePreloadExposes(exposes) {
|
|
1237
|
+
if (!exposes) {
|
|
1238
|
+
return [];
|
|
1239
|
+
}
|
|
1240
|
+
return exposes.map((expose)=>{
|
|
1241
|
+
if (expose === '.') {
|
|
1242
|
+
return expose;
|
|
1243
|
+
}
|
|
1244
|
+
if (expose.startsWith('./')) {
|
|
1245
|
+
return expose.replace('./', '');
|
|
1246
|
+
}
|
|
1247
|
+
return expose;
|
|
1248
|
+
});
|
|
1249
|
+
}
|
|
1250
|
+
function preloadAssets(remoteInfo, host, assets, // It is used to distinguish preload from load remote parallel loading
|
|
1251
|
+
useLinkPreload = true) {
|
|
1252
|
+
const { cssAssets, jsAssetsWithoutEntry, entryAssets } = assets;
|
|
1253
|
+
if (host.options.inBrowser) {
|
|
1254
|
+
entryAssets.forEach((asset)=>{
|
|
1255
|
+
const { moduleInfo } = asset;
|
|
1256
|
+
const module = host.moduleCache.get(remoteInfo.name);
|
|
1257
|
+
if (module) {
|
|
1258
|
+
getRemoteEntry({
|
|
1259
|
+
origin: host,
|
|
1260
|
+
remoteInfo: moduleInfo,
|
|
1261
|
+
remoteEntryExports: module.remoteEntryExports
|
|
1262
|
+
});
|
|
1263
|
+
} else {
|
|
1264
|
+
getRemoteEntry({
|
|
1265
|
+
origin: host,
|
|
1266
|
+
remoteInfo: moduleInfo,
|
|
1267
|
+
remoteEntryExports: undefined
|
|
1268
|
+
});
|
|
1269
|
+
}
|
|
1270
|
+
});
|
|
1271
|
+
if (useLinkPreload) {
|
|
1272
|
+
const defaultAttrs = {
|
|
1273
|
+
rel: 'preload',
|
|
1274
|
+
as: 'style'
|
|
1275
|
+
};
|
|
1276
|
+
cssAssets.forEach((cssUrl)=>{
|
|
1277
|
+
const { link: cssEl, needAttach } = sdk.createLink({
|
|
1278
|
+
url: cssUrl,
|
|
1279
|
+
cb: ()=>{
|
|
1280
|
+
// noop
|
|
1281
|
+
},
|
|
1282
|
+
attrs: defaultAttrs,
|
|
1283
|
+
createLinkHook: (url, attrs)=>{
|
|
1284
|
+
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
1285
|
+
url,
|
|
1286
|
+
attrs
|
|
1287
|
+
});
|
|
1288
|
+
if (res instanceof HTMLLinkElement) {
|
|
1289
|
+
return res;
|
|
1290
|
+
}
|
|
1291
|
+
return;
|
|
1292
|
+
}
|
|
1293
|
+
});
|
|
1294
|
+
needAttach && document.head.appendChild(cssEl);
|
|
1295
|
+
});
|
|
1296
|
+
} else {
|
|
1297
|
+
const defaultAttrs = {
|
|
1298
|
+
rel: 'stylesheet',
|
|
1299
|
+
type: 'text/css'
|
|
1300
|
+
};
|
|
1301
|
+
cssAssets.forEach((cssUrl)=>{
|
|
1302
|
+
const { link: cssEl, needAttach } = sdk.createLink({
|
|
1303
|
+
url: cssUrl,
|
|
1304
|
+
cb: ()=>{
|
|
1305
|
+
// noop
|
|
1306
|
+
},
|
|
1307
|
+
attrs: defaultAttrs,
|
|
1308
|
+
createLinkHook: (url, attrs)=>{
|
|
1309
|
+
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
1310
|
+
url,
|
|
1311
|
+
attrs
|
|
1312
|
+
});
|
|
1313
|
+
if (res instanceof HTMLLinkElement) {
|
|
1314
|
+
return res;
|
|
1315
|
+
}
|
|
1316
|
+
return;
|
|
1317
|
+
},
|
|
1318
|
+
needDeleteLink: false
|
|
1319
|
+
});
|
|
1320
|
+
needAttach && document.head.appendChild(cssEl);
|
|
1321
|
+
});
|
|
1322
|
+
}
|
|
1323
|
+
if (useLinkPreload) {
|
|
1324
|
+
const defaultAttrs = {
|
|
1325
|
+
rel: 'preload',
|
|
1326
|
+
as: 'script'
|
|
1327
|
+
};
|
|
1328
|
+
jsAssetsWithoutEntry.forEach((jsUrl)=>{
|
|
1329
|
+
const { link: linkEl, needAttach } = sdk.createLink({
|
|
1330
|
+
url: jsUrl,
|
|
1331
|
+
cb: ()=>{
|
|
1332
|
+
// noop
|
|
1333
|
+
},
|
|
1334
|
+
attrs: defaultAttrs,
|
|
1335
|
+
createLinkHook: (url, attrs)=>{
|
|
1336
|
+
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
1337
|
+
url,
|
|
1338
|
+
attrs
|
|
1339
|
+
});
|
|
1340
|
+
if (res instanceof HTMLLinkElement) {
|
|
1341
|
+
return res;
|
|
1342
|
+
}
|
|
1343
|
+
return;
|
|
1344
|
+
}
|
|
1345
|
+
});
|
|
1346
|
+
needAttach && document.head.appendChild(linkEl);
|
|
1347
|
+
});
|
|
1348
|
+
} else {
|
|
1349
|
+
const defaultAttrs = {
|
|
1350
|
+
fetchpriority: 'high',
|
|
1351
|
+
type: (remoteInfo == null ? void 0 : remoteInfo.type) === 'module' ? 'module' : 'text/javascript'
|
|
1352
|
+
};
|
|
1353
|
+
jsAssetsWithoutEntry.forEach((jsUrl)=>{
|
|
1354
|
+
const { script: scriptEl, needAttach } = sdk.createScript({
|
|
1355
|
+
url: jsUrl,
|
|
1356
|
+
cb: ()=>{
|
|
1357
|
+
// noop
|
|
1358
|
+
},
|
|
1359
|
+
attrs: defaultAttrs,
|
|
1360
|
+
createScriptHook: (url, attrs)=>{
|
|
1361
|
+
const res = host.loaderHook.lifecycle.createScript.emit({
|
|
1362
|
+
url,
|
|
1363
|
+
attrs
|
|
1364
|
+
});
|
|
1365
|
+
if (res instanceof HTMLScriptElement) {
|
|
1366
|
+
return res;
|
|
1367
|
+
}
|
|
1368
|
+
return;
|
|
1369
|
+
},
|
|
1370
|
+
needDeleteScript: true
|
|
1371
|
+
});
|
|
1372
|
+
needAttach && document.head.appendChild(scriptEl);
|
|
1373
|
+
});
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
const ShareUtils = {
|
|
1379
|
+
getRegisteredShare,
|
|
1380
|
+
getGlobalShareScope
|
|
1381
|
+
};
|
|
1382
|
+
const GlobalUtils = {
|
|
1383
|
+
Global,
|
|
1384
|
+
nativeGlobal,
|
|
1385
|
+
resetFederationGlobalInfo,
|
|
1386
|
+
setGlobalFederationInstance,
|
|
1387
|
+
getGlobalFederationConstructor,
|
|
1388
|
+
setGlobalFederationConstructor,
|
|
1389
|
+
getInfoWithoutType,
|
|
1390
|
+
getGlobalSnapshot,
|
|
1391
|
+
getTargetSnapshotInfoByModuleInfo,
|
|
1392
|
+
getGlobalSnapshotInfoByModuleInfo,
|
|
1393
|
+
setGlobalSnapshotInfoByModuleInfo,
|
|
1394
|
+
addGlobalSnapshot,
|
|
1395
|
+
getRemoteEntryExports,
|
|
1396
|
+
registerGlobalPlugins,
|
|
1397
|
+
getGlobalHostPlugins,
|
|
1398
|
+
getPreloaded,
|
|
1399
|
+
setPreloaded
|
|
1400
|
+
};
|
|
1401
|
+
var helpers = {
|
|
1402
|
+
global: GlobalUtils,
|
|
1403
|
+
share: ShareUtils,
|
|
1404
|
+
utils: {
|
|
1405
|
+
matchRemoteWithNameAndExpose,
|
|
1406
|
+
preloadAssets,
|
|
1407
|
+
getRemoteInfo
|
|
1408
|
+
}
|
|
1409
|
+
};
|
|
1410
|
+
|
|
1243
1411
|
let Module = class Module {
|
|
1244
1412
|
async getEntry() {
|
|
1245
1413
|
if (this.remoteEntryExports) {
|
|
@@ -1563,169 +1731,6 @@ class PluginSystem {
|
|
|
1563
1731
|
}
|
|
1564
1732
|
}
|
|
1565
1733
|
|
|
1566
|
-
function defaultPreloadArgs(preloadConfig) {
|
|
1567
|
-
return polyfills._extends({
|
|
1568
|
-
resourceCategory: 'sync',
|
|
1569
|
-
share: true,
|
|
1570
|
-
depsRemote: true,
|
|
1571
|
-
prefetchInterface: false
|
|
1572
|
-
}, preloadConfig);
|
|
1573
|
-
}
|
|
1574
|
-
function formatPreloadArgs(remotes, preloadArgs) {
|
|
1575
|
-
return preloadArgs.map((args)=>{
|
|
1576
|
-
const remoteInfo = matchRemote(remotes, args.nameOrAlias);
|
|
1577
|
-
assert(remoteInfo, `Unable to preload ${args.nameOrAlias} as it is not included in ${!remoteInfo && sdk.safeToString({
|
|
1578
|
-
remoteInfo,
|
|
1579
|
-
remotes
|
|
1580
|
-
})}`);
|
|
1581
|
-
return {
|
|
1582
|
-
remote: remoteInfo,
|
|
1583
|
-
preloadConfig: defaultPreloadArgs(args)
|
|
1584
|
-
};
|
|
1585
|
-
});
|
|
1586
|
-
}
|
|
1587
|
-
function normalizePreloadExposes(exposes) {
|
|
1588
|
-
if (!exposes) {
|
|
1589
|
-
return [];
|
|
1590
|
-
}
|
|
1591
|
-
return exposes.map((expose)=>{
|
|
1592
|
-
if (expose === '.') {
|
|
1593
|
-
return expose;
|
|
1594
|
-
}
|
|
1595
|
-
if (expose.startsWith('./')) {
|
|
1596
|
-
return expose.replace('./', '');
|
|
1597
|
-
}
|
|
1598
|
-
return expose;
|
|
1599
|
-
});
|
|
1600
|
-
}
|
|
1601
|
-
function preloadAssets(remoteInfo, host, assets, // It is used to distinguish preload from load remote parallel loading
|
|
1602
|
-
useLinkPreload = true) {
|
|
1603
|
-
const { cssAssets, jsAssetsWithoutEntry, entryAssets } = assets;
|
|
1604
|
-
if (host.options.inBrowser) {
|
|
1605
|
-
entryAssets.forEach((asset)=>{
|
|
1606
|
-
const { moduleInfo } = asset;
|
|
1607
|
-
const module = host.moduleCache.get(remoteInfo.name);
|
|
1608
|
-
if (module) {
|
|
1609
|
-
getRemoteEntry({
|
|
1610
|
-
origin: host,
|
|
1611
|
-
remoteInfo: moduleInfo,
|
|
1612
|
-
remoteEntryExports: module.remoteEntryExports
|
|
1613
|
-
});
|
|
1614
|
-
} else {
|
|
1615
|
-
getRemoteEntry({
|
|
1616
|
-
origin: host,
|
|
1617
|
-
remoteInfo: moduleInfo,
|
|
1618
|
-
remoteEntryExports: undefined
|
|
1619
|
-
});
|
|
1620
|
-
}
|
|
1621
|
-
});
|
|
1622
|
-
if (useLinkPreload) {
|
|
1623
|
-
const defaultAttrs = {
|
|
1624
|
-
rel: 'preload',
|
|
1625
|
-
as: 'style'
|
|
1626
|
-
};
|
|
1627
|
-
cssAssets.forEach((cssUrl)=>{
|
|
1628
|
-
const { link: cssEl, needAttach } = sdk.createLink({
|
|
1629
|
-
url: cssUrl,
|
|
1630
|
-
cb: ()=>{
|
|
1631
|
-
// noop
|
|
1632
|
-
},
|
|
1633
|
-
attrs: defaultAttrs,
|
|
1634
|
-
createLinkHook: (url, attrs)=>{
|
|
1635
|
-
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
1636
|
-
url,
|
|
1637
|
-
attrs
|
|
1638
|
-
});
|
|
1639
|
-
if (res instanceof HTMLLinkElement) {
|
|
1640
|
-
return res;
|
|
1641
|
-
}
|
|
1642
|
-
return;
|
|
1643
|
-
}
|
|
1644
|
-
});
|
|
1645
|
-
needAttach && document.head.appendChild(cssEl);
|
|
1646
|
-
});
|
|
1647
|
-
} else {
|
|
1648
|
-
const defaultAttrs = {
|
|
1649
|
-
rel: 'stylesheet',
|
|
1650
|
-
type: 'text/css'
|
|
1651
|
-
};
|
|
1652
|
-
cssAssets.forEach((cssUrl)=>{
|
|
1653
|
-
const { link: cssEl, needAttach } = sdk.createLink({
|
|
1654
|
-
url: cssUrl,
|
|
1655
|
-
cb: ()=>{
|
|
1656
|
-
// noop
|
|
1657
|
-
},
|
|
1658
|
-
attrs: defaultAttrs,
|
|
1659
|
-
createLinkHook: (url, attrs)=>{
|
|
1660
|
-
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
1661
|
-
url,
|
|
1662
|
-
attrs
|
|
1663
|
-
});
|
|
1664
|
-
if (res instanceof HTMLLinkElement) {
|
|
1665
|
-
return res;
|
|
1666
|
-
}
|
|
1667
|
-
return;
|
|
1668
|
-
},
|
|
1669
|
-
needDeleteLink: false
|
|
1670
|
-
});
|
|
1671
|
-
needAttach && document.head.appendChild(cssEl);
|
|
1672
|
-
});
|
|
1673
|
-
}
|
|
1674
|
-
if (useLinkPreload) {
|
|
1675
|
-
const defaultAttrs = {
|
|
1676
|
-
rel: 'preload',
|
|
1677
|
-
as: 'script'
|
|
1678
|
-
};
|
|
1679
|
-
jsAssetsWithoutEntry.forEach((jsUrl)=>{
|
|
1680
|
-
const { link: linkEl, needAttach } = sdk.createLink({
|
|
1681
|
-
url: jsUrl,
|
|
1682
|
-
cb: ()=>{
|
|
1683
|
-
// noop
|
|
1684
|
-
},
|
|
1685
|
-
attrs: defaultAttrs,
|
|
1686
|
-
createLinkHook: (url, attrs)=>{
|
|
1687
|
-
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
1688
|
-
url,
|
|
1689
|
-
attrs
|
|
1690
|
-
});
|
|
1691
|
-
if (res instanceof HTMLLinkElement) {
|
|
1692
|
-
return res;
|
|
1693
|
-
}
|
|
1694
|
-
return;
|
|
1695
|
-
}
|
|
1696
|
-
});
|
|
1697
|
-
needAttach && document.head.appendChild(linkEl);
|
|
1698
|
-
});
|
|
1699
|
-
} else {
|
|
1700
|
-
const defaultAttrs = {
|
|
1701
|
-
fetchpriority: 'high',
|
|
1702
|
-
type: (remoteInfo == null ? void 0 : remoteInfo.type) === 'module' ? 'module' : 'text/javascript'
|
|
1703
|
-
};
|
|
1704
|
-
jsAssetsWithoutEntry.forEach((jsUrl)=>{
|
|
1705
|
-
const { script: scriptEl, needAttach } = sdk.createScript({
|
|
1706
|
-
url: jsUrl,
|
|
1707
|
-
cb: ()=>{
|
|
1708
|
-
// noop
|
|
1709
|
-
},
|
|
1710
|
-
attrs: defaultAttrs,
|
|
1711
|
-
createScriptHook: (url, attrs)=>{
|
|
1712
|
-
const res = host.loaderHook.lifecycle.createScript.emit({
|
|
1713
|
-
url,
|
|
1714
|
-
attrs
|
|
1715
|
-
});
|
|
1716
|
-
if (res instanceof HTMLScriptElement) {
|
|
1717
|
-
return res;
|
|
1718
|
-
}
|
|
1719
|
-
return;
|
|
1720
|
-
},
|
|
1721
|
-
needDeleteScript: true
|
|
1722
|
-
});
|
|
1723
|
-
needAttach && document.head.appendChild(scriptEl);
|
|
1724
|
-
});
|
|
1725
|
-
}
|
|
1726
|
-
}
|
|
1727
|
-
}
|
|
1728
|
-
|
|
1729
1734
|
function assignRemoteInfo(remoteInfo, remoteSnapshot) {
|
|
1730
1735
|
const remoteEntryInfo = getRemoteEntryInfoFromSnapshot(remoteSnapshot);
|
|
1731
1736
|
if (!remoteEntryInfo.url) {
|
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ as _extends, a as _object_without_properties_loose } from './polyfills.esm.js';
|
|
2
|
-
import { createLogger, isBrowserEnv, isReactNativeEnv, isDebugMode, composeKeyWithSeparator, loadScriptNode, loadScript,
|
|
2
|
+
import { createLogger, isBrowserEnv, isReactNativeEnv, isDebugMode, composeKeyWithSeparator, loadScriptNode, loadScript, createLink, createScript, safeToString, getResourceUrl, isManifestProvider, generateSnapshotFromManifest, warn as warn$1 } from '@module-federation/sdk';
|
|
3
3
|
export { loadScript, loadScriptNode } from '@module-federation/sdk';
|
|
4
4
|
import { getShortErrorMsg, RUNTIME_008, runtimeDescMap, RUNTIME_001, RUNTIME_002, RUNTIME_007, RUNTIME_003, RUNTIME_005, RUNTIME_006, RUNTIME_004 } from '@module-federation/error-codes';
|
|
5
5
|
|
|
@@ -942,34 +942,6 @@ function getTargetSharedOptions(options) {
|
|
|
942
942
|
return Object.assign({}, resolver(shareInfos[pkgName]), extraOptions == null ? void 0 : extraOptions.customShareInfo);
|
|
943
943
|
}
|
|
944
944
|
|
|
945
|
-
const ShareUtils = {
|
|
946
|
-
getRegisteredShare,
|
|
947
|
-
getGlobalShareScope
|
|
948
|
-
};
|
|
949
|
-
const GlobalUtils = {
|
|
950
|
-
Global,
|
|
951
|
-
nativeGlobal,
|
|
952
|
-
resetFederationGlobalInfo,
|
|
953
|
-
setGlobalFederationInstance,
|
|
954
|
-
getGlobalFederationConstructor,
|
|
955
|
-
setGlobalFederationConstructor,
|
|
956
|
-
getInfoWithoutType,
|
|
957
|
-
getGlobalSnapshot,
|
|
958
|
-
getTargetSnapshotInfoByModuleInfo,
|
|
959
|
-
getGlobalSnapshotInfoByModuleInfo,
|
|
960
|
-
setGlobalSnapshotInfoByModuleInfo,
|
|
961
|
-
addGlobalSnapshot,
|
|
962
|
-
getRemoteEntryExports,
|
|
963
|
-
registerGlobalPlugins,
|
|
964
|
-
getGlobalHostPlugins,
|
|
965
|
-
getPreloaded,
|
|
966
|
-
setPreloaded
|
|
967
|
-
};
|
|
968
|
-
var helpers = {
|
|
969
|
-
global: GlobalUtils,
|
|
970
|
-
share: ShareUtils
|
|
971
|
-
};
|
|
972
|
-
|
|
973
945
|
function getBuilderId() {
|
|
974
946
|
//@ts-ignore
|
|
975
947
|
return typeof FEDERATION_BUILD_IDENTIFIER !== 'undefined' ? FEDERATION_BUILD_IDENTIFIER : '';
|
|
@@ -1239,6 +1211,202 @@ function getRemoteInfo(remote) {
|
|
|
1239
1211
|
});
|
|
1240
1212
|
}
|
|
1241
1213
|
|
|
1214
|
+
function defaultPreloadArgs(preloadConfig) {
|
|
1215
|
+
return _extends({
|
|
1216
|
+
resourceCategory: 'sync',
|
|
1217
|
+
share: true,
|
|
1218
|
+
depsRemote: true,
|
|
1219
|
+
prefetchInterface: false
|
|
1220
|
+
}, preloadConfig);
|
|
1221
|
+
}
|
|
1222
|
+
function formatPreloadArgs(remotes, preloadArgs) {
|
|
1223
|
+
return preloadArgs.map((args)=>{
|
|
1224
|
+
const remoteInfo = matchRemote(remotes, args.nameOrAlias);
|
|
1225
|
+
assert(remoteInfo, `Unable to preload ${args.nameOrAlias} as it is not included in ${!remoteInfo && safeToString({
|
|
1226
|
+
remoteInfo,
|
|
1227
|
+
remotes
|
|
1228
|
+
})}`);
|
|
1229
|
+
return {
|
|
1230
|
+
remote: remoteInfo,
|
|
1231
|
+
preloadConfig: defaultPreloadArgs(args)
|
|
1232
|
+
};
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
function normalizePreloadExposes(exposes) {
|
|
1236
|
+
if (!exposes) {
|
|
1237
|
+
return [];
|
|
1238
|
+
}
|
|
1239
|
+
return exposes.map((expose)=>{
|
|
1240
|
+
if (expose === '.') {
|
|
1241
|
+
return expose;
|
|
1242
|
+
}
|
|
1243
|
+
if (expose.startsWith('./')) {
|
|
1244
|
+
return expose.replace('./', '');
|
|
1245
|
+
}
|
|
1246
|
+
return expose;
|
|
1247
|
+
});
|
|
1248
|
+
}
|
|
1249
|
+
function preloadAssets(remoteInfo, host, assets, // It is used to distinguish preload from load remote parallel loading
|
|
1250
|
+
useLinkPreload = true) {
|
|
1251
|
+
const { cssAssets, jsAssetsWithoutEntry, entryAssets } = assets;
|
|
1252
|
+
if (host.options.inBrowser) {
|
|
1253
|
+
entryAssets.forEach((asset)=>{
|
|
1254
|
+
const { moduleInfo } = asset;
|
|
1255
|
+
const module = host.moduleCache.get(remoteInfo.name);
|
|
1256
|
+
if (module) {
|
|
1257
|
+
getRemoteEntry({
|
|
1258
|
+
origin: host,
|
|
1259
|
+
remoteInfo: moduleInfo,
|
|
1260
|
+
remoteEntryExports: module.remoteEntryExports
|
|
1261
|
+
});
|
|
1262
|
+
} else {
|
|
1263
|
+
getRemoteEntry({
|
|
1264
|
+
origin: host,
|
|
1265
|
+
remoteInfo: moduleInfo,
|
|
1266
|
+
remoteEntryExports: undefined
|
|
1267
|
+
});
|
|
1268
|
+
}
|
|
1269
|
+
});
|
|
1270
|
+
if (useLinkPreload) {
|
|
1271
|
+
const defaultAttrs = {
|
|
1272
|
+
rel: 'preload',
|
|
1273
|
+
as: 'style'
|
|
1274
|
+
};
|
|
1275
|
+
cssAssets.forEach((cssUrl)=>{
|
|
1276
|
+
const { link: cssEl, needAttach } = createLink({
|
|
1277
|
+
url: cssUrl,
|
|
1278
|
+
cb: ()=>{
|
|
1279
|
+
// noop
|
|
1280
|
+
},
|
|
1281
|
+
attrs: defaultAttrs,
|
|
1282
|
+
createLinkHook: (url, attrs)=>{
|
|
1283
|
+
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
1284
|
+
url,
|
|
1285
|
+
attrs
|
|
1286
|
+
});
|
|
1287
|
+
if (res instanceof HTMLLinkElement) {
|
|
1288
|
+
return res;
|
|
1289
|
+
}
|
|
1290
|
+
return;
|
|
1291
|
+
}
|
|
1292
|
+
});
|
|
1293
|
+
needAttach && document.head.appendChild(cssEl);
|
|
1294
|
+
});
|
|
1295
|
+
} else {
|
|
1296
|
+
const defaultAttrs = {
|
|
1297
|
+
rel: 'stylesheet',
|
|
1298
|
+
type: 'text/css'
|
|
1299
|
+
};
|
|
1300
|
+
cssAssets.forEach((cssUrl)=>{
|
|
1301
|
+
const { link: cssEl, needAttach } = createLink({
|
|
1302
|
+
url: cssUrl,
|
|
1303
|
+
cb: ()=>{
|
|
1304
|
+
// noop
|
|
1305
|
+
},
|
|
1306
|
+
attrs: defaultAttrs,
|
|
1307
|
+
createLinkHook: (url, attrs)=>{
|
|
1308
|
+
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
1309
|
+
url,
|
|
1310
|
+
attrs
|
|
1311
|
+
});
|
|
1312
|
+
if (res instanceof HTMLLinkElement) {
|
|
1313
|
+
return res;
|
|
1314
|
+
}
|
|
1315
|
+
return;
|
|
1316
|
+
},
|
|
1317
|
+
needDeleteLink: false
|
|
1318
|
+
});
|
|
1319
|
+
needAttach && document.head.appendChild(cssEl);
|
|
1320
|
+
});
|
|
1321
|
+
}
|
|
1322
|
+
if (useLinkPreload) {
|
|
1323
|
+
const defaultAttrs = {
|
|
1324
|
+
rel: 'preload',
|
|
1325
|
+
as: 'script'
|
|
1326
|
+
};
|
|
1327
|
+
jsAssetsWithoutEntry.forEach((jsUrl)=>{
|
|
1328
|
+
const { link: linkEl, needAttach } = createLink({
|
|
1329
|
+
url: jsUrl,
|
|
1330
|
+
cb: ()=>{
|
|
1331
|
+
// noop
|
|
1332
|
+
},
|
|
1333
|
+
attrs: defaultAttrs,
|
|
1334
|
+
createLinkHook: (url, attrs)=>{
|
|
1335
|
+
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
1336
|
+
url,
|
|
1337
|
+
attrs
|
|
1338
|
+
});
|
|
1339
|
+
if (res instanceof HTMLLinkElement) {
|
|
1340
|
+
return res;
|
|
1341
|
+
}
|
|
1342
|
+
return;
|
|
1343
|
+
}
|
|
1344
|
+
});
|
|
1345
|
+
needAttach && document.head.appendChild(linkEl);
|
|
1346
|
+
});
|
|
1347
|
+
} else {
|
|
1348
|
+
const defaultAttrs = {
|
|
1349
|
+
fetchpriority: 'high',
|
|
1350
|
+
type: (remoteInfo == null ? void 0 : remoteInfo.type) === 'module' ? 'module' : 'text/javascript'
|
|
1351
|
+
};
|
|
1352
|
+
jsAssetsWithoutEntry.forEach((jsUrl)=>{
|
|
1353
|
+
const { script: scriptEl, needAttach } = createScript({
|
|
1354
|
+
url: jsUrl,
|
|
1355
|
+
cb: ()=>{
|
|
1356
|
+
// noop
|
|
1357
|
+
},
|
|
1358
|
+
attrs: defaultAttrs,
|
|
1359
|
+
createScriptHook: (url, attrs)=>{
|
|
1360
|
+
const res = host.loaderHook.lifecycle.createScript.emit({
|
|
1361
|
+
url,
|
|
1362
|
+
attrs
|
|
1363
|
+
});
|
|
1364
|
+
if (res instanceof HTMLScriptElement) {
|
|
1365
|
+
return res;
|
|
1366
|
+
}
|
|
1367
|
+
return;
|
|
1368
|
+
},
|
|
1369
|
+
needDeleteScript: true
|
|
1370
|
+
});
|
|
1371
|
+
needAttach && document.head.appendChild(scriptEl);
|
|
1372
|
+
});
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
const ShareUtils = {
|
|
1378
|
+
getRegisteredShare,
|
|
1379
|
+
getGlobalShareScope
|
|
1380
|
+
};
|
|
1381
|
+
const GlobalUtils = {
|
|
1382
|
+
Global,
|
|
1383
|
+
nativeGlobal,
|
|
1384
|
+
resetFederationGlobalInfo,
|
|
1385
|
+
setGlobalFederationInstance,
|
|
1386
|
+
getGlobalFederationConstructor,
|
|
1387
|
+
setGlobalFederationConstructor,
|
|
1388
|
+
getInfoWithoutType,
|
|
1389
|
+
getGlobalSnapshot,
|
|
1390
|
+
getTargetSnapshotInfoByModuleInfo,
|
|
1391
|
+
getGlobalSnapshotInfoByModuleInfo,
|
|
1392
|
+
setGlobalSnapshotInfoByModuleInfo,
|
|
1393
|
+
addGlobalSnapshot,
|
|
1394
|
+
getRemoteEntryExports,
|
|
1395
|
+
registerGlobalPlugins,
|
|
1396
|
+
getGlobalHostPlugins,
|
|
1397
|
+
getPreloaded,
|
|
1398
|
+
setPreloaded
|
|
1399
|
+
};
|
|
1400
|
+
var helpers = {
|
|
1401
|
+
global: GlobalUtils,
|
|
1402
|
+
share: ShareUtils,
|
|
1403
|
+
utils: {
|
|
1404
|
+
matchRemoteWithNameAndExpose,
|
|
1405
|
+
preloadAssets,
|
|
1406
|
+
getRemoteInfo
|
|
1407
|
+
}
|
|
1408
|
+
};
|
|
1409
|
+
|
|
1242
1410
|
let Module = class Module {
|
|
1243
1411
|
async getEntry() {
|
|
1244
1412
|
if (this.remoteEntryExports) {
|
|
@@ -1562,169 +1730,6 @@ class PluginSystem {
|
|
|
1562
1730
|
}
|
|
1563
1731
|
}
|
|
1564
1732
|
|
|
1565
|
-
function defaultPreloadArgs(preloadConfig) {
|
|
1566
|
-
return _extends({
|
|
1567
|
-
resourceCategory: 'sync',
|
|
1568
|
-
share: true,
|
|
1569
|
-
depsRemote: true,
|
|
1570
|
-
prefetchInterface: false
|
|
1571
|
-
}, preloadConfig);
|
|
1572
|
-
}
|
|
1573
|
-
function formatPreloadArgs(remotes, preloadArgs) {
|
|
1574
|
-
return preloadArgs.map((args)=>{
|
|
1575
|
-
const remoteInfo = matchRemote(remotes, args.nameOrAlias);
|
|
1576
|
-
assert(remoteInfo, `Unable to preload ${args.nameOrAlias} as it is not included in ${!remoteInfo && safeToString({
|
|
1577
|
-
remoteInfo,
|
|
1578
|
-
remotes
|
|
1579
|
-
})}`);
|
|
1580
|
-
return {
|
|
1581
|
-
remote: remoteInfo,
|
|
1582
|
-
preloadConfig: defaultPreloadArgs(args)
|
|
1583
|
-
};
|
|
1584
|
-
});
|
|
1585
|
-
}
|
|
1586
|
-
function normalizePreloadExposes(exposes) {
|
|
1587
|
-
if (!exposes) {
|
|
1588
|
-
return [];
|
|
1589
|
-
}
|
|
1590
|
-
return exposes.map((expose)=>{
|
|
1591
|
-
if (expose === '.') {
|
|
1592
|
-
return expose;
|
|
1593
|
-
}
|
|
1594
|
-
if (expose.startsWith('./')) {
|
|
1595
|
-
return expose.replace('./', '');
|
|
1596
|
-
}
|
|
1597
|
-
return expose;
|
|
1598
|
-
});
|
|
1599
|
-
}
|
|
1600
|
-
function preloadAssets(remoteInfo, host, assets, // It is used to distinguish preload from load remote parallel loading
|
|
1601
|
-
useLinkPreload = true) {
|
|
1602
|
-
const { cssAssets, jsAssetsWithoutEntry, entryAssets } = assets;
|
|
1603
|
-
if (host.options.inBrowser) {
|
|
1604
|
-
entryAssets.forEach((asset)=>{
|
|
1605
|
-
const { moduleInfo } = asset;
|
|
1606
|
-
const module = host.moduleCache.get(remoteInfo.name);
|
|
1607
|
-
if (module) {
|
|
1608
|
-
getRemoteEntry({
|
|
1609
|
-
origin: host,
|
|
1610
|
-
remoteInfo: moduleInfo,
|
|
1611
|
-
remoteEntryExports: module.remoteEntryExports
|
|
1612
|
-
});
|
|
1613
|
-
} else {
|
|
1614
|
-
getRemoteEntry({
|
|
1615
|
-
origin: host,
|
|
1616
|
-
remoteInfo: moduleInfo,
|
|
1617
|
-
remoteEntryExports: undefined
|
|
1618
|
-
});
|
|
1619
|
-
}
|
|
1620
|
-
});
|
|
1621
|
-
if (useLinkPreload) {
|
|
1622
|
-
const defaultAttrs = {
|
|
1623
|
-
rel: 'preload',
|
|
1624
|
-
as: 'style'
|
|
1625
|
-
};
|
|
1626
|
-
cssAssets.forEach((cssUrl)=>{
|
|
1627
|
-
const { link: cssEl, needAttach } = createLink({
|
|
1628
|
-
url: cssUrl,
|
|
1629
|
-
cb: ()=>{
|
|
1630
|
-
// noop
|
|
1631
|
-
},
|
|
1632
|
-
attrs: defaultAttrs,
|
|
1633
|
-
createLinkHook: (url, attrs)=>{
|
|
1634
|
-
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
1635
|
-
url,
|
|
1636
|
-
attrs
|
|
1637
|
-
});
|
|
1638
|
-
if (res instanceof HTMLLinkElement) {
|
|
1639
|
-
return res;
|
|
1640
|
-
}
|
|
1641
|
-
return;
|
|
1642
|
-
}
|
|
1643
|
-
});
|
|
1644
|
-
needAttach && document.head.appendChild(cssEl);
|
|
1645
|
-
});
|
|
1646
|
-
} else {
|
|
1647
|
-
const defaultAttrs = {
|
|
1648
|
-
rel: 'stylesheet',
|
|
1649
|
-
type: 'text/css'
|
|
1650
|
-
};
|
|
1651
|
-
cssAssets.forEach((cssUrl)=>{
|
|
1652
|
-
const { link: cssEl, needAttach } = createLink({
|
|
1653
|
-
url: cssUrl,
|
|
1654
|
-
cb: ()=>{
|
|
1655
|
-
// noop
|
|
1656
|
-
},
|
|
1657
|
-
attrs: defaultAttrs,
|
|
1658
|
-
createLinkHook: (url, attrs)=>{
|
|
1659
|
-
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
1660
|
-
url,
|
|
1661
|
-
attrs
|
|
1662
|
-
});
|
|
1663
|
-
if (res instanceof HTMLLinkElement) {
|
|
1664
|
-
return res;
|
|
1665
|
-
}
|
|
1666
|
-
return;
|
|
1667
|
-
},
|
|
1668
|
-
needDeleteLink: false
|
|
1669
|
-
});
|
|
1670
|
-
needAttach && document.head.appendChild(cssEl);
|
|
1671
|
-
});
|
|
1672
|
-
}
|
|
1673
|
-
if (useLinkPreload) {
|
|
1674
|
-
const defaultAttrs = {
|
|
1675
|
-
rel: 'preload',
|
|
1676
|
-
as: 'script'
|
|
1677
|
-
};
|
|
1678
|
-
jsAssetsWithoutEntry.forEach((jsUrl)=>{
|
|
1679
|
-
const { link: linkEl, needAttach } = createLink({
|
|
1680
|
-
url: jsUrl,
|
|
1681
|
-
cb: ()=>{
|
|
1682
|
-
// noop
|
|
1683
|
-
},
|
|
1684
|
-
attrs: defaultAttrs,
|
|
1685
|
-
createLinkHook: (url, attrs)=>{
|
|
1686
|
-
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
1687
|
-
url,
|
|
1688
|
-
attrs
|
|
1689
|
-
});
|
|
1690
|
-
if (res instanceof HTMLLinkElement) {
|
|
1691
|
-
return res;
|
|
1692
|
-
}
|
|
1693
|
-
return;
|
|
1694
|
-
}
|
|
1695
|
-
});
|
|
1696
|
-
needAttach && document.head.appendChild(linkEl);
|
|
1697
|
-
});
|
|
1698
|
-
} else {
|
|
1699
|
-
const defaultAttrs = {
|
|
1700
|
-
fetchpriority: 'high',
|
|
1701
|
-
type: (remoteInfo == null ? void 0 : remoteInfo.type) === 'module' ? 'module' : 'text/javascript'
|
|
1702
|
-
};
|
|
1703
|
-
jsAssetsWithoutEntry.forEach((jsUrl)=>{
|
|
1704
|
-
const { script: scriptEl, needAttach } = createScript({
|
|
1705
|
-
url: jsUrl,
|
|
1706
|
-
cb: ()=>{
|
|
1707
|
-
// noop
|
|
1708
|
-
},
|
|
1709
|
-
attrs: defaultAttrs,
|
|
1710
|
-
createScriptHook: (url, attrs)=>{
|
|
1711
|
-
const res = host.loaderHook.lifecycle.createScript.emit({
|
|
1712
|
-
url,
|
|
1713
|
-
attrs
|
|
1714
|
-
});
|
|
1715
|
-
if (res instanceof HTMLScriptElement) {
|
|
1716
|
-
return res;
|
|
1717
|
-
}
|
|
1718
|
-
return;
|
|
1719
|
-
},
|
|
1720
|
-
needDeleteScript: true
|
|
1721
|
-
});
|
|
1722
|
-
needAttach && document.head.appendChild(scriptEl);
|
|
1723
|
-
});
|
|
1724
|
-
}
|
|
1725
|
-
}
|
|
1726
|
-
}
|
|
1727
|
-
|
|
1728
1733
|
function assignRemoteInfo(remoteInfo, remoteSnapshot) {
|
|
1729
1734
|
const remoteEntryInfo = getRemoteEntryInfoFromSnapshot(remoteSnapshot);
|
|
1730
1735
|
if (!remoteEntryInfo.url) {
|
package/dist/src/helpers.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { resetFederationGlobalInfo, setGlobalFederationInstance, getGlobalFederationConstructor, setGlobalFederationConstructor, getInfoWithoutType, getGlobalSnapshot, getTargetSnapshotInfoByModuleInfo, getGlobalSnapshotInfoByModuleInfo, setGlobalSnapshotInfoByModuleInfo, addGlobalSnapshot, getRemoteEntryExports, registerGlobalPlugins, getGlobalHostPlugins, getPreloaded, setPreloaded, Global } from './global';
|
|
2
2
|
import { getRegisteredShare, getGlobalShareScope } from './utils/share';
|
|
3
|
+
import { getRemoteInfo, matchRemoteWithNameAndExpose } from './utils';
|
|
4
|
+
import { preloadAssets } from './utils/preload';
|
|
3
5
|
interface IShareUtils {
|
|
4
6
|
getRegisteredShare: typeof getRegisteredShare;
|
|
5
7
|
getGlobalShareScope: typeof getGlobalShareScope;
|
|
@@ -26,6 +28,11 @@ interface IGlobalUtils {
|
|
|
26
28
|
declare const _default: {
|
|
27
29
|
global: IGlobalUtils;
|
|
28
30
|
share: IShareUtils;
|
|
31
|
+
utils: {
|
|
32
|
+
matchRemoteWithNameAndExpose: typeof matchRemoteWithNameAndExpose;
|
|
33
|
+
preloadAssets: typeof preloadAssets;
|
|
34
|
+
getRemoteInfo: typeof getRemoteInfo;
|
|
35
|
+
};
|
|
29
36
|
};
|
|
30
37
|
export default _default;
|
|
31
38
|
export type { IGlobalUtils, IShareUtils };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/runtime-core",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20250626022312",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "zhouxiao <codingzx@gmail.com>",
|
|
6
6
|
"main": "./dist/index.cjs.cjs",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@module-federation/sdk": "0.0.0-next-
|
|
56
|
-
"@module-federation/error-codes": "0.0.0-next-
|
|
55
|
+
"@module-federation/sdk": "0.0.0-next-20250626022312",
|
|
56
|
+
"@module-federation/error-codes": "0.0.0-next-20250626022312"
|
|
57
57
|
}
|
|
58
58
|
}
|