@module-federation/runtime 0.0.0-next-20240306063912 → 0.0.0-next-20240306224838
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 +22 -3
- package/dist/index.esm.js +19 -4
- package/dist/package.json +1 -1
- package/dist/share.cjs.js +11 -2
- package/dist/share.esm.js +11 -2
- package/dist/src/core.d.ts +1 -0
- package/dist/src/index.d.ts +1 -1
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -107,7 +107,10 @@ async function loadEsmEntry({ entry, remoteEntryExports }) {
|
|
|
107
107
|
try {
|
|
108
108
|
if (!remoteEntryExports) {
|
|
109
109
|
// eslint-disable-next-line no-eval
|
|
110
|
-
new Function('
|
|
110
|
+
new Function('callbacks', `import("${entry}").then(callbacks[0]).catch(callbacks[1])`)([
|
|
111
|
+
resolve,
|
|
112
|
+
reject
|
|
113
|
+
]);
|
|
111
114
|
} else {
|
|
112
115
|
resolve(remoteEntryExports);
|
|
113
116
|
}
|
|
@@ -136,7 +139,6 @@ async function loadEntryScript({ name, globalName, entry, createScriptHook }) {
|
|
|
136
139
|
1. '${entry}' is not the correct URL, or the remoteEntry resource or name is incorrect.\n
|
|
137
140
|
2. ${remoteEntryKey} cannot be used to get remoteEntry exports in the window object.
|
|
138
141
|
`);
|
|
139
|
-
console.log(entryExports);
|
|
140
142
|
return entryExports;
|
|
141
143
|
}).catch((e)=>{
|
|
142
144
|
return e;
|
|
@@ -1276,6 +1278,19 @@ class FederationHost {
|
|
|
1276
1278
|
2. The ${pkgName} share was not registered with the 'lib' attribute.\n
|
|
1277
1279
|
`);
|
|
1278
1280
|
}
|
|
1281
|
+
initRawContainer(name, url, container) {
|
|
1282
|
+
const remoteInfo = getRemoteInfo({
|
|
1283
|
+
name,
|
|
1284
|
+
entry: url
|
|
1285
|
+
});
|
|
1286
|
+
const module = new Module({
|
|
1287
|
+
host: this,
|
|
1288
|
+
remoteInfo
|
|
1289
|
+
});
|
|
1290
|
+
module.remoteEntryExports = container;
|
|
1291
|
+
this.moduleCache.set(name, module);
|
|
1292
|
+
return module;
|
|
1293
|
+
}
|
|
1279
1294
|
async _getRemoteModuleAndOptions(id) {
|
|
1280
1295
|
const loadRemoteArgs = await this.hooks.lifecycle.beforeRequest.emit({
|
|
1281
1296
|
id,
|
|
@@ -1590,7 +1605,7 @@ class FederationHost {
|
|
|
1590
1605
|
// not used yet
|
|
1591
1606
|
afterPreloadRemote: new AsyncHook()
|
|
1592
1607
|
});
|
|
1593
|
-
this.version = "0.0.
|
|
1608
|
+
this.version = "0.0.14";
|
|
1594
1609
|
this.moduleCache = new Map();
|
|
1595
1610
|
this.loaderHook = new PluginSystem({
|
|
1596
1611
|
// FIXME: may not be suitable , not open to the public yet
|
|
@@ -1673,6 +1688,10 @@ Object.defineProperty(exports, 'loadScript', {
|
|
|
1673
1688
|
enumerable: true,
|
|
1674
1689
|
get: function () { return sdk.loadScript; }
|
|
1675
1690
|
});
|
|
1691
|
+
Object.defineProperty(exports, 'loadScriptNode', {
|
|
1692
|
+
enumerable: true,
|
|
1693
|
+
get: function () { return sdk.loadScriptNode; }
|
|
1694
|
+
});
|
|
1676
1695
|
exports.FederationHost = FederationHost;
|
|
1677
1696
|
exports.init = init;
|
|
1678
1697
|
exports.loadRemote = loadRemote;
|
package/dist/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { g as getGlobalHostPlugins, D as DEFAULT_REMOTE_TYPE, a as DEFAULT_SCOPE, b as globalLoading, c as getRemoteEntryExports, d as assert, s as safeToString, e as getFMId, i as isObject, f as error, w as warn, h as isPlainObject, j as isRemoteInfoWithEntry, k as isPureRemoteEntry, l as getRegisteredShare, m as getInfoWithoutType, n as getPreloaded, o as setPreloaded, p as getGlobalSnapshotInfoByModuleInfo, q as addGlobalSnapshot, r as setGlobalSnapshotInfoByModuleInfo, t as getGlobalSnapshot, G as Global, u as getGlobalShareScope, v as formatShareConfigs, x as isBrowserEnv, y as getBuilderId, z as addUniqueItem, A as setGlobalFederationConstructor, B as getGlobalFederationInstance, C as getGlobalFederationConstructor, E as setGlobalFederationInstance } from './share.esm.js';
|
|
2
2
|
export { F as registerGlobalPlugins } from './share.esm.js';
|
|
3
3
|
import { composeKeyWithSeparator, loadScriptNode, loadScript, createLink, getResourceUrl, isManifestProvider, generateSnapshotFromManifest } from '@module-federation/sdk';
|
|
4
|
-
export { loadScript } from '@module-federation/sdk';
|
|
4
|
+
export { loadScript, loadScriptNode } from '@module-federation/sdk';
|
|
5
5
|
|
|
6
6
|
// Function to match a remote with its name and expose
|
|
7
7
|
// id: pkgName(@federation/app1) + expose(button) = @federation/app1/button
|
|
@@ -105,7 +105,10 @@ async function loadEsmEntry({ entry, remoteEntryExports }) {
|
|
|
105
105
|
try {
|
|
106
106
|
if (!remoteEntryExports) {
|
|
107
107
|
// eslint-disable-next-line no-eval
|
|
108
|
-
new Function('
|
|
108
|
+
new Function('callbacks', `import("${entry}").then(callbacks[0]).catch(callbacks[1])`)([
|
|
109
|
+
resolve,
|
|
110
|
+
reject
|
|
111
|
+
]);
|
|
109
112
|
} else {
|
|
110
113
|
resolve(remoteEntryExports);
|
|
111
114
|
}
|
|
@@ -134,7 +137,6 @@ async function loadEntryScript({ name, globalName, entry, createScriptHook }) {
|
|
|
134
137
|
1. '${entry}' is not the correct URL, or the remoteEntry resource or name is incorrect.\n
|
|
135
138
|
2. ${remoteEntryKey} cannot be used to get remoteEntry exports in the window object.
|
|
136
139
|
`);
|
|
137
|
-
console.log(entryExports);
|
|
138
140
|
return entryExports;
|
|
139
141
|
}).catch((e)=>{
|
|
140
142
|
return e;
|
|
@@ -1274,6 +1276,19 @@ class FederationHost {
|
|
|
1274
1276
|
2. The ${pkgName} share was not registered with the 'lib' attribute.\n
|
|
1275
1277
|
`);
|
|
1276
1278
|
}
|
|
1279
|
+
initRawContainer(name, url, container) {
|
|
1280
|
+
const remoteInfo = getRemoteInfo({
|
|
1281
|
+
name,
|
|
1282
|
+
entry: url
|
|
1283
|
+
});
|
|
1284
|
+
const module = new Module({
|
|
1285
|
+
host: this,
|
|
1286
|
+
remoteInfo
|
|
1287
|
+
});
|
|
1288
|
+
module.remoteEntryExports = container;
|
|
1289
|
+
this.moduleCache.set(name, module);
|
|
1290
|
+
return module;
|
|
1291
|
+
}
|
|
1277
1292
|
async _getRemoteModuleAndOptions(id) {
|
|
1278
1293
|
const loadRemoteArgs = await this.hooks.lifecycle.beforeRequest.emit({
|
|
1279
1294
|
id,
|
|
@@ -1588,7 +1603,7 @@ class FederationHost {
|
|
|
1588
1603
|
// not used yet
|
|
1589
1604
|
afterPreloadRemote: new AsyncHook()
|
|
1590
1605
|
});
|
|
1591
|
-
this.version = "0.0.
|
|
1606
|
+
this.version = "0.0.14";
|
|
1592
1607
|
this.moduleCache = new Map();
|
|
1593
1608
|
this.loaderHook = new PluginSystem({
|
|
1594
1609
|
// FIXME: may not be suitable , not open to the public yet
|
package/dist/package.json
CHANGED
package/dist/share.cjs.js
CHANGED
|
@@ -19,10 +19,19 @@ function assert(condition, msg) {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
function error(msg) {
|
|
22
|
+
if (msg instanceof Error) {
|
|
23
|
+
msg.message = `${LOG_CATEGORY}: ${msg.message}`;
|
|
24
|
+
throw msg;
|
|
25
|
+
}
|
|
22
26
|
throw new Error(`${LOG_CATEGORY}: ${msg}`);
|
|
23
27
|
}
|
|
24
28
|
function warn(msg) {
|
|
25
|
-
|
|
29
|
+
if (msg instanceof Error) {
|
|
30
|
+
msg.message = `${LOG_CATEGORY}: ${msg.message}`;
|
|
31
|
+
console.warn(msg);
|
|
32
|
+
} else {
|
|
33
|
+
console.warn(`${LOG_CATEGORY}: ${msg}`);
|
|
34
|
+
}
|
|
26
35
|
}
|
|
27
36
|
|
|
28
37
|
function addUniqueItem(arr, item) {
|
|
@@ -176,7 +185,7 @@ function getGlobalFederationConstructor() {
|
|
|
176
185
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
|
|
177
186
|
if (isDebug) {
|
|
178
187
|
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
179
|
-
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.
|
|
188
|
+
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.14";
|
|
180
189
|
}
|
|
181
190
|
}
|
|
182
191
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
package/dist/share.esm.js
CHANGED
|
@@ -17,10 +17,19 @@ function assert(condition, msg) {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
function error(msg) {
|
|
20
|
+
if (msg instanceof Error) {
|
|
21
|
+
msg.message = `${LOG_CATEGORY}: ${msg.message}`;
|
|
22
|
+
throw msg;
|
|
23
|
+
}
|
|
20
24
|
throw new Error(`${LOG_CATEGORY}: ${msg}`);
|
|
21
25
|
}
|
|
22
26
|
function warn(msg) {
|
|
23
|
-
|
|
27
|
+
if (msg instanceof Error) {
|
|
28
|
+
msg.message = `${LOG_CATEGORY}: ${msg.message}`;
|
|
29
|
+
console.warn(msg);
|
|
30
|
+
} else {
|
|
31
|
+
console.warn(`${LOG_CATEGORY}: ${msg}`);
|
|
32
|
+
}
|
|
24
33
|
}
|
|
25
34
|
|
|
26
35
|
function addUniqueItem(arr, item) {
|
|
@@ -174,7 +183,7 @@ function getGlobalFederationConstructor() {
|
|
|
174
183
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
|
|
175
184
|
if (isDebug) {
|
|
176
185
|
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
177
|
-
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.
|
|
186
|
+
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.14";
|
|
178
187
|
}
|
|
179
188
|
}
|
|
180
189
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
package/dist/src/core.d.ts
CHANGED
|
@@ -136,6 +136,7 @@ export declare class FederationHost {
|
|
|
136
136
|
initOptions(userOptions: UserOptions): Options;
|
|
137
137
|
loadShare<T>(pkgName: string, customShareInfo?: Partial<Shared>): Promise<false | (() => T | undefined)>;
|
|
138
138
|
loadShareSync<T>(pkgName: string, customShareInfo?: Partial<Shared>): () => T | never;
|
|
139
|
+
initRawContainer(name: string, url: string, container: RemoteEntryExports): Module;
|
|
139
140
|
private _getRemoteModuleAndOptions;
|
|
140
141
|
loadRemote<T>(id: string, options?: {
|
|
141
142
|
loadFactory?: boolean;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { FederationHost } from './core';
|
|
|
2
2
|
import { UserOptions, FederationRuntimePlugin } from './type';
|
|
3
3
|
export { FederationHost } from './core';
|
|
4
4
|
export { registerGlobalPlugins } from './global';
|
|
5
|
-
export { loadScript } from '@module-federation/sdk';
|
|
5
|
+
export { loadScript, loadScriptNode } from '@module-federation/sdk';
|
|
6
6
|
export type { Federation } from './global';
|
|
7
7
|
export type { FederationRuntimePlugin };
|
|
8
8
|
export declare function init(options: UserOptions): FederationHost;
|
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-20240306224838",
|
|
4
4
|
"author": "zhouxiao <codingzx@gmail.com>",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
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-20240306224838"
|
|
49
49
|
}
|
|
50
50
|
}
|