Skip to content

Commit d545369

Browse files
committed
Expand docs
1 parent b0f3af3 commit d545369

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

docs/explanation/code-splitting.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Run clientLoader: |-----|
108108
Render: |-|
109109
```
110110

111-
To achieve this optimization, React Router will split the route module during the production build process. In this case, we'll end up with two separate [virtual modules][virtual-modules] — one for the client loader and one for the component.
111+
To achieve this optimization, React Router will split the route module into multiple smaller modules during the production build process. In this case, we'll end up with two separate [virtual modules][virtual-modules] — one for the client loader and one for the component and its dependencies.
112112

113113
```tsx filename=routes/example.tsx?route-chunk=clientLoader
114114
export async function clientLoader() {
@@ -126,6 +126,8 @@ export default function Component({ loaderData }) {
126126
}
127127
```
128128

129+
<docs-info>This optimization is automatically applied in framework mode, but you can also implement it in library mode via `route.lazy` and authoring your route in multiple files as covered in our blog post on [lazy loading route modules.][blog-lazy-loading-routes]</docs-info>
130+
129131
Now that these are available as separate modules, the client loader and the component can be downloaded in parallel. This means that the client loader can be executed as soon as it's ready without having to wait for the component.
130132

131133
This optimization is even more pronounced when more Route Module APIs are used. For example, when using `clientLoader`, `clientAction` and `HydrateFallback`, the timeline for a single route module during a client-side navigation might look like this:
@@ -239,3 +241,4 @@ This export could not be split into its own chunk because it shares code with ot
239241

240242
[route-module]: ../../start/framework/route-module
241243
[virtual-modules]: https://vite.dev/guide/api-plugin#virtual-modules-convention
244+
[blog-lazy-loading-routes]: https://remix.run/blog/lazy-loading-routes#advanced-usage-and-optimizations

0 commit comments

Comments
 (0)