@module-federation/runtime 0.0.0-next-20240824225724 → 0.0.0-next-20240826075118

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.esm.js CHANGED
@@ -1,9 +1,7 @@
1
- import { _ } from '@swc/helpers/_/_extends';
2
- 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';
3
- export { H as registerGlobalPlugins } from './share.esm.js';
4
- import { isBrowserEnv, loadScriptNode, composeKeyWithSeparator, loadScript, safeToString, createLink, createScript, getResourceUrl, isManifestProvider, generateSnapshotFromManifest, warn as warn$1 } from '@module-federation/sdk';
1
+ import { g as getGlobalHostPlugins, a as globalLoading, D as DEFAULT_REMOTE_TYPE, b as DEFAULT_SCOPE, 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 getRemoteEntryInfoFromSnapshot, m as isBrowserEnv$1, n as getInfoWithoutType, o as getPreloaded, p as setPreloaded, q as getRegisteredShare, r as arrayOptions, t as getGlobalSnapshotInfoByModuleInfo, u as addGlobalSnapshot, v as setGlobalSnapshotInfoByModuleInfo, G as Global, x as getGlobalSnapshot, y as formatShareConfigs, z as getTargetSharedOptions, A as getGlobalShareScope, B as addUniqueItem, C as getBuilderId, E as setGlobalFederationConstructor, F as getGlobalFederationInstance, H as getGlobalFederationConstructor, I as setGlobalFederationInstance } from './share.esm.js';
2
+ export { J as registerGlobalPlugins } from './share.esm.js';
3
+ import { isBrowserEnv, loadScriptNode, composeKeyWithSeparator, loadScript, createLink, createScript, getResourceUrl, isManifestProvider, generateSnapshotFromManifest, warn as warn$1 } from '@module-federation/sdk';
5
4
  export { loadScript, loadScriptNode } from '@module-federation/sdk';
6
- import { _ as _$1 } from '@swc/helpers/_/_object_without_properties_loose';
7
5
 
8
6
  // Function to match a remote with its name and expose
9
7
  // id: pkgName(@federation/app1) + expose(button) = @federation/app1/button
@@ -89,6 +87,20 @@ function registerPlugins$1(plugins, hookInstances) {
89
87
  return plugins;
90
88
  }
91
89
 
