@module-federation/runtime 0.0.0-next-20240905232541 → 0.0.0-next-20240909062831
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/helpers.cjs.js +1 -2
- package/dist/helpers.esm.js +1 -2
- package/dist/index.cjs.js +18 -16
- package/dist/index.esm.js +18 -17
- package/dist/package.json +2 -3
- package/dist/polyfills.cjs.js +28 -0
- package/dist/polyfills.esm.js +25 -0
- package/dist/share.cjs.js +7 -8
- package/dist/share.esm.js +7 -8
- package/dist/src/core.d.ts +3 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/module/index.d.ts +2 -1
- package/dist/src/remote/index.d.ts +2 -2
- package/package.json +2 -3
package/dist/helpers.cjs.js
CHANGED
package/dist/helpers.esm.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { o as getRegisteredShare, y as getGlobalShareScope, G as Global, I as nativeGlobal, J as resetFederationGlobalInfo, C as getGlobalFederationInstance, F as setGlobalFederationInstance, E as getGlobalFederationConstructor, B as setGlobalFederationConstructor, m as getInfoWithoutType, u as getGlobalSnapshot, K as getTargetSnapshotInfoByModuleInfo, q as getGlobalSnapshotInfoByModuleInfo, t as setGlobalSnapshotInfoByModuleInfo, r as addGlobalSnapshot, c as getRemoteEntryExports, H as registerGlobalPlugins, g as getGlobalHostPlugins, n as getPreloaded, s as setPreloaded } from './share.esm.js';
|
|
2
|
-
import '
|
|
3
|
-
import '@swc/helpers/_/_object_without_properties_loose';
|
|
2
|
+
import './polyfills.esm.js';
|
|
4
3
|
import '@module-federation/sdk';
|
|
5
4
|
|
|
6
5
|
const ShareUtils = {
|
package/dist/index.cjs.js
CHANGED
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var polyfills = require('./polyfills.cjs.js');
|
|
6
6
|
var sdk = require('@module-federation/sdk');
|
|
7
7
|
var share = require('./share.cjs.js');
|
|
8
|
-
var _object_without_properties_loose = require('@swc/helpers/_/_object_without_properties_loose');
|
|
9
8
|
|
|
10
9
|
// Function to match a remote with its name and expose
|
|
11
10
|
// id: pkgName(@federation/app1) + expose(button) = @federation/app1/button
|
|
@@ -253,7 +252,7 @@ async function getRemoteEntry({ origin, remoteEntryExports, remoteInfo }) {
|
|
|
253
252
|
return share.globalLoading[uniqueKey];
|
|
254
253
|
}
|
|
255
254
|
function getRemoteInfo(remote) {
|
|
256
|
-
return _extends
|
|
255
|
+
return polyfills._extends({}, remote, {
|
|
257
256
|
entry: 'entry' in remote ? remote.entry : '',
|
|
258
257
|
type: remote.type || share.DEFAULT_REMOTE_TYPE,
|
|
259
258
|
entryGlobalName: remote.entryGlobalName || remote.name,
|
|
@@ -277,7 +276,7 @@ let Module = class Module {
|
|
|
277
276
|
return this.remoteEntryExports;
|
|
278
277
|
}
|
|
279
278
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
280
|
-
async get(id, expose, options) {
|
|
279
|
+
async get(id, expose, options, remoteSnapshot) {
|
|
281
280
|
const { loadFactory = true } = options || {
|
|
282
281
|
loadFactory: true
|
|
283
282
|
};
|
|
@@ -312,7 +311,9 @@ let Module = class Module {
|
|
|
312
311
|
console.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.');
|
|
313
312
|
}
|
|
314
313
|
await remoteEntryExports.init(initContainerOptions.shareScope, initContainerOptions.initScope, initContainerOptions.remoteEntryInitOptions);
|
|
315
|
-
await this.host.hooks.lifecycle.initContainer.emit(_extends
|
|
314
|
+
await this.host.hooks.lifecycle.initContainer.emit(polyfills._extends({}, initContainerOptions, {
|
|
315
|
+
id,
|
|
316
|
+
remoteSnapshot,
|
|
316
317
|
remoteEntryExports
|
|
317
318
|
}));
|
|
318
319
|
}
|
|
@@ -549,7 +550,7 @@ class PluginSystem {
|
|
|
549
550
|
}
|
|
550
551
|
|
|
551
552
|
function defaultPreloadArgs(preloadConfig) {
|
|
552
|
-
return _extends
|
|
553
|
+
return polyfills._extends({
|
|
553
554
|
resourceCategory: 'sync',
|
|
554
555
|
share: true,
|
|
555
556
|
depsRemote: true,
|
|
@@ -752,7 +753,7 @@ function snapshotPlugin() {
|
|
|
752
753
|
if (assets) {
|
|
753
754
|
preloadAssets(remoteInfo, origin, assets, false);
|
|
754
755
|
}
|
|
755
|
-
return _extends
|
|
756
|
+
return polyfills._extends({}, args, {
|
|
756
757
|
remoteSnapshot
|
|
757
758
|
});
|
|
758
759
|
}
|
|
@@ -1040,7 +1041,7 @@ class SnapshotHandler {
|
|
|
1040
1041
|
// This ensures the snapshot's integrity and helps the chrome plugin correctly identify all producer modules, ensuring that proxyable producer modules will not be missing.
|
|
1041
1042
|
if (hostSnapshot && 'remotesInfo' in hostSnapshot && !share.getInfoWithoutType(hostSnapshot.remotesInfo, moduleInfo.name).value) {
|
|
1042
1043
|
if ('version' in moduleInfo || 'entry' in moduleInfo) {
|
|
1043
|
-
hostSnapshot.remotesInfo = _extends
|
|
1044
|
+
hostSnapshot.remotesInfo = polyfills._extends({}, hostSnapshot == null ? void 0 : hostSnapshot.remotesInfo, {
|
|
1044
1045
|
[moduleInfo.name]: {
|
|
1045
1046
|
matchedVersion: 'version' in moduleInfo ? moduleInfo.version : moduleInfo.entry
|
|
1046
1047
|
}
|
|
@@ -1061,7 +1062,7 @@ class SnapshotHandler {
|
|
|
1061
1062
|
const remoteEntry = sdk.isBrowserEnv() ? globalRemoteSnapshot.remoteEntry : globalRemoteSnapshot.ssrRemoteEntry || globalRemoteSnapshot.remoteEntry || '';
|
|
1062
1063
|
const moduleSnapshot = await this.getManifestJson(remoteEntry, moduleInfo, {});
|
|
1063
1064
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
1064
|
-
const globalSnapshotRes = share.setGlobalSnapshotInfoByModuleInfo(_extends
|
|
1065
|
+
const globalSnapshotRes = share.setGlobalSnapshotInfoByModuleInfo(polyfills._extends({}, moduleInfo, {
|
|
1065
1066
|
// The global remote may be overridden
|
|
1066
1067
|
// Therefore, set the snapshot key to the global address of the actual request
|
|
1067
1068
|
entry: remoteEntry
|
|
@@ -1458,7 +1459,7 @@ class SharedHandler {
|
|
|
1458
1459
|
});
|
|
1459
1460
|
}
|
|
1460
1461
|
setShared({ pkgName, shared, from, lib, loading, loaded, get }) {
|
|
1461
|
-
const { version, scope = 'default' } = shared, shareInfo = _object_without_properties_loose
|
|
1462
|
+
const { version, scope = 'default' } = shared, shareInfo = polyfills._object_without_properties_loose(shared, [
|
|
1462
1463
|
"version",
|
|
1463
1464
|
"scope"
|
|
1464
1465
|
]);
|
|
@@ -1475,7 +1476,7 @@ class SharedHandler {
|
|
|
1475
1476
|
if (this.shareScopeMap[sc][pkgName][version]) {
|
|
1476
1477
|
return;
|
|
1477
1478
|
}
|
|
1478
|
-
this.shareScopeMap[sc][pkgName][version] = _extends
|
|
1479
|
+
this.shareScopeMap[sc][pkgName][version] = polyfills._extends({
|
|
1479
1480
|
version,
|
|
1480
1481
|
scope: [
|
|
1481
1482
|
'default'
|
|
@@ -1565,8 +1566,8 @@ class RemoteHandler {
|
|
|
1565
1566
|
const { module, moduleOptions, remoteMatchInfo } = await this.getRemoteModuleAndOptions({
|
|
1566
1567
|
id
|
|
1567
1568
|
});
|
|
1568
|
-
const { pkgNameOrAlias, remote, expose, id: idRes } = remoteMatchInfo;
|
|
1569
|
-
const moduleOrFactory = await module.get(idRes, expose, options);
|
|
1569
|
+
const { pkgNameOrAlias, remote, expose, id: idRes, remoteSnapshot } = remoteMatchInfo;
|
|
1570
|
+
const moduleOrFactory = await module.get(idRes, expose, options, remoteSnapshot);
|
|
1570
1571
|
const moduleWrapper = await this.hooks.lifecycle.onLoad.emit({
|
|
1571
1572
|
id: idRes,
|
|
1572
1573
|
pkgNameOrAlias,
|
|
@@ -1670,7 +1671,7 @@ class RemoteHandler {
|
|
|
1670
1671
|
`);
|
|
1671
1672
|
const { remote: rawRemote } = remoteSplitInfo;
|
|
1672
1673
|
const remoteInfo = getRemoteInfo(rawRemote);
|
|
1673
|
-
const matchInfo = await host.sharedHandler.hooks.lifecycle.afterResolve.emit(_extends
|
|
1674
|
+
const matchInfo = await host.sharedHandler.hooks.lifecycle.afterResolve.emit(polyfills._extends({
|
|
1674
1675
|
id: idRes
|
|
1675
1676
|
}, remoteSplitInfo, {
|
|
1676
1677
|
options: host.options,
|
|
@@ -1935,7 +1936,7 @@ class FederationHost {
|
|
|
1935
1936
|
}
|
|
1936
1937
|
});
|
|
1937
1938
|
}
|
|
1938
|
-
const optionsRes = _extends
|
|
1939
|
+
const optionsRes = polyfills._extends({}, globalOptions, userOptions, {
|
|
1939
1940
|
plugins,
|
|
1940
1941
|
remotes,
|
|
1941
1942
|
shared: handledShared
|
|
@@ -1975,7 +1976,7 @@ class FederationHost {
|
|
|
1975
1976
|
// maybe will change, temporarily for internal use only
|
|
1976
1977
|
initContainer: new AsyncWaterfallHook('initContainer')
|
|
1977
1978
|
});
|
|
1978
|
-
this.version = "0.6.
|
|
1979
|
+
this.version = "0.6.1";
|
|
1979
1980
|
this.moduleCache = new Map();
|
|
1980
1981
|
this.loaderHook = new PluginSystem({
|
|
1981
1982
|
// FIXME: may not be suitable , not open to the public yet
|
|
@@ -2080,6 +2081,7 @@ Object.defineProperty(exports, 'loadScriptNode', {
|
|
|
2080
2081
|
});
|
|
2081
2082
|
exports.registerGlobalPlugins = share.registerGlobalPlugins;
|
|
2082
2083
|
exports.FederationHost = FederationHost;
|
|
2084
|
+
exports.Module = Module;
|
|
2083
2085
|
exports.getInstance = getInstance;
|
|
2084
2086
|
exports.getRemoteEntry = getRemoteEntry;
|
|
2085
2087
|
exports.getRemoteInfo = getRemoteInfo;
|
package/dist/index.esm.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { _ } from '
|
|
1
|
+
import { _ as _extends, a 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
4
|
import { g as getGlobalHostPlugins, a as globalLoading, D as DEFAULT_REMOTE_TYPE, b as DEFAULT_SCOPE, c as getRemoteEntryExports, d as assert, e as getFMId, i as isObject, f as error, w as warn, h as isPlainObject, j as isRemoteInfoWithEntry, k as isPureRemoteEntry, l as getRemoteEntryInfoFromSnapshot, m as getInfoWithoutType, n as getPreloaded, s as setPreloaded, o as getRegisteredShare, p as arrayOptions, q as getGlobalSnapshotInfoByModuleInfo, r as addGlobalSnapshot, t as setGlobalSnapshotInfoByModuleInfo, G as Global, u as getGlobalSnapshot, v as formatShareConfigs, x as getTargetSharedOptions, y as getGlobalShareScope, z as addUniqueItem, A as getBuilderId, B as setGlobalFederationConstructor, C as getGlobalFederationInstance, E as getGlobalFederationConstructor, F as setGlobalFederationInstance } from './share.esm.js';
|
|
5
5
|
export { H as registerGlobalPlugins } from './share.esm.js';
|
|
6
|
-
import { _ as _$1 } from '@swc/helpers/_/_object_without_properties_loose';
|
|
7
6
|
|
|
8
7
|
// Function to match a remote with its name and expose
|
|
9
8
|
// id: pkgName(@federation/app1) + expose(button) = @federation/app1/button
|
|
@@ -251,7 +250,7 @@ async function getRemoteEntry({ origin, remoteEntryExports, remoteInfo }) {
|
|
|
251
250
|
return globalLoading[uniqueKey];
|
|
252
251
|
}
|
|
253
252
|
function getRemoteInfo(remote) {
|
|
254
|
-
return
|
|
253
|
+
return _extends({}, remote, {
|
|
255
254
|
entry: 'entry' in remote ? remote.entry : '',
|
|
256
255
|
type: remote.type || DEFAULT_REMOTE_TYPE,
|
|
257
256
|
entryGlobalName: remote.entryGlobalName || remote.name,
|
|
@@ -275,7 +274,7 @@ let Module = class Module {
|
|
|
275
274
|
return this.remoteEntryExports;
|
|
276
275
|
}
|
|
277
276
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
278
|
-
async get(id, expose, options) {
|
|
277
|
+
async get(id, expose, options, remoteSnapshot) {
|
|
279
278
|
const { loadFactory = true } = options || {
|
|
280
279
|
loadFactory: true
|
|
281
280
|
};
|
|
@@ -310,7 +309,9 @@ let Module = class Module {
|
|
|
310
309
|
console.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.');
|
|
311
310
|
}
|
|
312
311
|
await remoteEntryExports.init(initContainerOptions.shareScope, initContainerOptions.initScope, initContainerOptions.remoteEntryInitOptions);
|
|
313
|
-
await this.host.hooks.lifecycle.initContainer.emit(
|
|
312
|
+
await this.host.hooks.lifecycle.initContainer.emit(_extends({}, initContainerOptions, {
|
|
313
|
+
id,
|
|
314
|
+
remoteSnapshot,
|
|
314
315
|
remoteEntryExports
|
|
315
316
|
}));
|
|
316
317
|
}
|
|
@@ -547,7 +548,7 @@ class PluginSystem {
|
|
|
547
548
|
}
|
|
548
549
|
|
|
549
550
|
function defaultPreloadArgs(preloadConfig) {
|
|
550
|
-
return
|
|
551
|
+
return _extends({
|
|
551
552
|
resourceCategory: 'sync',
|
|
552
553
|
share: true,
|
|
553
554
|
depsRemote: true,
|
|
@@ -750,7 +751,7 @@ function snapshotPlugin() {
|
|
|
750
751
|
if (assets) {
|
|
751
752
|
preloadAssets(remoteInfo, origin, assets, false);
|
|
752
753
|
}
|
|
753
|
-
return
|
|
754
|
+
return _extends({}, args, {
|
|
754
755
|
remoteSnapshot
|
|
755
756
|
});
|
|
756
757
|
}
|
|
@@ -1038,7 +1039,7 @@ class SnapshotHandler {
|
|
|
1038
1039
|
// This ensures the snapshot's integrity and helps the chrome plugin correctly identify all producer modules, ensuring that proxyable producer modules will not be missing.
|
|
1039
1040
|
if (hostSnapshot && 'remotesInfo' in hostSnapshot && !getInfoWithoutType(hostSnapshot.remotesInfo, moduleInfo.name).value) {
|
|
1040
1041
|
if ('version' in moduleInfo || 'entry' in moduleInfo) {
|
|
1041
|
-
hostSnapshot.remotesInfo =
|
|
1042
|
+
hostSnapshot.remotesInfo = _extends({}, hostSnapshot == null ? void 0 : hostSnapshot.remotesInfo, {
|
|
1042
1043
|
[moduleInfo.name]: {
|
|
1043
1044
|
matchedVersion: 'version' in moduleInfo ? moduleInfo.version : moduleInfo.entry
|
|
1044
1045
|
}
|
|
@@ -1059,7 +1060,7 @@ class SnapshotHandler {
|
|
|
1059
1060
|
const remoteEntry = isBrowserEnv() ? globalRemoteSnapshot.remoteEntry : globalRemoteSnapshot.ssrRemoteEntry || globalRemoteSnapshot.remoteEntry || '';
|
|
1060
1061
|
const moduleSnapshot = await this.getManifestJson(remoteEntry, moduleInfo, {});
|
|
1061
1062
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
1062
|
-
const globalSnapshotRes = setGlobalSnapshotInfoByModuleInfo(
|
|
1063
|
+
const globalSnapshotRes = setGlobalSnapshotInfoByModuleInfo(_extends({}, moduleInfo, {
|
|
1063
1064
|
// The global remote may be overridden
|
|
1064
1065
|
// Therefore, set the snapshot key to the global address of the actual request
|
|
1065
1066
|
entry: remoteEntry
|
|
@@ -1456,7 +1457,7 @@ class SharedHandler {
|
|
|
1456
1457
|
});
|
|
1457
1458
|
}
|
|
1458
1459
|
setShared({ pkgName, shared, from, lib, loading, loaded, get }) {
|
|
1459
|
-
const { version, scope = 'default' } = shared, shareInfo =
|
|
1460
|
+
const { version, scope = 'default' } = shared, shareInfo = _object_without_properties_loose(shared, [
|
|
1460
1461
|
"version",
|
|
1461
1462
|
"scope"
|
|
1462
1463
|
]);
|
|
@@ -1473,7 +1474,7 @@ class SharedHandler {
|
|
|
1473
1474
|
if (this.shareScopeMap[sc][pkgName][version]) {
|
|
1474
1475
|
return;
|
|
1475
1476
|
}
|
|
1476
|
-
this.shareScopeMap[sc][pkgName][version] =
|
|
1477
|
+
this.shareScopeMap[sc][pkgName][version] = _extends({
|
|
1477
1478
|
version,
|
|
1478
1479
|
scope: [
|
|
1479
1480
|
'default'
|
|
@@ -1563,8 +1564,8 @@ class RemoteHandler {
|
|
|
1563
1564
|
const { module, moduleOptions, remoteMatchInfo } = await this.getRemoteModuleAndOptions({
|
|
1564
1565
|
id
|
|
1565
1566
|
});
|
|
1566
|
-
const { pkgNameOrAlias, remote, expose, id: idRes } = remoteMatchInfo;
|
|
1567
|
-
const moduleOrFactory = await module.get(idRes, expose, options);
|
|
1567
|
+
const { pkgNameOrAlias, remote, expose, id: idRes, remoteSnapshot } = remoteMatchInfo;
|
|
1568
|
+
const moduleOrFactory = await module.get(idRes, expose, options, remoteSnapshot);
|
|
1568
1569
|
const moduleWrapper = await this.hooks.lifecycle.onLoad.emit({
|
|
1569
1570
|
id: idRes,
|
|
1570
1571
|
pkgNameOrAlias,
|
|
@@ -1668,7 +1669,7 @@ class RemoteHandler {
|
|
|
1668
1669
|
`);
|
|
1669
1670
|
const { remote: rawRemote } = remoteSplitInfo;
|
|
1670
1671
|
const remoteInfo = getRemoteInfo(rawRemote);
|
|
1671
|
-
const matchInfo = await host.sharedHandler.hooks.lifecycle.afterResolve.emit(
|
|
1672
|
+
const matchInfo = await host.sharedHandler.hooks.lifecycle.afterResolve.emit(_extends({
|
|
1672
1673
|
id: idRes
|
|
1673
1674
|
}, remoteSplitInfo, {
|
|
1674
1675
|
options: host.options,
|
|
@@ -1933,7 +1934,7 @@ class FederationHost {
|
|
|
1933
1934
|
}
|
|
1934
1935
|
});
|
|
1935
1936
|
}
|
|
1936
|
-
const optionsRes =
|
|
1937
|
+
const optionsRes = _extends({}, globalOptions, userOptions, {
|
|
1937
1938
|
plugins,
|
|
1938
1939
|
remotes,
|
|
1939
1940
|
shared: handledShared
|
|
@@ -1973,7 +1974,7 @@ class FederationHost {
|
|
|
1973
1974
|
// maybe will change, temporarily for internal use only
|
|
1974
1975
|
initContainer: new AsyncWaterfallHook('initContainer')
|
|
1975
1976
|
});
|
|
1976
|
-
this.version = "0.6.
|
|
1977
|
+
this.version = "0.6.1";
|
|
1977
1978
|
this.moduleCache = new Map();
|
|
1978
1979
|
this.loaderHook = new PluginSystem({
|
|
1979
1980
|
// FIXME: may not be suitable , not open to the public yet
|
|
@@ -2068,4 +2069,4 @@ function getInstance() {
|
|
|
2068
2069
|
// Inject for debug
|
|
2069
2070
|
setGlobalFederationConstructor(FederationHost);
|
|
2070
2071
|
|
|
2071
|
-
export { FederationHost, getInstance, getRemoteEntry, getRemoteInfo, init, loadRemote, loadShare, loadShareSync, preloadRemote, registerPlugins, registerRemotes };
|
|
2072
|
+
export { FederationHost, Module, getInstance, getRemoteEntry, getRemoteInfo, init, loadRemote, loadShare, loadShareSync, preloadRemote, registerPlugins, registerRemotes };
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/runtime",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"author": "zhouxiao <codingzx@gmail.com>",
|
|
5
5
|
"main": "./index.cjs.js",
|
|
6
6
|
"module": "./index.esm.js",
|
|
@@ -50,7 +50,6 @@
|
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@module-federation/sdk": "workspace:*"
|
|
54
|
-
"@swc/helpers": "^0.5.0"
|
|
53
|
+
"@module-federation/sdk": "workspace:*"
|
|
55
54
|
}
|
|
56
55
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function _extends() {
|
|
4
|
+
_extends = Object.assign || function assign(target) {
|
|
5
|
+
for(var i = 1; i < arguments.length; i++){
|
|
6
|
+
var source = arguments[i];
|
|
7
|
+
for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
8
|
+
}
|
|
9
|
+
return target;
|
|
10
|
+
};
|
|
11
|
+
return _extends.apply(this, arguments);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function _object_without_properties_loose(source, excluded) {
|
|
15
|
+
if (source == null) return {};
|
|
16
|
+
var target = {};
|
|
17
|
+
var sourceKeys = Object.keys(source);
|
|
18
|
+
var key, i;
|
|
19
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
20
|
+
key = sourceKeys[i];
|
|
21
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
22
|
+
target[key] = source[key];
|
|
23
|
+
}
|
|
24
|
+
return target;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports._extends = _extends;
|
|
28
|
+
exports._object_without_properties_loose = _object_without_properties_loose;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
function _extends() {
|
|
2
|
+
_extends = Object.assign || function assign(target) {
|
|
3
|
+
for(var i = 1; i < arguments.length; i++){
|
|
4
|
+
var source = arguments[i];
|
|
5
|
+
for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
6
|
+
}
|
|
7
|
+
return target;
|
|
8
|
+
};
|
|
9
|
+
return _extends.apply(this, arguments);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function _object_without_properties_loose(source, excluded) {
|
|
13
|
+
if (source == null) return {};
|
|
14
|
+
var target = {};
|
|
15
|
+
var sourceKeys = Object.keys(source);
|
|
16
|
+
var key, i;
|
|
17
|
+
for(i = 0; i < sourceKeys.length; i++){
|
|
18
|
+
key = sourceKeys[i];
|
|
19
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
20
|
+
target[key] = source[key];
|
|
21
|
+
}
|
|
22
|
+
return target;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { _extends as _, _object_without_properties_loose as a };
|
package/dist/share.cjs.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var _object_without_properties_loose = require('@swc/helpers/_/_object_without_properties_loose');
|
|
3
|
+
var polyfills = require('./polyfills.cjs.js');
|
|
5
4
|
var sdk = require('@module-federation/sdk');
|
|
6
5
|
|
|
7
6
|
function getBuilderId() {
|
|
@@ -176,7 +175,7 @@ function getGlobalFederationConstructor() {
|
|
|
176
175
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = sdk.isDebugMode()) {
|
|
177
176
|
if (isDebug) {
|
|
178
177
|
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
179
|
-
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.
|
|
178
|
+
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.1";
|
|
180
179
|
}
|
|
181
180
|
}
|
|
182
181
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -224,7 +223,7 @@ const getTargetSnapshotInfoByModuleInfo = (moduleInfo, snapshot)=>{
|
|
|
224
223
|
}
|
|
225
224
|
// If the remote is not included in the hostSnapshot, deploy a micro app snapshot
|
|
226
225
|
if ('version' in moduleInfo && moduleInfo['version']) {
|
|
227
|
-
const { version } = moduleInfo, resModuleInfo = _object_without_properties_loose
|
|
226
|
+
const { version } = moduleInfo, resModuleInfo = polyfills._object_without_properties_loose(moduleInfo, [
|
|
228
227
|
"version"
|
|
229
228
|
]);
|
|
230
229
|
const moduleKeyWithoutVersion = getFMId(resModuleInfo);
|
|
@@ -242,7 +241,7 @@ const setGlobalSnapshotInfoByModuleInfo = (remoteInfo, moduleDetailInfo)=>{
|
|
|
242
241
|
return nativeGlobal.__FEDERATION__.moduleInfo;
|
|
243
242
|
};
|
|
244
243
|
const addGlobalSnapshot = (moduleInfos)=>{
|
|
245
|
-
nativeGlobal.__FEDERATION__.moduleInfo = _extends
|
|
244
|
+
nativeGlobal.__FEDERATION__.moduleInfo = polyfills._extends({}, nativeGlobal.__FEDERATION__.moduleInfo, moduleInfos);
|
|
246
245
|
return ()=>{
|
|
247
246
|
const keys = Object.keys(moduleInfos);
|
|
248
247
|
for (const key of keys){
|
|
@@ -651,13 +650,13 @@ function formatShare(shareArgs, from, name, shareStrategy) {
|
|
|
651
650
|
warn(`"shared.strategy is deprecated, please set in initOptions.shareStrategy instead!"`);
|
|
652
651
|
}
|
|
653
652
|
var _shareArgs_version, _shareArgs_scope, _shareArgs_strategy;
|
|
654
|
-
return _extends
|
|
653
|
+
return polyfills._extends({
|
|
655
654
|
deps: [],
|
|
656
655
|
useIn: [],
|
|
657
656
|
from,
|
|
658
657
|
loading: null
|
|
659
658
|
}, shareArgs, {
|
|
660
|
-
shareConfig: _extends
|
|
659
|
+
shareConfig: polyfills._extends({
|
|
661
660
|
requiredVersion: `^${shareArgs.version}`,
|
|
662
661
|
singleton: false,
|
|
663
662
|
eager: false,
|
|
@@ -683,7 +682,7 @@ function formatShareConfigs(globalOptions, userOptions) {
|
|
|
683
682
|
});
|
|
684
683
|
return res;
|
|
685
684
|
}, {});
|
|
686
|
-
const shared = _extends
|
|
685
|
+
const shared = polyfills._extends({}, globalOptions.shared);
|
|
687
686
|
Object.keys(shareInfos).forEach((shareKey)=>{
|
|
688
687
|
if (!shared[shareKey]) {
|
|
689
688
|
shared[shareKey] = shareInfos[shareKey];
|
package/dist/share.esm.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { _ } from '@swc/helpers/_/_object_without_properties_loose';
|
|
1
|
+
import { a as _object_without_properties_loose, _ as _extends } from './polyfills.esm.js';
|
|
3
2
|
import { isBrowserEnv, isDebugMode } from '@module-federation/sdk';
|
|
4
3
|
|
|
5
4
|
function getBuilderId() {
|
|
@@ -174,7 +173,7 @@ function getGlobalFederationConstructor() {
|
|
|
174
173
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
|
|
175
174
|
if (isDebug) {
|
|
176
175
|
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
177
|
-
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.
|
|
176
|
+
globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.1";
|
|
178
177
|
}
|
|
179
178
|
}
|
|
180
179
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -222,7 +221,7 @@ const getTargetSnapshotInfoByModuleInfo = (moduleInfo, snapshot)=>{
|
|
|
222
221
|
}
|
|
223
222
|
// If the remote is not included in the hostSnapshot, deploy a micro app snapshot
|
|
224
223
|
if ('version' in moduleInfo && moduleInfo['version']) {
|
|
225
|
-
const { version } = moduleInfo, resModuleInfo =
|
|
224
|
+
const { version } = moduleInfo, resModuleInfo = _object_without_properties_loose(moduleInfo, [
|
|
226
225
|
"version"
|
|
227
226
|
]);
|
|
228
227
|
const moduleKeyWithoutVersion = getFMId(resModuleInfo);
|
|
@@ -240,7 +239,7 @@ const setGlobalSnapshotInfoByModuleInfo = (remoteInfo, moduleDetailInfo)=>{
|
|
|
240
239
|
return nativeGlobal.__FEDERATION__.moduleInfo;
|
|
241
240
|
};
|
|
242
241
|
const addGlobalSnapshot = (moduleInfos)=>{
|
|
243
|
-
nativeGlobal.__FEDERATION__.moduleInfo =
|
|
242
|
+
nativeGlobal.__FEDERATION__.moduleInfo = _extends({}, nativeGlobal.__FEDERATION__.moduleInfo, moduleInfos);
|
|
244
243
|
return ()=>{
|
|
245
244
|
const keys = Object.keys(moduleInfos);
|
|
246
245
|
for (const key of keys){
|
|
@@ -649,13 +648,13 @@ function formatShare(shareArgs, from, name, shareStrategy) {
|
|
|
649
648
|
warn(`"shared.strategy is deprecated, please set in initOptions.shareStrategy instead!"`);
|
|
650
649
|
}
|
|
651
650
|
var _shareArgs_version, _shareArgs_scope, _shareArgs_strategy;
|
|
652
|
-
return
|
|
651
|
+
return _extends({
|
|
653
652
|
deps: [],
|
|
654
653
|
useIn: [],
|
|
655
654
|
from,
|
|
656
655
|
loading: null
|
|
657
656
|
}, shareArgs, {
|
|
658
|
-
shareConfig:
|
|
657
|
+
shareConfig: _extends({
|
|
659
658
|
requiredVersion: `^${shareArgs.version}`,
|
|
660
659
|
singleton: false,
|
|
661
660
|
eager: false,
|
|
@@ -681,7 +680,7 @@ function formatShareConfigs(globalOptions, userOptions) {
|
|
|
681
680
|
});
|
|
682
681
|
return res;
|
|
683
682
|
}, {});
|
|
684
|
-
const shared =
|
|
683
|
+
const shared = _extends({}, globalOptions.shared);
|
|
685
684
|
Object.keys(shareInfos).forEach((shareKey)=>{
|
|
686
685
|
if (!shared[shareKey]) {
|
|
687
686
|
shared[shareKey] = shareInfos[shareKey];
|
package/dist/src/core.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CreateScriptHookReturn } from '@module-federation/sdk';
|
|
1
|
+
import type { CreateScriptHookReturn, ModuleInfo } from '@module-federation/sdk';
|
|
2
2
|
import { Options, PreloadRemoteArgs, RemoteEntryExports, Remote, Shared, ShareInfos, UserOptions, RemoteInfo, ShareScopeMap, InitScope, RemoteEntryInitOptions, CallFrom } from './type';
|
|
3
3
|
import { Module } from './module';
|
|
4
4
|
import { AsyncHook, AsyncWaterfallHook, PluginSystem, SyncHook, SyncWaterfallHook } from './utils/hooks';
|
|
@@ -32,6 +32,8 @@ export declare class FederationHost {
|
|
|
32
32
|
remoteInfo: RemoteInfo;
|
|
33
33
|
remoteEntryExports: RemoteEntryExports;
|
|
34
34
|
origin: FederationHost;
|
|
35
|
+
id: string;
|
|
36
|
+
remoteSnapshot?: ModuleInfo;
|
|
35
37
|
}>;
|
|
36
38
|
}>;
|
|
37
39
|
version: string;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { FederationHost } from './core';
|
|
|
4
4
|
export { registerGlobalPlugins } from './global';
|
|
5
5
|
export { getRemoteEntry, getRemoteInfo } from './utils';
|
|
6
6
|
export { loadScript, loadScriptNode } from '@module-federation/sdk';
|
|
7
|
+
export { Module } from './module';
|
|
7
8
|
export type { Federation } from './global';
|
|
8
9
|
export type { FederationRuntimePlugin };
|
|
9
10
|
export declare function init(options: UserOptions): FederationHost;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ModuleInfo } from '@module-federation/sdk';
|
|
1
2
|
import { FederationHost } from '../core';
|
|
2
3
|
import { RemoteEntryExports, RemoteInfo } from '../type';
|
|
3
4
|
export type ModuleOptions = ConstructorParameters<typeof Module>[0];
|
|
@@ -14,7 +15,7 @@ declare class Module {
|
|
|
14
15
|
getEntry(): Promise<RemoteEntryExports>;
|
|
15
16
|
get(id: string, expose: string, options?: {
|
|
16
17
|
loadFactory?: boolean;
|
|
17
|
-
}): Promise<any>;
|
|
18
|
+
}, remoteSnapshot?: ModuleInfo): Promise<any>;
|
|
18
19
|
private wraperFactory;
|
|
19
20
|
}
|
|
20
21
|
export { Module };
|
|
@@ -44,14 +44,14 @@ export declare class RemoteHandler {
|
|
|
44
44
|
exposeModuleFactory: any;
|
|
45
45
|
moduleInstance: Module;
|
|
46
46
|
}], void>;
|
|
47
|
-
handlePreloadModule: SyncHook<{
|
|
47
|
+
handlePreloadModule: SyncHook<[{
|
|
48
48
|
id: string;
|
|
49
49
|
name: string;
|
|
50
50
|
remote: Remote;
|
|
51
51
|
remoteSnapshot: ModuleInfo;
|
|
52
52
|
preloadConfig: PreloadRemoteArgs;
|
|
53
53
|
origin: FederationHost;
|
|
54
|
-
}, void>;
|
|
54
|
+
}], void>;
|
|
55
55
|
errorLoadRemote: AsyncHook<[{
|
|
56
56
|
id: string;
|
|
57
57
|
error: unknown;
|
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-20240909062831",
|
|
4
4
|
"author": "zhouxiao <codingzx@gmail.com>",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -50,7 +50,6 @@
|
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@
|
|
54
|
-
"@module-federation/sdk": "0.0.0-next-20240905232541"
|
|
53
|
+
"@module-federation/sdk": "0.0.0-next-20240909062831"
|
|
55
54
|
}
|
|
56
55
|
}
|