@module-federation/runtime 0.8.1 → 0.8.3

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
@@ -270,12 +270,24 @@ let Module = class Module {
270
270
  if (this.remoteEntryExports) {
271
271
  return this.remoteEntryExports;
272
272
  }
273
- // Get remoteEntry.js
274
- const remoteEntryExports = await getRemoteEntry({
275
- origin: this.host,
276
- remoteInfo: this.remoteInfo,
277
- remoteEntryExports: this.remoteEntryExports
278
- });
273
+ let remoteEntryExports;
274
+ try {
275
+ remoteEntryExports = await getRemoteEntry({
276
+ origin: this.host,
277
+ remoteInfo: this.remoteInfo,
278
+ remoteEntryExports: this.remoteEntryExports
279
+ });
280
+ } catch (err) {
281
+ const uniqueKey = getRemoteEntryUniqueKey(this.remoteInfo);
282
+ remoteEntryExports = await this.host.loaderHook.lifecycle.loadEntryError.emit({
283
+ getRemoteEntry,
284
+ origin: this.host,
285
+ remoteInfo: this.remoteInfo,
286
+ remoteEntryExports: this.remoteEntryExports,
287
+ globalLoading: share.globalLoading,
288
+ uniqueKey
289
+ });
290
+ }
279
291
  share.assert(remoteEntryExports, `remoteEntryExports is undefined \n ${sdk.safeToString(this.remoteInfo)}`);
280
292
  this.remoteEntryExports = remoteEntryExports;
281
293
  return this.remoteEntryExports;
@@ -1772,7 +1784,7 @@ class RemoteHandler {
1772
1784
  } else {
1773
1785
  const messages = [
1774
1786
  `The remote "${remote.name}" is already registered.`,
1775
- (options == null ? void 0 : options.force) ? 'Hope you have known that OVERRIDE it may have some unexpected errors' : 'If you want to merge the remote, you can set "force: true".'
1787
+ 'Please note that overriding it may cause unexpected errors.'
1776
1788
  ];
1777
1789
  if (options == null ? void 0 : options.force) {
1778
1790
  // remove registered remote
@@ -1783,8 +1795,8 @@ class RemoteHandler {
1783
1795
  remote,
1784
1796
  origin: host
1785
1797
  });
1798
+ sdk.warn(messages.join(' '));
1786
1799
  }
1787
- sdk.warn(messages.join(' '));
1788
1800
  }
1789
1801
  }
1790
1802
  removeRemote(remote) {
@@ -2014,15 +2026,15 @@ class FederationHost {
2014
2026
  // maybe will change, temporarily for internal use only
2015
2027
  initContainer: new AsyncWaterfallHook('initContainer')
2016
2028
  });
2017
- this.version = "0.8.1";
2029
+ this.version = "0.8.3";
2018
2030
  this.moduleCache = new Map();
2019
2031
  this.loaderHook = new PluginSystem({
2020
2032
  // FIXME: may not be suitable , not open to the public yet
2021
2033
  getModuleInfo: new SyncHook(),
2022
2034
  createScript: new SyncHook(),
2023
2035
  createLink: new SyncHook(),
2024
- // only work for manifest , so not open to the public yet
2025
2036
  fetch: new AsyncHook(),
2037
+ loadEntryError: new AsyncHook(),
2026
2038
  getModuleFactory: new AsyncHook()
2027
2039
  });
