-
Notifications
You must be signed in to change notification settings - Fork 31.8k
Expand file tree
/
Copy pathconfig-shared.ts
More file actions
2560 lines (2325 loc) · 85 KB
/
Copy pathconfig-shared.ts
File metadata and controls
2560 lines (2325 loc) · 85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import os from 'os'
import type { webpack } from 'next/dist/compiled/webpack/webpack'
import type { Header, Redirect, Rewrite } from '../lib/load-custom-routes'
import { imageConfigDefault } from '../shared/lib/image-config'
import type {
ImageConfig,
ImageConfigComplete,
} from '../shared/lib/image-config'
import type { SubresourceIntegrityAlgorithm } from '../build/webpack/plugins/subresource-integrity-plugin'
import type { WEB_VITALS } from '../shared/lib/utils'
import type { NextParsedUrlQuery } from './request-meta'
import type { SizeLimit } from '../types'
import type { SupportedTestRunners } from '../cli/next-test'
import { INFINITE_CACHE } from '../lib/constants'
import { isStableBuild } from '../shared/lib/errors/canary-only-config-error'
import type { FallbackRouteParam } from '../build/static-paths/types'
import type { MemoryEvictionMode } from '../build/swc/types'
import type { CacheLife } from './use-cache/cache-life'
/**
* The `cacheLife` profiles after config normalization. `config.ts` always
* backfills the `default` profile so that its `stale`, `revalidate`, and
* `expire` are all defined, which is why `default` is `Required<CacheLife>`
* here while other profiles may still be partial. Runtime `"use cache"` code
* can therefore read `cacheLifeProfiles.default` without re-validating it.
*/
export interface ResolvedCacheLifeProfiles {
default: Required<CacheLife>
[profile: string]: CacheLife
}
/**
* Resolved form of the prefetchInlining config after normalization in
* config.ts. User input (true, partial objects) is converted to this shape.
*/
export type PrefetchInliningConfig =
| false
| { maxSize: number; maxBundleSize: number }
export type NextConfigComplete = Required<
Omit<
NextConfig,
| 'configFile'
| 'cacheLife'
| 'expireTime'
| 'output'
| 'modularizeImports'
| 'allowedDevOrigins'
| 'adapterPath'
>
> &
// Don't apply `Required<>` for these properties. They really can be undefined in the finalized config.
Pick<
NextConfig,
| 'cacheLife'
| 'expireTime'
| 'output'
| 'modularizeImports'
| 'allowedDevOrigins'
| 'adapterPath'
> & {
images: Required<ImageConfigComplete>
typescript: TypeScriptConfig
configFile: string | undefined
configFileName: string
// Normalized by config.ts: the `default` profile is backfilled to be complete
// (see `ResolvedCacheLifeProfiles`), unlike the optional/partial user input.
// Omitted from the base so this is a clean replacement, not an intersection.
cacheLife: ResolvedCacheLifeProfiles
// override NextConfigComplete.experimental.htmlLimitedBots to string
// because it's not defined in NextConfigComplete.experimental
htmlLimitedBots: string | undefined
experimental: ExperimentalConfig & {
// Normalized by config.ts: true and partial objects become resolved objects
prefetchInlining?: PrefetchInliningConfig
// Normalized by config.ts: defaulted to 90% of staticPageGenerationTimeout
useCacheTimeout: number
// Normalized by config.ts `finalizeConfig`: defaulted to `'warning'`
instantInsights: { validationLevel: ValidationLevel }
// Normalized by finalized config with a default and the expected type
turbopackMemoryEvictionMode: MemoryEvictionMode
}
// The root directory of the distDir. In development mode, this is the parent directory of `distDir`
// since development builds use `{distDir}/dev`. This is used to ensure that the bundler doesn't
// traverse into the output directory.
distDirRoot: string
// The repository root, regardless of overwritten outputFileTracingRoot or turbopack.root.
repoRoot: string
}
export type I18NDomains = readonly DomainLocale[]
export interface I18NConfig {
defaultLocale: string
domains?: I18NDomains
localeDetection?: false
locales: readonly string[]
}
export interface DomainLocale {
defaultLocale: string
domain: string
http?: true
locales?: readonly string[]
}
export interface TypeScriptConfig {
/** Do not run TypeScript during production builds (`next build`). */
ignoreBuildErrors?: boolean
/** Relative path to a custom tsconfig file */
tsconfigPath?: string
}
export interface EmotionConfig {
sourceMap?: boolean
autoLabel?: 'dev-only' | 'always' | 'never'
labelFormat?: string
importMap?: {
[importName: string]: {
[exportName: string]: {
canonicalImport?: [string, string]
styledBaseImport?: [string, string]
}
}
}
}
export interface StyledComponentsConfig {
/**
* Enabled by default in development, disabled in production to reduce file size,
* setting this will override the default for all environments.
*/
displayName?: boolean
topLevelImportPaths?: string[]
ssr?: boolean
fileName?: boolean
meaninglessFileNames?: string[]
minify?: boolean
transpileTemplateLiterals?: boolean
namespace?: string
pure?: boolean
cssProp?: boolean
}
export type JSONValue =
| string
| number
| boolean
| JSONValue[]
| { [k: string]: JSONValue }
// At the moment, Turbopack options must be JSON-serializable, so restrict values.
export type TurbopackLoaderOptions = Record<string, JSONValue>
export type TurbopackLoaderItem =
| string
| {
loader: string
options?: TurbopackLoaderOptions
}
export type TurbopackLoaderBuiltinCondition =
| 'browser'
| 'foreign'
| 'development'
| 'production'
| 'node'
| 'edge-light'
export type TurbopackRuleCondition =
| { all: TurbopackRuleCondition[] }
| { any: TurbopackRuleCondition[] }
| { not: TurbopackRuleCondition }
| TurbopackLoaderBuiltinCondition
| {
path?: string | RegExp
content?: RegExp
query?: string | RegExp
contentType?: string | RegExp
}
/**
* The module type to use for matched files. This determines how files are
* processed without requiring a custom loader.
*
* - `'asset'` - Emit the file and return its URL (like webpack's `asset/resource`)
* - `'ecmascript'` - Process as JavaScript module
* - `'typescript'` - Process as TypeScript module
* - `'css'` - Process as CSS file
* - `'css-module'` - Process as CSS module
* - `'json'` - Parse as JSON and export it
* - `'wasm'` - Process as WebAssembly module
* - `'raw'` - Export file contents as a string (an alias of `'text'`)
* - `'node'` - Process as native Node.js addon
* - `'bytes'` - Export file contents as a `Uint8Array`
* - `'text'` - Export file contents as a string
*
* @see [Module Types](https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack#module-types)
*/
export type TurbopackModuleType =
| 'asset'
| 'ecmascript'
| 'typescript'
| 'css'
| 'css-module'
| 'json'
| 'wasm'
| 'raw'
| 'node'
| 'bytes'
| 'text'
export type TurbopackRuleConfigItem = {
/** Loaders to apply to matched files. */
loaders?: TurbopackLoaderItem[]
/** Rename the file extension for loader output (e.g., `'*.js'`). */
as?: string
/** Additional conditions for when this rule applies. */
condition?: TurbopackRuleCondition
/**
* Set the module type directly without using a loader.
* @see [Module Types](https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack#module-types)
*/
type?: TurbopackModuleType
}
/**
* This can be an object representing a single configuration, or a list of
* loaders and/or rule configuration objects.
*
* - A list of loader path strings or objects is the "shorthand" syntax.
* - A list of rule configuration objects can be useful when each configuration
* object has different `condition` fields, but still match the same top-level
* path glob.
*/
export type TurbopackRuleConfigCollection =
| TurbopackRuleConfigItem
| (TurbopackLoaderItem | TurbopackRuleConfigItem)[]
export interface TurbopackOptions {
/**
* (`next --turbopack` only) A mapping of aliased imports to modules to load in their place.
*
* @see [Resolve Alias](https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack#resolving-aliases)
*/
resolveAlias?: Record<
string,
string | string[] | Record<string, string | string[]>
>
/**
* (`next --turbopack` only) A list of extensions to resolve when importing files.
*
* @see [Resolve Extensions](https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack#resolving-custom-extensions)
*/
resolveExtensions?: string[]
/**
* (`next --turbopack` only) A list of webpack loaders to apply when running with Turbopack.
*
* @see [Turbopack Loaders](https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack#configuring-webpack-loaders)
*/
rules?: Record<string, TurbopackRuleConfigCollection>
/**
* This is the repo root usually and only files above this
* directory can be resolved by turbopack.
*/
root?: string
/**
* Enables generation of debug IDs in JavaScript bundles and source maps.
* These debug IDs help with debugging and error tracking by providing stable identifiers.
*
* @see https://github.com/tc39/ecma426/blob/main/proposals/debug-id.md TC39 Debug ID Proposal
*/
debugIds?: boolean
/**
* An array of issue filter rules to ignore specific Turbopack issues.
* Each rule must have a `path` field (mandatory) and optionally `title`
* and `description`. String paths are treated as glob patterns. String
* titles/descriptions are exact matches. RegExp values match anywhere
* within the string (use `^` and `$` anchors for full-string matching).
*/
ignoreIssue?: Array<{
path: string | RegExp
title?: string | RegExp
description?: string | RegExp
}>
/**
* Override the global variable name used for
* chunk loading. Useful when multiple Turbopack-built apps run on the same
* page (e.g. horizontal micro-frontends) to avoid `globalThis.TURBOPACK`
* conflicts.
*
* @see https://webpack.js.org/configuration/output/#outputchunkloadingglobal
*/
chunkLoadingGlobal?: string
}
export interface WebpackConfigContext {
/** Next.js root directory */
dir: string
/** Indicates if the compilation will be done in development */
dev: boolean
/** It's `true` for server-side compilation, and `false` for client-side compilation */
isServer: boolean
/** The build id, used as a unique identifier between builds */
buildId: string
/** The next.config.js merged with default values */
config: NextConfigComplete
/** Default loaders used internally by Next.js */
defaultLoaders: {
/** Default babel-loader configuration */
babel: any
}
/** Number of total Next.js pages */
totalPages: number
/** The webpack configuration */
webpack: any
/** The current server runtime */
nextRuntime?: 'nodejs' | 'edge'
}
export interface NextJsWebpackConfig {
(
/** Existing Webpack config */
config: any,
context: WebpackConfigContext
): any
}
/**
* Set of options for React Compiler that Next.js currently supports.
*
* These options may be changed in breaking ways at any time without notice
* while support for React Compiler is experimental.
*
* @see https://react.dev/reference/react-compiler/configuration
*/
export interface ReactCompilerOptions {
/**
* Controls the strategy for determining which functions the React Compiler
* will optimize.
*
* The default is `'infer'`, which uses intelligent heuristics to identify
* React components and hooks.
*
* When using `infer`, Next.js applies its own heuristics before calling
* `react-compiler`. This improves compilation performance by avoiding extra
* invocations of Babel and reducing redundant parsing of code.
*
* @see https://react.dev/reference/react-compiler/compilationMode
*/
compilationMode?: 'infer' | 'annotation' | 'all'
/**
* Controls how the React Compiler handles errors during compilation.
*
* The default is `'none'`, which skips components which cannot be compiled.
*
* @see https://react.dev/reference/react-compiler/panicThreshold
*/
panicThreshold?: 'none' | 'critical_errors' | 'all_errors'
}
export interface IncomingRequestLoggingConfig {
/**
* A regular expression array to match incoming requests that should not be logged.
* You can specify multiple patterns to match incoming requests that should not be logged.
*/
ignore?: RegExp[]
}
export interface LoggingConfig {
fetches?: {
fullUrl?: boolean
/**
* If true, fetch requests that are restored from the HMR cache are logged
* during an HMR refresh request, i.e. when editing a server component.
*/
hmrRefreshes?: boolean
}
/**
* If set to false, incoming request logging is disabled.
* You can specify a pattern to match incoming requests that should not be logged.
*/
incomingRequests?: boolean | IncomingRequestLoggingConfig
/**
* If false, Server Function invocation logging is disabled.
* @default true
*/
serverFunctions?: boolean
/**
* Forward browser console logs to terminal.
* - `false`: Disable browser log forwarding
* - `true`: Forward all browser console output to terminal
* - `'warn'`: Forward warnings and errors to terminal
* - `'error'`: Forward only errors to terminal
*/
browserToTerminal?: boolean | 'error' | 'warn'
}
/**
* All recognized lightningcss feature names.
* Individual features map 1:1 to lightningcss `Features` bitflags.
* Composite names (`selectors`, `media-queries`, `colors`) enable a group of
* related individual features at once.
*
* The name→bitmask mapping is duplicated in:
* - JS: `packages/next/src/build/webpack/loaders/lightningcss-loader/src/features.ts`
* - Rust: `crates/next-core/src/next_config.rs` (`lightningcss_feature_names_to_mask`)
*/
export const LIGHTNINGCSS_FEATURE_NAMES = [
// Individual features (bit 0–20)
'nesting',
'not-selector-list',
'dir-selector',
'lang-selector-list',
'is-selector',
'text-decoration-thickness-percent',
'media-interval-syntax',
'media-range-syntax',
'custom-media-queries',
'clamp-function',
'color-function',
'oklab-colors',
'lab-colors',
'p3-colors',
'hex-alpha-colors',
'space-separated-color-notation',
'font-family-system-ui',
'double-position-gradients',
'vendor-prefixes',
'logical-properties',
'light-dark',
// Composite groups
'selectors',
'media-queries',
'colors',
] as const
export type LightningCssFeature = (typeof LIGHTNINGCSS_FEATURE_NAMES)[number]
export interface LightningCssFeatures {
include?: LightningCssFeature[]
exclude?: LightningCssFeature[]
}
/**
* Accepted shapes for `experimental.cssChunking`. See [`ExperimentalConfig.cssChunking`] for the
* accepted values; use [`resolveCssChunkingMode`] to normalize the value at runtime.
*/
export type CssChunkingConfig =
| boolean
| 'strict'
| 'loose'
| 'graph'
| { type: 'strict' }
| { type: 'loose' }
| { type: 'graph'; requestCost?: number; weightDistribution?: number }
/**
* Normalize any [`CssChunkingConfig`] value to one of the four modes the build pipeline cares
* about:
* - `'off'` — `false`/`undefined`: do not run a CSS chunking plugin.
* - `'loose'` — `true` / `'loose'` / `{ type: 'loose' }`: heuristic-based chunking
* (the default).
* - `'strict'` — `'strict'` / `{ type: 'strict' }`: webpack-only ordered-chunking plugin.
* - `'graph'` — `'graph'` / `{ type: 'graph', … }`: Turbopack-only graph algorithm.
*/
export function resolveCssChunkingMode(
value: CssChunkingConfig | undefined
): 'off' | 'loose' | 'strict' | 'graph' {
if (value === undefined || value === false) return 'off'
if (value === true || value === 'loose') return 'loose'
if (value === 'strict' || value === 'graph') return value
// Object form. `requestCost` and `weightDistribution` are validated by the schema.
if (value.type === 'strict') return 'strict'
if (value.type === 'graph') return 'graph'
return 'loose'
}
export interface ExperimentalConfig {
/**
* @deprecated Use the top-level `outputHashSalt` option instead.
*/
outputHashSalt?: string
/**
* Shows a persistent "Cold cache" badge in the dev overlay after a load that
* filled an empty cache while streaming. Off by default while the badge's
* UI/UX is iterated on; the transient "Rendering (cold cache)" pill is shown
* regardless of this flag.
*/
coldCacheBadge?: boolean
useSkewCookie?: boolean
/** @deprecated use top-level `cacheHandlers` instead */
cacheHandlers?: NextConfig['cacheHandlers']
multiZoneDraftMode?: boolean
appNavFailHandling?: boolean
prerenderEarlyExit?: boolean
linkNoTouchStart?: boolean
caseSensitiveRoutes?: boolean
/**
* The origins that are allowed to write the rewritten headers when
* performing a non-relative rewrite. When undefined, no non-relative
* rewrites will get the rewrite headers.
*/
clientParamParsingOrigins?: string[]
/**
* Caches subsets of a route, seeded from actual navigations, so subsequent
* navigations to the same or similar pages can be served instantly. Requires
* Cache Components.
*/
cachedNavigations?: boolean
dynamicOnHover?: boolean
useOffline?: boolean
optimisticRouting?: boolean
/**
* Replaces the client router's sequential action queue with a rewritten
* concurrent implementation. The implementations are swapped at the module
* level by the bundler; the inactive one is not included in the bundle.
*/
concurrentRouterQueue?: boolean
instrumentationClientRouterTransitionEvents?: boolean
varyParams?: boolean
prefetchInlining?:
| boolean
| {
maxSize?: number
maxBundleSize?: number
}
preloadEntriesOnStart?: boolean
clientRouterFilter?: boolean
clientRouterFilterRedirects?: boolean
/**
* This config can be used to override the cache behavior for the client router.
* These values indicate the time, in seconds, that the cache should be considered
* reusable. When the `prefetch` Link prop is left unspecified, this will use the `dynamic` value.
* When the `prefetch` Link prop is set to `true`, this will use the `static` value.
*/
staleTimes?: {
dynamic?: number
/** Must be greater than or equal to 30 seconds, to ensure prefetching is not completely wasteful */
static?: number
}
/**
* @deprecated use top-level `cacheLife` instead
*/
cacheLife?: NextConfig['cacheLife']
// decimal for percent for possible false positives
// e.g. 0.01 for 10% potential false matches lower
// percent increases size of the filter
clientRouterFilterAllowedRate?: number
/**
* @deprecated Use `externalProxyRewritesResolve` instead.
*/
externalMiddlewareRewritesResolve?: boolean
externalProxyRewritesResolve?: boolean
/**
* Exposes the Instant Navigation Testing API in production builds. This
* API is always available in development mode.
*
* The testing API allows e2e tests to control navigation timing, enabling
* deterministic assertions on prefetched/cached UI before dynamic data
* streams in.
*
* WARNING: This flag is intended for profiling and testing purposes only.
* Do not enable in user-facing production deployments.
*/
exposeTestingApiInProductionBuild?: boolean
/**
* Show Request Insights in the dev tools indicator. Request Insights records
* the local framework spans needed to explain App Router request, render,
* fetch, and cache behavior without requiring an external OTEL collector.
*/
requestInsights?: boolean
extensionAlias?: Record<string, any>
allowedRevalidateHeaderKeys?: string[]
fetchCacheKeyPrefix?: string
imgOptConcurrency?: number | null
imgOptOperationCache?: boolean | null
imgOptTimeoutInSeconds?: number
imgOptMaxInputPixels?: number
imgOptSequentialRead?: boolean | null
optimisticClientCache?: boolean
/**
* @deprecated use config.expireTime instead
*/
expireTime?: number
/**
* @deprecated Use `proxyPrefetch` instead.
*/
middlewarePrefetch?: 'strict' | 'flexible'
proxyPrefetch?: 'strict' | 'flexible'
manualClientBasePath?: boolean
/**
* CSS Chunking strategy. Defaults to `true` (loose mode), which guesses dependencies between
* CSS files to keep ordering of them.
*
* - `true` / `'loose'` / `{ type: 'loose' }` — default heuristic-based chunking.
* - `'strict'` / `{ type: 'strict' }` — preserve correct ordering as much as possible, even
* when this leads to many requests. Webpack only.
* - `false` — disable chunking; emit one chunk per CSS module. Webpack only.
* - `'graph'` / `{ type: 'graph', requestCost?, weightDistribution? }` — Turbopack only.
* Selects a CSS chunking strategy that analyzes the most common style orderings across the
* application and produces shared chunks accordingly. Compared to the default mode it
* intentionally overships some styles in order to reduce the number of CSS requests per
* page. Cost overrides:
* - `requestCost` (bytes, default `100000`) — additional cost charged for every CSS
* request a chunk group makes. Larger values bias the algorithm toward fewer, larger
* shared chunks; smaller values toward more, smaller chunks.
* - `weightDistribution` (default `0.1`) — controls how a chunk's cost is distributed across
* the chunk groups that load it, via a per-group weight of
* `groupSize ^ (-weightDistribution)`. `0` weights every chunk group equally; higher
* values give smaller chunk groups more weight, so small pages ship fewer unrelated
* styles at the expense of more requests overall.
*/
cssChunking?: CssChunkingConfig
/**
* Controls whether the development server automatically restarts when its
* heap usage exceeds the memory threshold. Defaults to `true`.
*/
devMemoryThresholdRestart?: boolean
disablePostcssPresetEnv?: boolean
cpus?: number
memoryBasedWorkersCount?: boolean
proxyTimeout?: number
isrFlushToDisk?: boolean
workerThreads?: boolean
// optimizeCss can be boolean or critters' option object
// Use Record<string, unknown> as critters doesn't export its Option type
// https://github.com/GoogleChromeLabs/critters/blob/a590c05f9197b656d2aeaae9369df2483c26b072/packages/critters/src/index.d.ts
optimizeCss?: boolean | Record<string, unknown>
nextScriptWorkers?: boolean
scrollRestoration?: boolean
externalDir?: boolean
disableOptimizedLoading?: boolean
/** @deprecated A no-op as of Next 16, size metrics were removed from the build output. */
gzipSize?: boolean
craCompat?: boolean
esmExternals?: boolean | 'loose'
fullySpecified?: boolean
urlImports?: NonNullable<webpack.Configuration['experiments']>['buildHttp']
swcTraceProfiling?: boolean
forceSwcTransforms?: boolean
swcPlugins?: Array<[string, Record<string, unknown>]>
/**
* Additional options for SWC's preset-env (`env` configuration).
* These are merged into the `env` block that Next.js passes to SWC,
* alongside the browserslist-derived `targets`.
*
* See https://swc.rs/docs/configuration/supported-browsers for full details.
*
* @example
* ```js
* // next.config.js
* module.exports = {
* experimental: {
* swcEnvOptions: {
* mode: 'usage',
* coreJs: '3.38',
* },
* },
* }
* ```
*/
swcEnvOptions?: {
/**
* Polyfill injection mode, matching Babel's `useBuiltIns`.
* - `'usage'`: Adds specific polyfill imports per file based on actual usage.
* - `'entry'`: Replaces a single `import 'core-js'` with only the polyfills
* needed for the target browsers.
*/
mode?: 'usage' | 'entry'
/** The core-js version to use (e.g. `'3.38'`). Required when `mode` is set. */
coreJs?: string
/** Core-js modules or SWC transform passes to skip. */
skip?: string[]
/** Core-js modules or SWC transform passes to always include. */
include?: string[]
/** Core-js modules or SWC transform passes to always exclude. */
exclude?: string[]
/** Enable shipped TC39 proposals. */
shippedProposals?: boolean
/** Force all transforms regardless of targets. */
forceAllTransforms?: boolean
/** Enable debug output for preset-env. */
debug?: boolean
/** Enable loose mode for transforms. */
loose?: boolean
}
largePageDataBytes?: number
/**
* If set to `false`, webpack won't fall back to polyfill Node.js modules in the browser
* Full list of old polyfills is accessible here:
* [webpack/webpack#ModuleNotoundError.js#L13-L42](https://github.com/webpack/webpack/blob/2a0536cf510768111a3a6dceeb14cb79b9f59273/lib/ModuleNotFoundError.js#L13-L42)
*/
fallbackNodePolyfills?: false
sri?: {
algorithm?: SubresourceIntegrityAlgorithm
}
webVitalsAttribution?: Array<(typeof WEB_VITALS)[number]>
/**
* Automatically apply the "modularizeImports" optimization to imports of the specified packages.
*/
optimizePackageImports?: string[]
/**
* Optimize React APIs for server builds.
*/
optimizeServerReact?: boolean
/**
* Type-checks props and return values of pages.
* Requires literal values for segment config (e.g. `export const dynamic = 'force-static' as const`).
*/
strictRouteTypes?: boolean
/**
* Runs the project-local TypeScript CLI instead of using TypeScript's
* programmatic API for build-time type checking and config loading.
*/
useTypeScriptCli?: boolean
/**
* Displays an indicator when a React Transition has no other indicator rendered.
* This includes displaying an indicator on client-side navigations.
*/
transitionIndicator?: boolean
/**
* Enables experimental gesture transition APIs for optimistic client
* navigations. Requires experimental React.
*/
gestureTransition?: boolean
/**
* Controls Turbopack's memory eviction strategy for development sessions
*
* Only effective in dev sessions where
* `experimental.turbopackFileSystemCacheForDev` is enabled (which it is by default).
*
* - `false`: disable eviction.
* - `'full'`: after every snapshot, drop as much memory as possible.
* - `'auto'`: evict after a snapshot when we expect to save a lot of memory or the system is under pressure
*
* Defaults to `'auto'`
*/
turbopackMemoryEviction?: false | 'full' | 'auto'
/**
* Selects the backend used by Turbopack for Node.js evaluation, e.g. webpack
* loaders, Babel, or PostCSS.
*
* This defaults to `'childProcesses'`, which creates a pool of child node.js
* processes and communciates with them over sockets.
*
* `'workerThreads'` runs the same work in worker threads instead, which should
* use less memory and CPU. It may become the default in a future version of
* Next.js.
*/
turbopackPluginRuntimeStrategy?: 'workerThreads' | 'childProcesses'
/**
* Enable minification. Defaults to true in build mode and false in dev mode.
*
* Pass an object to configure each environment separately, e.g.
* `{ server: false, client: true }`. The `server` option takes precedence
* over `experimental.serverMinification`.
*
* We don't recommend disabling minification in production. Disabling it
* increases server function size, slows down cold starts, and leads to
* degraded performance.
*/
turbopackMinify?:
| boolean
| { server?: boolean; client?: boolean; edge?: boolean }
/**
* Enable support for `with {type: "bytes"}` for ESM imports.
*/
turbopackImportTypeBytes?: boolean
/**
* Enable scope hoisting. Defaults to true in build mode. Always disabled in development mode.
*/
turbopackScopeHoisting?: boolean
/**
* Share the browser runtime across routes in a single `runtime.js` asset and inline the
* per-route chunk-group bootstrap into the HTML, dropping the per-route runtime. Defaults to
* true on canary releases and false on stable releases. Only applies to production builds; has
* no effect in development mode.
*/
turbopackSharedRuntime?: boolean
/**
* (`next --turbopack` only) These options change the assumptions Turbopack makes when
* making chunk merging decisions and the raw size thresholds it uses.
*/
turbopackChunking?: {
/**
* Groups of pages commonly visited together, each defined by a list of regular
* expressions matched against the route pathname.
*
* @example
* ```js
* clusters: [
* [/^\/dashboard/, /^\/dashboard\/settings/],
* [/^\/blog/, /^\/blog\/[^/]+$/],
* ]
* ```
*/
clusters?: RegExp[][]
/**
* This is a number between `0..1`, when higher, we weight the benefits of
* merging chunks for a signal page load higher. If you don't know a good
* number for this, your bounce rate is a good approximate for this value.
*/
firstPageLoadPriority?: number
/**
* Regular expressions matching routes that are often the first page
* visited and whose client-side bundles should be merged more eagerly to reduce the single-route
* request cost (e.g. the homepage). This is at the cost of extra requests on other pages.
*/
priorityRoutes?: RegExp[]
/**
* How much more eagerly to merge the client-side bundles of
* `priorityRoutes` routes, as a multiplier on their single-request probability (default
* `1.5`). Higher values merge more aggressively for those routes at the cost of extra requests
* elsewhere.
*/
priorityBoost?: number
/**
* Estimated cost of an additional request, in bytes (uncompressed
* and unminfified bytes of code, default is 200 KB), used by the chunker to
* trade off request count against preventing double-fetching. Uncompressed and unminfified code
* is approximately 5x the size of compressed and minified code.
*/
requestCost?: number
/**
* Avoid creating more than one chunk smaller than this size, in bytes. Smaller
* chunks are merged into bigger ones to avoid that. Defaults to `50000` (50 KB).
*/
minChunkSize?: number
/**
* Avoid creating more than this number of chunks per chunk group. Chunks are
* merged into bigger ones to avoid that. Defaults to `40`.
*/
maxChunkCountPerGroup?: number
/**
* Never merge chunks bigger than this size, in bytes, with other chunks. This keeps code
* in big chunks from being duplicated across multiple chunks. Defaults to `200000` (200 KB).
*/
maxMergeChunkSize?: number
/**
* Emit each merged production chunk's constituent component chunks alongside it, so the
* browser runtime can load only the ones it doesn't already have. Defaults to `false`.
*/
generateComponentChunks?: boolean
/**
* Minimum size, in bytes, for a component chunk to be emitted on its own when
* `generateComponentChunks` is enabled. Component chunks smaller than this are folded into a
* single remainder chunk. Defaults to `20000` (20 KB).
*/
minComponentChunkSize?: number
}
/**
* (`next --turbopack` only) A custom URL prefix for Web Worker URLs
* produced by `new Worker(new URL(..., import.meta.url))` — both the
* entrypoint URL and the module chunks loaded inside the worker —
* overriding `assetPrefix` for those URLs.
*
* Use this when `assetPrefix` points to a cross-origin CDN: browsers
* reject cross-origin Worker construction, so the entrypoint must stay
* same-origin. Module chunks loaded inside the worker are also routed
* through this prefix because the worker bootstrap requires them to be
* same-origin with the entrypoint. Mirrors webpack's
* `output.workerPublicPath`.
*
* Like `assetPrefix`, the value is a prefix without a trailing slash and
* without `/_next` — `/_next/` is appended automatically. An empty
* string is treated as a literal empty prefix (resulting in same-origin
* `/_next/...` URLs); only `undefined` falls back to `assetPrefix`.
*
* @example
* ```js
* // next.config.js
* module.exports = {
* assetPrefix: 'https://cdn.example.com',
* experimental: {
* turbopackWorkerAssetPrefix: '',
* },
* }
* ```
*/
turbopackWorkerAssetPrefix?: string
/**
* Enable nested async chunking for client side assets. Defaults to true in build mode and false in dev mode.
* This optimization computes all possible paths through dynamic imports in the applications to figure out the modules needed at dynamic imports for every path.
*/
turbopackClientSideNestedAsyncChunking?: boolean
/**
* Enable nested async chunking for server side assets. Defaults to false in dev and build mode.
* This optimization computes all possible paths through dynamic imports in the applications to figure out the modules needed at dynamic imports for every path.
*/
turbopackServerSideNestedAsyncChunking?: boolean
/**
* Enable filesystem cache for the turbopack dev server.
*
* Defaults to `true`.
*/
turbopackFileSystemCacheForDev?: boolean
/**
* Enable filesystem cache for the turbopack build.
*
* Defaults to `true`.
*/
turbopackFileSystemCacheForBuild?: boolean
/**
* When running inside a git worktree, warm-start this worktree's Turbopack
* filesystem cache by seeding it from the main checkout's cache if the
* worktree doesn't have one yet. This is best-effort and never fails a build.
*
* Defaults to `false`.
*/
turbopackSeedCacheFromWorktree?: boolean
/**
* Enable source maps. Defaults to true.
*/
turbopackSourceMaps?: boolean
/**
* Enable extraction of source maps from input files. Defaults to true.
*/
turbopackInputSourceMaps?: boolean
/**
* Currently in active development. This splits modules into fragments and
* chunks only import the used fragments of the modules.
*/
turbopackModuleFragments?: boolean
/**
* Enable removing unused imports for turbopack dev server and build.
*/
turbopackRemoveUnusedImports?: boolean
/**
* Enable removing unused exports for turbopack dev server and build.
*/
turbopackRemoveUnusedExports?: boolean
/**
* Enable local analysis to infer side effect free modules. When enabled, Turbopack will
* analyze module code to determine if it has side effects. This can improve tree shaking
* and bundle size at the cost of some additional analysis.
*
* Defaults to `true`
*/
turbopackInferModuleSideEffects?: boolean
/**
* Enable tree shaking of unused exports from analyzable CommonJS modules in Turbopack.
*
* Defaults to `false`
*/
turbopackCjsTreeShaking?: boolean
/**
* Enable scope hoisting of static CommonJS modules.
*
* Defaults to `false`
*/
turbopackCjsScopeHoisting?: boolean
/**
* Set this to `false` to disable the automatic configuration of the babel loader when a Babel
* configuration file is present. This option is enabled by default.
*
* If this is set to `false`, but `reactCompiler` is `true`, the built-in Babel will