@module-federation/runtime 0.0.0-next-20240829065118 → 0.0.0-next-20240830065016

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 { isBrowserEnv, loadScriptNode, composeKeyWithSeparator, loadScript, safeToString, createLink, createScript, getResourceUrl, isManifestProvider, generateSnapshotFromManifest, warn as warn$1 } from '@module-federation/sdk';
1
+ import { g as globalLoading, D as DEFAULT_REMOTE_TYPE, a as DEFAULT_SCOPE, b as getRemoteEntryExports, c as assert, s as safeToString, d as getFMId, i as isRemoteInfoWithEntry, e as isPureRemoteEntry, f as getRemoteEntryInfoFromSnapshot, h as error, j as isBrowserEnv$1, k as getInfoWithoutType, l as getPreloaded, m as setPreloaded, n as getRegisteredShare, o as arrayOptions, p as getGlobalSnapshotInfoByModuleInfo, q as addGlobalSnapshot, r as setGlobalSnapshotInfoByModuleInfo, P as PluginSystem, A as AsyncHook, t as AsyncWaterfallHook, G as Global, u as getGlobalSnapshot, v as formatShareConfigs, w as getTargetSharedOptions, x as getGlobalShareScope, S as SyncWaterfallHook, y as addUniqueItem, z as SyncHook, B as registerPlugins$1, 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 } from '@module-federation/sdk';
3
4
  export { loadScript, loadScriptNode } from '@module-federation/sdk';
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
- export { H as registerGlobalPlugins } from './share.esm.js';
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
@@ -69,26 +67,20 @@ function matchRemote(remotes, nameOrAlias) {
69
67
  return;
70
68
  }
71
69
 
