experimental.turbopackChunking config option
experimental.turbopackChunking is a configuration option that lets you configure Turbopack's production JavaScript chunker. It allows you to change the assumptions the chunker makes about user behavior, tweak raw size thresholds, and enable the experimental component chunks feature (App Router only).
turbopackChunking.minChunkSize default
minChunkSize has a default value of 50000 bytes. Turbopack will avoid creating more than one chunk smaller than this size by merging small chunks into larger ones. Raising this number produces fewer, larger chunks. Lowering it produces more, smaller chunks.
turbopackChunking.maxChunkCountPerGroup default
maxChunkCountPerGroup has a default value of 40. Turbopack will not emit more than this many chunks per chunk group (e.g. a route or a dynamic import). Lowering this number leads to more aggressive merging and fewer network requests per-page. Raising it produces smaller chunks and increases the likelihood of cache hits when navigating.
turbopackChunking.maxMergeChunkSize default
maxMergeChunkSize has a default value of 200000 bytes. Turbopack never merges a chunk larger than this size with other chunks. This keeps the code in large chunks from being duplicated across multiple large output chunks.
turbopackChunking size thresholds units
All size thresholds in turbopackChunking configuration are measured in bytes of uncompressed, unminified code, which is roughly 5 times the size of compressed, minified output.
turbopackChunking.generateComponentChunks default
generateComponentChunks has a default value of false. When enabled, each merged production chunk also emits its constituent component chunks alongside it, so the browser runtime can fetch individual component chunks. This is an experimental feature available in the App Router.
turbopackChunking.minComponentChunkSize default
minComponentChunkSize has a default value of 20000 bytes. Component chunks smaller than this size are folded into a single component instead of being emitted on their own, to avoid producing many tiny chunks. This option is available in the App Router.
turbopackChunking.clusters heuristic
clusters is a configuration option that takes an array of arrays of RegExp patterns (e.g. [[/^\/dashboard/, /^\/settings/]]). It groups routes that are commonly visited together, matched against the route pathname. Turbopack assumes navigations are likely to stay within a cluster, so chunks shared by a cluster's routes are merged more eagerly.
turbopackChunking.firstPageLoadPriority heuristic
firstPageLoadPriority is a number between 0 and 1 that controls how heavily to weight the benefit of merging chunks for a single page load. Higher values merge more eagerly. If you don't have a better value, your site's bounce rate is a good approximation.
turbopackChunking.priorityRoutes heuristic
priorityRoutes is an array of RegExp patterns that specify routes often visited first (e.g. the homepage). Their client-side bundles are merged more eagerly to reduce the single-route request cost, at the cost of extra requests when navigating to other pages.
turbopackChunking.priorityBoost default
priorityBoost has a default value of 1.5. It is a multiplier on the single-request probability of priorityRoutes routes. Higher values merge those routes' bundles more aggressively.
turbopackChunking.requestCost default
requestCost has a default value of 200000 bytes. It represents the estimated cost of an additional request, measured in bytes of uncompressed, unminified code. Larger values bias toward fewer, larger chunks and fewer requests overall.
turbopackChunking App Router config example
Default turbopackChunking configuration for App Router: { experimental: { turbopackChunking: { minChunkSize: 50000, maxChunkCountPerGroup: 40, maxMergeChunkSize: 200000, minComponentChunkSize: 20000, generateComponentChunks: false, } } }
turbopackChunking component chunks benefit
Component chunks is an experimental feature that aims to give you the initial page load benefits of merged chunks without sacrificing reusability. It lets the runtime dynamically choose whether to load a merged chunk as a single file, or to load only the component chunks it doesn't already have. Chunks that were already loaded as part of a merged chunk will not be re-downloaded, avoiding re-downloading JavaScript the browser already has when navigating.