@module-federation/runtime-core 0.0.0-next-20250321094426 → 0.0.0-next-20250323051630
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 +19 -20
- package/dist/index.esm.mjs +19 -20
- package/dist/src/type/config.d.ts +5 -3
- package/package.json +3 -3
package/dist/index.cjs.js
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.10.0";
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -1227,14 +1227,23 @@ let Module = class Module {
|
|
|
1227
1227
|
const remoteEntryExports = await this.getEntry();
|
|
1228
1228
|
if (!this.inited) {
|
|
1229
1229
|
const localShareScopeMap = this.host.shareScopeMap;
|
|
1230
|
-
const
|
|
1231
|
-
|
|
1232
|
-
|
|
1230
|
+
const shareScopeKeys = Array.isArray(this.remoteInfo.shareScope) ? this.remoteInfo.shareScope : [
|
|
1231
|
+
this.remoteInfo.shareScope
|
|
1232
|
+
];
|
|
1233
|
+
if (!shareScopeKeys.length) {
|
|
1234
|
+
shareScopeKeys.push('default');
|
|
1233
1235
|
}
|
|
1234
|
-
|
|
1236
|
+
shareScopeKeys.forEach((shareScopeKey)=>{
|
|
1237
|
+
if (!localShareScopeMap[shareScopeKey]) {
|
|
1238
|
+
localShareScopeMap[shareScopeKey] = {};
|
|
1239
|
+
}
|
|
1240
|
+
});
|
|
1241
|
+
// TODO: compate legacy init params, should use shareScopeMap if exist
|
|
1242
|
+
const shareScope = localShareScopeMap[shareScopeKeys[0]];
|
|
1235
1243
|
const initScope = [];
|
|
1236
1244
|
const remoteEntryInitOptions = {
|
|
1237
|
-
version: this.remoteInfo.version || ''
|
|
1245
|
+
version: this.remoteInfo.version || '',
|
|
1246
|
+
shareScopeKeys: Array.isArray(this.remoteInfo.shareScope) ? shareScopeKeys : this.remoteInfo.shareScope || 'default'
|
|
1238
1247
|
};
|
|
1239
1248
|
// Help to find host instance
|
|
1240
1249
|
Object.defineProperty(remoteEntryInitOptions, 'shareScopeMap', {
|
|
@@ -1768,9 +1777,6 @@ function traverseModuleInfo(globalSnapshot, remoteInfo, traverse, isRoot, memo =
|
|
|
1768
1777
|
}
|
|
1769
1778
|
}
|
|
1770
1779
|
}
|
|
1771
|
-
const isExisted = (type, url)=>{
|
|
1772
|
-
return document.querySelector(`${type}[${type === 'link' ? 'href' : 'src'}="${url}"]`);
|
|
1773
|
-
};
|
|
1774
1780
|
// eslint-disable-next-line max-lines-per-function
|
|
1775
1781
|
function generatePreloadAssets(origin, preloadOptions, remote, globalSnapshot, remoteSnapshot) {
|
|
1776
1782
|
const cssAssets = [];
|
|
@@ -1899,12 +1905,12 @@ function generatePreloadAssets(origin, preloadOptions, remote, globalSnapshot, r
|
|
|
1899
1905
|
});
|
|
1900
1906
|
});
|
|
1901
1907
|
}
|
|
1902
|
-
const needPreloadJsAssets = jsAssets.filter((asset)=>!loadedSharedJsAssets.has(asset)
|
|
1903
|
-
const needPreloadCssAssets = cssAssets.filter((asset)=>!loadedSharedCssAssets.has(asset)
|
|
1908
|
+
const needPreloadJsAssets = jsAssets.filter((asset)=>!loadedSharedJsAssets.has(asset));
|
|
1909
|
+
const needPreloadCssAssets = cssAssets.filter((asset)=>!loadedSharedCssAssets.has(asset));
|
|
1904
1910
|
return {
|
|
1905
1911
|
cssAssets: needPreloadCssAssets,
|
|
1906
1912
|
jsAssetsWithoutEntry: needPreloadJsAssets,
|
|
1907
|
-
entryAssets
|
|
1913
|
+
entryAssets
|
|
1908
1914
|
};
|
|
1909
1915
|
}
|
|
1910
1916
|
const generatePreloadAssetsPlugin = function() {
|
|
@@ -1912,13 +1918,6 @@ const generatePreloadAssetsPlugin = function() {
|
|
|
1912
1918
|
name: 'generate-preload-assets-plugin',
|
|
1913
1919
|
async generatePreloadAssets (args) {
|
|
1914
1920
|
const { origin, preloadOptions, remoteInfo, remote, globalSnapshot, remoteSnapshot } = args;
|
|
1915
|
-
if (!sdk.isBrowserEnv()) {
|
|
1916
|
-
return {
|
|
1917
|
-
cssAssets: [],
|
|
1918
|
-
jsAssetsWithoutEntry: [],
|
|
1919
|
-
entryAssets: []
|
|
1920
|
-
};
|
|
1921
|
-
}
|
|
1922
1921
|
if (isRemoteInfoWithEntry(remote) && isPureRemoteEntry(remote)) {
|
|
1923
1922
|
return {
|
|
1924
1923
|
cssAssets: [],
|
|
@@ -2971,7 +2970,7 @@ class FederationHost {
|
|
|
2971
2970
|
// maybe will change, temporarily for internal use only
|
|
2972
2971
|
initContainer: new AsyncWaterfallHook('initContainer')
|
|
2973
2972
|
});
|
|
2974
|
-
this.version = "0.
|
|
2973
|
+
this.version = "0.10.0";
|
|
2975
2974
|
this.moduleCache = new Map();
|
|
2976
2975
|
this.loaderHook = new PluginSystem({
|
|
2977
2976
|
// FIXME: may not be suitable , not open to the public yet
|
package/dist/index.esm.mjs
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.10.0";
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -1226,14 +1226,23 @@ let Module = class Module {
|
|
|
1226
1226
|
const remoteEntryExports = await this.getEntry();
|
|
1227
1227
|
if (!this.inited) {
|
|
1228
1228
|
const localShareScopeMap = this.host.shareScopeMap;
|
|
1229
|
-
const
|
|
1230
|
-
|
|
1231
|
-
|
|
1229
|
+
const shareScopeKeys = Array.isArray(this.remoteInfo.shareScope) ? this.remoteInfo.shareScope : [
|
|
1230
|
+
this.remoteInfo.shareScope
|
|
1231
|
+
];
|
|
1232
|
+
if (!shareScopeKeys.length) {
|
|
1233
|
+
shareScopeKeys.push('default');
|
|
1232
1234
|
}
|
|
1233
|
-
|
|
1235
|
+
shareScopeKeys.forEach((shareScopeKey)=>{
|
|
1236
|
+
if (!localShareScopeMap[shareScopeKey]) {
|
|
1237
|
+
localShareScopeMap[shareScopeKey] = {};
|
|
1238
|
+
}
|
|
1239
|
+
});
|
|
1240
|
+
// TODO: compate legacy init params, should use shareScopeMap if exist
|
|
1241
|
+
const shareScope = localShareScopeMap[shareScopeKeys[0]];
|
|
1234
1242
|
const initScope = [];
|
|
1235
1243
|
const remoteEntryInitOptions = {
|
|
1236
|
-
version: this.remoteInfo.version || ''
|
|
1244
|
+
version: this.remoteInfo.version || '',
|
|
1245
|
+
shareScopeKeys: Array.isArray(this.remoteInfo.shareScope) ? shareScopeKeys : this.remoteInfo.shareScope || 'default'
|
|
1237
1246
|
};
|
|
1238
1247
|
// Help to find host instance
|
|
1239
1248
|
Object.defineProperty(remoteEntryInitOptions, 'shareScopeMap', {
|
|
@@ -1767,9 +1776,6 @@ function traverseModuleInfo(globalSnapshot, remoteInfo, traverse, isRoot, memo =
|
|
|
1767
1776
|
}
|
|
1768
1777
|
}
|
|
1769
1778
|
}
|
|
1770
|
-
const isExisted = (type, url)=>{
|
|
1771
|
-
return document.querySelector(`${type}[${type === 'link' ? 'href' : 'src'}="${url}"]`);
|
|
1772
|
-
};
|
|
1773
1779
|
// eslint-disable-next-line max-lines-per-function
|
|
1774
1780
|
function generatePreloadAssets(origin, preloadOptions, remote, globalSnapshot, remoteSnapshot) {
|
|
1775
1781
|
const cssAssets = [];
|
|
@@ -1898,12 +1904,12 @@ function generatePreloadAssets(origin, preloadOptions, remote, globalSnapshot, r
|
|
|
1898
1904
|
});
|
|
1899
1905
|
});
|
|
1900
1906
|
}
|
|
1901
|
-
const needPreloadJsAssets = jsAssets.filter((asset)=>!loadedSharedJsAssets.has(asset)
|
|
1902
|
-
const needPreloadCssAssets = cssAssets.filter((asset)=>!loadedSharedCssAssets.has(asset)
|
|
1907
|
+
const needPreloadJsAssets = jsAssets.filter((asset)=>!loadedSharedJsAssets.has(asset));
|
|
1908
|
+
const needPreloadCssAssets = cssAssets.filter((asset)=>!loadedSharedCssAssets.has(asset));
|
|
1903
1909
|
return {
|
|
1904
1910
|
cssAssets: needPreloadCssAssets,
|
|
1905
1911
|
jsAssetsWithoutEntry: needPreloadJsAssets,
|
|
1906
|
-
entryAssets
|
|
1912
|
+
entryAssets
|
|
1907
1913
|
};
|
|
1908
1914
|
}
|
|
1909
1915
|
const generatePreloadAssetsPlugin = function() {
|
|
@@ -1911,13 +1917,6 @@ const generatePreloadAssetsPlugin = function() {
|
|
|
1911
1917
|
name: 'generate-preload-assets-plugin',
|
|
1912
1918
|
async generatePreloadAssets (args) {
|
|
1913
1919
|
const { origin, preloadOptions, remoteInfo, remote, globalSnapshot, remoteSnapshot } = args;
|
|
1914
|
-
if (!isBrowserEnv()) {
|
|
1915
|
-
return {
|
|
1916
|
-
cssAssets: [],
|
|
1917
|
-
jsAssetsWithoutEntry: [],
|
|
1918
|
-
entryAssets: []
|
|
1919
|
-
};
|
|
1920
|
-
}
|
|
1921
1920
|
if (isRemoteInfoWithEntry(remote) && isPureRemoteEntry(remote)) {
|
|
1922
1921
|
return {
|
|
1923
1922
|
cssAssets: [],
|
|
@@ -2970,7 +2969,7 @@ class FederationHost {
|
|
|
2970
2969
|
// maybe will change, temporarily for internal use only
|
|
2971
2970
|
initContainer: new AsyncWaterfallHook('initContainer')
|
|
2972
2971
|
});
|
|
2973
|
-
this.version = "0.
|
|
2972
|
+
this.version = "0.10.0";
|
|
2974
2973
|
this.moduleCache = new Map();
|
|
2975
2974
|
this.loaderHook = new PluginSystem({
|
|
2976
2975
|
// FIXME: may not be suitable , not open to the public yet
|
|
@@ -6,7 +6,7 @@ export type PartialOptional<T, K extends keyof T> = Omit<T, K> & {
|
|
|
6
6
|
};
|
|
7
7
|
export interface RemoteInfoCommon {
|
|
8
8
|
alias?: string;
|
|
9
|
-
shareScope?: string;
|
|
9
|
+
shareScope?: string | string[];
|
|
10
10
|
type?: RemoteEntryType;
|
|
11
11
|
entryGlobalName?: string;
|
|
12
12
|
}
|
|
@@ -26,7 +26,7 @@ export interface RemoteInfo {
|
|
|
26
26
|
entry: string;
|
|
27
27
|
type: RemoteEntryType;
|
|
28
28
|
entryGlobalName: string;
|
|
29
|
-
shareScope: string;
|
|
29
|
+
shareScope: string | string[];
|
|
30
30
|
}
|
|
31
31
|
export type HostInfo = Pick<Options, 'name' | 'version' | 'remotes' | 'version'>;
|
|
32
32
|
export interface SharedConfig {
|
|
@@ -34,6 +34,7 @@ export interface SharedConfig {
|
|
|
34
34
|
requiredVersion: false | string;
|
|
35
35
|
eager?: boolean;
|
|
36
36
|
strictVersion?: boolean;
|
|
37
|
+
layer?: string | null;
|
|
37
38
|
}
|
|
38
39
|
type SharedBaseArgs = {
|
|
39
40
|
version?: string;
|
|
@@ -100,7 +101,8 @@ export type LoadModuleOptions = {
|
|
|
100
101
|
};
|
|
101
102
|
export type RemoteEntryInitOptions = {
|
|
102
103
|
version: string;
|
|
103
|
-
shareScopeMap
|
|
104
|
+
shareScopeMap?: ShareScopeMap;
|
|
105
|
+
shareScopeKeys: string | string[];
|
|
104
106
|
};
|
|
105
107
|
export type InitTokens = Record<string, Record<string, any>>;
|
|
106
108
|
export type InitScope = InitTokens[];
|
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-20250323051630",
|
|
4
4
|
"author": "zhouxiao <codingzx@gmail.com>",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"module": "./dist/index.esm.mjs",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@module-federation/sdk": "0.0.0-next-
|
|
40
|
-
"@module-federation/error-codes": "0.0.0-next-
|
|
39
|
+
"@module-federation/sdk": "0.0.0-next-20250323051630",
|
|
40
|
+
"@module-federation/error-codes": "0.0.0-next-20250323051630"
|
|
41
41
|
}
|
|
42
42
|
}
|