@module-federation/runtime 0.0.0-next-20240521035527 → 0.0.0-next-20240521123600
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/helpers.esm.js +1 -1
- package/dist/index.cjs.js +21 -32
- package/dist/index.esm.js +26 -38
- package/dist/package.json +1 -1
- package/dist/share.cjs.js +24 -1
- package/dist/share.esm.js +24 -2
- package/dist/src/core.d.ts +1 -2
- package/dist/src/index.d.ts +1 -0
- package/dist/src/plugins/snapshot/SnapshotHandler.d.ts +5 -1
- package/dist/src/remote/index.d.ts +1 -0
- package/dist/src/utils/load.d.ts +2 -3
- package/dist/src/utils/tool.d.ts +6 -1
- package/package.json +2 -2
package/dist/helpers.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { q as getRegisteredShare, A as getGlobalShareScope, G as Global, K as nativeGlobal, L as resetFederationGlobalInfo, F as getGlobalFederationInstance, I as setGlobalFederationInstance, H as getGlobalFederationConstructor, E as setGlobalFederationConstructor, n as getInfoWithoutType, x as getGlobalSnapshot, M as getTargetSnapshotInfoByModuleInfo, t as getGlobalSnapshotInfoByModuleInfo, v as setGlobalSnapshotInfoByModuleInfo, u as addGlobalSnapshot, c as getRemoteEntryExports, J as registerGlobalPlugins, g as getGlobalHostPlugins, o as getPreloaded, p as setPreloaded } from './share.esm.js';
|
|
2
2
|
|
|
3
3
|
const ShareUtils = {
|
|
4
4
|
getRegisteredShare,
|
package/dist/index.cjs.js
CHANGED
|
@@ -224,7 +224,6 @@ let Module = class Module {
|
|
|
224
224
|
const res = this.host.loaderHook.lifecycle.createScript.emit({
|
|
225
225
|
url
|
|
226
226
|
});
|
|
227
|
-
if (!res) return;
|
|
228
227
|
if (typeof document === 'undefined') {
|
|
229
228
|
//todo: needs real fix
|
|
230
229
|
return res;
|
|
@@ -232,9 +231,6 @@ let Module = class Module {
|
|
|
232
231
|
if (res instanceof HTMLScriptElement) {
|
|
233
232
|
return res;
|
|
234
233
|
}
|
|
235
|
-
if ('script' in res || 'timeout' in res) {
|
|
236
|
-
return res;
|
|
237
|
-
}
|
|
238
234
|
return;
|
|
239
235
|
}
|
|
240
236
|
});
|
|
@@ -548,17 +544,9 @@ function preloadAssets(remoteInfo, host, assets) {
|
|
|
548
544
|
const res = host.loaderHook.lifecycle.createScript.emit({
|
|
549
545
|
url
|
|
550
546
|
});
|
|
551
|
-
if (!res) return;
|
|
552
|
-
if (typeof document === 'undefined') {
|
|
553
|
-
//todo: needs real fix
|
|
554
|
-
return res;
|
|
555
|
-
}
|
|
556
547
|
if (res instanceof HTMLScriptElement) {
|
|
557
548
|
return res;
|
|
558
549
|
}
|
|
559
|
-
if ('script' in res || 'timeout' in res) {
|
|
560
|
-
return res;
|
|
561
|
-
}
|
|
562
550
|
return;
|
|
563
551
|
}
|
|
564
552
|
});
|
|
@@ -570,17 +558,9 @@ function preloadAssets(remoteInfo, host, assets) {
|
|
|
570
558
|
const res = host.loaderHook.lifecycle.createScript.emit({
|
|
571
559
|
url
|
|
572
560
|
});
|
|
573
|
-
if (!res) return;
|
|
574
|
-
if (typeof document === 'undefined') {
|
|
575
|
-
//todo: needs real fix
|
|
576
|
-
return res;
|
|
577
|
-
}
|
|
578
561
|
if (res instanceof HTMLScriptElement) {
|
|
579
562
|
return res;
|
|
580
563
|
}
|
|
581
|
-
if ('script' in res || 'timeout' in res) {
|
|
582
|
-
return res;
|
|
583
|
-
}
|
|
584
564
|
return;
|
|
585
565
|
}
|
|
586
566
|
});
|
|
@@ -638,13 +618,16 @@ function _extends$4() {
|
|
|
638
618
|
return _extends$4.apply(this, arguments);
|
|
639
619
|
}
|
|
640
620
|
function assignRemoteInfo(remoteInfo, remoteSnapshot) {
|
|
641
|
-
|
|
642
|
-
|
|
621
|
+
const remoteEntryInfo = share.getRemoteEntryInfoFromSnapshot(remoteSnapshot);
|
|
622
|
+
if (!remoteEntryInfo.url) {
|
|
623
|
+
share.error(`The attribute remoteEntry of ${remoteInfo.name} must not be undefined.`);
|
|
624
|
+
}
|
|
625
|
+
let entryUrl = sdk.getResourceUrl(remoteSnapshot, remoteEntryInfo.url);
|
|
626
|
+
if (!share.isBrowserEnv() && !entryUrl.startsWith('http')) {
|
|
627
|
+
entryUrl = `https:${entryUrl}`;
|
|
643
628
|
}
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
remoteInfo.type = remoteSnapshot.remoteEntryType;
|
|
647
|
-
remoteInfo.entryGlobalName = remoteSnapshot.globalName;
|
|
629
|
+
remoteInfo.type = remoteEntryInfo.type;
|
|
630
|
+
remoteInfo.entryGlobalName = remoteEntryInfo.globalName;
|
|
648
631
|
remoteInfo.entry = entryUrl;
|
|
649
632
|
remoteInfo.version = remoteSnapshot.version;
|
|
650
633
|
remoteInfo.buildVersion = remoteSnapshot.buildVersion;
|
|
@@ -769,7 +752,7 @@ function generatePreloadAssets(origin, preloadOptions, remote, globalSnapshot, r
|
|
|
769
752
|
return;
|
|
770
753
|
}
|
|
771
754
|
}
|
|
772
|
-
const remoteEntryUrl = sdk.getResourceUrl(moduleInfoSnapshot,
|
|
755
|
+
const remoteEntryUrl = sdk.getResourceUrl(moduleInfoSnapshot, share.getRemoteEntryInfoFromSnapshot(moduleInfoSnapshot).url);
|
|
773
756
|
if (remoteEntryUrl) {
|
|
774
757
|
entryAssets.push({
|
|
775
758
|
name: remoteInfo.name,
|
|
@@ -975,12 +958,13 @@ class SnapshotHandler {
|
|
|
975
958
|
// global snapshot includes manifest or module info includes manifest
|
|
976
959
|
if (globalRemoteSnapshot) {
|
|
977
960
|
if (sdk.isManifestProvider(globalRemoteSnapshot)) {
|
|
978
|
-
const
|
|
961
|
+
const remoteEntry = share.isBrowserEnv() ? globalRemoteSnapshot.remoteEntry : globalRemoteSnapshot.ssrRemoteEntry || globalRemoteSnapshot.remoteEntry || '';
|
|
962
|
+
const moduleSnapshot = await this.getManifestJson(remoteEntry, moduleInfo, {});
|
|
979
963
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
980
964
|
const globalSnapshotRes = share.setGlobalSnapshotInfoByModuleInfo(_extends$3({}, moduleInfo, {
|
|
981
965
|
// The global remote may be overridden
|
|
982
966
|
// Therefore, set the snapshot key to the global address of the actual request
|
|
983
|
-
entry:
|
|
967
|
+
entry: remoteEntry
|
|
984
968
|
}), moduleSnapshot);
|
|
985
969
|
return {
|
|
986
970
|
remoteSnapshot: moduleSnapshot,
|
|
@@ -1512,6 +1496,7 @@ class RemoteHandler {
|
|
|
1512
1496
|
moduleInstance: module,
|
|
1513
1497
|
origin: host
|
|
1514
1498
|
});
|
|
1499
|
+
this.idToModuleNameMap[id] = remote.name;
|
|
1515
1500
|
if (typeof moduleWrapper === 'function') {
|
|
1516
1501
|
return moduleWrapper;
|
|
1517
1502
|
}
|
|
@@ -1678,10 +1663,9 @@ class RemoteHandler {
|
|
|
1678
1663
|
}
|
|
1679
1664
|
const loadedModule = host.moduleCache.get(remote.name);
|
|
1680
1665
|
if (loadedModule) {
|
|
1681
|
-
var _Object_getOwnPropertyDescriptor;
|
|
1682
1666
|
const remoteInfo = loadedModule.remoteInfo;
|
|
1683
1667
|
const key = remoteInfo.entryGlobalName;
|
|
1684
|
-
if (globalThis[key]
|
|
1668
|
+
if (globalThis[key]) {
|
|
1685
1669
|
delete globalThis[key];
|
|
1686
1670
|
}
|
|
1687
1671
|
const remoteEntryUniqueKey = getRemoteEntryUniqueKey(loadedModule.remoteInfo);
|
|
@@ -1759,6 +1743,7 @@ class RemoteHandler {
|
|
|
1759
1743
|
afterPreloadRemote: new AsyncHook()
|
|
1760
1744
|
});
|
|
1761
1745
|
this.host = host;
|
|
1746
|
+
this.idToModuleNameMap = {};
|
|
1762
1747
|
}
|
|
1763
1748
|
}
|
|
1764
1749
|
|
|
@@ -1881,7 +1866,7 @@ class FederationHost {
|
|
|
1881
1866
|
// maybe will change, temporarily for internal use only
|
|
1882
1867
|
initContainer: new AsyncWaterfallHook('initContainer')
|
|
1883
1868
|
});
|
|
1884
|
-
this.version = "0.1.
|
|
1869
|
+
this.version = "0.1.13";
|
|
1885
1870
|
this.moduleCache = new Map();
|
|
1886
1871
|
this.loaderHook = new PluginSystem({
|
|
1887
1872
|
// FIXME: may not be suitable , not open to the public yet
|
|
@@ -1970,6 +1955,9 @@ function registerPlugins(...args) {
|
|
|
1970
1955
|
// eslint-disable-next-line prefer-spread
|
|
1971
1956
|
return FederationInstance.registerPlugins.apply(FederationInstance, args);
|
|
1972
1957
|
}
|
|
1958
|
+
function getInstance() {
|
|
1959
|
+
return FederationInstance;
|
|
1960
|
+
}
|
|
1973
1961
|
// Inject for debug
|
|
1974
1962
|
share.setGlobalFederationConstructor(FederationHost);
|
|
1975
1963
|
|
|
@@ -1983,6 +1971,7 @@ Object.defineProperty(exports, 'loadScriptNode', {
|
|
|
1983
1971
|
get: function () { return sdk.loadScriptNode; }
|
|
1984
1972
|
});
|
|
1985
1973
|
exports.FederationHost = FederationHost;
|
|
1974
|
+
exports.getInstance = getInstance;
|
|
1986
1975
|
exports.getRemoteEntry = getRemoteEntry;
|
|
1987
1976
|
exports.getRemoteInfo = getRemoteInfo;
|
|
1988
1977
|
exports.init = init;
|
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
|
|
2
|
-
export {
|
|
3
|
-
import { loadScriptNode, loadScript, composeKeyWithSeparator, createLink, getResourceUrl, isManifestProvider, generateSnapshotFromManifest, warn as warn$1, isBrowserEnv } from '@module-federation/sdk';
|
|
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, x as getGlobalSnapshot, G as Global, 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
|
+
export { J as registerGlobalPlugins } from './share.esm.js';
|
|
3
|
+
import { loadScriptNode, loadScript, composeKeyWithSeparator, createLink, 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
|
|
@@ -222,7 +222,6 @@ let Module = class Module {
|
|
|
222
222
|
const res = this.host.loaderHook.lifecycle.createScript.emit({
|
|
223
223
|
url
|
|
224
224
|
});
|
|
225
|
-
if (!res) return;
|
|
226
225
|
if (typeof document === 'undefined') {
|
|
227
226
|
//todo: needs real fix
|
|
228
227
|
return res;
|
|
@@ -230,9 +229,6 @@ let Module = class Module {
|
|
|
230
229
|
if (res instanceof HTMLScriptElement) {
|
|
231
230
|
return res;
|
|
232
231
|
}
|
|
233
|
-
if ('script' in res || 'timeout' in res) {
|
|
234
|
-
return res;
|
|
235
|
-
}
|
|
236
232
|
return;
|
|
237
233
|
}
|
|
238
234
|
});
|
|
@@ -546,17 +542,9 @@ function preloadAssets(remoteInfo, host, assets) {
|
|
|
546
542
|
const res = host.loaderHook.lifecycle.createScript.emit({
|
|
547
543
|
url
|
|
548
544
|
});
|
|
549
|
-
if (!res) return;
|
|
550
|
-
if (typeof document === 'undefined') {
|
|
551
|
-
//todo: needs real fix
|
|
552
|
-
return res;
|
|
553
|
-
}
|
|
554
545
|
if (res instanceof HTMLScriptElement) {
|
|
555
546
|
return res;
|
|
556
547
|
}
|
|
557
|
-
if ('script' in res || 'timeout' in res) {
|
|
558
|
-
return res;
|
|
559
|
-
}
|
|
560
548
|
return;
|
|
561
549
|
}
|
|
562
550
|
});
|
|
@@ -568,17 +556,9 @@ function preloadAssets(remoteInfo, host, assets) {
|
|
|
568
556
|
const res = host.loaderHook.lifecycle.createScript.emit({
|
|
569
557
|
url
|
|
570
558
|
});
|
|
571
|
-
if (!res) return;
|
|
572
|
-
if (typeof document === 'undefined') {
|
|
573
|
-
//todo: needs real fix
|
|
574
|
-
return res;
|
|
575
|
-
}
|
|
576
559
|
if (res instanceof HTMLScriptElement) {
|
|
577
560
|
return res;
|
|
578
561
|
}
|
|
579
|
-
if ('script' in res || 'timeout' in res) {
|
|
580
|
-
return res;
|
|
581
|
-
}
|
|
582
562
|
return;
|
|
583
563
|
}
|
|
584
564
|
});
|
|
@@ -636,13 +616,16 @@ function _extends$4() {
|
|
|
636
616
|
return _extends$4.apply(this, arguments);
|
|
637
617
|
}
|
|
638
618
|
function assignRemoteInfo(remoteInfo, remoteSnapshot) {
|
|
639
|
-
|
|
640
|
-
|
|
619
|
+
const remoteEntryInfo = getRemoteEntryInfoFromSnapshot(remoteSnapshot);
|
|
620
|
+
if (!remoteEntryInfo.url) {
|
|
621
|
+
error(`The attribute remoteEntry of ${remoteInfo.name} must not be undefined.`);
|
|
622
|
+
}
|
|
623
|
+
let entryUrl = getResourceUrl(remoteSnapshot, remoteEntryInfo.url);
|
|
624
|
+
if (!isBrowserEnv() && !entryUrl.startsWith('http')) {
|
|
625
|
+
entryUrl = `https:${entryUrl}`;
|
|
641
626
|
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
remoteInfo.type = remoteSnapshot.remoteEntryType;
|
|
645
|
-
remoteInfo.entryGlobalName = remoteSnapshot.globalName;
|
|
627
|
+
remoteInfo.type = remoteEntryInfo.type;
|
|
628
|
+
remoteInfo.entryGlobalName = remoteEntryInfo.globalName;
|
|
646
629
|
remoteInfo.entry = entryUrl;
|
|
647
630
|
remoteInfo.version = remoteSnapshot.version;
|
|
648
631
|
remoteInfo.buildVersion = remoteSnapshot.buildVersion;
|
|
@@ -767,7 +750,7 @@ function generatePreloadAssets(origin, preloadOptions, remote, globalSnapshot, r
|
|
|
767
750
|
return;
|
|
768
751
|
}
|
|
769
752
|
}
|
|
770
|
-
const remoteEntryUrl = getResourceUrl(moduleInfoSnapshot,
|
|
753
|
+
const remoteEntryUrl = getResourceUrl(moduleInfoSnapshot, getRemoteEntryInfoFromSnapshot(moduleInfoSnapshot).url);
|
|
771
754
|
if (remoteEntryUrl) {
|
|
772
755
|
entryAssets.push({
|
|
773
756
|
name: remoteInfo.name,
|
|
@@ -973,12 +956,13 @@ class SnapshotHandler {
|
|
|
973
956
|
// global snapshot includes manifest or module info includes manifest
|
|
974
957
|
if (globalRemoteSnapshot) {
|
|
975
958
|
if (isManifestProvider(globalRemoteSnapshot)) {
|
|
976
|
-
const
|
|
959
|
+
const remoteEntry = isBrowserEnv() ? globalRemoteSnapshot.remoteEntry : globalRemoteSnapshot.ssrRemoteEntry || globalRemoteSnapshot.remoteEntry || '';
|
|
960
|
+
const moduleSnapshot = await this.getManifestJson(remoteEntry, moduleInfo, {});
|
|
977
961
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
978
962
|
const globalSnapshotRes = setGlobalSnapshotInfoByModuleInfo(_extends$3({}, moduleInfo, {
|
|
979
963
|
// The global remote may be overridden
|
|
980
964
|
// Therefore, set the snapshot key to the global address of the actual request
|
|
981
|
-
entry:
|
|
965
|
+
entry: remoteEntry
|
|
982
966
|
}), moduleSnapshot);
|
|
983
967
|
return {
|
|
984
968
|
remoteSnapshot: moduleSnapshot,
|
|
@@ -1510,6 +1494,7 @@ class RemoteHandler {
|
|
|
1510
1494
|
moduleInstance: module,
|
|
1511
1495
|
origin: host
|
|
1512
1496
|
});
|
|
1497
|
+
this.idToModuleNameMap[id] = remote.name;
|
|
1513
1498
|
if (typeof moduleWrapper === 'function') {
|
|
1514
1499
|
return moduleWrapper;
|
|
1515
1500
|
}
|
|
@@ -1638,7 +1623,7 @@ class RemoteHandler {
|
|
|
1638
1623
|
}
|
|
1639
1624
|
// Set the remote entry to a complete path
|
|
1640
1625
|
if ('entry' in remote) {
|
|
1641
|
-
if (isBrowserEnv() && !remote.entry.startsWith('http')) {
|
|
1626
|
+
if (isBrowserEnv$1() && !remote.entry.startsWith('http')) {
|
|
1642
1627
|
remote.entry = new URL(remote.entry, window.location.origin).href;
|
|
1643
1628
|
}
|
|
1644
1629
|
}
|
|
@@ -1676,10 +1661,9 @@ class RemoteHandler {
|
|
|
1676
1661
|
}
|
|
1677
1662
|
const loadedModule = host.moduleCache.get(remote.name);
|
|
1678
1663
|
if (loadedModule) {
|
|
1679
|
-
var _Object_getOwnPropertyDescriptor;
|
|
1680
1664
|
const remoteInfo = loadedModule.remoteInfo;
|
|
1681
1665
|
const key = remoteInfo.entryGlobalName;
|
|
1682
|
-
if (globalThis[key]
|
|
1666
|
+
if (globalThis[key]) {
|
|
1683
1667
|
delete globalThis[key];
|
|
1684
1668
|
}
|
|
1685
1669
|
const remoteEntryUniqueKey = getRemoteEntryUniqueKey(loadedModule.remoteInfo);
|
|
@@ -1757,6 +1741,7 @@ class RemoteHandler {
|
|
|
1757
1741
|
afterPreloadRemote: new AsyncHook()
|
|
1758
1742
|
});
|
|
1759
1743
|
this.host = host;
|
|
1744
|
+
this.idToModuleNameMap = {};
|
|
1760
1745
|
}
|
|
1761
1746
|
}
|
|
1762
1747
|
|
|
@@ -1879,7 +1864,7 @@ class FederationHost {
|
|
|
1879
1864
|
// maybe will change, temporarily for internal use only
|
|
1880
1865
|
initContainer: new AsyncWaterfallHook('initContainer')
|
|
1881
1866
|
});
|
|
1882
|
-
this.version = "0.1.
|
|
1867
|
+
this.version = "0.1.13";
|
|
1883
1868
|
this.moduleCache = new Map();
|
|
1884
1869
|
this.loaderHook = new PluginSystem({
|
|
1885
1870
|
// FIXME: may not be suitable , not open to the public yet
|
|
@@ -1900,7 +1885,7 @@ class FederationHost {
|
|
|
1900
1885
|
],
|
|
1901
1886
|
remotes: [],
|
|
1902
1887
|
shared: {},
|
|
1903
|
-
inBrowser: isBrowserEnv
|
|
1888
|
+
inBrowser: isBrowserEnv()
|
|
1904
1889
|
};
|
|
1905
1890
|
this.name = userOptions.name;
|
|
1906
1891
|
this.options = defaultOptions;
|
|
@@ -1968,7 +1953,10 @@ function registerPlugins(...args) {
|
|
|
1968
1953
|
// eslint-disable-next-line prefer-spread
|
|
1969
1954
|
return FederationInstance.registerPlugins.apply(FederationInstance, args);
|
|
1970
1955
|
}
|
|
1956
|
+
function getInstance() {
|
|
1957
|
+
return FederationInstance;
|
|
1958
|
+
}
|
|
1971
1959
|
// Inject for debug
|
|
1972
1960
|
setGlobalFederationConstructor(FederationHost);
|
|
1973
1961
|
|
|
1974
|
-
export { FederationHost, getRemoteEntry, getRemoteInfo, init, loadRemote, loadShare, loadShareSync, preloadRemote, registerPlugins, registerRemotes };
|
|
1962
|
+
export { FederationHost, getInstance, getRemoteEntry, getRemoteInfo, init, loadRemote, loadShare, loadShareSync, preloadRemote, registerPlugins, registerRemotes };
|
package/dist/package.json
CHANGED
package/dist/share.cjs.js
CHANGED
|
@@ -76,6 +76,28 @@ function arrayOptions(options) {
|
|
|
76
76
|
options
|
|
77
77
|
];
|
|
78
78
|
}
|
|
79
|
+
function getRemoteEntryInfoFromSnapshot(snapshot) {
|
|
80
|
+
const defaultRemoteEntryInfo = {
|
|
81
|
+
url: '',
|
|
82
|
+
type: 'global',
|
|
83
|
+
globalName: ''
|
|
84
|
+
};
|
|
85
|
+
if (isBrowserEnv()) {
|
|
86
|
+
return 'remoteEntry' in snapshot ? {
|
|
87
|
+
url: snapshot.remoteEntry,
|
|
88
|
+
type: snapshot.remoteEntryType,
|
|
89
|
+
globalName: snapshot.globalName
|
|
90
|
+
} : defaultRemoteEntryInfo;
|
|
91
|
+
}
|
|
92
|
+
if ('ssrRemoteEntry' in snapshot) {
|
|
93
|
+
return {
|
|
94
|
+
url: snapshot.ssrRemoteEntry || defaultRemoteEntryInfo.url,
|
|
95
|
+
type: snapshot.ssrRemoteEntryType || defaultRemoteEntryInfo.type,
|
|
96
|
+
globalName: snapshot.globalName
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return defaultRemoteEntryInfo;
|
|
100
|
+
}
|
|
79
101
|
|
|
80
102
|
function _extends$1() {
|
|
81
103
|
_extends$1 = Object.assign || function(target) {
|
|
@@ -190,7 +212,7 @@ function getGlobalFederationConstructor() {
|
|
|
190
212
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
|
|
191
213
|
if (isDebug) {
|
|
192
214
|
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
193
|
-
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.1.
|
|
215
|
+
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.1.13";
|
|
194
216
|
}
|
|
195
217
|
}
|
|
196
218
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -893,6 +915,7 @@ exports.getInfoWithoutType = getInfoWithoutType;
|
|
|
893
915
|
exports.getPreloaded = getPreloaded;
|
|
894
916
|
exports.getRegisteredShare = getRegisteredShare;
|
|
895
917
|
exports.getRemoteEntryExports = getRemoteEntryExports;
|
|
918
|
+
exports.getRemoteEntryInfoFromSnapshot = getRemoteEntryInfoFromSnapshot;
|
|
896
919
|
exports.getTargetSharedOptions = getTargetSharedOptions;
|
|
897
920
|
exports.getTargetSnapshotInfoByModuleInfo = getTargetSnapshotInfoByModuleInfo;
|
|
898
921
|
exports.globalLoading = globalLoading;
|
package/dist/share.esm.js
CHANGED
|
@@ -74,6 +74,28 @@ function arrayOptions(options) {
|
|
|
74
74
|
options
|
|
75
75
|
];
|
|
76
76
|
}
|
|
77
|
+
function getRemoteEntryInfoFromSnapshot(snapshot) {
|
|
78
|
+
const defaultRemoteEntryInfo = {
|
|
79
|
+
url: '',
|
|
80
|
+
type: 'global',
|
|
81
|
+
globalName: ''
|
|
82
|
+
};
|
|
83
|
+
if (isBrowserEnv()) {
|
|
84
|
+
return 'remoteEntry' in snapshot ? {
|
|
85
|
+
url: snapshot.remoteEntry,
|
|
86
|
+
type: snapshot.remoteEntryType,
|
|
87
|
+
globalName: snapshot.globalName
|
|
88
|
+
} : defaultRemoteEntryInfo;
|
|
89
|
+
}
|
|
90
|
+
if ('ssrRemoteEntry' in snapshot) {
|
|
91
|
+
return {
|
|
92
|
+
url: snapshot.ssrRemoteEntry || defaultRemoteEntryInfo.url,
|
|
93
|
+
type: snapshot.ssrRemoteEntryType || defaultRemoteEntryInfo.type,
|
|
94
|
+
globalName: snapshot.globalName
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return defaultRemoteEntryInfo;
|
|
98
|
+
}
|
|
77
99
|
|
|
78
100
|
function _extends$1() {
|
|
79
101
|
_extends$1 = Object.assign || function(target) {
|
|
@@ -188,7 +210,7 @@ function getGlobalFederationConstructor() {
|
|
|
188
210
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
|
|
189
211
|
if (isDebug) {
|
|
190
212
|
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
191
|
-
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.1.
|
|
213
|
+
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.1.13";
|
|
192
214
|
}
|
|
193
215
|
}
|
|
194
216
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -870,4 +892,4 @@ function getTargetSharedOptions(options) {
|
|
|
870
892
|
return Object.assign({}, resolver(shareInfos[pkgName]), extraOptions == null ? void 0 : extraOptions.customShareInfo);
|
|
871
893
|
}
|
|
872
894
|
|
|
873
|
-
export {
|
|
895
|
+
export { getGlobalShareScope as A, addUniqueItem as B, getBuilderId as C, DEFAULT_REMOTE_TYPE as D, setGlobalFederationConstructor as E, getGlobalFederationInstance as F, Global as G, getGlobalFederationConstructor as H, setGlobalFederationInstance as I, registerGlobalPlugins as J, nativeGlobal as K, resetFederationGlobalInfo as L, getTargetSnapshotInfoByModuleInfo as M, globalLoading as a, DEFAULT_SCOPE as b, getRemoteEntryExports as c, assert as d, getFMId as e, error as f, getGlobalHostPlugins as g, isPlainObject as h, isObject as i, isRemoteInfoWithEntry as j, isPureRemoteEntry as k, getRemoteEntryInfoFromSnapshot as l, isBrowserEnv as m, getInfoWithoutType as n, getPreloaded as o, setPreloaded as p, getRegisteredShare as q, arrayOptions as r, safeToString as s, getGlobalSnapshotInfoByModuleInfo as t, addGlobalSnapshot as u, setGlobalSnapshotInfoByModuleInfo as v, warn as w, getGlobalSnapshot as x, formatShareConfigs as y, getTargetSharedOptions as z };
|
package/dist/src/core.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { CreateScriptHookReturn } from '@module-federation/sdk';
|
|
2
1
|
import { Options, PreloadRemoteArgs, RemoteEntryExports, Remote, Shared, ShareInfos, UserOptions, RemoteInfo, ShareScopeMap, InitScope, RemoteEntryInitOptions } from './type';
|
|
3
2
|
import { Module } from './module';
|
|
4
3
|
import { AsyncHook, AsyncWaterfallHook, PluginSystem, SyncHook, SyncWaterfallHook } from './utils/hooks';
|
|
@@ -51,7 +50,7 @@ export declare class FederationHost {
|
|
|
51
50
|
}>;
|
|
52
51
|
createScript: SyncHook<[{
|
|
53
52
|
url: string;
|
|
54
|
-
}],
|
|
53
|
+
}], void | HTMLScriptElement>;
|
|
55
54
|
createLink: SyncHook<[{
|
|
56
55
|
url: string;
|
|
57
56
|
}], void | HTMLLinkElement>;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -13,3 +13,4 @@ export declare function loadShareSync<T>(...args: Parameters<FederationHost['loa
|
|
|
13
13
|
export declare function preloadRemote(...args: Parameters<FederationHost['preloadRemote']>): ReturnType<FederationHost['preloadRemote']>;
|
|
14
14
|
export declare function registerRemotes(...args: Parameters<FederationHost['registerRemotes']>): ReturnType<FederationHost['registerRemotes']>;
|
|
15
15
|
export declare function registerPlugins(...args: Parameters<FederationHost['registerPlugins']>): ReturnType<FederationHost['registerRemotes']>;
|
|
16
|
+
export declare function getInstance(): FederationHost | null;
|
|
@@ -39,6 +39,10 @@ export declare class SnapshotHandler {
|
|
|
39
39
|
remoteSnapshot: ModuleInfo;
|
|
40
40
|
globalSnapshot: GlobalModuleInfo;
|
|
41
41
|
}> | never;
|
|
42
|
-
|
|
42
|
+
getGlobalRemoteInfo(moduleInfo: Remote): {
|
|
43
|
+
hostGlobalSnapshot: ModuleInfo | undefined;
|
|
44
|
+
globalSnapshot: ReturnType<typeof getGlobalSnapshot>;
|
|
45
|
+
remoteSnapshot: GlobalModuleInfo[string] | undefined;
|
|
46
|
+
};
|
|
43
47
|
private getManifestJson;
|
|
44
48
|
}
|
package/dist/src/utils/load.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { CreateScriptHookReturn } from '@module-federation/sdk';
|
|
2
1
|
import { Remote, RemoteEntryExports, RemoteInfo } from '../type';
|
|
3
2
|
export declare function loadEsmEntry({ entry, remoteEntryExports, }: {
|
|
4
3
|
entry: string;
|
|
@@ -8,12 +7,12 @@ export declare function loadEntryScript({ name, globalName, entry, createScriptH
|
|
|
8
7
|
name: string;
|
|
9
8
|
globalName: string;
|
|
10
9
|
entry: string;
|
|
11
|
-
createScriptHook?: (url: string) =>
|
|
10
|
+
createScriptHook?: (url: string) => HTMLScriptElement | void;
|
|
12
11
|
}): Promise<RemoteEntryExports>;
|
|
13
12
|
export declare function getRemoteEntryUniqueKey(remoteInfo: RemoteInfo): string;
|
|
14
13
|
export declare function getRemoteEntry({ remoteEntryExports, remoteInfo, createScriptHook, }: {
|
|
15
14
|
remoteInfo: RemoteInfo;
|
|
16
15
|
remoteEntryExports?: RemoteEntryExports | undefined;
|
|
17
|
-
createScriptHook?: (url: string) =>
|
|
16
|
+
createScriptHook?: (url: string) => HTMLScriptElement | void;
|
|
18
17
|
}): Promise<RemoteEntryExports | void>;
|
|
19
18
|
export declare function getRemoteInfo(remote: Remote): RemoteInfo;
|
package/dist/src/utils/tool.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RemoteWithEntry } from '@module-federation/sdk';
|
|
1
|
+
import type { RemoteWithEntry, ModuleInfo, RemoteEntryType } from '@module-federation/sdk';
|
|
2
2
|
import { Remote, RemoteInfoOptionalVersion } from '../type';
|
|
3
3
|
export declare function addUniqueItem(arr: Array<string>, item: string): Array<string>;
|
|
4
4
|
export declare function getFMId(remoteInfo: RemoteInfoOptionalVersion | RemoteWithEntry): string;
|
|
@@ -11,3 +11,8 @@ export declare const objectToString: () => string;
|
|
|
11
11
|
export declare function isPlainObject(val: any): val is object;
|
|
12
12
|
export declare function isStaticResourcesEqual(url1: string, url2: string): boolean;
|
|
13
13
|
export declare function arrayOptions<T>(options: T | Array<T>): Array<T>;
|
|
14
|
+
export declare function getRemoteEntryInfoFromSnapshot(snapshot: ModuleInfo): {
|
|
15
|
+
url: string;
|
|
16
|
+
type: RemoteEntryType;
|
|
17
|
+
globalName: string;
|
|
18
|
+
};
|
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-20240521123600",
|
|
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-20240521123600"
|
|
49
49
|
}
|
|
50
50
|
}
|