{"version":3,"sources":["../../src/server/config-shared.ts"],"sourcesContent":["import os from 'os'\nimport type { webpack } from 'next/dist/compiled/webpack/webpack'\nimport type { Header, Redirect, Rewrite } from '../lib/load-custom-routes'\nimport { imageConfigDefault } from '../shared/lib/image-config'\nimport type {\n ImageConfig,\n ImageConfigComplete,\n} from '../shared/lib/image-config'\nimport type { SubresourceIntegrityAlgorithm } from '../build/webpack/plugins/subresource-integrity-plugin'\nimport type { WEB_VITALS } from '../shared/lib/utils'\nimport type { NextParsedUrlQuery } from './request-meta'\nimport type { SizeLimit } from '../types'\nimport type { SupportedTestRunners } from '../cli/next-test'\nimport type { ExperimentalPPRConfig } from './lib/experimental/ppr'\nimport { INFINITE_CACHE } from '../lib/constants'\nimport { isStableBuild } from '../shared/lib/errors/canary-only-config-error'\nimport type { FallbackRouteParam } from '../build/static-paths/types'\n\nexport type NextConfigComplete = Required> & {\n images: Required\n typescript: TypeScriptConfig\n configFile: string | undefined\n configFileName: string\n // override NextConfigComplete.experimental.htmlLimitedBots to string\n // because it's not defined in NextConfigComplete.experimental\n htmlLimitedBots: string | undefined\n experimental: ExperimentalConfig\n // The root directory of the distDir. Generally the same as `distDir` but when `isolatedDevBuild`\n // is true it is the parent directory of `distDir`. This is used to ensure that the bundler doesn't\n // traverse into the output directory.\n distDirRoot: string\n}\n\nexport type I18NDomains = readonly DomainLocale[]\n\nexport interface I18NConfig {\n defaultLocale: string\n domains?: I18NDomains\n localeDetection?: false\n locales: readonly string[]\n}\n\nexport interface DomainLocale {\n defaultLocale: string\n domain: string\n http?: true\n locales?: readonly string[]\n}\n\nexport interface TypeScriptConfig {\n /** Do not run TypeScript during production builds (`next build`). */\n ignoreBuildErrors?: boolean\n /** Relative path to a custom tsconfig file */\n tsconfigPath?: string\n}\n\nexport interface EmotionConfig {\n sourceMap?: boolean\n autoLabel?: 'dev-only' | 'always' | 'never'\n labelFormat?: string\n importMap?: {\n [importName: string]: {\n [exportName: string]: {\n canonicalImport?: [string, string]\n styledBaseImport?: [string, string]\n }\n }\n }\n}\n\nexport interface StyledComponentsConfig {\n /**\n * Enabled by default in development, disabled in production to reduce file size,\n * setting this will override the default for all environments.\n */\n displayName?: boolean\n topLevelImportPaths?: string[]\n ssr?: boolean\n fileName?: boolean\n meaninglessFileNames?: string[]\n minify?: boolean\n transpileTemplateLiterals?: boolean\n namespace?: string\n pure?: boolean\n cssProp?: boolean\n}\n\nexport type JSONValue =\n | string\n | number\n | boolean\n | JSONValue[]\n | { [k: string]: JSONValue }\n\n// At the moment, Turbopack options must be JSON-serializable, so restrict values.\nexport type TurbopackLoaderOptions = Record\n\nexport type TurbopackLoaderItem =\n | string\n | {\n loader: string\n options?: TurbopackLoaderOptions\n }\n\nexport type TurbopackLoaderBuiltinCondition =\n | 'browser'\n | 'foreign'\n | 'development'\n | 'production'\n | 'node'\n | 'edge-light'\n\nexport type TurbopackRuleCondition =\n | { all: TurbopackRuleCondition[] }\n | { any: TurbopackRuleCondition[] }\n | { not: TurbopackRuleCondition }\n | TurbopackLoaderBuiltinCondition\n | {\n path?: string | RegExp\n content?: RegExp\n }\n\nexport type TurbopackRuleConfigItem = {\n loaders: TurbopackLoaderItem[]\n as?: string\n condition?: TurbopackRuleCondition\n}\n\n/**\n * This can be an object representing a single configuration, or a list of\n * loaders and/or rule configuration objects.\n *\n * - A list of loader path strings or objects is the \"shorthand\" syntax.\n * - A list of rule configuration objects can be useful when each configuration\n * object has different `condition` fields, but still match the same top-level\n * path glob.\n */\nexport type TurbopackRuleConfigCollection =\n | TurbopackRuleConfigItem\n | (TurbopackLoaderItem | TurbopackRuleConfigItem)[]\n\nexport interface TurbopackOptions {\n /**\n * (`next --turbopack` only) A mapping of aliased imports to modules to load in their place.\n *\n * @see [Resolve Alias](https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack#resolving-aliases)\n */\n resolveAlias?: Record<\n string,\n string | string[] | Record\n >\n\n /**\n * (`next --turbopack` only) A list of extensions to resolve when importing files.\n *\n * @see [Resolve Extensions](https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack#resolving-custom-extensions)\n */\n resolveExtensions?: string[]\n\n /**\n * (`next --turbopack` only) A list of webpack loaders to apply when running with Turbopack.\n *\n * @see [Turbopack Loaders](https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack#configuring-webpack-loaders)\n */\n rules?: Record\n\n /**\n * This is the repo root usually and only files above this\n * directory can be resolved by turbopack.\n */\n root?: string\n\n /**\n * Enables generation of debug IDs in JavaScript bundles and source maps.\n * These debug IDs help with debugging and error tracking by providing stable identifiers.\n *\n * @see https://github.com/tc39/ecma426/blob/main/proposals/debug-id.md TC39 Debug ID Proposal\n */\n debugIds?: boolean\n}\n\nexport interface WebpackConfigContext {\n /** Next.js root directory */\n dir: string\n /** Indicates if the compilation will be done in development */\n dev: boolean\n /** It's `true` for server-side compilation, and `false` for client-side compilation */\n isServer: boolean\n /** The build id, used as a unique identifier between builds */\n buildId: string\n /** The next.config.js merged with default values */\n config: NextConfigComplete\n /** Default loaders used internally by Next.js */\n defaultLoaders: {\n /** Default babel-loader configuration */\n babel: any\n }\n /** Number of total Next.js pages */\n totalPages: number\n /** The webpack configuration */\n webpack: any\n /** The current server runtime */\n nextRuntime?: 'nodejs' | 'edge'\n}\n\nexport interface NextJsWebpackConfig {\n (\n /** Existing Webpack config */\n config: any,\n context: WebpackConfigContext\n ): any\n}\n\n/**\n * Set of options for React Compiler that Next.js currently supports.\n *\n * These options may be changed in breaking ways at any time without notice\n * while support for React Compiler is experimental.\n *\n * @see https://react.dev/reference/react-compiler/configuration\n */\nexport interface ReactCompilerOptions {\n /**\n * Controls the strategy for determining which functions the React Compiler\n * will optimize.\n *\n * The default is `'infer'`, which uses intelligent heuristics to identify\n * React components and hooks.\n *\n * When using `infer`, Next.js applies its own heuristics before calling\n * `react-compiler`. This improves compilation performance by avoiding extra\n * invocations of Babel and reducing redundant parsing of code.\n *\n * @see https://react.dev/reference/react-compiler/compilationMode\n */\n compilationMode?: 'infer' | 'annotation' | 'all'\n /**\n * Controls how the React Compiler handles errors during compilation.\n *\n * The default is `'none'`, which skips components which cannot be compiled.\n *\n * @see https://react.dev/reference/react-compiler/panicThreshold\n */\n panicThreshold?: 'none' | 'critical_errors' | 'all_errors'\n}\n\nexport interface IncomingRequestLoggingConfig {\n /**\n * A regular expression array to match incoming requests that should not be logged.\n * You can specify multiple patterns to match incoming requests that should not be logged.\n */\n ignore?: RegExp[]\n}\n\nexport interface LoggingConfig {\n fetches?: {\n fullUrl?: boolean\n /**\n * If true, fetch requests that are restored from the HMR cache are logged\n * during an HMR refresh request, i.e. when editing a server component.\n */\n hmrRefreshes?: boolean\n }\n\n /**\n * If set to false, incoming request logging is disabled.\n * You can specify a pattern to match incoming requests that should not be logged.\n */\n incomingRequests?: boolean | IncomingRequestLoggingConfig\n}\n\nexport interface ExperimentalConfig {\n adapterPath?: string\n useSkewCookie?: boolean\n /** @deprecated use top-level `cacheHandlers` instead */\n cacheHandlers?: NextConfig['cacheHandlers']\n multiZoneDraftMode?: boolean\n appNavFailHandling?: boolean\n prerenderEarlyExit?: boolean\n linkNoTouchStart?: boolean\n caseSensitiveRoutes?: boolean\n clientSegmentCache?: boolean | 'client-only'\n\n /**\n * The origins that are allowed to write the rewritten headers when\n * performing a non-relative rewrite. When undefined, no non-relative\n * rewrites will get the rewrite headers.\n */\n clientParamParsingOrigins?: string[]\n dynamicOnHover?: boolean\n preloadEntriesOnStart?: boolean\n clientRouterFilter?: boolean\n clientRouterFilterRedirects?: boolean\n /**\n * This config can be used to override the cache behavior for the client router.\n * These values indicate the time, in seconds, that the cache should be considered\n * reusable. When the `prefetch` Link prop is left unspecified, this will use the `dynamic` value.\n * When the `prefetch` Link prop is set to `true`, this will use the `static` value.\n */\n staleTimes?: {\n dynamic?: number\n static?: number\n }\n /**\n * @deprecated use top-level `cacheLife` instead\n */\n cacheLife?: NextConfig['cacheLife']\n // decimal for percent for possible false positives\n // e.g. 0.01 for 10% potential false matches lower\n // percent increases size of the filter\n clientRouterFilterAllowedRate?: number\n /**\n * @deprecated Use `externalProxyRewritesResolve` instead.\n */\n externalMiddlewareRewritesResolve?: boolean\n externalProxyRewritesResolve?: boolean\n extensionAlias?: Record\n allowedRevalidateHeaderKeys?: string[]\n fetchCacheKeyPrefix?: string\n imgOptConcurrency?: number | null\n imgOptTimeoutInSeconds?: number\n imgOptMaxInputPixels?: number\n imgOptSequentialRead?: boolean | null\n imgOptSkipMetadata?: boolean | null\n optimisticClientCache?: boolean\n /**\n * @deprecated use config.expireTime instead\n */\n expireTime?: number\n /**\n * @deprecated Use `proxyPrefetch` instead.\n */\n middlewarePrefetch?: 'strict' | 'flexible'\n proxyPrefetch?: 'strict' | 'flexible'\n manualClientBasePath?: boolean\n /**\n * CSS Chunking strategy. Defaults to `true` (\"loose\" mode), which guesses dependencies\n * between CSS files to keep ordering of them.\n * An alternative is 'strict', which will try to keep correct ordering as\n * much as possible, even when this leads to many requests.\n */\n cssChunking?: boolean | 'strict'\n disablePostcssPresetEnv?: boolean\n cpus?: number\n memoryBasedWorkersCount?: boolean\n proxyTimeout?: number\n isrFlushToDisk?: boolean\n workerThreads?: boolean\n // optimizeCss can be boolean or critters' option object\n // Use Record as critters doesn't export its Option type\n // https://github.com/GoogleChromeLabs/critters/blob/a590c05f9197b656d2aeaae9369df2483c26b072/packages/critters/src/index.d.ts\n optimizeCss?: boolean | Record\n nextScriptWorkers?: boolean\n scrollRestoration?: boolean\n externalDir?: boolean\n disableOptimizedLoading?: boolean\n\n /** @deprecated A no-op as of Next 16, size metrics were removed from the build output. */\n gzipSize?: boolean\n craCompat?: boolean\n esmExternals?: boolean | 'loose'\n fullySpecified?: boolean\n urlImports?: NonNullable['buildHttp']\n swcTraceProfiling?: boolean\n forceSwcTransforms?: boolean\n\n swcPlugins?: Array<[string, Record]>\n largePageDataBytes?: number\n /**\n * If set to `false`, webpack won't fall back to polyfill Node.js modules in the browser\n * Full list of old polyfills is accessible here:\n * [webpack/webpack#ModuleNotoundError.js#L13-L42](https://github.com/webpack/webpack/blob/2a0536cf510768111a3a6dceeb14cb79b9f59273/lib/ModuleNotFoundError.js#L13-L42)\n */\n fallbackNodePolyfills?: false\n sri?: {\n algorithm?: SubresourceIntegrityAlgorithm\n }\n\n webVitalsAttribution?: Array<(typeof WEB_VITALS)[number]>\n\n /**\n * Automatically apply the \"modularizeImports\" optimization to imports of the specified packages.\n */\n optimizePackageImports?: string[]\n\n /**\n * Optimize React APIs for server builds.\n */\n optimizeServerReact?: boolean\n\n /**\n * A target memory limit for turbo, in bytes.\n */\n turbopackMemoryLimit?: number\n\n /**\n * Enable minification. Defaults to true in build mode and false in dev mode.\n */\n turbopackMinify?: boolean\n\n /**\n * Enable support for `with {type: \"module\"}` for ESM imports.\n */\n turbopackImportTypeBytes?: boolean\n\n /**\n * Enable scope hoisting. Defaults to true in build mode. Always disabled in development mode.\n */\n turbopackScopeHoisting?: boolean\n\n /**\n * Enable filesystem cache for the turbopack dev server.\n */\n turbopackFileSystemCacheForDev?: boolean\n\n /**\n * Enable filesystem cache for the turbopack build.\n */\n turbopackFileSystemCacheForBuild?: boolean\n\n /**\n * Enable source maps. Defaults to true.\n */\n turbopackSourceMaps?: boolean\n\n /**\n * Enable tree shaking for the turbopack dev server and build.\n */\n turbopackTreeShaking?: boolean\n\n /**\n * Enable removing unused exports for turbopack dev server and build.\n */\n turbopackRemoveUnusedExports?: boolean\n\n /**\n * Use the system-provided CA roots instead of bundled CA roots for external HTTPS requests\n * made by Turbopack. Currently this is only used for fetching data from Google Fonts.\n *\n * This may be useful in cases where you or an employer are MITMing traffic.\n *\n * This option is experimental because:\n * - This may cause small performance problems, as it uses [`rustls-native-certs`](\n * https://github.com/rustls/rustls-native-certs).\n * - In the future, this may become the default, and this option may be eliminated, once\n * is resolved.\n *\n * Users who need to configure this behavior system-wide can override the project\n * configuration using the `NEXT_TURBOPACK_EXPERIMENTAL_USE_SYSTEM_TLS_CERTS=1` environment\n * variable.\n *\n * This option is ignored on Windows on ARM, where the native TLS implementation is always\n * used.\n *\n * If you need to set a proxy, Turbopack [respects the common `HTTP_PROXY` and `HTTPS_PROXY`\n * environment variable convention](https://docs.rs/reqwest/latest/reqwest/#proxies). HTTP\n * proxies are supported, SOCKS proxies are not currently supported.\n */\n turbopackUseSystemTlsCerts?: boolean\n\n /**\n * Set this to `false` to disable the automatic configuration of the babel loader when a Babel\n * configuration file is present. This option is enabled by default.\n *\n * If this is set to `false`, but `reactCompiler` is `true`, the built-in Babel will\n * still be configured, but any Babel configuration files on disk will be ignored. If you wish to\n * use React Compiler with a different manually-configured `babel-loader`, you should disable both\n * this and `reactCompiler`.\n */\n turbopackUseBuiltinBabel?: boolean\n\n /**\n * Set this to `false` to disable the automatic configuration of the sass loader. The sass loader\n * configuration is enabled by default.\n */\n turbopackUseBuiltinSass?: boolean\n\n /**\n * The module ID strategy to use for Turbopack.\n * If not set, the default is `'named'` for development and `'deterministic'`\n * for production.\n */\n turbopackModuleIds?: 'named' | 'deterministic'\n\n /**\n * For use with `@next/mdx`. Compile MDX files using the new Rust compiler.\n * @see https://nextjs.org/docs/app/api-reference/next-config-js/mdxRs\n */\n mdxRs?:\n | boolean\n | {\n development?: boolean\n jsx?: boolean\n jsxRuntime?: string\n jsxImportSource?: string\n providerImportSource?: string\n mdxType?: 'gfm' | 'commonmark'\n }\n\n /**\n * Enable type checking for Link and Router.push, etc.\n * @deprecated Use `typedRoutes` instead — this feature is now stable.\n * @see https://nextjs.org/docs/app/api-reference/config/typescript#statically-typed-links\n */\n typedRoutes?: boolean\n\n /**\n * Enable type-checking and autocompletion for environment variables.\n *\n * @default false\n */\n typedEnv?: boolean\n\n /**\n * Runs the compilations for server and edge in parallel instead of in serial.\n * This will make builds faster if there is enough server and edge functions\n * in the application at the cost of more memory.\n *\n * NOTE: This option is only valid when the build process can use workers. See\n * the documentation for `webpackBuildWorker` for more details.\n */\n parallelServerCompiles?: boolean\n\n /**\n * Runs the logic to collect build traces for the server routes in parallel\n * with other work during the compilation. This will increase the speed of\n * the build at the cost of more memory. This option may incur some additional\n * work compared to if the option was disabled since the work is started\n * before data from the client compilation is available to potentially reduce\n * the amount of code that needs to be traced. Despite that, this may still\n * result in faster builds for some applications.\n *\n * Valid values are:\n * - `true`: Collect the server build traces in parallel.\n * - `false`: Do not collect the server build traces in parallel.\n * - `undefined`: Collect server build traces in parallel only in the `experimental-compile` mode.\n *\n * NOTE: This option is only valid when the build process can use workers. See\n * the documentation for `webpackBuildWorker` for more details.\n */\n parallelServerBuildTraces?: boolean\n\n /**\n * Run the Webpack build in a separate process to optimize memory usage during build.\n * Valid values are:\n * - `false`: Disable the Webpack build worker\n * - `true`: Enable the Webpack build worker\n * - `undefined`: Enable the Webpack build worker only if the webpack config is not customized\n */\n webpackBuildWorker?: boolean\n\n /**\n * Enables optimizations to reduce memory usage in Webpack. This reduces the max size of the heap\n * but may increase compile times slightly.\n * Valid values are:\n * - `false`: Disable Webpack memory optimizations (default).\n * - `true`: Enables Webpack memory optimizations.\n */\n webpackMemoryOptimizations?: boolean\n\n /**\n * The array of the meta tags to the client injected by tracing propagation data.\n */\n clientTraceMetadata?: string[]\n\n /**\n * @deprecated This configuration option has been merged into `cacheComponents`.\n * The Partial Prerendering feature is still available via `cacheComponents`.\n */\n ppr?: ExperimentalPPRConfig\n\n /**\n * Enables experimental taint APIs in React.\n * Using this feature will enable the `react@experimental` for the `app` directory.\n */\n taint?: boolean\n\n /**\n * Uninstalls all \"unhandledRejection\" and \"uncaughtException\" listeners from\n * the global process so that we can override the behavior, which in some\n * runtimes is to exit the process.\n *\n * This is experimental until we've considered the impact in various\n * deployment environments.\n */\n removeUncaughtErrorAndRejectionListeners?: boolean\n\n /**\n * During an RSC request, validates that the request headers match the\n * cache-busting search parameter sent by the client.\n */\n validateRSCRequestHeaders?: boolean\n\n serverActions?: {\n /**\n * Allows adjusting body parser size limit for server actions.\n */\n bodySizeLimit?: SizeLimit\n\n /**\n * Allowed origins that can bypass Server Action's CSRF check. This is helpful\n * when you have reverse proxy in front of your app.\n * @example\n * [\"my-app.com\", \"*.my-app.com\"]\n */\n allowedOrigins?: string[]\n }\n\n /**\n * enables the minification of server code.\n */\n serverMinification?: boolean\n\n /**\n * Enables source maps generation for the server production bundle.\n */\n serverSourceMaps?: boolean\n\n /**\n * @internal Used by the Next.js internals only.\n */\n trustHostHeader?: boolean\n /**\n * @internal Used by the Next.js internals only.\n */\n isExperimentalCompile?: boolean\n\n useWasmBinary?: boolean\n\n /**\n * Use lightningcss instead of postcss-loader\n */\n useLightningcss?: boolean\n\n /**\n * Enables view transitions by using the {@link https://react.dev/reference/react/ViewTransition ViewTransition} Component.\n */\n viewTransition?: boolean\n\n /**\n * Enables `fetch` requests to be proxied to the experimental test proxy server\n */\n testProxy?: boolean\n\n /**\n * Set a default test runner to be used by `next experimental-test`.\n */\n defaultTestRunner?: SupportedTestRunners\n /**\n * Allow NODE_ENV=development even for `next build`.\n */\n allowDevelopmentBuild?: true\n /**\n * @deprecated use `config.bundlePagesRouterDependencies` instead\n *\n */\n bundlePagesExternals?: boolean\n /**\n * @deprecated use `config.serverExternalPackages` instead\n *\n */\n serverComponentsExternalPackages?: string[]\n\n /**\n * When enabled, in dev mode, Next.js will send React's debug info through the\n * WebSocket connection, instead of including it in the main RSC payload.\n */\n reactDebugChannel?: boolean\n\n /**\n * @deprecated use top-level `cacheComponents` instead\n */\n cacheComponents?: boolean\n\n /**\n * The number of times to retry static generation (per page) before giving up.\n */\n staticGenerationRetryCount?: number\n\n /**\n * The amount of pages to export per worker during static generation.\n */\n staticGenerationMaxConcurrency?: number\n\n /**\n * The minimum number of pages to be chunked into each export worker.\n */\n staticGenerationMinPagesPerWorker?: number\n\n /**\n * Allows previously fetched data to be re-used when editing server components.\n */\n serverComponentsHmrCache?: boolean\n\n /**\n * Render