-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: Add support for MSW and Global data fetching #92
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
code-person
reviewed
Oct 18, 2023
Co-authored-by: Alexandre Asselin <[email protected]>
alexasselin008
previously approved these changes
Oct 19, 2023
alexasselin008
previously approved these changes
Oct 19, 2023
alexasselin008
approved these changes
Oct 19, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a huge PR, sorry about that. The goal of this PR is to improve Squide to better support MSW fake API endpoints, the fetching of the initial global data (Session, Subscription etc..), while offering a great UX for the user by preventing showing multiple flickering loading screens.
This has been achieved by rewriting the hoisting feature, adding a new
useIsRouteMatchProtected
hook, adding support for plugins, introducing a new package/plugin to support MSW called@squide/msw
and reworking the shell package of the samples.To demonstrate how it's done a new sample as been introduced:
/samples/endpoint
. An hosted version is available here.What changed
@squide/core
Addition
parentName
option toregisterRoute
.Updated
layoutPath
option ofregisterRoute
has been renamed toparentPath
.registerNavigationItems
has been renamed toregisterNavigationItem
and now only accepts a single item by call.label
,additionalProps
andpriority
fields has been renamed to$label
,$additionalProps
and$priority
. This is part of an effort to ensure no future release of React Router introduced new properties with names that are conflicting with Squide.register
function can now beasync
. This is useful if you want for example to conditionally to a dynamicimport
to load a dependency such as msw.Removed
@squide/react-router
Addition
$visibility
field to theRoute
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 arepublic
andprotected
. By default, every route isprotected
.$name
field to theRoute
type. This new field allow a nested route to be named so other routes can be configured to be nested under this route with theparentName
option.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 aparentPath
orparentName
option.useRouteMatch
anduseIsRouteMatchProtected
hooks.Updated
registerRoutes
has been renamed toregisterRoute
and now only accepts a single route by call.hoist
option from the route definition to an option ofregisterRoute
.Before:
After:
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 theparentPath
option but couldn't nest routes under the"/root/another-level"
and"/root/another-level/deeply-nested-route"
with theparentPath
option because there was no indexes for these routes.Now the following is possible:
Removed
RootRoute
has been removed, there's now only a singleRoute
type.useHoistedRoutes
has been removed. Hoisting is now supported by default with thehoist
option of theregisterRoute
function and theManagedRoutes
placeholder.@squide/webpack-module-federation
register
functions can now beasync
.@squide/msw
That's a new package to help with MSW in a federated application.
It helps to register their request handlers:
In module:
In the host app:
And offer an utility to wait for MSW to be started before rendering the app:
What's next?