90
+ function _extends$7() {
91
+ _extends$7 = Object.assign || function(target) {
92
+ for(var i = 1; i < arguments.length; i++){
93
+ var source = arguments[i];
94
+ for(var key in source){
95
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
96
+ target[key] = source[key];
97
+ }
98
+ }
99
+ }
100
+ return target;
101
+ };
102
+ return _extends$7.apply(this, arguments);
103
+ }
92
104
  async function loadEsmEntry({ entry, remoteEntryExports }) {
93
105
  return new Promise((resolve, reject)=>{
94
106
  try {
@@ -251,7 +263,7 @@ async function getRemoteEntry({ origin, remoteEntryExports, remoteInfo }) {
251
263
  return globalLoading[uniqueKey];
252
264
  }
253
265
  function getRemoteInfo(remote) {
254
- return _({}, remote, {
266
+ return _extends$7({}, remote, {
255
267
  entry: 'entry' in remote ? remote.entry : '',
256
268
  type: remote.type || DEFAULT_REMOTE_TYPE,
257
269
  entryGlobalName: remote.entryGlobalName || remote.name,
@@ -259,6 +271,20 @@ function getRemoteInfo(remote) {
259
271
  });
260
272
  }
261
273
 
274
+ function _extends$6() {
275
+ _extends$6 = Object.assign || function(target) {
276
+ for(var i = 1; i < arguments.length; i++){
277
+ var source = arguments[i];
278
+ for(var key in source){
279
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
280
+ target[key] = source[key];
281
+ }
282
+ }
283
+ }
284
+ return target;
285
+ };
286
+ return _extends$6.apply(this, arguments);
287
+ }
262
288
  let Module = class Module {
263
289
  async getEntry() {
264
290
  if (this.remoteEntryExports) {
@@ -310,7 +336,7 @@ let Module = class Module {
310
336
  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
337
  }
312
338
  await remoteEntryExports.init(initContainerOptions.shareScope, initContainerOptions.initScope, initContainerOptions.remoteEntryInitOptions);
313
- await this.host.hooks.lifecycle.initContainer.emit(_({}, initContainerOptions, {
339
+ await this.host.hooks.lifecycle.initContainer.emit(_extends$6({}, initContainerOptions, {
314
340
  remoteEntryExports
315
341
  }));
316
342
  }
@@ -546,8 +572,22 @@ class PluginSystem {
546
572
  }
547
573
  }
548
574
 
575
+ function _extends$5() {
576
+ _extends$5 = Object.assign || function(target) {
577
+ for(var i = 1; i < arguments.length; i++){
578
+ var source = arguments[i];
579
+ for(var key in source){
580
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
581
+ target[key] = source[key];
582
+ }
583
+ }
584
+ }
585
+ return target;
586
+ };
587
+ return _extends$5.apply(this, arguments);
588
+ }
549
589
  function defaultPreloadArgs(preloadConfig) {
550
- return _({
590
+ return _extends$5({
551
591
  resourceCategory: 'sync',
552
592
  share: true,
553
593
  depsRemote: true,
@@ -703,13 +743,27 @@ useLinkPreload = true) {
703
743
  }
704
744
  }
705
745
 
746
+ function _extends$4() {
747
+ _extends$4 = Object.assign || function(target) {
748
+ for(var i = 1; i < arguments.length; i++){
749
+ var source = arguments[i];
750
+ for(var key in source){
751
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
752
+ target[key] = source[key];
753
+ }
754
+ }
755
+ }
756
+ return target;
757
+ };
758
+ return _extends$4.apply(this, arguments);
759
+ }
706
760
  function assignRemoteInfo(remoteInfo, remoteSnapshot) {
707
761
  const remoteEntryInfo = getRemoteEntryInfoFromSnapshot(remoteSnapshot);
708
762
  if (!remoteEntryInfo.url) {
709
763
  error(`The attribute remoteEntry of ${remoteInfo.name} must not be undefined.`);
710
764
  }
711
765
  let entryUrl = getResourceUrl(remoteSnapshot, remoteEntryInfo.url);
712
- if (!isBrowserEnv() && !entryUrl.startsWith('http')) {
766
+ if (!isBrowserEnv$1() && !entryUrl.startsWith('http')) {
713
767
  entryUrl = `https:${entryUrl}`;
714
768
  }
715
769
  remoteInfo.type = remoteEntryInfo.type;
@@ -750,7 +804,7 @@ function snapshotPlugin() {
750
804
  if (assets) {
751
805
  preloadAssets(remoteInfo, origin, assets, false);
752
806
  }
753
- return _({}, args, {
807
+ return _extends$4({}, args, {
754
808
  remoteSnapshot
755
809
  });
756
810
  }
@@ -971,6 +1025,20 @@ const generatePreloadAssetsPlugin = function() {
971
1025
  };
972
1026
  };
973
1027
 
1028
+ function _extends$3() {
1029
+ _extends$3 = Object.assign || function(target) {
1030
+ for(var i = 1; i < arguments.length; i++){
1031
+ var source = arguments[i];
1032
+ for(var key in source){
1033
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1034
+ target[key] = source[key];
1035
+ }
1036
+ }
1037
+ }
1038
+ return target;
1039
+ };
1040
+ return _extends$3.apply(this, arguments);
1041
+ }
974
1042
  function getGlobalRemoteInfo(moduleInfo, origin) {
975
1043
  const hostGlobalSnapshot = getGlobalSnapshotInfoByModuleInfo({
976
1044
  name: origin.options.name,
@@ -1038,7 +1106,7 @@ class SnapshotHandler {
1038
1106
  // 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
1107
  if (hostSnapshot && 'remotesInfo' in hostSnapshot && !getInfoWithoutType(hostSnapshot.remotesInfo, moduleInfo.name).value) {
1040
1108
  if ('version' in moduleInfo || 'entry' in moduleInfo) {
1041
- hostSnapshot.remotesInfo = _({}, hostSnapshot == null ? void 0 : hostSnapshot.remotesInfo, {
1109
+ hostSnapshot.remotesInfo = _extends$3({}, hostSnapshot == null ? void 0 : hostSnapshot.remotesInfo, {
1042
1110
  [moduleInfo.name]: {
1043
1111
  matchedVersion: 'version' in moduleInfo ? moduleInfo.version : moduleInfo.entry
1044
1112
  }
@@ -1056,10 +1124,10 @@ class SnapshotHandler {
1056
1124
  // global snapshot includes manifest or module info includes manifest
1057
1125
  if (globalRemoteSnapshot) {
1058
1126
  if (isManifestProvider(globalRemoteSnapshot)) {
1059
- const remoteEntry = isBrowserEnv() ? globalRemoteSnapshot.remoteEntry : globalRemoteSnapshot.ssrRemoteEntry || globalRemoteSnapshot.remoteEntry || '';
1127
+ const remoteEntry = isBrowserEnv$1() ? globalRemoteSnapshot.remoteEntry : globalRemoteSnapshot.ssrRemoteEntry || globalRemoteSnapshot.remoteEntry || '';
1060
1128
  const moduleSnapshot = await this.getManifestJson(remoteEntry, moduleInfo, {});
1061
1129
  // eslint-disable-next-line @typescript-eslint/no-shadow
1062
- const globalSnapshotRes = setGlobalSnapshotInfoByModuleInfo(_({}, moduleInfo, {
1130
+ const globalSnapshotRes = setGlobalSnapshotInfoByModuleInfo(_extends$3({}, moduleInfo, {
1063
1131
  // The global remote may be overridden
1064
1132
  // Therefore, set the snapshot key to the global address of the actual request
1065
1133
  entry: remoteEntry
@@ -1165,6 +1233,32 @@ class SnapshotHandler {
1165
1233
  }
1166
1234
  }
1167
1235
 
1236
+ function _extends$2() {
1237
+ _extends$2 = Object.assign || function(target) {
1238
+ for(var i = 1; i < arguments.length; i++){
1239
+ var source = arguments[i];
1240
+ for(var key in source){
1241
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1242
+ target[key] = source[key];
1243
+ }
1244
+ }
1245
+ }
1246
+ return target;
1247
+ };
1248
+ return _extends$2.apply(this, arguments);
1249
+ }
1250
+ function _object_without_properties_loose(source, excluded) {
1251
+ if (source == null) return {};
1252
+ var target = {};
1253
+ var sourceKeys = Object.keys(source);
1254
+ var key, i;
1255
+ for(i = 0; i < sourceKeys.length; i++){
1256
+ key = sourceKeys[i];
1257
+ if (excluded.indexOf(key) >= 0) continue;
1258
+ target[key] = source[key];
1259
+ }
1260
+ return target;
1261
+ }
1168
1262
  class SharedHandler {
1169
1263
  // register shared in shareScopeMap
1170
1264
  registerShared(globalOptions, userOptions) {
@@ -1204,7 +1298,9 @@ class SharedHandler {
1204
1298
  });
1205
1299
  if (shareInfo == null ? void 0 : shareInfo.scope) {
1206
1300
  await Promise.all(shareInfo.scope.map(async (shareScope)=>{
1207
- await Promise.all(this.initializeSharing(shareScope, shareInfo.strategy));
1301
+ await Promise.all(this.initializeSharing(shareScope, {
1302
+ strategy: shareInfo.strategy
1303
+ }));
1208
1304
  return;
1209
1305
  }));
1210
1306
  }
@@ -1292,8 +1388,22 @@ class SharedHandler {
1292
1388
  * It accepts one argument, the name of the share scope.
1293
1389
  * If the share scope does not exist, it creates one.
1294
1390
  */ // eslint-disable-next-line @typescript-eslint/member-ordering
1295
- initializeSharing(shareScopeName = DEFAULT_SCOPE, strategy) {
1391
+ initializeSharing(shareScopeName = DEFAULT_SCOPE, extraOptions) {
1296
1392
  const { host } = this;
1393
+ const from = extraOptions == null ? void 0 : extraOptions.from;
1394
+ const strategy = extraOptions == null ? void 0 : extraOptions.strategy;
1395
+ let initScope = extraOptions == null ? void 0 : extraOptions.initScope;
1396
+ const promises = [];
1397
+ if (from !== 'build') {
1398
+ const { initTokens } = this;
1399
+ if (!initScope) initScope = [];
1400
+ let initToken = initTokens[shareScopeName];
1401
+ if (!initToken) initToken = initTokens[shareScopeName] = {
1402
+ from: this.host.name
1403
+ };
1404
+ if (initScope.indexOf(initToken) >= 0) return promises;
1405
+ initScope.push(initToken);
1406
+ }
1297
1407
  const shareScope = this.shareScopeMap;
1298
1408
  const hostName = host.options.name;
1299
1409
  // Creates a new share scope if necessary
@@ -1313,8 +1423,7 @@ class SharedHandler {
1313
1423
  versions[version] = shared;
1314
1424
  }
1315
1425
  };
1316
- const promises = [];
1317
- const initFn = (mod)=>mod && mod.init && mod.init(shareScope[shareScopeName]);
1426
+ const initFn = (mod)=>mod && mod.init && mod.init(shareScope[shareScopeName], initScope);
1318
1427
  const initRemoteModule = async (key)=>{
1319
1428
  const { module } = await host.remoteHandler.getRemoteModuleAndOptions({
1320
1429
  id: key
@@ -1322,7 +1431,7 @@ class SharedHandler {
1322
1431
  if (module.getEntry) {
1323
1432
  const entry = await module.getEntry();
1324
1433
  if (!module.inited) {
1325
- initFn(entry);
1434
+ await initFn(entry);
1326
1435
  module.inited = true;
1327
1436
  }
1328
1437
  }
@@ -1358,7 +1467,9 @@ class SharedHandler {
1358
1467
  });
1359
1468
  if (shareInfo == null ? void 0 : shareInfo.scope) {
1360
1469
  shareInfo.scope.forEach((shareScope)=>{
1361
- this.initializeSharing(shareScope, shareInfo.strategy);
1470
+ this.initializeSharing(shareScope, {
1471
+ strategy: shareInfo.strategy
1472
+ });
1362
1473
  });
1363
1474
  }
1364
1475
  const registeredShared = getRegisteredShare(this.shareScopeMap, pkgName, shareInfo, this.hooks.lifecycle.resolveShare);
@@ -1439,7 +1550,7 @@ class SharedHandler {
1439
1550
  });
1440
1551
  }
1441
1552
  setShared({ pkgName, shared, from, lib, loading, loaded, get }) {
1442
- const { version, scope = 'default' } = shared, shareInfo = _$1(shared, [
1553
+ const { version, scope = 'default' } = shared, shareInfo = _object_without_properties_loose(shared, [
1443
1554
  "version",
1444
1555
  "scope"
1445
1556
  ]);
@@ -1456,7 +1567,7 @@ class SharedHandler {
1456
1567
  if (this.shareScopeMap[sc][pkgName][version]) {
1457
1568
  return;
1458
1569
  }
1459
- this.shareScopeMap[sc][pkgName][version] = _({
1570
+ this.shareScopeMap[sc][pkgName][version] = _extends$2({
1460
1571
  version,
1461
1572
  scope: [
1462
1573
  'default'
@@ -1490,10 +1601,25 @@ class SharedHandler {
1490
1601
  });
1491
1602
  this.host = host;
1492
1603
  this.shareScopeMap = {};
1604
+ this.initTokens = {};
1493
1605
  this._setGlobalShareScopeMap(host.options);
1494
1606
  }
1495
1607
  }
1496
1608
 
1609
+ function _extends$1() {
1610
+ _extends$1 = Object.assign || function(target) {
1611
+ for(var i = 1; i < arguments.length; i++){
1612
+ var source = arguments[i];
1613
+ for(var key in source){
1614
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1615
+ target[key] = source[key];
1616
+ }
1617
+ }
1618
+ }
1619
+ return target;
1620
+ };
1621
+ return _extends$1.apply(this, arguments);
1622
+ }
1497
1623
  class RemoteHandler {
1498
1624
  formatAndRegisterRemote(globalOptions, userOptions) {
1499
1625
  const userRemotes = userOptions.remotes || [];
@@ -1650,7 +1776,7 @@ class RemoteHandler {
1650
1776
  `);
1651
1777
  const { remote: rawRemote } = remoteSplitInfo;
1652
1778
  const remoteInfo = getRemoteInfo(rawRemote);
1653
- const matchInfo = await host.sharedHandler.hooks.lifecycle.afterResolve.emit(_({
1779
+ const matchInfo = await host.sharedHandler.hooks.lifecycle.afterResolve.emit(_extends$1({
1654
1780
  id: idRes
1655
1781
  }, remoteSplitInfo, {
1656
1782
  options: host.options,
@@ -1819,8 +1945,7 @@ class RemoteHandler {
1819
1945
  const remoteKey = hostGlobalSnapshot && 'remotesInfo' in hostGlobalSnapshot && hostGlobalSnapshot.remotesInfo && getInfoWithoutType(hostGlobalSnapshot.remotesInfo, remote.name).key;
1820
1946
  if (remoteKey) {
1821
1947
  delete hostGlobalSnapshot.remotesInfo[remoteKey];
1822
- if (//eslint-disable-next-line no-extra-boolean-cast
1823
- Boolean(Global.__FEDERATION__.__MANIFEST_LOADING__[remoteKey])) {
1948
+ if (Boolean(Global.__FEDERATION__.__MANIFEST_LOADING__[remoteKey])) {
1824
1949
  delete Global.__FEDERATION__.__MANIFEST_LOADING__[remoteKey];
1825
1950
  }
1826
1951
  }
@@ -1850,6 +1975,20 @@ class RemoteHandler {
1850
1975
  }
1851
1976
  }
1852
1977
 
1978
+ function _extends() {
1979
+ _extends = Object.assign || function(target) {
1980
+ for(var i = 1; i < arguments.length; i++){
1981
+ var source = arguments[i];
1982
+ for(var key in source){
1983
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1984
+ target[key] = source[key];
1985
+ }
1986
+ }
1987
+ }
1988
+ return target;
1989
+ };
1990
+ return _extends.apply(this, arguments);
1991
+ }
1853
1992
  class FederationHost {
1854
1993
  initOptions(userOptions) {
1855
1994
  this.registerPlugins(userOptions.plugins);
@@ -1867,8 +2006,8 @@ class FederationHost {
1867
2006
  loadShareSync(pkgName, extraOptions) {
1868
2007
  return this.sharedHandler.loadShareSync(pkgName, extraOptions);
1869
2008
  }
1870
- initializeSharing(shareScopeName = DEFAULT_SCOPE, strategy) {
1871
- return this.sharedHandler.initializeSharing(shareScopeName, strategy);
2009
+ initializeSharing(shareScopeName = DEFAULT_SCOPE, extraOptions) {
2010
+ return this.sharedHandler.initializeSharing(shareScopeName, extraOptions);
1872
2011
  }
1873
2012
  initRawContainer(name, url, container) {
1874
2013
  const remoteInfo = getRemoteInfo({
@@ -1915,7 +2054,7 @@ class FederationHost {
1915
2054
  }
1916
2055
  });
1917
2056
  }
1918
- const optionsRes = _({}, globalOptions, userOptions, {
2057
+ const optionsRes = _extends({}, globalOptions, userOptions, {
1919
2058
  plugins,
1920
2059
  remotes,
1921
2060
  shared: handledShared
@@ -1955,7 +2094,7 @@ class FederationHost {
1955
2094
  // maybe will change, temporarily for internal use only
1956
2095
  initContainer: new AsyncWaterfallHook('initContainer')
1957
2096
  });
1958
- this.version = "0.5.1";
2097
+ this.version = "0.5.2";
1959
2098
  this.moduleCache = new Map();
1960
2099
  this.loaderHook = new PluginSystem({
1961
2100
  // FIXME: may not be suitable , not open to the public yet
@@ -1976,7 +2115,7 @@ class FederationHost {
1976
2115
  ],
1977
2116
  remotes: [],
1978
2117
  shared: {},
1979
- inBrowser: isBrowserEnv()
2118
+ inBrowser: isBrowserEnv$1()
1980
2119
  };
1981
2120
  this.name = userOptions.name;
1982
2121
  this.options = defaultOptions;
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/runtime",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "author": "zhouxiao <codingzx@gmail.com>",
5
5
  "main": "./index.cjs.js",
6
6
  "module": "./index.esm.js",
@@ -34,11 +34,6 @@
34
34
  "import": "./dist/retry-plugin.esm.js",
35
35
  "require": "./dist/retry-plugin.cjs.js"
36
36
  },
37
- "./embedded": {
38
- "types": "./dist/embedded.cjs.d.ts",
39
- "import": "./dist/embedded.esm.js",
40
- "require": "./dist/embedded.cjs.js"
41
- },
42
37
  "./*": "./*"
43
38
  },
44
39
  "typesVersions": {
@@ -1,7 +1,19 @@
1
1
  'use strict';
2
2
 
3
- var _extends = require('@swc/helpers/_/_extends');
4
-
3
+ function _extends() {
4
+ _extends = Object.assign || function(target) {
5
+ for(var i = 1; i < arguments.length; i++){
6
+ var source = arguments[i];
7
+ for(var key in source){
8
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
9
+ target[key] = source[key];
10
+ }
11
+ }
12
+ }
13
+ return target;
14
+ };
15
+ return _extends.apply(this, arguments);
16
+ }
5
17
  const defaultRetries = 3;
6
18
  async function fetchWithRetry({ url, options = {}, retryTimes = defaultRetries, fallbackUrl = '' }) {
7
19
  try {
@@ -46,7 +58,7 @@ const RetryPlugin = (params)=>({
46
58
  async fetch (url, options) {
47
59
  return fetchWithRetry({
48
60
  url,
49
- options: _extends._({}, options, params == null ? void 0 : params.options),
61
+ options: _extends({}, options, params == null ? void 0 : params.options),
50
62
  retryTimes: params == null ? void 0 : params.retryTimes,
51
63
  fallbackUrl: params == null ? void 0 : params.fallbackUrl
52
64
  });
@@ -1,5 +1,17 @@
1
- import { _ } from '@swc/helpers/_/_extends';
2
-
1
+ function _extends() {
2
+ _extends = Object.assign || function(target) {
3
+ for(var i = 1; i < arguments.length; i++){
4
+ var source = arguments[i];
5
+ for(var key in source){
6
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
7
+ target[key] = source[key];
8
+ }
9
+ }
10
+ }
11
+ return target;
12
+ };
13
+ return _extends.apply(this, arguments);
14
+ }
3
15
  const defaultRetries = 3;
4
16
  async function fetchWithRetry({ url, options = {}, retryTimes = defaultRetries, fallbackUrl = '' }) {
5
17
  try {
@@ -44,7 +56,7 @@ const RetryPlugin = (params)=>({
44
56
  async fetch (url, options) {
45
57
  return fetchWithRetry({
46
58
  url,
47
- options: _({}, options, params == null ? void 0 : params.options),
59
+ options: _extends({}, options, params == null ? void 0 : params.options),
48
60
  retryTimes: params == null ? void 0 : params.retryTimes,
49
61
  fallbackUrl: params == null ? void 0 : params.fallbackUrl
50
62
  });
package/dist/share.cjs.js CHANGED
@@ -1,13 +1,15 @@
1
1
  'use strict';
2
2
 
3
- var _extends = require('@swc/helpers/_/_extends');
4
- var _object_without_properties_loose = require('@swc/helpers/_/_object_without_properties_loose');
5
- var sdk = require('@module-federation/sdk');
6
-
7
3
  function getBuilderId() {
8
4
  //@ts-ignore
9
5
  return typeof FEDERATION_BUILD_IDENTIFIER !== 'undefined' ? FEDERATION_BUILD_IDENTIFIER : '';
10
6
  }
7
+ function isDebugMode() {
8
+ return Boolean("");
9
+ }
10
+ function isBrowserEnv() {
11
+ return typeof window !== 'undefined';
12
+ }
11
13
 
12
14
  const LOG_CATEGORY = '[ Federation Runtime ]';
13
15
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
@@ -53,6 +55,14 @@ function isRemoteInfoWithEntry(remote) {
53
55
  function isPureRemoteEntry(remote) {
54
56
  return !remote.entry.includes('.json') && remote.entry.includes('.js');
55
57
  }
58
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
59
+ function safeToString(info) {
60
+ try {
61
+ return JSON.stringify(info, null, 2);
62
+ } catch (e) {
63
+ return '';
64
+ }
65
+ }
56
66
  function isObject(val) {
57
67
  return val && typeof val === 'object';
58
68
  }
@@ -72,7 +82,7 @@ function getRemoteEntryInfoFromSnapshot(snapshot) {
72
82
  type: 'global',
73
83
  globalName: ''
74
84
  };
75
- if (sdk.isBrowserEnv()) {
85
+ if (isBrowserEnv()) {
76
86
  return 'remoteEntry' in snapshot ? {
77
87
  url: snapshot.remoteEntry,
78
88
  type: snapshot.remoteEntryType,
@@ -89,6 +99,32 @@ function getRemoteEntryInfoFromSnapshot(snapshot) {
89
99
  return defaultRemoteEntryInfo;
90
100
  }
91
101
 
102
+ function _extends$1() {
103
+ _extends$1 = Object.assign || function(target) {
104
+ for(var i = 1; i < arguments.length; i++){
105
+ var source = arguments[i];
106
+ for(var key in source){
107
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
108
+ target[key] = source[key];
109
+ }
110
+ }
111
+ }
112
+ return target;
113
+ };
114
+ return _extends$1.apply(this, arguments);
115
+ }
116
+ function _object_without_properties_loose(source, excluded) {
117
+ if (source == null) return {};
118
+ var target = {};
119
+ var sourceKeys = Object.keys(source);
120
+ var key, i;
121
+ for(i = 0; i < sourceKeys.length; i++){
122
+ key = sourceKeys[i];
123
+ if (excluded.indexOf(key) >= 0) continue;
124
+ target[key] = source[key];
125
+ }
126
+ return target;
127
+ }
92
128
  const nativeGlobal = (()=>{
93
129
  try {
94
130
  return new Function('return this')();
@@ -173,10 +209,10 @@ function setGlobalFederationInstance(FederationInstance) {
173
209
  function getGlobalFederationConstructor() {
174
210
  return globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__;
175
211
  }
176
- function setGlobalFederationConstructor(FederationConstructor, isDebug = sdk.isDebugMode()) {
212
+ function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
177
213
  if (isDebug) {
178
214
  globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
179
- globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.5.1";
215
+ globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.5.2";
180
216
  }
181
217
  }
182
218
  // eslint-disable-next-line @typescript-eslint/ban-types
@@ -224,7 +260,7 @@ const getTargetSnapshotInfoByModuleInfo = (moduleInfo, snapshot)=>{
224
260
  }
225
261
  // If the remote is not included in the hostSnapshot, deploy a micro app snapshot
226
262
  if ('version' in moduleInfo && moduleInfo['version']) {
227
- const { version } = moduleInfo, resModuleInfo = _object_without_properties_loose._(moduleInfo, [
263
+ const { version } = moduleInfo, resModuleInfo = _object_without_properties_loose(moduleInfo, [
228
264
  "version"
229
265
  ]);
230
266
  const moduleKeyWithoutVersion = getFMId(resModuleInfo);
@@ -242,7 +278,7 @@ const setGlobalSnapshotInfoByModuleInfo = (remoteInfo, moduleDetailInfo)=>{
242
278
  return nativeGlobal.__FEDERATION__.moduleInfo;
243
279
  };
244
280
  const addGlobalSnapshot = (moduleInfos)=>{
245
- nativeGlobal.__FEDERATION__.moduleInfo = _extends._({}, nativeGlobal.__FEDERATION__.moduleInfo, moduleInfos);
281
+ nativeGlobal.__FEDERATION__.moduleInfo = _extends$1({}, nativeGlobal.__FEDERATION__.moduleInfo, moduleInfos);
246
282
  return ()=>{
247
283
  const keys = Object.keys(moduleInfos);
248
284
  for (const key of keys){
@@ -635,6 +671,20 @@ function satisfy(version, range) {
635
671
  return true;
636
672
  }
637
673
 
674
+ function _extends() {
675
+ _extends = Object.assign || function(target) {
676
+ for(var i = 1; i < arguments.length; i++){
677
+ var source = arguments[i];
678
+ for(var key in source){
679
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
680
+ target[key] = source[key];
681
+ }
682
+ }
683
+ }
684
+ return target;
685
+ };
686
+ return _extends.apply(this, arguments);
687
+ }
638
688
  function formatShare(shareArgs, from, name, shareStrategy) {
639
689
  let get;
640
690
  if ('get' in shareArgs) {
@@ -651,13 +701,13 @@ function formatShare(shareArgs, from, name, shareStrategy) {
651
701
  warn(`"shared.strategy is deprecated, please set in initOptions.shareStrategy instead!"`);
652
702
  }
653
703
  var _shareArgs_version, _shareArgs_scope, _shareArgs_strategy;
654
- return _extends._({
704
+ return _extends({
655
705
  deps: [],
656
706
  useIn: [],
657
707
  from,
658
708
  loading: null
659
709
  }, shareArgs, {
660
- shareConfig: _extends._({
710
+ shareConfig: _extends({
661
711
  requiredVersion: `^${shareArgs.version}`,
662
712
  singleton: false,
663
713
  eager: false,
@@ -683,7 +733,7 @@ function formatShareConfigs(globalOptions, userOptions) {
683
733
  });
684
734
  return res;
685
735
  }, {});
686
- const shared = _extends._({}, globalOptions.shared);
736
+ const shared = _extends({}, globalOptions.shared);
687
737
  Object.keys(shareInfos).forEach((shareKey)=>{
688
738
  if (!shared[shareKey]) {
689
739
  shared[shareKey] = shareInfos[shareKey];
@@ -872,6 +922,7 @@ exports.getRemoteEntryInfoFromSnapshot = getRemoteEntryInfoFromSnapshot;
872
922
  exports.getTargetSharedOptions = getTargetSharedOptions;
873
923
  exports.getTargetSnapshotInfoByModuleInfo = getTargetSnapshotInfoByModuleInfo;
874
924
  exports.globalLoading = globalLoading;
925
+ exports.isBrowserEnv = isBrowserEnv;
875
926
  exports.isObject = isObject;
876
927
  exports.isPlainObject = isPlainObject;
877
928
  exports.isPureRemoteEntry = isPureRemoteEntry;
@@ -879,6 +930,7 @@ exports.isRemoteInfoWithEntry = isRemoteInfoWithEntry;
879
930
  exports.nativeGlobal = nativeGlobal;
880
931
  exports.registerGlobalPlugins = registerGlobalPlugins;
881
932
  exports.resetFederationGlobalInfo = resetFederationGlobalInfo;
933
+ exports.safeToString = safeToString;
882
934
  exports.setGlobalFederationConstructor = setGlobalFederationConstructor;
883
935
  exports.setGlobalFederationInstance = setGlobalFederationInstance;
884
936
  exports.setGlobalSnapshotInfoByModuleInfo = setGlobalSnapshotInfoByModuleInfo;