@module-federation/runtime 0.0.0-next-20240905232541 → 0.0.0-next-20240906012942

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.
@@ -1,8 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var share = require('./share.cjs.js');
4
- require('@swc/helpers/_/_extends');
5
- require('@swc/helpers/_/_object_without_properties_loose');
4
+ require('./polyfills.cjs.js');
6
5
  require('@module-federation/sdk');
7
6
 
8
7
  const ShareUtils = {
@@ -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 '@swc/helpers/_/_extends';
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 _extends = require('@swc/helpers/_/_extends');
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._({}, remote, {
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,
@@ -312,7 +311,7 @@ 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._({}, initContainerOptions, {
314
+ await this.host.hooks.lifecycle.initContainer.emit(polyfills._extends({}, initContainerOptions, {
316
315
  remoteEntryExports
317
316
  }));
318
317
  }
@@ -549,7 +548,7 @@ class PluginSystem {
549
548
  }
550
549
 
551
550
  function defaultPreloadArgs(preloadConfig) {
552
- return _extends._({
551
+ return polyfills._extends({
553
552
  resourceCategory: 'sync',
554
553
  share: true,
555
554
  depsRemote: true,
@@ -752,7 +751,7 @@ function snapshotPlugin() {
752
751
  if (assets) {
753
752
  preloadAssets(remoteInfo, origin, assets, false);
754
753
  }
755
- return _extends._({}, args, {
754
+ return polyfills._extends({}, args, {
756
755
  remoteSnapshot
757
756
  });
758
757
  }
@@ -1040,7 +1039,7 @@ class SnapshotHandler {
1040
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.
1041
1040
  if (hostSnapshot && 'remotesInfo' in hostSnapshot && !share.getInfoWithoutType(hostSnapshot.remotesInfo, moduleInfo.name).value) {
1042
1041
  if ('version' in moduleInfo || 'entry' in moduleInfo) {
1043
- hostSnapshot.remotesInfo = _extends._({}, hostSnapshot == null ? void 0 : hostSnapshot.remotesInfo, {
1042
+ hostSnapshot.remotesInfo = polyfills._extends({}, hostSnapshot == null ? void 0 : hostSnapshot.remotesInfo, {
1044
1043
  [moduleInfo.name]: {
1045
1044
  matchedVersion: 'version' in moduleInfo ? moduleInfo.version : moduleInfo.entry
1046
1045
  }
@@ -1061,7 +1060,7 @@ class SnapshotHandler {
1061
1060
  const remoteEntry = sdk.isBrowserEnv() ? globalRemoteSnapshot.remoteEntry : globalRemoteSnapshot.ssrRemoteEntry || globalRemoteSnapshot.remoteEntry || '';
1062
1061
  const moduleSnapshot = await this.getManifestJson(remoteEntry, moduleInfo, {});
1063
1062
  // eslint-disable-next-line @typescript-eslint/no-shadow
1064
- const globalSnapshotRes = share.setGlobalSnapshotInfoByModuleInfo(_extends._({}, moduleInfo, {
1063
+ const globalSnapshotRes = share.setGlobalSnapshotInfoByModuleInfo(polyfills._extends({}, moduleInfo, {
1065
1064
  // The global remote may be overridden
1066
1065
  // Therefore, set the snapshot key to the global address of the actual request
1067
1066
  entry: remoteEntry
@@ -1458,7 +1457,7 @@ class SharedHandler {
1458
1457
  });
1459
1458
  }
1460
1459
  setShared({ pkgName, shared, from, lib, loading, loaded, get }) {
1461
- const { version, scope = 'default' } = shared, shareInfo = _object_without_properties_loose._(shared, [
1460
+ const { version, scope = 'default' } = shared, shareInfo = polyfills._object_without_properties_loose(shared, [
1462
1461
  "version",
1463
1462
  "scope"
1464
1463
  ]);
@@ -1475,7 +1474,7 @@ class SharedHandler {
1475
1474
  if (this.shareScopeMap[sc][pkgName][version]) {
1476
1475
  return;
1477
1476
  }
1478
- this.shareScopeMap[sc][pkgName][version] = _extends._({
1477
+ this.shareScopeMap[sc][pkgName][version] = polyfills._extends({
1479
1478
  version,
1480
1479
  scope: [
1481
1480
  'default'
@@ -1670,7 +1669,7 @@ class RemoteHandler {
1670
1669
  `);
1671
1670
  const { remote: rawRemote } = remoteSplitInfo;
1672
1671
  const remoteInfo = getRemoteInfo(rawRemote);
1673
- const matchInfo = await host.sharedHandler.hooks.lifecycle.afterResolve.emit(_extends._({
1672
+ const matchInfo = await host.sharedHandler.hooks.lifecycle.afterResolve.emit(polyfills._extends({
1674
1673
  id: idRes
1675
1674
  }, remoteSplitInfo, {
1676
1675
  options: host.options,
@@ -1935,7 +1934,7 @@ class FederationHost {
1935
1934
  }
1936
1935
  });
1937
1936
  }
1938
- const optionsRes = _extends._({}, globalOptions, userOptions, {
1937
+ const optionsRes = polyfills._extends({}, globalOptions, userOptions, {
1939
1938
  plugins,
1940
1939
  remotes,
1941
1940
  shared: handledShared
package/dist/index.esm.js CHANGED
@@ -1,9 +1,8 @@
1
- import { _ } from '@swc/helpers/_/_extends';
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 _({}, remote, {
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,
@@ -310,7 +309,7 @@ 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(_({}, initContainerOptions, {
312
+ await this.host.hooks.lifecycle.initContainer.emit(_extends({}, initContainerOptions, {
314
313
  remoteEntryExports
315
314
  }));
316
315
  }
@@ -547,7 +546,7 @@ class PluginSystem {
547
546
  }
548
547
 
549
548
  function defaultPreloadArgs(preloadConfig) {
550
- return _({
549
+ return _extends({
551
550
  resourceCategory: 'sync',
552
551
  share: true,
553
552
  depsRemote: true,
@@ -750,7 +749,7 @@ function snapshotPlugin() {
750
749
  if (assets) {
751
750
  preloadAssets(remoteInfo, origin, assets, false);
752
751
  }
753
- return _({}, args, {
752
+ return _extends({}, args, {
754
753
  remoteSnapshot
755
754
  });
756
755
  }
@@ -1038,7 +1037,7 @@ class SnapshotHandler {
1038
1037
  // 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
1038
  if (hostSnapshot && 'remotesInfo' in hostSnapshot && !getInfoWithoutType(hostSnapshot.remotesInfo, moduleInfo.name).value) {
1040
1039
  if ('version' in moduleInfo || 'entry' in moduleInfo) {
1041
- hostSnapshot.remotesInfo = _({}, hostSnapshot == null ? void 0 : hostSnapshot.remotesInfo, {
1040
+ hostSnapshot.remotesInfo = _extends({}, hostSnapshot == null ? void 0 : hostSnapshot.remotesInfo, {
1042
1041
  [moduleInfo.name]: {
1043
1042
  matchedVersion: 'version' in moduleInfo ? moduleInfo.version : moduleInfo.entry
1044
1043
  }
@@ -1059,7 +1058,7 @@ class SnapshotHandler {
1059
1058
  const remoteEntry = isBrowserEnv() ? globalRemoteSnapshot.remoteEntry : globalRemoteSnapshot.ssrRemoteEntry || globalRemoteSnapshot.remoteEntry || '';
1060
1059
  const moduleSnapshot = await this.getManifestJson(remoteEntry, moduleInfo, {});
1061
1060
  // eslint-disable-next-line @typescript-eslint/no-shadow
1062
- const globalSnapshotRes = setGlobalSnapshotInfoByModuleInfo(_({}, moduleInfo, {
1061
+ const globalSnapshotRes = setGlobalSnapshotInfoByModuleInfo(_extends({}, moduleInfo, {
1063
1062
  // The global remote may be overridden
1064
1063
  // Therefore, set the snapshot key to the global address of the actual request
1065
1064
  entry: remoteEntry
@@ -1456,7 +1455,7 @@ class SharedHandler {
1456
1455
  });
1457
1456
  }
1458
1457
  setShared({ pkgName, shared, from, lib, loading, loaded, get }) {
1459
- const { version, scope = 'default' } = shared, shareInfo = _$1(shared, [
1458
+ const { version, scope = 'default' } = shared, shareInfo = _object_without_properties_loose(shared, [
1460
1459
  "version",
1461
1460
  "scope"
1462
1461
  ]);
@@ -1473,7 +1472,7 @@ class SharedHandler {
1473
1472
  if (this.shareScopeMap[sc][pkgName][version]) {
1474
1473
  return;
1475
1474
  }
1476
- this.shareScopeMap[sc][pkgName][version] = _({
1475
+ this.shareScopeMap[sc][pkgName][version] = _extends({
1477
1476
  version,
1478
1477
  scope: [
1479
1478
  'default'
@@ -1668,7 +1667,7 @@ class RemoteHandler {
1668
1667
  `);
1669
1668
  const { remote: rawRemote } = remoteSplitInfo;
1670
1669
  const remoteInfo = getRemoteInfo(rawRemote);
1671
- const matchInfo = await host.sharedHandler.hooks.lifecycle.afterResolve.emit(_({
1670
+ const matchInfo = await host.sharedHandler.hooks.lifecycle.afterResolve.emit(_extends({
1672
1671
  id: idRes
1673
1672
  }, remoteSplitInfo, {
1674
1673
  options: host.options,
@@ -1933,7 +1932,7 @@ class FederationHost {
1933
1932
  }
1934
1933
  });
1935
1934
  }
1936
- const optionsRes = _({}, globalOptions, userOptions, {
1935
+ const optionsRes = _extends({}, globalOptions, userOptions, {
1937
1936
  plugins,
1938
1937
  remotes,
1939
1938
  shared: handledShared
package/dist/package.json CHANGED
@@ -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 _extends = require('@swc/helpers/_/_extends');
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() {
@@ -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._(moduleInfo, [
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._({}, nativeGlobal.__FEDERATION__.moduleInfo, moduleInfos);
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._({}, globalOptions.shared);
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 { _ as _$1 } from '@swc/helpers/_/_extends';
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() {
@@ -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 = _(moduleInfo, [
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 = _$1({}, nativeGlobal.__FEDERATION__.moduleInfo, moduleInfos);
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 _$1({
651
+ return _extends({
653
652
  deps: [],
654
653
  useIn: [],
655
654
  from,
656
655
  loading: null
657
656
  }, shareArgs, {
658
- shareConfig: _$1({
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 = _$1({}, globalOptions.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/runtime",
3
- "version": "0.0.0-next-20240905232541",
3
+ "version": "0.0.0-next-20240906012942",
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
- "@swc/helpers": "^0.5.0",
54
- "@module-federation/sdk": "0.0.0-next-20240905232541"
53
+ "@module-federation/sdk": "0.0.0-next-20240906012942"
55
54
  }
56
55
  }