@module-federation/runtime 0.0.0-next-20241015065721 → 0.0.0-next-20241016071233

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,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  function getRuntime() {
6
4
  // @ts-ignore
7
5
  const runtime = __webpack_require__.federation.runtime;
@@ -0,0 +1 @@
1
+ export * from "./src/embedded";
@@ -1,17 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var share = require('./share.cjs.js');
4
- require('@module-federation/sdk');
5
4
  require('./polyfills.cjs.js');
6
-
7
- var pluginHelper = /*#__PURE__*/Object.freeze({
8
- __proto__: null,
9
- SyncHook: share.SyncHook,
10
- AsyncHook: share.AsyncHook,
11
- SyncWaterfallHook: share.SyncWaterfallHook,
12
- AsyncWaterfallHook: share.AsyncWaterfallHook,
13
- PluginSystem: share.PluginSystem
14
- });
5
+ require('@module-federation/sdk');
15
6
 
16
7
  const ShareUtils = {
17
8
  getRegisteredShare: share.getRegisteredShare,
@@ -35,9 +26,7 @@ const GlobalUtils = {
35
26
  registerGlobalPlugins: share.registerGlobalPlugins,
36
27
  getGlobalHostPlugins: share.getGlobalHostPlugins,
37
28
  getPreloaded: share.getPreloaded,
38
- setPreloaded: share.setPreloaded,
39
- registerPlugins: share.registerPlugins,
40
- pluginHelper
29
+ setPreloaded: share.setPreloaded
41
30
  };
42
31
  var helpers = {
43
32
  global: GlobalUtils,
@@ -0,0 +1,2 @@
1
+ export * from "./src/helpers";
2
+ export { default } from "./src/helpers";
@@ -1,15 +1,6 @@
1
- import { y as SyncHook, A as AsyncHook, S as SyncWaterfallHook, r as AsyncWaterfallHook, P as PluginSystem, l as getRegisteredShare, w as getGlobalShareScope, G as Global, J as nativeGlobal, K as resetFederationGlobalInfo, E as getGlobalFederationInstance, H as setGlobalFederationInstance, F as getGlobalFederationConstructor, C as setGlobalFederationConstructor, j as getInfoWithoutType, t as getGlobalSnapshot, L as getTargetSnapshotInfoByModuleInfo, n as getGlobalSnapshotInfoByModuleInfo, q as setGlobalSnapshotInfoByModuleInfo, o as addGlobalSnapshot, b as getRemoteEntryExports, I as registerGlobalPlugins, M as getGlobalHostPlugins, k as getPreloaded, s as setPreloaded, z as registerPlugins } from './share.esm.js';
2
- import '@module-federation/sdk';
1
+ import { g as getRegisteredShare, a as getGlobalShareScope, G as Global, n as nativeGlobal, r as resetFederationGlobalInfo, b as getGlobalFederationInstance, s as setGlobalFederationInstance, c as getGlobalFederationConstructor, d as setGlobalFederationConstructor, e as getInfoWithoutType, f as getGlobalSnapshot, h as getTargetSnapshotInfoByModuleInfo, i as getGlobalSnapshotInfoByModuleInfo, j as setGlobalSnapshotInfoByModuleInfo, k as addGlobalSnapshot, l as getRemoteEntryExports, m as registerGlobalPlugins, o as getGlobalHostPlugins, p as getPreloaded, q as setPreloaded } from './share.esm.js';
3
2
  import './polyfills.esm.js';
4
-
5
- var pluginHelper = /*#__PURE__*/Object.freeze({
6
- __proto__: null,
7
- SyncHook: SyncHook,
8
- AsyncHook: AsyncHook,
9
- SyncWaterfallHook: SyncWaterfallHook,
10
- AsyncWaterfallHook: AsyncWaterfallHook,
11
- PluginSystem: PluginSystem
12
- });
3
+ import '@module-federation/sdk';
13
4
 
14
5
  const ShareUtils = {
15
6
  getRegisteredShare,
@@ -33,9 +24,7 @@ const GlobalUtils = {
33
24
  registerGlobalPlugins,
34
25
  getGlobalHostPlugins,
35
26
  getPreloaded,
36
- setPreloaded,
37
- registerPlugins,
38
- pluginHelper
27
+ setPreloaded
39
28
  };
40
29
  var helpers = {
41
30
  global: GlobalUtils,
package/dist/index.cjs.js CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var polyfills = require('./polyfills.cjs.js');
6
4
  var sdk = require('@module-federation/sdk');
7
5
  var share = require('./share.cjs.js');
@@ -70,15 +68,31 @@ function matchRemote(remotes, nameOrAlias) {
70
68
  return;
71
69
  }
72
70
 
71
+ function registerPlugins$1(plugins, hookInstances) {
72
+ const globalPlugins = share.getGlobalHostPlugins();
73
+ // Incorporate global plugins
74
+ if (globalPlugins.length > 0) {
75
+ globalPlugins.forEach((plugin)=>{
76
+ if (plugins == null ? void 0 : plugins.find((item)=>item.name !== plugin.name)) {
77
+ plugins.push(plugin);
78
+ }
79
+ });
80
+ }
81
+ if (plugins && plugins.length > 0) {
82
+ plugins.forEach((plugin)=>{
83
+ hookInstances.forEach((hookInstance)=>{
84
+ hookInstance.applyPlugin(plugin);
85
+ });
86
+ });
87
+ }
88
+ return plugins;
89
+ }
90
+
73
91
  async function loadEsmEntry({ entry, remoteEntryExports }) {
74
92
  return new Promise((resolve, reject)=>{
75
93
  try {
76
94
  if (!remoteEntryExports) {
77
- // eslint-disable-next-line no-eval
78
- new Function('callbacks', `import("${entry}").then(callbacks[0]).catch(callbacks[1])`)([
79
- resolve,
80
- reject
81
- ]);
95
+ import(/* webpackIgnore: true */ entry).then(resolve).catch(reject);
82
96
  } else {
83
97
  resolve(remoteEntryExports);
84
98
  }
@@ -91,11 +105,16 @@ async function loadSystemJsEntry({ entry, remoteEntryExports }) {
91
105
  return new Promise((resolve, reject)=>{
92
106
  try {
93
107
  if (!remoteEntryExports) {
94
- // eslint-disable-next-line no-eval
95
- new Function('callbacks', `System.import("${entry}").then(callbacks[0]).catch(callbacks[1])`)([
96
- resolve,
97
- reject
98
- ]);
108
+ //@ts-ignore
109
+ if (typeof __system_context__ === 'undefined') {
110
+ //@ts-ignore
111
+ System.import(entry).then(resolve).catch(reject);
112
+ } else {
113
+ new Function('callbacks', `System.import("${entry}").then(callbacks[0]).catch(callbacks[1])`)([
114
+ resolve,
115
+ reject
116
+ ]);
117
+ }
99
118
  } else {
100
119
  resolve(remoteEntryExports);
101
120
  }
@@ -162,7 +181,7 @@ async function loadEntryDom({ remoteInfo, remoteEntryExports, createScriptHook }
162
181
  }
163
182
  }
164
183
  async function loadEntryNode({ remoteInfo, createScriptHook }) {
165
- const { entry, entryGlobalName: globalName, name } = remoteInfo;
184
+ const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
166
185
  const { entryExports: remoteEntryExports } = share.getRemoteEntryExports(name, globalName);
167
186
  if (remoteEntryExports) {
168
187
  return remoteEntryExports;
@@ -170,7 +189,8 @@ async function loadEntryNode({ remoteInfo, createScriptHook }) {
170
189
  return sdk.loadScriptNode(entry, {
171
190
  attrs: {
172
191
  name,
173
- globalName
192
+ globalName,
193
+ type
174
194
  },
175
195
  createScriptHook: (url, attrs)=>{
176
196
  const res = createScriptHook.emit({
@@ -207,27 +227,24 @@ async function getRemoteEntry({ origin, remoteEntryExports, remoteInfo }) {
207
227
  }
208
228
  if (!share.globalLoading[uniqueKey]) {
209
229
  const loadEntryHook = origin.remoteHandler.hooks.lifecycle.loadEntry;
210
- if (loadEntryHook.listeners.size) {
211
- share.globalLoading[uniqueKey] = loadEntryHook.emit({
212
- createScriptHook: origin.loaderHook.lifecycle.createScript,
213
- remoteInfo,
214
- remoteEntryExports
215
- }).then((res)=>res || undefined);
216
- } else {
217
- const createScriptHook = origin.loaderHook.lifecycle.createScript;
218
- if (!sdk.isBrowserEnv()) {
219
- share.globalLoading[uniqueKey] = loadEntryNode({
220
- remoteInfo,
221
- createScriptHook
222
- });
223
- } else {
224
- share.globalLoading[uniqueKey] = loadEntryDom({
225
- remoteInfo,
226
- remoteEntryExports,
227
- createScriptHook
228
- });
230
+ const createScriptHook = origin.loaderHook.lifecycle.createScript;
231
+ share.globalLoading[uniqueKey] = loadEntryHook.emit({
232
+ createScriptHook,
233
+ remoteInfo,
234
+ remoteEntryExports
235
+ }).then((res)=>{
236
+ if (res) {
237
+ return res;
229
238
  }
230
- }
239
+ return sdk.isBrowserEnv() ? loadEntryDom({
240
+ remoteInfo,
241
+ remoteEntryExports,
242
+ createScriptHook
243
+ }) : loadEntryNode({
244
+ remoteInfo,
245
+ createScriptHook
246
+ });
247
+ });
231
248
  }
232
249
  return share.globalLoading[uniqueKey];
233
250
  }
@@ -302,9 +319,7 @@ let Module = class Module {
302
319
  // get exposeGetter
303
320
  const moduleFactory = await remoteEntryExports.get(expose);
304
321
  share.assert(moduleFactory, `${share.getFMId(this.remoteInfo)} remote don't export ${expose}.`);
305
- // keep symbol for module name always one format
306
- const symbolName = share.processModuleAlias(this.remoteInfo.name, expose);
307
- const wrapModuleFactory = this.wraperFactory(moduleFactory, symbolName);
322
+ const wrapModuleFactory = this.wraperFactory(moduleFactory, id);
308
323
  if (!loadFactory) {
309
324
  return wrapModuleFactory;
310
325
  }
@@ -344,6 +359,191 @@ let Module = class Module {
344
359
  }
345
360
  };
346
361
 
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 (!share.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 (!share.isObject(data)) {
441
+ share.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;
451
+ }
452
+ } catch (e) {
453
+ share.warn(e);
454
+ this.onerror(e);
455
+ }
456
+ }
457
+ return data;
458
+ }
459
+ constructor(type){
460
+ super(), this.onerror = share.error;
461
+ this.type = type;
462
+ }
463
+ }
464
+
465
+ class AsyncWaterfallHook extends SyncHook {
466
+ emit(data) {
467
+ if (!share.isObject(data)) {
468
+ share.error(`The response data for the "${this.type}" hook must be an object.`);
469
+ }
470
+ const ls = Array.from(this.listeners);
471
+ if (ls.length > 0) {
472
+ let i = 0;
473
+ const processError = (e)=>{
474
+ share.warn(e);
475
+ this.onerror(e);
476
+ return data;
477
+ };
478
+ const call = (prevData)=>{
479
+ if (checkReturnData(data, prevData)) {
480
+ data = prevData;
481
+ if (i < ls.length) {
482
+ try {
483
+ return Promise.resolve(ls[i++](data)).then(call, processError);
484
+ } catch (e) {
485
+ return processError(e);
486
+ }
487
+ }
488
+ } else {
489
+ this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`);
490
+ }
491
+ return data;
492
+ };
493
+ return Promise.resolve(call(data));
494
+ }
495
+ return Promise.resolve(data);
496
+ }
497
+ constructor(type){
498
+ super(), this.onerror = share.error;
499
+ this.type = type;
500
+ }
501
+ }
502
+
503
+ class PluginSystem {
504
+ applyPlugin(plugin) {
505
+ share.assert(share.isPlainObject(plugin), 'Plugin configuration is invalid.');
506
+ // The plugin's name is mandatory and must be unique
507
+ const pluginName = plugin.name;
508
+ share.assert(pluginName, 'A name must be provided by the plugin.');
509
+ if (!this.registerPlugins[pluginName]) {
510
+ this.registerPlugins[pluginName] = plugin;
511
+ Object.keys(this.lifecycle).forEach((key)=>{
512
+ const pluginLife = plugin[key];
513
+ if (pluginLife) {
514
+ this.lifecycle[key].on(pluginLife);
515
+ }
516
+ });
517
+ }
518
+ }
519
+ removePlugin(pluginName) {
520
+ share.assert(pluginName, 'A name is required.');
521
+ const plugin = this.registerPlugins[pluginName];
522
+ share.assert(plugin, `The plugin "${pluginName}" is not registered.`);
523
+ Object.keys(plugin).forEach((key)=>{
524
+ if (key !== 'name') {
525
+ this.lifecycle[key].remove(plugin[key]);
526
+ }
527
+ });
528
+ }
529
+ // eslint-disable-next-line @typescript-eslint/no-shadow
530
+ inherit({ lifecycle, registerPlugins }) {
531
+ Object.keys(lifecycle).forEach((hookName)=>{
532
+ share.assert(!this.lifecycle[hookName], `The hook "${hookName}" has a conflict and cannot be inherited.`);
533
+ this.lifecycle[hookName] = lifecycle[hookName];
534
+ });
535
+ Object.keys(registerPlugins).forEach((pluginName)=>{
536
+ share.assert(!this.registerPlugins[pluginName], `The plugin "${pluginName}" has a conflict and cannot be inherited.`);
537
+ this.applyPlugin(registerPlugins[pluginName]);
538
+ });
539
+ }
540
+ constructor(lifecycle){
541
+ this.registerPlugins = {};
542
+ this.lifecycle = lifecycle;
543
+ this.lifecycleKeys = Object.keys(lifecycle);
544
+ }
545
+ }
546
+
347
547
  function defaultPreloadArgs(preloadConfig) {
348
548
  return polyfills._extends({
349
549
  resourceCategory: 'sync',
@@ -403,13 +603,14 @@ useLinkPreload = true) {
403
603
  if (useLinkPreload) {
404
604
  const defaultAttrs = {
405
605
  rel: 'preload',
406
- as: 'style',
407
- crossorigin: 'anonymous'
606
+ as: 'style'
408
607
  };
409
608
  cssAssets.forEach((cssUrl)=>{
410
609
  const { link: cssEl, needAttach } = sdk.createLink({
411
610
  url: cssUrl,
412
- cb: ()=>{},
611
+ cb: ()=>{
612
+ // noop
613
+ },
413
614
  attrs: defaultAttrs,
414
615
  createLinkHook: (url, attrs)=>{
415
616
  const res = host.loaderHook.lifecycle.createLink.emit({
@@ -432,7 +633,9 @@ useLinkPreload = true) {
432
633
  cssAssets.forEach((cssUrl)=>{
433
634
  const { link: cssEl, needAttach } = sdk.createLink({
434
635
  url: cssUrl,
435
- cb: ()=>{},
636
+ cb: ()=>{
637
+ // noop
638
+ },
436
639
  attrs: defaultAttrs,
437
640
  createLinkHook: (url, attrs)=>{
438
641
  const res = host.loaderHook.lifecycle.createLink.emit({
@@ -452,13 +655,14 @@ useLinkPreload = true) {
452
655
  if (useLinkPreload) {
453
656
  const defaultAttrs = {
454
657
  rel: 'preload',
455
- as: 'script',
456
- crossorigin: 'anonymous'
658
+ as: 'script'
457
659
  };
458
660
  jsAssetsWithoutEntry.forEach((jsUrl)=>{
459
661
  const { link: linkEl, needAttach } = sdk.createLink({
460
662
  url: jsUrl,
461
- cb: ()=>{},
663
+ cb: ()=>{
664
+ // noop
665
+ },
462
666
  attrs: defaultAttrs,
463
667
  createLinkHook: (url, attrs)=>{
464
668
  const res = host.loaderHook.lifecycle.createLink.emit({
@@ -481,7 +685,9 @@ useLinkPreload = true) {
481
685
  jsAssetsWithoutEntry.forEach((jsUrl)=>{
482
686
  const { script: scriptEl, needAttach } = sdk.createScript({
483
687
  url: jsUrl,
484
- cb: ()=>{},
688
+ cb: ()=>{
689
+ // noop
690
+ },
485
691
  attrs: defaultAttrs,
486
692
  createScriptHook: (url, attrs)=>{
487
693
  const res = host.loaderHook.lifecycle.createScript.emit({
@@ -754,7 +960,7 @@ const generatePreloadAssetsPlugin = function() {
754
960
  moduleInfo: {
755
961
  name: remoteInfo.name,
756
962
  entry: remote.entry,
757
- type: 'global',
963
+ type: remoteInfo.type || 'global',
758
964
  entryGlobalName: '',
759
965
  shareScope: ''
760
966
  }
@@ -851,8 +1057,6 @@ class SnapshotHandler {
851
1057
  remoteSnapshot,
852
1058
  globalSnapshot
853
1059
  });
854
- let mSnapshot;
855
- let gSnapshot;
856
1060
  // global snapshot includes manifest or module info includes manifest
857
1061
  if (globalRemoteSnapshot) {
858
1062
  if (sdk.isManifestProvider(globalRemoteSnapshot)) {
@@ -864,8 +1068,10 @@ class SnapshotHandler {
864
1068
  // Therefore, set the snapshot key to the global address of the actual request
865
1069
  entry: remoteEntry
866
1070
  }), moduleSnapshot);
867
- mSnapshot = moduleSnapshot;
868
- gSnapshot = globalSnapshotRes;
1071
+ return {
1072
+ remoteSnapshot: moduleSnapshot,
1073
+ globalSnapshot: globalSnapshotRes
1074
+ };
869
1075
  } else {
870
1076
  const { remoteSnapshot: remoteSnapshotRes } = await this.hooks.lifecycle.loadRemoteSnapshot.emit({
871
1077
  options: this.HostInstance.options,
@@ -873,8 +1079,10 @@ class SnapshotHandler {
873
1079
  remoteSnapshot: globalRemoteSnapshot,
874
1080
  from: 'global'
875
1081
  });
876
- mSnapshot = remoteSnapshotRes;
877
- gSnapshot = globalSnapshotRes;
1082
+ return {
1083
+ remoteSnapshot: remoteSnapshotRes,
1084
+ globalSnapshot: globalSnapshotRes
1085
+ };
878
1086
  }
879
1087
  } else {
880
1088
  if (share.isRemoteInfoWithEntry(moduleInfo)) {
@@ -888,8 +1096,10 @@ class SnapshotHandler {
888
1096
  remoteSnapshot: moduleSnapshot,
889
1097
  from: 'global'
890
1098
  });
891
- mSnapshot = remoteSnapshotRes;
892
- gSnapshot = globalSnapshotRes;
1099
+ return {
1100
+ remoteSnapshot: remoteSnapshotRes,
1101
+ globalSnapshot: globalSnapshotRes
1102
+ };
893
1103
  } else {
894
1104
  share.error(`
895
1105
  Cannot get remoteSnapshot with the name: '${moduleInfo.name}', version: '${moduleInfo.version}' from __FEDERATION__.moduleInfo. The following reasons may be causing the problem:\n
@@ -899,15 +1109,6 @@ class SnapshotHandler {
899
1109
  `);
900
1110
  }
901
1111
  }
902
- await this.hooks.lifecycle.afterLoadSnapshot.emit({
903
- options,
904
- moduleInfo,
905
- remoteSnapshot: mSnapshot
906
- });
907
- return {
908
- remoteSnapshot: mSnapshot,
909
- globalSnapshot: gSnapshot
910
- };
911
1112
  }
912
1113
  getGlobalRemoteInfo(moduleInfo) {
913
1114
  return getGlobalRemoteInfo(moduleInfo, this.HostInstance);
@@ -957,11 +1158,10 @@ class SnapshotHandler {
957
1158
  constructor(HostInstance){
958
1159
  this.loadingHostSnapshot = null;
959
1160
  this.manifestCache = new Map();
960
- this.hooks = new share.PluginSystem({
961
- beforeLoadRemoteSnapshot: new share.AsyncHook('beforeLoadRemoteSnapshot'),
962
- loadSnapshot: new share.AsyncWaterfallHook('loadGlobalSnapshot'),
963
- loadRemoteSnapshot: new share.AsyncWaterfallHook('loadRemoteSnapshot'),
964
- afterLoadSnapshot: new share.AsyncWaterfallHook('afterLoadSnapshot')
1161
+ this.hooks = new PluginSystem({
1162
+ beforeLoadRemoteSnapshot: new AsyncHook('beforeLoadRemoteSnapshot'),
1163
+ loadSnapshot: new AsyncWaterfallHook('loadGlobalSnapshot'),
1164
+ loadRemoteSnapshot: new AsyncWaterfallHook('loadRemoteSnapshot')
965
1165
  });
966
1166
  this.manifestLoading = share.Global.__FEDERATION__.__MANIFEST_LOADING__;
967
1167
  this.HostInstance = HostInstance;
@@ -1139,9 +1339,20 @@ class SharedHandler {
1139
1339
  id: key
1140
1340
  });
1141
1341
  if (module.getEntry) {
1142
- const entry = await module.getEntry();
1342
+ let remoteEntryExports;
1343
+ try {
1344
+ remoteEntryExports = await module.getEntry();
1345
+ } catch (error) {
1346
+ remoteEntryExports = await host.remoteHandler.hooks.lifecycle.errorLoadRemote.emit({
1347
+ id: key,
1348
+ error,
1349
+ from: 'runtime',
1350
+ lifecycle: 'beforeLoadShare',
1351
+ origin: host
1352
+ });
1353
+ }
1143
1354
  if (!module.inited) {
1144
- await initFn(entry);
1355
+ await initFn(remoteEntryExports);
1145
1356
  module.inited = true;
1146
1357
  }
1147
1358
  }
@@ -1304,14 +1515,14 @@ class SharedHandler {
1304
1515
  }
1305
1516
  }
1306
1517
  constructor(host){
1307
- this.hooks = new share.PluginSystem({
1308
- afterResolve: new share.AsyncWaterfallHook('afterResolve'),
1309
- beforeLoadShare: new share.AsyncWaterfallHook('beforeLoadShare'),
1518
+ this.hooks = new PluginSystem({
1519
+ afterResolve: new AsyncWaterfallHook('afterResolve'),
1520
+ beforeLoadShare: new AsyncWaterfallHook('beforeLoadShare'),
1310
1521
  // not used yet
1311
- loadShare: new share.AsyncHook(),
1312
- resolveShare: new share.SyncWaterfallHook('resolveShare'),
1522
+ loadShare: new AsyncHook(),
1523
+ resolveShare: new SyncWaterfallHook('resolveShare'),
1313
1524
  // maybe will change, temporarily for internal use only
1314
- initContainerShareScopeMap: new share.SyncWaterfallHook('initContainerShareScopeMap')
1525
+ initContainerShareScopeMap: new SyncWaterfallHook('initContainerShareScopeMap')
1315
1526
  });
1316
1527
  this.host = host;
1317
1528
  this.shareScopeMap = {};
@@ -1658,18 +1869,18 @@ class RemoteHandler {
1658
1869
  }
1659
1870
  }
1660
1871
  constructor(host){
1661
- this.hooks = new share.PluginSystem({
1662
- beforeRegisterRemote: new share.SyncWaterfallHook('beforeRegisterRemote'),
1663
- registerRemote: new share.SyncWaterfallHook('registerRemote'),
1664
- beforeRequest: new share.AsyncWaterfallHook('beforeRequest'),
1665
- onLoad: new share.AsyncHook('onLoad'),
1666
- handlePreloadModule: new share.SyncHook('handlePreloadModule'),
1667
- errorLoadRemote: new share.AsyncHook('errorLoadRemote'),
1668
- beforePreloadRemote: new share.AsyncHook('beforePreloadRemote'),
1669
- generatePreloadAssets: new share.AsyncHook('generatePreloadAssets'),
1872
+ this.hooks = new PluginSystem({
1873
+ beforeRegisterRemote: new SyncWaterfallHook('beforeRegisterRemote'),
1874
+ registerRemote: new SyncWaterfallHook('registerRemote'),
1875
+ beforeRequest: new AsyncWaterfallHook('beforeRequest'),
1876
+ onLoad: new AsyncHook('onLoad'),
1877
+ handlePreloadModule: new SyncHook('handlePreloadModule'),
1878
+ errorLoadRemote: new AsyncHook('errorLoadRemote'),
1879
+ beforePreloadRemote: new AsyncHook('beforePreloadRemote'),
1880
+ generatePreloadAssets: new AsyncHook('generatePreloadAssets'),
1670
1881
  // not used yet
1671
- afterPreloadRemote: new share.AsyncHook(),
1672
- loadEntry: new share.AsyncHook()
1882
+ afterPreloadRemote: new AsyncHook(),
1883
+ loadEntry: new AsyncHook()
1673
1884
  });
1674
1885
  this.host = host;
1675
1886
  this.idToRemoteMap = {};
@@ -1753,7 +1964,7 @@ class FederationHost {
1753
1964
  return optionsRes;
1754
1965
  }
1755
1966
  registerPlugins(plugins) {
1756
- const pluginRes = share.registerPlugins(plugins, [
1967
+ const pluginRes = registerPlugins$1(plugins, [
1757
1968
  this.hooks,
1758
1969
  this.remoteHandler.hooks,
1759
1970
  this.sharedHandler.hooks,
@@ -1773,23 +1984,23 @@ class FederationHost {
1773
1984
  return this.remoteHandler.registerRemotes(remotes, options);
1774
1985
  }
1775
1986
  constructor(userOptions){
1776
- this.hooks = new share.PluginSystem({
1777
- beforeInit: new share.SyncWaterfallHook('beforeInit'),
1778
- init: new share.SyncHook(),
1987
+ this.hooks = new PluginSystem({
1988
+ beforeInit: new SyncWaterfallHook('beforeInit'),
1989
+ init: new SyncHook(),
1779
1990
  // maybe will change, temporarily for internal use only
1780
- beforeInitContainer: new share.AsyncWaterfallHook('beforeInitContainer'),
1991
+ beforeInitContainer: new AsyncWaterfallHook('beforeInitContainer'),
1781
1992
  // maybe will change, temporarily for internal use only
1782
- initContainer: new share.AsyncWaterfallHook('initContainer')
1993
+ initContainer: new AsyncWaterfallHook('initContainer')
1783
1994
  });
1784
- this.version = "0.6.6";
1995
+ this.version = "0.6.10";
1785
1996
  this.moduleCache = new Map();
1786
- this.loaderHook = new share.PluginSystem({
1997
+ this.loaderHook = new PluginSystem({
1787
1998
  // FIXME: may not be suitable , not open to the public yet
1788
- getModuleInfo: new share.SyncHook(),
1789
- createScript: new share.SyncHook(),
1790
- createLink: new share.SyncHook(),
1999
+ getModuleInfo: new SyncHook(),
2000
+ createScript: new SyncHook(),
2001
+ createLink: new SyncHook(),
1791
2002
  // only work for manifest , so not open to the public yet
1792
- fetch: new share.AsyncHook()
2003
+ fetch: new AsyncHook()
1793
2004
  });
1794
2005
  // TODO: Validate the details of the options
1795
2006
  // Initialize options with default values
@@ -1876,11 +2087,11 @@ function getInstance() {
1876
2087
  // Inject for debug
1877
2088
  share.setGlobalFederationConstructor(FederationHost);
1878
2089
 
1879
- Object.defineProperty(exports, 'loadScript', {
2090
+ Object.defineProperty(exports, "loadScript", {
1880
2091
  enumerable: true,
1881
2092
  get: function () { return sdk.loadScript; }
1882
2093
  });
1883
- Object.defineProperty(exports, 'loadScriptNode', {
2094
+ Object.defineProperty(exports, "loadScriptNode", {
1884
2095
  enumerable: true,
1885
2096
  get: function () { return sdk.loadScriptNode; }
1886
2097
  });
@@ -0,0 +1 @@
1
+ export * from "./src/index";