Skip to content

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

Merged
merged 77 commits into from
Jan 30, 2025
Merged

Split Route Modules #11871

merged 77 commits into from
Jan 30, 2025

Conversation

markdalgleish
Copy link
Member

@markdalgleish markdalgleish commented Aug 5, 2024

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 set future.unstable_splitRouteModules to true.

Copy link

changeset-bot bot commented Aug 5, 2024

🦋 Changeset detected

Latest commit: d545369

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@react-router/dev Patch
react-router Patch
@react-router/fs-routes Patch
@react-router/remix-routes-option-adapter Patch
@react-router/architect Patch
@react-router/cloudflare Patch
react-router-dom Patch
@react-router/express Patch
@react-router/node Patch
@react-router/serve Patch
create-react-router Patch

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

@markdalgleish markdalgleish changed the title WIP: Route Module Chunks WIP: Split Route Modules Jan 16, 2025
@markdalgleish markdalgleish marked this pull request as ready for review January 21, 2025 20:59
@markdalgleish markdalgleish changed the title WIP: Split Route Modules Split Route Modules Jan 21, 2025
Copy link
Contributor

@brophdawg11 brophdawg11 left a 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

Comment on lines +722 to +730
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");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

Comment on lines +430 to +448
} 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);
},
});
};
Copy link
Contributor

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

@markdalgleish markdalgleish merged commit bfc2de7 into dev Jan 30, 2025
8 checks passed
@markdalgleish markdalgleish deleted the markdalgleish/route-chunks branch January 30, 2025 00:46
Copy link
Contributor

🤖 Hello there,

We just published version 7.2.0-pre.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Copy link
Contributor

🤖 Hello there,

We just published version 7.2.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Copy link
Contributor

github-actions bot commented Mar 6, 2025

🤖 Hello there,

We just published version 7.3.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants