@module-federation/sdk 0.0.0-next-20240605063149 → 0.0.0-next-20240605083609

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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- function _define_property$4(obj, key, value) {
5
+ function _define_property$3(obj, key, value) {
6
6
  if (key in obj) {
7
7
  Object.defineProperty(obj, key, {
8
8
  value: value,
@@ -25,9 +25,9 @@ var NameTransformSymbol = {
25
25
  SLASH: '/'
26
26
  };
27
27
  var _obj;
28
- var NameTransformMap = (_obj = {}, _define_property$4(_obj, NameTransformSymbol.AT, 'scope_'), _define_property$4(_obj, NameTransformSymbol.HYPHEN, '_'), _define_property$4(_obj, NameTransformSymbol.SLASH, '__'), _obj);
28
+ var NameTransformMap = (_obj = {}, _define_property$3(_obj, NameTransformSymbol.AT, 'scope_'), _define_property$3(_obj, NameTransformSymbol.HYPHEN, '_'), _define_property$3(_obj, NameTransformSymbol.SLASH, '__'), _obj);
29
29
  var _obj1;
30
- var EncodedNameTransformMap = (_obj1 = {}, _define_property$4(_obj1, NameTransformMap[NameTransformSymbol.AT], NameTransformSymbol.AT), _define_property$4(_obj1, NameTransformMap[NameTransformSymbol.HYPHEN], NameTransformSymbol.HYPHEN), _define_property$4(_obj1, NameTransformMap[NameTransformSymbol.SLASH], NameTransformSymbol.SLASH), _obj1);
30
+ var EncodedNameTransformMap = (_obj1 = {}, _define_property$3(_obj1, NameTransformMap[NameTransformSymbol.AT], NameTransformSymbol.AT), _define_property$3(_obj1, NameTransformMap[NameTransformSymbol.HYPHEN], NameTransformSymbol.HYPHEN), _define_property$3(_obj1, NameTransformMap[NameTransformSymbol.SLASH], NameTransformSymbol.SLASH), _obj1);
31
31
  var SEPARATOR = ':';
32
32
  var ManifestFileName = 'mf-manifest.json';
33
33
  var StatsFileName = 'mf-stats.json';
@@ -93,7 +93,7 @@ function _create_class(Constructor, protoProps, staticProps) {
93
93
  if (staticProps) _defineProperties(Constructor, staticProps);
94
94
  return Constructor;
95
95
  }
96
- function _define_property$3(obj, key, value) {
96
+ function _define_property$2(obj, key, value) {
97
97
  if (key in obj) {
98
98
  Object.defineProperty(obj, key, {
99
99
  value: value,
@@ -144,8 +144,8 @@ function safeGetLocalStorageItem() {
144
144
  var Logger = /*#__PURE__*/ function() {
145
145
  function Logger(identifier) {
146
146
  _class_call_check(this, Logger);
147
- _define_property$3(this, "enable", false);
148
- _define_property$3(this, "identifier", void 0);
147
+ _define_property$2(this, "enable", false);
148
+ _define_property$2(this, "identifier", void 0);
149
149
  this.identifier = identifier || DEBUG_LOG;
150
150
  if (isBrowserEnv() && safeGetLocalStorageItem()) {
151
151
  this.enable = true;
@@ -374,7 +374,7 @@ var warn = function(msg) {
374
374
  console.warn("".concat(LOG_CATEGORY, ": ").concat(msg));
375
375
  };
376
376
 
377
- function _define_property$2(obj, key, value) {
377
+ function _define_property$1(obj, key, value) {
378
378
  if (key in obj) {
379
379
  Object.defineProperty(obj, key, {
380
380
  value: value,
@@ -387,7 +387,7 @@ function _define_property$2(obj, key, value) {
387
387
  }
388
388
  return obj;
389
389
  }
390
- function _object_spread$2(target) {
390
+ function _object_spread$1(target) {
391
391
  for(var i = 1; i < arguments.length; i++){
392
392
  var source = arguments[i] != null ? arguments[i] : {};
393
393
  var ownKeys = Object.keys(source);
@@ -397,7 +397,7 @@ function _object_spread$2(target) {
397
397
  }));
398
398
  }
399
399
  ownKeys.forEach(function(key) {
400
- _define_property$2(target, key, source[key]);
400
+ _define_property$1(target, key, source[key]);
401
401
  });
402
402
  }
403
403
  return target;
@@ -507,7 +507,7 @@ function generateSnapshotFromManifest(manifest) {
507
507
  matchedVersion: overridesKeys.includes(key) ? overrides[key] : remotes[key]
508
508
  };
509
509
  });
510
- var _manifest_metaData2 = manifest.metaData, _manifest_metaData_remoteEntry = _manifest_metaData2.remoteEntry, remoteEntryPath = _manifest_metaData_remoteEntry.path, remoteEntryName = _manifest_metaData_remoteEntry.name, remoteEntryType = _manifest_metaData_remoteEntry.type, remoteTypes = _manifest_metaData2.types, buildVersion = _manifest_metaData2.buildInfo.buildVersion, globalName = _manifest_metaData2.globalName;
510
+ var _manifest_metaData2 = manifest.metaData, _manifest_metaData_remoteEntry = _manifest_metaData2.remoteEntry, remoteEntryPath = _manifest_metaData_remoteEntry.path, remoteEntryName = _manifest_metaData_remoteEntry.name, remoteEntryType = _manifest_metaData_remoteEntry.type, remoteTypes = _manifest_metaData2.types, buildVersion = _manifest_metaData2.buildInfo.buildVersion, globalName = _manifest_metaData2.globalName, ssrRemoteEntry = _manifest_metaData2.ssrRemoteEntry;
511
511
  var exposes = manifest.exposes;
512
512
  var basicRemoteSnapshot = {
513
513
  version: version ? version : '',
@@ -536,26 +536,31 @@ function generateSnapshotFromManifest(manifest) {
536
536
  };
537
537
  if ((_manifest_metaData = manifest.metaData) === null || _manifest_metaData === void 0 ? void 0 : _manifest_metaData.prefetchInterface) {
538
538
  var prefetchInterface = manifest.metaData.prefetchInterface;
539
- basicRemoteSnapshot = _object_spread_props(_object_spread$2({}, basicRemoteSnapshot), {
539
+ basicRemoteSnapshot = _object_spread_props(_object_spread$1({}, basicRemoteSnapshot), {
540
540
  prefetchInterface: prefetchInterface
541
541
  });
542
542
  }
543
543
  if ((_manifest_metaData1 = manifest.metaData) === null || _manifest_metaData1 === void 0 ? void 0 : _manifest_metaData1.prefetchEntry) {
544
544
  var _manifest_metaData_prefetchEntry = manifest.metaData.prefetchEntry, path = _manifest_metaData_prefetchEntry.path, name = _manifest_metaData_prefetchEntry.name, type = _manifest_metaData_prefetchEntry.type;
545
- basicRemoteSnapshot = _object_spread_props(_object_spread$2({}, basicRemoteSnapshot), {
545
+ basicRemoteSnapshot = _object_spread_props(_object_spread$1({}, basicRemoteSnapshot), {
546
546
  prefetchEntry: simpleJoinRemoteEntry(path, name),
547
547
  prefetchEntryType: type
548
548
  });
549
549
  }
550
550
  if ('publicPath' in manifest.metaData) {
551
- remoteSnapshot = _object_spread_props(_object_spread$2({}, basicRemoteSnapshot), {
551
+ remoteSnapshot = _object_spread_props(_object_spread$1({}, basicRemoteSnapshot), {
552
552
  publicPath: getPublicPath()
553
553
  });
554
554
  } else {
555
- remoteSnapshot = _object_spread_props(_object_spread$2({}, basicRemoteSnapshot), {
555
+ remoteSnapshot = _object_spread_props(_object_spread$1({}, basicRemoteSnapshot), {
556
556
  getPublicPath: getPublicPath()
557
557
  });
558
558
  }
559
+ if (ssrRemoteEntry) {
560
+ var fullSSRRemoteEntry = simpleJoinRemoteEntry(ssrRemoteEntry.path, ssrRemoteEntry.name);
561
+ remoteSnapshot.ssrRemoteEntry = fullSSRRemoteEntry;
562
+ remoteSnapshot.ssrRemoteEntryType = 'cjs:webpack';
563
+ }
559
564
  return remoteSnapshot;
560
565
  }
561
566
  function isManifestProvider(moduleInfo) {
@@ -595,19 +600,6 @@ function _async_to_generator$1(fn) {
595
600
  });
596
601
  };
597
602
  }
598
- function _define_property$1(obj, key, value) {
599
- if (key in obj) {
600
- Object.defineProperty(obj, key, {
601
- value: value,
602
- enumerable: true,
603
- configurable: true,
604
- writable: true
605
- });
606
- } else {
607
- obj[key] = value;
608
- }
609
- return obj;
610
- }
611
603
  function _instanceof(left, right) {
612
604
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
613
605
  return !!right[Symbol.hasInstance](left);
@@ -615,21 +607,6 @@ function _instanceof(left, right) {
615
607
  return left instanceof right;
616
608
  }
617
609
  }
618
- function _object_spread$1(target) {
619
- for(var i = 1; i < arguments.length; i++){
620
- var source = arguments[i] != null ? arguments[i] : {};
621
- var ownKeys = Object.keys(source);
622
- if (typeof Object.getOwnPropertySymbols === "function") {
623
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
624
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
625
- }));
626
- }
627
- ownKeys.forEach(function(key) {
628
- _define_property$1(target, key, source[key]);
629
- });
630
- }
631
- return target;
632
- }
633
610
  function _ts_generator$1(thisArg, body) {
634
611
  var f, y, t, g, _ = {
635
612
  label: 0,
@@ -774,7 +751,7 @@ function isStaticResourcesEqual(url1, url2) {
774
751
  // Check if the relative paths are identical
775
752
  return relativeUrl1 === relativeUrl2;
776
753
  }
777
- function createScript(info) {
754
+ function createScript(url, cb, attrs, createScriptHook) {
778
755
  // Retrieve the existing script element by its src attribute
779
756
  var script = null;
780
757
  var needAttach = true;
@@ -784,7 +761,7 @@ function createScript(info) {
784
761
  for(var i = 0; i < scripts.length; i++){
785
762
  var s = scripts[i];
786
763
  var scriptSrc = s.getAttribute('src');
787
- if (scriptSrc && isStaticResourcesEqual(scriptSrc, info.url)) {
764
+ if (scriptSrc && isStaticResourcesEqual(scriptSrc, url)) {
788
765
  script = s;
789
766
  needAttach = false;
790
767
  break;
@@ -793,9 +770,9 @@ function createScript(info) {
793
770
  if (!script) {
794
771
  script = document.createElement('script');
795
772
  script.type = 'text/javascript';
796
- script.src = info.url;
797
- if (info.createScriptHook) {
798
- var createScriptRes = info.createScriptHook(info.url);
773
+ script.src = url;
774
+ if (createScriptHook) {
775
+ var createScriptRes = createScriptHook(url);
799
776
  if (_instanceof(createScriptRes, HTMLScriptElement)) {
800
777
  script = createScriptRes;
801
778
  } else if (typeof createScriptRes === 'object') {
@@ -804,7 +781,6 @@ function createScript(info) {
804
781
  }
805
782
  }
806
783
  }
807
- var attrs = info.attrs;
808
784
  if (attrs) {
809
785
  Object.keys(attrs).forEach(function(name) {
810
786
  if (script) {
@@ -818,38 +794,35 @@ function createScript(info) {
818
794
  }
819
795
  var onScriptComplete = function(prev, // eslint-disable-next-line @typescript-eslint/no-explicit-any
820
796
  event) {
821
- var _info_cb;
822
797
  clearTimeout(timeoutId);
823
798
  // Prevent memory leaks in IE.
824
799
  if (script) {
825
800
  script.onerror = null;
826
801
  script.onload = null;
827
802
  safeWrapper(function() {
828
- if (info.needDeleteScript) {
829
- (script === null || script === void 0 ? void 0 : script.parentNode) && script.parentNode.removeChild(script);
830
- }
803
+ (script === null || script === void 0 ? void 0 : script.parentNode) && script.parentNode.removeChild(script);
831
804
  });
832
805
  if (prev) {
833
- var _info_cb1;
834
806
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
835
807
  var res = prev(event);
836
- info === null || info === void 0 ? void 0 : (_info_cb1 = info.cb) === null || _info_cb1 === void 0 ? void 0 : _info_cb1.call(info);
808
+ cb();
837
809
  return res;
838
810
  }
839
811
  }
840
- info === null || info === void 0 ? void 0 : (_info_cb = info.cb) === null || _info_cb === void 0 ? void 0 : _info_cb.call(info);
812
+ cb();
841
813
  };
842
814
  script.onerror = onScriptComplete.bind(null, script.onerror);
843
815
  script.onload = onScriptComplete.bind(null, script.onload);
844
816
  timeoutId = setTimeout(function() {
845
- onScriptComplete(null, new Error('Remote script "'.concat(info.url, '" time-outed.')));
817
+ onScriptComplete(null, new Error('Remote script "'.concat(url, '" time-outed.')));
846
818
  }, timeout);
847
819
  return {
848
820
  script: script,
849
821
  needAttach: needAttach
850
822
  };
851
823
  }
852
- function createLink(info) {
824
+ function createLink(url, cb) {
825
+ var attrs = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, createLinkHook = arguments.length > 3 ? arguments[3] : void 0;
853
826
  // <link rel="preload" href="script.js" as="script">
854
827
  // Retrieve the existing script element by its src attribute
855
828
  var link = null;
@@ -859,7 +832,7 @@ function createLink(info) {
859
832
  var l = links[i];
860
833
  var linkHref = l.getAttribute('href');
861
834
  var linkRef = l.getAttribute('ref');
862
- if (linkHref && isStaticResourcesEqual(linkHref, info.url) && linkRef === info.attrs['ref']) {
835
+ if (linkHref && isStaticResourcesEqual(linkHref, url) && linkRef === attrs['ref']) {
863
836
  link = l;
864
837
  needAttach = false;
865
838
  break;
@@ -867,15 +840,14 @@ function createLink(info) {
867
840
  }
868
841
  if (!link) {
869
842
  link = document.createElement('link');
870
- link.setAttribute('href', info.url);
871
- if (info.createLinkHook) {
872
- var createLinkRes = info.createLinkHook(info.url);
843
+ link.setAttribute('href', url);
844
+ if (createLinkHook) {
845
+ var createLinkRes = createLinkHook(url);
873
846
  if (_instanceof(createLinkRes, HTMLLinkElement)) {
874
847
  link = createLinkRes;
875
848
  }
876
849
  }
877
850
  }
878
- var attrs = info.attrs;
879
851
  if (attrs) {
880
852
  Object.keys(attrs).forEach(function(name) {
881
853
  if (link) {
@@ -895,11 +867,11 @@ function createLink(info) {
895
867
  if (prev) {
896
868
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
897
869
  var res = prev(event);
898
- info.cb();
870
+ cb();
899
871
  return res;
900
872
  }
901
873
  }
902
- info.cb();
874
+ cb();
903
875
  };
904
876
  link.onerror = onLinkComplete.bind(null, link.onerror);
905
877
  link.onload = onLinkComplete.bind(null, link.onload);
@@ -909,19 +881,10 @@ function createLink(info) {
909
881
  };
910
882
  }
911
883
  function loadScript(url, info) {
912
- var _info_attrs = info.attrs, attrs = _info_attrs === void 0 ? {} : _info_attrs, createScriptHook = info.createScriptHook;
884
+ var attrs = info.attrs, createScriptHook = info.createScriptHook;
913
885
  return new Promise(function(resolve, _reject) {
914
- var _createScript = createScript({
915
- url: url,
916
- cb: resolve,
917
- attrs: _object_spread$1({
918
- crossorigin: 'anonymous',
919
- fetchpriority: 'high'
920
- }, attrs),
921
- createScriptHook: createScriptHook,
922
- needDeleteScript: true
923
- }), script = _createScript.script, needAttach = _createScript.needAttach;
924
- needAttach && document.head.appendChild(script);
886
+ var _createScript = createScript(url, resolve, attrs, createScriptHook), script = _createScript.script, needAttach = _createScript.needAttach;
887
+ needAttach && document.getElementsByTagName('head')[0].appendChild(script);
925
888
  });
926
889
  }
927
890
 
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- function _define_property$4(obj, key, value) {
1
+ function _define_property$3(obj, key, value) {
2
2
  if (key in obj) {
3
3
  Object.defineProperty(obj, key, {
4
4
  value: value,
@@ -21,9 +21,9 @@ var NameTransformSymbol = {
21
21
  SLASH: '/'
22
22
  };
23
23
  var _obj;
24
- var NameTransformMap = (_obj = {}, _define_property$4(_obj, NameTransformSymbol.AT, 'scope_'), _define_property$4(_obj, NameTransformSymbol.HYPHEN, '_'), _define_property$4(_obj, NameTransformSymbol.SLASH, '__'), _obj);
24
+ var NameTransformMap = (_obj = {}, _define_property$3(_obj, NameTransformSymbol.AT, 'scope_'), _define_property$3(_obj, NameTransformSymbol.HYPHEN, '_'), _define_property$3(_obj, NameTransformSymbol.SLASH, '__'), _obj);
25
25
  var _obj1;
26
- var EncodedNameTransformMap = (_obj1 = {}, _define_property$4(_obj1, NameTransformMap[NameTransformSymbol.AT], NameTransformSymbol.AT), _define_property$4(_obj1, NameTransformMap[NameTransformSymbol.HYPHEN], NameTransformSymbol.HYPHEN), _define_property$4(_obj1, NameTransformMap[NameTransformSymbol.SLASH], NameTransformSymbol.SLASH), _obj1);
26
+ var EncodedNameTransformMap = (_obj1 = {}, _define_property$3(_obj1, NameTransformMap[NameTransformSymbol.AT], NameTransformSymbol.AT), _define_property$3(_obj1, NameTransformMap[NameTransformSymbol.HYPHEN], NameTransformSymbol.HYPHEN), _define_property$3(_obj1, NameTransformMap[NameTransformSymbol.SLASH], NameTransformSymbol.SLASH), _obj1);
27
27
  var SEPARATOR = ':';
28
28
  var ManifestFileName = 'mf-manifest.json';
29
29
  var StatsFileName = 'mf-stats.json';
@@ -89,7 +89,7 @@ function _create_class(Constructor, protoProps, staticProps) {
89
89
  if (staticProps) _defineProperties(Constructor, staticProps);
90
90
  return Constructor;
91
91
  }
92
- function _define_property$3(obj, key, value) {
92
+ function _define_property$2(obj, key, value) {
93
93
  if (key in obj) {
94
94
  Object.defineProperty(obj, key, {
95
95
  value: value,
@@ -140,8 +140,8 @@ function safeGetLocalStorageItem() {
140
140
  var Logger = /*#__PURE__*/ function() {
141
141
  function Logger(identifier) {
142
142
  _class_call_check(this, Logger);
143
- _define_property$3(this, "enable", false);
144
- _define_property$3(this, "identifier", void 0);
143
+ _define_property$2(this, "enable", false);
144
+ _define_property$2(this, "identifier", void 0);
145
145
  this.identifier = identifier || DEBUG_LOG;
146
146
  if (isBrowserEnv() && safeGetLocalStorageItem()) {
147
147
  this.enable = true;
@@ -370,7 +370,7 @@ var warn = function(msg) {
370
370
  console.warn("".concat(LOG_CATEGORY, ": ").concat(msg));
371
371
  };
372
372
 
373
- function _define_property$2(obj, key, value) {
373
+ function _define_property$1(obj, key, value) {
374
374
  if (key in obj) {
375
375
  Object.defineProperty(obj, key, {
376
376
  value: value,
@@ -383,7 +383,7 @@ function _define_property$2(obj, key, value) {
383
383
  }
384
384
  return obj;
385
385
  }
386
- function _object_spread$2(target) {
386
+ function _object_spread$1(target) {
387
387
  for(var i = 1; i < arguments.length; i++){
388
388
  var source = arguments[i] != null ? arguments[i] : {};
389
389
  var ownKeys = Object.keys(source);
@@ -393,7 +393,7 @@ function _object_spread$2(target) {
393
393
  }));
394
394
  }
395
395
  ownKeys.forEach(function(key) {
396
- _define_property$2(target, key, source[key]);
396
+ _define_property$1(target, key, source[key]);
397
397
  });
398
398
  }
399
399
  return target;
@@ -503,7 +503,7 @@ function generateSnapshotFromManifest(manifest) {
503
503
  matchedVersion: overridesKeys.includes(key) ? overrides[key] : remotes[key]
504
504
  };
505
505
  });
506
- var _manifest_metaData2 = manifest.metaData, _manifest_metaData_remoteEntry = _manifest_metaData2.remoteEntry, remoteEntryPath = _manifest_metaData_remoteEntry.path, remoteEntryName = _manifest_metaData_remoteEntry.name, remoteEntryType = _manifest_metaData_remoteEntry.type, remoteTypes = _manifest_metaData2.types, buildVersion = _manifest_metaData2.buildInfo.buildVersion, globalName = _manifest_metaData2.globalName;
506
+ var _manifest_metaData2 = manifest.metaData, _manifest_metaData_remoteEntry = _manifest_metaData2.remoteEntry, remoteEntryPath = _manifest_metaData_remoteEntry.path, remoteEntryName = _manifest_metaData_remoteEntry.name, remoteEntryType = _manifest_metaData_remoteEntry.type, remoteTypes = _manifest_metaData2.types, buildVersion = _manifest_metaData2.buildInfo.buildVersion, globalName = _manifest_metaData2.globalName, ssrRemoteEntry = _manifest_metaData2.ssrRemoteEntry;
507
507
  var exposes = manifest.exposes;
508
508
  var basicRemoteSnapshot = {
509
509
  version: version ? version : '',
@@ -532,26 +532,31 @@ function generateSnapshotFromManifest(manifest) {
532
532
  };
533
533
  if ((_manifest_metaData = manifest.metaData) === null || _manifest_metaData === void 0 ? void 0 : _manifest_metaData.prefetchInterface) {
534
534
  var prefetchInterface = manifest.metaData.prefetchInterface;
535
- basicRemoteSnapshot = _object_spread_props(_object_spread$2({}, basicRemoteSnapshot), {
535
+ basicRemoteSnapshot = _object_spread_props(_object_spread$1({}, basicRemoteSnapshot), {
536
536
  prefetchInterface: prefetchInterface
537
537
  });
538
538
  }
539
539
  if ((_manifest_metaData1 = manifest.metaData) === null || _manifest_metaData1 === void 0 ? void 0 : _manifest_metaData1.prefetchEntry) {
540
540
  var _manifest_metaData_prefetchEntry = manifest.metaData.prefetchEntry, path = _manifest_metaData_prefetchEntry.path, name = _manifest_metaData_prefetchEntry.name, type = _manifest_metaData_prefetchEntry.type;
541
- basicRemoteSnapshot = _object_spread_props(_object_spread$2({}, basicRemoteSnapshot), {
541
+ basicRemoteSnapshot = _object_spread_props(_object_spread$1({}, basicRemoteSnapshot), {
542
542
  prefetchEntry: simpleJoinRemoteEntry(path, name),
543
543
  prefetchEntryType: type
544
544
  });
545
545
  }
546
546
  if ('publicPath' in manifest.metaData) {
547
- remoteSnapshot = _object_spread_props(_object_spread$2({}, basicRemoteSnapshot), {
547
+ remoteSnapshot = _object_spread_props(_object_spread$1({}, basicRemoteSnapshot), {
548
548
  publicPath: getPublicPath()
549
549
  });
550
550
  } else {
551
- remoteSnapshot = _object_spread_props(_object_spread$2({}, basicRemoteSnapshot), {
551
+ remoteSnapshot = _object_spread_props(_object_spread$1({}, basicRemoteSnapshot), {
552
552
  getPublicPath: getPublicPath()
553
553
  });
554
554
  }
555
+ if (ssrRemoteEntry) {
556
+ var fullSSRRemoteEntry = simpleJoinRemoteEntry(ssrRemoteEntry.path, ssrRemoteEntry.name);
557
+ remoteSnapshot.ssrRemoteEntry = fullSSRRemoteEntry;
558
+ remoteSnapshot.ssrRemoteEntryType = 'cjs:webpack';
559
+ }
555
560
  return remoteSnapshot;
556
561
  }
557
562
  function isManifestProvider(moduleInfo) {
@@ -591,19 +596,6 @@ function _async_to_generator$1(fn) {
591
596
  });
592
597
  };
593
598
  }
594
- function _define_property$1(obj, key, value) {
595
- if (key in obj) {
596
- Object.defineProperty(obj, key, {
597
- value: value,
598
- enumerable: true,
599
- configurable: true,
600
- writable: true
601
- });
602
- } else {
603
- obj[key] = value;
604
- }
605
- return obj;
606
- }
607
599
  function _instanceof(left, right) {
608
600
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
609
601
  return !!right[Symbol.hasInstance](left);
@@ -611,21 +603,6 @@ function _instanceof(left, right) {
611
603
  return left instanceof right;
612
604
  }
613
605
  }
614
- function _object_spread$1(target) {
615
- for(var i = 1; i < arguments.length; i++){
616
- var source = arguments[i] != null ? arguments[i] : {};
617
- var ownKeys = Object.keys(source);
618
- if (typeof Object.getOwnPropertySymbols === "function") {
619
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
620
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
621
- }));
622
- }
623
- ownKeys.forEach(function(key) {
624
- _define_property$1(target, key, source[key]);
625
- });
626
- }
627
- return target;
628
- }
629
606
  function _ts_generator$1(thisArg, body) {
630
607
  var f, y, t, g, _ = {
631
608
  label: 0,
@@ -770,7 +747,7 @@ function isStaticResourcesEqual(url1, url2) {
770
747
  // Check if the relative paths are identical
771
748
  return relativeUrl1 === relativeUrl2;
772
749
  }
773
- function createScript(info) {
750
+ function createScript(url, cb, attrs, createScriptHook) {
774
751
  // Retrieve the existing script element by its src attribute
775
752
  var script = null;
776
753
  var needAttach = true;
@@ -780,7 +757,7 @@ function createScript(info) {
780
757
  for(var i = 0; i < scripts.length; i++){
781
758
  var s = scripts[i];
782
759
  var scriptSrc = s.getAttribute('src');
783
- if (scriptSrc && isStaticResourcesEqual(scriptSrc, info.url)) {
760
+ if (scriptSrc && isStaticResourcesEqual(scriptSrc, url)) {
784
761
  script = s;
785
762
  needAttach = false;
786
763
  break;
@@ -789,9 +766,9 @@ function createScript(info) {
789
766
  if (!script) {
790
767
  script = document.createElement('script');
791
768
  script.type = 'text/javascript';
792
- script.src = info.url;
793
- if (info.createScriptHook) {
794
- var createScriptRes = info.createScriptHook(info.url);
769
+ script.src = url;
770
+ if (createScriptHook) {
771
+ var createScriptRes = createScriptHook(url);
795
772
  if (_instanceof(createScriptRes, HTMLScriptElement)) {
796
773
  script = createScriptRes;
797
774
  } else if (typeof createScriptRes === 'object') {
@@ -800,7 +777,6 @@ function createScript(info) {
800
777
  }
801
778
  }
802
779
  }
803
- var attrs = info.attrs;
804
780
  if (attrs) {
805
781
  Object.keys(attrs).forEach(function(name) {
806
782
  if (script) {
@@ -814,38 +790,35 @@ function createScript(info) {
814
790
  }
815
791
  var onScriptComplete = function(prev, // eslint-disable-next-line @typescript-eslint/no-explicit-any
816
792
  event) {
817
- var _info_cb;
818
793
  clearTimeout(timeoutId);
819
794
  // Prevent memory leaks in IE.
820
795
  if (script) {
821
796
  script.onerror = null;
822
797
  script.onload = null;
823
798
  safeWrapper(function() {
824
- if (info.needDeleteScript) {
825
- (script === null || script === void 0 ? void 0 : script.parentNode) && script.parentNode.removeChild(script);
826
- }
799
+ (script === null || script === void 0 ? void 0 : script.parentNode) && script.parentNode.removeChild(script);
827
800
  });
828
801
  if (prev) {
829
- var _info_cb1;
830
802
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
831
803
  var res = prev(event);
832
- info === null || info === void 0 ? void 0 : (_info_cb1 = info.cb) === null || _info_cb1 === void 0 ? void 0 : _info_cb1.call(info);
804
+ cb();
833
805
  return res;
834
806
  }
835
807
  }
836
- info === null || info === void 0 ? void 0 : (_info_cb = info.cb) === null || _info_cb === void 0 ? void 0 : _info_cb.call(info);
808
+ cb();
837
809
  };
838
810
  script.onerror = onScriptComplete.bind(null, script.onerror);
839
811
  script.onload = onScriptComplete.bind(null, script.onload);
840
812
  timeoutId = setTimeout(function() {
841
- onScriptComplete(null, new Error('Remote script "'.concat(info.url, '" time-outed.')));
813
+ onScriptComplete(null, new Error('Remote script "'.concat(url, '" time-outed.')));
842
814
  }, timeout);
843
815
  return {
844
816
  script: script,
845
817
  needAttach: needAttach
846
818
  };
847
819
  }
848
- function createLink(info) {
820
+ function createLink(url, cb) {
821
+ var attrs = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, createLinkHook = arguments.length > 3 ? arguments[3] : void 0;
849
822
  // <link rel="preload" href="script.js" as="script">
850
823
  // Retrieve the existing script element by its src attribute
851
824
  var link = null;
@@ -855,7 +828,7 @@ function createLink(info) {
855
828
  var l = links[i];
856
829
  var linkHref = l.getAttribute('href');
857
830
  var linkRef = l.getAttribute('ref');
858
- if (linkHref && isStaticResourcesEqual(linkHref, info.url) && linkRef === info.attrs['ref']) {
831
+ if (linkHref && isStaticResourcesEqual(linkHref, url) && linkRef === attrs['ref']) {
859
832
  link = l;
860
833
  needAttach = false;
861
834
  break;
@@ -863,15 +836,14 @@ function createLink(info) {
863
836
  }
864
837
  if (!link) {
865
838
  link = document.createElement('link');
866
- link.setAttribute('href', info.url);
867
- if (info.createLinkHook) {
868
- var createLinkRes = info.createLinkHook(info.url);
839
+ link.setAttribute('href', url);
840
+ if (createLinkHook) {
841
+ var createLinkRes = createLinkHook(url);
869
842
  if (_instanceof(createLinkRes, HTMLLinkElement)) {
870
843
  link = createLinkRes;
871
844
  }
872
845
  }
873
846
  }
874
- var attrs = info.attrs;
875
847
  if (attrs) {
876
848
  Object.keys(attrs).forEach(function(name) {
877
849
  if (link) {
@@ -891,11 +863,11 @@ function createLink(info) {
891
863
  if (prev) {
892
864
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
893
865
  var res = prev(event);
894
- info.cb();
866
+ cb();
895
867
  return res;
896
868
  }
897
869
  }
898
- info.cb();
870
+ cb();
899
871
  };
900
872
  link.onerror = onLinkComplete.bind(null, link.onerror);
901
873
  link.onload = onLinkComplete.bind(null, link.onload);
@@ -905,19 +877,10 @@ function createLink(info) {
905
877
  };
906
878
  }
907
879
  function loadScript(url, info) {
908
- var _info_attrs = info.attrs, attrs = _info_attrs === void 0 ? {} : _info_attrs, createScriptHook = info.createScriptHook;
880
+ var attrs = info.attrs, createScriptHook = info.createScriptHook;
909
881
  return new Promise(function(resolve, _reject) {
910
- var _createScript = createScript({
911
- url: url,
912
- cb: resolve,
913
- attrs: _object_spread$1({
914
- crossorigin: 'anonymous',
915
- fetchpriority: 'high'
916
- }, attrs),
917
- createScriptHook: createScriptHook,
918
- needDeleteScript: true
919
- }), script = _createScript.script, needAttach = _createScript.needAttach;
920
- needAttach && document.head.appendChild(script);
882
+ var _createScript = createScript(url, resolve, attrs, createScriptHook), script = _createScript.script, needAttach = _createScript.needAttach;
883
+ needAttach && document.getElementsByTagName('head')[0].appendChild(script);
921
884
  });
922
885
  }
923
886
 
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/sdk",
3
- "version": "0.1.18",
3
+ "version": "0.1.15",
4
4
  "license": "MIT",
5
5
  "description": "A sdk for support module federation",
6
6
  "keywords": [
package/dist/src/dom.d.ts CHANGED
@@ -4,22 +4,11 @@ export type CreateScriptHookReturn = HTMLScriptElement | {
4
4
  script?: HTMLScriptElement;
5
5
  timeout?: number;
6
6
  } | void;
7
- export declare function createScript(info: {
8
- url: string;
9
- cb?: (value: void | PromiseLike<void>) => void;
10
- attrs?: Record<string, any>;
11
- needDeleteScript?: boolean;
12
- createScriptHook?: (url: string) => CreateScriptHookReturn;
13
- }): {
7
+ export declare function createScript(url: string, cb: (value: void | PromiseLike<void>) => void, attrs?: Record<string, any>, createScriptHook?: (url: string) => CreateScriptHookReturn): {
14
8
  script: HTMLScriptElement;
15
9
  needAttach: boolean;
16
10
  };
17
- export declare function createLink(info: {
18
- url: string;
19
- cb: (value: void | PromiseLike<void>) => void;
20
- attrs: Record<string, string>;
21
- createLinkHook?: (url: string) => HTMLLinkElement | void;
22
- }): {
11
+ export declare function createLink(url: string, cb: (value: void | PromiseLike<void>) => void, attrs?: Record<string, string>, createLinkHook?: (url: string) => HTMLLinkElement | void): {
23
12
  link: HTMLLinkElement;
24
13
  needAttach: boolean;
25
14
  };
@@ -82,6 +82,7 @@ export interface PluginManifestOptions {
82
82
  export interface PluginDevOptions {
83
83
  disableLiveReload?: boolean;
84
84
  disableHotTypesReload?: boolean;
85
+ injectWebClient?: boolean;
85
86
  }
86
87
  export interface DtsHostOptions {
87
88
  typesFolder?: string;
@@ -111,6 +112,10 @@ export interface PluginDtsOptions {
111
112
  extraOptions?: Record<string, any>;
112
113
  implementation?: string;
113
114
  }
115
+ export type AsyncBoundaryOptions = {
116
+ eager?: RegExp | ((module: any) => boolean);
117
+ excludeChunk?: (chunk: any) => boolean;
118
+ };
114
119
  export interface ModuleFederationPluginOptions {
115
120
  /**
116
121
  * Modules that should be exposed by this container. When provided, property name is used as public name, otherwise public name is automatically inferred from request.
@@ -159,6 +164,7 @@ export interface ModuleFederationPluginOptions {
159
164
  manifest?: boolean | PluginManifestOptions;
160
165
  dev?: boolean | PluginDevOptions;
161
166
  dts?: boolean | PluginDtsOptions;
167
+ async?: boolean | AsyncBoundaryOptions;
162
168
  }
163
169
  /**
164
170
  * Modules that should be exposed by this container. Property names are used as public paths.
@@ -23,6 +23,8 @@ interface BasicModuleInfo {
23
23
  export interface BasicProviderModuleInfo extends BasicModuleInfo {
24
24
  remoteEntry: string;
25
25
  remoteEntryType: RemoteEntryType;
26
+ ssrRemoteEntry?: string;
27
+ ssrRemoteEntryType?: RemoteEntryType;
26
28
  remoteManifest?: string;
27
29
  globalName: string;
28
30
  modules: Array<{
@@ -42,6 +44,7 @@ interface BasicProviderModuleInfoWithGetPublicPath extends BasicProviderModuleIn
42
44
  }
43
45
  export interface ManifestProvider {
44
46
  remoteEntry: string;
47
+ ssrRemoteEntry?: string;
45
48
  version?: string;
46
49
  }
47
50
  export interface PureEntryProvider extends ManifestProvider {
@@ -1,6 +1,6 @@
1
1
  import type { RemoteWithEntry, RemoteWithVersion } from './common';
2
- export type RemoteEntryType = 'var' | 'module' | 'assign' | 'assign-properties' | 'this' | 'window' | 'self' | 'global' | 'commonjs' | 'commonjs2' | 'commonjs-module' | 'commonjs-static' | 'amd' | 'amd-require' | 'umd' | 'umd2' | 'jsonp' | 'system' | string;
3
- interface ResourceInfo {
2
+ export type RemoteEntryType = 'esm' | 'global' | 'cjs:webpack';
3
+ export interface ResourceInfo {
4
4
  path: string;
5
5
  name: string;
6
6
  type: RemoteEntryType;
@@ -20,6 +20,7 @@ export interface BasicStatsMetaData {
20
20
  globalName: string;
21
21
  buildInfo: StatsBuildInfo;
22
22
  remoteEntry: ResourceInfo;
23
+ ssrRemoteEntry?: ResourceInfo;
23
24
  prefetchInterface?: boolean;
24
25
  prefetchEntry?: ResourceInfo;
25
26
  types: MetaDataTypes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/sdk",
3
- "version": "0.0.0-next-20240605063149",
3
+ "version": "0.0.0-next-20240605083609",
4
4
  "license": "MIT",
5
5
  "description": "A sdk for support module federation",
6
6
  "keywords": [