@module-federation/runtime 0.0.0-next-20240510094642 → 0.0.0-next-20240511031741
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 +10 -25
- package/dist/index.esm.js +10 -25
- package/dist/package.json +1 -1
- package/dist/share.cjs.js +22 -6
- package/dist/share.esm.js +22 -6
- package/dist/src/shared/index.d.ts +2 -3
- package/dist/src/utils/share.d.ts +7 -2
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -1112,28 +1112,9 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
1112
1112
|
return target;
|
|
1113
1113
|
}
|
|
1114
1114
|
class SharedHandler {
|
|
1115
|
-
formatShareConfigs(globalOptions, userOptions) {
|
|
1116
|
-
const shareInfos = share.formatShareConfigs(userOptions.shared || {}, userOptions.name);
|
|
1117
|
-
const shared = _extends$2({}, globalOptions.shared);
|
|
1118
|
-
Object.keys(shareInfos).forEach((shareKey)=>{
|
|
1119
|
-
if (!shared[shareKey]) {
|
|
1120
|
-
shared[shareKey] = shareInfos[shareKey];
|
|
1121
|
-
} else {
|
|
1122
|
-
shareInfos[shareKey].forEach((newUserSharedOptions)=>{
|
|
1123
|
-
const isSameVersion = shared[shareKey].find((sharedVal)=>sharedVal.version === newUserSharedOptions.version);
|
|
1124
|
-
if (!isSameVersion) {
|
|
1125
|
-
shared[shareKey].push(newUserSharedOptions);
|
|
1126
|
-
}
|
|
1127
|
-
});
|
|
1128
|
-
}
|
|
1129
|
-
});
|
|
1130
|
-
return {
|
|
1131
|
-
shared,
|
|
1132
|
-
shareInfos
|
|
1133
|
-
};
|
|
1134
|
-
}
|
|
1135
1115
|
// register shared in shareScopeMap
|
|
1136
|
-
registerShared(
|
|
1116
|
+
registerShared(globalOptions, userOptions) {
|
|
1117
|
+
const { shareInfos, shared } = share.formatShareConfigs(globalOptions, userOptions);
|
|
1137
1118
|
const sharedKeys = Object.keys(shareInfos);
|
|
1138
1119
|
sharedKeys.forEach((sharedKey)=>{
|
|
1139
1120
|
const sharedVals = shareInfos[sharedKey];
|
|
@@ -1151,6 +1132,10 @@ class SharedHandler {
|
|
|
1151
1132
|
}
|
|
1152
1133
|
});
|
|
1153
1134
|
});
|
|
1135
|
+
return {
|
|
1136
|
+
shareInfos,
|
|
1137
|
+
shared
|
|
1138
|
+
};
|
|
1154
1139
|
}
|
|
1155
1140
|
async loadShare(pkgName, extraOptions) {
|
|
1156
1141
|
const { host } = this;
|
|
@@ -1759,7 +1744,7 @@ class FederationHost {
|
|
|
1759
1744
|
this.sharedHandler.initShareScopeMap(scopeName, shareScope);
|
|
1760
1745
|
}
|
|
1761
1746
|
formatOptions(globalOptions, userOptions) {
|
|
1762
|
-
const { shared
|
|
1747
|
+
const { shared } = share.formatShareConfigs(globalOptions, userOptions);
|
|
1763
1748
|
const { userOptions: userOptionsRes, options: globalOptionsRes } = this.hooks.lifecycle.beforeInit.emit({
|
|
1764
1749
|
origin: this,
|
|
1765
1750
|
userOptions,
|
|
@@ -1767,7 +1752,7 @@ class FederationHost {
|
|
|
1767
1752
|
shareInfo: shared
|
|
1768
1753
|
});
|
|
1769
1754
|
const remotes = this.remoteHandler.formatAndRegisterRemote(globalOptionsRes, userOptionsRes);
|
|
1770
|
-
this.sharedHandler.registerShared(
|
|
1755
|
+
const { shared: handledShared } = this.sharedHandler.registerShared(globalOptionsRes, userOptionsRes);
|
|
1771
1756
|
const plugins = [
|
|
1772
1757
|
...globalOptionsRes.plugins
|
|
1773
1758
|
];
|
|
@@ -1781,7 +1766,7 @@ class FederationHost {
|
|
|
1781
1766
|
const optionsRes = _extends({}, globalOptions, userOptions, {
|
|
1782
1767
|
plugins,
|
|
1783
1768
|
remotes,
|
|
1784
|
-
shared
|
|
1769
|
+
shared: handledShared
|
|
1785
1770
|
});
|
|
1786
1771
|
this.hooks.lifecycle.init.emit({
|
|
1787
1772
|
origin: this,
|
|
@@ -1818,7 +1803,7 @@ class FederationHost {
|
|
|
1818
1803
|
// maybe will change, temporarily for internal use only
|
|
1819
1804
|
initContainer: new AsyncWaterfallHook('initContainer')
|
|
1820
1805
|
});
|
|
1821
|
-
this.version = "0.1.
|
|
1806
|
+
this.version = "0.1.12";
|
|
1822
1807
|
this.moduleCache = new Map();
|
|
1823
1808
|
this.loaderHook = new PluginSystem({
|
|
1824
1809
|
// FIXME: may not be suitable , not open to the public yet
|
package/dist/index.esm.js
CHANGED
|
@@ -1110,28 +1110,9 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
1110
1110
|
return target;
|
|
1111
1111
|
}
|
|
1112
1112
|
class SharedHandler {
|
|
1113
|
-
formatShareConfigs(globalOptions, userOptions) {
|
|
1114
|
-
const shareInfos = formatShareConfigs(userOptions.shared || {}, userOptions.name);
|
|
1115
|
-
const shared = _extends$2({}, globalOptions.shared);
|
|
1116
|
-
Object.keys(shareInfos).forEach((shareKey)=>{
|
|
1117
|
-
if (!shared[shareKey]) {
|
|
1118
|
-
shared[shareKey] = shareInfos[shareKey];
|
|
1119
|
-
} else {
|
|
1120
|
-
shareInfos[shareKey].forEach((newUserSharedOptions)=>{
|
|
1121
|
-
const isSameVersion = shared[shareKey].find((sharedVal)=>sharedVal.version === newUserSharedOptions.version);
|
|
1122
|
-
if (!isSameVersion) {
|
|
1123
|
-
shared[shareKey].push(newUserSharedOptions);
|
|
1124
|
-
}
|
|
1125
|
-
});
|
|
1126
|
-
}
|
|
1127
|
-
});
|
|
1128
|
-
return {
|
|
1129
|
-
shared,
|
|
1130
|
-
shareInfos
|
|
1131
|
-
};
|
|
1132
|
-
}
|
|
1133
1113
|
// register shared in shareScopeMap
|
|
1134
|
-
registerShared(
|
|
1114
|
+
registerShared(globalOptions, userOptions) {
|
|
1115
|
+
const { shareInfos, shared } = formatShareConfigs(globalOptions, userOptions);
|
|
1135
1116
|
const sharedKeys = Object.keys(shareInfos);
|
|
1136
1117
|
sharedKeys.forEach((sharedKey)=>{
|
|
1137
1118
|
const sharedVals = shareInfos[sharedKey];
|
|
@@ -1149,6 +1130,10 @@ class SharedHandler {
|
|
|
1149
1130
|
}
|
|
1150
1131
|
});
|
|
1151
1132
|
});
|
|
1133
|
+
return {
|
|
1134
|
+
shareInfos,
|
|
1135
|
+
shared
|
|
1136
|
+
};
|
|
1152
1137
|
}
|
|
1153
1138
|
async loadShare(pkgName, extraOptions) {
|
|
1154
1139
|
const { host } = this;
|
|
@@ -1757,7 +1742,7 @@ class FederationHost {
|
|
|
1757
1742
|
this.sharedHandler.initShareScopeMap(scopeName, shareScope);
|
|
1758
1743
|
}
|
|
1759
1744
|
formatOptions(globalOptions, userOptions) {
|
|
1760
|
-
const { shared
|
|
1745
|
+
const { shared } = formatShareConfigs(globalOptions, userOptions);
|
|
1761
1746
|
const { userOptions: userOptionsRes, options: globalOptionsRes } = this.hooks.lifecycle.beforeInit.emit({
|
|
1762
1747
|
origin: this,
|
|
1763
1748
|
userOptions,
|
|
@@ -1765,7 +1750,7 @@ class FederationHost {
|
|
|
1765
1750
|
shareInfo: shared
|
|
1766
1751
|
});
|
|
1767
1752
|
const remotes = this.remoteHandler.formatAndRegisterRemote(globalOptionsRes, userOptionsRes);
|
|
1768
|
-
this.sharedHandler.registerShared(
|
|
1753
|
+
const { shared: handledShared } = this.sharedHandler.registerShared(globalOptionsRes, userOptionsRes);
|
|
1769
1754
|
const plugins = [
|
|
1770
1755
|
...globalOptionsRes.plugins
|
|
1771
1756
|
];
|
|
@@ -1779,7 +1764,7 @@ class FederationHost {
|
|
|
1779
1764
|
const optionsRes = _extends({}, globalOptions, userOptions, {
|
|
1780
1765
|
plugins,
|
|
1781
1766
|
remotes,
|
|
1782
|
-
shared
|
|
1767
|
+
shared: handledShared
|
|
1783
1768
|
});
|
|
1784
1769
|
this.hooks.lifecycle.init.emit({
|
|
1785
1770
|
origin: this,
|
|
@@ -1816,7 +1801,7 @@ class FederationHost {
|
|
|
1816
1801
|
// maybe will change, temporarily for internal use only
|
|
1817
1802
|
initContainer: new AsyncWaterfallHook('initContainer')
|
|
1818
1803
|
});
|
|
1819
|
-
this.version = "0.1.
|
|
1804
|
+
this.version = "0.1.12";
|
|
1820
1805
|
this.moduleCache = new Map();
|
|
1821
1806
|
this.loaderHook = new PluginSystem({
|
|
1822
1807
|
// FIXME: may not be suitable , not open to the public yet
|
package/dist/package.json
CHANGED
package/dist/share.cjs.js
CHANGED
|
@@ -190,7 +190,7 @@ function getGlobalFederationConstructor() {
|
|
|
190
190
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
|
|
191
191
|
if (isDebug) {
|
|
192
192
|
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
193
|
-
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.1.
|
|
193
|
+
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.1.12";
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -697,11 +697,10 @@ function formatShare(shareArgs, from, name) {
|
|
|
697
697
|
strategy: shareArgs.strategy || 'version-first'
|
|
698
698
|
});
|
|
699
699
|
}
|
|
700
|
-
function formatShareConfigs(
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
return Object.keys(shareArgs).reduce((res, pkgName)=>{
|
|
700
|
+
function formatShareConfigs(globalOptions, userOptions) {
|
|
701
|
+
const shareArgs = userOptions.shared || {};
|
|
702
|
+
const from = userOptions.name;
|
|
703
|
+
const shareInfos = Object.keys(shareArgs).reduce((res, pkgName)=>{
|
|
705
704
|
const arrayShareArgs = arrayOptions(shareArgs[pkgName]);
|
|
706
705
|
res[pkgName] = res[pkgName] || [];
|
|
707
706
|
arrayShareArgs.forEach((shareConfig)=>{
|
|
@@ -709,6 +708,23 @@ function formatShareConfigs(shareArgs, from) {
|
|
|
709
708
|
});
|
|
710
709
|
return res;
|
|
711
710
|
}, {});
|
|
711
|
+
const shared = _extends({}, globalOptions.shared);
|
|
712
|
+
Object.keys(shareInfos).forEach((shareKey)=>{
|
|
713
|
+
if (!shared[shareKey]) {
|
|
714
|
+
shared[shareKey] = shareInfos[shareKey];
|
|
715
|
+
} else {
|
|
716
|
+
shareInfos[shareKey].forEach((newUserSharedOptions)=>{
|
|
717
|
+
const isSameVersion = shared[shareKey].find((sharedVal)=>sharedVal.version === newUserSharedOptions.version);
|
|
718
|
+
if (!isSameVersion) {
|
|
719
|
+
shared[shareKey].push(newUserSharedOptions);
|
|
720
|
+
}
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
});
|
|
724
|
+
return {
|
|
725
|
+
shared,
|
|
726
|
+
shareInfos
|
|
727
|
+
};
|
|
712
728
|
}
|
|
713
729
|
function versionLt(a, b) {
|
|
714
730
|
const transformInvalidVersion = (version)=>{
|
package/dist/share.esm.js
CHANGED
|
@@ -188,7 +188,7 @@ function getGlobalFederationConstructor() {
|
|
|
188
188
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
|
|
189
189
|
if (isDebug) {
|
|
190
190
|
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
191
|
-
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.1.
|
|
191
|
+
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.1.12";
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -695,11 +695,10 @@ function formatShare(shareArgs, from, name) {
|
|
|
695
695
|
strategy: shareArgs.strategy || 'version-first'
|
|
696
696
|
});
|
|
697
697
|
}
|
|
698
|
-
function formatShareConfigs(
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
return Object.keys(shareArgs).reduce((res, pkgName)=>{
|
|
698
|
+
function formatShareConfigs(globalOptions, userOptions) {
|
|
699
|
+
const shareArgs = userOptions.shared || {};
|
|
700
|
+
const from = userOptions.name;
|
|
701
|
+
const shareInfos = Object.keys(shareArgs).reduce((res, pkgName)=>{
|
|
703
702
|
const arrayShareArgs = arrayOptions(shareArgs[pkgName]);
|
|
704
703
|
res[pkgName] = res[pkgName] || [];
|
|
705
704
|
arrayShareArgs.forEach((shareConfig)=>{
|
|
@@ -707,6 +706,23 @@ function formatShareConfigs(shareArgs, from) {
|
|
|
707
706
|
});
|
|
708
707
|
return res;
|
|
709
708
|
}, {});
|
|
709
|
+
const shared = _extends({}, globalOptions.shared);
|
|
710
|
+
Object.keys(shareInfos).forEach((shareKey)=>{
|
|
711
|
+
if (!shared[shareKey]) {
|
|
712
|
+
shared[shareKey] = shareInfos[shareKey];
|
|
713
|
+
} else {
|
|
714
|
+
shareInfos[shareKey].forEach((newUserSharedOptions)=>{
|
|
715
|
+
const isSameVersion = shared[shareKey].find((sharedVal)=>sharedVal.version === newUserSharedOptions.version);
|
|
716
|
+
if (!isSameVersion) {
|
|
717
|
+
shared[shareKey].push(newUserSharedOptions);
|
|
718
|
+
}
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
});
|
|
722
|
+
return {
|
|
723
|
+
shared,
|
|
724
|
+
shareInfos
|
|
725
|
+
};
|
|
710
726
|
}
|
|
711
727
|
function versionLt(a, b) {
|
|
712
728
|
const transformInvalidVersion = (version)=>{
|
|
@@ -30,13 +30,12 @@ export declare class SharedHandler {
|
|
|
30
30
|
}>;
|
|
31
31
|
}>;
|
|
32
32
|
constructor(host: FederationHost);
|
|
33
|
-
|
|
33
|
+
registerShared(globalOptions: Options, userOptions: UserOptions): {
|
|
34
|
+
shareInfos: ShareInfos;
|
|
34
35
|
shared: {
|
|
35
36
|
[x: string]: Shared[];
|
|
36
37
|
};
|
|
37
|
-
shareInfos: ShareInfos;
|
|
38
38
|
};
|
|
39
|
-
registerShared(shareInfos: ShareInfos, userOptions: UserOptions): void;
|
|
40
39
|
loadShare<T>(pkgName: string, extraOptions?: {
|
|
41
40
|
customShareInfo?: Partial<Shared>;
|
|
42
41
|
resolver?: (sharedOptions: ShareInfos[string]) => Shared;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { Federation } from '../global';
|
|
2
|
-
import { GlobalShareScopeMap, Shared, ShareArgs, ShareInfos, ShareScopeMap, LoadShareExtraOptions, UserOptions } from '../type';
|
|
2
|
+
import { GlobalShareScopeMap, Shared, ShareArgs, ShareInfos, ShareScopeMap, LoadShareExtraOptions, UserOptions, Options } from '../type';
|
|
3
3
|
import { SyncWaterfallHook } from './hooks';
|
|
4
4
|
export declare function formatShare(shareArgs: ShareArgs, from: string, name: string): Shared;
|
|
5
|
-
export declare function formatShareConfigs(
|
|
5
|
+
export declare function formatShareConfigs(globalOptions: Options, userOptions: UserOptions): {
|
|
6
|
+
shared: {
|
|
7
|
+
[x: string]: Shared[];
|
|
8
|
+
};
|
|
9
|
+
shareInfos: ShareInfos;
|
|
10
|
+
};
|
|
6
11
|
export declare function versionLt(a: string, b: string): boolean;
|
|
7
12
|
export declare const findVersion: (shareVersionMap: ShareScopeMap[string][string], cb?: ((prev: string, cur: string) => boolean) | undefined) => string;
|
|
8
13
|
export declare const isLoaded: (shared: Shared) => boolean;
|
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-20240511031741",
|
|
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-20240511031741"
|
|
49
49
|
}
|
|
50
50
|
}
|