@module-federation/runtime 0.2.3 → 0.2.4
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 +26 -3
- package/dist/index.esm.js +26 -3
- package/dist/package.json +1 -1
- package/dist/share.cjs.js +1 -1
- package/dist/share.esm.js +1 -1
- package/dist/src/core.d.ts +1 -0
- package/dist/src/utils/load.d.ts +6 -2
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -120,6 +120,23 @@ async function loadEsmEntry({ entry, remoteEntryExports }) {
|
|
|
120
120
|
}
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
|
+
async function loadSystemJsEntry({ entry, remoteEntryExports }) {
|
|
124
|
+
return new Promise((resolve, reject)=>{
|
|
125
|
+
try {
|
|
126
|
+
if (!remoteEntryExports) {
|
|
127
|
+
// eslint-disable-next-line no-eval
|
|
128
|
+
new Function('callbacks', `System.import("${entry}").then(callbacks[0]).catch(callbacks[1])`)([
|
|
129
|
+
resolve,
|
|
130
|
+
reject
|
|
131
|
+
]);
|
|
132
|
+
} else {
|
|
133
|
+
resolve(remoteEntryExports);
|
|
134
|
+
}
|
|
135
|
+
} catch (e) {
|
|
136
|
+
reject(e);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
123
140
|
async function loadEntryScript({ name, globalName, entry, createScriptHook }) {
|
|
124
141
|
const { entryExports: remoteEntryExports } = share.getRemoteEntryExports(name, globalName);
|
|
125
142
|
if (remoteEntryExports) {
|
|
@@ -180,6 +197,11 @@ async function getRemoteEntry({ remoteEntryExports, remoteInfo, createScriptHook
|
|
|
180
197
|
entry,
|
|
181
198
|
remoteEntryExports
|
|
182
199
|
});
|
|
200
|
+
} else if (type === 'system') {
|
|
201
|
+
share.globalLoading[uniqueKey] = loadSystemJsEntry({
|
|
202
|
+
entry,
|
|
203
|
+
remoteEntryExports
|
|
204
|
+
});
|
|
183
205
|
} else {
|
|
184
206
|
share.globalLoading[uniqueKey] = loadEntryScript({
|
|
185
207
|
name,
|
|
@@ -223,9 +245,10 @@ let Module = class Module {
|
|
|
223
245
|
const remoteEntryExports = await getRemoteEntry({
|
|
224
246
|
remoteInfo: this.remoteInfo,
|
|
225
247
|
remoteEntryExports: this.remoteEntryExports,
|
|
226
|
-
createScriptHook: (url)=>{
|
|
248
|
+
createScriptHook: (url, attrs)=>{
|
|
227
249
|
const res = this.host.loaderHook.lifecycle.createScript.emit({
|
|
228
|
-
url
|
|
250
|
+
url,
|
|
251
|
+
attrs
|
|
229
252
|
});
|
|
230
253
|
if (!res) return;
|
|
231
254
|
if (typeof document === 'undefined') {
|
|
@@ -1983,7 +2006,7 @@ class FederationHost {
|
|
|
1983
2006
|
// maybe will change, temporarily for internal use only
|
|
1984
2007
|
initContainer: new AsyncWaterfallHook('initContainer')
|
|
1985
2008
|
});
|
|
1986
|
-
this.version = "0.2.
|
|
2009
|
+
this.version = "0.2.4";
|
|
1987
2010
|
this.moduleCache = new Map();
|
|
1988
2011
|
this.loaderHook = new PluginSystem({
|
|
1989
2012
|
// FIXME: may not be suitable , not open to the public yet
|
package/dist/index.esm.js
CHANGED
|
@@ -118,6 +118,23 @@ async function loadEsmEntry({ entry, remoteEntryExports }) {
|
|
|
118
118
|
}
|
|
119
119
|
});
|
|
120
120
|
}
|
|
121
|
+
async function loadSystemJsEntry({ entry, remoteEntryExports }) {
|
|
122
|
+
return new Promise((resolve, reject)=>{
|
|
123
|
+
try {
|
|
124
|
+
if (!remoteEntryExports) {
|
|
125
|
+
// eslint-disable-next-line no-eval
|
|
126
|
+
new Function('callbacks', `System.import("${entry}").then(callbacks[0]).catch(callbacks[1])`)([
|
|
127
|
+
resolve,
|
|
128
|
+
reject
|
|
129
|
+
]);
|
|
130
|
+
} else {
|
|
131
|
+
resolve(remoteEntryExports);
|
|
132
|
+
}
|
|
133
|
+
} catch (e) {
|
|
134
|
+
reject(e);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
121
138
|
async function loadEntryScript({ name, globalName, entry, createScriptHook }) {
|
|
122
139
|
const { entryExports: remoteEntryExports } = getRemoteEntryExports(name, globalName);
|
|
123
140
|
if (remoteEntryExports) {
|
|
@@ -178,6 +195,11 @@ async function getRemoteEntry({ remoteEntryExports, remoteInfo, createScriptHook
|
|
|
178
195
|
entry,
|
|
179
196
|
remoteEntryExports
|
|
180
197
|
});
|
|
198
|
+
} else if (type === 'system') {
|
|
199
|
+
globalLoading[uniqueKey] = loadSystemJsEntry({
|
|
200
|
+
entry,
|
|
201
|
+
remoteEntryExports
|
|
202
|
+
});
|
|
181
203
|
} else {
|
|
182
204
|
globalLoading[uniqueKey] = loadEntryScript({
|
|
183
205
|
name,
|
|
@@ -221,9 +243,10 @@ let Module = class Module {
|
|
|
221
243
|
const remoteEntryExports = await getRemoteEntry({
|
|
222
244
|
remoteInfo: this.remoteInfo,
|
|
223
245
|
remoteEntryExports: this.remoteEntryExports,
|
|
224
|
-
createScriptHook: (url)=>{
|
|
246
|
+
createScriptHook: (url, attrs)=>{
|
|
225
247
|
const res = this.host.loaderHook.lifecycle.createScript.emit({
|
|
226
|
-
url
|
|
248
|
+
url,
|
|
249
|
+
attrs
|
|
227
250
|
});
|
|
228
251
|
if (!res) return;
|
|
229
252
|
if (typeof document === 'undefined') {
|
|
@@ -1981,7 +2004,7 @@ class FederationHost {
|
|
|
1981
2004
|
// maybe will change, temporarily for internal use only
|
|
1982
2005
|
initContainer: new AsyncWaterfallHook('initContainer')
|
|
1983
2006
|
});
|
|
1984
|
-
this.version = "0.2.
|
|
2007
|
+
this.version = "0.2.4";
|
|
1985
2008
|
this.moduleCache = new Map();
|
|
1986
2009
|
this.loaderHook = new PluginSystem({
|
|
1987
2010
|
// 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.2.
|
|
193
|
+
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.2.4";
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
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.2.
|
|
191
|
+
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.2.4";
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
package/dist/src/core.d.ts
CHANGED
package/dist/src/utils/load.d.ts
CHANGED
|
@@ -4,16 +4,20 @@ export declare function loadEsmEntry({ entry, remoteEntryExports, }: {
|
|
|
4
4
|
entry: string;
|
|
5
5
|
remoteEntryExports: RemoteEntryExports | undefined;
|
|
6
6
|
}): Promise<RemoteEntryExports>;
|
|
7
|
+
export declare function loadSystemJsEntry({ entry, remoteEntryExports, }: {
|
|
8
|
+
entry: string;
|
|
9
|
+
remoteEntryExports: RemoteEntryExports | undefined;
|
|
10
|
+
}): Promise<RemoteEntryExports>;
|
|
7
11
|
export declare function loadEntryScript({ name, globalName, entry, createScriptHook, }: {
|
|
8
12
|
name: string;
|
|
9
13
|
globalName: string;
|
|
10
14
|
entry: string;
|
|
11
|
-
createScriptHook?: (url: string) => CreateScriptHookReturn;
|
|
15
|
+
createScriptHook?: (url: string, attrs?: Record<string, any> | undefined) => CreateScriptHookReturn;
|
|
12
16
|
}): Promise<RemoteEntryExports>;
|
|
13
17
|
export declare function getRemoteEntryUniqueKey(remoteInfo: RemoteInfo): string;
|
|
14
18
|
export declare function getRemoteEntry({ remoteEntryExports, remoteInfo, createScriptHook, }: {
|
|
15
19
|
remoteInfo: RemoteInfo;
|
|
16
20
|
remoteEntryExports?: RemoteEntryExports | undefined;
|
|
17
|
-
createScriptHook?: (url: string) => CreateScriptHookReturn;
|
|
21
|
+
createScriptHook?: (url: string, attrs?: Record<string, any> | undefined) => CreateScriptHookReturn;
|
|
18
22
|
}): Promise<RemoteEntryExports | void>;
|
|
19
23
|
export declare function getRemoteInfo(remote: Remote): RemoteInfo;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/runtime",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
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.2.
|
|
48
|
+
"@module-federation/sdk": "0.2.4"
|
|
49
49
|
}
|
|
50
50
|
}
|