Skip to content
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
merged 40 commits into from
Feb 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a31bf7e
feat(router-plugin): implementation for splitting loader and componen…
SeanCassiere Feb 7, 2025
091b583
test(router-plugin): update test suite
SeanCassiere Feb 7, 2025
d028323
Merge branch 'main' into refactor/split-loader-and-component-bundles
SeanCassiere Feb 7, 2025
e0ca45b
Merge branch 'main' into refactor/split-loader-and-component-bundles
SeanCassiere Feb 7, 2025
59b0b12
chore(router-plugin): add comment explaining why 'intendedSplitNodes'…
SeanCassiere Feb 7, 2025
abedfdd
chore(router-plugin): fix variable spelling
SeanCassiere Feb 7, 2025
b82d499
chore(router-plugin): more notes for future adventurers
SeanCassiere Feb 7, 2025
2f934ab
Merge branch 'main' into refactor/split-loader-and-component-bundles
SeanCassiere Feb 7, 2025
449fcd3
test(router-plugin): update tests for the new changes
SeanCassiere Feb 7, 2025
f8f14f0
chore(router-plugin): swap positions of functions
SeanCassiere Feb 7, 2025
ccf8dbf
refactor(router-plugin): prepare for the custom behaviours
SeanCassiere Feb 7, 2025
a63a0eb
refactor(router-plugin): move around again
SeanCassiere Feb 7, 2025
1b0be75
Merge branch 'main' into refactor/split-loader-and-component-bundles
SeanCassiere Feb 8, 2025
3c0e466
chore(router-plugin): duh! make the config optional!
SeanCassiere Feb 8, 2025
7784ed7
feat(router-plugin): more validation behaviours for the user input of…
SeanCassiere Feb 8, 2025
c4717df
feat(router-plugin): implementation
SeanCassiere Feb 8, 2025
9d1ea1c
test(router-plugin): snapshots
SeanCassiere Feb 8, 2025
fbf8e1b
feat(router-plugin): handle errorComponent, pendingComponent, notFoun…
SeanCassiere Feb 8, 2025
13ebf70
test(router-plugin): update testing
SeanCassiere Feb 8, 2025
dab006f
test(router-plugin): add more test files
SeanCassiere Feb 8, 2025
3fbb8c0
chore: update jsdocs
SeanCassiere Feb 8, 2025
2af1d0b
chore(router-plugin): internal typing
SeanCassiere Feb 8, 2025
60d5e9f
fix(router-plugin): revert the chaining
SeanCassiere Feb 8, 2025
0f3486e
fix(router-plugin): handle type-assertions
SeanCassiere Feb 8, 2025
3896538
feat(router-plugin): implement codesplitting by static analysis
SeanCassiere Feb 8, 2025
1e76dde
test: don't fail during build
SeanCassiere Feb 8, 2025
fb1c706
chore(router-plugin): validate user input
SeanCassiere Feb 8, 2025
766f50f
refactor(router-plugin): also extract the routeId
SeanCassiere Feb 8, 2025
971f420
feat(router-plugin): add the `shouldSplit` fn
SeanCassiere Feb 8, 2025
72b892f
fix(router-plugin): issue with pulling out the routeId
SeanCassiere Feb 8, 2025
7dfa4b4
fix(router-plugin): more runtime fixing
SeanCassiere Feb 8, 2025
db3a750
feat(react-router): add the `codeSplitGroupings` type
SeanCassiere Feb 8, 2025
a9c9406
chore(examples): examples
SeanCassiere Feb 8, 2025
777d722
fix(router-plugin): better checks for matching the schema
SeanCassiere Feb 8, 2025
37627d2
fix(router-plugin): by default make it non repeatable
SeanCassiere Feb 8, 2025
1453c04
US spelling for 'behavior'
schiller-manuel Feb 8, 2025
f8acd34
typesafe routeId
schiller-manuel Feb 8, 2025
678f65c
fix formatting
schiller-manuel Feb 8, 2025
1c3a108
Merge branch 'main' into refactor/split-loader-and-component-bundles
SeanCassiere Feb 8, 2025
ea18741
chore(router-plugin): add link to the PR for future adventurers
SeanCassiere Feb 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export const Route = createFileRoute('/posts/$postId')({
return <p>Post not found</p>
},
component: PostComponent,
codeSplitGroupings: [
['component'],
['pendingComponent', 'errorComponent', 'notFoundComponent'],
],
})

export function PostErrorComponent({ error }: ErrorComponentProps) {
Expand Down
18 changes: 17 additions & 1 deletion e2e/react-router/basic-file-based-code-splitting/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,21 @@ import { TanStackRouterVite } from '@tanstack/router-plugin/vite'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [TanStackRouterVite({ autoCodeSplitting: true }), react()],
plugins: [
TanStackRouterVite({
autoCodeSplitting: true,
codeSplittingOptions: {
splitBehavior: ({ routeId }) => {
if (routeId === '/posts') {
return [
['loader'],
['component'],
['pendingComponent', 'notFoundComponent', 'errorComponent'],
]
}
},
},
}),
react(),
],
})
9 changes: 9 additions & 0 deletions packages/react-router/src/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,15 @@ export interface UpdatableRouteOptions<
meta?: AnyRouteMatch['meta']
}
ssr?: boolean
codeSplitGroupings?: Array<
Array<
| 'loader'
| 'component'
| 'pendingComponent'
| 'notFoundComponent'
| 'errorComponent'
>
>
}

export type RouteLoaderFn<
Expand Down
Loading