@module-federation/runtime 0.6.13 → 0.6.15
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 +14 -5
- package/dist/index.esm.js +15 -6
- package/dist/package.json +1 -1
- package/dist/share.cjs.js +6 -3
- package/dist/share.esm.js +7 -5
- package/dist/src/core.d.ts +5 -0
- package/dist/src/embedded.d.ts +5 -0
- package/dist/src/utils/logger.d.ts +3 -0
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -305,7 +305,7 @@ let Module = class Module {
|
|
|
305
305
|
origin: this.host
|
|
306
306
|
});
|
|
307
307
|
if (typeof (remoteEntryExports == null ? void 0 : remoteEntryExports.init) === 'undefined') {
|
|
308
|
-
|
|
308
|
+
share.logger.error('The remote entry interface does not contain "init"', '\n', 'Ensure the name of this remote is not reserved or in use. Check if anything already exists on window[nameOfRemote]', '\n', 'Ensure that window[nameOfRemote] is returning a {get,init} object.');
|
|
309
309
|
}
|
|
310
310
|
await remoteEntryExports.init(initContainerOptions.shareScope, initContainerOptions.initScope, initContainerOptions.remoteEntryInitOptions);
|
|
311
311
|
await this.host.hooks.lifecycle.initContainer.emit(polyfills._extends({}, initContainerOptions, {
|
|
@@ -316,8 +316,16 @@ let Module = class Module {
|
|
|
316
316
|
}
|
|
317
317
|
this.lib = remoteEntryExports;
|
|
318
318
|
this.inited = true;
|
|
319
|
+
let moduleFactory;
|
|
320
|
+
moduleFactory = await this.host.loaderHook.lifecycle.getModuleFactory.emit({
|
|
321
|
+
remoteEntryExports,
|
|
322
|
+
expose,
|
|
323
|
+
moduleInfo: this.remoteInfo
|
|
324
|
+
});
|
|
319
325
|
// get exposeGetter
|
|
320
|
-
|
|
326
|
+
if (!moduleFactory) {
|
|
327
|
+
moduleFactory = await remoteEntryExports.get(expose);
|
|
328
|
+
}
|
|
321
329
|
share.assert(moduleFactory, `${share.getFMId(this.remoteInfo)} remote don't export ${expose}.`);
|
|
322
330
|
const wrapModuleFactory = this.wraperFactory(moduleFactory, id);
|
|
323
331
|
if (!loadFactory) {
|
|
@@ -1865,7 +1873,7 @@ class RemoteHandler {
|
|
|
1865
1873
|
host.moduleCache.delete(remote.name);
|
|
1866
1874
|
}
|
|
1867
1875
|
} catch (err) {
|
|
1868
|
-
|
|
1876
|
+
share.logger.log('removeRemote fail: ', err);
|
|
1869
1877
|
}
|
|
1870
1878
|
}
|
|
1871
1879
|
constructor(host){
|
|
@@ -1992,7 +2000,7 @@ class FederationHost {
|
|
|
1992
2000
|
// maybe will change, temporarily for internal use only
|
|
1993
2001
|
initContainer: new AsyncWaterfallHook('initContainer')
|
|
1994
2002
|
});
|
|
1995
|
-
this.version = "0.6.
|
|
2003
|
+
this.version = "0.6.15";
|
|
1996
2004
|
this.moduleCache = new Map();
|
|
1997
2005
|
this.loaderHook = new PluginSystem({
|
|
1998
2006
|
// FIXME: may not be suitable , not open to the public yet
|
|
@@ -2000,7 +2008,8 @@ class FederationHost {
|
|
|
2000
2008
|
createScript: new SyncHook(),
|
|
2001
2009
|
createLink: new SyncHook(),
|
|
2002
2010
|
// only work for manifest , so not open to the public yet
|
|
2003
|
-
fetch: new AsyncHook()
|
|
2011
|
+
fetch: new AsyncHook(),
|
|
2012
|
+
getModuleFactory: new AsyncHook()
|
|
2004
2013
|
});
|
|
2005
2014
|
// TODO: Validate the details of the options
|
|
2006
2015
|
// Initialize options with default values
|
package/dist/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as _extends, _ as _object_without_properties_loose } from './polyfills.esm.js';
|
|
2
2
|
import { isBrowserEnv, loadScriptNode, composeKeyWithSeparator, loadScript, safeToString, createLink, createScript, getResourceUrl, isManifestProvider, generateSnapshotFromManifest, warn as warn$1 } from '@module-federation/sdk';
|
|
3
3
|
export { loadScript, loadScriptNode } from '@module-federation/sdk';
|
|
4
|
-
import { o as getGlobalHostPlugins, t as globalLoading, D as DEFAULT_REMOTE_TYPE, u as DEFAULT_SCOPE, l as getRemoteEntryExports, v as assert, w as
|
|
4
|
+
import { o as getGlobalHostPlugins, t as globalLoading, D as DEFAULT_REMOTE_TYPE, u as DEFAULT_SCOPE, l as getRemoteEntryExports, v as assert, w as logger, x as getFMId, y as isObject, z as error, A as warn, B as isPlainObject, C as isRemoteInfoWithEntry, E as isPureRemoteEntry, F as getRemoteEntryInfoFromSnapshot, e as getInfoWithoutType, p as getPreloaded, q as setPreloaded, g as getRegisteredShare, H as arrayOptions, i as getGlobalSnapshotInfoByModuleInfo, k as addGlobalSnapshot, j as setGlobalSnapshotInfoByModuleInfo, G as Global, f as getGlobalSnapshot, I as formatShareConfigs, J as getTargetSharedOptions, a as getGlobalShareScope, K as addUniqueItem, L as getBuilderId, d as setGlobalFederationConstructor, b as getGlobalFederationInstance, c as getGlobalFederationConstructor, s as setGlobalFederationInstance } from './share.esm.js';
|
|
5
5
|
export { m as registerGlobalPlugins } from './share.esm.js';
|
|
6
6
|
|
|
7
7
|
// Function to match a remote with its name and expose
|
|
@@ -305,7 +305,7 @@ let Module = class Module {
|
|
|
305
305
|
origin: this.host
|
|
306
306
|
});
|
|
307
307
|
if (typeof (remoteEntryExports == null ? void 0 : remoteEntryExports.init) === 'undefined') {
|
|
308
|
-
|
|
308
|
+
logger.error('The remote entry interface does not contain "init"', '\n', 'Ensure the name of this remote is not reserved or in use. Check if anything already exists on window[nameOfRemote]', '\n', 'Ensure that window[nameOfRemote] is returning a {get,init} object.');
|
|
309
309
|
}
|
|
310
310
|
await remoteEntryExports.init(initContainerOptions.shareScope, initContainerOptions.initScope, initContainerOptions.remoteEntryInitOptions);
|
|
311
311
|
await this.host.hooks.lifecycle.initContainer.emit(_extends({}, initContainerOptions, {
|
|
@@ -316,8 +316,16 @@ let Module = class Module {
|
|
|
316
316
|
}
|
|
317
317
|
this.lib = remoteEntryExports;
|
|
318
318
|
this.inited = true;
|
|
319
|
+
let moduleFactory;
|
|
320
|
+
moduleFactory = await this.host.loaderHook.lifecycle.getModuleFactory.emit({
|
|
321
|
+
remoteEntryExports,
|
|
322
|
+
expose,
|
|
323
|
+
moduleInfo: this.remoteInfo
|
|
324
|
+
});
|
|
319
325
|
// get exposeGetter
|
|
320
|
-
|
|
326
|
+
if (!moduleFactory) {
|
|
327
|
+
moduleFactory = await remoteEntryExports.get(expose);
|
|
328
|
+
}
|
|
321
329
|
assert(moduleFactory, `${getFMId(this.remoteInfo)} remote don't export ${expose}.`);
|
|
322
330
|
const wrapModuleFactory = this.wraperFactory(moduleFactory, id);
|
|
323
331
|
if (!loadFactory) {
|
|
@@ -1865,7 +1873,7 @@ class RemoteHandler {
|
|
|
1865
1873
|
host.moduleCache.delete(remote.name);
|
|
1866
1874
|
}
|
|
1867
1875
|
} catch (err) {
|
|
1868
|
-
|
|
1876
|
+
logger.log('removeRemote fail: ', err);
|
|
1869
1877
|
}
|
|
1870
1878
|
}
|
|
1871
1879
|
constructor(host){
|
|
@@ -1992,7 +2000,7 @@ class FederationHost {
|
|
|
1992
2000
|
// maybe will change, temporarily for internal use only
|
|
1993
2001
|
initContainer: new AsyncWaterfallHook('initContainer')
|
|
1994
2002
|
});
|
|
1995
|
-
this.version = "0.6.
|
|
2003
|
+
this.version = "0.6.15";
|
|
1996
2004
|
this.moduleCache = new Map();
|
|
1997
2005
|
this.loaderHook = new PluginSystem({
|
|
1998
2006
|
// FIXME: may not be suitable , not open to the public yet
|
|
@@ -2000,7 +2008,8 @@ class FederationHost {
|
|
|
2000
2008
|
createScript: new SyncHook(),
|
|
2001
2009
|
createLink: new SyncHook(),
|
|
2002
2010
|
// only work for manifest , so not open to the public yet
|
|
2003
|
-
fetch: new AsyncHook()
|
|
2011
|
+
fetch: new AsyncHook(),
|
|
2012
|
+
getModuleFactory: new AsyncHook()
|
|
2004
2013
|
});
|
|
2005
2014
|
// TODO: Validate the details of the options
|
|
2006
2015
|
// Initialize options with default values
|
package/dist/package.json
CHANGED
package/dist/share.cjs.js
CHANGED
|
@@ -9,6 +9,8 @@ function getBuilderId() {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
const LOG_CATEGORY = '[ Federation Runtime ]';
|
|
12
|
+
// FIXME: pre-bundle ?
|
|
13
|
+
const logger = sdk.createLogger(LOG_CATEGORY);
|
|
12
14
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
13
15
|
function assert(condition, msg) {
|
|
14
16
|
if (!condition) {
|
|
@@ -25,9 +27,9 @@ function error(msg) {
|
|
|
25
27
|
function warn(msg) {
|
|
26
28
|
if (msg instanceof Error) {
|
|
27
29
|
msg.message = `${LOG_CATEGORY}: ${msg.message}`;
|
|
28
|
-
|
|
30
|
+
logger.warn(msg);
|
|
29
31
|
} else {
|
|
30
|
-
|
|
32
|
+
logger.warn(msg);
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
|
|
@@ -175,7 +177,7 @@ function getGlobalFederationConstructor() {
|
|
|
175
177
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = sdk.isDebugMode()) {
|
|
176
178
|
if (isDebug) {
|
|
177
179
|
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
178
|
-
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.
|
|
180
|
+
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.15";
|
|
179
181
|
}
|
|
180
182
|
}
|
|
181
183
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -896,6 +898,7 @@ exports.isObject = isObject;
|
|
|
896
898
|
exports.isPlainObject = isPlainObject;
|
|
897
899
|
exports.isPureRemoteEntry = isPureRemoteEntry;
|
|
898
900
|
exports.isRemoteInfoWithEntry = isRemoteInfoWithEntry;
|
|
901
|
+
exports.logger = logger;
|
|
899
902
|
exports.nativeGlobal = nativeGlobal;
|
|
900
903
|
exports.registerGlobalPlugins = registerGlobalPlugins;
|
|
901
904
|
exports.resetFederationGlobalInfo = resetFederationGlobalInfo;
|
package/dist/share.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ as _object_without_properties_loose, a as _extends } from './polyfills.esm.js';
|
|
2
|
-
import { isBrowserEnv, isDebugMode } from '@module-federation/sdk';
|
|
2
|
+
import { createLogger, isBrowserEnv, isDebugMode } from '@module-federation/sdk';
|
|
3
3
|
|
|
4
4
|
function getBuilderId() {
|
|
5
5
|
//@ts-ignore
|
|
@@ -7,6 +7,8 @@ function getBuilderId() {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
const LOG_CATEGORY = '[ Federation Runtime ]';
|
|
10
|
+
// FIXME: pre-bundle ?
|
|
11
|
+
const logger = createLogger(LOG_CATEGORY);
|
|
10
12
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
11
13
|
function assert(condition, msg) {
|
|
12
14
|
if (!condition) {
|
|
@@ -23,9 +25,9 @@ function error(msg) {
|
|
|
23
25
|
function warn(msg) {
|
|
24
26
|
if (msg instanceof Error) {
|
|
25
27
|
msg.message = `${LOG_CATEGORY}: ${msg.message}`;
|
|
26
|
-
|
|
28
|
+
logger.warn(msg);
|
|
27
29
|
} else {
|
|
28
|
-
|
|
30
|
+
logger.warn(msg);
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
|
|
@@ -173,7 +175,7 @@ function getGlobalFederationConstructor() {
|
|
|
173
175
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
|
|
174
176
|
if (isDebug) {
|
|
175
177
|
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
176
|
-
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.
|
|
178
|
+
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.15";
|
|
177
179
|
}
|
|
178
180
|
}
|
|
179
181
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -865,4 +867,4 @@ function getTargetSharedOptions(options) {
|
|
|
865
867
|
return Object.assign({}, resolver(shareInfos[pkgName]), extraOptions == null ? void 0 : extraOptions.customShareInfo);
|
|
866
868
|
}
|
|
867
869
|
|
|
868
|
-
export {
|
|
870
|
+
export { warn as A, isPlainObject as B, isRemoteInfoWithEntry as C, DEFAULT_REMOTE_TYPE as D, isPureRemoteEntry as E, getRemoteEntryInfoFromSnapshot as F, Global as G, arrayOptions as H, formatShareConfigs as I, getTargetSharedOptions as J, addUniqueItem as K, getBuilderId as L, getGlobalShareScope as a, getGlobalFederationInstance as b, getGlobalFederationConstructor as c, setGlobalFederationConstructor as d, getInfoWithoutType as e, getGlobalSnapshot as f, getRegisteredShare as g, getTargetSnapshotInfoByModuleInfo as h, getGlobalSnapshotInfoByModuleInfo as i, setGlobalSnapshotInfoByModuleInfo as j, addGlobalSnapshot as k, getRemoteEntryExports as l, registerGlobalPlugins as m, nativeGlobal as n, getGlobalHostPlugins as o, getPreloaded as p, setPreloaded as q, resetFederationGlobalInfo as r, setGlobalFederationInstance as s, globalLoading as t, DEFAULT_SCOPE as u, assert as v, logger as w, getFMId as x, isObject as y, error as z };
|
package/dist/src/core.d.ts
CHANGED
|
@@ -60,6 +60,11 @@ export declare class FederationHost {
|
|
|
60
60
|
attrs?: Record<string, any>;
|
|
61
61
|
}], void | HTMLLinkElement>;
|
|
62
62
|
fetch: AsyncHook<[string, RequestInit], false | void | Promise<Response>>;
|
|
63
|
+
getModuleFactory: AsyncHook<[{
|
|
64
|
+
remoteEntryExports: RemoteEntryExports;
|
|
65
|
+
expose: string;
|
|
66
|
+
moduleInfo: RemoteInfo;
|
|
67
|
+
}], Promise<(() => Promise<Module>) | undefined>>;
|
|
63
68
|
}>;
|
|
64
69
|
constructor(userOptions: UserOptions);
|
|
65
70
|
initOptions(userOptions: UserOptions): Options;
|
package/dist/src/embedded.d.ts
CHANGED
|
@@ -72,6 +72,11 @@ export declare class FederationHost implements IndexModule.FederationHost {
|
|
|
72
72
|
attrs?: Record<string, any>;
|
|
73
73
|
}], void | HTMLLinkElement>;
|
|
74
74
|
fetch: import("./utils/hooks").AsyncHook<[string, RequestInit], false | void | Promise<Response>>;
|
|
75
|
+
getModuleFactory: import("./utils/hooks").AsyncHook<[{
|
|
76
|
+
remoteEntryExports: import("./type").RemoteEntryExports;
|
|
77
|
+
expose: string;
|
|
78
|
+
moduleInfo: import("./type").RemoteInfo;
|
|
79
|
+
}], Promise<(() => Promise<IndexModule.Module>) | undefined>>;
|
|
75
80
|
}>;
|
|
76
81
|
initOptions(...args: Parameters<IndexModule.FederationHost['initOptions']>): import("./type").Options;
|
|
77
82
|
loadShare<T>(...args: Parameters<IndexModule.FederationHost['loadShare']>): Promise<false | (() => T | undefined)>;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
declare const logger: import("@module-federation/sdk").Logger;
|
|
1
2
|
export declare function assert(condition: any, msg: string): asserts condition;
|
|
2
3
|
export declare function error(msg: string | Error | unknown): never;
|
|
3
4
|
export declare function warn(msg: Parameters<typeof console.warn>[0]): void;
|
|
5
|
+
export declare function log(...args: unknown[]): void;
|
|
6
|
+
export { logger };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/runtime",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.15",
|
|
4
4
|
"author": "zhouxiao <codingzx@gmail.com>",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -50,6 +50,6 @@
|
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@module-federation/sdk": "0.6.
|
|
53
|
+
"@module-federation/sdk": "0.6.15"
|
|
54
54
|
}
|
|
55
55
|
}
|