72
- function registerPlugins$1(plugins, hookInstances) {
73
- const globalPlugins = getGlobalHostPlugins();
74
- // Incorporate global plugins
75
- if (globalPlugins.length > 0) {
76
- globalPlugins.forEach((plugin)=>{
77
- if (plugins == null ? void 0 : plugins.find((item)=>item.name !== plugin.name)) {
78
- plugins.push(plugin);
70
+ function _extends$7() {
71
+ _extends$7 = Object.assign || function(target) {
72
+ for(var i = 1; i < arguments.length; i++){
73
+ var source = arguments[i];
74
+ for(var key in source){
75
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
76
+ target[key] = source[key];
77
+ }
79
78
  }
80
- });
81
- }
82
- if (plugins && plugins.length > 0) {
83
- plugins.forEach((plugin)=>{
84
- hookInstances.forEach((hookInstance)=>{
85
- hookInstance.applyPlugin(plugin);
86
- });
87
- });
88
- }
89
- return plugins;
79
+ }
80
+ return target;
81
+ };
82
+ return _extends$7.apply(this, arguments);
90
83
  }
91
-
92
84
  async function loadEsmEntry({ entry, remoteEntryExports }) {
93
85
  return new Promise((resolve, reject)=>{
94
86
  try {
@@ -251,7 +243,7 @@ async function getRemoteEntry({ origin, remoteEntryExports, remoteInfo }) {
251
243
  return globalLoading[uniqueKey];
252
244
  }
253
245
  function getRemoteInfo(remote) {
254
- return _({}, remote, {
246
+ return _extends$7({}, remote, {
255
247
  entry: 'entry' in remote ? remote.entry : '',
256
248
  type: remote.type || DEFAULT_REMOTE_TYPE,
257
249
  entryGlobalName: remote.entryGlobalName || remote.name,
@@ -259,6 +251,20 @@ function getRemoteInfo(remote) {
259
251
  });
260
252
  }
261
253
 
254
+ function _extends$6() {
255
+ _extends$6 = Object.assign || function(target) {
256
+ for(var i = 1; i < arguments.length; i++){
257
+ var source = arguments[i];
258
+ for(var key in source){
259
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
260
+ target[key] = source[key];
261
+ }
262
+ }
263
+ }
264
+ return target;
265
+ };
266
+ return _extends$6.apply(this, arguments);
267
+ }
262
268
  let Module = class Module {
263
269
  async getEntry() {
264
270
  if (this.remoteEntryExports) {
@@ -310,7 +316,7 @@ let Module = class Module {
310
316
  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
317
  }
312
318
  await remoteEntryExports.init(initContainerOptions.shareScope, initContainerOptions.initScope, initContainerOptions.remoteEntryInitOptions);
313
- await this.host.hooks.lifecycle.initContainer.emit(_({}, initContainerOptions, {
319
+ await this.host.hooks.lifecycle.initContainer.emit(_extends$6({}, initContainerOptions, {
314
320
  remoteEntryExports
315
321
  }));
316
322
  }
@@ -359,195 +365,22 @@ let Module = class Module {
359
365
  }
360
366
  };
361
367
 
362
- class SyncHook {
363
- on(fn) {
364
- if (typeof fn === 'function') {
365
- this.listeners.add(fn);
366
- }
367
- }
368
- once(fn) {
369
- // eslint-disable-next-line @typescript-eslint/no-this-alias
370
- const self = this;
371
- this.on(function wrapper(...args) {
372
- self.remove(wrapper);
373
- // eslint-disable-next-line prefer-spread
374
- return fn.apply(null, args);
375
- });
376
- }
377
- emit(...data) {
378
- let result;
379
- if (this.listeners.size > 0) {
380
- // eslint-disable-next-line prefer-spread
381
- this.listeners.forEach((fn)=>{
382
- result = fn(...data);
383
- });
384
- }
385
- return result;
386
- }
387
- remove(fn) {
388
- this.listeners.delete(fn);
389
- }
390
- removeAll() {
391
- this.listeners.clear();
392
- }
393
- constructor(type){
394
- this.type = '';
395
- this.listeners = new Set();
396
- if (type) {
397
- this.type = type;
398
- }
399
- }
400
- }
401
-
402
- class AsyncHook extends SyncHook {
403
- emit(...data) {
404
- let result;
405
- const ls = Array.from(this.listeners);
406
- if (ls.length > 0) {
407
- let i = 0;
408
- const call = (prev)=>{
409
- if (prev === false) {
410
- return false; // Abort process
411
- } else if (i < ls.length) {
412
- return Promise.resolve(ls[i++].apply(null, data)).then(call);
413
- } else {
414
- return prev;
415
- }
416
- };
417
- result = call();
418
- }
419
- return Promise.resolve(result);
420
- }
421
- }
422
-
423
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
424
- function checkReturnData(originalData, returnedData) {
425
- if (!isObject(returnedData)) {
426
- return false;
427
- }
428
- if (originalData !== returnedData) {
429
- // eslint-disable-next-line no-restricted-syntax
430
- for(const key in originalData){
431
- if (!(key in returnedData)) {
432
- return false;
433
- }
434
- }
435
- }
436
- return true;
437
- }
438
- class SyncWaterfallHook extends SyncHook {
439
- emit(data) {
440
- if (!isObject(data)) {
441
- error(`The data for the "${this.type}" hook should be an object.`);
442
- }
443
- for (const fn of this.listeners){
444
- try {
445
- const tempData = fn(data);
446
- if (checkReturnData(data, tempData)) {
447
- data = tempData;
448
- } else {
449
- this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`);
450
- break;
368
+ function _extends$5() {
369
+ _extends$5 = Object.assign || function(target) {
370
+ for(var i = 1; i < arguments.length; i++){
371
+ var source = arguments[i];
372
+ for(var key in source){
373
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
374
+ target[key] = source[key];
451
375
  }
452
- } catch (e) {
453
- warn(e);
454
- this.onerror(e);
455
376
  }
456
377
  }
457
- return data;
458
- }
459
- constructor(type){
460
- super();
461
- this.onerror = error;
462
- this.type = type;
463
- }
464
- }
465
-
466
- class AsyncWaterfallHook extends SyncHook {
467
- emit(data) {
468
- if (!isObject(data)) {
469
- error(`The response data for the "${this.type}" hook must be an object.`);
470
- }
471
- const ls = Array.from(this.listeners);
472
- if (ls.length > 0) {
473
- let i = 0;
474
- const processError = (e)=>{
475
- warn(e);
476
- this.onerror(e);
477
- return data;
478
- };
479
- const call = (prevData)=>{
480
- if (checkReturnData(data, prevData)) {
481
- data = prevData;
482
- if (i < ls.length) {
483
- try {
484
- return Promise.resolve(ls[i++](data)).then(call, processError);
485
- } catch (e) {
486
- return processError(e);
487
- }
488
- }
489
- } else {
490
- this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);
491
- }
492
- return data;
493
- };
494
- return Promise.resolve(call(data));
495
- }
496
- return Promise.resolve(data);
497
- }
498
- constructor(type){
499
- super();
500
- this.onerror = error;
501
- this.type = type;
502
- }
503
- }
504
-
505
- class PluginSystem {
506
- applyPlugin(plugin) {
507
- assert(isPlainObject(plugin), 'Plugin configuration is invalid.');
508
- // The plugin's name is mandatory and must be unique
509
- const pluginName = plugin.name;
510
- assert(pluginName, 'A name must be provided by the plugin.');
511
- if (!this.registerPlugins[pluginName]) {
512
- this.registerPlugins[pluginName] = plugin;
513
- Object.keys(this.lifecycle).forEach((key)=>{
514
- const pluginLife = plugin[key];
515
- if (pluginLife) {
516
- this.lifecycle[key].on(pluginLife);
517
- }
518
- });
519
- }
520
- }
521
- removePlugin(pluginName) {
522
- assert(pluginName, 'A name is required.');
523
- const plugin = this.registerPlugins[pluginName];
524
- assert(plugin, `The plugin "${pluginName}" is not registered.`);
525
- Object.keys(plugin).forEach((key)=>{
526
- if (key !== 'name') {
527
- this.lifecycle[key].remove(plugin[key]);
528
- }
529
- });
530
- }
531
- // eslint-disable-next-line @typescript-eslint/no-shadow
532
- inherit({ lifecycle, registerPlugins }) {
533
- Object.keys(lifecycle).forEach((hookName)=>{
534
- assert(!this.lifecycle[hookName], `The hook "${hookName}" has a conflict and cannot be inherited.`);
535
- this.lifecycle[hookName] = lifecycle[hookName];
536
- });
537
- Object.keys(registerPlugins).forEach((pluginName)=>{
538
- assert(!this.registerPlugins[pluginName], `The plugin "${pluginName}" has a conflict and cannot be inherited.`);
539
- this.applyPlugin(registerPlugins[pluginName]);
540
- });
541
- }
542
- constructor(lifecycle){
543
- this.registerPlugins = {};
544
- this.lifecycle = lifecycle;
545
- this.lifecycleKeys = Object.keys(lifecycle);
546
- }
378
+ return target;
379
+ };
380
+ return _extends$5.apply(this, arguments);
547
381
  }
548
-
549
382
  function defaultPreloadArgs(preloadConfig) {
550
- return _({
383
+ return _extends$5({
551
384
  resourceCategory: 'sync',
552
385
  share: true,
553
386
  depsRemote: true,
@@ -703,13 +536,27 @@ useLinkPreload = true) {
703
536
  }
704
537
  }
705
538
 
539
+ function _extends$4() {
540
+ _extends$4 = Object.assign || function(target) {
541
+ for(var i = 1; i < arguments.length; i++){
542
+ var source = arguments[i];
543
+ for(var key in source){
544
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
545
+ target[key] = source[key];
546
+ }
547
+ }
548
+ }
549
+ return target;
550
+ };
551
+ return _extends$4.apply(this, arguments);
552
+ }
706
553
  function assignRemoteInfo(remoteInfo, remoteSnapshot) {
707
554
  const remoteEntryInfo = getRemoteEntryInfoFromSnapshot(remoteSnapshot);
708
555
  if (!remoteEntryInfo.url) {
709
556
  error(`The attribute remoteEntry of ${remoteInfo.name} must not be undefined.`);
710
557
  }
711
558
  let entryUrl = getResourceUrl(remoteSnapshot, remoteEntryInfo.url);
712
- if (!isBrowserEnv() && !entryUrl.startsWith('http')) {
559
+ if (!isBrowserEnv$1() && !entryUrl.startsWith('http')) {
713
560
  entryUrl = `https:${entryUrl}`;
714
561
  }
715
562
  remoteInfo.type = remoteEntryInfo.type;
@@ -750,7 +597,7 @@ function snapshotPlugin() {
750
597
  if (assets) {
751
598
  preloadAssets(remoteInfo, origin, assets, false);
752
599
  }
753
- return _({}, args, {
600
+ return _extends$4({}, args, {
754
601
  remoteSnapshot
755
602
  });
756
603
  }
@@ -971,6 +818,20 @@ const generatePreloadAssetsPlugin = function() {
971
818
  };
972
819
  };
973
820
 
821
+ function _extends$3() {
822
+ _extends$3 = Object.assign || function(target) {
823
+ for(var i = 1; i < arguments.length; i++){
824
+ var source = arguments[i];
825
+ for(var key in source){
826
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
827
+ target[key] = source[key];
828
+ }
829
+ }
830
+ }
831
+ return target;
832
+ };
833
+ return _extends$3.apply(this, arguments);
834
+ }
974
835
  function getGlobalRemoteInfo(moduleInfo, origin) {
975
836
  const hostGlobalSnapshot = getGlobalSnapshotInfoByModuleInfo({
976
837
  name: origin.options.name,
@@ -1038,7 +899,7 @@ class SnapshotHandler {
1038
899
  // 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
900
  if (hostSnapshot && 'remotesInfo' in hostSnapshot && !getInfoWithoutType(hostSnapshot.remotesInfo, moduleInfo.name).value) {
1040
901
  if ('version' in moduleInfo || 'entry' in moduleInfo) {
1041
- hostSnapshot.remotesInfo = _({}, hostSnapshot == null ? void 0 : hostSnapshot.remotesInfo, {
902
+ hostSnapshot.remotesInfo = _extends$3({}, hostSnapshot == null ? void 0 : hostSnapshot.remotesInfo, {
1042
903
  [moduleInfo.name]: {
1043
904
  matchedVersion: 'version' in moduleInfo ? moduleInfo.version : moduleInfo.entry
1044
905
  }
@@ -1053,21 +914,21 @@ class SnapshotHandler {
1053
914
  remoteSnapshot,
1054
915
  globalSnapshot
1055
916
  });
917
+ let mSnapshot;
918
+ let gSnapshot;
1056
919
  // global snapshot includes manifest or module info includes manifest
1057
920
  if (globalRemoteSnapshot) {
1058
921
  if (isManifestProvider(globalRemoteSnapshot)) {
1059
- const remoteEntry = isBrowserEnv() ? globalRemoteSnapshot.remoteEntry : globalRemoteSnapshot.ssrRemoteEntry || globalRemoteSnapshot.remoteEntry || '';
922
+ const remoteEntry = isBrowserEnv$1() ? globalRemoteSnapshot.remoteEntry : globalRemoteSnapshot.ssrRemoteEntry || globalRemoteSnapshot.remoteEntry || '';
1060
923
  const moduleSnapshot = await this.getManifestJson(remoteEntry, moduleInfo, {});
1061
924
  // eslint-disable-next-line @typescript-eslint/no-shadow
1062
- const globalSnapshotRes = setGlobalSnapshotInfoByModuleInfo(_({}, moduleInfo, {
925
+ const globalSnapshotRes = setGlobalSnapshotInfoByModuleInfo(_extends$3({}, moduleInfo, {
1063
926
  // The global remote may be overridden
1064
927
  // Therefore, set the snapshot key to the global address of the actual request
1065
928
  entry: remoteEntry
1066
929
  }), moduleSnapshot);
1067
- return {
1068
- remoteSnapshot: moduleSnapshot,
1069
- globalSnapshot: globalSnapshotRes
1070
- };
930
+ mSnapshot = moduleSnapshot;
931
+ gSnapshot = globalSnapshotRes;
1071
932
  } else {
1072
933
  const { remoteSnapshot: remoteSnapshotRes } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
1073
934
  options: this.HostInstance.options,
@@ -1075,10 +936,8 @@ class SnapshotHandler {
1075
936
  remoteSnapshot: globalRemoteSnapshot,
1076
937
  from: 'global'
1077
938
  });
1078
- return {
1079
- remoteSnapshot: remoteSnapshotRes,
1080
- globalSnapshot: globalSnapshotRes
1081
- };
939
+ mSnapshot = remoteSnapshotRes;
940
+ gSnapshot = globalSnapshotRes;
1082
941
  }
1083
942
  } else {
1084
943
  if (isRemoteInfoWithEntry(moduleInfo)) {
@@ -1092,10 +951,8 @@ class SnapshotHandler {
1092
951
  remoteSnapshot: moduleSnapshot,
1093
952
  from: 'global'
1094
953
  });
1095
- return {
1096
- remoteSnapshot: remoteSnapshotRes,
1097
- globalSnapshot: globalSnapshotRes
1098
- };
954
+ mSnapshot = remoteSnapshotRes;
955
+ gSnapshot = globalSnapshotRes;
1099
956
  } else {
1100
957
  error(`
1101
958
  Cannot get remoteSnapshot with the name: '${moduleInfo.name}', version: '${moduleInfo.version}' from __FEDERATION__.moduleInfo. The following reasons may be causing the problem:\n
@@ -1105,6 +962,15 @@ class SnapshotHandler {
1105
962
  `);
1106
963
  }
1107
964
  }
965
+ await this.hooks.lifecycle.afterLoadSnapshot.emit({
966
+ options,
967
+ moduleInfo,
968
+ remoteSnapshot: mSnapshot
969
+ });
970
+ return {
971
+ remoteSnapshot: mSnapshot,
972
+ globalSnapshot: gSnapshot
973
+ };
1108
974
  }
1109
975
  getGlobalRemoteInfo(moduleInfo) {
1110
976
  return getGlobalRemoteInfo(moduleInfo, this.HostInstance);
@@ -1157,7 +1023,8 @@ class SnapshotHandler {
1157
1023
  this.hooks = new PluginSystem({
1158
1024
  beforeLoadRemoteSnapshot: new AsyncHook('beforeLoadRemoteSnapshot'),
1159
1025
  loadSnapshot: new AsyncWaterfallHook('loadGlobalSnapshot'),
1160
- loadRemoteSnapshot: new AsyncWaterfallHook('loadRemoteSnapshot')
1026
+ loadRemoteSnapshot: new AsyncWaterfallHook('loadRemoteSnapshot'),
1027
+ afterLoadSnapshot: new AsyncWaterfallHook('afterLoadSnapshot')
1161
1028
  });
1162
1029
  this.manifestLoading = Global.__FEDERATION__.__MANIFEST_LOADING__;
1163
1030
  this.HostInstance = HostInstance;
@@ -1165,6 +1032,32 @@ class SnapshotHandler {
1165
1032
  }
1166
1033
  }
1167
1034
 
1035
+ function _extends$2() {
1036
+ _extends$2 = Object.assign || function(target) {
1037
+ for(var i = 1; i < arguments.length; i++){
1038
+ var source = arguments[i];
1039
+ for(var key in source){
1040
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1041
+ target[key] = source[key];
1042
+ }
1043
+ }
1044
+ }
1045
+ return target;
1046
+ };
1047
+ return _extends$2.apply(this, arguments);
1048
+ }
1049
+ function _object_without_properties_loose(source, excluded) {
1050
+ if (source == null) return {};
1051
+ var target = {};
1052
+ var sourceKeys = Object.keys(source);
1053
+ var key, i;
1054
+ for(i = 0; i < sourceKeys.length; i++){
1055
+ key = sourceKeys[i];
1056
+ if (excluded.indexOf(key) >= 0) continue;
1057
+ target[key] = source[key];
1058
+ }
1059
+ return target;
1060
+ }
1168
1061
  class SharedHandler {
1169
1062
  // register shared in shareScopeMap
1170
1063
  registerShared(globalOptions, userOptions) {
@@ -1204,9 +1097,7 @@ class SharedHandler {
1204
1097
  });
1205
1098
  if (shareInfo == null ? void 0 : shareInfo.scope) {
1206
1099
  await Promise.all(shareInfo.scope.map(async (shareScope)=>{
1207
- await Promise.all(this.initializeSharing(shareScope, {
1208
- strategy: shareInfo.strategy
1209
- }));
1100
+ await Promise.all(this.initializeSharing(shareScope, shareInfo.strategy));
1210
1101
  return;
1211
1102
  }));
1212
1103
  }
@@ -1294,22 +1185,8 @@ class SharedHandler {
1294
1185
  * It accepts one argument, the name of the share scope.
1295
1186
  * If the share scope does not exist, it creates one.
1296
1187
  */ // eslint-disable-next-line @typescript-eslint/member-ordering
1297
- initializeSharing(shareScopeName = DEFAULT_SCOPE, extraOptions) {
1188
+ initializeSharing(shareScopeName = DEFAULT_SCOPE, strategy) {
1298
1189
  const { host } = this;
1299
- const from = extraOptions == null ? void 0 : extraOptions.from;
1300
- const strategy = extraOptions == null ? void 0 : extraOptions.strategy;
1301
- let initScope = extraOptions == null ? void 0 : extraOptions.initScope;
1302
- const promises = [];
1303
- if (from !== 'build') {
1304
- const { initTokens } = this;
1305
- if (!initScope) initScope = [];
1306
- let initToken = initTokens[shareScopeName];
1307
- if (!initToken) initToken = initTokens[shareScopeName] = {
1308
- from: this.host.name
1309
- };
1310
- if (initScope.indexOf(initToken) >= 0) return promises;
1311
- initScope.push(initToken);
1312
- }
1313
1190
  const shareScope = this.shareScopeMap;
1314
1191
  const hostName = host.options.name;
1315
1192
  // Creates a new share scope if necessary
@@ -1329,7 +1206,8 @@ class SharedHandler {
1329
1206
  versions[version] = shared;
1330
1207
  }
1331
1208
  };
1332
- const initFn = (mod)=>mod && mod.init && mod.init(shareScope[shareScopeName], initScope);
1209
+ const promises = [];
1210
+ const initFn = (mod)=>mod && mod.init && mod.init(shareScope[shareScopeName]);
1333
1211
  const initRemoteModule = async (key)=>{
1334
1212
  const { module } = await host.remoteHandler.getRemoteModuleAndOptions({
1335
1213
  id: key
@@ -1337,7 +1215,7 @@ class SharedHandler {
1337
1215
  if (module.getEntry) {
1338
1216
  const entry = await module.getEntry();
1339
1217
  if (!module.inited) {
1340
- await initFn(entry);
1218
+ initFn(entry);
1341
1219
  module.inited = true;
1342
1220
  }
1343
1221
  }
@@ -1373,9 +1251,7 @@ class SharedHandler {
1373
1251
  });
1374
1252
  if (shareInfo == null ? void 0 : shareInfo.scope) {
1375
1253
  shareInfo.scope.forEach((shareScope)=>{
1376
- this.initializeSharing(shareScope, {
1377
- strategy: shareInfo.strategy
1378
- });
1254
+ this.initializeSharing(shareScope, shareInfo.strategy);
1379
1255
  });
1380
1256
  }
1381
1257
  const registeredShared = getRegisteredShare(this.shareScopeMap, pkgName, shareInfo, this.hooks.lifecycle.resolveShare);
@@ -1456,7 +1332,7 @@ class SharedHandler {
1456
1332
  });
1457
1333
  }
1458
1334
  setShared({ pkgName, shared, from, lib, loading, loaded, get }) {
1459
- const { version, scope = 'default' } = shared, shareInfo = _$1(shared, [
1335
+ const { version, scope = 'default' } = shared, shareInfo = _object_without_properties_loose(shared, [
1460
1336
  "version",
1461
1337
  "scope"
1462
1338
  ]);
@@ -1473,7 +1349,7 @@ class SharedHandler {
1473
1349
  if (this.shareScopeMap[sc][pkgName][version]) {
1474
1350
  return;
1475
1351
  }
1476
- this.shareScopeMap[sc][pkgName][version] = _({
1352
+ this.shareScopeMap[sc][pkgName][version] = _extends$2({
1477
1353
  version,
1478
1354
  scope: [
1479
1355
  'default'
@@ -1507,11 +1383,24 @@ class SharedHandler {
1507
1383
  });
1508
1384
  this.host = host;
1509
1385
  this.shareScopeMap = {};
1510
- this.initTokens = {};
1511
1386
  this._setGlobalShareScopeMap(host.options);
1512
1387
  }
1513
1388
  }
1514
1389
 
1390
+ function _extends$1() {
1391
+ _extends$1 = Object.assign || function(target) {
1392
+ for(var i = 1; i < arguments.length; i++){
1393
+ var source = arguments[i];
1394
+ for(var key in source){
1395
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1396
+ target[key] = source[key];
1397
+ }
1398
+ }
1399
+ }
1400
+ return target;
1401
+ };
1402
+ return _extends$1.apply(this, arguments);
1403
+ }
1515
1404
  class RemoteHandler {
1516
1405
  formatAndRegisterRemote(globalOptions, userOptions) {
1517
1406
  const userRemotes = userOptions.remotes || [];
@@ -1668,7 +1557,7 @@ class RemoteHandler {
1668
1557
  `);
1669
1558
  const { remote: rawRemote } = remoteSplitInfo;
1670
1559
  const remoteInfo = getRemoteInfo(rawRemote);
1671
- const matchInfo = await host.sharedHandler.hooks.lifecycle.afterResolve.emit(_({
1560
+ const matchInfo = await host.sharedHandler.hooks.lifecycle.afterResolve.emit(_extends$1({
1672
1561
  id: idRes
1673
1562
  }, remoteSplitInfo, {
1674
1563
  options: host.options,
@@ -1744,7 +1633,7 @@ class RemoteHandler {
1744
1633
  origin: host
1745
1634
  });
1746
1635
  }
1747
- warn$1(messages.join(' '));
1636
+ warn(messages.join(' '));
1748
1637
  }
1749
1638
  }
1750
1639
  removeRemote(remote) {
@@ -1837,8 +1726,7 @@ class RemoteHandler {
1837
1726
  const remoteKey = hostGlobalSnapshot && 'remotesInfo' in hostGlobalSnapshot && hostGlobalSnapshot.remotesInfo && getInfoWithoutType(hostGlobalSnapshot.remotesInfo, remote.name).key;
1838
1727
  if (remoteKey) {
1839
1728
  delete hostGlobalSnapshot.remotesInfo[remoteKey];
1840
- if (//eslint-disable-next-line no-extra-boolean-cast
1841
- Boolean(Global.__FEDERATION__.__MANIFEST_LOADING__[remoteKey])) {
1729
+ if (Boolean(Global.__FEDERATION__.__MANIFEST_LOADING__[remoteKey])) {
1842
1730
  delete Global.__FEDERATION__.__MANIFEST_LOADING__[remoteKey];
1843
1731
  }
1844
1732
  }
@@ -1868,6 +1756,20 @@ class RemoteHandler {
1868
1756
  }
1869
1757
  }
1870
1758
 
1759
+ function _extends() {
1760
+ _extends = Object.assign || function(target) {
1761
+ for(var i = 1; i < arguments.length; i++){
1762
+ var source = arguments[i];
1763
+ for(var key in source){
1764
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1765
+ target[key] = source[key];
1766
+ }
1767
+ }
1768
+ }
1769
+ return target;
1770
+ };
1771
+ return _extends.apply(this, arguments);
1772
+ }
1871
1773
  class FederationHost {
1872
1774
  initOptions(userOptions) {
1873
1775
  this.registerPlugins(userOptions.plugins);
@@ -1885,8 +1787,8 @@ class FederationHost {
1885
1787
  loadShareSync(pkgName, extraOptions) {
1886
1788
  return this.sharedHandler.loadShareSync(pkgName, extraOptions);
1887
1789
  }
1888
- initializeSharing(shareScopeName = DEFAULT_SCOPE, extraOptions) {
1889
- return this.sharedHandler.initializeSharing(shareScopeName, extraOptions);
1790
+ initializeSharing(shareScopeName = DEFAULT_SCOPE, strategy) {
1791
+ return this.sharedHandler.initializeSharing(shareScopeName, strategy);
1890
1792
  }
1891
1793
  initRawContainer(name, url, container) {
1892
1794
  const remoteInfo = getRemoteInfo({
@@ -1933,7 +1835,7 @@ class FederationHost {
1933
1835
  }
1934
1836
  });
1935
1837
  }
1936
- const optionsRes = _({}, globalOptions, userOptions, {
1838
+ const optionsRes = _extends({}, globalOptions, userOptions, {
1937
1839
  plugins,
1938
1840
  remotes,
1939
1841
  shared: handledShared
@@ -1973,7 +1875,7 @@ class FederationHost {
1973
1875
  // maybe will change, temporarily for internal use only
1974
1876
  initContainer: new AsyncWaterfallHook('initContainer')
1975
1877
  });
1976
- this.version = "0.6.0";
1878
+ this.version = "0.5.1";
1977
1879
  this.moduleCache = new Map();
1978
1880
  this.loaderHook = new PluginSystem({
1979
1881
  // FIXME: may not be suitable , not open to the public yet
@@ -1994,7 +1896,7 @@ class FederationHost {
1994
1896
  ],
1995
1897
  remotes: [],
1996
1898
  shared: {},
1997
- inBrowser: isBrowserEnv()
1899
+ inBrowser: isBrowserEnv$1()
1998
1900
  };
1999
1901
  this.name = userOptions.name;
2000
1902
  this.options = defaultOptions;
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/runtime",
3
- "version": "0.6.0",
3
+ "version": "0.5.1",
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": {