-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Add client middleware to split route modules #13210
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
Conversation
🦋 Changeset detectedLatest commit: e878b8d The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@@ -1074,7 +1253,7 @@ test.describe("Middleware", () => { | |||
await page.waitForSelector("[data-child]"); | |||
|
|||
// 2 separate server requests made | |||
expect(requests).toEqual([ | |||
expect(requests.sort()).toEqual([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test was flaky in Firefox due to the order of requests not being deterministic.
expect.stringMatching( | ||
/\/parent\/child\.data\?_routes=routes%2Fparent\.child\._index$/ | ||
), | ||
expect(requests.sort()).toEqual([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Gave it a run in the playground locally and everything looked good
let clientMiddlewareModule = await import( | ||
/* @vite-ignore */ | ||
/* webpackIgnore: true */ | ||
route.clientMiddlewareModule || route.module |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯 This is really clever - it took me a sec to figure out how it was working without the route chunks since we weren't waiting on the route module promise in dataStrategy
anymore
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
When
future.unstable_splitRouteModules
is enabled, theunstable_clientMiddleware
route export is now split into its own chunk so it can be downloaded and executed ASAP.For this to work, we've had to introduce a new
route.unstable_lazyMiddleware
property inreact-router
and ignore middleware defined in the return value fromroute.lazy
. This allows us to know ahead of time whether we need to wait for the middleware, whereas withroute.lazy
we'd have no idea if there's middleware or not until after it's resolved.