-
-
Notifications
You must be signed in to change notification settings - Fork 809
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
feat(router-plugin): configurable key-based code splitting #3355
Merged
SeanCassiere
merged 40 commits into
main
from
refactor/split-loader-and-component-bundles
Feb 9, 2025
Merged
feat(router-plugin): configurable key-based code splitting #3355
SeanCassiere
merged 40 commits into
main
from
refactor/split-loader-and-component-bundles
Feb 9, 2025
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
View your CI Pipeline Execution ↗ for commit ea18741.
☁️ Nx Cloud last updated this comment at |
More templates
@tanstack/arktype-adapter
@tanstack/create-router
@tanstack/directive-functions-plugin
@tanstack/create-start
@tanstack/history
@tanstack/eslint-plugin-router
@tanstack/react-cross-context
@tanstack/react-router-with-query
@tanstack/react-router
@tanstack/router-cli
@tanstack/router-core
@tanstack/router-devtools
@tanstack/router-generator
@tanstack/router-plugin
@tanstack/router-utils
@tanstack/router-vite-plugin
@tanstack/server-functions-plugin
@tanstack/start
@tanstack/start-api-routes
@tanstack/start-client
@tanstack/start-config
@tanstack/start-plugin
@tanstack/start-router-manifest
@tanstack/start-server
@tanstack/start-server-functions-client
@tanstack/start-server-functions-fetcher
@tanstack/start-server-functions-handler
@tanstack/start-server-functions-server
@tanstack/start-server-functions-ssr
@tanstack/valibot-adapter
@tanstack/virtual-file-routes
@tanstack/zod-adapter
commit: |
SeanCassiere
commented
Feb 7, 2025
… the split groupings
661052f
to
678f65c
Compare
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.
Customizable grouping of the code-splittable parts.
The goal of this change is as follows.
loader
andcomponent
) are split into their own virtual route bundles.loader
andcomponent
from a "virtual" route.loader
andcomponent
being exported out of it by the end.loader
andcomponent
are being exported out of the same "virtual" file. This change makes it so that the user can control how this behaviour works.pendingComponent
,notFoundComponent
, and theerrorComponent
.loader
,component
,pendingComponent
,errorComponent
, andnotFoundComponent
.[['loader', 'component']]
to this new grouping:[ ['component'], ['pendingComponent'], ['notFoundComponent'], ['errorComponent'] ]
loader
will NOT be extracted out to follow the guidelines set in our documentation.router/docs/router/framework/react/guide/code-splitting.md
Lines 11 to 40 in 026ea55
What is a grouping?
As mentioned earlier, a grouping will consistent only of the relevant exports as stated by the user.
So, for this reference route.
This will be the virtual route generated for
['component', 'loader']
.And this will be the virtual route generated for
['pendingComponent']
.So finally, the transformed "reference" route will look similar to this.
How does this work?
This flow is the flow for how the "reference" and "virtual" routes are formed.
How is this configured?
As shown in the diagram, you have three layers at which configuration can occur:
1. Route-level configuration
If the
codeSplitGroupings
value is set, therouter-plugin
will disregard all other settings further down the tree.2. Plugin function-based configuration API
This is a function that lets you programmatically change the code-splitting behaviour.
3. Plugin global configuration API
This is the last stop on the train checking for user-controlled code splitting.
Closes #2524