@squide/firefly-module-federation 1.0.9 → 1.0.11
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
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @squide/firefly-module-federation
|
|
2
2
|
|
|
3
|
+
## 1.0.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#392](https://github.com/workleap/wl-squide/pull/392) [`4001ae7`](https://github.com/workleap/wl-squide/commit/4001ae75f7aea8ee124ce831f69a1f55a342cef5) Thanks [@patricklafrance](https://github.com/patricklafrance)! - `initializeFireflyForStorybook` now accept a `useMsw` option to opt-out of MSW and will now render as expected if no local modules are provided.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`4001ae7`](https://github.com/workleap/wl-squide/commit/4001ae75f7aea8ee124ce831f69a1f55a342cef5)]:
|
|
10
|
+
- @squide/firefly@16.1.7
|
|
11
|
+
- @squide/core@6.1.12
|
|
12
|
+
|
|
13
|
+
## 1.0.10
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#373](https://github.com/workleap/wl-squide/pull/373) [`f9138cc`](https://github.com/workleap/wl-squide/commit/f9138cc4bd0a1d175ad4bd7e695d1edd7fbe4c1c) Thanks [@alexasselin008](https://github.com/alexasselin008)! - Bumped dependencies
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [[`f9138cc`](https://github.com/workleap/wl-squide/commit/f9138cc4bd0a1d175ad4bd7e695d1edd7fbe4c1c)]:
|
|
20
|
+
- @squide/firefly@16.1.6
|
|
21
|
+
- @squide/core@6.1.11
|
|
22
|
+
|
|
3
23
|
## 1.0.9
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -44,6 +44,7 @@ export declare class RemoteModuleRegistry implements ModuleRegistry {
|
|
|
44
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
|
+
setAsReady(): void;
|
|
47
48
|
get registrationStatus(): ModuleRegistrationStatus;
|
|
48
49
|
}
|
|
49
50
|
export declare function toRemoteModuleDefinitions(remotes: (RemoteDefinition | undefined)[]): ModuleDefinition[];
|
|
@@ -250,6 +250,12 @@ class RemoteModuleRegistry {
|
|
|
250
250
|
removeStatusChangedListener(callback) {
|
|
251
251
|
this.#statusChangedListeners.delete(callback);
|
|
252
252
|
}
|
|
253
|
+
setAsReady() {
|
|
254
|
+
if (this.#registrationStatus !== "none") {
|
|
255
|
+
throw new Error(`[squide] Cannot set a module registry as "ready" when registrations are already in progress. The registry current status is "${this.#registrationStatus}".`);
|
|
256
|
+
}
|
|
257
|
+
this.#setRegistrationStatus("ready");
|
|
258
|
+
}
|
|
253
259
|
#setRegistrationStatus(status) {
|
|
254
260
|
this.#registrationStatus = status;
|
|
255
261
|
this.#statusChangedListeners.forEach((x)=>{
|
|
@@ -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 #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;AA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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;gBACXP,QAAQ,QAAQ,CAAC,QAAQ,CAACZ,mDAAmDmB;YACjF;QACJ;QAEAP,QAAQ,QAAQ,CAAC,QAAQ,CAACb,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,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":["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;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;IAC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B,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"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squide/firefly-module-federation",
|
|
3
3
|
"author": "Workleap",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.11",
|
|
5
5
|
"description": "Add support for Module Federation to Squide firefly.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -28,42 +28,43 @@
|
|
|
28
28
|
],
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@opentelemetry/api": "^1.9.0",
|
|
31
|
-
"@tanstack/react-query": "^5.90.
|
|
31
|
+
"@tanstack/react-query": "^5.90.20",
|
|
32
32
|
"msw": "^2.12.7",
|
|
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.13.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@module-federation/enhanced": "0.11.4",
|
|
39
|
-
"@rspack/core": "^1.7.
|
|
39
|
+
"@rspack/core": "^1.7.4",
|
|
40
40
|
"@workleap/logging": "^1.3.4",
|
|
41
|
-
"@squide/
|
|
42
|
-
"@squide/
|
|
41
|
+
"@squide/core": "6.1.12",
|
|
42
|
+
"@squide/firefly": "16.1.7"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@eslint/js": "9.39.2",
|
|
46
46
|
"@rsbuild/core": "1.7.2",
|
|
47
|
-
"@rslib/core": "0.19.
|
|
48
|
-
"@testing-library/react": "16.3.
|
|
49
|
-
"@types/react": "19.2.
|
|
47
|
+
"@rslib/core": "0.19.3",
|
|
48
|
+
"@testing-library/react": "16.3.2",
|
|
49
|
+
"@types/react": "19.2.10",
|
|
50
50
|
"@types/react-dom": "19.2.3",
|
|
51
|
-
"@typescript-eslint/parser": "8.
|
|
51
|
+
"@typescript-eslint/parser": "8.54.0",
|
|
52
|
+
"@typescript/native-preview": "7.0.0-dev.20260128.1",
|
|
52
53
|
"@vitejs/plugin-react": "5.1.2",
|
|
53
|
-
"@workleap/eslint-configs": "1.1.
|
|
54
|
-
"@workleap/rslib-configs": "1.1.
|
|
54
|
+
"@workleap/eslint-configs": "1.1.11",
|
|
55
|
+
"@workleap/rslib-configs": "1.1.6",
|
|
55
56
|
"@workleap/typescript-configs": "3.0.7",
|
|
56
57
|
"eslint": "9.39.2",
|
|
57
|
-
"happy-dom": "20.3.
|
|
58
|
+
"happy-dom": "20.3.9",
|
|
58
59
|
"typescript": "5.9.3",
|
|
59
|
-
"typescript-eslint": "8.
|
|
60
|
-
"vitest": "4.0.
|
|
60
|
+
"typescript-eslint": "8.54.0",
|
|
61
|
+
"vitest": "4.0.18"
|
|
61
62
|
},
|
|
62
63
|
"sideEffects": false,
|
|
63
64
|
"scripts": {
|
|
64
65
|
"build": "rslib build --config ./rslib.build.ts",
|
|
65
66
|
"eslint": "eslint . --max-warnings=0 --cache --cache-location node_modules/.cache/eslint",
|
|
66
|
-
"typecheck": "
|
|
67
|
+
"typecheck": "tsgo",
|
|
67
68
|
"test": "vitest --config vitest.config.ts --no-watch"
|
|
68
69
|
}
|
|
69
70
|
}
|
|
@@ -377,6 +377,14 @@ export class RemoteModuleRegistry implements ModuleRegistry {
|
|
|
377
377
|
this.#statusChangedListeners.delete(callback);
|
|
378
378
|
}
|
|
379
379
|
|
|
380
|
+
setAsReady() {
|
|
381
|
+
if (this.#registrationStatus !== "none") {
|
|
382
|
+
throw new Error(`[squide] Cannot set a module registry as "ready" when registrations are already in progress. The registry current status is "${this.#registrationStatus}".`);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
this.#setRegistrationStatus("ready");
|
|
386
|
+
}
|
|
387
|
+
|
|
380
388
|
#setRegistrationStatus(status: ModuleRegistrationStatus) {
|
|
381
389
|
this.#registrationStatus = status;
|
|
382
390
|
|