-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Split Route Modules #11871
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
Split Route Modules #11871
Conversation
🦋 Changeset detectedLatest commit: d545369 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 |
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.
Awesome work! I did some light testing in my own playground app and everything looked good. All the router related code look 👌 too
let chunkImportsSnippet = chunks | ||
.map((chunk) => `import * as ${chunk.varName} from "${chunk.module}";`) | ||
.join("\n"); | ||
|
||
let mergedChunksSnippet = `const ${routeVarName} = {${chunks | ||
.map((chunk) => `...${chunk.varName}`) | ||
.join(",")}};`; | ||
|
||
return [chunkImportsSnippet, mergedChunksSnippet].join("\n"); |
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.
👌
} else if (route.clientLoaderModule) { | ||
dataRoute.loader = async ( | ||
args: LoaderFunctionArgs, | ||
singleFetch?: unknown | ||
) => { | ||
invariant(route.clientLoaderModule); | ||
let { clientLoader } = await import( | ||
/* @vite-ignore */ | ||
/* webpackIgnore: true */ | ||
route.clientLoaderModule | ||
); | ||
return clientLoader({ | ||
...args, | ||
async serverLoader() { | ||
preventInvalidServerHandlerCall("loader", route, isSpaMode); | ||
return fetchServerLoader(singleFetch); | ||
}, | ||
}); | ||
}; |
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.
I love how simple this is at the route creation level
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
Proposal: #11571
For more information, documentation is included in this PR.
If you want to try this out, install
0.0.0-experimental-df0f1dfda
and setfuture.unstable_splitRouteModules
totrue
.