From daaa1b203a86265c82e669e70352e1bcf6b16694 Mon Sep 17 00:00:00 2001 From: patricklafrance Date: Thu, 19 Oct 2023 16:17:43 -0400 Subject: [PATCH] v2 release --- .changeset/config.json | 2 +- .changeset/healthy-cobras-sell.md | 6 +++ .changeset/kind-papayas-walk.md | 30 +++++++++++ .changeset/loud-ways-laugh.md | 19 +++++++ .changeset/stale-birds-attend.md | 90 +++++++++++++++++++++++++++++++ 5 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 .changeset/healthy-cobras-sell.md create mode 100644 .changeset/kind-papayas-walk.md create mode 100644 .changeset/loud-ways-laugh.md create mode 100644 .changeset/stale-birds-attend.md diff --git a/.changeset/config.json b/.changeset/config.json index 2326f5f69..4f6b64b7b 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -10,5 +10,5 @@ "access": "restricted", "baseBranch": "main", "updateInternalDependencies": "patch", - "ignore": ["@sample/*"] + "ignore": ["@basic/*", "@endpoints/*"] } diff --git a/.changeset/healthy-cobras-sell.md b/.changeset/healthy-cobras-sell.md new file mode 100644 index 000000000..4157d78b5 --- /dev/null +++ b/.changeset/healthy-cobras-sell.md @@ -0,0 +1,6 @@ +--- +"@squide/webpack-module-federation": major +--- + +- The devserver error overlay is now disabled by default for the remote modules to prevent them from stacking on top of the host application error overlay. +- Remote modules `register` functions can now be `async`. diff --git a/.changeset/kind-papayas-walk.md b/.changeset/kind-papayas-walk.md new file mode 100644 index 000000000..3bcd87da4 --- /dev/null +++ b/.changeset/kind-papayas-walk.md @@ -0,0 +1,30 @@ +--- +"@squide/msw": major +--- + +This is a new package to help with [Mock Service Worker](https://mswjs.io/) in a federated application. + +It helps to register their request handlers: + +**In module:** + +```ts +const mswPlugin = getMswPlugin(runtime); +mswPlugin.registerRequestHandlers(requestHandlers); +``` + +**In the host app:** + +```ts +import("../mocks/browser.ts").then(({ startMsw }) => { + startMsw(mswPlugin.requestHandlers); + + setMswAsStarted(); +}); +``` + +And offer an utility to wait for MSW to be started before rendering the app: + +```ts +const isMswStarted = useIsMswStarted(process.env.USE_MSW); +``` diff --git a/.changeset/loud-ways-laugh.md b/.changeset/loud-ways-laugh.md new file mode 100644 index 000000000..42d7f9a99 --- /dev/null +++ b/.changeset/loud-ways-laugh.md @@ -0,0 +1,19 @@ +--- +"@squide/core": major +--- + +### Addition + +- Added support for plugins to Squide runtime. +- Added a `parentName` option to `registerRoute`. + +### Updated + +- The `layoutPath` option of `registerRoute` has been renamed to `parentPath`. +- `registerNavigationItems` has been renamed to `registerNavigationItem` and now only accepts a single item by call. +- A navigation item `label`, `additionalProps` and `priority` fields has been renamed to `$label`, `$additionalProps` and `$priority`. This is part of an effort to ensure no future release of [React Router](https://reactrouter.com/en/main) introduced new properties with names that are conflicting with Squide. +- Local modules `register` function can now be `async`. This is useful if you want for example to conditionally to a dynamic `import` to load a dependency such as [msw](https://www.npmjs.com/package/msw). + +### Removed + +- Removed the Service features at it was confusing and not that helpful. We recommend using React context instead to share services with the modules. diff --git a/.changeset/stale-birds-attend.md b/.changeset/stale-birds-attend.md new file mode 100644 index 000000000..b73444039 --- /dev/null +++ b/.changeset/stale-birds-attend.md @@ -0,0 +1,90 @@ +--- +"@squide/react-router": major +--- + +### Addition + +- Added the `$visibility` field to the `Route` type. This new field indicates that the route doesn't depend on the initial global data (authenticated data) and can be rendered before that data is loaded. The accepted values are `public` and `protected`. By default, every route is `protected`. +- Added the `$name` field to the `Route` type. This new field allow a nested route to be named so other routes can be configured to be nested under this route with the `parentName` option. +- Added a `ManagedRoutes` placeholder, allowing the application to indicates where managed routes should be rendered. A managed route is a route that is neither hoisted or nested with a `parentPath` or `parentName` option. +- Added the `useRouteMatch` and `useIsRouteMatchProtected` hooks. + +### Updated + +- `registerRoutes` has been renamed to `registerRoute` and now only accepts a single route by call. +- Moved the `hoist` option from the route definition to an option of `registerRoute`. + +Before: + +```tsx +registerRoute({ + hoist: true, + path: "/foo", + element:
Foo
+}); +``` + +After: + +```tsx +registerRoute({ + path: "/foo", + element:
Foo
+}, { + hoist: true, +}); +``` + +- Route indexes are now created for nested routes registered in a single block. Given the following registration block: + +```tsx +runtime.registerRoutes([ + { + path: "/root", + element:
Hello
, + children: [ + { + path: "/root/another-level", + element:
You!
, + children: [ + { + path: "/root/another-level/deeply-nested-route", + element:
Hello from nested!
+ } + ] + } + ] + } +]); +``` + +Before the changes, only an index for the `"/root"` route would have been created. This means that consumers could add nested routes under `"/root"` route with the `parentPath` option but couldn't nest routes under the `"/root/another-level"` and `"/root/another-level/deeply-nested-route"` with the `parentPath` option because there was no indexes for these routes. + +Now the following is possible: + +```tsx +runtime.registerRoutes( + [ + { + path: "/foo", + element:
Hello
+ } + ], + { parentPath: "/root/another-level" } +); + +runtime.registerRoutes( + [ + { + path: "/foo", + element:
Hello
+ } + ], + { parentPath: "/root/another-level/deeply-nested-route" } +); +``` + +### Removed + +- The `RootRoute` has been removed, there's now only a single `Route` type. +- The `useHoistedRoutes` has been removed. Hoisting is now supported by default with the `hoist` option of the `registerRoute` function and the `ManagedRoutes` placeholder.