@module-federation/runtime-core 0.14.3 → 0.16.0
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/README.md +1 -1
- package/dist/index.cjs.cjs +88 -42
- package/dist/index.esm.js +88 -42
- package/dist/src/plugins/snapshot/SnapshotHandler.d.ts +7 -5
- package/dist/src/type/config.d.ts +1 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
## Documentation
|
|
8
8
|
|
|
9
|
-
See [https://module-federation.io/guide/basic/runtime.html](https://module-federation.io/guide/basic/runtime.html) for details.
|
|
9
|
+
See [https://module-federation.io/guide/basic/runtime/runtime.html](https://module-federation.io/guide/basic/runtime/runtime.html) for details.
|
|
10
10
|
|
|
11
11
|
## License
|
|
12
12
|
|
package/dist/index.cjs.cjs
CHANGED
|
@@ -196,7 +196,7 @@ function getGlobalFederationConstructor() {
|
|
|
196
196
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = sdk.isDebugMode()) {
|
|
197
197
|
if (isDebug) {
|
|
198
198
|
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
199
|
-
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.
|
|
199
|
+
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.16.0";
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -639,40 +639,93 @@ function satisfy(version, range) {
|
|
|
639
639
|
if (!version) {
|
|
640
640
|
return false;
|
|
641
641
|
}
|
|
642
|
-
|
|
643
|
-
const parsedComparator = parsedRange.split(' ').map((rangeVersion)=>parseComparatorString(rangeVersion)).join(' ');
|
|
644
|
-
const comparators = parsedComparator.split(/\s+/).map((comparator)=>parseGTE0(comparator));
|
|
642
|
+
// Extract version details once
|
|
645
643
|
const extractedVersion = extractComparator(version);
|
|
646
644
|
if (!extractedVersion) {
|
|
645
|
+
// If the version string is invalid, it can't satisfy any range
|
|
647
646
|
return false;
|
|
648
647
|
}
|
|
649
648
|
const [, versionOperator, , versionMajor, versionMinor, versionPatch, versionPreRelease] = extractedVersion;
|
|
650
649
|
const versionAtom = {
|
|
650
|
+
operator: versionOperator,
|
|
651
651
|
version: combineVersion(versionMajor, versionMinor, versionPatch, versionPreRelease),
|
|
652
652
|
major: versionMajor,
|
|
653
653
|
minor: versionMinor,
|
|
654
654
|
patch: versionPatch,
|
|
655
655
|
preRelease: versionPreRelease == null ? void 0 : versionPreRelease.split('.')
|
|
656
656
|
};
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
657
|
+
// Split the range by || to handle OR conditions
|
|
658
|
+
const orRanges = range.split('||');
|
|
659
|
+
for (const orRange of orRanges){
|
|
660
|
+
const trimmedOrRange = orRange.trim();
|
|
661
|
+
if (!trimmedOrRange) {
|
|
662
|
+
// An empty range string signifies wildcard *, satisfy any valid version
|
|
663
|
+
// (We already checked if the version itself is valid)
|
|
664
|
+
return true;
|
|
665
|
+
}
|
|
666
|
+
// Handle simple wildcards explicitly before complex parsing
|
|
667
|
+
if (trimmedOrRange === '*' || trimmedOrRange === 'x') {
|
|
668
|
+
return true;
|
|
661
669
|
}
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
670
|
+
try {
|
|
671
|
+
// Apply existing parsing logic to the current OR sub-range
|
|
672
|
+
const parsedSubRange = parseRange(trimmedOrRange); // Handles hyphens, trims etc.
|
|
673
|
+
// Check if the result of initial parsing is empty, which can happen
|
|
674
|
+
// for some wildcard cases handled by parseRange/parseComparatorString.
|
|
675
|
+
// E.g. `parseStar` used in `parseComparatorString` returns ''.
|
|
676
|
+
if (!parsedSubRange.trim()) {
|
|
677
|
+
// If parsing results in empty string, treat as wildcard match
|
|
678
|
+
return true;
|
|
679
|
+
}
|
|
680
|
+
const parsedComparatorString = parsedSubRange.split(' ').map((rangeVersion)=>parseComparatorString(rangeVersion)) // Expands ^, ~
|
|
681
|
+
.join(' ');
|
|
682
|
+
// Check again if the comparator string became empty after specific parsing like ^ or ~
|
|
683
|
+
if (!parsedComparatorString.trim()) {
|
|
684
|
+
return true;
|
|
685
|
+
}
|
|
686
|
+
// Split the sub-range by space for implicit AND conditions
|
|
687
|
+
const comparators = parsedComparatorString.split(/\s+/).map((comparator)=>parseGTE0(comparator))// Filter out empty strings that might result from multiple spaces
|
|
688
|
+
.filter(Boolean);
|
|
689
|
+
// If a sub-range becomes empty after parsing (e.g., invalid characters),
|
|
690
|
+
// it cannot be satisfied. This check might be redundant now but kept for safety.
|
|
691
|
+
if (comparators.length === 0) {
|
|
692
|
+
continue;
|
|
693
|
+
}
|
|
694
|
+
let subRangeSatisfied = true;
|
|
695
|
+
for (const comparator of comparators){
|
|
696
|
+
const extractedComparator = extractComparator(comparator);
|
|
697
|
+
// If any part of the AND sub-range is invalid, the sub-range is not satisfied
|
|
698
|
+
if (!extractedComparator) {
|
|
699
|
+
subRangeSatisfied = false;
|
|
700
|
+
break;
|
|
701
|
+
}
|
|
702
|
+
const [, rangeOperator, , rangeMajor, rangeMinor, rangePatch, rangePreRelease] = extractedComparator;
|
|
703
|
+
const rangeAtom = {
|
|
704
|
+
operator: rangeOperator,
|
|
705
|
+
version: combineVersion(rangeMajor, rangeMinor, rangePatch, rangePreRelease),
|
|
706
|
+
major: rangeMajor,
|
|
707
|
+
minor: rangeMinor,
|
|
708
|
+
patch: rangePatch,
|
|
709
|
+
preRelease: rangePreRelease == null ? void 0 : rangePreRelease.split('.')
|
|
710
|
+
};
|
|
711
|
+
// Check if the version satisfies this specific comparator in the AND chain
|
|
712
|
+
if (!compare(rangeAtom, versionAtom)) {
|
|
713
|
+
subRangeSatisfied = false; // This part of the AND condition failed
|
|
714
|
+
break; // No need to check further comparators in this sub-range
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
// If all AND conditions within this OR sub-range were met, the overall range is satisfied
|
|
718
|
+
if (subRangeSatisfied) {
|
|
719
|
+
return true;
|
|
720
|
+
}
|
|
721
|
+
} catch (e) {
|
|
722
|
+
// Log error and treat this sub-range as unsatisfied
|
|
723
|
+
console.error(`[semver] Error processing range part "${trimmedOrRange}":`, e);
|
|
724
|
+
continue;
|
|
673
725
|
}
|
|
674
726
|
}
|
|
675
|
-
|
|
727
|
+
// If none of the OR sub-ranges were satisfied
|
|
728
|
+
return false;
|
|
676
729
|
}
|
|
677
730
|
|
|
678
731
|
function formatShare(shareArgs, from, name, shareStrategy) {
|
|
@@ -1257,7 +1310,8 @@ let Module = class Module {
|
|
|
1257
1310
|
});
|
|
1258
1311
|
if (typeof (remoteEntryExports == null ? void 0 : remoteEntryExports.init) === 'undefined') {
|
|
1259
1312
|
error(errorCodes.getShortErrorMsg(errorCodes.RUNTIME_002, errorCodes.runtimeDescMap, {
|
|
1260
|
-
|
|
1313
|
+
hostName: this.host.name,
|
|
1314
|
+
remoteName: this.remoteInfo.name,
|
|
1261
1315
|
remoteEntryUrl: this.remoteInfo.entry,
|
|
1262
1316
|
remoteEntryKey: this.remoteInfo.entryGlobalName
|
|
1263
1317
|
}));
|
|
@@ -1691,9 +1745,12 @@ function snapshotPlugin() {
|
|
|
1691
1745
|
return {
|
|
1692
1746
|
name: 'snapshot-plugin',
|
|
1693
1747
|
async afterResolve (args) {
|
|
1694
|
-
const { remote, pkgNameOrAlias, expose, origin, remoteInfo } = args;
|
|
1748
|
+
const { remote, pkgNameOrAlias, expose, origin, remoteInfo, id } = args;
|
|
1695
1749
|
if (!isRemoteInfoWithEntry(remote) || !isPureRemoteEntry(remote)) {
|
|
1696
|
-
const { remoteSnapshot, globalSnapshot } = await origin.snapshotHandler.loadRemoteSnapshotInfo(
|
|
1750
|
+
const { remoteSnapshot, globalSnapshot } = await origin.snapshotHandler.loadRemoteSnapshotInfo({
|
|
1751
|
+
moduleInfo: remote,
|
|
1752
|
+
id
|
|
1753
|
+
});
|
|
1697
1754
|
assignRemoteInfo(remoteInfo, remoteSnapshot);
|
|
1698
1755
|
// preloading assets
|
|
1699
1756
|
const preloadOptions = {
|
|
@@ -1952,7 +2009,7 @@ const generatePreloadAssetsPlugin = function() {
|
|
|
1952
2009
|
|
|
1953
2010
|
function getGlobalRemoteInfo(moduleInfo, origin) {
|
|
1954
2011
|
const hostGlobalSnapshot = getGlobalSnapshotInfoByModuleInfo({
|
|
1955
|
-
name: origin.
|
|
2012
|
+
name: origin.name,
|
|
1956
2013
|
version: origin.options.version
|
|
1957
2014
|
});
|
|
1958
2015
|
// get remote detail info from global
|
|
@@ -1977,23 +2034,8 @@ function getGlobalRemoteInfo(moduleInfo, origin) {
|
|
|
1977
2034
|
};
|
|
1978
2035
|
}
|
|
1979
2036
|
class SnapshotHandler {
|
|
1980
|
-
async loadSnapshot(moduleInfo) {
|
|
1981
|
-
const { options } = this.HostInstance;
|
|
1982
|
-
const { hostGlobalSnapshot, remoteSnapshot, globalSnapshot } = this.getGlobalRemoteInfo(moduleInfo);
|
|
1983
|
-
const { remoteSnapshot: globalRemoteSnapshot, globalSnapshot: globalSnapshotRes } = await this.hooks.lifecycle.loadSnapshot.emit({
|
|
1984
|
-
options,
|
|
1985
|
-
moduleInfo,
|
|
1986
|
-
hostGlobalSnapshot,
|
|
1987
|
-
remoteSnapshot,
|
|
1988
|
-
globalSnapshot
|
|
1989
|
-
});
|
|
1990
|
-
return {
|
|
1991
|
-
remoteSnapshot: globalRemoteSnapshot,
|
|
1992
|
-
globalSnapshot: globalSnapshotRes
|
|
1993
|
-
};
|
|
1994
|
-
}
|
|
1995
2037
|
// eslint-disable-next-line max-lines-per-function
|
|
1996
|
-
async loadRemoteSnapshotInfo(moduleInfo) {
|
|
2038
|
+
async loadRemoteSnapshotInfo({ moduleInfo, id, expose }) {
|
|
1997
2039
|
const { options } = this.HostInstance;
|
|
1998
2040
|
await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({
|
|
1999
2041
|
options,
|
|
@@ -2080,6 +2122,8 @@ class SnapshotHandler {
|
|
|
2080
2122
|
}
|
|
2081
2123
|
}
|
|
2082
2124
|
await this.hooks.lifecycle.afterLoadSnapshot.emit({
|
|
2125
|
+
id,
|
|
2126
|
+
host: this.HostInstance,
|
|
2083
2127
|
options,
|
|
2084
2128
|
moduleInfo,
|
|
2085
2129
|
remoteSnapshot: mSnapshot
|
|
@@ -2617,7 +2661,9 @@ class RemoteHandler {
|
|
|
2617
2661
|
await Promise.all(preloadOps.map(async (ops)=>{
|
|
2618
2662
|
const { remote } = ops;
|
|
2619
2663
|
const remoteInfo = getRemoteInfo(remote);
|
|
2620
|
-
const { globalSnapshot, remoteSnapshot } = await host.snapshotHandler.loadRemoteSnapshotInfo(
|
|
2664
|
+
const { globalSnapshot, remoteSnapshot } = await host.snapshotHandler.loadRemoteSnapshotInfo({
|
|
2665
|
+
moduleInfo: remote
|
|
2666
|
+
});
|
|
2621
2667
|
const assets = await this.hooks.lifecycle.generatePreloadAssets.emit({
|
|
2622
2668
|
origin: host,
|
|
2623
2669
|
preloadOptions: ops,
|
|
@@ -2978,7 +3024,7 @@ class FederationHost {
|
|
|
2978
3024
|
// maybe will change, temporarily for internal use only
|
|
2979
3025
|
initContainer: new AsyncWaterfallHook('initContainer')
|
|
2980
3026
|
});
|
|
2981
|
-
this.version = "0.
|
|
3027
|
+
this.version = "0.16.0";
|
|
2982
3028
|
this.moduleCache = new Map();
|
|
2983
3029
|
this.loaderHook = new PluginSystem({
|
|
2984
3030
|
// FIXME: may not be suitable , not open to the public yet
|
package/dist/index.esm.js
CHANGED
|
@@ -195,7 +195,7 @@ function getGlobalFederationConstructor() {
|
|
|
195
195
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
|
|
196
196
|
if (isDebug) {
|
|
197
197
|
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
198
|
-
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.
|
|
198
|
+
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.16.0";
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -638,40 +638,93 @@ function satisfy(version, range) {
|
|
|
638
638
|
if (!version) {
|
|
639
639
|
return false;
|
|
640
640
|
}
|
|
641
|
-
|
|
642
|
-
const parsedComparator = parsedRange.split(' ').map((rangeVersion)=>parseComparatorString(rangeVersion)).join(' ');
|
|
643
|
-
const comparators = parsedComparator.split(/\s+/).map((comparator)=>parseGTE0(comparator));
|
|
641
|
+
// Extract version details once
|
|
644
642
|
const extractedVersion = extractComparator(version);
|
|
645
643
|
if (!extractedVersion) {
|
|
644
|
+
// If the version string is invalid, it can't satisfy any range
|
|
646
645
|
return false;
|
|
647
646
|
}
|
|
648
647
|
const [, versionOperator, , versionMajor, versionMinor, versionPatch, versionPreRelease] = extractedVersion;
|
|
649
648
|
const versionAtom = {
|
|
649
|
+
operator: versionOperator,
|
|
650
650
|
version: combineVersion(versionMajor, versionMinor, versionPatch, versionPreRelease),
|
|
651
651
|
major: versionMajor,
|
|
652
652
|
minor: versionMinor,
|
|
653
653
|
patch: versionPatch,
|
|
654
654
|
preRelease: versionPreRelease == null ? void 0 : versionPreRelease.split('.')
|
|
655
655
|
};
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
656
|
+
// Split the range by || to handle OR conditions
|
|
657
|
+
const orRanges = range.split('||');
|
|
658
|
+
for (const orRange of orRanges){
|
|
659
|
+
const trimmedOrRange = orRange.trim();
|
|
660
|
+
if (!trimmedOrRange) {
|
|
661
|
+
// An empty range string signifies wildcard *, satisfy any valid version
|
|
662
|
+
// (We already checked if the version itself is valid)
|
|
663
|
+
return true;
|
|
664
|
+
}
|
|
665
|
+
// Handle simple wildcards explicitly before complex parsing
|
|
666
|
+
if (trimmedOrRange === '*' || trimmedOrRange === 'x') {
|
|
667
|
+
return true;
|
|
660
668
|
}
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
669
|
+
try {
|
|
670
|
+
// Apply existing parsing logic to the current OR sub-range
|
|
671
|
+
const parsedSubRange = parseRange(trimmedOrRange); // Handles hyphens, trims etc.
|
|
672
|
+
// Check if the result of initial parsing is empty, which can happen
|
|
673
|
+
// for some wildcard cases handled by parseRange/parseComparatorString.
|
|
674
|
+
// E.g. `parseStar` used in `parseComparatorString` returns ''.
|
|
675
|
+
if (!parsedSubRange.trim()) {
|
|
676
|
+
// If parsing results in empty string, treat as wildcard match
|
|
677
|
+
return true;
|
|
678
|
+
}
|
|
679
|
+
const parsedComparatorString = parsedSubRange.split(' ').map((rangeVersion)=>parseComparatorString(rangeVersion)) // Expands ^, ~
|
|
680
|
+
.join(' ');
|
|
681
|
+
// Check again if the comparator string became empty after specific parsing like ^ or ~
|
|
682
|
+
if (!parsedComparatorString.trim()) {
|
|
683
|
+
return true;
|
|
684
|
+
}
|
|
685
|
+
// Split the sub-range by space for implicit AND conditions
|
|
686
|
+
const comparators = parsedComparatorString.split(/\s+/).map((comparator)=>parseGTE0(comparator))// Filter out empty strings that might result from multiple spaces
|
|
687
|
+
.filter(Boolean);
|
|
688
|
+
// If a sub-range becomes empty after parsing (e.g., invalid characters),
|
|
689
|
+
// it cannot be satisfied. This check might be redundant now but kept for safety.
|
|
690
|
+
if (comparators.length === 0) {
|
|
691
|
+
continue;
|
|
692
|
+
}
|
|
693
|
+
let subRangeSatisfied = true;
|
|
694
|
+
for (const comparator of comparators){
|
|
695
|
+
const extractedComparator = extractComparator(comparator);
|
|
696
|
+
// If any part of the AND sub-range is invalid, the sub-range is not satisfied
|
|
697
|
+
if (!extractedComparator) {
|
|
698
|
+
subRangeSatisfied = false;
|
|
699
|
+
break;
|
|
700
|
+
}
|
|
701
|
+
const [, rangeOperator, , rangeMajor, rangeMinor, rangePatch, rangePreRelease] = extractedComparator;
|
|
702
|
+
const rangeAtom = {
|
|
703
|
+
operator: rangeOperator,
|
|
704
|
+
version: combineVersion(rangeMajor, rangeMinor, rangePatch, rangePreRelease),
|
|
705
|
+
major: rangeMajor,
|
|
706
|
+
minor: rangeMinor,
|
|
707
|
+
patch: rangePatch,
|
|
708
|
+
preRelease: rangePreRelease == null ? void 0 : rangePreRelease.split('.')
|
|
709
|
+
};
|
|
710
|
+
// Check if the version satisfies this specific comparator in the AND chain
|
|
711
|
+
if (!compare(rangeAtom, versionAtom)) {
|
|
712
|
+
subRangeSatisfied = false; // This part of the AND condition failed
|
|
713
|
+
break; // No need to check further comparators in this sub-range
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
// If all AND conditions within this OR sub-range were met, the overall range is satisfied
|
|
717
|
+
if (subRangeSatisfied) {
|
|
718
|
+
return true;
|
|
719
|
+
}
|
|
720
|
+
} catch (e) {
|
|
721
|
+
// Log error and treat this sub-range as unsatisfied
|
|
722
|
+
console.error(`[semver] Error processing range part "${trimmedOrRange}":`, e);
|
|
723
|
+
continue;
|
|
672
724
|
}
|
|
673
725
|
}
|
|
674
|
-
|
|
726
|
+
// If none of the OR sub-ranges were satisfied
|
|
727
|
+
return false;
|
|
675
728
|
}
|
|
676
729
|
|
|
677
730
|
function formatShare(shareArgs, from, name, shareStrategy) {
|
|
@@ -1256,7 +1309,8 @@ let Module = class Module {
|
|
|
1256
1309
|
});
|
|
1257
1310
|
if (typeof (remoteEntryExports == null ? void 0 : remoteEntryExports.init) === 'undefined') {
|
|
1258
1311
|
error(getShortErrorMsg(RUNTIME_002, runtimeDescMap, {
|
|
1259
|
-
|
|
1312
|
+
hostName: this.host.name,
|
|
1313
|
+
remoteName: this.remoteInfo.name,
|
|
1260
1314
|
remoteEntryUrl: this.remoteInfo.entry,
|
|
1261
1315
|
remoteEntryKey: this.remoteInfo.entryGlobalName
|
|
1262
1316
|
}));
|
|
@@ -1690,9 +1744,12 @@ function snapshotPlugin() {
|
|
|
1690
1744
|
return {
|
|
1691
1745
|
name: 'snapshot-plugin',
|
|
1692
1746
|
async afterResolve (args) {
|
|
1693
|
-
const { remote, pkgNameOrAlias, expose, origin, remoteInfo } = args;
|
|
1747
|
+
const { remote, pkgNameOrAlias, expose, origin, remoteInfo, id } = args;
|
|
1694
1748
|
if (!isRemoteInfoWithEntry(remote) || !isPureRemoteEntry(remote)) {
|
|
1695
|
-
const { remoteSnapshot, globalSnapshot } = await origin.snapshotHandler.loadRemoteSnapshotInfo(
|
|
1749
|
+
const { remoteSnapshot, globalSnapshot } = await origin.snapshotHandler.loadRemoteSnapshotInfo({
|
|
1750
|
+
moduleInfo: remote,
|
|
1751
|
+
id
|
|
1752
|
+
});
|
|
1696
1753
|
assignRemoteInfo(remoteInfo, remoteSnapshot);
|
|
1697
1754
|
// preloading assets
|
|
1698
1755
|
const preloadOptions = {
|
|
@@ -1951,7 +2008,7 @@ const generatePreloadAssetsPlugin = function() {
|
|
|
1951
2008
|
|
|
1952
2009
|
function getGlobalRemoteInfo(moduleInfo, origin) {
|
|
1953
2010
|
const hostGlobalSnapshot = getGlobalSnapshotInfoByModuleInfo({
|
|
1954
|
-
name: origin.
|
|
2011
|
+
name: origin.name,
|
|
1955
2012
|
version: origin.options.version
|
|
1956
2013
|
});
|
|
1957
2014
|
// get remote detail info from global
|
|
@@ -1976,23 +2033,8 @@ function getGlobalRemoteInfo(moduleInfo, origin) {
|
|
|
1976
2033
|
};
|
|
1977
2034
|
}
|
|
1978
2035
|
class SnapshotHandler {
|
|
1979
|
-
async loadSnapshot(moduleInfo) {
|
|
1980
|
-
const { options } = this.HostInstance;
|
|
1981
|
-
const { hostGlobalSnapshot, remoteSnapshot, globalSnapshot } = this.getGlobalRemoteInfo(moduleInfo);
|
|
1982
|
-
const { remoteSnapshot: globalRemoteSnapshot, globalSnapshot: globalSnapshotRes } = await this.hooks.lifecycle.loadSnapshot.emit({
|
|
1983
|
-
options,
|
|
1984
|
-
moduleInfo,
|
|
1985
|
-
hostGlobalSnapshot,
|
|
1986
|
-
remoteSnapshot,
|
|
1987
|
-
globalSnapshot
|
|
1988
|
-
});
|
|
1989
|
-
return {
|
|
1990
|
-
remoteSnapshot: globalRemoteSnapshot,
|
|
1991
|
-
globalSnapshot: globalSnapshotRes
|
|
1992
|
-
};
|
|
1993
|
-
}
|
|
1994
2036
|
// eslint-disable-next-line max-lines-per-function
|
|
1995
|
-
async loadRemoteSnapshotInfo(moduleInfo) {
|
|
2037
|
+
async loadRemoteSnapshotInfo({ moduleInfo, id, expose }) {
|
|
1996
2038
|
const { options } = this.HostInstance;
|
|
1997
2039
|
await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({
|
|
1998
2040
|
options,
|
|
@@ -2079,6 +2121,8 @@ class SnapshotHandler {
|
|
|
2079
2121
|
}
|
|
2080
2122
|
}
|
|
2081
2123
|
await this.hooks.lifecycle.afterLoadSnapshot.emit({
|
|
2124
|
+
id,
|
|
2125
|
+
host: this.HostInstance,
|
|
2082
2126
|
options,
|
|
2083
2127
|
moduleInfo,
|
|
2084
2128
|
remoteSnapshot: mSnapshot
|
|
@@ -2616,7 +2660,9 @@ class RemoteHandler {
|
|
|
2616
2660
|
await Promise.all(preloadOps.map(async (ops)=>{
|
|
2617
2661
|
const { remote } = ops;
|
|
2618
2662
|
const remoteInfo = getRemoteInfo(remote);
|
|
2619
|
-
const { globalSnapshot, remoteSnapshot } = await host.snapshotHandler.loadRemoteSnapshotInfo(
|
|
2663
|
+
const { globalSnapshot, remoteSnapshot } = await host.snapshotHandler.loadRemoteSnapshotInfo({
|
|
2664
|
+
moduleInfo: remote
|
|
2665
|
+
});
|
|
2620
2666
|
const assets = await this.hooks.lifecycle.generatePreloadAssets.emit({
|
|
2621
2667
|
origin: host,
|
|
2622
2668
|
preloadOptions: ops,
|
|
@@ -2977,7 +3023,7 @@ class FederationHost {
|
|
|
2977
3023
|
// maybe will change, temporarily for internal use only
|
|
2978
3024
|
initContainer: new AsyncWaterfallHook('initContainer')
|
|
2979
3025
|
});
|
|
2980
|
-
this.version = "0.
|
|
3026
|
+
this.version = "0.16.0";
|
|
2981
3027
|
this.moduleCache = new Map();
|
|
2982
3028
|
this.loaderHook = new PluginSystem({
|
|
2983
3029
|
// FIXME: may not be suitable , not open to the public yet
|
|
@@ -33,6 +33,8 @@ export declare class SnapshotHandler {
|
|
|
33
33
|
from: "global" | "manifest";
|
|
34
34
|
}>;
|
|
35
35
|
afterLoadSnapshot: AsyncWaterfallHook<{
|
|
36
|
+
id?: string;
|
|
37
|
+
host: FederationHost;
|
|
36
38
|
options: Options;
|
|
37
39
|
moduleInfo: Remote;
|
|
38
40
|
remoteSnapshot: ModuleInfo;
|
|
@@ -41,11 +43,11 @@ export declare class SnapshotHandler {
|
|
|
41
43
|
loaderHook: FederationHost['loaderHook'];
|
|
42
44
|
manifestLoading: Record<string, Promise<ModuleInfo>>;
|
|
43
45
|
constructor(HostInstance: FederationHost);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
loadRemoteSnapshotInfo({ moduleInfo, id, expose, }: {
|
|
47
|
+
moduleInfo: Remote;
|
|
48
|
+
id?: string;
|
|
49
|
+
expose?: string;
|
|
50
|
+
}): Promise<{
|
|
49
51
|
remoteSnapshot: ModuleInfo;
|
|
50
52
|
globalSnapshot: GlobalModuleInfo;
|
|
51
53
|
}> | never;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/runtime-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
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.
|
|
56
|
-
"@module-federation/error-codes": "0.
|
|
55
|
+
"@module-federation/sdk": "0.16.0",
|
|
56
|
+
"@module-federation/error-codes": "0.16.0"
|
|
57
57
|
}
|
|
58
58
|
}
|