@tanstack/react-router 1.131.40 → 1.131.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/llms/rules/guide.js
CHANGED
|
@@ -254,6 +254,38 @@ This means that it creates three separate lazy-loaded chunks for each route. Res
|
|
|
254
254
|
- One for the error component
|
|
255
255
|
- And one for the not-found component.
|
|
256
256
|
|
|
257
|
+
### Rules of Splitting
|
|
258
|
+
|
|
259
|
+
For automatic code splitting to work, there are some rules in-place to make sure that this process can reliably and predictably happen.
|
|
260
|
+
|
|
261
|
+
#### Do not export route properties
|
|
262
|
+
|
|
263
|
+
Route properties like \`component\`, \`loader\`, etc., should not be exported from the route file. Exporting these properties results in them being bundled into the main application bundle, which means that they will not be code-split.
|
|
264
|
+
|
|
265
|
+
\`\`\`tsx
|
|
266
|
+
import { createRoute } from '@tanstack/react-router'
|
|
267
|
+
|
|
268
|
+
export const Route = createRoute('/posts')({
|
|
269
|
+
// ...
|
|
270
|
+
notFoundComponent: PostsNotFoundComponent,
|
|
271
|
+
})
|
|
272
|
+
|
|
273
|
+
// ❌ Do NOT do this!
|
|
274
|
+
// Exporting the notFoundComponent will prevent it from being code-split
|
|
275
|
+
// and will be included in the main bundle.
|
|
276
|
+
export function PostsNotFoundComponent() {
|
|
277
|
+
// ❌
|
|
278
|
+
// ...
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function PostsNotFoundComponent() {
|
|
282
|
+
// ✅
|
|
283
|
+
// ...
|
|
284
|
+
}
|
|
285
|
+
\`\`\`
|
|
286
|
+
|
|
287
|
+
**That's it!** There are no other restrictions. You can use any other JavaScript or TypeScript features in your route files as you normally would. If you run into any issues, please [open an issue](https://github.com/tanstack/router/issues) on GitHub.
|
|
288
|
+
|
|
257
289
|
## Granular control
|
|
258
290
|
|
|
259
291
|
For most applications, the default behavior of using \`autoCodeSplitting: true\` is sufficient. However, TanStack Router provides several options to customize how your routes are split into chunks, allowing you to optimize for specific use cases or performance needs.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-router",
|
|
3
|
-
"version": "1.131.
|
|
3
|
+
"version": "1.131.44",
|
|
4
4
|
"description": "Modern and scalable routing for React applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"tiny-invariant": "^1.3.3",
|
|
81
81
|
"tiny-warning": "^1.0.3",
|
|
82
82
|
"@tanstack/history": "1.131.2",
|
|
83
|
-
"@tanstack/router-core": "1.131.
|
|
83
|
+
"@tanstack/router-core": "1.131.44"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@testing-library/jest-dom": "^6.6.3",
|