@squide/firefly-module-federation 1.0.2 → 1.0.4
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/CHANGELOG.md +20 -0
- package/dist/ModuleFederationPlugin.js +6 -4
- package/dist/ModuleFederationPlugin.js.map +1 -1
- package/dist/RemoteModuleRegistry.d.ts +5 -8
- package/dist/RemoteModuleRegistry.js +9 -5
- package/dist/RemoteModuleRegistry.js.map +1 -1
- package/dist/initializeFirefly.d.ts +1 -1
- package/dist/initializeFirefly.js.map +1 -1
- package/package.json +17 -17
- package/src/ModuleFederationPlugin.ts +7 -5
- package/src/RemoteModuleRegistry.ts +12 -9
- package/src/initializeFirefly.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @squide/firefly-module-federation
|
|
2
2
|
|
|
3
|
+
## 1.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#352](https://github.com/workleap/wl-squide/pull/352) [`7bd7af5`](https://github.com/workleap/wl-squide/commit/7bd7af5a757912309704b9e93bf8ecf1388e6787) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Bump dependency versions.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`7bd7af5`](https://github.com/workleap/wl-squide/commit/7bd7af5a757912309704b9e93bf8ecf1388e6787), [`7bd7af5`](https://github.com/workleap/wl-squide/commit/7bd7af5a757912309704b9e93bf8ecf1388e6787)]:
|
|
10
|
+
- @squide/core@6.1.7
|
|
11
|
+
- @squide/firefly@16.1.0
|
|
12
|
+
|
|
13
|
+
## 1.0.3
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#347](https://github.com/workleap/wl-squide/pull/347) [`6354489`](https://github.com/workleap/wl-squide/commit/6354489117e9826291da71f977daae55a5c5484a) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Bumped package versions.
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [[`6354489`](https://github.com/workleap/wl-squide/commit/6354489117e9826291da71f977daae55a5c5484a)]:
|
|
20
|
+
- @squide/firefly@16.0.3
|
|
21
|
+
- @squide/core@6.1.6
|
|
22
|
+
|
|
3
23
|
## 1.0.2
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { loadRemote } from "@module-federation/enhanced/runtime";
|
|
2
|
-
import { Plugin
|
|
2
|
+
import { Plugin } from "@squide/core";
|
|
3
3
|
import { addProtectedListener, endActiveSpan, getTracer, startActiveChildSpan, startChildSpan, traceError } from "@squide/firefly/internal";
|
|
4
4
|
import { RemoteModuleDeferredRegistrationFailedEvent, RemoteModuleDeferredRegistrationUpdateFailedEvent, RemoteModuleRegistrationFailedEvent, RemoteModuleRegistry, RemoteModuleRegistryId, RemoteModulesDeferredRegistrationCompletedEvent, RemoteModulesDeferredRegistrationStartedEvent, RemoteModulesDeferredRegistrationsUpdateCompletedEvent, RemoteModulesDeferredRegistrationsUpdateStartedEvent, RemoteModulesRegistrationCompletedEvent, RemoteModulesRegistrationStartedEvent } from "./RemoteModuleRegistry.js";
|
|
5
5
|
|
|
@@ -179,9 +179,11 @@ class ModuleFederationPlugin extends Plugin {
|
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
function getModuleFederationPlugin(runtime) {
|
|
182
|
-
const plugin = runtime.getPlugin(ModuleFederationPluginName
|
|
183
|
-
|
|
184
|
-
|
|
182
|
+
const plugin = runtime.getPlugin(ModuleFederationPluginName, {
|
|
183
|
+
throwOnNotFound: false
|
|
184
|
+
});
|
|
185
|
+
if (!plugin) {
|
|
186
|
+
throw new Error("[squide] The getModuleFederationPlugin function is called but no ModuleFederationPlugin instance has been registered with the runtime. Did you import the initializeFirefly function from the \"@squide/firefly-module-federation\" package?");
|
|
185
187
|
}
|
|
186
188
|
return plugin;
|
|
187
189
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModuleFederationPlugin.js","sources":["../src/ModuleFederationPlugin.ts"],"sourcesContent":["import { loadRemote as loadModuleFederationRemote } from \"@module-federation/enhanced/runtime\";\nimport { Span } from \"@opentelemetry/api\";\nimport { isNil, Plugin, RegisterModulesOptions, type Runtime } from \"@squide/core\";\nimport { FireflyPlugin, FireflyRuntime } from \"@squide/firefly\";\nimport { ActiveSpan, addProtectedListener, endActiveSpan, getTracer, HoneycombTrackingUnmanagedErrorHandler, startActiveChildSpan, startChildSpan, traceError, type GetSpanFunction } from \"@squide/firefly/internal\";\nimport { RemoteDefinition } from \"./RemoteDefinition.ts\";\nimport { RemoteModuleDeferredRegistrationFailedEvent, RemoteModuleDeferredRegistrationUpdateFailedEvent, RemoteModuleRegistrationError, RemoteModuleRegistrationFailedEvent, RemoteModuleRegistry, RemoteModuleRegistryId, RemoteModulesDeferredRegistrationCompletedEvent, RemoteModulesDeferredRegistrationCompletedEventPayload, RemoteModulesDeferredRegistrationStartedEvent, RemoteModulesDeferredRegistrationStartedEventPayload, RemoteModulesDeferredRegistrationsUpdateCompletedEvent, RemoteModulesDeferredRegistrationsUpdateCompletedEventPayload, RemoteModulesDeferredRegistrationsUpdateStartedEvent, RemoteModulesDeferredRegistrationsUpdateStartedEventPayload, RemoteModulesRegistrationCompletedEvent, RemoteModulesRegistrationCompletedEventPayload, RemoteModulesRegistrationStartedEvent, RemoteModulesRegistrationStartedEventPayload } from \"./RemoteModuleRegistry.ts\";\n\nexport const ModuleFederationPluginName = \"module-federation-plugin\";\n\nexport class ModuleFederationPlugin extends Plugin<FireflyRuntime> implements FireflyPlugin {\n constructor(runtime: FireflyRuntime) {\n super(ModuleFederationPluginName, runtime);\n\n this._runtime.moduleManager.addModuleRegistry(new RemoteModuleRegistry((remoteName, moduleName) => loadModuleFederationRemote(`${remoteName}/${moduleName}`)));\n }\n\n registerRemoteModules<TContext = unknown>(remotes: RemoteDefinition[], options?: RegisterModulesOptions<TContext>) {\n return this._runtime.moduleManager.registerModules(remotes.map(x => ({\n definition: x,\n registryId: RemoteModuleRegistryId\n })), options);\n }\n\n registerHoneycombTrackingListeners(\n getBootstrappingSpan: GetSpanFunction,\n getDeferredRegistrationsUpdateSpan: GetSpanFunction,\n onUnmanagedError: HoneycombTrackingUnmanagedErrorHandler\n ) {\n let remoteModuleRegistrationSpan: Span;\n let remoteModuleDeferredRegistrationSpan: Span;\n let remoteModuleDeferredRegistrationsUpdateSpan: ActiveSpan;\n\n const handleUnmanagedError = (error: unknown) => {\n if (remoteModuleRegistrationSpan) {\n remoteModuleRegistrationSpan.end();\n }\n\n if (remoteModuleDeferredRegistrationSpan) {\n remoteModuleDeferredRegistrationSpan.end();\n }\n\n if (remoteModuleDeferredRegistrationsUpdateSpan) {\n remoteModuleDeferredRegistrationsUpdateSpan.instance.end();\n }\n\n onUnmanagedError(error);\n };\n\n addProtectedListener(this._runtime, RemoteModulesRegistrationStartedEvent, (payload: unknown) => {\n const bootstrappingSpan = getBootstrappingSpan();\n\n const attributes = {\n \"app.squide.remote_count\": (payload as RemoteModulesRegistrationStartedEventPayload).remoteCount\n };\n\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"remote-module-registration-started\", attributes);\n }\n\n remoteModuleRegistrationSpan = startChildSpan(bootstrappingSpan, (options, context) => {\n return getTracer().startSpan(\"remote-module-registration\", { ...options, attributes }, context);\n });\n }, {\n once: true,\n onError: handleUnmanagedError\n });\n\n addProtectedListener(this._runtime, RemoteModulesRegistrationCompletedEvent, (payload: unknown) => {\n const bootstrappingSpan = getBootstrappingSpan();\n\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"remote-module-registration-completed\", {\n \"app.squide.remote_count\": (payload as RemoteModulesRegistrationCompletedEventPayload).remoteCount\n });\n }\n\n if (remoteModuleRegistrationSpan) {\n remoteModuleRegistrationSpan.end();\n }\n }, {\n once: true,\n onError: handleUnmanagedError\n });\n\n // Can occur multiple times.\n addProtectedListener(this._runtime, RemoteModuleRegistrationFailedEvent, (payload: unknown) => {\n const registrationError = payload as RemoteModuleRegistrationError;\n\n if (remoteModuleRegistrationSpan) {\n traceError(remoteModuleRegistrationSpan, registrationError);\n }\n }, {\n onError: handleUnmanagedError\n });\n\n addProtectedListener(this._runtime, RemoteModulesDeferredRegistrationStartedEvent, (payload: unknown) => {\n const bootstrappingSpan = getBootstrappingSpan();\n\n const attributes = {\n \"app.squide.registration_count\": (payload as RemoteModulesDeferredRegistrationStartedEventPayload).registrationCount\n };\n\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"remote-module-deferred-registration-started\", attributes);\n }\n\n remoteModuleDeferredRegistrationSpan = startChildSpan(bootstrappingSpan, (options, context) => {\n return getTracer().startSpan(\"remote-module-deferred-registration\", { ...options, attributes }, context);\n });\n }, {\n once: true,\n onError: handleUnmanagedError\n });\n\n addProtectedListener(this._runtime, RemoteModulesDeferredRegistrationCompletedEvent, (payload: unknown) => {\n const bootstrappingSpan = getBootstrappingSpan();\n\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"remote-module-deferred-registration-completed\", {\n \"app.squide.registration_count\": (payload as RemoteModulesDeferredRegistrationCompletedEventPayload).registrationCount\n });\n }\n\n if (remoteModuleDeferredRegistrationSpan) {\n remoteModuleDeferredRegistrationSpan.end();\n }\n }, {\n once: true,\n onError: handleUnmanagedError\n });\n\n // Can occur multiple times.\n addProtectedListener(this._runtime, RemoteModuleDeferredRegistrationFailedEvent, (payload: unknown) => {\n const registrationError = payload as RemoteModuleRegistrationError;\n\n if (remoteModuleDeferredRegistrationSpan) {\n traceError(remoteModuleDeferredRegistrationSpan, registrationError);\n }\n }, {\n onError: handleUnmanagedError\n });\n\n // Can occur multiple times.\n addProtectedListener(this._runtime, RemoteModulesDeferredRegistrationsUpdateStartedEvent, (payload: unknown) => {\n const deferredRegistrationsUpdateSpan = getDeferredRegistrationsUpdateSpan();\n\n const attributes = {\n \"app.squide.registration_count\": (payload as RemoteModulesDeferredRegistrationsUpdateStartedEventPayload).registrationCount\n };\n\n if (deferredRegistrationsUpdateSpan) {\n deferredRegistrationsUpdateSpan.addEvent(\"remote-module-deferred-registrations-update-started\", attributes);\n }\n\n remoteModuleDeferredRegistrationsUpdateSpan = startActiveChildSpan(deferredRegistrationsUpdateSpan, (options, context) => {\n const name = \"remote-module-deferred-registrations-update\";\n\n const span = getTracer().startSpan(name, {\n attributes,\n ...options\n }, context);\n\n return {\n name,\n span\n };\n });\n }, {\n onError: handleUnmanagedError\n });\n\n // Can occur multiple times.\n addProtectedListener(this._runtime, RemoteModulesDeferredRegistrationsUpdateCompletedEvent, (payload: unknown) => {\n const deferredRegistrationsUpdateSpan = getDeferredRegistrationsUpdateSpan();\n\n if (deferredRegistrationsUpdateSpan) {\n deferredRegistrationsUpdateSpan.addEvent(\"remote-module-deferred-registrations-update-completed\", {\n \"app.squide.registration_count\": (payload as RemoteModulesDeferredRegistrationsUpdateCompletedEventPayload).registrationCount\n });\n }\n\n if (remoteModuleDeferredRegistrationsUpdateSpan) {\n endActiveSpan(remoteModuleDeferredRegistrationsUpdateSpan);\n }\n }, {\n onError: handleUnmanagedError\n });\n\n // Can occur multiple times.\n addProtectedListener(this._runtime, RemoteModuleDeferredRegistrationUpdateFailedEvent, (payload: unknown) => {\n const registrationError = payload as RemoteModuleRegistrationError;\n\n if (remoteModuleDeferredRegistrationsUpdateSpan) {\n traceError(remoteModuleDeferredRegistrationsUpdateSpan.instance, registrationError);\n }\n }, {\n onError: handleUnmanagedError\n });\n\n // Cleanup the spans if the root tracking is failing.\n return (error: unknown) => {\n handleUnmanagedError(error);\n };\n }\n}\n\nexport function getModuleFederationPlugin(runtime: Runtime) {\n const plugin = runtime.getPlugin(ModuleFederationPluginName);\n\n if (isNil(plugin)) {\n throw new Error(\"[squide] The getModuleFederationPlugin function is called but no ModuleFederationPlugin instance has been registered with the runtime.\");\n }\n\n return plugin as ModuleFederationPlugin;\n}\n"],"names":["loadRemote","loadModuleFederationRemote","isNil","Plugin","addProtectedListener","endActiveSpan","getTracer","startActiveChildSpan","startChildSpan","traceError","RemoteModuleDeferredRegistrationFailedEvent","RemoteModuleDeferredRegistrationUpdateFailedEvent","RemoteModuleRegistrationFailedEvent","RemoteModuleRegistry","RemoteModuleRegistryId","RemoteModulesDeferredRegistrationCompletedEvent","RemoteModulesDeferredRegistrationStartedEvent","RemoteModulesDeferredRegistrationsUpdateCompletedEvent","RemoteModulesDeferredRegistrationsUpdateStartedEvent","RemoteModulesRegistrationCompletedEvent","RemoteModulesRegistrationStartedEvent","ModuleFederationPluginName","ModuleFederationPlugin","runtime","remoteName","moduleName","remotes","options","x","getBootstrappingSpan","getDeferredRegistrationsUpdateSpan","onUnmanagedError","remoteModuleRegistrationSpan","remoteModuleDeferredRegistrationSpan","remoteModuleDeferredRegistrationsUpdateSpan","handleUnmanagedError","error","payload","bootstrappingSpan","attributes","context","registrationError","deferredRegistrationsUpdateSpan","name","span","getModuleFederationPlugin","plugin","Error"],"mappings":";;;;;;;;;;;;;;AAA+F;AAEZ;AAEmI;AAE6oB;AAE51B,MAAMqB,6BAA6B,2BAA2B;AAE9D,MAAMC,+BAA+BnB,MAAMA;IAC9C,YAAYoB,OAAuB,CAAE;QACjC,KAAK,CAACF,4BAA4BE;QAElC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,iBAAiB,CAAC,IAAIV,oBAAoBA,CAAC,CAACW,YAAYC,aAAexB,UAA0BA,CAAC,GAAGuB,WAAW,CAAC,EAAEC,YAAY;IAC/J;IAEA,sBAA0CC,OAA2B,EAAEC,OAA0C,EAAE;QAC/G,OAAO,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,eAAe,CAACD,QAAQ,GAAG,CAACE,CAAAA,IAAM;gBACjE,YAAYA;gBACZ,YAAYd,sBAAsBA;YACtC,KAAKa;IACT;IAEA,mCACIE,oBAAqC,EACrCC,kCAAmD,EACnDC,gBAAwD,EAC1D;QACE,IAAIC;QACJ,IAAIC;QACJ,IAAIC;QAEJ,MAAMC,uBAAuB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HG;oBACAC;gBACJ;YACJ;QACJ,GAAG;YACC,SAAST;QACb;QAEA,4BAA4B;QAC5B/B,oBAAoBA,CAAC,IAAI,CAAC,QAAQ,EAAEa,sDAAsDA,EAAE,CAACoB;YACzF,MAAMK,kCAAkCZ;YAExC,IAAIY,iCAAiC;gBACjCA,gCAAgC,QAAQ,CAAC,yDAAyD;oBAC9F,iCAAkCL,QAA0E,iBAAiB;gBACjI;YACJ;YAEA,IAAIH,6CAA6C;gBAC7C7B,aAAaA,CAAC6B;YAClB;QACJ,GAAG;YACC,SAASC;QACb;QAEA,4BAA4B;QAC5B/B,oBAAoBA,CAAC,IAAI,CAAC,QAAQ,EAAEO,iDAAiDA,EAAE,CAAC0B;YACpF,MAAMI,oBAAoBJ;YAE1B,IAAIH,6CAA6C;gBAC7CzB,UAAUA,CAACyB,4CAA4C,QAAQ,EAAEO;YACrE;QACJ,GAAG;YACC,SAASN;QACb;QAEA,qDAAqD;QACrD,OAAO,CAACC;YACJD,qBAAqBC;QACzB;IACJ;AACJ;AAEO,SAASS,0BAA0BtB,OAAgB;IACtD,MAAMuB,SAASvB,QAAQ,SAAS,CAACF;IAEjC,IAAInB,KAAKA,CAAC4C,SAAS;QACf,MAAM,IAAIC,MAAM;IACpB;IAEA,OAAOD;AACX"}
|
|
1
|
+
{"version":3,"file":"ModuleFederationPlugin.js","sources":["../src/ModuleFederationPlugin.ts"],"sourcesContent":["import { loadRemote as loadModuleFederationRemote } from \"@module-federation/enhanced/runtime\";\nimport { Span } from \"@opentelemetry/api\";\nimport { Plugin, RegisterModulesOptions, type Runtime } from \"@squide/core\";\nimport { FireflyPlugin, FireflyRuntime } from \"@squide/firefly\";\nimport { ActiveSpan, addProtectedListener, endActiveSpan, getTracer, HoneycombTrackingUnmanagedErrorHandler, startActiveChildSpan, startChildSpan, traceError, type GetSpanFunction } from \"@squide/firefly/internal\";\nimport { RemoteDefinition } from \"./RemoteDefinition.ts\";\nimport { RemoteModuleDeferredRegistrationFailedEvent, RemoteModuleDeferredRegistrationUpdateFailedEvent, RemoteModuleRegistrationError, RemoteModuleRegistrationFailedEvent, RemoteModuleRegistry, RemoteModuleRegistryId, RemoteModulesDeferredRegistrationCompletedEvent, RemoteModulesDeferredRegistrationCompletedEventPayload, RemoteModulesDeferredRegistrationStartedEvent, RemoteModulesDeferredRegistrationStartedEventPayload, RemoteModulesDeferredRegistrationsUpdateCompletedEvent, RemoteModulesDeferredRegistrationsUpdateCompletedEventPayload, RemoteModulesDeferredRegistrationsUpdateStartedEvent, RemoteModulesDeferredRegistrationsUpdateStartedEventPayload, RemoteModulesRegistrationCompletedEvent, RemoteModulesRegistrationCompletedEventPayload, RemoteModulesRegistrationStartedEvent, RemoteModulesRegistrationStartedEventPayload } from \"./RemoteModuleRegistry.ts\";\n\nexport const ModuleFederationPluginName = \"module-federation-plugin\";\n\nexport class ModuleFederationPlugin extends Plugin<FireflyRuntime> implements FireflyPlugin {\n constructor(runtime: FireflyRuntime) {\n super(ModuleFederationPluginName, runtime);\n\n this._runtime.moduleManager.addModuleRegistry(new RemoteModuleRegistry((remoteName, moduleName) => loadModuleFederationRemote(`${remoteName}/${moduleName}`)));\n }\n\n registerRemoteModules<TContext = unknown>(remotes: RemoteDefinition[], options?: RegisterModulesOptions<TContext>) {\n return this._runtime.moduleManager.registerModules(remotes.map(x => ({\n definition: x,\n registryId: RemoteModuleRegistryId\n })), options);\n }\n\n registerHoneycombTrackingListeners(\n getBootstrappingSpan: GetSpanFunction,\n getDeferredRegistrationsUpdateSpan: GetSpanFunction,\n onUnmanagedError: HoneycombTrackingUnmanagedErrorHandler\n ) {\n let remoteModuleRegistrationSpan: Span;\n let remoteModuleDeferredRegistrationSpan: Span;\n let remoteModuleDeferredRegistrationsUpdateSpan: ActiveSpan;\n\n const handleUnmanagedError = (error: unknown) => {\n if (remoteModuleRegistrationSpan) {\n remoteModuleRegistrationSpan.end();\n }\n\n if (remoteModuleDeferredRegistrationSpan) {\n remoteModuleDeferredRegistrationSpan.end();\n }\n\n if (remoteModuleDeferredRegistrationsUpdateSpan) {\n remoteModuleDeferredRegistrationsUpdateSpan.instance.end();\n }\n\n onUnmanagedError(error);\n };\n\n addProtectedListener(this._runtime, RemoteModulesRegistrationStartedEvent, (payload: unknown) => {\n const bootstrappingSpan = getBootstrappingSpan();\n\n const attributes = {\n \"app.squide.remote_count\": (payload as RemoteModulesRegistrationStartedEventPayload).remoteCount\n };\n\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"remote-module-registration-started\", attributes);\n }\n\n remoteModuleRegistrationSpan = startChildSpan(bootstrappingSpan, (options, context) => {\n return getTracer().startSpan(\"remote-module-registration\", { ...options, attributes }, context);\n });\n }, {\n once: true,\n onError: handleUnmanagedError\n });\n\n addProtectedListener(this._runtime, RemoteModulesRegistrationCompletedEvent, (payload: unknown) => {\n const bootstrappingSpan = getBootstrappingSpan();\n\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"remote-module-registration-completed\", {\n \"app.squide.remote_count\": (payload as RemoteModulesRegistrationCompletedEventPayload).remoteCount\n });\n }\n\n if (remoteModuleRegistrationSpan) {\n remoteModuleRegistrationSpan.end();\n }\n }, {\n once: true,\n onError: handleUnmanagedError\n });\n\n // Can occur multiple times.\n addProtectedListener(this._runtime, RemoteModuleRegistrationFailedEvent, (payload: unknown) => {\n const registrationError = payload as RemoteModuleRegistrationError;\n\n if (remoteModuleRegistrationSpan) {\n traceError(remoteModuleRegistrationSpan, registrationError);\n }\n }, {\n onError: handleUnmanagedError\n });\n\n addProtectedListener(this._runtime, RemoteModulesDeferredRegistrationStartedEvent, (payload: unknown) => {\n const bootstrappingSpan = getBootstrappingSpan();\n\n const attributes = {\n \"app.squide.registration_count\": (payload as RemoteModulesDeferredRegistrationStartedEventPayload).registrationCount\n };\n\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"remote-module-deferred-registration-started\", attributes);\n }\n\n remoteModuleDeferredRegistrationSpan = startChildSpan(bootstrappingSpan, (options, context) => {\n return getTracer().startSpan(\"remote-module-deferred-registration\", { ...options, attributes }, context);\n });\n }, {\n once: true,\n onError: handleUnmanagedError\n });\n\n addProtectedListener(this._runtime, RemoteModulesDeferredRegistrationCompletedEvent, (payload: unknown) => {\n const bootstrappingSpan = getBootstrappingSpan();\n\n if (bootstrappingSpan) {\n bootstrappingSpan.addEvent(\"remote-module-deferred-registration-completed\", {\n \"app.squide.registration_count\": (payload as RemoteModulesDeferredRegistrationCompletedEventPayload).registrationCount\n });\n }\n\n if (remoteModuleDeferredRegistrationSpan) {\n remoteModuleDeferredRegistrationSpan.end();\n }\n }, {\n once: true,\n onError: handleUnmanagedError\n });\n\n // Can occur multiple times.\n addProtectedListener(this._runtime, RemoteModuleDeferredRegistrationFailedEvent, (payload: unknown) => {\n const registrationError = payload as RemoteModuleRegistrationError;\n\n if (remoteModuleDeferredRegistrationSpan) {\n traceError(remoteModuleDeferredRegistrationSpan, registrationError);\n }\n }, {\n onError: handleUnmanagedError\n });\n\n // Can occur multiple times.\n addProtectedListener(this._runtime, RemoteModulesDeferredRegistrationsUpdateStartedEvent, (payload: unknown) => {\n const deferredRegistrationsUpdateSpan = getDeferredRegistrationsUpdateSpan();\n\n const attributes = {\n \"app.squide.registration_count\": (payload as RemoteModulesDeferredRegistrationsUpdateStartedEventPayload).registrationCount\n };\n\n if (deferredRegistrationsUpdateSpan) {\n deferredRegistrationsUpdateSpan.addEvent(\"remote-module-deferred-registrations-update-started\", attributes);\n }\n\n remoteModuleDeferredRegistrationsUpdateSpan = startActiveChildSpan(deferredRegistrationsUpdateSpan, (options, context) => {\n const name = \"remote-module-deferred-registrations-update\";\n\n const span = getTracer().startSpan(name, {\n attributes,\n ...options\n }, context);\n\n return {\n name,\n span\n };\n });\n }, {\n onError: handleUnmanagedError\n });\n\n // Can occur multiple times.\n addProtectedListener(this._runtime, RemoteModulesDeferredRegistrationsUpdateCompletedEvent, (payload: unknown) => {\n const deferredRegistrationsUpdateSpan = getDeferredRegistrationsUpdateSpan();\n\n if (deferredRegistrationsUpdateSpan) {\n deferredRegistrationsUpdateSpan.addEvent(\"remote-module-deferred-registrations-update-completed\", {\n \"app.squide.registration_count\": (payload as RemoteModulesDeferredRegistrationsUpdateCompletedEventPayload).registrationCount\n });\n }\n\n if (remoteModuleDeferredRegistrationsUpdateSpan) {\n endActiveSpan(remoteModuleDeferredRegistrationsUpdateSpan);\n }\n }, {\n onError: handleUnmanagedError\n });\n\n // Can occur multiple times.\n addProtectedListener(this._runtime, RemoteModuleDeferredRegistrationUpdateFailedEvent, (payload: unknown) => {\n const registrationError = payload as RemoteModuleRegistrationError;\n\n if (remoteModuleDeferredRegistrationsUpdateSpan) {\n traceError(remoteModuleDeferredRegistrationsUpdateSpan.instance, registrationError);\n }\n }, {\n onError: handleUnmanagedError\n });\n\n // Cleanup the spans if the root tracking is failing.\n return (error: unknown) => {\n handleUnmanagedError(error);\n };\n }\n}\n\nexport function getModuleFederationPlugin(runtime: Runtime) {\n const plugin = runtime.getPlugin(ModuleFederationPluginName, {\n throwOnNotFound: false\n }) as ModuleFederationPlugin;\n\n if (!plugin) {\n throw new Error(\"[squide] The getModuleFederationPlugin function is called but no ModuleFederationPlugin instance has been registered with the runtime. Did you import the initializeFirefly function from the \\\"@squide/firefly-module-federation\\\" package?\");\n }\n\n return plugin;\n}\n"],"names":["loadRemote","loadModuleFederationRemote","Plugin","addProtectedListener","endActiveSpan","getTracer","startActiveChildSpan","startChildSpan","traceError","RemoteModuleDeferredRegistrationFailedEvent","RemoteModuleDeferredRegistrationUpdateFailedEvent","RemoteModuleRegistrationFailedEvent","RemoteModuleRegistry","RemoteModuleRegistryId","RemoteModulesDeferredRegistrationCompletedEvent","RemoteModulesDeferredRegistrationStartedEvent","RemoteModulesDeferredRegistrationsUpdateCompletedEvent","RemoteModulesDeferredRegistrationsUpdateStartedEvent","RemoteModulesRegistrationCompletedEvent","RemoteModulesRegistrationStartedEvent","ModuleFederationPluginName","ModuleFederationPlugin","runtime","remoteName","moduleName","remotes","options","x","getBootstrappingSpan","getDeferredRegistrationsUpdateSpan","onUnmanagedError","remoteModuleRegistrationSpan","remoteModuleDeferredRegistrationSpan","remoteModuleDeferredRegistrationsUpdateSpan","handleUnmanagedError","error","payload","bootstrappingSpan","attributes","context","registrationError","deferredRegistrationsUpdateSpan","name","span","getModuleFederationPlugin","plugin","Error"],"mappings":";;;;;;;;;;;;;;AAA+F;AAEnB;AAE0I;AAE6oB;AAE51B,MAAMoB,6BAA6B,2BAA2B;AAE9D,MAAMC,+BAA+BnB,MAAMA;IAC9C,YAAYoB,OAAuB,CAAE;QACjC,KAAK,CAACF,4BAA4BE;QAElC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,iBAAiB,CAAC,IAAIV,oBAAoBA,CAAC,CAACW,YAAYC,aAAevB,UAA0BA,CAAC,GAAGsB,WAAW,CAAC,EAAEC,YAAY;IAC/J;IAEA,sBAA0CC,OAA2B,EAAEC,OAA0C,EAAE;QAC/G,OAAO,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,eAAe,CAACD,QAAQ,GAAG,CAACE,CAAAA,IAAM;gBACjE,YAAYA;gBACZ,YAAYd,sBAAsBA;YACtC,KAAKa;IACT;IAEA,mCACIE,oBAAqC,EACrCC,kCAAmD,EACnDC,gBAAwD,EAC1D;QACE,IAAIC;QACJ,IAAIC;QACJ,IAAIC;QAEJ,MAAMC,uBAAuB,CAACC;YAC1B,IAAIJ,8BAA8B;gBAC9BA,6BAA6B,GAAG;YACpC;YAEA,IAAIC,sCAAsC;gBACtCA,qCAAqC,GAAG;YAC5C;YAEA,IAAIC,6CAA6C;gBAC7CA,4CAA4C,QAAQ,CAAC,GAAG;YAC5D;YAEAH,iBAAiBK;QACrB;QAEAhC,oBAAoBA,CAAC,IAAI,CAAC,QAAQ,EAAEgB,qCAAqCA,EAAE,CAACiB;YACxE,MAAMC,oBAAoBT;YAE1B,MAAMU,aAAa;gBACf,2BAA4BF,QAAyD,WAAW;YACpG;YAEA,IAAIC,mBAA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B/B,oBAAoBA,CAAC,IAAI,CAAC,QAAQ,EAAEO,iDAAiDA,EAAE,CAAC0B;YACpF,MAAMI,oBAAoBJ;YAE1B,IAAIH,6CAA6C;gBAC7CzB,UAAUA,CAACyB,4CAA4C,QAAQ,EAAEO;YACrE;QACJ,GAAG;YACC,SAASN;QACb;QAEA,qDAAqD;QACrD,OAAO,CAACC;YACJD,qBAAqBC;QACzB;IACJ;AACJ;AAEO,SAASS,0BAA0BtB,OAAgB;IACtD,MAAMuB,SAASvB,QAAQ,SAAS,CAACF,4BAA4B;QACzD,iBAAiB;IACrB;IAEA,IAAI,CAACyB,QAAQ;QACT,MAAM,IAAIC,MAAM;IACpB;IAEA,OAAOD;AACX"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ModuleRegistrationError, type ModuleRegistrationStatus, type ModuleRegistrationStatusChangedListener, type ModuleRegistry, type RegisterModulesOptions, type Runtime } from "@squide/core";
|
|
1
|
+
import { ModuleDefinition, ModuleRegistrationError, type ModuleRegistrationStatus, type ModuleRegistrationStatusChangedListener, type ModuleRegistry, type RegisterModulesOptions, type Runtime } from "@squide/core";
|
|
2
2
|
import type { RemoteDefinition } from "./RemoteDefinition.ts";
|
|
3
3
|
export declare const RemoteModuleRegistryId = "remote";
|
|
4
4
|
export declare const RemoteModulesRegistrationStartedEvent = "squide-remote-modules-registration-started";
|
|
@@ -39,15 +39,12 @@ export declare class RemoteModuleRegistry implements ModuleRegistry {
|
|
|
39
39
|
#private;
|
|
40
40
|
constructor(loadRemote: LoadRemoteFunction);
|
|
41
41
|
get id(): string;
|
|
42
|
-
registerModules<TRuntime extends Runtime = Runtime, TContext = unknown, TData = unknown>(remotes: RemoteDefinition[],
|
|
43
|
-
registerDeferredRegistrations<
|
|
44
|
-
updateDeferredRegistrations<
|
|
42
|
+
registerModules<TRuntime extends Runtime = Runtime, TContext = unknown, TData = unknown>(runtime: TRuntime, remotes: RemoteDefinition[], { context }?: RegisterModulesOptions<TContext>): Promise<RemoteModuleRegistrationError[]>;
|
|
43
|
+
registerDeferredRegistrations<TRuntime extends Runtime = Runtime, TData = unknown>(runtime: TRuntime, data?: TData): Promise<RemoteModuleRegistrationError[]>;
|
|
44
|
+
updateDeferredRegistrations<TRuntime extends Runtime = Runtime, TData = unknown>(runtime: TRuntime, data?: TData): Promise<RemoteModuleRegistrationError[]>;
|
|
45
45
|
registerStatusChangedListener(callback: ModuleRegistrationStatusChangedListener): void;
|
|
46
46
|
removeStatusChangedListener(callback: ModuleRegistrationStatusChangedListener): void;
|
|
47
47
|
get registrationStatus(): ModuleRegistrationStatus;
|
|
48
48
|
}
|
|
49
|
-
export declare function toRemoteModuleDefinitions(remotes: RemoteDefinition[]):
|
|
50
|
-
definition: RemoteDefinition;
|
|
51
|
-
registryId: string;
|
|
52
|
-
}[];
|
|
49
|
+
export declare function toRemoteModuleDefinitions(remotes: (RemoteDefinition | undefined)[]): ModuleDefinition[];
|
|
53
50
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ModuleRegistrationError,
|
|
1
|
+
import { ModuleRegistrationError, registerModule } from "@squide/core";
|
|
2
|
+
import { isFunction, isNil } from "@squide/core/internal";
|
|
2
3
|
// The require scope
|
|
3
4
|
var __webpack_require__ = {};
|
|
4
5
|
|
|
@@ -9,8 +10,11 @@ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj
|
|
|
9
10
|
|
|
10
11
|
;// CONCATENATED MODULE: external "@squide/core"
|
|
11
12
|
|
|
13
|
+
;// CONCATENATED MODULE: external "@squide/core/internal"
|
|
14
|
+
|
|
12
15
|
;// CONCATENATED MODULE: ./src/RemoteModuleRegistry.ts
|
|
13
16
|
|
|
17
|
+
|
|
14
18
|
const RemoteModuleRegistryId = "remote";
|
|
15
19
|
const RemoteModulesRegistrationStartedEvent = "squide-remote-modules-registration-started";
|
|
16
20
|
const RemoteModulesRegistrationCompletedEvent = "squide-remote-modules-registration-completed";
|
|
@@ -57,7 +61,7 @@ class RemoteModuleRegistry {
|
|
|
57
61
|
__webpack_require__.S.default);
|
|
58
62
|
}
|
|
59
63
|
}
|
|
60
|
-
async registerModules(
|
|
64
|
+
async registerModules(runtime, remotes, { context } = {}) {
|
|
61
65
|
const errors = [];
|
|
62
66
|
if (this.#registrationStatus !== "none") {
|
|
63
67
|
throw new Error("[squide] The registerRemoteModules function can only be called once.");
|
|
@@ -133,7 +137,7 @@ class RemoteModuleRegistry {
|
|
|
133
137
|
}
|
|
134
138
|
return errors;
|
|
135
139
|
}
|
|
136
|
-
async registerDeferredRegistrations(
|
|
140
|
+
async registerDeferredRegistrations(runtime, data) {
|
|
137
141
|
const errors = [];
|
|
138
142
|
if (this.#registrationStatus === "ready" && this.#deferredRegistrations.length === 0) {
|
|
139
143
|
// No deferred registrations were returned by the remote modules, skip this phase.
|
|
@@ -192,7 +196,7 @@ class RemoteModuleRegistry {
|
|
|
192
196
|
this.#logSharedScope(runtime.logger);
|
|
193
197
|
return errors;
|
|
194
198
|
}
|
|
195
|
-
async updateDeferredRegistrations(
|
|
199
|
+
async updateDeferredRegistrations(runtime, data) {
|
|
196
200
|
const errors = [];
|
|
197
201
|
if (this.#registrationStatus !== "ready") {
|
|
198
202
|
throw new Error("[squide] The updateDeferredRegistrations function can only be called once the remote modules are ready.");
|
|
@@ -257,7 +261,7 @@ class RemoteModuleRegistry {
|
|
|
257
261
|
}
|
|
258
262
|
}
|
|
259
263
|
function toRemoteModuleDefinitions(remotes) {
|
|
260
|
-
return remotes.map((x)=>({
|
|
264
|
+
return remotes.filter((x)=>Boolean(x)).map((x)=>({
|
|
261
265
|
definition: x,
|
|
262
266
|
registryId: RemoteModuleRegistryId
|
|
263
267
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RemoteModuleRegistry.js","sources":["webpack/runtime/has_own_property","../src/RemoteModuleRegistry.ts"],"sourcesContent":["__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","import { isFunction, isNil, ModuleRegistrationError, registerModule, type DeferredRegistrationFunction, type ModuleRegistrationStatus, type ModuleRegistrationStatusChangedListener, type ModuleRegistry, type RegisterModulesOptions, type Runtime } from \"@squide/core\";\nimport type { Logger, RootLogger } from \"@workleap/logging\";\nimport type { RemoteDefinition } from \"./RemoteDefinition.ts\";\n\nexport const RemoteModuleRegistryId = \"remote\";\n\nexport const RemoteModulesRegistrationStartedEvent = \"squide-remote-modules-registration-started\";\nexport const RemoteModulesRegistrationCompletedEvent = \"squide-remote-modules-registration-completed\";\nexport const RemoteModuleRegistrationFailedEvent = \"squide-remote-module-registration-failed\";\n\nexport const RemoteModulesDeferredRegistrationStartedEvent = \"squide-remote-modules-deferred-registration-started\";\nexport const RemoteModulesDeferredRegistrationCompletedEvent = \"squide-remote-modules-deferred-registration-completed\";\nexport const RemoteModuleDeferredRegistrationFailedEvent = \"squide-some-remote-module-deferred-registration-failed\";\n\nexport const RemoteModulesDeferredRegistrationsUpdateStartedEvent = \"squide-remote-modules-deferred-registrations-update-started\";\nexport const RemoteModulesDeferredRegistrationsUpdateCompletedEvent = \"squide-remote-modules-deferred-registrations-update-completed-started\";\nexport const RemoteModuleDeferredRegistrationUpdateFailedEvent = \"squide-remote-module-deferred-registration-update-failed\";\n\nexport interface RemoteModulesRegistrationStartedEventPayload {\n remoteCount: number;\n}\n\nexport interface RemoteModulesRegistrationCompletedEventPayload {\n remoteCount: number;\n}\n\nexport interface RemoteModulesDeferredRegistrationStartedEventPayload {\n registrationCount: number;\n}\n\nexport interface RemoteModulesDeferredRegistrationCompletedEventPayload {\n registrationCount: number;\n}\n\nexport interface RemoteModulesDeferredRegistrationsUpdateStartedEventPayload {\n registrationCount: number;\n}\n\nexport interface RemoteModulesDeferredRegistrationsUpdateCompletedEventPayload {\n registrationCount: number;\n}\n\nconst RemoteRegisterModuleName = \"register\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype LoadRemoteFunction = (remoteName: string, moduleName: string) => Promise<any>;\n\ninterface DeferredRegistration<TRuntime extends Runtime = Runtime, TData = unknown> {\n remoteName: string;\n index: string;\n fct: DeferredRegistrationFunction<TRuntime, TData>;\n}\n\nexport class RemoteModuleRegistrationError extends ModuleRegistrationError {\n readonly #remoteName: string;\n readonly #moduleName: string;\n\n constructor(message: string, remoteName: string, moduleName: string, options?: ErrorOptions) {\n super(message, options);\n\n this.#remoteName = remoteName;\n this.#moduleName = moduleName;\n }\n\n get remoteName() {\n return this.#remoteName;\n }\n\n get moduleName() {\n return this.#moduleName;\n }\n}\n\nexport class RemoteModuleRegistry implements ModuleRegistry {\n #registrationStatus: ModuleRegistrationStatus = \"none\";\n\n readonly #deferredRegistrations: DeferredRegistration[] = [];\n readonly #loadRemote: LoadRemoteFunction;\n readonly #statusChangedListeners = new Set<ModuleRegistrationStatusChangedListener>();\n\n constructor(loadRemote: LoadRemoteFunction) {\n this.#loadRemote = loadRemote;\n }\n\n get id() {\n return RemoteModuleRegistryId;\n }\n\n #logSharedScope(logger: Logger) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (__webpack_share_scopes__) {\n logger.debug(\n \"[squide] Module Federation shared scope is available:\",\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n __webpack_share_scopes__.default\n );\n }\n }\n\n async registerModules<TRuntime extends Runtime = Runtime, TContext = unknown, TData = unknown>(remotes: RemoteDefinition[], runtime: TRuntime, { context }: RegisterModulesOptions<TContext> = {}) {\n const errors: RemoteModuleRegistrationError[] = [];\n\n if (this.#registrationStatus !== \"none\") {\n throw new Error(\"[squide] The registerRemoteModules function can only be called once.\");\n }\n\n if (remotes.length > 0) {\n runtime.logger.information(`[squide] Found ${remotes.length} remote module${remotes.length !== 1 ? \"s\" : \"\"} to register.`);\n\n this.#setRegistrationStatus(\"registering-modules\");\n\n runtime.eventBus.dispatch(RemoteModulesRegistrationStartedEvent, {\n remoteCount: remotes.length\n } satisfies RemoteModulesRegistrationStartedEventPayload);\n\n let completedCount = 0;\n\n await Promise.allSettled(remotes.map(async (x, index) => {\n const remoteName = x.name;\n const loggerScope = (runtime.logger as RootLogger).startScope(`[squide] ${index + 1}/${remotes.length} Loading module \"${RemoteRegisterModuleName}\" of remote \"${remoteName}\".`);\n const runtimeScope = runtime.startScope(loggerScope);\n\n try {\n const module = await this.#loadRemote(remoteName, RemoteRegisterModuleName);\n\n if (isNil(module.register)) {\n throw new Error(`[squide] A \"register\" function is not available for module \"${RemoteRegisterModuleName}\" of remote \"${remoteName}\". Make sure your remote \"./register.[js,jsx,ts.tsx]\" file export a function named \"register\".`);\n }\n\n loggerScope.debug(\"[squide] Registering module...\");\n\n const optionalDeferredRegistration = await registerModule<TRuntime, TContext, TData>(module.register, runtimeScope as TRuntime, context);\n\n if (isFunction(optionalDeferredRegistration)) {\n this.#deferredRegistrations.push({\n remoteName: x.name,\n index: `${index + 1}/${remotes.length}`,\n fct: optionalDeferredRegistration as DeferredRegistrationFunction\n });\n }\n\n completedCount += 1;\n\n loggerScope.information(\"[squide] Successfully registered remote module.\", {\n style: {\n color: \"green\"\n }\n });\n\n loggerScope.end({\n labelStyle: {\n color: \"green\"\n }\n });\n } catch (error: unknown) {\n loggerScope\n .withText(\"[squide] An error occured while registering the remote module.\")\n .withError(error as Error)\n .error();\n\n loggerScope.end({\n labelStyle: {\n color: \"red\"\n }\n });\n\n errors.push(\n new RemoteModuleRegistrationError(\n `An error occured while registering module \"${RemoteRegisterModuleName}\" of remote \"${remoteName}\".`,\n remoteName,\n RemoteRegisterModuleName,\n { cause: error }\n )\n );\n }\n }));\n\n if (errors.length > 0) {\n errors.forEach(x => {\n runtime.eventBus.dispatch(RemoteModuleRegistrationFailedEvent, x);\n });\n }\n\n // Must be dispatched before updating the registration status to ensure bootstrapping events sequencing.\n runtime.eventBus.dispatch(RemoteModulesRegistrationCompletedEvent, {\n remoteCount: completedCount\n } satisfies RemoteModulesRegistrationCompletedEventPayload);\n\n this.#setRegistrationStatus(this.#deferredRegistrations.length > 0 ? \"modules-registered\" : \"ready\");\n\n // After introducting the \"setRegistrationStatus\" method, TypeScript seems to think that the only possible\n // values for registrationStatus is \"none\" and now complains about the lack of overlapping between \"none\" and \"ready\".\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (this.#registrationStatus === \"ready\") {\n this.#logSharedScope(runtime.logger);\n }\n } else {\n // There's no modules to register, it can be considered as ready.\n this.#setRegistrationStatus(\"ready\");\n }\n\n return errors;\n }\n\n async registerDeferredRegistrations<TData = unknown, TRuntime extends Runtime = Runtime>(data: TData, runtime: TRuntime) {\n const errors: RemoteModuleRegistrationError[] = [];\n\n if (this.#registrationStatus === \"ready\" && this.#deferredRegistrations.length === 0) {\n // No deferred registrations were returned by the remote modules, skip this phase.\n return errors;\n }\n\n if (this.#registrationStatus === \"none\" || this.#registrationStatus === \"registering-modules\") {\n throw new Error(\"[squide] The registerDeferredRegistrations function can only be called once the remote modules are registered.\");\n }\n\n if (this.#registrationStatus !== \"modules-registered\") {\n throw new Error(\"[squide] The registerDeferredRegistrations function can only be called once.\");\n }\n\n this.#setRegistrationStatus(\"registering-deferred-registration\");\n\n runtime.eventBus.dispatch(RemoteModulesDeferredRegistrationStartedEvent, {\n registrationCount: this.#deferredRegistrations.length\n } satisfies RemoteModulesDeferredRegistrationStartedEventPayload);\n\n let completedCount = 0;\n\n await Promise.allSettled(this.#deferredRegistrations.map(async ({ remoteName, index, fct: deferredRegister }) => {\n const loggerScope = (runtime.logger as RootLogger).startScope(`[squide] ${index} Registering the deferred registrations for module \"${RemoteRegisterModuleName}\" of remote \"${remoteName}\".`);\n const runtimeScope = runtime.startScope(loggerScope);\n\n loggerScope\n .withText(\"Data:\")\n .withObject(data)\n .debug();\n\n try {\n await deferredRegister(runtimeScope, data, \"register\");\n\n completedCount += 1;\n } catch (error: unknown) {\n loggerScope\n .withText(\"[squide] An error occured while registering the deferred registrations.\")\n .withError(error as Error)\n .error();\n\n loggerScope.end({\n labelStyle: {\n color: \"red\"\n }\n });\n\n errors.push(\n new RemoteModuleRegistrationError(\n `An error occured while registering the deferred registrations for module \"${RemoteRegisterModuleName}\" of remote \"${remoteName}\".`,\n remoteName,\n RemoteRegisterModuleName,\n { cause: error }\n )\n );\n }\n\n loggerScope.information(\"[squide] Successfully registered deferred registrations.\", {\n style: {\n color: \"green\"\n }\n });\n\n loggerScope.end({\n labelStyle: {\n color: \"green\"\n }\n });\n }));\n\n if (errors.length > 0) {\n errors.forEach(x => {\n runtime.eventBus.dispatch(RemoteModuleDeferredRegistrationFailedEvent, x);\n });\n }\n\n // Must be dispatched before updating the registration status to ensure bootstrapping events sequencing.\n runtime.eventBus.dispatch(RemoteModulesDeferredRegistrationCompletedEvent, {\n registrationCount: completedCount\n } satisfies RemoteModulesDeferredRegistrationCompletedEventPayload);\n\n this.#setRegistrationStatus(\"ready\");\n this.#logSharedScope(runtime.logger);\n\n return errors;\n }\n\n async updateDeferredRegistrations<TData = unknown, TRuntime extends Runtime = Runtime>(data: TData, runtime: TRuntime) {\n const errors: RemoteModuleRegistrationError[] = [];\n\n if (this.#registrationStatus !== \"ready\") {\n throw new Error(\"[squide] The updateDeferredRegistrations function can only be called once the remote modules are ready.\");\n }\n\n runtime.eventBus.dispatch(RemoteModulesDeferredRegistrationsUpdateStartedEvent, {\n registrationCount: this.#deferredRegistrations.length\n } satisfies RemoteModulesDeferredRegistrationsUpdateStartedEventPayload);\n\n let completedCount = 0;\n\n await Promise.allSettled(this.#deferredRegistrations.map(async ({ remoteName, index, fct: deferredRegister }) => {\n const loggerScope = (runtime.logger as RootLogger).startScope(`[squide] ${index} Updating the deferred registrations for module \"${RemoteRegisterModuleName}\" of remote \"${remoteName}\".`);\n const runtimeScope = runtime.startScope(loggerScope);\n\n loggerScope\n .withText(\"Data:\")\n .withObject(data)\n .debug();\n\n try {\n await deferredRegister(runtimeScope, data, \"update\");\n\n completedCount += 1;\n } catch (error: unknown) {\n loggerScope\n .withText(\"[squide] An error occured while updating the deferred registrations.\")\n .withError(error as Error)\n .error();\n\n loggerScope.end({\n labelStyle: {\n color: \"red\"\n }\n });\n\n errors.push(\n new RemoteModuleRegistrationError(\n `An error occured while updating the deferred registrations for module \"${RemoteRegisterModuleName}\" of remote \"${remoteName}\".`,\n remoteName,\n RemoteRegisterModuleName,\n { cause: error }\n )\n );\n }\n\n loggerScope.information(\"[squide] Successfully updated the deferred registrations.\", {\n style: {\n color: \"green\"\n }\n });\n\n loggerScope.end({\n labelStyle: {\n color: \"green\"\n }\n });\n }));\n\n if (errors.length > 0) {\n errors.forEach(x => {\n runtime.eventBus.dispatch(RemoteModuleDeferredRegistrationUpdateFailedEvent, x);\n });\n }\n\n runtime.eventBus.dispatch(RemoteModulesDeferredRegistrationsUpdateCompletedEvent, {\n registrationCount: completedCount\n } satisfies RemoteModulesDeferredRegistrationsUpdateCompletedEventPayload);\n\n return errors;\n }\n\n registerStatusChangedListener(callback: ModuleRegistrationStatusChangedListener) {\n this.#statusChangedListeners.add(callback);\n }\n\n removeStatusChangedListener(callback: ModuleRegistrationStatusChangedListener) {\n this.#statusChangedListeners.delete(callback);\n }\n\n #setRegistrationStatus(status: ModuleRegistrationStatus) {\n this.#registrationStatus = status;\n\n this.#statusChangedListeners.forEach(x => {\n x();\n });\n }\n\n get registrationStatus() {\n return this.#registrationStatus;\n }\n}\n\nexport function toRemoteModuleDefinitions(remotes: RemoteDefinition[]) {\n return remotes.map(x => ({\n definition: x,\n registryId: RemoteModuleRegistryId\n }));\n}\n"],"names":["isFunction","isNil","ModuleRegistrationError","registerModule","RemoteModuleRegistryId","RemoteModulesRegistrationStartedEvent","RemoteModulesRegistrationCompletedEvent","RemoteModuleRegistrationFailedEvent","RemoteModulesDeferredRegistrationStartedEvent","RemoteModulesDeferredRegistrationCompletedEvent","RemoteModuleDeferredRegistrationFailedEvent","RemoteModulesDeferredRegistrationsUpdateStartedEvent","RemoteModulesDeferredRegistrationsUpdateCompletedEvent","RemoteModuleDeferredRegistrationUpdateFailedEvent","RemoteRegisterModuleName","RemoteModuleRegistrationError","message","remoteName","moduleName","options","RemoteModuleRegistry","Set","loadRemote","logger","__webpack_share_scopes__","remotes","runtime","context","errors","Error","completedCount","Promise","x","index","loggerScope","runtimeScope","module","optionalDeferredRegistration","error","data","deferredRegister","callback","status","toRemoteModuleDefinitions"],"mappings":";;;;;;AAAA,wF;;;;;;ACA0Q;AAInQ,MAAMI,yBAAyB,SAAS;AAExC,MAAMC,wCAAwC,6CAA6C;AAC3F,MAAMC,0CAA0C,+CAA+C;AAC/F,MAAMC,sCAAsC,2CAA2C;AAEvF,MAAMC,gDAAgD,sDAAsD;AAC5G,MAAMC,kDAAkD,wDAAwD;AAChH,MAAMC,8CAA8C,yDAAyD;AAE7G,MAAMC,uDAAuD,8DAA8D;AAC3H,MAAMC,yDAAyD,wEAAwE;AACvI,MAAMC,oDAAoD,2DAA2D;AA0B5H,MAAMC,2BAA2B;AAW1B,MAAMC,sCAAsCb,uBAAuBA;IAC7D,WAAW,CAAS;IACpB,WAAW,CAAS;IAE7B,YAAYc,OAAe,EAAEC,UAAkB,EAAEC,UAAkB,EAAEC,OAAsB,CAAE;QACzF,KAAK,CAACH,SAASG;QAEf,IAAI,CAAC,WAAW,GAAGF;QACnB,IAAI,CAAC,WAAW,GAAGC;IACvB;IAEA,IAAI,aAAa;QACb,OAAO,IAAI,CAAC,WAAW;IAC3B;IAEA,IAAI,aAAa;QACb,OAAO,IAAI,CAAC,WAAW;IAC3B;AACJ;AAEO,MAAME;IACT,mBAAmB,GAA6B,OAAO;IAE9C,sBAAsB,GAA2B,EAAE,CAAC;IACpD,WAAW,CAAqB;IAChC,uBAAuB,GAAG,IAAIC,MAA+C;IAEtF,YAAYC,UAA8B,CAAE;QACxC,IAAI,CAAC,WAAW,GAAGA;IACvB;IAEA,IAAI,KAAK;QACL,OAAOlB;IACX;IAEA,eAAe,CAACmB,MAAc;QAC1B,6DAA6D;QAC7D,aAAa;QACb,IAAIC,qBAAwBA,EAAE;YAC1BD,OAAO,K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AAQ,CAAC,wEACT,SAAS,CAACI,OACV,KAAK;gBAEVJ,YAAY,GAAG,CAAC;oBACZ,YAAY;wBACR,OAAO;oBACX;gBACJ;gBAEAN,OAAO,IAAI,CACP,IAAIb,8BACA,CAAC,uEAAuE,EAAED,yBAAyB,aAAa,EAAEG,WAAW,EAAE,CAAC,EAChIA,YACAH,0BACA;oBAAE,OAAOwB;gBAAM;YAG3B;YAEAJ,YAAY,WAAW,CAAC,6DAA6D;gBACjF,OAAO;oBACH,OAAO;gBACX;YACJ;YAEAA,YAAY,GAAG,CAAC;gBACZ,YAAY;oBACR,OAAO;gBACX;YACJ;QACJ;QAEA,IAAIN,OAAO,MAAM,GAAG,GAAG;YACnBA,OAAO,OAAO,CAACI,CAAAA;gBACXN,QAAQ,QAAQ,CAAC,QAAQ,CAACb,mDAAmDmB;YACjF;QACJ;QAEAN,QAAQ,QAAQ,CAAC,QAAQ,CAACd,wDAAwD;YAC9E,mBAAmBkB;QACvB;QAEA,OAAOF;IACX;IAEA,8BAA8Ba,QAAiD,EAAE;QAC7E,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAACA;IACrC;IAEA,4BAA4BA,QAAiD,EAAE;QAC3E,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAACA;IACxC;IAEA,sBAAsB,CAACC,MAAgC;QACnD,IAAI,CAAC,mBAAmB,GAAGA;QAE3B,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAACV,CAAAA;YACjCA;QACJ;IACJ;IAEA,IAAI,qBAAqB;QACrB,OAAO,IAAI,CAAC,mBAAmB;IACnC;AACJ;AAEO,SAASW,0BAA0BlB,OAA2B;IACjE,OAAOA,QAAQ,GAAG,CAACO,CAAAA,IAAM;YACrB,YAAYA;YACZ,YAAY5B;QAChB;AACJ"}
|
|
1
|
+
{"version":3,"file":"RemoteModuleRegistry.js","sources":["webpack/runtime/has_own_property","../src/RemoteModuleRegistry.ts"],"sourcesContent":["__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","import { ModuleDefinition, ModuleRegistrationError, registerModule, type DeferredRegistrationFunction, type ModuleRegistrationStatus, type ModuleRegistrationStatusChangedListener, type ModuleRegistry, type RegisterModulesOptions, type Runtime } from \"@squide/core\";\nimport { isFunction, isNil } from \"@squide/core/internal\";\nimport type { Logger, RootLogger } from \"@workleap/logging\";\nimport type { RemoteDefinition } from \"./RemoteDefinition.ts\";\n\nexport const RemoteModuleRegistryId = \"remote\";\n\nexport const RemoteModulesRegistrationStartedEvent = \"squide-remote-modules-registration-started\";\nexport const RemoteModulesRegistrationCompletedEvent = \"squide-remote-modules-registration-completed\";\nexport const RemoteModuleRegistrationFailedEvent = \"squide-remote-module-registration-failed\";\n\nexport const RemoteModulesDeferredRegistrationStartedEvent = \"squide-remote-modules-deferred-registration-started\";\nexport const RemoteModulesDeferredRegistrationCompletedEvent = \"squide-remote-modules-deferred-registration-completed\";\nexport const RemoteModuleDeferredRegistrationFailedEvent = \"squide-some-remote-module-deferred-registration-failed\";\n\nexport const RemoteModulesDeferredRegistrationsUpdateStartedEvent = \"squide-remote-modules-deferred-registrations-update-started\";\nexport const RemoteModulesDeferredRegistrationsUpdateCompletedEvent = \"squide-remote-modules-deferred-registrations-update-completed-started\";\nexport const RemoteModuleDeferredRegistrationUpdateFailedEvent = \"squide-remote-module-deferred-registration-update-failed\";\n\nexport interface RemoteModulesRegistrationStartedEventPayload {\n remoteCount: number;\n}\n\nexport interface RemoteModulesRegistrationCompletedEventPayload {\n remoteCount: number;\n}\n\nexport interface RemoteModulesDeferredRegistrationStartedEventPayload {\n registrationCount: number;\n}\n\nexport interface RemoteModulesDeferredRegistrationCompletedEventPayload {\n registrationCount: number;\n}\n\nexport interface RemoteModulesDeferredRegistrationsUpdateStartedEventPayload {\n registrationCount: number;\n}\n\nexport interface RemoteModulesDeferredRegistrationsUpdateCompletedEventPayload {\n registrationCount: number;\n}\n\nconst RemoteRegisterModuleName = \"register\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype LoadRemoteFunction = (remoteName: string, moduleName: string) => Promise<any>;\n\ninterface DeferredRegistration<TRuntime extends Runtime = Runtime, TData = unknown> {\n remoteName: string;\n index: string;\n fct: DeferredRegistrationFunction<TRuntime, TData>;\n}\n\nexport class RemoteModuleRegistrationError extends ModuleRegistrationError {\n readonly #remoteName: string;\n readonly #moduleName: string;\n\n constructor(message: string, remoteName: string, moduleName: string, options?: ErrorOptions) {\n super(message, options);\n\n this.#remoteName = remoteName;\n this.#moduleName = moduleName;\n }\n\n get remoteName() {\n return this.#remoteName;\n }\n\n get moduleName() {\n return this.#moduleName;\n }\n}\n\nexport class RemoteModuleRegistry implements ModuleRegistry {\n #registrationStatus: ModuleRegistrationStatus = \"none\";\n\n readonly #deferredRegistrations: DeferredRegistration[] = [];\n readonly #loadRemote: LoadRemoteFunction;\n readonly #statusChangedListeners = new Set<ModuleRegistrationStatusChangedListener>();\n\n constructor(loadRemote: LoadRemoteFunction) {\n this.#loadRemote = loadRemote;\n }\n\n get id() {\n return RemoteModuleRegistryId;\n }\n\n #logSharedScope(logger: Logger) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (__webpack_share_scopes__) {\n logger.debug(\n \"[squide] Module Federation shared scope is available:\",\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n __webpack_share_scopes__.default\n );\n }\n }\n\n async registerModules<TRuntime extends Runtime = Runtime, TContext = unknown, TData = unknown>(runtime: TRuntime, remotes: RemoteDefinition[], { context }: RegisterModulesOptions<TContext> = {}) {\n const errors: RemoteModuleRegistrationError[] = [];\n\n if (this.#registrationStatus !== \"none\") {\n throw new Error(\"[squide] The registerRemoteModules function can only be called once.\");\n }\n\n if (remotes.length > 0) {\n runtime.logger.information(`[squide] Found ${remotes.length} remote module${remotes.length !== 1 ? \"s\" : \"\"} to register.`);\n\n this.#setRegistrationStatus(\"registering-modules\");\n\n runtime.eventBus.dispatch(RemoteModulesRegistrationStartedEvent, {\n remoteCount: remotes.length\n } satisfies RemoteModulesRegistrationStartedEventPayload);\n\n let completedCount = 0;\n\n await Promise.allSettled(remotes.map(async (x, index) => {\n const remoteName = x.name;\n const loggerScope = (runtime.logger as RootLogger).startScope(`[squide] ${index + 1}/${remotes.length} Loading module \"${RemoteRegisterModuleName}\" of remote \"${remoteName}\".`);\n const runtimeScope = runtime.startScope(loggerScope);\n\n try {\n const module = await this.#loadRemote(remoteName, RemoteRegisterModuleName);\n\n if (isNil(module.register)) {\n throw new Error(`[squide] A \"register\" function is not available for module \"${RemoteRegisterModuleName}\" of remote \"${remoteName}\". Make sure your remote \"./register.[js,jsx,ts.tsx]\" file export a function named \"register\".`);\n }\n\n loggerScope.debug(\"[squide] Registering module...\");\n\n const optionalDeferredRegistration = await registerModule<TRuntime, TContext, TData>(module.register, runtimeScope as TRuntime, context);\n\n if (isFunction(optionalDeferredRegistration)) {\n this.#deferredRegistrations.push({\n remoteName: x.name,\n index: `${index + 1}/${remotes.length}`,\n fct: optionalDeferredRegistration as DeferredRegistrationFunction\n });\n }\n\n completedCount += 1;\n\n loggerScope.information(\"[squide] Successfully registered remote module.\", {\n style: {\n color: \"green\"\n }\n });\n\n loggerScope.end({\n labelStyle: {\n color: \"green\"\n }\n });\n } catch (error: unknown) {\n loggerScope\n .withText(\"[squide] An error occured while registering the remote module.\")\n .withError(error as Error)\n .error();\n\n loggerScope.end({\n labelStyle: {\n color: \"red\"\n }\n });\n\n errors.push(\n new RemoteModuleRegistrationError(\n `An error occured while registering module \"${RemoteRegisterModuleName}\" of remote \"${remoteName}\".`,\n remoteName,\n RemoteRegisterModuleName,\n { cause: error }\n )\n );\n }\n }));\n\n if (errors.length > 0) {\n errors.forEach(x => {\n runtime.eventBus.dispatch(RemoteModuleRegistrationFailedEvent, x);\n });\n }\n\n // Must be dispatched before updating the registration status to ensure bootstrapping events sequencing.\n runtime.eventBus.dispatch(RemoteModulesRegistrationCompletedEvent, {\n remoteCount: completedCount\n } satisfies RemoteModulesRegistrationCompletedEventPayload);\n\n this.#setRegistrationStatus(this.#deferredRegistrations.length > 0 ? \"modules-registered\" : \"ready\");\n\n // After introducting the \"setRegistrationStatus\" method, TypeScript seems to think that the only possible\n // values for registrationStatus is \"none\" and now complains about the lack of overlapping between \"none\" and \"ready\".\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (this.#registrationStatus === \"ready\") {\n this.#logSharedScope(runtime.logger);\n }\n } else {\n // There's no modules to register, it can be considered as ready.\n this.#setRegistrationStatus(\"ready\");\n }\n\n return errors;\n }\n\n async registerDeferredRegistrations<TRuntime extends Runtime = Runtime, TData = unknown>(runtime: TRuntime, data?: TData) {\n const errors: RemoteModuleRegistrationError[] = [];\n\n if (this.#registrationStatus === \"ready\" && this.#deferredRegistrations.length === 0) {\n // No deferred registrations were returned by the remote modules, skip this phase.\n return errors;\n }\n\n if (this.#registrationStatus === \"none\" || this.#registrationStatus === \"registering-modules\") {\n throw new Error(\"[squide] The registerDeferredRegistrations function can only be called once the remote modules are registered.\");\n }\n\n if (this.#registrationStatus !== \"modules-registered\") {\n throw new Error(\"[squide] The registerDeferredRegistrations function can only be called once.\");\n }\n\n this.#setRegistrationStatus(\"registering-deferred-registration\");\n\n runtime.eventBus.dispatch(RemoteModulesDeferredRegistrationStartedEvent, {\n registrationCount: this.#deferredRegistrations.length\n } satisfies RemoteModulesDeferredRegistrationStartedEventPayload);\n\n let completedCount = 0;\n\n await Promise.allSettled(this.#deferredRegistrations.map(async ({ remoteName, index, fct: deferredRegister }) => {\n const loggerScope = (runtime.logger as RootLogger).startScope(`[squide] ${index} Registering the deferred registrations for module \"${RemoteRegisterModuleName}\" of remote \"${remoteName}\".`);\n const runtimeScope = runtime.startScope(loggerScope);\n\n loggerScope\n .withText(\"Data:\")\n .withObject(data)\n .debug();\n\n try {\n await deferredRegister(runtimeScope, data, \"register\");\n\n completedCount += 1;\n } catch (error: unknown) {\n loggerScope\n .withText(\"[squide] An error occured while registering the deferred registrations.\")\n .withError(error as Error)\n .error();\n\n loggerScope.end({\n labelStyle: {\n color: \"red\"\n }\n });\n\n errors.push(\n new RemoteModuleRegistrationError(\n `An error occured while registering the deferred registrations for module \"${RemoteRegisterModuleName}\" of remote \"${remoteName}\".`,\n remoteName,\n RemoteRegisterModuleName,\n { cause: error }\n )\n );\n }\n\n loggerScope.information(\"[squide] Successfully registered deferred registrations.\", {\n style: {\n color: \"green\"\n }\n });\n\n loggerScope.end({\n labelStyle: {\n color: \"green\"\n }\n });\n }));\n\n if (errors.length > 0) {\n errors.forEach(x => {\n runtime.eventBus.dispatch(RemoteModuleDeferredRegistrationFailedEvent, x);\n });\n }\n\n // Must be dispatched before updating the registration status to ensure bootstrapping events sequencing.\n runtime.eventBus.dispatch(RemoteModulesDeferredRegistrationCompletedEvent, {\n registrationCount: completedCount\n } satisfies RemoteModulesDeferredRegistrationCompletedEventPayload);\n\n this.#setRegistrationStatus(\"ready\");\n this.#logSharedScope(runtime.logger);\n\n return errors;\n }\n\n async updateDeferredRegistrations<TRuntime extends Runtime = Runtime, TData = unknown>(runtime: TRuntime, data?: TData) {\n const errors: RemoteModuleRegistrationError[] = [];\n\n if (this.#registrationStatus !== \"ready\") {\n throw new Error(\"[squide] The updateDeferredRegistrations function can only be called once the remote modules are ready.\");\n }\n\n runtime.eventBus.dispatch(RemoteModulesDeferredRegistrationsUpdateStartedEvent, {\n registrationCount: this.#deferredRegistrations.length\n } satisfies RemoteModulesDeferredRegistrationsUpdateStartedEventPayload);\n\n let completedCount = 0;\n\n await Promise.allSettled(this.#deferredRegistrations.map(async ({ remoteName, index, fct: deferredRegister }) => {\n const loggerScope = (runtime.logger as RootLogger).startScope(`[squide] ${index} Updating the deferred registrations for module \"${RemoteRegisterModuleName}\" of remote \"${remoteName}\".`);\n const runtimeScope = runtime.startScope(loggerScope);\n\n loggerScope\n .withText(\"Data:\")\n .withObject(data)\n .debug();\n\n try {\n await deferredRegister(runtimeScope, data, \"update\");\n\n completedCount += 1;\n } catch (error: unknown) {\n loggerScope\n .withText(\"[squide] An error occured while updating the deferred registrations.\")\n .withError(error as Error)\n .error();\n\n loggerScope.end({\n labelStyle: {\n color: \"red\"\n }\n });\n\n errors.push(\n new RemoteModuleRegistrationError(\n `An error occured while updating the deferred registrations for module \"${RemoteRegisterModuleName}\" of remote \"${remoteName}\".`,\n remoteName,\n RemoteRegisterModuleName,\n { cause: error }\n )\n );\n }\n\n loggerScope.information(\"[squide] Successfully updated the deferred registrations.\", {\n style: {\n color: \"green\"\n }\n });\n\n loggerScope.end({\n labelStyle: {\n color: \"green\"\n }\n });\n }));\n\n if (errors.length > 0) {\n errors.forEach(x => {\n runtime.eventBus.dispatch(RemoteModuleDeferredRegistrationUpdateFailedEvent, x);\n });\n }\n\n runtime.eventBus.dispatch(RemoteModulesDeferredRegistrationsUpdateCompletedEvent, {\n registrationCount: completedCount\n } satisfies RemoteModulesDeferredRegistrationsUpdateCompletedEventPayload);\n\n return errors;\n }\n\n registerStatusChangedListener(callback: ModuleRegistrationStatusChangedListener) {\n this.#statusChangedListeners.add(callback);\n }\n\n removeStatusChangedListener(callback: ModuleRegistrationStatusChangedListener) {\n this.#statusChangedListeners.delete(callback);\n }\n\n #setRegistrationStatus(status: ModuleRegistrationStatus) {\n this.#registrationStatus = status;\n\n this.#statusChangedListeners.forEach(x => {\n x();\n });\n }\n\n get registrationStatus() {\n return this.#registrationStatus;\n }\n}\n\nexport function toRemoteModuleDefinitions(remotes: (RemoteDefinition | undefined)[]): ModuleDefinition[] {\n return remotes\n .filter((x): x is RemoteDefinition => Boolean(x))\n .map(x => ({\n definition: x,\n registryId: RemoteModuleRegistryId\n }));\n}\n"],"names":["ModuleRegistrationError","registerModule","isFunction","isNil","RemoteModuleRegistryId","RemoteModulesRegistrationStartedEvent","RemoteModulesRegistrationCompletedEvent","RemoteModuleRegistrationFailedEvent","RemoteModulesDeferredRegistrationStartedEvent","RemoteModulesDeferredRegistrationCompletedEvent","RemoteModuleDeferredRegistrationFailedEvent","RemoteModulesDeferredRegistrationsUpdateStartedEvent","RemoteModulesDeferredRegistrationsUpdateCompletedEvent","RemoteModuleDeferredRegistrationUpdateFailedEvent","RemoteRegisterModuleName","RemoteModuleRegistrationError","message","remoteName","moduleName","options","RemoteModuleRegistry","Set","loadRemote","logger","__webpack_share_scopes__","runtime","remotes","context","errors","Error","completedCount","Promise","x","index","loggerScope","runtimeScope","module","optionalDeferredRegistration","error","data","deferredRegister","callback","status","toRemoteModuleDefinitions","Boolean"],"mappings":";;;;;;;AAAA,wF;;;;;;;;ACAyQ;AAC/M;AAInD,MAAMI,yBAAyB,SAAS;AAExC,MAAMC,wCAAwC,6CAA6C;AAC3F,MAAMC,0CAA0C,+CAA+C;AAC/F,MAAMC,sCAAsC,2CAA2C;AAEvF,MAAMC,gDAAgD,sDAAsD;AAC5G,MAAMC,kDAAkD,wDAAwD;AAChH,MAAMC,8CAA8C,yDAAyD;AAE7G,MAAMC,uDAAuD,8DAA8D;AAC3H,MAAMC,yDAAyD,wEAAwE;AACvI,MAAMC,oDAAoD,2DAA2D;AA0B5H,MAAMC,2BAA2B;AAW1B,MAAMC,sCAAsCf,uBAAuBA;IAC7D,WAAW,CAAS;IACpB,WAAW,CAAS;IAE7B,YAAYgB,OAAe,EAAEC,UAAkB,EAAEC,UAAkB,EAAEC,OAAsB,CAAE;QACzF,KAAK,CAACH,SAASG;QAEf,IAAI,CAAC,WAAW,GAAGF;QACnB,IAAI,CAAC,WAAW,GAAGC;IACvB;IAEA,IAAI,aAAa;QACb,OAAO,IAAI,CAAC,WAAW;IAC3B;IAEA,IAAI,aAAa;QACb,OAAO,IAAI,CAAC,WAAW;IAC3B;AACJ;AAEO,MAAME;IACT,mBAAmB,GAA6B,OAAO;IAE9C,sBAAsB,GAA2B,EAAE,CAAC;IACpD,WAAW,CAAqB;IAChC,uBAAuB,GAAG,IAAIC,MAA+C;IAEtF,YAAYC,UAA8B,CAAE;QACxC,IAAI,CAAC,WAAW,GAAGA;IACvB;IA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M;YACP,YAAYA;YACZ,YAAY5B;QAChB;AACR"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FireflyRuntime, type InitializeFireflyOptions as BaseInitializeFireflyOptions } from "@squide/firefly";
|
|
2
2
|
import { RemoteDefinition } from "./RemoteDefinition.ts";
|
|
3
3
|
export interface InitializeFireflyOptions<TRuntime extends FireflyRuntime, TContext = unknown, TData = unknown> extends BaseInitializeFireflyOptions<TRuntime, TContext, TData> {
|
|
4
|
-
remotes?: RemoteDefinition[];
|
|
4
|
+
remotes?: (RemoteDefinition | undefined)[];
|
|
5
5
|
}
|
|
6
6
|
export declare function initializeFirefly<TContext = unknown, TData = unknown>(options?: InitializeFireflyOptions<FireflyRuntime, TContext, TData>): FireflyRuntime<any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initializeFirefly.js","sources":["../src/initializeFirefly.ts"],"sourcesContent":["import { FireflyRuntime, initializeFirefly as baseInitializeFirefly, type InitializeFireflyOptions as BaseInitializeFireflyOptions } from \"@squide/firefly\";\nimport { ModuleFederationPlugin } from \"./ModuleFederationPlugin.ts\";\nimport { RemoteDefinition } from \"./RemoteDefinition.ts\";\nimport { toRemoteModuleDefinitions } from \"./RemoteModuleRegistry.ts\";\n\nexport interface InitializeFireflyOptions<TRuntime extends FireflyRuntime, TContext = unknown, TData = unknown> extends BaseInitializeFireflyOptions<TRuntime, TContext, TData> {\n remotes?: RemoteDefinition[];\n}\n\nexport function initializeFirefly<TContext = unknown, TData = unknown>(options: InitializeFireflyOptions<FireflyRuntime, TContext, TData> = {}) {\n const {\n remotes = [],\n moduleDefinitions = [],\n plugins = [],\n ...rest\n } = options;\n\n return baseInitializeFirefly({\n moduleDefinitions: [\n ...moduleDefinitions,\n ...toRemoteModuleDefinitions(remotes)\n ],\n plugins: [\n x => new ModuleFederationPlugin(x),\n ...plugins\n ],\n ...rest\n });\n}\n"],"names":["initializeFirefly","baseInitializeFirefly","ModuleFederationPlugin","toRemoteModuleDefinitions","options","remotes","moduleDefinitions","plugins","rest","x"],"mappings":";;;;;;;;;;;AAA4J;AACvF;AAEC;AAM/D,SAASA,mCAAiBA,CAAsCI,UAAqE,CAAC,CAAC;IAC1I,MAAM,EACFC,UAAU,EAAE,EACZC,oBAAoB,EAAE,EACtBC,UAAU,EAAE,EACZ,GAAGC,MACN,GAAGJ;IAEJ,OAAOH,iBAAqBA,CAAC;QACzB,mBAAmB;eACZK;eACAH,yBAAyBA,CAACE;SAChC;QACD,SAAS;YACLI,CAAAA,IAAK,IAAIP,sBAAsBA,CAACO;eAC7BF;SACN;QACD,GAAGC,IAAI;IACX;AACJ"}
|
|
1
|
+
{"version":3,"file":"initializeFirefly.js","sources":["../src/initializeFirefly.ts"],"sourcesContent":["import { FireflyRuntime, initializeFirefly as baseInitializeFirefly, type InitializeFireflyOptions as BaseInitializeFireflyOptions } from \"@squide/firefly\";\nimport { ModuleFederationPlugin } from \"./ModuleFederationPlugin.ts\";\nimport { RemoteDefinition } from \"./RemoteDefinition.ts\";\nimport { toRemoteModuleDefinitions } from \"./RemoteModuleRegistry.ts\";\n\nexport interface InitializeFireflyOptions<TRuntime extends FireflyRuntime, TContext = unknown, TData = unknown> extends BaseInitializeFireflyOptions<TRuntime, TContext, TData> {\n remotes?: (RemoteDefinition | undefined)[];\n}\n\nexport function initializeFirefly<TContext = unknown, TData = unknown>(options: InitializeFireflyOptions<FireflyRuntime, TContext, TData> = {}) {\n const {\n remotes = [],\n moduleDefinitions = [],\n plugins = [],\n ...rest\n } = options;\n\n return baseInitializeFirefly({\n moduleDefinitions: [\n ...moduleDefinitions,\n ...toRemoteModuleDefinitions(remotes)\n ],\n plugins: [\n x => new ModuleFederationPlugin(x),\n ...plugins\n ],\n ...rest\n });\n}\n"],"names":["initializeFirefly","baseInitializeFirefly","ModuleFederationPlugin","toRemoteModuleDefinitions","options","remotes","moduleDefinitions","plugins","rest","x"],"mappings":";;;;;;;;;;;AAA4J;AACvF;AAEC;AAM/D,SAASA,mCAAiBA,CAAsCI,UAAqE,CAAC,CAAC;IAC1I,MAAM,EACFC,UAAU,EAAE,EACZC,oBAAoB,EAAE,EACtBC,UAAU,EAAE,EACZ,GAAGC,MACN,GAAGJ;IAEJ,OAAOH,iBAAqBA,CAAC;QACzB,mBAAmB;eACZK;eACAH,yBAAyBA,CAACE;SAChC;QACD,SAAS;YACLI,CAAAA,IAAK,IAAIP,sBAAsBA,CAACO;eAC7BF;SACN;QACD,GAAGC,IAAI;IACX;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squide/firefly-module-federation",
|
|
3
3
|
"author": "Workleap",
|
|
4
|
-
"version": "1.0.
|
|
5
|
-
"description": "Add support for Module Federation to
|
|
4
|
+
"version": "1.0.4",
|
|
5
|
+
"description": "Add support for Module Federation to Squide firefly.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -28,36 +28,36 @@
|
|
|
28
28
|
],
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@opentelemetry/api": "^1.9.0",
|
|
31
|
-
"@tanstack/react-query": "^5.90.
|
|
32
|
-
"msw": "^2.12.
|
|
31
|
+
"@tanstack/react-query": "^5.90.12",
|
|
32
|
+
"msw": "^2.12.4",
|
|
33
33
|
"react": "^18.0.0 || ^19.0.0",
|
|
34
34
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
35
|
-
"react-router": "^7.
|
|
35
|
+
"react-router": "^7.10.1"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@module-federation/enhanced": "0.11.4",
|
|
39
|
-
"@rspack/core": "^1.6.
|
|
39
|
+
"@rspack/core": "^1.6.7",
|
|
40
40
|
"@workleap/logging": "^1.3.2",
|
|
41
|
-
"@squide/core": "6.1.
|
|
42
|
-
"@squide/firefly": "16.0
|
|
41
|
+
"@squide/core": "6.1.7",
|
|
42
|
+
"@squide/firefly": "16.1.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@eslint/js": "9.39.1",
|
|
46
|
-
"@rsbuild/core": "1.6.
|
|
47
|
-
"@rslib/core": "0.18.
|
|
46
|
+
"@rsbuild/core": "1.6.14",
|
|
47
|
+
"@rslib/core": "0.18.4",
|
|
48
48
|
"@testing-library/react": "16.3.0",
|
|
49
|
-
"@types/react": "19.2.
|
|
49
|
+
"@types/react": "19.2.7",
|
|
50
50
|
"@types/react-dom": "19.2.3",
|
|
51
|
-
"@typescript-eslint/parser": "8.
|
|
52
|
-
"@vitejs/plugin-react": "5.1.
|
|
53
|
-
"@workleap/eslint-configs": "1.1.
|
|
51
|
+
"@typescript-eslint/parser": "8.49.0",
|
|
52
|
+
"@vitejs/plugin-react": "5.1.2",
|
|
53
|
+
"@workleap/eslint-configs": "1.1.6",
|
|
54
54
|
"@workleap/rslib-configs": "1.1.3",
|
|
55
55
|
"@workleap/typescript-configs": "3.0.7",
|
|
56
56
|
"eslint": "9.39.1",
|
|
57
|
-
"happy-dom": "20.0.
|
|
57
|
+
"happy-dom": "20.0.11",
|
|
58
58
|
"typescript": "5.9.3",
|
|
59
|
-
"typescript-eslint": "8.
|
|
60
|
-
"vitest": "4.0.
|
|
59
|
+
"typescript-eslint": "8.49.0",
|
|
60
|
+
"vitest": "4.0.15"
|
|
61
61
|
},
|
|
62
62
|
"sideEffects": false,
|
|
63
63
|
"scripts": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { loadRemote as loadModuleFederationRemote } from "@module-federation/enhanced/runtime";
|
|
2
2
|
import { Span } from "@opentelemetry/api";
|
|
3
|
-
import {
|
|
3
|
+
import { Plugin, RegisterModulesOptions, type Runtime } from "@squide/core";
|
|
4
4
|
import { FireflyPlugin, FireflyRuntime } from "@squide/firefly";
|
|
5
5
|
import { ActiveSpan, addProtectedListener, endActiveSpan, getTracer, HoneycombTrackingUnmanagedErrorHandler, startActiveChildSpan, startChildSpan, traceError, type GetSpanFunction } from "@squide/firefly/internal";
|
|
6
6
|
import { RemoteDefinition } from "./RemoteDefinition.ts";
|
|
@@ -206,11 +206,13 @@ export class ModuleFederationPlugin extends Plugin<FireflyRuntime> implements Fi
|
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
export function getModuleFederationPlugin(runtime: Runtime) {
|
|
209
|
-
const plugin = runtime.getPlugin(ModuleFederationPluginName
|
|
209
|
+
const plugin = runtime.getPlugin(ModuleFederationPluginName, {
|
|
210
|
+
throwOnNotFound: false
|
|
211
|
+
}) as ModuleFederationPlugin;
|
|
210
212
|
|
|
211
|
-
if (
|
|
212
|
-
throw new Error("[squide] The getModuleFederationPlugin function is called but no ModuleFederationPlugin instance has been registered with the runtime.");
|
|
213
|
+
if (!plugin) {
|
|
214
|
+
throw new Error("[squide] The getModuleFederationPlugin function is called but no ModuleFederationPlugin instance has been registered with the runtime. Did you import the initializeFirefly function from the \"@squide/firefly-module-federation\" package?");
|
|
213
215
|
}
|
|
214
216
|
|
|
215
|
-
return plugin
|
|
217
|
+
return plugin;
|
|
216
218
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ModuleDefinition, ModuleRegistrationError, registerModule, type DeferredRegistrationFunction, type ModuleRegistrationStatus, type ModuleRegistrationStatusChangedListener, type ModuleRegistry, type RegisterModulesOptions, type Runtime } from "@squide/core";
|
|
2
|
+
import { isFunction, isNil } from "@squide/core/internal";
|
|
2
3
|
import type { Logger, RootLogger } from "@workleap/logging";
|
|
3
4
|
import type { RemoteDefinition } from "./RemoteDefinition.ts";
|
|
4
5
|
|
|
@@ -99,7 +100,7 @@ export class RemoteModuleRegistry implements ModuleRegistry {
|
|
|
99
100
|
}
|
|
100
101
|
}
|
|
101
102
|
|
|
102
|
-
async registerModules<TRuntime extends Runtime = Runtime, TContext = unknown, TData = unknown>(remotes: RemoteDefinition[],
|
|
103
|
+
async registerModules<TRuntime extends Runtime = Runtime, TContext = unknown, TData = unknown>(runtime: TRuntime, remotes: RemoteDefinition[], { context }: RegisterModulesOptions<TContext> = {}) {
|
|
103
104
|
const errors: RemoteModuleRegistrationError[] = [];
|
|
104
105
|
|
|
105
106
|
if (this.#registrationStatus !== "none") {
|
|
@@ -205,7 +206,7 @@ export class RemoteModuleRegistry implements ModuleRegistry {
|
|
|
205
206
|
return errors;
|
|
206
207
|
}
|
|
207
208
|
|
|
208
|
-
async registerDeferredRegistrations<
|
|
209
|
+
async registerDeferredRegistrations<TRuntime extends Runtime = Runtime, TData = unknown>(runtime: TRuntime, data?: TData) {
|
|
209
210
|
const errors: RemoteModuleRegistrationError[] = [];
|
|
210
211
|
|
|
211
212
|
if (this.#registrationStatus === "ready" && this.#deferredRegistrations.length === 0) {
|
|
@@ -294,7 +295,7 @@ export class RemoteModuleRegistry implements ModuleRegistry {
|
|
|
294
295
|
return errors;
|
|
295
296
|
}
|
|
296
297
|
|
|
297
|
-
async updateDeferredRegistrations<
|
|
298
|
+
async updateDeferredRegistrations<TRuntime extends Runtime = Runtime, TData = unknown>(runtime: TRuntime, data?: TData) {
|
|
298
299
|
const errors: RemoteModuleRegistrationError[] = [];
|
|
299
300
|
|
|
300
301
|
if (this.#registrationStatus !== "ready") {
|
|
@@ -389,9 +390,11 @@ export class RemoteModuleRegistry implements ModuleRegistry {
|
|
|
389
390
|
}
|
|
390
391
|
}
|
|
391
392
|
|
|
392
|
-
export function toRemoteModuleDefinitions(remotes: RemoteDefinition[]) {
|
|
393
|
-
return remotes
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
393
|
+
export function toRemoteModuleDefinitions(remotes: (RemoteDefinition | undefined)[]): ModuleDefinition[] {
|
|
394
|
+
return remotes
|
|
395
|
+
.filter((x): x is RemoteDefinition => Boolean(x))
|
|
396
|
+
.map(x => ({
|
|
397
|
+
definition: x,
|
|
398
|
+
registryId: RemoteModuleRegistryId
|
|
399
|
+
}));
|
|
397
400
|
}
|
package/src/initializeFirefly.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { RemoteDefinition } from "./RemoteDefinition.ts";
|
|
|
4
4
|
import { toRemoteModuleDefinitions } from "./RemoteModuleRegistry.ts";
|
|
5
5
|
|
|
6
6
|
export interface InitializeFireflyOptions<TRuntime extends FireflyRuntime, TContext = unknown, TData = unknown> extends BaseInitializeFireflyOptions<TRuntime, TContext, TData> {
|
|
7
|
-
remotes?: RemoteDefinition[];
|
|
7
|
+
remotes?: (RemoteDefinition | undefined)[];
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export function initializeFirefly<TContext = unknown, TData = unknown>(options: InitializeFireflyOptions<FireflyRuntime, TContext, TData> = {}) {
|