@module-federation/runtime 0.1.16 → 0.1.17
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 +31 -5
- package/dist/index.esm.js +31 -5
- package/dist/package.json +1 -1
- package/dist/share.cjs.js +1 -1
- package/dist/share.esm.js +1 -1
- package/dist/src/module/index.d.ts +2 -1
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -243,7 +243,7 @@ let Module = class Module {
|
|
|
243
243
|
return this.remoteEntryExports;
|
|
244
244
|
}
|
|
245
245
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
246
|
-
async get(expose, options) {
|
|
246
|
+
async get(id, expose, options) {
|
|
247
247
|
const { loadFactory = true } = options || {
|
|
248
248
|
loadFactory: true
|
|
249
249
|
};
|
|
@@ -284,12 +284,38 @@ let Module = class Module {
|
|
|
284
284
|
// get exposeGetter
|
|
285
285
|
const moduleFactory = await remoteEntryExports.get(expose);
|
|
286
286
|
share.assert(moduleFactory, `${share.getFMId(this.remoteInfo)} remote don't export ${expose}.`);
|
|
287
|
+
const wrapModuleFactory = this.wraperFactory(moduleFactory, id);
|
|
287
288
|
if (!loadFactory) {
|
|
288
|
-
return
|
|
289
|
+
return wrapModuleFactory;
|
|
289
290
|
}
|
|
290
|
-
const exposeContent = await
|
|
291
|
+
const exposeContent = await wrapModuleFactory();
|
|
291
292
|
return exposeContent;
|
|
292
293
|
}
|
|
294
|
+
wraperFactory(moduleFactory, id) {
|
|
295
|
+
function defineModuleId(res, id) {
|
|
296
|
+
if (res && typeof res === 'object' && !Object.getOwnPropertyDescriptor(res, Symbol.for('mf_module_id'))) {
|
|
297
|
+
Object.defineProperty(res, Symbol.for('mf_module_id'), {
|
|
298
|
+
value: id,
|
|
299
|
+
enumerable: false
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
if (moduleFactory instanceof Promise) {
|
|
304
|
+
return async ()=>{
|
|
305
|
+
const res = await moduleFactory();
|
|
306
|
+
// This parameter is used for bridge debugging
|
|
307
|
+
defineModuleId(res, id);
|
|
308
|
+
return res;
|
|
309
|
+
};
|
|
310
|
+
} else {
|
|
311
|
+
return ()=>{
|
|
312
|
+
const res = moduleFactory();
|
|
313
|
+
// This parameter is used for bridge debugging
|
|
314
|
+
defineModuleId(res, id);
|
|
315
|
+
return res;
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
}
|
|
293
319
|
constructor({ remoteInfo, host }){
|
|
294
320
|
this.inited = false;
|
|
295
321
|
this.lib = undefined;
|
|
@@ -1500,7 +1526,7 @@ class RemoteHandler {
|
|
|
1500
1526
|
id
|
|
1501
1527
|
});
|
|
1502
1528
|
const { pkgNameOrAlias, remote, expose, id: idRes } = remoteMatchInfo;
|
|
1503
|
-
const moduleOrFactory = await module.get(expose, options);
|
|
1529
|
+
const moduleOrFactory = await module.get(idRes, expose, options);
|
|
1504
1530
|
const moduleWrapper = await this.hooks.lifecycle.onLoad.emit({
|
|
1505
1531
|
id: idRes,
|
|
1506
1532
|
pkgNameOrAlias,
|
|
@@ -1881,7 +1907,7 @@ class FederationHost {
|
|
|
1881
1907
|
// maybe will change, temporarily for internal use only
|
|
1882
1908
|
initContainer: new AsyncWaterfallHook('initContainer')
|
|
1883
1909
|
});
|
|
1884
|
-
this.version = "0.1.
|
|
1910
|
+
this.version = "0.1.17";
|
|
1885
1911
|
this.moduleCache = new Map();
|
|
1886
1912
|
this.loaderHook = new PluginSystem({
|
|
1887
1913
|
// FIXME: may not be suitable , not open to the public yet
|
package/dist/index.esm.js
CHANGED
|
@@ -241,7 +241,7 @@ let Module = class Module {
|
|
|
241
241
|
return this.remoteEntryExports;
|
|
242
242
|
}
|
|
243
243
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
244
|
-
async get(expose, options) {
|
|
244
|
+
async get(id, expose, options) {
|
|
245
245
|
const { loadFactory = true } = options || {
|
|
246
246
|
loadFactory: true
|
|
247
247
|
};
|
|
@@ -282,12 +282,38 @@ let Module = class Module {
|
|
|
282
282
|
// get exposeGetter
|
|
283
283
|
const moduleFactory = await remoteEntryExports.get(expose);
|
|
284
284
|
assert(moduleFactory, `${getFMId(this.remoteInfo)} remote don't export ${expose}.`);
|
|
285
|
+
const wrapModuleFactory = this.wraperFactory(moduleFactory, id);
|
|
285
286
|
if (!loadFactory) {
|
|
286
|
-
return
|
|
287
|
+
return wrapModuleFactory;
|
|
287
288
|
}
|
|
288
|
-
const exposeContent = await
|
|
289
|
+
const exposeContent = await wrapModuleFactory();
|
|
289
290
|
return exposeContent;
|
|
290
291
|
}
|
|
292
|
+
wraperFactory(moduleFactory, id) {
|
|
293
|
+
function defineModuleId(res, id) {
|
|
294
|
+
if (res && typeof res === 'object' && !Object.getOwnPropertyDescriptor(res, Symbol.for('mf_module_id'))) {
|
|
295
|
+
Object.defineProperty(res, Symbol.for('mf_module_id'), {
|
|
296
|
+
value: id,
|
|
297
|
+
enumerable: false
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
if (moduleFactory instanceof Promise) {
|
|
302
|
+
return async ()=>{
|
|
303
|
+
const res = await moduleFactory();
|
|
304
|
+
// This parameter is used for bridge debugging
|
|
305
|
+
defineModuleId(res, id);
|
|
306
|
+
return res;
|
|
307
|
+
};
|
|
308
|
+
} else {
|
|
309
|
+
return ()=>{
|
|
310
|
+
const res = moduleFactory();
|
|
311
|
+
// This parameter is used for bridge debugging
|
|
312
|
+
defineModuleId(res, id);
|
|
313
|
+
return res;
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
}
|
|
291
317
|
constructor({ remoteInfo, host }){
|
|
292
318
|
this.inited = false;
|
|
293
319
|
this.lib = undefined;
|
|
@@ -1498,7 +1524,7 @@ class RemoteHandler {
|
|
|
1498
1524
|
id
|
|
1499
1525
|
});
|
|
1500
1526
|
const { pkgNameOrAlias, remote, expose, id: idRes } = remoteMatchInfo;
|
|
1501
|
-
const moduleOrFactory = await module.get(expose, options);
|
|
1527
|
+
const moduleOrFactory = await module.get(idRes, expose, options);
|
|
1502
1528
|
const moduleWrapper = await this.hooks.lifecycle.onLoad.emit({
|
|
1503
1529
|
id: idRes,
|
|
1504
1530
|
pkgNameOrAlias,
|
|
@@ -1879,7 +1905,7 @@ class FederationHost {
|
|
|
1879
1905
|
// maybe will change, temporarily for internal use only
|
|
1880
1906
|
initContainer: new AsyncWaterfallHook('initContainer')
|
|
1881
1907
|
});
|
|
1882
|
-
this.version = "0.1.
|
|
1908
|
+
this.version = "0.1.17";
|
|
1883
1909
|
this.moduleCache = new Map();
|
|
1884
1910
|
this.loaderHook = new PluginSystem({
|
|
1885
1911
|
// 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.17";
|
|
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.1.
|
|
191
|
+
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.1.17";
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -12,8 +12,9 @@ declare class Module {
|
|
|
12
12
|
host: FederationHost;
|
|
13
13
|
});
|
|
14
14
|
getEntry(): Promise<RemoteEntryExports>;
|
|
15
|
-
get(expose: string, options?: {
|
|
15
|
+
get(id: string, expose: string, options?: {
|
|
16
16
|
loadFactory?: boolean;
|
|
17
17
|
}): Promise<any>;
|
|
18
|
+
private wraperFactory;
|
|
18
19
|
}
|
|
19
20
|
export { Module };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/runtime",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
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.1.
|
|
48
|
+
"@module-federation/sdk": "0.1.17"
|
|
49
49
|
}
|
|
50
50
|
}
|