@squide/firefly-module-federation 1.1.0 → 1.1.2
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 +19 -0
- package/dist/ModuleFederationPlugin.js +0 -5
- package/dist/ModuleFederationPlugin.js.map +1 -1
- package/dist/RemoteDefinition.js +0 -2
- package/dist/RemoteDefinition.js.map +1 -1
- package/dist/RemoteModuleRegistry.js +1 -10
- package/dist/RemoteModuleRegistry.js.map +1 -1
- package/dist/index.js +3 -9
- package/dist/index.js.map +1 -1
- package/dist/initializeFirefly.js +0 -4
- package/dist/initializeFirefly.js.map +1 -1
- package/dist/rslib-runtime.js +11 -0
- package/dist/rslib-runtime.js.map +1 -0
- package/package.json +21 -20
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @squide/firefly-module-federation
|
|
2
2
|
|
|
3
|
+
## 1.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#575](https://github.com/workleap/wl-squide/pull/575) [`9c91bd4`](https://github.com/workleap/wl-squide/commit/9c91bd47c5357a2b15b1fb0e984f81687a3b8b53) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Bump dependencies
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`9c91bd4`](https://github.com/workleap/wl-squide/commit/9c91bd47c5357a2b15b1fb0e984f81687a3b8b53)]:
|
|
10
|
+
- @squide/firefly@16.2.2
|
|
11
|
+
- @squide/core@6.1.15
|
|
12
|
+
|
|
13
|
+
## 1.1.1
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#567](https://github.com/workleap/wl-squide/pull/567) [`5f16979`](https://github.com/workleap/wl-squide/commit/5f16979d9e922590fdca39be76e79dde54211efa) Thanks [@patricklafrance](https://github.com/patricklafrance)! - useDeferredRegistrations will now trigger a deferred registration update whenever the data object reference changes, even if no global data has been fetch or no feature flags changed.
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [[`5f16979`](https://github.com/workleap/wl-squide/commit/5f16979d9e922590fdca39be76e79dde54211efa)]:
|
|
20
|
+
- @squide/firefly@16.2.1
|
|
21
|
+
|
|
3
22
|
## 1.1.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
|
@@ -3,15 +3,10 @@ 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
|
|
|
6
|
-
;// CONCATENATED MODULE: external "@module-federation/enhanced/runtime"
|
|
7
6
|
|
|
8
|
-
;// CONCATENATED MODULE: external "@squide/core"
|
|
9
7
|
|
|
10
|
-
;// CONCATENATED MODULE: external "@squide/firefly/internal"
|
|
11
8
|
|
|
12
|
-
;// CONCATENATED MODULE: external "./RemoteModuleRegistry.js"
|
|
13
9
|
|
|
14
|
-
;// CONCATENATED MODULE: ./src/ModuleFederationPlugin.ts
|
|
15
10
|
|
|
16
11
|
|
|
17
12
|
|
|
@@ -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 { 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,CA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;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,4BAA4B;QACzD,iBAAiB;IACrB;IAEA,IAAI,CAACyB,QAAQ;QACT,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,0BAA0BA,GAAG,2BAA2B;AAE9D,MAAMC,sBAAsBA,SAASnB,MAAMA;IAC9C,YAAYoB,OAAuB,CAAE;QACjC,KAAK,CAACF,0BAA0BA,EAAEE;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,mBAAmB;gBACnBA,kBAAkB,QAAQ,CAAC,sCAAsCC;YACrE;YAEAP,+BAA+BxB,cAAcA,CAAC8B,mBAAmB,CAACX,SAASa;gBACvE,OAAOlC,SAASA,GAA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UAAUA,CAACyB,4CAA4C,QAAQ,EAAEO;YACrE;QACJ,GAAG;YACC,SAASN;QACb;QAEA,qDAAqD;QACrD,OAAO,CAACC;YACJD,qBAAqBC;QACzB;IACJ;AACJ;AAEO,SAASS,yBAAyBA,CAACtB,OAAgB;IACtD,MAAMuB,SAASvB,QAAQ,SAAS,CAACF,0BAA0BA,EAAE;QACzD,iBAAiB;IACrB;IAEA,IAAI,CAACyB,QAAQ;QACT,MAAM,IAAIC,MAAM;IACpB;IAEA,OAAOD;AACX"}
|
package/dist/RemoteDefinition.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RemoteDefinition.js","sources":["../src/RemoteDefinition.ts"],"sourcesContent":["export interface RemoteDefinition extends Record<string, unknown> {\n // The name of the remote module.\n name: string;\n}\n\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RemoteDefinition.js","sources":["../src/RemoteDefinition.ts"],"sourcesContent":["export interface RemoteDefinition extends Record<string, unknown> {\n // The name of the remote module.\n name: string;\n}\n\n"],"names":[],"mappings":"AAGC"}
|
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
import { ModuleRegistrationError, registerModule } from "@squide/core";
|
|
2
2
|
import { isFunction, isNil } from "@squide/core/internal";
|
|
3
|
-
|
|
4
|
-
var __webpack_require__ = {};
|
|
3
|
+
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
5
4
|
|
|
6
|
-
// webpack/runtime/has_own_property
|
|
7
|
-
(() => {
|
|
8
|
-
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
9
|
-
})();
|
|
10
5
|
|
|
11
|
-
;// CONCATENATED MODULE: external "@squide/core"
|
|
12
6
|
|
|
13
|
-
;// CONCATENATED MODULE: external "@squide/core/internal"
|
|
14
|
-
|
|
15
|
-
;// CONCATENATED MODULE: ./src/RemoteModuleRegistry.ts
|
|
16
7
|
|
|
17
8
|
|
|
18
9
|
const RemoteModuleRegistryId = "remote";
|
|
@@ -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 { 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 setAsReady() {\n if (this.#registrationStatus !== \"none\") {\n throw new Error(`[squide] Cannot set a module registry as \"ready\" when registrations are already in progress. The registry current status is \"${this.#registrationStatus}\".`);\n }\n\n this.#setRegistrationStatus(\"ready\");\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;IA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aAAa;QACT,IAAI,IAAI,CAAC,mBAAmB,KAAK,QAAQ;YACrC,MAAM,IAAIZ,MAAM,CAAC,6HAA6H,EAAE,IAAI,CAAC,mBAAmB,CAAC,EAAE,CAAC;QAChL;QAEA,IAAI,CAAC,sBAAsB,CAAC;IAChC;IAEA,sBAAsB,CAACa,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,0BAA0BjB,OAAyC;IAC/E,OAAOA,QACF,MAAM,CAAC,CAACM,IAA6BY,QAAQZ,IAC7C,GAAG,CAACA,CAAAA,IAAM;YACP,YAAYA;YACZ,YAAY5B;QAChB;AACR"}
|
|
1
|
+
{"version":3,"file":"RemoteModuleRegistry.js","sources":["../src/RemoteModuleRegistry.ts"],"sourcesContent":["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 setAsReady() {\n if (this.#registrationStatus !== \"none\") {\n throw new Error(`[squide] Cannot set a module registry as \"ready\" when registrations are already in progress. The registry current status is \"${this.#registrationStatus}\".`);\n }\n\n this.#setRegistrationStatus(\"ready\");\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":";;;;;;AAAyQ;AAC/M;AAInD,MAAMI,sBAAsBA,GAAG,SAAS;AAExC,MAAMC,qCAAqCA,GAAG,6CAA6C;AAC3F,MAAMC,uCAAuCA,GAAG,+CAA+C;AAC/F,MAAMC,mCAAmCA,GAAG,2CAA2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Z,YAAY5B,sBAAsBA;QACtC;AACR"}
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
import { initializeFirefly } from "./initializeFirefly.js";
|
|
2
|
-
import { ModuleFederationPluginName, getModuleFederationPlugin } from "./ModuleFederationPlugin.js";
|
|
3
|
-
import { RemoteModuleDeferredRegistrationFailedEvent, RemoteModuleDeferredRegistrationUpdateFailedEvent, RemoteModuleRegistrationFailedEvent, RemoteModuleRegistryId, RemoteModulesDeferredRegistrationCompletedEvent, RemoteModulesDeferredRegistrationStartedEvent, RemoteModulesDeferredRegistrationsUpdateCompletedEvent, RemoteModulesDeferredRegistrationsUpdateStartedEvent, RemoteModulesRegistrationCompletedEvent, RemoteModulesRegistrationStartedEvent } from "./RemoteModuleRegistry.js";
|
|
4
1
|
|
|
5
|
-
;// CONCATENATED MODULE: external "./initializeFirefly.js"
|
|
6
2
|
|
|
7
|
-
;// CONCATENATED MODULE: external "./ModuleFederationPlugin.js"
|
|
8
3
|
|
|
9
|
-
;// CONCATENATED MODULE: external "./RemoteModuleRegistry.js"
|
|
10
4
|
|
|
11
|
-
;// CONCATENATED MODULE: ./src/index.ts
|
|
12
5
|
|
|
13
6
|
|
|
14
7
|
|
|
15
|
-
|
|
16
|
-
export { ModuleFederationPluginName,
|
|
8
|
+
export { initializeFirefly } from "./initializeFirefly.js";
|
|
9
|
+
export { ModuleFederationPluginName, getModuleFederationPlugin } from "./ModuleFederationPlugin.js";
|
|
10
|
+
export { RemoteModuleDeferredRegistrationFailedEvent, RemoteModuleDeferredRegistrationUpdateFailedEvent, RemoteModuleRegistrationFailedEvent, RemoteModuleRegistryId, RemoteModulesDeferredRegistrationCompletedEvent, RemoteModulesDeferredRegistrationStartedEvent, RemoteModulesDeferredRegistrationsUpdateCompletedEvent, RemoteModulesDeferredRegistrationsUpdateStartedEvent, RemoteModulesRegistrationCompletedEvent, RemoteModulesRegistrationStartedEvent } from "./RemoteModuleRegistry.js";
|
|
17
11
|
|
|
18
12
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["export { initializeFirefly, type InitializeFireflyOptions } from \"./initializeFirefly.ts\";\nexport { getModuleFederationPlugin, ModuleFederationPluginName, type ModuleFederationPlugin } from \"./ModuleFederationPlugin.ts\";\nexport type { RemoteDefinition } from \"./RemoteDefinition.ts\";\nexport {\n RemoteModuleDeferredRegistrationFailedEvent,\n RemoteModuleDeferredRegistrationUpdateFailedEvent,\n RemoteModuleRegistrationFailedEvent,\n RemoteModuleRegistryId,\n RemoteModulesDeferredRegistrationCompletedEvent,\n RemoteModulesDeferredRegistrationStartedEvent,\n RemoteModulesDeferredRegistrationsUpdateCompletedEvent,\n RemoteModulesDeferredRegistrationsUpdateStartedEvent,\n RemoteModulesRegistrationCompletedEvent,\n RemoteModulesRegistrationStartedEvent,\n type RemoteModuleRegistrationError,\n type RemoteModulesDeferredRegistrationCompletedEventPayload,\n type RemoteModulesDeferredRegistrationStartedEventPayload,\n type RemoteModulesDeferredRegistrationsUpdateCompletedEventPayload,\n type RemoteModulesDeferredRegistrationsUpdateStartedEventPayload,\n type RemoteModulesRegistrationCompletedEventPayload,\n type RemoteModulesRegistrationStartedEventPayload\n} from \"./RemoteModuleRegistry.ts\";\n\n"],"names":["initializeFirefly","getModuleFederationPlugin","ModuleFederationPluginName","RemoteModuleDeferredRegistrationFailedEvent","RemoteModuleDeferredRegistrationUpdateFailedEvent","RemoteModuleRegistrationFailedEvent","RemoteModuleRegistryId","RemoteModulesDeferredRegistrationCompletedEvent","RemoteModulesDeferredRegistrationStartedEvent","RemoteModulesDeferredRegistrationsUpdateCompletedEvent","RemoteModulesDeferredRegistrationsUpdateStartedEvent","RemoteModulesRegistrationCompletedEvent","RemoteModulesRegistrationStartedEvent"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["export { initializeFirefly, type InitializeFireflyOptions } from \"./initializeFirefly.ts\";\nexport { getModuleFederationPlugin, ModuleFederationPluginName, type ModuleFederationPlugin } from \"./ModuleFederationPlugin.ts\";\nexport type { RemoteDefinition } from \"./RemoteDefinition.ts\";\nexport {\n RemoteModuleDeferredRegistrationFailedEvent,\n RemoteModuleDeferredRegistrationUpdateFailedEvent,\n RemoteModuleRegistrationFailedEvent,\n RemoteModuleRegistryId,\n RemoteModulesDeferredRegistrationCompletedEvent,\n RemoteModulesDeferredRegistrationStartedEvent,\n RemoteModulesDeferredRegistrationsUpdateCompletedEvent,\n RemoteModulesDeferredRegistrationsUpdateStartedEvent,\n RemoteModulesRegistrationCompletedEvent,\n RemoteModulesRegistrationStartedEvent,\n type RemoteModuleRegistrationError,\n type RemoteModulesDeferredRegistrationCompletedEventPayload,\n type RemoteModulesDeferredRegistrationStartedEventPayload,\n type RemoteModulesDeferredRegistrationsUpdateCompletedEventPayload,\n type RemoteModulesDeferredRegistrationsUpdateStartedEventPayload,\n type RemoteModulesRegistrationCompletedEventPayload,\n type RemoteModulesRegistrationStartedEventPayload\n} from \"./RemoteModuleRegistry.ts\";\n\n"],"names":["initializeFirefly","getModuleFederationPlugin","ModuleFederationPluginName","RemoteModuleDeferredRegistrationFailedEvent","RemoteModuleDeferredRegistrationUpdateFailedEvent","RemoteModuleRegistrationFailedEvent","RemoteModuleRegistryId","RemoteModulesDeferredRegistrationCompletedEvent","RemoteModulesDeferredRegistrationStartedEvent","RemoteModulesDeferredRegistrationsUpdateCompletedEvent","RemoteModulesDeferredRegistrationsUpdateStartedEvent","RemoteModulesRegistrationCompletedEvent","RemoteModulesRegistrationStartedEvent"],"mappings":";;;AAA0F;AACuC;AAoB9F"}
|
|
@@ -2,13 +2,9 @@ import { initializeFirefly } from "@squide/firefly";
|
|
|
2
2
|
import { ModuleFederationPlugin } from "./ModuleFederationPlugin.js";
|
|
3
3
|
import { toRemoteModuleDefinitions } from "./RemoteModuleRegistry.js";
|
|
4
4
|
|
|
5
|
-
;// CONCATENATED MODULE: external "@squide/firefly"
|
|
6
5
|
|
|
7
|
-
;// CONCATENATED MODULE: external "./ModuleFederationPlugin.js"
|
|
8
6
|
|
|
9
|
-
;// CONCATENATED MODULE: external "./RemoteModuleRegistry.js"
|
|
10
7
|
|
|
11
|
-
;// CONCATENATED MODULE: ./src/initializeFirefly.ts
|
|
12
8
|
|
|
13
9
|
|
|
14
10
|
|
|
@@ -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 | 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":"
|
|
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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// The require scope
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
|
|
4
|
+
// webpack/runtime/has_own_property
|
|
5
|
+
(() => {
|
|
6
|
+
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
7
|
+
})();
|
|
8
|
+
|
|
9
|
+
export { __webpack_require__ };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=rslib-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rslib-runtime.js","sources":["webpack/runtime/has_own_property"],"sourcesContent":["__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))"],"names":[],"mappings":";;;;;AAAA,wF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squide/firefly-module-federation",
|
|
3
3
|
"author": "Workleap",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.2",
|
|
5
5
|
"description": "Add support for Module Federation to Squide firefly.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -27,38 +27,39 @@
|
|
|
27
27
|
"CHANGELOG.md"
|
|
28
28
|
],
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@opentelemetry/api": "^1.9.
|
|
31
|
-
"@tanstack/react-query": "^5.
|
|
32
|
-
"msw": "^2.12.
|
|
30
|
+
"@opentelemetry/api": "^1.9.1",
|
|
31
|
+
"@tanstack/react-query": "^5.96.0",
|
|
32
|
+
"msw": "^2.12.14",
|
|
33
33
|
"react": "^18.0.0 || ^19.0.0",
|
|
34
34
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
35
|
-
"react-router": "^7.13.
|
|
35
|
+
"react-router": "^7.13.2"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@module-federation/enhanced": "0.11.4",
|
|
39
|
-
"@rspack/core": "^1.7.
|
|
40
|
-
"@workleap/logging": "^1.3.
|
|
41
|
-
"@squide/core": "^6.1.
|
|
42
|
-
"@squide/firefly": "^16.2.
|
|
39
|
+
"@rspack/core": "^1.7.11",
|
|
40
|
+
"@workleap/logging": "^1.3.7",
|
|
41
|
+
"@squide/core": "^6.1.15",
|
|
42
|
+
"@squide/firefly": "^16.2.2"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@eslint/js": "9.39.2",
|
|
46
|
-
"@rsbuild/core": "1.7.
|
|
47
|
-
"@rslib/core": "0.
|
|
46
|
+
"@rsbuild/core": "1.7.5",
|
|
47
|
+
"@rslib/core": "0.20.2",
|
|
48
48
|
"@testing-library/react": "16.3.2",
|
|
49
|
+
"@types/node": "25.5.0",
|
|
49
50
|
"@types/react": "19.2.14",
|
|
50
51
|
"@types/react-dom": "19.2.3",
|
|
51
|
-
"@typescript-eslint/parser": "8.
|
|
52
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
53
|
-
"@vitejs/plugin-react": "
|
|
54
|
-
"@workleap/eslint-configs": "
|
|
55
|
-
"@workleap/rslib-configs": "1.1.
|
|
56
|
-
"@workleap/typescript-configs": "
|
|
52
|
+
"@typescript-eslint/parser": "8.58.0",
|
|
53
|
+
"@typescript/native-preview": "7.0.0-dev.20260331.1",
|
|
54
|
+
"@vitejs/plugin-react": "6.0.1",
|
|
55
|
+
"@workleap/eslint-configs": "2.0.1",
|
|
56
|
+
"@workleap/rslib-configs": "1.1.11",
|
|
57
|
+
"@workleap/typescript-configs": "4.0.0",
|
|
57
58
|
"eslint": "9.39.2",
|
|
58
|
-
"happy-dom": "20.8.
|
|
59
|
-
"typescript": "
|
|
59
|
+
"happy-dom": "20.8.9",
|
|
60
|
+
"typescript": "6.0.2",
|
|
60
61
|
"typescript-eslint": "8.54.0",
|
|
61
|
-
"vitest": "4.
|
|
62
|
+
"vitest": "4.1.2"
|
|
62
63
|
},
|
|
63
64
|
"sideEffects": false,
|
|
64
65
|
"scripts": {
|