@squide/firefly 7.0.0 → 8.0.0

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,126 @@
1
1
  # @squide/firefly
2
2
 
3
+ ## 8.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#168](https://github.com/gsoft-inc/wl-squide/pull/168) [`89ace29`](https://github.com/gsoft-inc/wl-squide/commit/89ace29b9aeadbbe83cfa71dd137b9f1a115c283) Thanks [@patricklafrance](https://github.com/patricklafrance)! - This release Migrates Squide from Webpack Module Federation to [Module Federation 2.0](https://module-federation.io/guide/start/quick-start.html).
8
+
9
+ This release deprecates the following packages:
10
+
11
+ - `@squide/webpack-module-federation`, use `@squide/module-federation` instead.
12
+ - `@squide/firefly-configs`, use `@squide/firefly-webpack-configs` instead.
13
+
14
+ And introduce a few changes to existing API:
15
+
16
+ - The `FireflyRuntime` nows accept a `useMsw` option and expose a new `isMswEnabled` getter:
17
+
18
+ ```ts
19
+ // bootstrap.tsx
20
+
21
+ import { FireflyRuntime } from "@squide/firefly";
22
+
23
+ const runtime = new FireflyRuntime({
24
+ useMsw: true,
25
+ });
26
+
27
+ // Use the runtime to determine if MSW handlers should be registered.
28
+ if (runtime.isMswEnabled) {
29
+ // ...
30
+ }
31
+ ```
32
+
33
+ - The `registerRemoteModules` function doesn't accept the remotes URL anymore. The remotes URL should be configured in the webpack configuration files.
34
+
35
+ Previously:
36
+
37
+ ```ts
38
+ // bootstrap.tsx
39
+
40
+ import {
41
+ registerRemoteModules,
42
+ type RemoteDefinition,
43
+ } from "@squide/firefly";
44
+
45
+ const Remotes: RemoteDefinition = [
46
+ {
47
+ name: "remote1",
48
+ url: "http://localhost:8081",
49
+ },
50
+ ];
51
+
52
+ await registerRemoteModules(Remotes, runtime);
53
+ ```
54
+
55
+ ```js
56
+ // webpack.dev.js
57
+
58
+ import { defineDevHostConfig } from "@squide/firefly-webpack-configs";
59
+ import { swcConfig } from "./swc.dev.js";
60
+
61
+ export default defineDevHostConfig(swcConfig, "host", 8080, {
62
+ overlay: false,
63
+ });
64
+ ```
65
+
66
+ Now:
67
+
68
+ ```ts
69
+ // bootstrap.tsx
70
+
71
+ import {
72
+ registerRemoteModules,
73
+ type RemoteDefinition,
74
+ } from "@squide/firefly";
75
+
76
+ const Remotes: RemoteDefinition = [
77
+ {
78
+ name: "remote1",
79
+ },
80
+ ];
81
+
82
+ await registerRemoteModules(Remotes, runtime);
83
+ ```
84
+
85
+ ```js
86
+ // webpack.dev.js
87
+
88
+ import { defineDevHostConfig } from "@squide/firefly-webpack-configs";
89
+ import { swcConfig } from "./swc.dev.js";
90
+
91
+ /**
92
+ * @typedef {import("@squide/firefly-webpack-configs").RemoteDefinition}[]
93
+ */
94
+ export const Remotes = [
95
+ {
96
+ name: "remote1",
97
+ url: "http://localhost:8081",
98
+ },
99
+ ];
100
+
101
+ export default defineDevHostConfig(swcConfig, "host", 8080, Remotes, {
102
+ overlay: false,
103
+ });
104
+ ```
105
+
106
+ To migrate:
107
+
108
+ 1. Replace the `@squide/webpack-module-federation` dependency by `@squide/module-federation`.
109
+
110
+ 2. Replace the `@squide/firefly-configs` dependency by `@squide/firefly-webpack-configs`.
111
+
112
+ 3. Move the remotes URL from the `bootstrap.tsx` file to the `webpack.*.js` files.
113
+
114
+ 4. Integrate the new `useMsw` and `isMswEnabled` props.
115
+
116
+ ### Patch Changes
117
+
118
+ - Updated dependencies [[`89ace29`](https://github.com/gsoft-inc/wl-squide/commit/89ace29b9aeadbbe83cfa71dd137b9f1a115c283)]:
119
+ - @squide/module-federation@5.0.0
120
+ - @squide/react-router@5.0.0
121
+ - @squide/core@4.0.0
122
+ - @squide/msw@2.0.14
123
+
3
124
  ## 7.0.0
4
125
 
5
126
  ### Major Changes
package/dist/AppRouter.js CHANGED
@@ -1 +1 @@
1
- export { AppRouter, BootstrappingRoute } from './chunk-YPB7BNRJ.js';
1
+ export { AppRouter, BootstrappingRoute } from './chunk-URNAUMUG.js';
@@ -1,7 +1,7 @@
1
1
  import { useLogOnceLogger, isNil } from '@squide/core';
2
+ import { useAreModulesRegistered, useAreModulesReady } from '@squide/module-federation';
2
3
  import { useIsMswStarted } from '@squide/msw';
3
4
  import { useRouteMatch, useIsRouteProtected, useRoutes, findRouteByPath } from '@squide/react-router';
4
- import { useAreModulesRegistered, useAreModulesReady } from '@squide/webpack-module-federation';
5
5
  import { useEffect, useCallback, cloneElement, useMemo } from 'react';
6
6
  import { ErrorBoundary, useErrorBoundary } from 'react-error-boundary';
7
7
  import { useLocation, Outlet } from 'react-router-dom';
@@ -0,0 +1,45 @@
1
+ import { MswPlugin } from '@squide/msw';
2
+ import { ReactRouterRuntime } from '@squide/react-router';
3
+
4
+ // src/fireflyRuntime.tsx
5
+ var FireflyRuntime = class extends ReactRouterRuntime {
6
+ #mswPlugin;
7
+ #useMsw;
8
+ constructor({ plugins, useMsw, ...options } = {}) {
9
+ if (useMsw) {
10
+ const mswPlugin = new MswPlugin();
11
+ super({
12
+ plugins: [
13
+ ...plugins ?? [],
14
+ mswPlugin
15
+ ],
16
+ ...options
17
+ });
18
+ this.#mswPlugin = mswPlugin;
19
+ this.#useMsw = true;
20
+ } else {
21
+ super({
22
+ plugins,
23
+ ...options
24
+ });
25
+ this.#useMsw = false;
26
+ }
27
+ }
28
+ registerRequestHandlers(handlers) {
29
+ if (!this.#mswPlugin) {
30
+ throw new Error(`[squide] Cannot register the provided MSW request handlers because the runtime hasn't been initialized with MSW. Did you instanciate the FireflyRuntime with the "useMsw" option?`);
31
+ }
32
+ this.#mswPlugin.registerRequestHandlers(handlers);
33
+ }
34
+ get requestHandlers() {
35
+ if (!this.#mswPlugin) {
36
+ throw new Error(`[squide] Cannot retrieve MSW request handlers because the runtime hasn't been initialized with MSW. Did you instanciate the FireflyRuntime with the "useMsw" option?`);
37
+ }
38
+ return this.#mswPlugin.requestHandlers;
39
+ }
40
+ get isMswEnabled() {
41
+ return this.#useMsw;
42
+ }
43
+ };
44
+
45
+ export { FireflyRuntime };
@@ -2,12 +2,15 @@ import { RuntimeOptions } from '@squide/core';
2
2
  import { ReactRouterRuntime } from '@squide/react-router';
3
3
  import { RequestHandler } from 'msw';
4
4
 
5
- type FireflyRuntimeOptions = RuntimeOptions;
5
+ interface FireflyRuntimeOptions extends RuntimeOptions {
6
+ useMsw?: boolean;
7
+ }
6
8
  declare class FireflyRuntime extends ReactRouterRuntime {
7
9
  #private;
8
- constructor({ plugins, ...options }?: FireflyRuntimeOptions);
10
+ constructor({ plugins, useMsw, ...options }?: FireflyRuntimeOptions);
9
11
  registerRequestHandlers(handlers: RequestHandler[]): void;
10
12
  get requestHandlers(): RequestHandler[];
13
+ get isMswEnabled(): boolean;
11
14
  }
12
15
 
13
16
  export { FireflyRuntime, type FireflyRuntimeOptions };
@@ -1 +1 @@
1
- export { FireflyRuntime } from './chunk-JRNDLQBI.js';
1
+ export { FireflyRuntime } from './chunk-YXMNS6U3.js';
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export * from '@squide/core';
2
+ export * from '@squide/module-federation';
2
3
  export * from '@squide/msw';
3
4
  export * from '@squide/react-router';
4
- export * from '@squide/webpack-module-federation';
5
5
  export { AppRouter, AppRouterProps, BootstrappingRoute, OnCompleteRegistrationsFunction, OnLoadProtectedDataFunction, OnLoadPublicDataFunction, RenderRouterProviderFunction } from './AppRouter.js';
6
6
  export { FireflyRuntime, FireflyRuntimeOptions } from './fireflyRuntime.js';
7
7
  import 'react';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- export { AppRouter, BootstrappingRoute } from './chunk-YPB7BNRJ.js';
2
- export { FireflyRuntime } from './chunk-JRNDLQBI.js';
1
+ export { AppRouter, BootstrappingRoute } from './chunk-URNAUMUG.js';
2
+ export { FireflyRuntime } from './chunk-YXMNS6U3.js';
3
3
  export * from '@squide/core';
4
+ export * from '@squide/module-federation';
4
5
  export * from '@squide/msw';
5
6
  export * from '@squide/react-router';
6
- export * from '@squide/webpack-module-federation';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@squide/firefly",
3
3
  "author": "Workleap",
4
- "version": "7.0.0",
4
+ "version": "8.0.0",
5
5
  "description": "Helpers to facilitate the creation of a shell package with Squide firefly technology stack.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -16,8 +16,8 @@
16
16
  "type": "module",
17
17
  "exports": {
18
18
  ".": {
19
- "import": "./dist/index.js",
20
19
  "types": "./dist/index.d.ts",
20
+ "import": "./dist/index.js",
21
21
  "default": "./dist/index.js"
22
22
  }
23
23
  },
@@ -34,33 +34,34 @@
34
34
  "react-router-dom": "*"
35
35
  },
36
36
  "devDependencies": {
37
- "@swc/core": "1.4.7",
37
+ "@swc/core": "1.4.17",
38
38
  "@swc/jest": "0.2.36",
39
39
  "@testing-library/jest-dom": "6.4.2",
40
- "@testing-library/react": "14.2.1",
40
+ "@testing-library/react": "15.0.5",
41
41
  "@types/jest": "29.5.12",
42
- "@types/react": "18.2.65",
43
- "@types/react-dom": "18.2.22",
44
- "@workleap/eslint-plugin": "3.1.0",
42
+ "@types/react": "18.3.1",
43
+ "@types/react-dom": "18.3.0",
44
+ "@workleap/eslint-plugin": "3.2.2",
45
45
  "@workleap/swc-configs": "2.2.3",
46
- "@workleap/tsup-configs": "3.0.4",
46
+ "@workleap/tsup-configs": "3.0.6",
47
47
  "@workleap/typescript-configs": "3.0.2",
48
+ "eslint": "8.57.0",
48
49
  "jest": "29.7.0",
49
50
  "jest-environment-jsdom": "29.7.0",
50
- "msw": "2.2.3",
51
- "react": "18.2.0",
52
- "react-dom": "18.2.0",
51
+ "msw": "2.2.14",
52
+ "react": "18.3.1",
53
+ "react-dom": "18.3.1",
53
54
  "react-error-boundary": "4.0.13",
54
- "react-router-dom": "6.22.3",
55
+ "react-router-dom": "6.23.0",
55
56
  "ts-jest": "29.1.2",
56
57
  "tsup": "8.0.2",
57
- "typescript": "5.4.2"
58
+ "typescript": "5.4.5"
58
59
  },
59
60
  "dependencies": {
60
- "@squide/core": "3.4.0",
61
- "@squide/msw": "2.0.13",
62
- "@squide/react-router": "4.1.3",
63
- "@squide/webpack-module-federation": "4.0.0"
61
+ "@squide/core": "4.0.0",
62
+ "@squide/module-federation": "5.0.0",
63
+ "@squide/msw": "2.0.14",
64
+ "@squide/react-router": "5.0.0"
64
65
  },
65
66
  "sideEffects": false,
66
67
  "engines": {
@@ -1,26 +0,0 @@
1
- import { MswPlugin } from '@squide/msw';
2
- import { ReactRouterRuntime } from '@squide/react-router';
3
-
4
- // src/fireflyRuntime.tsx
5
- var FireflyRuntime = class extends ReactRouterRuntime {
6
- #mswPlugin;
7
- constructor({ plugins, ...options } = {}) {
8
- const mswPlugin = new MswPlugin();
9
- super({
10
- plugins: [
11
- ...plugins ?? [],
12
- mswPlugin
13
- ],
14
- ...options
15
- });
16
- this.#mswPlugin = mswPlugin;
17
- }
18
- registerRequestHandlers(handlers) {
19
- this.#mswPlugin.registerRequestHandlers(handlers);
20
- }
21
- get requestHandlers() {
22
- return this.#mswPlugin.requestHandlers;
23
- }
24
- };
25
-
26
- export { FireflyRuntime };