Skip to content

Commit 61383fc

Browse files
hi-ogawaclaude
andcommitted
docs: add documentation for clientChunks option
Adds comprehensive JSDoc documentation for the clientChunks configuration option, including usage examples, parameter details, and benefits of custom client chunking. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent ce83f40 commit 61383fc

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

packages/plugin-rsc/src/plugin.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,35 @@ export type RscPluginOptions = {
180180
}
181181

182182
/**
183-
* @experimental
183+
* Custom chunking strategy for client reference modules.
184+
*
185+
* This function allows you to group multiple client components into
186+
* custom chunks instead of having each module in its own chunk.
187+
*
188+
* @param id - The absolute path of the client module
189+
* @returns The chunk name to group this module with, or undefined to use default behavior
190+
*
191+
* @example
192+
* ```js
193+
* clientChunks(id) {
194+
* // Group all client components in a specific route together
195+
* if (id.includes('/src/routes/dashboard/')) {
196+
* return 'dashboard-clients'
197+
* }
198+
* // Group third-party client components
199+
* if (id.includes('node_modules/@company/ui/')) {
200+
* return 'vendor-ui'
201+
* }
202+
* }
203+
* ```
204+
*
205+
* Benefits:
206+
* - Reduces the number of HTTP requests by bundling related client components
207+
* - Improves loading performance for route-based code splitting
208+
* - Allows fine-grained control over client-side bundle optimization
209+
*
210+
* Note: Tree-shaking is still applied, so only the actually used exports
211+
* from each module will be included in the final chunk.
184212
*/
185213
clientChunks?: (id: string) => string | undefined
186214
}

0 commit comments

Comments
 (0)