2028
2040
  this.bridgeHook = new PluginSystem({
@@ -270,12 +270,24 @@ let Module = class Module {
270
270
  if (this.remoteEntryExports) {
271
271
  return this.remoteEntryExports;
272
272
  }
273
- // Get remoteEntry.js
274
- const remoteEntryExports = await getRemoteEntry({
275
- origin: this.host,
276
- remoteInfo: this.remoteInfo,
277
- remoteEntryExports: this.remoteEntryExports
278
- });
273
+ let remoteEntryExports;
274
+ try {
275
+ remoteEntryExports = await getRemoteEntry({
276
+ origin: this.host,
277
+ remoteInfo: this.remoteInfo,
278
+ remoteEntryExports: this.remoteEntryExports
279
+ });
280
+ } catch (err) {
281
+ const uniqueKey = getRemoteEntryUniqueKey(this.remoteInfo);
282
+ remoteEntryExports = await this.host.loaderHook.lifecycle.loadEntryError.emit({
283
+ getRemoteEntry,
284
+ origin: this.host,
285
+ remoteInfo: this.remoteInfo,
286
+ remoteEntryExports: this.remoteEntryExports,
287
+ globalLoading,
288
+ uniqueKey
289
+ });
290
+ }
279
291
  assert(remoteEntryExports, `remoteEntryExports is undefined \n ${safeToString(this.remoteInfo)}`);
280
292
  this.remoteEntryExports = remoteEntryExports;
281
293
  return this.remoteEntryExports;
@@ -1772,7 +1784,7 @@ class RemoteHandler {
1772
1784
  } else {
1773
1785
  const messages = [
1774
1786
  `The remote "${remote.name}" is already registered.`,
1775
- (options == null ? void 0 : options.force) ? 'Hope you have known that OVERRIDE it may have some unexpected errors' : 'If you want to merge the remote, you can set "force: true".'
1787
+ 'Please note that overriding it may cause unexpected errors.'
1776
1788
  ];
1777
1789
  if (options == null ? void 0 : options.force) {
1778
1790
  // remove registered remote
@@ -1783,8 +1795,8 @@ class RemoteHandler {
1783
1795
  remote,
1784
1796
  origin: host
1785
1797
  });
1798
+ warn$1(messages.join(' '));
1786
1799
  }
1787
- warn$1(messages.join(' '));
1788
1800
  }
1789
1801
  }
1790
1802
  removeRemote(remote) {
@@ -2014,15 +2026,15 @@ class FederationHost {
2014
2026
  // maybe will change, temporarily for internal use only
2015
2027
  initContainer: new AsyncWaterfallHook('initContainer')
2016
2028
  });
2017
- this.version = "0.8.1";
2029
+ this.version = "0.8.3";
2018
2030
  this.moduleCache = new Map();
2019
2031
  this.loaderHook = new PluginSystem({
2020
2032
  // FIXME: may not be suitable , not open to the public yet
2021
2033
  getModuleInfo: new SyncHook(),
2022
2034
  createScript: new SyncHook(),
2023
2035
  createLink: new SyncHook(),
2024
- // only work for manifest , so not open to the public yet
2025
2036
  fetch: new AsyncHook(),
2037
+ loadEntryError: new AsyncHook(),
2026
2038
  getModuleFactory: new AsyncHook()
2027
2039
  });
2028
2040
  this.bridgeHook = new PluginSystem({
package/dist/share.cjs.js CHANGED
@@ -197,7 +197,7 @@ function getGlobalFederationConstructor() {
197
197
  function setGlobalFederationConstructor(FederationConstructor, isDebug = sdk.isDebugMode()) {
198
198
  if (isDebug) {
199
199
  CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
200
- CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.8.1";
200
+ CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.8.3";
201
201
  }
202
202
  }
203
203
  // eslint-disable-next-line @typescript-eslint/ban-types
@@ -195,7 +195,7 @@ function getGlobalFederationConstructor() {
195
195
  function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
196
196
  if (isDebug) {
197
197
  CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
198
- CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.8.1";
198
+ CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.8.3";
199
199
  }
200
200
  }
201
201
  // eslint-disable-next-line @typescript-eslint/ban-types
@@ -1,5 +1,6 @@
1
1
  import type { CreateScriptHookReturn, ModuleInfo } from '@module-federation/sdk';
2
2
  import { Options, PreloadRemoteArgs, RemoteEntryExports, Remote, Shared, ShareInfos, UserOptions, RemoteInfo, ShareScopeMap, InitScope, RemoteEntryInitOptions, CallFrom } from './type';
3
+ import { getRemoteEntry } from './utils';
3
4
  import { Module } from './module';
4
5
  import { AsyncHook, AsyncWaterfallHook, PluginSystem, SyncHook, SyncWaterfallHook } from './utils/hooks';
5
6
  import { SnapshotHandler } from './plugins/snapshot/SnapshotHandler';
@@ -60,6 +61,14 @@ export declare class FederationHost {
60
61
  attrs?: Record<string, any>;
61
62
  }], void | HTMLLinkElement>;
62
63
  fetch: AsyncHook<[string, RequestInit], false | void | Promise<Response>>;
64
+ loadEntryError: AsyncHook<[{
65
+ getRemoteEntry: typeof getRemoteEntry;
66
+ origin: FederationHost;
67
+ remoteInfo: RemoteInfo;
68
+ remoteEntryExports?: RemoteEntryExports | undefined;
69
+ globalLoading: Record<string, Promise<void | RemoteEntryExports> | undefined>;
70
+ uniqueKey: string;
71
+ }], Promise<(() => Promise<RemoteEntryExports | undefined>) | undefined>>;
63
72
  getModuleFactory: AsyncHook<[{
64
73
  remoteEntryExports: RemoteEntryExports;
65
74
  expose: string;
@@ -72,6 +72,14 @@ export declare class FederationHost implements IndexModule.FederationHost {
72
72
  attrs?: Record<string, any>;
73
73
  }], void | HTMLLinkElement>;
74
74
  fetch: import("./utils/hooks").AsyncHook<[string, RequestInit], false | void | Promise<Response>>;
75
+ loadEntryError: import("./utils/hooks").AsyncHook<[{
76
+ getRemoteEntry: typeof IndexModule.getRemoteEntry;
77
+ origin: IndexModule.FederationHost;
78
+ remoteInfo: import("./type").RemoteInfo;
79
+ remoteEntryExports?: import("./type").RemoteEntryExports | undefined;
80
+ globalLoading: Record<string, Promise<void | import("./type").RemoteEntryExports> | undefined>;
81
+ uniqueKey: string;
82
+ }], Promise<(() => Promise<import("./type").RemoteEntryExports | undefined>) | undefined>>;
75
83
  getModuleFactory: import("./utils/hooks").AsyncHook<[{
76
84
  remoteEntryExports: import("./type").RemoteEntryExports;
77
85
  expose: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/runtime",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "author": "zhouxiao <codingzx@gmail.com>",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.esm.mjs",
@@ -9,6 +9,11 @@
9
9
  "publishConfig": {
10
10
  "access": "public"
11
11
  },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/module-federation/core/",
15
+ "directory": "packages/runtime"
16
+ },
12
17
  "files": [
13
18
  "dist/",
14
19
  "README.md"
@@ -50,7 +55,7 @@
50
55
  }
51
56
  },
52
57
  "dependencies": {
53
- "@module-federation/sdk": "0.8.1",
54
- "@module-federation/error-codes": "0.8.1"
58
+ "@module-federation/sdk": "0.8.3",
59
+ "@module-federation/error-codes": "0.8.3"
55
60
  }
56
61
  }