vinext 0.0.52 → 0.0.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/build/clean-output.d.ts +14 -0
- package/dist/build/clean-output.js +36 -0
- package/dist/build/clean-output.js.map +1 -0
- package/dist/build/prerender.d.ts +6 -2
- package/dist/build/prerender.js +49 -11
- package/dist/build/prerender.js.map +1 -1
- package/dist/build/run-prerender.js +10 -1
- package/dist/build/run-prerender.js.map +1 -1
- package/dist/build/static-export.d.ts +5 -0
- package/dist/build/static-export.js +8 -3
- package/dist/build/static-export.js.map +1 -1
- package/dist/cli.js +19 -4
- package/dist/cli.js.map +1 -1
- package/dist/client/instrumentation-client-inject.d.ts +34 -0
- package/dist/client/instrumentation-client-inject.js +57 -0
- package/dist/client/instrumentation-client-inject.js.map +1 -0
- package/dist/client/navigation-runtime.d.ts +14 -1
- package/dist/client/navigation-runtime.js +16 -1
- package/dist/client/navigation-runtime.js.map +1 -1
- package/dist/client/vinext-next-data.d.ts +2 -1
- package/dist/client/vinext-next-data.js.map +1 -1
- package/dist/client/window-next.d.ts +10 -2
- package/dist/client/window-next.js.map +1 -1
- package/dist/cloudflare/tpr.js +1 -1
- package/dist/cloudflare/tpr.js.map +1 -1
- package/dist/config/config-matchers.js +2 -1
- package/dist/config/config-matchers.js.map +1 -1
- package/dist/config/next-config.d.ts +12 -3
- package/dist/config/next-config.js +44 -14
- package/dist/config/next-config.js.map +1 -1
- package/dist/deploy.js +29 -7
- package/dist/deploy.js.map +1 -1
- package/dist/entries/app-rsc-entry.d.ts +4 -2
- package/dist/entries/app-rsc-entry.js +23 -3
- package/dist/entries/app-rsc-entry.js.map +1 -1
- package/dist/entries/pages-client-entry.js +22 -1
- package/dist/entries/pages-client-entry.js.map +1 -1
- package/dist/entries/pages-server-entry.js +211 -31
- package/dist/entries/pages-server-entry.js.map +1 -1
- package/dist/index.js +29 -6
- package/dist/index.js.map +1 -1
- package/dist/plugins/fonts.js +25 -2
- package/dist/plugins/fonts.js.map +1 -1
- package/dist/routing/route-trie.js +13 -18
- package/dist/routing/route-trie.js.map +1 -1
- package/dist/routing/utils.d.ts +11 -1
- package/dist/routing/utils.js +15 -1
- package/dist/routing/utils.js.map +1 -1
- package/dist/server/api-handler.js +18 -9
- package/dist/server/api-handler.js.map +1 -1
- package/dist/server/app-browser-action-result.d.ts +16 -1
- package/dist/server/app-browser-action-result.js +15 -1
- package/dist/server/app-browser-action-result.js.map +1 -1
- package/dist/server/app-browser-entry.js +22 -12
- package/dist/server/app-browser-entry.js.map +1 -1
- package/dist/server/app-elements.js +1 -1
- package/dist/server/app-fallback-renderer.d.ts +12 -3
- package/dist/server/app-fallback-renderer.js +10 -5
- package/dist/server/app-fallback-renderer.js.map +1 -1
- package/dist/server/app-history-state.js +6 -2
- package/dist/server/app-history-state.js.map +1 -1
- package/dist/server/app-interception-context-header.d.ts +33 -0
- package/dist/server/app-interception-context-header.js +44 -0
- package/dist/server/app-interception-context-header.js.map +1 -0
- package/dist/server/app-mounted-slots-header.d.ts +19 -0
- package/dist/server/app-mounted-slots-header.js +40 -1
- package/dist/server/app-mounted-slots-header.js.map +1 -1
- package/dist/server/app-optimistic-routing.js +26 -18
- package/dist/server/app-optimistic-routing.js.map +1 -1
- package/dist/server/app-page-boundary-render.d.ts +1 -0
- package/dist/server/app-page-boundary-render.js +2 -0
- package/dist/server/app-page-boundary-render.js.map +1 -1
- package/dist/server/app-page-boundary.d.ts +1 -0
- package/dist/server/app-page-boundary.js +2 -0
- package/dist/server/app-page-boundary.js.map +1 -1
- package/dist/server/app-page-cache.d.ts +2 -0
- package/dist/server/app-page-cache.js +7 -1
- package/dist/server/app-page-cache.js.map +1 -1
- package/dist/server/app-page-dispatch.d.ts +3 -0
- package/dist/server/app-page-dispatch.js +11 -4
- package/dist/server/app-page-dispatch.js.map +1 -1
- package/dist/server/app-page-element-builder.d.ts +2 -1
- package/dist/server/app-page-element-builder.js +5 -2
- package/dist/server/app-page-element-builder.js.map +1 -1
- package/dist/server/app-page-execution.d.ts +1 -0
- package/dist/server/app-page-execution.js +2 -0
- package/dist/server/app-page-execution.js.map +1 -1
- package/dist/server/app-page-head.d.ts +1 -0
- package/dist/server/app-page-head.js +8 -0
- package/dist/server/app-page-head.js.map +1 -1
- package/dist/server/app-page-render-observation.js +1 -1
- package/dist/server/app-page-render.d.ts +1 -0
- package/dist/server/app-page-render.js +5 -2
- package/dist/server/app-page-render.js.map +1 -1
- package/dist/server/app-page-response.d.ts +11 -1
- package/dist/server/app-page-response.js +14 -2
- package/dist/server/app-page-response.js.map +1 -1
- package/dist/server/app-page-route-wiring.d.ts +1 -0
- package/dist/server/app-page-route-wiring.js +19 -6
- package/dist/server/app-page-route-wiring.js.map +1 -1
- package/dist/server/app-page-stream.d.ts +1 -0
- package/dist/server/app-page-stream.js +2 -0
- package/dist/server/app-page-stream.js.map +1 -1
- package/dist/server/app-route-handler-dispatch.d.ts +1 -0
- package/dist/server/app-route-handler-dispatch.js +3 -0
- package/dist/server/app-route-handler-dispatch.js.map +1 -1
- package/dist/server/app-route-handler-execution.d.ts +1 -0
- package/dist/server/app-route-handler-execution.js +1 -0
- package/dist/server/app-route-handler-execution.js.map +1 -1
- package/dist/server/app-route-handler-response.js +1 -1
- package/dist/server/app-rsc-handler.d.ts +2 -0
- package/dist/server/app-rsc-handler.js +18 -9
- package/dist/server/app-rsc-handler.js.map +1 -1
- package/dist/server/app-rsc-request-normalization.js +3 -2
- package/dist/server/app-rsc-request-normalization.js.map +1 -1
- package/dist/server/app-segment-config.d.ts +4 -1
- package/dist/server/app-segment-config.js +6 -1
- package/dist/server/app-segment-config.js.map +1 -1
- package/dist/server/app-server-action-execution.d.ts +1 -0
- package/dist/server/app-server-action-execution.js +4 -0
- package/dist/server/app-server-action-execution.js.map +1 -1
- package/dist/server/app-ssr-entry.js +39 -3
- package/dist/server/app-ssr-entry.js.map +1 -1
- package/dist/server/app-ssr-stream.d.ts +24 -1
- package/dist/server/app-ssr-stream.js +78 -5
- package/dist/server/app-ssr-stream.js.map +1 -1
- package/dist/server/app-static-generation.d.ts +1 -0
- package/dist/server/app-static-generation.js +2 -1
- package/dist/server/app-static-generation.js.map +1 -1
- package/dist/server/default-not-found-module.d.ts +20 -0
- package/dist/server/default-not-found-module.js +20 -0
- package/dist/server/default-not-found-module.js.map +1 -0
- package/dist/server/dev-server.d.ts +1 -1
- package/dist/server/dev-server.js +23 -7
- package/dist/server/dev-server.js.map +1 -1
- package/dist/server/headers.d.ts +5 -1
- package/dist/server/headers.js +5 -1
- package/dist/server/headers.js.map +1 -1
- package/dist/server/image-optimization.d.ts +13 -4
- package/dist/server/image-optimization.js +15 -4
- package/dist/server/image-optimization.js.map +1 -1
- package/dist/server/middleware.js +1 -1
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/pages-api-route.d.ts +18 -0
- package/dist/server/pages-api-route.js +3 -1
- package/dist/server/pages-api-route.js.map +1 -1
- package/dist/server/pages-body-parser-config.d.ts +60 -0
- package/dist/server/pages-body-parser-config.js +79 -0
- package/dist/server/pages-body-parser-config.js.map +1 -0
- package/dist/server/pages-data-route.js +1 -0
- package/dist/server/pages-data-route.js.map +1 -1
- package/dist/server/pages-default-404.d.ts +31 -0
- package/dist/server/pages-default-404.js +40 -0
- package/dist/server/pages-default-404.js.map +1 -0
- package/dist/server/pages-node-compat.d.ts +10 -0
- package/dist/server/pages-node-compat.js +12 -1
- package/dist/server/pages-node-compat.js.map +1 -1
- package/dist/server/pages-page-data.d.ts +40 -0
- package/dist/server/pages-page-data.js +16 -14
- package/dist/server/pages-page-data.js.map +1 -1
- package/dist/server/pages-page-response.d.ts +2 -0
- package/dist/server/pages-page-response.js +11 -8
- package/dist/server/pages-page-response.js.map +1 -1
- package/dist/server/prerender-route-params.d.ts +14 -0
- package/dist/server/prerender-route-params.js +94 -0
- package/dist/server/prerender-route-params.js.map +1 -0
- package/dist/server/prod-server.d.ts +3 -23
- package/dist/server/prod-server.js +40 -57
- package/dist/server/prod-server.js.map +1 -1
- package/dist/server/proxy-trust.d.ts +41 -0
- package/dist/server/proxy-trust.js +70 -0
- package/dist/server/proxy-trust.js.map +1 -0
- package/dist/server/request-pipeline.d.ts +3 -3
- package/dist/server/request-pipeline.js +5 -4
- package/dist/server/request-pipeline.js.map +1 -1
- package/dist/server/seed-cache.js +12 -6
- package/dist/server/seed-cache.js.map +1 -1
- package/dist/server/static-file-cache.js +1 -1
- package/dist/server/static-file-cache.js.map +1 -1
- package/dist/server/streaming-metadata.d.ts +5 -0
- package/dist/server/streaming-metadata.js +10 -0
- package/dist/server/streaming-metadata.js.map +1 -0
- package/dist/shims/app-router-scroll-state.d.ts +12 -0
- package/dist/shims/app-router-scroll-state.js +38 -0
- package/dist/shims/app-router-scroll-state.js.map +1 -0
- package/dist/shims/app-router-scroll.d.ts +14 -0
- package/dist/shims/app-router-scroll.js +100 -0
- package/dist/shims/app-router-scroll.js.map +1 -0
- package/dist/shims/before-interactive-context.d.ts +30 -0
- package/dist/shims/before-interactive-context.js +10 -0
- package/dist/shims/before-interactive-context.js.map +1 -0
- package/dist/shims/cache-runtime.d.ts +1 -1
- package/dist/shims/cache-runtime.js +14 -1
- package/dist/shims/cache-runtime.js.map +1 -1
- package/dist/shims/default-not-found.d.ts +12 -0
- package/dist/shims/default-not-found.js +61 -0
- package/dist/shims/default-not-found.js.map +1 -0
- package/dist/shims/font-local.d.ts +5 -0
- package/dist/shims/font-local.js +6 -2
- package/dist/shims/font-local.js.map +1 -1
- package/dist/shims/head.js +4 -4
- package/dist/shims/head.js.map +1 -1
- package/dist/shims/headers.d.ts +6 -2
- package/dist/shims/headers.js +64 -21
- package/dist/shims/headers.js.map +1 -1
- package/dist/shims/image.d.ts +1 -1
- package/dist/shims/image.js +4 -4
- package/dist/shims/image.js.map +1 -1
- package/dist/shims/internal/pages-data-target.d.ts +58 -0
- package/dist/shims/internal/pages-data-target.js +91 -0
- package/dist/shims/internal/pages-data-target.js.map +1 -0
- package/dist/shims/internal/pages-data-url.d.ts +42 -0
- package/dist/shims/internal/pages-data-url.js +73 -0
- package/dist/shims/internal/pages-data-url.js.map +1 -0
- package/dist/shims/link.js +59 -9
- package/dist/shims/link.js.map +1 -1
- package/dist/shims/metadata.d.ts +2 -1
- package/dist/shims/metadata.js +61 -2
- package/dist/shims/metadata.js.map +1 -1
- package/dist/shims/navigation.js +32 -9
- package/dist/shims/navigation.js.map +1 -1
- package/dist/shims/router.js +376 -77
- package/dist/shims/router.js.map +1 -1
- package/dist/shims/script.js +86 -12
- package/dist/shims/script.js.map +1 -1
- package/dist/shims/server.js +1 -0
- package/dist/shims/server.js.map +1 -1
- package/dist/shims/url-utils.d.ts +2 -1
- package/dist/shims/url-utils.js +15 -4
- package/dist/shims/url-utils.js.map +1 -1
- package/dist/utils/html-limited-bots.d.ts +5 -0
- package/dist/utils/html-limited-bots.js +15 -0
- package/dist/utils/html-limited-bots.js.map +1 -0
- package/dist/utils/query.d.ts +6 -0
- package/dist/utils/query.js +10 -1
- package/dist/utils/query.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-config.js","names":[],"sources":["../../src/config/next-config.ts"],"sourcesContent":["/**\n * next.config.js / next.config.mjs / next.config.ts parser\n *\n * Loads the Next.js config file (if present) and extracts supported options.\n * Unsupported options are logged as warnings.\n */\nimport path from \"node:path\";\nimport { createRequire } from \"node:module\";\nimport fs from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { randomUUID } from \"node:crypto\";\nimport commonjs from \"vite-plugin-commonjs\";\nimport { PHASE_DEVELOPMENT_SERVER } from \"vinext/shims/constants\";\nimport { normalizePageExtensions } from \"../routing/file-matcher.js\";\nimport { applyLocaleToRoutes, isExternalUrl } from \"./config-matchers.js\";\nimport { loadTsconfigPathAliasesForRoot } from \"./tsconfig-paths.js\";\n\n/**\n * Parse a body size limit value (string or number) into bytes.\n * Accepts Next.js-style strings like \"1mb\", \"500kb\", \"10mb\", bare number strings like \"1048576\" (bytes),\n * and numeric values. Supports b, kb, mb, gb, tb, pb units.\n * Returns the default 1MB if the value is not provided or invalid.\n * Throws if the parsed value is less than 1.\n */\nexport function parseBodySizeLimit(value: string | number | undefined | null): number {\n if (value === undefined || value === null) return 1 * 1024 * 1024;\n if (typeof value === \"number\") {\n if (value < 1) throw new Error(`Body size limit must be a positive number, got ${value}`);\n return value;\n }\n const trimmed = value.trim();\n const match = trimmed.match(/^(\\d+(?:\\.\\d+)?)\\s*(b|kb|mb|gb|tb|pb)?$/i);\n if (!match) {\n console.warn(\n `[vinext] Invalid bodySizeLimit value: \"${value}\". Expected a number or a string like \"1mb\", \"500kb\". Falling back to 1MB.`,\n );\n return 1 * 1024 * 1024;\n }\n const num = parseFloat(match[1]);\n const unit = (match[2] ?? \"b\").toLowerCase();\n let bytes: number;\n switch (unit) {\n case \"b\":\n bytes = Math.floor(num);\n break;\n case \"kb\":\n bytes = Math.floor(num * 1024);\n break;\n case \"mb\":\n bytes = Math.floor(num * 1024 * 1024);\n break;\n case \"gb\":\n bytes = Math.floor(num * 1024 * 1024 * 1024);\n break;\n case \"tb\":\n bytes = Math.floor(num * 1024 * 1024 * 1024 * 1024);\n break;\n case \"pb\":\n bytes = Math.floor(num * 1024 * 1024 * 1024 * 1024 * 1024);\n break;\n default:\n return 1 * 1024 * 1024;\n }\n if (bytes < 1) throw new Error(`Body size limit must be a positive number, got ${bytes}`);\n return bytes;\n}\n\nexport type HasCondition = {\n type: \"header\" | \"cookie\" | \"query\" | \"host\";\n key: string;\n value?: string;\n};\n\nexport type NextRedirect = {\n source: string;\n destination: string;\n permanent: boolean;\n has?: HasCondition[];\n missing?: HasCondition[];\n /**\n * When true (the default with i18n configured), Next.js prepends an internal\n * locale alternation to the source so the rule matches locale-prefixed paths.\n * When `false`, the source is left untouched and matches the raw path,\n * letting user-supplied `:locale` segments capture the prefix themselves.\n * See https://nextjs.org/docs/app/api-reference/config/next-config-js/redirects#locale\n */\n locale?: false;\n /**\n * When `false`, the rule is NOT prefixed with `basePath`. Source and\n * destination are matched/applied verbatim. Mirrors Next.js's\n * `Redirect.basePath: false` opt-out — see\n * `.nextjs-ref/packages/next/src/lib/load-custom-routes.ts:26`.\n */\n basePath?: false;\n};\n\nexport type NextRewrite = {\n source: string;\n destination: string;\n has?: HasCondition[];\n missing?: HasCondition[];\n /** See {@link NextRedirect.locale}. */\n locale?: false;\n /** See {@link NextRedirect.basePath}. */\n basePath?: false;\n};\n\nexport type NextHeader = {\n source: string;\n has?: HasCondition[];\n missing?: HasCondition[];\n headers: Array<{ key: string; value: string }>;\n /** See {@link NextRedirect.basePath}. */\n basePath?: false;\n};\n\nexport type NextI18nConfig = {\n /** List of supported locales */\n locales: string[];\n /** The default locale (used when no locale prefix is in the URL) */\n defaultLocale: string;\n /**\n * Whether to auto-detect locale from Accept-Language header.\n * Defaults to true in Next.js.\n */\n localeDetection?: boolean;\n /**\n * Domain-based routing. Each domain maps to a specific locale.\n */\n domains?: Array<{\n domain: string;\n defaultLocale: string;\n locales?: string[];\n http?: boolean;\n }>;\n};\n\n/**\n * MDX compilation options extracted from @next/mdx config.\n * These are passed through to @mdx-js/rollup so that custom\n * remark/rehype/recma plugins configured in next.config work with Vite.\n */\nexport type MdxOptions = {\n remarkPlugins?: unknown[];\n rehypePlugins?: unknown[];\n recmaPlugins?: unknown[];\n};\n\nexport type NextConfig = {\n /** Additional env variables */\n env?: Record<string, string>;\n /** Base URL path prefix */\n basePath?: string;\n /**\n * Prefix applied to every emitted JS/CSS/image/static asset URL.\n * Accepts a path prefix (e.g. `/custom-asset-prefix`) or an absolute\n * URL (e.g. `https://cdn.example.com`). Distinct from `basePath`:\n * `basePath` affects route URLs; `assetPrefix` only affects asset URLs.\n * @see https://nextjs.org/docs/app/api-reference/config/next-config-js/assetPrefix\n */\n assetPrefix?: string;\n /** Whether to add trailing slashes */\n trailingSlash?: boolean;\n /** Internationalization routing config */\n i18n?: NextI18nConfig;\n /** URL redirect rules */\n redirects?: () => Promise<NextRedirect[]> | NextRedirect[];\n /** URL rewrite rules */\n rewrites?: () =>\n | Promise<\n | NextRewrite[]\n | {\n beforeFiles: NextRewrite[];\n afterFiles: NextRewrite[];\n fallback: NextRewrite[];\n }\n >\n | NextRewrite[]\n | {\n beforeFiles: NextRewrite[];\n afterFiles: NextRewrite[];\n fallback: NextRewrite[];\n };\n /** Custom response headers */\n headers?: () => Promise<NextHeader[]> | NextHeader[];\n /** Image optimization config */\n images?: {\n remotePatterns?: Array<{\n protocol?: string;\n hostname: string;\n port?: string;\n pathname?: string;\n search?: string;\n }>;\n domains?: string[];\n unoptimized?: boolean;\n /** Allowed device widths for image optimization. Defaults to Next.js defaults: [640, 750, 828, 1080, 1200, 1920, 2048, 3840] */\n deviceSizes?: number[];\n /** Allowed image sizes for fixed-width images. Defaults to Next.js defaults: [16, 32, 48, 64, 96, 128, 256, 384] */\n imageSizes?: number[];\n /** Allow SVG images through the image optimization endpoint. SVG can contain scripts, so only enable if you trust all image sources. */\n dangerouslyAllowSVG?: boolean;\n /** Allow image optimization for hostnames that resolve to private IP addresses. This is a security risk (SSRF) — only enable for private networks when you understand the risk. */\n dangerouslyAllowLocalIP?: boolean;\n /** Content-Disposition header for image responses. Defaults to \"inline\". */\n contentDispositionType?: \"inline\" | \"attachment\";\n /** Content-Security-Policy header for image responses. Defaults to \"script-src 'none'; frame-src 'none'; sandbox;\" */\n contentSecurityPolicy?: string;\n };\n /** Build output mode: 'export' for full static export, 'standalone' for single server */\n output?: \"export\" | \"standalone\";\n /** File extensions treated as routable pages/routes (Next.js pageExtensions) */\n pageExtensions?: string[];\n /** Extra origins allowed to access the dev server. */\n allowedDevOrigins?: string[];\n /** Maximum age in seconds for stale ISR entries before blocking regeneration. */\n expireTime?: number;\n /**\n * Enable Cache Components (Next.js 16).\n * When true, enables the \"use cache\" directive for pages, components, and functions.\n * Replaces the removed experimental.ppr and experimental.dynamicIO flags.\n */\n cacheComponents?: boolean;\n /**\n * Enables source maps while generating static pages.\n * Helps with errors during the prerender phase in `vinext build`.\n * Defaults to `true`. Set to `false` to disable.\n */\n enablePrerenderSourceMaps?: boolean;\n /** Transpile packages (Vite handles this natively) */\n transpilePackages?: string[];\n /**\n * Packages that should be treated as server-external (not bundled by Vite).\n * Corresponds to Next.js `serverExternalPackages` (or the legacy\n * `experimental.serverComponentsExternalPackages`).\n */\n serverExternalPackages?: string[];\n /** Webpack config (ignored — we use Vite) */\n webpack?: unknown;\n /**\n * Path to a custom cache handler module (e.g., KV, Redis, DynamoDB).\n * Accepts relative paths, absolute paths, or file:// URLs from import.meta.resolve().\n * When \"type\": \"module\" is set in package.json, use import.meta.resolve() instead of\n * require.resolve() to get a valid path.\n */\n cacheHandler?: string;\n /**\n * Maximum memory size (bytes) for the default in-memory cache handler.\n * Set to 0 to disable in-memory caching entirely.\n */\n cacheMaxMemorySize?: number;\n /**\n * Custom build ID generator. If provided, called once at build/dev start.\n * Must return a non-empty string, or null to use the default random ID.\n */\n generateBuildId?: () => string | null | Promise<string | null>;\n /** Identifier for deployment-aware cache keys and version skew protection. */\n deploymentId?: string;\n /** Any other options */\n [key: string]: unknown;\n};\n\nexport type NextConfigFactory = (\n phase: string,\n opts: { defaultConfig: NextConfig },\n) => NextConfig | Promise<NextConfig>;\n\nexport type NextConfigInput = NextConfig | NextConfigFactory;\n\n/**\n * Resolved configuration with all async values awaited.\n */\nexport type ResolvedNextConfig = {\n env: Record<string, string>;\n basePath: string;\n /**\n * Resolved `assetPrefix` from next.config.\n *\n * Empty string when unset. Trailing slashes are trimmed. May be either:\n * - a path prefix beginning with `/` (e.g. `\"/custom-asset-prefix\"`), or\n * - an absolute URL with `http(s)://` origin (e.g. `\"https://cdn.example.com\"`\n * or `\"https://cdn.example.com/sub\"`).\n *\n * Mirrors Next.js semantics — `assetPrefix` controls emitted asset URLs\n * only; route URLs continue to live under `basePath`.\n *\n * @see https://nextjs.org/docs/app/api-reference/config/next-config-js/assetPrefix\n */\n assetPrefix: string;\n trailingSlash: boolean;\n output: \"\" | \"export\" | \"standalone\";\n pageExtensions: string[];\n cacheComponents: boolean;\n redirects: NextRedirect[];\n rewrites: {\n beforeFiles: NextRewrite[];\n afterFiles: NextRewrite[];\n fallback: NextRewrite[];\n };\n headers: NextHeader[];\n images: NextConfig[\"images\"];\n i18n: NextI18nConfig | null;\n /** MDX remark/rehype/recma plugins extracted from @next/mdx config */\n mdx: MdxOptions | null;\n /** Explicit module aliases preserved from wrapped next.config plugins. */\n aliases: Record<string, string>;\n /** Extra allowed origins for dev server access (from allowedDevOrigins). */\n allowedDevOrigins: string[];\n /** Extra allowed origins for server action CSRF validation (from experimental.serverActions.allowedOrigins). */\n serverActionsAllowedOrigins: string[];\n /** Packages whose barrel imports should be optimized (from experimental.optimizePackageImports). */\n optimizePackageImports: string[];\n /** Parsed body size limit for server actions in bytes (from experimental.serverActions.bodySizeLimit). Defaults to 1MB. */\n serverActionsBodySizeLimit: number;\n /** Route-level expire fallback in seconds for ISR entries with numeric revalidate. */\n expireTime: number;\n /**\n * Packages that should be treated as server-external (not bundled by Vite).\n * Sourced from `serverExternalPackages` or the legacy\n * `experimental.serverComponentsExternalPackages` in next.config.\n */\n serverExternalPackages: string[];\n /** Enable sourcemaps for prerender error stack traces. Defaults to true. */\n enablePrerenderSourceMaps: boolean;\n /** Resolved build ID (from generateBuildId, or a random UUID if not provided). */\n buildId: string;\n /** Resolved deployment ID from next.config.js or NEXT_DEPLOYMENT_ID. */\n deploymentId: string | undefined;\n /**\n * Path to a custom cache handler module. file:// URLs are resolved to\n * filesystem paths via fileURLToPath() during config resolution.\n */\n cacheHandler: string | undefined;\n /**\n * Maximum memory size (bytes) for the default in-memory cache handler.\n * Set to 0 to disable in-memory caching entirely.\n */\n cacheMaxMemorySize: number | undefined;\n /**\n * Concatenated hash salt from `experimental.outputHashSalt` config option\n * and `NEXT_HASH_SALT` environment variable. Empty string when neither is set.\n * When non-empty, mix into content-addressed output filenames so hash values\n * change without modifying source — useful for cache-busting after CDN poisoning.\n */\n hashSalt: string;\n /**\n * Raw `sassOptions` object from next.config (or `null` when unset). vinext\n * passes the relevant keys through to Vite's `css.preprocessorOptions.scss`\n * so SCSS variables defined via `additionalData` / `prependData`, partials\n * resolved via `includePaths` / `loadPaths`, and a custom `implementation`\n * all behave the same as in Next.js.\n *\n * Kept loose (`Record<string, unknown> | null`) to match Next.js's typing —\n * the object is forwarded to Sass and may contain any modern Sass option.\n */\n sassOptions: Record<string, unknown> | null;\n};\n\n// Mirrors Next.js's accepted set in packages/next/src/shared/lib/constants.ts\n// (`.js`/`.mjs`/`.ts`/`.mts`) and adds `.cjs` for parity with vinext's own\n// loader, which has historically accepted CJS configs as well. The order is\n// significant: findNextConfigPath returns the first match, so prefer the more\n// modern flavours first.\nconst CONFIG_FILES = [\n \"next.config.ts\",\n \"next.config.mts\",\n \"next.config.mjs\",\n \"next.config.js\",\n \"next.config.cjs\",\n];\nconst DEFAULT_EXPIRE_TIME = 31_536_000;\n\n/**\n * Check whether an error indicates a CJS module was loaded in an ESM context\n * (i.e. the file uses `require()` which is not available in ESM).\n */\nfunction isCjsError(e: unknown): boolean {\n if (!(e instanceof Error)) return false;\n const msg = e.message;\n return (\n msg.includes(\"require is not a function\") ||\n msg.includes(\"require is not defined\") ||\n msg.includes(\"exports is not defined\") ||\n msg.includes(\"module is not defined\") ||\n msg.includes(\"__dirname is not defined\") ||\n msg.includes(\"__filename is not defined\")\n );\n}\n\n// Dev-server phase is the safe default for config loading: it enables all\n// optional config sections (headers, redirects, rewrites) without triggering\n// build-only behaviour. Used in two default parameter values below to avoid\n// repeating PHASE_DEVELOPMENT_SERVER inline.\nconst DEFAULT_PHASE = PHASE_DEVELOPMENT_SERVER;\n\n/**\n * Emit a warning when config loading fails, with a targeted hint for\n * known plugin wrappers that are unnecessary in vinext.\n */\nfunction warnConfigLoadFailure(filename: string, err: Error): void {\n const msg = err.message ?? \"\";\n const stack = err.stack ?? \"\";\n const isNextIntlPlugin =\n msg.includes(\"next-intl\") ||\n stack.includes(\"next-intl/plugin\") ||\n stack.includes(\"next-intl/dist\");\n\n console.log();\n console.error(`[vinext] Failed to load ${filename}: ${msg}`);\n console.log();\n if (isNextIntlPlugin) {\n console.warn(\n \"[vinext] Hint: createNextIntlPlugin() is not needed with vinext. \" +\n \"Remove the next-intl/plugin wrapper from your next.config — \" +\n \"vinext auto-detects next-intl and registers the i18n config alias automatically.\",\n );\n }\n}\n\n/**\n * Resolve a Next-style config value, calling it if it's a function-form config\n * (Next.js supports `module.exports = (phase, opts) => config`).\n */\nasync function resolveConfigValue(\n config: unknown,\n phase: string = DEFAULT_PHASE,\n): Promise<NextConfig> {\n if (typeof config === \"function\") {\n const result = await config(phase, {\n defaultConfig: {},\n });\n return result as NextConfig;\n }\n return config as NextConfig;\n}\n\n/**\n * Named export attached by `cjsGlobalsInjectorPlugin` when the source\n * statically looks like it assigns to `module.exports`. Holds the wrapper\n * `module` object so {@link unwrapConfig} can read back the user's CJS-style\n * export. Pure-ESM configs skip the wrapper entirely and rely on the ESM\n * `default` export instead.\n */\nconst VINEXT_CJS_EXPORTS_KEY = \"__vinext_cjs_exports\";\n\n/**\n * Companion named export pointing at the initial empty `{}` that the wrapper\n * is constructed with. Lets {@link unwrapConfig} distinguish \"user reassigned\n * or mutated module.exports\" from \"module.exports is still the untouched\n * empty wrapper\" — the latter happens when {@link reassignsModuleExports}\n * matches inside a string or comment (a harmless false positive that should\n * still fall through to the ESM `default` export).\n */\nconst VINEXT_CJS_INITIAL_KEY = \"__vinext_cjs_initial_exports\";\n\n/**\n * Unwrap the config value from a loaded module namespace.\n *\n * Prefers `module.exports` (CJS style) when the config file reassigned it,\n * otherwise falls back to `default`/the namespace itself. Mirrors Next.js's\n * behaviour, where the config is loaded through `Module._compile` and CJS\n * assignments override any ESM-style exports.\n *\n * The presence of the `__vinext_cjs_exports` named export is the static\n * signal (set by `cjsGlobalsInjectorPlugin` when `reassignsModuleExports`\n * matched) that this file might use CJS-style exports. We then disambiguate\n * \"user actually touched module.exports\" from \"static heuristic was a false\n * positive\" by comparing identity against the initial empty wrapper: if\n * `module.exports` is still the original `{}`, fall back to ESM `default`.\n */\nasync function unwrapConfig(\n // oxlint-disable-next-line typescript/no-explicit-any\n mod: any,\n phase: string = PHASE_DEVELOPMENT_SERVER,\n): Promise<NextConfig> {\n const cjsModule = mod?.[VINEXT_CJS_EXPORTS_KEY];\n const cjsExports = cjsModule?.exports;\n const cjsInitial = mod?.[VINEXT_CJS_INITIAL_KEY];\n const userTouchedExports =\n cjsExports !== undefined &&\n cjsExports !== null &&\n // Either reassigned outright, or mutated keys on the initial object.\n (cjsExports !== cjsInitial ||\n (typeof cjsExports === \"object\" && Object.keys(cjsExports).length > 0));\n if (userTouchedExports) {\n return await resolveConfigValue(cjsExports, phase);\n }\n return await resolveConfigValue(mod.default ?? mod, phase);\n}\n\n/**\n * Resolve a path through filesystem symlinks, falling back to the original\n * path when the file does not exist (e.g. virtual ids, query-suffixed ids).\n */\nfunction safeRealpath(p: string): string {\n try {\n return fs.realpathSync(p);\n } catch {\n return p;\n }\n}\n\n/**\n * Whole-word substring check for any of the CJS-style globals that the\n * injector plugin would shim. Used to skip the transform entirely for the\n * common case where the config is pure ESM (no `__filename`, `__dirname`,\n * `require`, `module`, or `exports` references).\n *\n * False positives are harmless: a comment, string literal, or unrelated\n * identifier like `node:module` will trigger the transform unnecessarily,\n * but the resulting injection is idempotent and the loaded config is\n * unaffected. False negatives would be a correctness bug, so we err on the\n * side of matching too eagerly.\n *\n * Note: `\\bexports\\b` does not match `export default` (different word\n * boundaries), and `\\brequire\\b` does not match `requireSomething`.\n */\nexport function referencesCjsGlobals(source: string): boolean {\n return /\\b(?:__filename|__dirname|require|module|exports)\\b/.test(source);\n}\n\n/**\n * Static heuristic: returns true when the source appears to assign to\n * `module.exports` — either via `module.exports = …`, `module.exports.foo = …`,\n * or `module.exports[…] = …`. Used to decide whether the injector plugin\n * needs to wire up the wrapper `module` object so {@link unwrapConfig} can\n * read back the user's CJS-style export.\n *\n * Pure-ESM configs skip the wrapper entirely, which means a faster transform\n * (no extra `export const` line) and a simpler unwrap path (no need to\n * disambiguate \"initial empty object\" from \"user reassigned to {}\").\n *\n * Like {@link referencesCjsGlobals}, false positives are harmless: at worst\n * we emit an unused `__vinext_cjs_exports` named export, and `unwrapConfig`\n * still prefers it (it points at an empty object, which then gets treated\n * as the config — equivalent to today's sentinel logic for pure-ESM files\n * that happen to mention `module.exports` only in a string).\n */\nexport function reassignsModuleExports(source: string): boolean {\n // Match `module.exports` followed by `=` (not `==` / `===`), `.identifier =`,\n // or `[...] =`. Whitespace allowed around the dot.\n return /\\bmodule\\s*\\.\\s*exports\\b\\s*(?:=(?!=)|\\.\\s*[A-Za-z_$][\\w$]*\\s*=(?!=)|\\[)/.test(source);\n}\n\n/**\n * Vite plugin that prepends CJS-style globals (`__filename`, `__dirname`,\n * `module`, `exports`, `require`) to the next.config.* source before\n * Vite's module runner evaluates it.\n *\n * Next.js's `next.config.ts` loader (packages/next/src/build/next-config-ts/\n * transpile-config.ts → require-hook.ts) feeds the file through Node's\n * `Module._compile`, which provides these CJS globals even when the source\n * uses ESM syntax. Upstream test fixtures in `test/e2e/app-dir/next-config-ts*`\n * rely on that, e.g. `node-api-cjs/next.config.ts` reads\n * `fs.readFileSync(path.join(__dirname, 'foo.txt'), 'utf8')`. vinext loads\n * configs through Vite's ESM-only module runner, so we inject the same\n * globals as plain `const` declarations.\n *\n * For configs that don't reference any CJS global (the common case — every\n * upstream `next-config-ts` fixture except `node-api-cjs` is pure ESM) we\n * skip the transform entirely; see {@link referencesCjsGlobals}.\n *\n * `module.exports` reassignment is preserved by exposing the injected\n * `module` object as a named export (see {@link VINEXT_CJS_EXPORTS_KEY}) and\n * reading it back in {@link unwrapConfig}.\n */\nfunction cjsGlobalsInjectorPlugin(configPath: string): {\n name: string;\n enforce: \"pre\";\n // oxlint-disable-next-line typescript/no-explicit-any\n transform(this: unknown, code: string, id: string): any;\n} {\n // Resolve symlinks once so we can compare against the (possibly\n // symlink-resolved) id Vite passes to `transform`. On macOS, `/var/folders`\n // is a symlink to `/private/var/folders`, so the temp-dir path in tests\n // would otherwise mismatch.\n const normalizedTarget = safeRealpath(path.resolve(configPath));\n return {\n name: \"vinext:next-config-cjs-globals\",\n enforce: \"pre\",\n transform(code: string, id: string) {\n // Vite may pass an id with a query suffix (?v=...) or as a file URL.\n const idPath = id.startsWith(\"file://\") ? fileURLToPath(id) : id.split(\"?\")[0];\n const resolvedId = safeRealpath(path.resolve(idPath));\n if (resolvedId !== normalizedTarget) return null;\n\n // Fast path: skip the transform when the source contains no bareword\n // reference to any of the shimmed globals. The vast majority of\n // `next.config.ts` files are pure ESM (`export default { ... }`) and\n // pay no cost from this plugin.\n if (!referencesCjsGlobals(code)) return null;\n\n const dirname = path.dirname(normalizedTarget);\n // JSON.stringify produces safe JS string literals for paths.\n const filenameLiteral = JSON.stringify(normalizedTarget);\n const dirnameLiteral = JSON.stringify(dirname);\n const requireBaseLiteral = JSON.stringify(path.join(dirname, \"package.json\"));\n\n // Only wire up the wrapper `module` object — and the corresponding\n // named export read by unwrapConfig — when the source statically looks\n // like it assigns to module.exports. Pure-ESM configs avoid the extra\n // export and the unwrap-by-wrapper code path.\n const needsModuleWrapper = reassignsModuleExports(code);\n const moduleLines = needsModuleWrapper\n ? `const __vinextInitialExports = {};\\n` +\n `const module = { exports: __vinextInitialExports };\\n` +\n `const exports = module.exports;\\n` +\n `export const ${VINEXT_CJS_EXPORTS_KEY} = module;\\n` +\n `export const ${VINEXT_CJS_INITIAL_KEY} = __vinextInitialExports;\\n`\n : \"\";\n\n // Preamble runs after ESM imports are hoisted; the const bindings shadow\n // any global lookups the source would otherwise perform.\n const preamble =\n `import { createRequire as __vinextCreateRequire } from \"node:module\";\\n` +\n `const __filename = ${filenameLiteral};\\n` +\n `const __dirname = ${dirnameLiteral};\\n` +\n `const require = __vinextCreateRequire(${requireBaseLiteral});\\n` +\n moduleLines;\n\n return {\n code: preamble + code,\n map: null,\n };\n },\n };\n}\n\nexport function findNextConfigPath(root: string): string | null {\n for (const filename of CONFIG_FILES) {\n const configPath = path.join(root, filename);\n if (fs.existsSync(configPath)) return configPath;\n }\n return null;\n}\n\nexport async function resolveNextConfigInput(\n config: NextConfigInput,\n phase: string = PHASE_DEVELOPMENT_SERVER,\n): Promise<NextConfig> {\n // Inline vinext({ nextConfig }) already receives the config value itself,\n // not a module namespace object, so do not treat a \"default\" key specially.\n return await resolveConfigValue(config, phase);\n}\n\n/**\n * Load a CJS-flavoured next.config.{js,cjs} via createRequire.\n *\n * For `.cjs` (or `.js` in a non-type-module package) Node's loader picks the\n * right format automatically and `require()` just works. For `.js` in a\n * `\"type\": \"module\"` package, Node infers ESM from package.json and the file\n * fails with `require is not defined`. In that case we copy the source to a\n * sibling temp `.cjs` (where the explicit extension forces CJS regardless of\n * the parent type field) and require *that*. Relative imports inside the\n * config still resolve against the original directory.\n */\nasync function loadConfigViaRequire(\n configPath: string,\n root: string,\n phase: string,\n): Promise<NextConfig> {\n const require = createRequire(path.join(root, \"package.json\"));\n try {\n return await unwrapConfig(require(configPath), phase);\n } catch (e) {\n if (!isCjsError(e) || !configPath.endsWith(\".js\")) throw e;\n return await loadConfigViaCjsTempCopy(configPath, root, phase);\n }\n}\n\nasync function loadConfigViaCjsTempCopy(\n configPath: string,\n root: string,\n phase: string,\n): Promise<NextConfig> {\n const dir = path.dirname(configPath);\n // Hidden + uniquely-named to avoid clashing with user files or being picked\n // up by next.js's own config scanner if a concurrent next dev is running.\n const tmpPath = path.join(dir, `.vinext-next-config.${process.pid}.${Date.now()}.cjs`);\n fs.copyFileSync(configPath, tmpPath);\n try {\n const require = createRequire(path.join(root, \"package.json\"));\n return await unwrapConfig(require(tmpPath), phase);\n } finally {\n try {\n fs.unlinkSync(tmpPath);\n } catch {\n // Best-effort cleanup; a stray tmp file is harmless.\n }\n }\n}\n\n/**\n * Find and load the next.config file from the project root.\n * Returns null if no config file is found.\n *\n * Attempts Vite's module runner first so TS configs and extensionless local\n * imports (e.g. `import \"./env\"`) resolve consistently. If loading fails due\n * to CJS constructs (`require`, `module.exports`), falls back to `createRequire`\n * so common CJS plugin wrappers (nextra, @next/mdx, etc.) still work, including\n * `next.config.js` files written in CJS syntax inside a `\"type\": \"module\"`\n * package (the common shape after `vinext init`).\n */\nexport async function loadNextConfig(\n root: string,\n phase: string = DEFAULT_PHASE,\n): Promise<NextConfig | null> {\n const configPath = findNextConfigPath(root);\n if (!configPath) return null;\n\n const filename = path.basename(configPath);\n\n // Mirror Next.js: read `compilerOptions.paths` from the project's\n // tsconfig.json so aliased imports inside next.config.ts (e.g.\n // `import { foo } from '@/foo'`) resolve at config-load time. Next.js\n // passes these to SWC; we pass them to Vite's resolver as `resolve.alias`.\n // See packages/next/src/build/next-config-ts/transpile-config.ts.\n const tsconfigAliases = loadTsconfigPathAliasesForRoot(root);\n\n // Symlink-resolved config path, used by the `commonjs()` filter below to\n // exclude the config file itself. macOS uses /private/var symlinks, so\n // string-compare without realpath would falsely include the config.\n const normalizedConfigPath = safeRealpath(path.resolve(configPath));\n\n try {\n // Load config via Vite's module runner (TS + extensionless import support)\n const { runnerImport } = await import(\"vite\");\n const { module: mod } = await runnerImport(configPath, {\n root,\n logLevel: \"error\",\n clearScreen: false,\n resolve: {\n alias: tsconfigAliases,\n // Include `.cjs` and `.cts` so `vite-plugin-commonjs` recognises\n // those extensions (the plugin keys off `config.resolve.extensions`,\n // which on Vite defaults to `[.mjs, .js, .mts, .ts, .jsx, .tsx,\n // .json]` — no CJS extensions). This also lets the runner's resolver\n // find `./foo` style imports that resolve to a `.cjs`/`.cts` sibling.\n extensions: [\".mjs\", \".js\", \".cjs\", \".mts\", \".ts\", \".cts\", \".jsx\", \".tsx\", \".json\"],\n },\n // Only inject CJS globals for TypeScript config flavours. Next.js\n // applies its `Module._compile` / SWC pipeline (which exposes the\n // CJS globals) exclusively to `.ts`/`.mts`/`.cts`; legacy `.js`/`.cjs`\n // configs are loaded through Node and already have `require`/`module`,\n // and `.mjs` configs are explicitly ESM-only.\n //\n // Pair that with `vite-plugin-commonjs` (the same plugin used for\n // application code in index.ts) so sibling imports like `.cjs`/`.cts`,\n // or `.js`/`.ts` files that assign to `module.exports`, are converted\n // to ESM before Vite's runner evaluates them. The default `filter`\n // skips `node_modules`; we opt back in so bare-import packages\n // imported by next.config.* (e.g. CJS plugin wrappers) keep working —\n // this mirrors how Next.js's SWC pipeline handles those imports too.\n //\n // The config file itself is excluded from `commonjs()`: when it needs\n // CJS globals it goes through `cjsGlobalsInjectorPlugin`, which sets\n // up a specific `__vinext_cjs_exports` wiring that `unwrapConfig` reads\n // back. Letting both plugins inject `module = { exports: {} }` for the\n // same source produces an `Identifier 'module' has already been\n // declared` syntax error.\n plugins: [\n ...(/\\.[cm]?ts$/.test(configPath) ? [cjsGlobalsInjectorPlugin(configPath)] : []),\n commonjs({\n filter: (id: string) => {\n const idPath = id.startsWith(\"file://\") ? fileURLToPath(id) : id.split(\"?\")[0];\n const resolvedId = safeRealpath(path.resolve(idPath));\n if (resolvedId === normalizedConfigPath) return false;\n // Returning `true` forces the transform to run even for ids\n // inside `node_modules` (default behaviour skips them);\n // `undefined` falls through to the plugin's default for\n // user code.\n return id.includes(\"node_modules\") ? true : undefined;\n },\n }),\n ],\n });\n return await unwrapConfig(mod, phase);\n } catch (e) {\n // If the error indicates a CJS file loaded in ESM context, retry with\n // createRequire which provides a proper CommonJS environment.\n if (isCjsError(e) && (filename.endsWith(\".js\") || filename.endsWith(\".cjs\"))) {\n try {\n return await loadConfigViaRequire(configPath, root, phase);\n } catch (e2) {\n warnConfigLoadFailure(filename, e2 as Error);\n throw e2;\n }\n }\n\n warnConfigLoadFailure(filename, e as Error);\n throw e;\n }\n}\n\n/**\n * Generate a UUID that doesn't contain \"ad\" to avoid false-positive ad-blocker hits.\n * Mirrors Next.js's own nanoid retry loop.\n */\nfunction safeUUID(): string {\n let id = randomUUID();\n while (/ad/i.test(id)) id = randomUUID();\n return id;\n}\n\n/**\n * Call the user's generateBuildId function and validate its return value.\n * Follows Next.js semantics: null return falls back to a random UUID; any\n * other non-string throws. Leading/trailing whitespace is trimmed.\n *\n * @see https://nextjs.org/docs/app/api-reference/config/next-config-js/generateBuildId\n */\nasync function resolveBuildId(\n generate: (() => string | null | Promise<string | null>) | undefined,\n): Promise<string> {\n if (!generate) return safeUUID();\n\n const result = await generate();\n\n if (result === null) return safeUUID();\n\n if (typeof result !== \"string\") {\n throw new Error(\n \"generateBuildId did not return a string. https://nextjs.org/docs/messages/generatebuildid-not-a-string\",\n );\n }\n\n const trimmed = result.trim();\n if (trimmed.length === 0) {\n throw new Error(\n \"generateBuildId returned an empty string. https://nextjs.org/docs/messages/generatebuildid-not-a-string\",\n );\n }\n\n return trimmed;\n}\n\n/**\n * Normalize the `assetPrefix` option from next.config.\n *\n * Accepts both absolute URLs (`https://cdn.example.com[/subpath]`) and\n * path prefixes (`/custom-asset-prefix`). Trailing slashes are trimmed.\n * Empty/whitespace-only strings are treated as unset and return `\"\"`.\n *\n * Path prefixes that omit the leading slash get one added so they always\n * begin with `/` — this matches how Next.js routes match against them.\n *\n * Non-string values are rejected to surface config mistakes early.\n *\n * @see https://nextjs.org/docs/app/api-reference/config/next-config-js/assetPrefix\n */\nexport function normalizeAssetPrefix(value: unknown): string {\n if (value === undefined || value === null || value === \"\") return \"\";\n\n if (typeof value !== \"string\") {\n throw new Error(\n `Invalid \\`assetPrefix\\` configuration: must be a string, got ${typeof value}. ` +\n `Accepts a path prefix (\"/custom-asset-prefix\") or an absolute URL ` +\n `(\"https://cdn.example.com\").`,\n );\n }\n\n // Avoid `replace(/\\/+$/, \"\")` — CodeQL flags it as polynomial backtracking\n // on uncontrolled input. An explicit loop has the same effect with linear time.\n let trimmed = value.trim();\n while (trimmed.endsWith(\"/\")) trimmed = trimmed.slice(0, -1);\n if (trimmed === \"\") return \"\";\n\n // Absolute URL — keep origin verbatim, validate parseability so a typo\n // surfaces at config-load time instead of as a confusing build error.\n if (/^https?:\\/\\//i.test(trimmed)) {\n if (!URL.canParse(trimmed)) {\n throw new Error(`Invalid \\`assetPrefix\\` configuration: \"${value}\" is not a parseable URL.`);\n }\n return trimmed;\n }\n\n // Path prefix — always begin with \"/\", consistent with basePath.\n return trimmed.startsWith(\"/\") ? trimmed : `/${trimmed}`;\n}\n\nfunction resolveDeploymentId(configDeploymentId: unknown): string | undefined {\n const deploymentId =\n configDeploymentId !== undefined ? configDeploymentId : process.env.NEXT_DEPLOYMENT_ID;\n if (deploymentId === undefined || deploymentId === \"\") return undefined;\n\n if (typeof deploymentId !== \"string\") {\n throw new Error(\n \"Invalid `deploymentId` configuration: must be a string. https://nextjs.org/docs/messages/deploymentid-not-a-string\",\n );\n }\n\n if (!/^[a-zA-Z0-9_-]+$/.test(deploymentId)) {\n throw new Error(\n \"Invalid `deploymentId` configuration: contains invalid characters. Only alphanumeric characters, hyphens, and underscores are allowed. https://nextjs.org/docs/messages/deploymentid-invalid-characters\",\n );\n }\n\n return deploymentId;\n}\n\n/**\n * Converts a cache handler path to a filesystem path.\n * ESM's import.meta.resolve() returns file:// URLs which break when concatenated\n * with path operations like path.join or path.relative.\n * @param filePath - Absolute path, relative path, or file:// URL (e.g. from import.meta.resolve)\n * @returns A filesystem path suitable for path operations\n */\nfunction resolveCacheHandlerPathToFilesystem(filePath: string): string {\n if (filePath.startsWith(\"file://\")) {\n return fileURLToPath(filePath);\n }\n return filePath;\n}\n\n/**\n * Resolve a NextConfig into a fully-resolved ResolvedNextConfig.\n * Awaits async functions for redirects/rewrites/headers.\n */\nexport async function resolveNextConfig(\n config: NextConfig | null,\n root: string = process.cwd(),\n): Promise<ResolvedNextConfig> {\n if (!config) {\n const buildId = await resolveBuildId(undefined);\n const deploymentId = resolveDeploymentId(undefined);\n const resolved: ResolvedNextConfig = {\n env: {},\n basePath: \"\",\n assetPrefix: \"\",\n trailingSlash: false,\n output: \"\",\n pageExtensions: normalizePageExtensions(),\n cacheComponents: false,\n redirects: [],\n rewrites: { beforeFiles: [], afterFiles: [], fallback: [] },\n headers: [],\n images: undefined,\n i18n: null,\n mdx: null,\n aliases: {},\n allowedDevOrigins: [],\n serverActionsAllowedOrigins: [],\n optimizePackageImports: [],\n serverActionsBodySizeLimit: 1 * 1024 * 1024,\n expireTime: DEFAULT_EXPIRE_TIME,\n serverExternalPackages: [],\n cacheHandler: undefined,\n cacheMaxMemorySize: undefined,\n enablePrerenderSourceMaps: true,\n hashSalt: process.env.NEXT_HASH_SALT ?? \"\",\n buildId,\n deploymentId,\n sassOptions: null,\n };\n detectNextIntlConfig(root, resolved);\n return resolved;\n }\n\n // Resolve redirects\n let redirects: NextRedirect[] = [];\n if (config.redirects) {\n const result = await config.redirects();\n redirects = Array.isArray(result) ? result : [];\n }\n\n // Resolve rewrites\n let rewrites = {\n beforeFiles: [] as NextRewrite[],\n afterFiles: [] as NextRewrite[],\n fallback: [] as NextRewrite[],\n };\n if (config.rewrites) {\n const result = await config.rewrites();\n if (Array.isArray(result)) {\n rewrites.afterFiles = result;\n } else {\n rewrites = {\n beforeFiles: result.beforeFiles ?? [],\n afterFiles: result.afterFiles ?? [],\n fallback: result.fallback ?? [],\n };\n }\n }\n\n {\n const allRewrites = [...rewrites.beforeFiles, ...rewrites.afterFiles, ...rewrites.fallback];\n const externalRewrites = allRewrites.filter((rewrite) => isExternalUrl(rewrite.destination));\n\n if (externalRewrites.length > 0) {\n const noun = externalRewrites.length === 1 ? \"external rewrite\" : \"external rewrites\";\n const listing = externalRewrites\n .map((rewrite) => ` ${rewrite.source} → ${rewrite.destination}`)\n .join(\"\\n\");\n\n console.warn(\n `[vinext] Found ${externalRewrites.length} ${noun} that proxy requests to external origins:\\n` +\n `${listing}\\n` +\n `Request headers, including credential headers (cookie, authorization, proxy-authorization, x-api-key), ` +\n `are forwarded to the external origin to match Next.js behavior. ` +\n `If you do not want to forward credentials, use an API route or route handler where you control exactly which headers are sent.`,\n );\n }\n }\n\n // Resolve headers\n let headers: NextHeader[] = [];\n if (config.headers) {\n headers = await config.headers();\n }\n\n // Probe wrapped webpack config once so alias extraction and MDX extraction\n // observe the same mock environment.\n const webpackProbe = await probeWebpackConfig(config, root);\n const mdx = webpackProbe.mdx;\n const aliases = {\n ...extractTurboAliases(config, root),\n ...webpackProbe.aliases,\n };\n\n const allowedDevOrigins = Array.isArray(config.allowedDevOrigins) ? config.allowedDevOrigins : [];\n\n // Resolve serverActions.allowedOrigins and bodySizeLimit from experimental config\n const experimental = config.experimental as Record<string, unknown> | undefined;\n const serverActionsConfig = experimental?.serverActions as Record<string, unknown> | undefined;\n const serverActionsAllowedOrigins = Array.isArray(serverActionsConfig?.allowedOrigins)\n ? (serverActionsConfig.allowedOrigins as string[])\n : [];\n const serverActionsBodySizeLimit = parseBodySizeLimit(\n serverActionsConfig?.bodySizeLimit as string | number | undefined,\n );\n\n // Resolve hashSalt from experimental.outputHashSalt config + NEXT_HASH_SALT env var.\n // Next.js concatenates them: config value first, then env var.\n const configOutputHashSalt = experimental?.outputHashSalt as string | undefined;\n const hashSalt = (configOutputHashSalt ?? \"\") + (process.env.NEXT_HASH_SALT ?? \"\");\n\n // Resolve optimizePackageImports from experimental config\n const rawOptimize = experimental?.optimizePackageImports;\n const optimizePackageImports = Array.isArray(rawOptimize)\n ? rawOptimize.filter((x): x is string => typeof x === \"string\")\n : [];\n\n // Resolve serverExternalPackages — support the current top-level key and the\n // legacy experimental.serverComponentsExternalPackages name that Next.js still\n // accepts (it moved out of experimental in Next.js 14.2).\n const legacyServerComponentsExternal = experimental?.serverComponentsExternalPackages;\n const serverExternalPackages: string[] = Array.isArray(config.serverExternalPackages)\n ? (config.serverExternalPackages as string[])\n : Array.isArray(legacyServerComponentsExternal)\n ? (legacyServerComponentsExternal as string[])\n : [];\n\n // Warn about unsupported experimental.swcEnvOptions. vinext uses Vite for\n // transforms, not SWC, so automatic polyfill injection is not applicable.\n if (experimental?.swcEnvOptions !== undefined) {\n console.warn(\n '[vinext] next.config option \"experimental.swcEnvOptions\" is not applicable and will be ignored (vinext uses Vite, not SWC). ' +\n \"A Vite-compatible polyfill solution may be explored in the future.\",\n );\n }\n\n // `next/root-params` is now stable — no longer requires an experimental flag.\n if (experimental?.rootParams !== undefined) {\n console.warn(\n \"[vinext] `experimental.rootParams` is no longer needed, because `next/root-params` is available by default. \" +\n \"You can remove it from next.config.(js|mjs|ts).\",\n );\n }\n\n // Warn about unsupported webpack usage. We preserve alias injection and\n // extract MDX settings, but all other webpack customization is still ignored.\n if (config.webpack !== undefined) {\n if (mdx || Object.keys(webpackProbe.aliases).length > 0) {\n console.warn(\n '[vinext] next.config option \"webpack\" is only partially supported. ' +\n \"vinext preserves resolve.alias entries and MDX loader settings, but other webpack customization is ignored\",\n );\n } else {\n console.warn(\n '[vinext] next.config option \"webpack\" is not yet supported and will be ignored',\n );\n }\n }\n\n const output = config.output ?? \"\";\n if (output && output !== \"export\" && output !== \"standalone\") {\n console.warn(`[vinext] Unknown output mode \"${output as string}\", ignoring`);\n }\n\n const pageExtensions = normalizePageExtensions(config.pageExtensions);\n\n // Parse i18n config\n let i18n: NextI18nConfig | null = null;\n if (config.i18n) {\n i18n = {\n locales: config.i18n.locales,\n defaultLocale: config.i18n.defaultLocale,\n localeDetection: config.i18n.localeDetection ?? true,\n domains: config.i18n.domains,\n };\n }\n\n const buildId = await resolveBuildId(\n config.generateBuildId as (() => string | null | Promise<string | null>) | undefined,\n );\n const deploymentId = resolveDeploymentId(config.deploymentId);\n\n // Resolve cacheHandler path — handle file:// URLs from import.meta.resolve()\n const cacheHandler: string | undefined =\n typeof config.cacheHandler === \"string\"\n ? resolveCacheHandlerPathToFilesystem(config.cacheHandler)\n : undefined;\n\n // Resolve cacheMaxMemorySize\n const cacheMaxMemorySize: number | undefined =\n typeof config.cacheMaxMemorySize === \"number\" ? config.cacheMaxMemorySize : undefined;\n\n // Apply Next.js i18n locale-prefix transformation to redirects/rewrites.\n // When i18n is configured and a rule does NOT carry `locale: false`, the\n // source is rewritten to match locale-prefixed URLs. Rules with\n // `locale: false` are left untouched so user-supplied `:locale` segments\n // can capture the prefix themselves. Mirrors processRoutes() in\n // packages/next/src/lib/load-custom-routes.ts.\n if (i18n) {\n const opts = { trailingSlash: config.trailingSlash ?? false };\n redirects = applyLocaleToRoutes(redirects, i18n, \"redirect\", opts);\n rewrites = {\n beforeFiles: applyLocaleToRoutes(rewrites.beforeFiles, i18n, \"rewrite\", opts),\n afterFiles: applyLocaleToRoutes(rewrites.afterFiles, i18n, \"rewrite\", opts),\n fallback: applyLocaleToRoutes(rewrites.fallback, i18n, \"rewrite\", opts),\n };\n }\n\n const resolved: ResolvedNextConfig = {\n env: config.env ?? {},\n basePath: config.basePath ?? \"\",\n assetPrefix: normalizeAssetPrefix(config.assetPrefix),\n trailingSlash: config.trailingSlash ?? false,\n output: output === \"export\" || output === \"standalone\" ? output : \"\",\n pageExtensions,\n cacheComponents: config.cacheComponents ?? false,\n redirects,\n rewrites,\n headers,\n images: config.images,\n i18n,\n mdx,\n aliases,\n allowedDevOrigins,\n serverActionsAllowedOrigins,\n optimizePackageImports,\n serverActionsBodySizeLimit,\n expireTime: typeof config.expireTime === \"number\" ? config.expireTime : DEFAULT_EXPIRE_TIME,\n serverExternalPackages,\n cacheHandler,\n cacheMaxMemorySize,\n enablePrerenderSourceMaps: config.enablePrerenderSourceMaps ?? true,\n hashSalt,\n buildId,\n deploymentId,\n sassOptions:\n config.sassOptions && typeof config.sassOptions === \"object\"\n ? (config.sassOptions as Record<string, unknown>)\n : null,\n };\n\n // Auto-detect next-intl (lowest priority — explicit aliases from\n // webpack/turbopack already in `aliases` take precedence)\n detectNextIntlConfig(root, resolved);\n\n // Parity with Next.js: when `basePath` is configured but `assetPrefix` is\n // not, fall back to using `basePath` as the asset prefix. This ensures the\n // on-disk layout under `dist/client` is rooted at `<basePath>/_next/static/`\n // (matching the URL Vite emits via `base + assetsDir`), so Cloudflare's\n // ASSETS binding and the prod-server static layer can serve requests\n // verbatim without any runtime path rewriting.\n //\n // Mirrors Next.js: packages/next/src/server/config.ts:509-532\n // https://github.com/vercel/next.js/blob/canary/packages/next/src/server/config.ts\n // Conditions copied verbatim:\n // - `basePath !== \"\"` (skips when basePath is unset)\n // - `basePath !== \"/\"` (Next.js rejects this earlier, but we mirror the\n // guard so we don't silently produce `assetPrefix === \"/\"`)\n // - `assetPrefix === \"\"` (user did not explicitly opt out by setting it)\n if (resolved.basePath !== \"\" && resolved.basePath !== \"/\" && resolved.assetPrefix === \"\") {\n resolved.assetPrefix = resolved.basePath;\n }\n\n return resolved;\n}\n\nfunction normalizeAliasEntries(\n aliases: Record<string, unknown> | undefined,\n root: string,\n): Record<string, string> {\n if (!aliases) return {};\n\n const normalized: Record<string, string> = {};\n for (const [key, value] of Object.entries(aliases)) {\n if (typeof value !== \"string\") continue;\n normalized[key] = path.isAbsolute(value) ? value : path.resolve(root, value);\n }\n return normalized;\n}\n\nfunction extractTurboAliases(config: NextConfig, root: string): Record<string, string> {\n const experimental = config.experimental as Record<string, unknown> | undefined;\n const experimentalTurbo = experimental?.turbo as Record<string, unknown> | undefined;\n const topLevelTurbopack = config.turbopack as Record<string, unknown> | undefined;\n\n return {\n ...normalizeAliasEntries(\n experimentalTurbo?.resolveAlias as Record<string, unknown> | undefined,\n root,\n ),\n ...normalizeAliasEntries(\n topLevelTurbopack?.resolveAlias as Record<string, unknown> | undefined,\n root,\n ),\n };\n}\n\nasync function probeWebpackConfig(\n config: NextConfig,\n root: string,\n): Promise<{ aliases: Record<string, string>; mdx: MdxOptions | null }> {\n if (typeof config.webpack !== \"function\") {\n return { aliases: {}, mdx: null };\n }\n\n // oxlint-disable-next-line typescript/no-explicit-any\n const mockModuleRules: any[] = [];\n const mockConfig = {\n context: root,\n resolve: { alias: {} as Record<string, unknown> },\n module: { rules: mockModuleRules },\n // oxlint-disable-next-line typescript/no-explicit-any\n plugins: [] as any[],\n };\n const mockOptions = {\n defaultLoaders: { babel: { loader: \"next-babel-loader\" } },\n isServer: false,\n dev: false,\n dir: root,\n };\n\n try {\n // oxlint-disable-next-line typescript/no-unsafe-function-type\n const result = await (config.webpack as Function)(mockConfig, mockOptions);\n const finalConfig = result ?? mockConfig;\n // oxlint-disable-next-line typescript/no-explicit-any\n const rules: any[] = finalConfig.module?.rules ?? mockModuleRules;\n return {\n aliases: normalizeAliasEntries(finalConfig.resolve?.alias, root),\n mdx: extractMdxOptionsFromRules(rules),\n };\n } catch {\n return { aliases: {}, mdx: null };\n }\n}\n\n/**\n * Extract MDX compilation options (remark/rehype/recma plugins) from\n * a Next.js config that uses @next/mdx.\n *\n * @next/mdx wraps the config with a webpack function that injects an MDX\n * loader rule. The remark/rehype plugins are captured in that closure.\n * We probe the webpack function with a mock config to extract them.\n */\nexport async function extractMdxOptions(\n config: NextConfig,\n root: string = process.cwd(),\n): Promise<MdxOptions | null> {\n return (await probeWebpackConfig(config, root)).mdx;\n}\n\n/**\n * Probe file candidates relative to root. Returns the first one that exists,\n * or null if none match.\n */\nfunction probeFiles(root: string, candidates: string[]): string | null {\n for (const candidate of candidates) {\n const abs = path.resolve(root, candidate);\n if (fs.existsSync(abs)) return abs;\n }\n return null;\n}\n\nconst I18N_REQUEST_CANDIDATES = [\n \"i18n/request.ts\",\n \"i18n/request.tsx\",\n \"i18n/request.js\",\n \"i18n/request.jsx\",\n \"src/i18n/request.ts\",\n \"src/i18n/request.tsx\",\n \"src/i18n/request.js\",\n \"src/i18n/request.jsx\",\n];\n\n/**\n * Detect next-intl in the project and auto-register the `next-intl/config`\n * alias if needed.\n *\n * next-intl's `createNextIntlPlugin()` crashes in vinext because it calls\n * `require('next/package.json')` to check the Next.js version. Instead,\n * vinext detects next-intl and registers the alias automatically.\n *\n * Note: `require.resolve('next-intl')` walks up to parent `node_modules`\n * directories via standard Node module resolution. In a monorepo, next-intl\n * installed at the workspace root will trigger detection even if not listed\n * in the project's own package.json. This is acceptable since a workspace-root\n * install implies the user wants it available.\n *\n * Mutates `resolved.aliases` and `resolved.env` in place.\n */\nexport function detectNextIntlConfig(root: string, resolved: ResolvedNextConfig): void {\n // Explicit alias wins — user or plugin already set it\n if (resolved.aliases[\"next-intl/config\"]) return;\n\n // Check if next-intl is installed (use main entry — some packages\n // don't expose ./package.json in their exports map)\n const require = createRequire(path.join(root, \"package.json\"));\n try {\n require.resolve(\"next-intl\");\n } catch {\n return; // next-intl not installed\n }\n\n // Probe for the i18n request config file\n const configPath = probeFiles(root, I18N_REQUEST_CANDIDATES);\n if (!configPath) return;\n\n resolved.aliases[\"next-intl/config\"] = configPath;\n\n if (resolved.trailingSlash) {\n resolved.env._next_intl_trailing_slash = \"true\";\n }\n}\n\n// oxlint-disable-next-line typescript/no-explicit-any\nfunction extractMdxOptionsFromRules(rules: any[]): MdxOptions | null {\n // Search through webpack rules for the MDX loader injected by @next/mdx\n for (const rule of rules) {\n const loaders = extractMdxLoaders(rule);\n if (loaders) return loaders;\n }\n return null;\n}\n\n/**\n * Recursively search a webpack rule (which may have nested `oneOf` arrays)\n * for an MDX loader and extract its remark/rehype/recma plugin options.\n */\n// oxlint-disable-next-line typescript/no-explicit-any\nfunction extractMdxLoaders(rule: any): MdxOptions | null {\n if (!rule) return null;\n\n // Check `oneOf` arrays (Next.js uses these extensively)\n if (Array.isArray(rule.oneOf)) {\n for (const child of rule.oneOf) {\n const result = extractMdxLoaders(child);\n if (result) return result;\n }\n }\n\n // Check `use` array (loader chain)\n const use = Array.isArray(rule.use) ? rule.use : rule.use ? [rule.use] : [];\n for (const loader of use) {\n const loaderPath = typeof loader === \"string\" ? loader : loader?.loader;\n if (typeof loaderPath === \"string\" && isMdxLoader(loaderPath)) {\n const opts = typeof loader === \"object\" ? loader.options : {};\n return extractPluginsFromOptions(opts);\n }\n }\n\n // Check direct `loader` field\n if (typeof rule.loader === \"string\" && isMdxLoader(rule.loader)) {\n return extractPluginsFromOptions(rule.options);\n }\n\n return null;\n}\n\nfunction isMdxLoader(loaderPath: string): boolean {\n return (\n loaderPath.includes(\"mdx\") &&\n (loaderPath.includes(\"@next\") ||\n loaderPath.includes(\"@mdx-js\") ||\n loaderPath.includes(\"mdx-js-loader\") ||\n loaderPath.includes(\"next-mdx\"))\n );\n}\n\n// oxlint-disable-next-line typescript/no-explicit-any\nfunction extractPluginsFromOptions(opts: any): MdxOptions | null {\n if (!opts || typeof opts !== \"object\") return null;\n\n const remarkPlugins = Array.isArray(opts.remarkPlugins) ? opts.remarkPlugins : undefined;\n const rehypePlugins = Array.isArray(opts.rehypePlugins) ? opts.rehypePlugins : undefined;\n const recmaPlugins = Array.isArray(opts.recmaPlugins) ? opts.recmaPlugins : undefined;\n\n // Only return if at least one plugin array is non-empty\n if (\n (remarkPlugins && remarkPlugins.length > 0) ||\n (rehypePlugins && rehypePlugins.length > 0) ||\n (recmaPlugins && recmaPlugins.length > 0)\n ) {\n return {\n ...(remarkPlugins && remarkPlugins.length > 0 ? { remarkPlugins } : {}),\n ...(rehypePlugins && rehypePlugins.length > 0 ? { rehypePlugins } : {}),\n ...(recmaPlugins && recmaPlugins.length > 0 ? { recmaPlugins } : {}),\n };\n }\n\n return null;\n}\n\nexport { PHASE_PRODUCTION_BUILD } from \"vinext/shims/constants\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,mBAAmB,OAAmD;CACpF,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM,OAAO,IAAI,OAAO;CAC7D,IAAI,OAAO,UAAU,UAAU;EAC7B,IAAI,QAAQ,GAAG,MAAM,IAAI,MAAM,kDAAkD,QAAQ;EACzF,OAAO;;CAGT,MAAM,QADU,MAAM,MACD,CAAC,MAAM,2CAA2C;CACvE,IAAI,CAAC,OAAO;EACV,QAAQ,KACN,0CAA0C,MAAM,4EACjD;EACD,OAAO,IAAI,OAAO;;CAEpB,MAAM,MAAM,WAAW,MAAM,GAAG;CAChC,MAAM,QAAQ,MAAM,MAAM,KAAK,aAAa;CAC5C,IAAI;CACJ,QAAQ,MAAR;EACE,KAAK;GACH,QAAQ,KAAK,MAAM,IAAI;GACvB;EACF,KAAK;GACH,QAAQ,KAAK,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AM,KACzB,WAAW,SAAS,QAAQ,IAC3B,WAAW,SAAS,UAAU,IAC9B,WAAW,SAAS,gBAAgB,IACpC,WAAW,SAAS,WAAW;;AAKrC,SAAS,0BAA0B,MAA8B;CAC/D,IAAI,CAAC,QAAQ,OAAO,SAAS,UAAU,OAAO;CAE9C,MAAM,gBAAgB,MAAM,QAAQ,KAAK,cAAc,GAAG,KAAK,gBAAgB,KAAA;CAC/E,MAAM,gBAAgB,MAAM,QAAQ,KAAK,cAAc,GAAG,KAAK,gBAAgB,KAAA;CAC/E,MAAM,eAAe,MAAM,QAAQ,KAAK,aAAa,GAAG,KAAK,eAAe,KAAA;CAG5E,IACG,iBAAiB,cAAc,SAAS,KACxC,iBAAiB,cAAc,SAAS,KACxC,gBAAgB,aAAa,SAAS,GAEvC,OAAO;EACL,GAAI,iBAAiB,cAAc,SAAS,IAAI,EAAE,eAAe,GAAG,EAAE;EACtE,GAAI,iBAAiB,cAAc,SAAS,IAAI,EAAE,eAAe,GAAG,EAAE;EACtE,GAAI,gBAAgB,aAAa,SAAS,IAAI,EAAE,cAAc,GAAG,EAAE;EACpE;CAGH,OAAO"}
|
|
1
|
+
{"version":3,"file":"next-config.js","names":[],"sources":["../../src/config/next-config.ts"],"sourcesContent":["/**\n * next.config.js / next.config.mjs / next.config.ts parser\n *\n * Loads the Next.js config file (if present) and extracts supported options.\n * Unsupported options are logged as warnings.\n */\nimport path from \"node:path\";\nimport { createRequire } from \"node:module\";\nimport fs from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { randomUUID } from \"node:crypto\";\nimport commonjs from \"vite-plugin-commonjs\";\nimport { PHASE_DEVELOPMENT_SERVER } from \"vinext/shims/constants\";\nimport { normalizePageExtensions } from \"../routing/file-matcher.js\";\nimport { getHtmlLimitedBotRegex } from \"../utils/html-limited-bots.js\";\nimport { isUnknownRecord } from \"../utils/record.js\";\nimport { applyLocaleToRoutes, isExternalUrl } from \"./config-matchers.js\";\nimport { loadTsconfigPathAliasesForRoot } from \"./tsconfig-paths.js\";\n\n/**\n * Parse a body size limit value (string or number) into bytes.\n * Accepts Next.js-style strings like \"1mb\", \"500kb\", \"10mb\", bare number strings like \"1048576\" (bytes),\n * and numeric values. Supports b, kb, mb, gb, tb, pb units.\n * Returns the default 1MB if the value is not provided or invalid.\n * Throws if the parsed value is less than 1.\n */\nexport function parseBodySizeLimit(value: string | number | undefined | null): number {\n if (value === undefined || value === null) return 1 * 1024 * 1024;\n if (typeof value === \"number\") {\n if (value < 1) throw new Error(`Body size limit must be a positive number, got ${value}`);\n return value;\n }\n const trimmed = value.trim();\n const match = trimmed.match(/^(\\d+(?:\\.\\d+)?)\\s*(b|kb|mb|gb|tb|pb)?$/i);\n if (!match) {\n console.warn(\n `[vinext] Invalid bodySizeLimit value: \"${value}\". Expected a number or a string like \"1mb\", \"500kb\". Falling back to 1MB.`,\n );\n return 1 * 1024 * 1024;\n }\n const num = parseFloat(match[1]);\n const unit = (match[2] ?? \"b\").toLowerCase();\n let bytes: number;\n switch (unit) {\n case \"b\":\n bytes = Math.floor(num);\n break;\n case \"kb\":\n bytes = Math.floor(num * 1024);\n break;\n case \"mb\":\n bytes = Math.floor(num * 1024 * 1024);\n break;\n case \"gb\":\n bytes = Math.floor(num * 1024 * 1024 * 1024);\n break;\n case \"tb\":\n bytes = Math.floor(num * 1024 * 1024 * 1024 * 1024);\n break;\n case \"pb\":\n bytes = Math.floor(num * 1024 * 1024 * 1024 * 1024 * 1024);\n break;\n default:\n return 1 * 1024 * 1024;\n }\n if (bytes < 1) throw new Error(`Body size limit must be a positive number, got ${bytes}`);\n return bytes;\n}\n\nexport type HasCondition = {\n type: \"header\" | \"cookie\" | \"query\" | \"host\";\n key: string;\n value?: string;\n};\n\nexport type NextRedirect = {\n source: string;\n destination: string;\n permanent: boolean;\n has?: HasCondition[];\n missing?: HasCondition[];\n /**\n * When true (the default with i18n configured), Next.js prepends an internal\n * locale alternation to the source so the rule matches locale-prefixed paths.\n * When `false`, the source is left untouched and matches the raw path,\n * letting user-supplied `:locale` segments capture the prefix themselves.\n * See https://nextjs.org/docs/app/api-reference/config/next-config-js/redirects#locale\n */\n locale?: false;\n /**\n * When `false`, the rule is NOT prefixed with `basePath`. Source and\n * destination are matched/applied verbatim. Mirrors Next.js's\n * `Redirect.basePath: false` opt-out — see\n * `.nextjs-ref/packages/next/src/lib/load-custom-routes.ts:26`.\n */\n basePath?: false;\n};\n\nexport type NextRewrite = {\n source: string;\n destination: string;\n has?: HasCondition[];\n missing?: HasCondition[];\n /** See {@link NextRedirect.locale}. */\n locale?: false;\n /** See {@link NextRedirect.basePath}. */\n basePath?: false;\n};\n\nexport type NextHeader = {\n source: string;\n has?: HasCondition[];\n missing?: HasCondition[];\n headers: Array<{ key: string; value: string }>;\n /** See {@link NextRedirect.basePath}. */\n basePath?: false;\n};\n\nexport type NextI18nConfig = {\n /** List of supported locales */\n locales: string[];\n /** The default locale (used when no locale prefix is in the URL) */\n defaultLocale: string;\n /**\n * Whether to auto-detect locale from Accept-Language header.\n * Defaults to true in Next.js.\n */\n localeDetection?: boolean;\n /**\n * Domain-based routing. Each domain maps to a specific locale.\n */\n domains?: Array<{\n domain: string;\n defaultLocale: string;\n locales?: string[];\n http?: boolean;\n }>;\n};\n\n/**\n * MDX compilation options extracted from @next/mdx config.\n * These are passed through to @mdx-js/rollup so that custom\n * remark/rehype/recma plugins configured in next.config work with Vite.\n */\nexport type MdxOptions = {\n remarkPlugins?: unknown[];\n rehypePlugins?: unknown[];\n recmaPlugins?: unknown[];\n};\n\nexport type NextConfig = {\n /** Additional env variables */\n env?: Record<string, string>;\n /** Base URL path prefix */\n basePath?: string;\n /**\n * Prefix applied to every emitted JS/CSS/image/static asset URL.\n * Accepts a path prefix (e.g. `/custom-asset-prefix`) or an absolute\n * URL (e.g. `https://cdn.example.com`). Distinct from `basePath`:\n * `basePath` affects route URLs; `assetPrefix` only affects asset URLs.\n * @see https://nextjs.org/docs/app/api-reference/config/next-config-js/assetPrefix\n */\n assetPrefix?: string;\n /** Whether to add trailing slashes */\n trailingSlash?: boolean;\n /** Internationalization routing config */\n i18n?: NextI18nConfig;\n /** URL redirect rules */\n redirects?: () => Promise<NextRedirect[]> | NextRedirect[];\n /** URL rewrite rules */\n rewrites?: () =>\n | Promise<\n | NextRewrite[]\n | {\n beforeFiles: NextRewrite[];\n afterFiles: NextRewrite[];\n fallback: NextRewrite[];\n }\n >\n | NextRewrite[]\n | {\n beforeFiles: NextRewrite[];\n afterFiles: NextRewrite[];\n fallback: NextRewrite[];\n };\n /** Custom response headers */\n headers?: () => Promise<NextHeader[]> | NextHeader[];\n /** Image optimization config */\n images?: {\n remotePatterns?: Array<{\n protocol?: string;\n hostname: string;\n port?: string;\n pathname?: string;\n search?: string;\n }>;\n domains?: string[];\n unoptimized?: boolean;\n /** Allowed device widths for image optimization. Defaults to Next.js defaults: [640, 750, 828, 1080, 1200, 1920, 2048, 3840] */\n deviceSizes?: number[];\n /** Allowed image sizes for fixed-width images. Defaults to Next.js defaults: [16, 32, 48, 64, 96, 128, 256, 384] */\n imageSizes?: number[];\n /** Allow SVG images through the image optimization endpoint. SVG can contain scripts, so only enable if you trust all image sources. */\n dangerouslyAllowSVG?: boolean;\n /** Allow image optimization for hostnames that resolve to private IP addresses. This is a security risk (SSRF) — only enable for private networks when you understand the risk. */\n dangerouslyAllowLocalIP?: boolean;\n /** Content-Disposition header for image responses. Defaults to \"inline\". */\n contentDispositionType?: \"inline\" | \"attachment\";\n /** Content-Security-Policy header for image responses. Defaults to \"script-src 'none'; frame-src 'none'; sandbox;\" */\n contentSecurityPolicy?: string;\n };\n /** Build output mode: 'export' for full static export, 'standalone' for single server */\n output?: \"export\" | \"standalone\";\n /** File extensions treated as routable pages/routes (Next.js pageExtensions) */\n pageExtensions?: string[];\n /**\n * Module specifiers that are required for side effects on the client before\n * hydration, in array order, ahead of the user's `instrumentation-client.{ts,js}`.\n * Each entry may be a bare npm package name or a path relative to the project root.\n */\n instrumentationClientInject?: string[];\n /** Extra origins allowed to access the dev server. */\n allowedDevOrigins?: string[];\n /** Maximum age in seconds for stale ISR entries before blocking regeneration. */\n expireTime?: number;\n /** User agents that require blocking metadata in the initial head. */\n htmlLimitedBots?: RegExp | string;\n /**\n * Enable Cache Components (Next.js 16).\n * When true, enables the \"use cache\" directive for pages, components, and functions.\n * Replaces the removed experimental.ppr and experimental.dynamicIO flags.\n */\n cacheComponents?: boolean;\n /**\n * Enables source maps while generating static pages.\n * Helps with errors during the prerender phase in `vinext build`.\n * Defaults to `true`. Set to `false` to disable.\n */\n enablePrerenderSourceMaps?: boolean;\n /** Transpile packages (Vite handles this natively) */\n transpilePackages?: string[];\n /**\n * Packages that should be treated as server-external (not bundled by Vite).\n * Corresponds to Next.js `serverExternalPackages` (or the legacy\n * `experimental.serverComponentsExternalPackages`).\n */\n serverExternalPackages?: string[];\n /** Webpack config (ignored — we use Vite) */\n webpack?: unknown;\n /**\n * Path to a custom cache handler module (e.g., KV, Redis, DynamoDB).\n * Accepts relative paths, absolute paths, or file:// URLs from import.meta.resolve().\n * When \"type\": \"module\" is set in package.json, use import.meta.resolve() instead of\n * require.resolve() to get a valid path.\n */\n cacheHandler?: string;\n /**\n * Maximum memory size (bytes) for the default in-memory cache handler.\n * Set to 0 to disable in-memory caching entirely.\n */\n cacheMaxMemorySize?: number;\n /**\n * Custom build ID generator. If provided, called once at build/dev start.\n * Must return a non-empty string, or null to use the default random ID.\n */\n generateBuildId?: () => string | null | Promise<string | null>;\n /** Identifier for deployment-aware cache keys and version skew protection. */\n deploymentId?: string;\n /** Any other options */\n [key: string]: unknown;\n};\n\nexport type NextConfigFactory = (\n phase: string,\n opts: { defaultConfig: NextConfig },\n) => NextConfig | Promise<NextConfig>;\n\nexport type NextConfigInput = NextConfig | NextConfigFactory;\n\n/**\n * Resolved configuration with all async values awaited.\n */\nexport type ResolvedNextConfig = {\n env: Record<string, string>;\n basePath: string;\n /**\n * Resolved `assetPrefix` from next.config.\n *\n * Empty string when unset. Trailing slashes are trimmed. May be either:\n * - a path prefix beginning with `/` (e.g. `\"/custom-asset-prefix\"`), or\n * - an absolute URL with `http(s)://` origin (e.g. `\"https://cdn.example.com\"`\n * or `\"https://cdn.example.com/sub\"`).\n *\n * Mirrors Next.js semantics — `assetPrefix` controls emitted asset URLs\n * only; route URLs continue to live under `basePath`.\n *\n * @see https://nextjs.org/docs/app/api-reference/config/next-config-js/assetPrefix\n */\n assetPrefix: string;\n trailingSlash: boolean;\n output: \"\" | \"export\" | \"standalone\";\n pageExtensions: string[];\n instrumentationClientInject: string[];\n cacheComponents: boolean;\n redirects: NextRedirect[];\n rewrites: {\n beforeFiles: NextRewrite[];\n afterFiles: NextRewrite[];\n fallback: NextRewrite[];\n };\n headers: NextHeader[];\n images: NextConfig[\"images\"];\n i18n: NextI18nConfig | null;\n /** MDX remark/rehype/recma plugins extracted from @next/mdx config */\n mdx: MdxOptions | null;\n /** Explicit module aliases preserved from wrapped next.config plugins. */\n aliases: Record<string, string>;\n /** Extra allowed origins for dev server access (from allowedDevOrigins). */\n allowedDevOrigins: string[];\n /** Extra allowed origins for server action CSRF validation (from experimental.serverActions.allowedOrigins). */\n serverActionsAllowedOrigins: string[];\n /** Packages whose barrel imports should be optimized (from experimental.optimizePackageImports). */\n optimizePackageImports: string[];\n /** Parsed body size limit for server actions in bytes (from experimental.serverActions.bodySizeLimit). Defaults to 1MB. */\n serverActionsBodySizeLimit: number;\n /** Route-level expire fallback in seconds for ISR entries with numeric revalidate. */\n expireTime: number;\n /** Serialized htmlLimitedBots regexp source from next.config. */\n htmlLimitedBots: string | undefined;\n /**\n * Packages that should be treated as server-external (not bundled by Vite).\n * Sourced from `serverExternalPackages` or the legacy\n * `experimental.serverComponentsExternalPackages` in next.config.\n */\n serverExternalPackages: string[];\n /** Enable sourcemaps for prerender error stack traces. Defaults to true. */\n enablePrerenderSourceMaps: boolean;\n /** Resolved build ID (from generateBuildId, or a random UUID if not provided). */\n buildId: string;\n /** Resolved deployment ID from next.config.js or NEXT_DEPLOYMENT_ID. */\n deploymentId: string | undefined;\n /**\n * Path to a custom cache handler module. file:// URLs are resolved to\n * filesystem paths via fileURLToPath() during config resolution.\n */\n cacheHandler: string | undefined;\n /**\n * Maximum memory size (bytes) for the default in-memory cache handler.\n * Set to 0 to disable in-memory caching entirely.\n */\n cacheMaxMemorySize: number | undefined;\n /**\n * Concatenated hash salt from `experimental.outputHashSalt` config option\n * and `NEXT_HASH_SALT` environment variable. Empty string when neither is set.\n * When non-empty, mix into content-addressed output filenames so hash values\n * change without modifying source — useful for cache-busting after CDN poisoning.\n */\n hashSalt: string;\n /**\n * Raw `sassOptions` object from next.config (or `null` when unset). vinext\n * passes the relevant keys through to Vite's `css.preprocessorOptions.scss`\n * so SCSS variables defined via `additionalData` / `prependData`, partials\n * resolved via `includePaths` / `loadPaths`, and a custom `implementation`\n * all behave the same as in Next.js.\n *\n * Kept loose (`Record<string, unknown> | null`) to match Next.js's typing —\n * the object is forwarded to Sass and may contain any modern Sass option.\n */\n sassOptions: Record<string, unknown> | null;\n};\n\n// Mirrors Next.js's accepted set in packages/next/src/shared/lib/constants.ts\n// (`.js`/`.mjs`/`.ts`/`.mts`) and adds `.cjs` for parity with vinext's own\n// loader, which has historically accepted CJS configs as well. The order is\n// significant: findNextConfigPath returns the first match, so prefer the more\n// modern flavours first.\nconst CONFIG_FILES = [\n \"next.config.ts\",\n \"next.config.mts\",\n \"next.config.mjs\",\n \"next.config.js\",\n \"next.config.cjs\",\n];\nconst DEFAULT_EXPIRE_TIME = 31_536_000;\n\n/**\n * Check whether an error indicates a CJS module was loaded in an ESM context\n * (i.e. the file uses `require()` which is not available in ESM).\n */\nfunction isCjsError(e: unknown): boolean {\n if (!(e instanceof Error)) return false;\n const msg = e.message;\n return (\n msg.includes(\"require is not a function\") ||\n msg.includes(\"require is not defined\") ||\n msg.includes(\"exports is not defined\") ||\n msg.includes(\"module is not defined\") ||\n msg.includes(\"__dirname is not defined\") ||\n msg.includes(\"__filename is not defined\")\n );\n}\n\n// Dev-server phase is the safe default for config loading: it enables all\n// optional config sections (headers, redirects, rewrites) without triggering\n// build-only behaviour. Used in two default parameter values below to avoid\n// repeating PHASE_DEVELOPMENT_SERVER inline.\nconst DEFAULT_PHASE = PHASE_DEVELOPMENT_SERVER;\n\n/**\n * Emit a warning when config loading fails, with a targeted hint for\n * known plugin wrappers that are unnecessary in vinext.\n */\nfunction warnConfigLoadFailure(filename: string, err: Error): void {\n const msg = err.message ?? \"\";\n const stack = err.stack ?? \"\";\n const isNextIntlPlugin =\n msg.includes(\"next-intl\") ||\n stack.includes(\"next-intl/plugin\") ||\n stack.includes(\"next-intl/dist\");\n\n console.log();\n console.error(`[vinext] Failed to load ${filename}: ${msg}`);\n console.log();\n if (isNextIntlPlugin) {\n console.warn(\n \"[vinext] Hint: createNextIntlPlugin() is not needed with vinext. \" +\n \"Remove the next-intl/plugin wrapper from your next.config — \" +\n \"vinext auto-detects next-intl and registers the i18n config alias automatically.\",\n );\n }\n}\n\n/**\n * Resolve a Next-style config value, calling it if it's a function-form config\n * (Next.js supports `module.exports = (phase, opts) => config`).\n */\nasync function resolveConfigValue(\n config: unknown,\n phase: string = DEFAULT_PHASE,\n): Promise<NextConfig> {\n if (typeof config === \"function\") {\n const result = await config(phase, {\n defaultConfig: {},\n });\n return result as NextConfig;\n }\n return config as NextConfig;\n}\n\n/**\n * Named export attached by `cjsGlobalsInjectorPlugin` when the source\n * statically looks like it assigns to `module.exports`. Holds the wrapper\n * `module` object so {@link unwrapConfig} can read back the user's CJS-style\n * export. Pure-ESM configs skip the wrapper entirely and rely on the ESM\n * `default` export instead.\n */\nconst VINEXT_CJS_EXPORTS_KEY = \"__vinext_cjs_exports\";\n\n/**\n * Companion named export pointing at the initial empty `{}` that the wrapper\n * is constructed with. Lets {@link unwrapConfig} distinguish \"user reassigned\n * or mutated module.exports\" from \"module.exports is still the untouched\n * empty wrapper\" — the latter happens when {@link reassignsModuleExports}\n * matches inside a string or comment (a harmless false positive that should\n * still fall through to the ESM `default` export).\n */\nconst VINEXT_CJS_INITIAL_KEY = \"__vinext_cjs_initial_exports\";\n\n/**\n * Unwrap the config value from a loaded module namespace.\n *\n * Prefers `module.exports` (CJS style) when the config file reassigned it,\n * otherwise falls back to `default`/the namespace itself. Mirrors Next.js's\n * behaviour, where the config is loaded through `Module._compile` and CJS\n * assignments override any ESM-style exports.\n *\n * The presence of the `__vinext_cjs_exports` named export is the static\n * signal (set by `cjsGlobalsInjectorPlugin` when `reassignsModuleExports`\n * matched) that this file might use CJS-style exports. We then disambiguate\n * \"user actually touched module.exports\" from \"static heuristic was a false\n * positive\" by comparing identity against the initial empty wrapper: if\n * `module.exports` is still the original `{}`, fall back to ESM `default`.\n */\nasync function unwrapConfig(\n // oxlint-disable-next-line typescript/no-explicit-any\n mod: any,\n phase: string = PHASE_DEVELOPMENT_SERVER,\n): Promise<NextConfig> {\n const cjsModule = mod?.[VINEXT_CJS_EXPORTS_KEY];\n const cjsExports = cjsModule?.exports;\n const cjsInitial = mod?.[VINEXT_CJS_INITIAL_KEY];\n const userTouchedExports =\n cjsExports !== undefined &&\n cjsExports !== null &&\n // Either reassigned outright, or mutated keys on the initial object.\n (cjsExports !== cjsInitial ||\n (typeof cjsExports === \"object\" && Object.keys(cjsExports).length > 0));\n if (userTouchedExports) {\n return await resolveConfigValue(cjsExports, phase);\n }\n return await resolveConfigValue(mod.default ?? mod, phase);\n}\n\n/**\n * Resolve a path through filesystem symlinks, falling back to the original\n * path when the file does not exist (e.g. virtual ids, query-suffixed ids).\n */\nfunction safeRealpath(p: string): string {\n try {\n return fs.realpathSync(p);\n } catch {\n return p;\n }\n}\n\n/**\n * Whole-word substring check for any of the CJS-style globals that the\n * injector plugin would shim. Used to skip the transform entirely for the\n * common case where the config is pure ESM (no `__filename`, `__dirname`,\n * `require`, `module`, or `exports` references).\n *\n * False positives are harmless: a comment, string literal, or unrelated\n * identifier like `node:module` will trigger the transform unnecessarily,\n * but the resulting injection is idempotent and the loaded config is\n * unaffected. False negatives would be a correctness bug, so we err on the\n * side of matching too eagerly.\n *\n * Note: `\\bexports\\b` does not match `export default` (different word\n * boundaries), and `\\brequire\\b` does not match `requireSomething`.\n */\nexport function referencesCjsGlobals(source: string): boolean {\n return /\\b(?:__filename|__dirname|require|module|exports)\\b/.test(source);\n}\n\n/**\n * Static heuristic: returns true when the source appears to assign to\n * `module.exports` — either via `module.exports = …`, `module.exports.foo = …`,\n * or `module.exports[…] = …`. Used to decide whether the injector plugin\n * needs to wire up the wrapper `module` object so {@link unwrapConfig} can\n * read back the user's CJS-style export.\n *\n * Pure-ESM configs skip the wrapper entirely, which means a faster transform\n * (no extra `export const` line) and a simpler unwrap path (no need to\n * disambiguate \"initial empty object\" from \"user reassigned to {}\").\n *\n * Like {@link referencesCjsGlobals}, false positives are harmless: at worst\n * we emit an unused `__vinext_cjs_exports` named export, and `unwrapConfig`\n * still prefers it (it points at an empty object, which then gets treated\n * as the config — equivalent to today's sentinel logic for pure-ESM files\n * that happen to mention `module.exports` only in a string).\n */\nexport function reassignsModuleExports(source: string): boolean {\n // Match `module.exports` followed by `=` (not `==` / `===`), `.identifier =`,\n // or `[...] =`. Whitespace allowed around the dot.\n return /\\bmodule\\s*\\.\\s*exports\\b\\s*(?:=(?!=)|\\.\\s*[A-Za-z_$][\\w$]*\\s*=(?!=)|\\[)/.test(source);\n}\n\n/**\n * Vite plugin that prepends CJS-style globals (`__filename`, `__dirname`,\n * `module`, `exports`, `require`) to the next.config.* source before\n * Vite's module runner evaluates it.\n *\n * Next.js's `next.config.ts` loader (packages/next/src/build/next-config-ts/\n * transpile-config.ts → require-hook.ts) feeds the file through Node's\n * `Module._compile`, which provides these CJS globals even when the source\n * uses ESM syntax. Upstream test fixtures in `test/e2e/app-dir/next-config-ts*`\n * rely on that, e.g. `node-api-cjs/next.config.ts` reads\n * `fs.readFileSync(path.join(__dirname, 'foo.txt'), 'utf8')`. vinext loads\n * configs through Vite's ESM-only module runner, so we inject the same\n * globals as plain `const` declarations.\n *\n * For configs that don't reference any CJS global (the common case — every\n * upstream `next-config-ts` fixture except `node-api-cjs` is pure ESM) we\n * skip the transform entirely; see {@link referencesCjsGlobals}.\n *\n * `module.exports` reassignment is preserved by exposing the injected\n * `module` object as a named export (see {@link VINEXT_CJS_EXPORTS_KEY}) and\n * reading it back in {@link unwrapConfig}.\n */\nfunction cjsGlobalsInjectorPlugin(configPath: string): {\n name: string;\n enforce: \"pre\";\n // oxlint-disable-next-line typescript/no-explicit-any\n transform(this: unknown, code: string, id: string): any;\n} {\n // Resolve symlinks once so we can compare against the (possibly\n // symlink-resolved) id Vite passes to `transform`. On macOS, `/var/folders`\n // is a symlink to `/private/var/folders`, so the temp-dir path in tests\n // would otherwise mismatch.\n const normalizedTarget = safeRealpath(path.resolve(configPath));\n return {\n name: \"vinext:next-config-cjs-globals\",\n enforce: \"pre\",\n transform(code: string, id: string) {\n // Vite may pass an id with a query suffix (?v=...) or as a file URL.\n const idPath = id.startsWith(\"file://\") ? fileURLToPath(id) : id.split(\"?\")[0];\n const resolvedId = safeRealpath(path.resolve(idPath));\n if (resolvedId !== normalizedTarget) return null;\n\n // Fast path: skip the transform when the source contains no bareword\n // reference to any of the shimmed globals. The vast majority of\n // `next.config.ts` files are pure ESM (`export default { ... }`) and\n // pay no cost from this plugin.\n if (!referencesCjsGlobals(code)) return null;\n\n const dirname = path.dirname(normalizedTarget);\n // JSON.stringify produces safe JS string literals for paths.\n const filenameLiteral = JSON.stringify(normalizedTarget);\n const dirnameLiteral = JSON.stringify(dirname);\n const requireBaseLiteral = JSON.stringify(path.join(dirname, \"package.json\"));\n\n // Only wire up the wrapper `module` object — and the corresponding\n // named export read by unwrapConfig — when the source statically looks\n // like it assigns to module.exports. Pure-ESM configs avoid the extra\n // export and the unwrap-by-wrapper code path.\n const needsModuleWrapper = reassignsModuleExports(code);\n const moduleLines = needsModuleWrapper\n ? `const __vinextInitialExports = {};\\n` +\n `const module = { exports: __vinextInitialExports };\\n` +\n `const exports = module.exports;\\n` +\n `export const ${VINEXT_CJS_EXPORTS_KEY} = module;\\n` +\n `export const ${VINEXT_CJS_INITIAL_KEY} = __vinextInitialExports;\\n`\n : \"\";\n\n // Preamble runs after ESM imports are hoisted; the const bindings shadow\n // any global lookups the source would otherwise perform.\n const preamble =\n `import { createRequire as __vinextCreateRequire } from \"node:module\";\\n` +\n `const __filename = ${filenameLiteral};\\n` +\n `const __dirname = ${dirnameLiteral};\\n` +\n `const require = __vinextCreateRequire(${requireBaseLiteral});\\n` +\n moduleLines;\n\n return {\n code: preamble + code,\n map: null,\n };\n },\n };\n}\n\nexport function findNextConfigPath(root: string): string | null {\n for (const filename of CONFIG_FILES) {\n const configPath = path.join(root, filename);\n if (fs.existsSync(configPath)) return configPath;\n }\n return null;\n}\n\nexport async function resolveNextConfigInput(\n config: NextConfigInput,\n phase: string = PHASE_DEVELOPMENT_SERVER,\n): Promise<NextConfig> {\n // Inline vinext({ nextConfig }) already receives the config value itself,\n // not a module namespace object, so do not treat a \"default\" key specially.\n return await resolveConfigValue(config, phase);\n}\n\n/**\n * Load a CJS-flavoured next.config.{js,cjs} via createRequire.\n *\n * For `.cjs` (or `.js` in a non-type-module package) Node's loader picks the\n * right format automatically and `require()` just works. For `.js` in a\n * `\"type\": \"module\"` package, Node infers ESM from package.json and the file\n * fails with `require is not defined`. In that case we copy the source to a\n * sibling temp `.cjs` (where the explicit extension forces CJS regardless of\n * the parent type field) and require *that*. Relative imports inside the\n * config still resolve against the original directory.\n */\nasync function loadConfigViaRequire(\n configPath: string,\n root: string,\n phase: string,\n): Promise<NextConfig> {\n const require = createRequire(path.join(root, \"package.json\"));\n try {\n return await unwrapConfig(require(configPath), phase);\n } catch (e) {\n if (!isCjsError(e) || !configPath.endsWith(\".js\")) throw e;\n return await loadConfigViaCjsTempCopy(configPath, root, phase);\n }\n}\n\nasync function loadConfigViaCjsTempCopy(\n configPath: string,\n root: string,\n phase: string,\n): Promise<NextConfig> {\n const dir = path.dirname(configPath);\n // Hidden + uniquely-named to avoid clashing with user files or being picked\n // up by next.js's own config scanner if a concurrent next dev is running.\n const tmpPath = path.join(dir, `.vinext-next-config.${process.pid}.${Date.now()}.cjs`);\n fs.copyFileSync(configPath, tmpPath);\n try {\n const require = createRequire(path.join(root, \"package.json\"));\n return await unwrapConfig(require(tmpPath), phase);\n } finally {\n try {\n fs.unlinkSync(tmpPath);\n } catch {\n // Best-effort cleanup; a stray tmp file is harmless.\n }\n }\n}\n\n/**\n * Find and load the next.config file from the project root.\n * Returns null if no config file is found.\n *\n * Attempts Vite's module runner first so TS configs and extensionless local\n * imports (e.g. `import \"./env\"`) resolve consistently. If loading fails due\n * to CJS constructs (`require`, `module.exports`), falls back to `createRequire`\n * so common CJS plugin wrappers (nextra, @next/mdx, etc.) still work, including\n * `next.config.js` files written in CJS syntax inside a `\"type\": \"module\"`\n * package (the common shape after `vinext init`).\n */\nexport async function loadNextConfig(\n root: string,\n phase: string = DEFAULT_PHASE,\n): Promise<NextConfig | null> {\n const configPath = findNextConfigPath(root);\n if (!configPath) return null;\n\n const filename = path.basename(configPath);\n\n // Mirror Next.js: read `compilerOptions.paths` from the project's\n // tsconfig.json so aliased imports inside next.config.ts (e.g.\n // `import { foo } from '@/foo'`) resolve at config-load time. Next.js\n // passes these to SWC; we pass them to Vite's resolver as `resolve.alias`.\n // See packages/next/src/build/next-config-ts/transpile-config.ts.\n const tsconfigAliases = loadTsconfigPathAliasesForRoot(root);\n\n // Symlink-resolved config path, used by the `commonjs()` filter below to\n // exclude the config file itself. macOS uses /private/var symlinks, so\n // string-compare without realpath would falsely include the config.\n const normalizedConfigPath = safeRealpath(path.resolve(configPath));\n\n try {\n // Load config via Vite's module runner (TS + extensionless import support)\n const { runnerImport } = await import(\"vite\");\n const { module: mod } = await runnerImport(configPath, {\n root,\n logLevel: \"error\",\n clearScreen: false,\n resolve: {\n alias: tsconfigAliases,\n // Include `.cjs` and `.cts` so `vite-plugin-commonjs` recognises\n // those extensions (the plugin keys off `config.resolve.extensions`,\n // which on Vite defaults to `[.mjs, .js, .mts, .ts, .jsx, .tsx,\n // .json]` — no CJS extensions). This also lets the runner's resolver\n // find `./foo` style imports that resolve to a `.cjs`/`.cts` sibling.\n extensions: [\".mjs\", \".js\", \".cjs\", \".mts\", \".ts\", \".cts\", \".jsx\", \".tsx\", \".json\"],\n },\n // Only inject CJS globals for TypeScript config flavours. Next.js\n // applies its `Module._compile` / SWC pipeline (which exposes the\n // CJS globals) exclusively to `.ts`/`.mts`/`.cts`; legacy `.js`/`.cjs`\n // configs are loaded through Node and already have `require`/`module`,\n // and `.mjs` configs are explicitly ESM-only.\n //\n // Pair that with `vite-plugin-commonjs` (the same plugin used for\n // application code in index.ts) so sibling imports like `.cjs`/`.cts`,\n // or `.js`/`.ts` files that assign to `module.exports`, are converted\n // to ESM before Vite's runner evaluates them. The default `filter`\n // skips `node_modules`; we opt back in so bare-import packages\n // imported by next.config.* (e.g. CJS plugin wrappers) keep working —\n // this mirrors how Next.js's SWC pipeline handles those imports too.\n //\n // The config file itself is excluded from `commonjs()`: when it needs\n // CJS globals it goes through `cjsGlobalsInjectorPlugin`, which sets\n // up a specific `__vinext_cjs_exports` wiring that `unwrapConfig` reads\n // back. Letting both plugins inject `module = { exports: {} }` for the\n // same source produces an `Identifier 'module' has already been\n // declared` syntax error.\n plugins: [\n ...(/\\.[cm]?ts$/.test(configPath) ? [cjsGlobalsInjectorPlugin(configPath)] : []),\n commonjs({\n filter: (id: string) => {\n const idPath = id.startsWith(\"file://\") ? fileURLToPath(id) : id.split(\"?\")[0];\n const resolvedId = safeRealpath(path.resolve(idPath));\n if (resolvedId === normalizedConfigPath) return false;\n // Returning `true` forces the transform to run even for ids\n // inside `node_modules` (default behaviour skips them);\n // `undefined` falls through to the plugin's default for\n // user code.\n return id.includes(\"node_modules\") ? true : undefined;\n },\n }),\n ],\n });\n return await unwrapConfig(mod, phase);\n } catch (e) {\n // If the error indicates a CJS file loaded in ESM context, retry with\n // createRequire which provides a proper CommonJS environment.\n if (isCjsError(e) && (filename.endsWith(\".js\") || filename.endsWith(\".cjs\"))) {\n try {\n return await loadConfigViaRequire(configPath, root, phase);\n } catch (e2) {\n warnConfigLoadFailure(filename, e2 as Error);\n throw e2;\n }\n }\n\n warnConfigLoadFailure(filename, e as Error);\n throw e;\n }\n}\n\n/**\n * Generate a UUID that doesn't contain \"ad\" to avoid false-positive ad-blocker hits.\n * Mirrors Next.js's own nanoid retry loop.\n */\nfunction safeUUID(): string {\n let id = randomUUID();\n while (/ad/i.test(id)) id = randomUUID();\n return id;\n}\n\n/**\n * Call the user's generateBuildId function and validate its return value.\n * Follows Next.js semantics: null return falls back to a random UUID; any\n * other non-string throws. Leading/trailing whitespace is trimmed.\n *\n * @see https://nextjs.org/docs/app/api-reference/config/next-config-js/generateBuildId\n */\nasync function resolveBuildId(\n generate: (() => string | null | Promise<string | null>) | undefined,\n): Promise<string> {\n if (!generate) return safeUUID();\n\n const result = await generate();\n\n if (result === null) return safeUUID();\n\n if (typeof result !== \"string\") {\n throw new Error(\n \"generateBuildId did not return a string. https://nextjs.org/docs/messages/generatebuildid-not-a-string\",\n );\n }\n\n const trimmed = result.trim();\n if (trimmed.length === 0) {\n throw new Error(\n \"generateBuildId returned an empty string. https://nextjs.org/docs/messages/generatebuildid-not-a-string\",\n );\n }\n\n return trimmed;\n}\n\n/**\n * Normalize the `assetPrefix` option from next.config.\n *\n * Accepts both absolute URLs (`https://cdn.example.com[/subpath]`) and\n * path prefixes (`/custom-asset-prefix`). Trailing slashes are trimmed.\n * Empty/whitespace-only strings are treated as unset and return `\"\"`.\n *\n * Path prefixes that omit the leading slash get one added so they always\n * begin with `/` — this matches how Next.js routes match against them.\n *\n * Non-string values are rejected to surface config mistakes early.\n *\n * @see https://nextjs.org/docs/app/api-reference/config/next-config-js/assetPrefix\n */\nexport function normalizeAssetPrefix(value: unknown): string {\n if (value === undefined || value === null || value === \"\") return \"\";\n\n if (typeof value !== \"string\") {\n throw new Error(\n `Invalid \\`assetPrefix\\` configuration: must be a string, got ${typeof value}. ` +\n `Accepts a path prefix (\"/custom-asset-prefix\") or an absolute URL ` +\n `(\"https://cdn.example.com\").`,\n );\n }\n\n // Avoid `replace(/\\/+$/, \"\")` — CodeQL flags it as polynomial backtracking\n // on uncontrolled input. An explicit loop has the same effect with linear time.\n let trimmed = value.trim();\n while (trimmed.endsWith(\"/\")) trimmed = trimmed.slice(0, -1);\n if (trimmed === \"\") return \"\";\n\n // Absolute URL — keep origin verbatim, validate parseability so a typo\n // surfaces at config-load time instead of as a confusing build error.\n if (/^https?:\\/\\//i.test(trimmed)) {\n if (!URL.canParse(trimmed)) {\n throw new Error(`Invalid \\`assetPrefix\\` configuration: \"${value}\" is not a parseable URL.`);\n }\n return trimmed;\n }\n\n // Path prefix — always begin with \"/\", consistent with basePath.\n return trimmed.startsWith(\"/\") ? trimmed : `/${trimmed}`;\n}\n\nfunction resolveDeploymentId(configDeploymentId: unknown): string | undefined {\n const deploymentId =\n configDeploymentId !== undefined ? configDeploymentId : process.env.NEXT_DEPLOYMENT_ID;\n if (deploymentId === undefined || deploymentId === \"\") return undefined;\n\n if (typeof deploymentId !== \"string\") {\n throw new Error(\n \"Invalid `deploymentId` configuration: must be a string. https://nextjs.org/docs/messages/deploymentid-not-a-string\",\n );\n }\n\n if (!/^[a-zA-Z0-9_-]+$/.test(deploymentId)) {\n throw new Error(\n \"Invalid `deploymentId` configuration: contains invalid characters. Only alphanumeric characters, hyphens, and underscores are allowed. https://nextjs.org/docs/messages/deploymentid-invalid-characters\",\n );\n }\n\n return deploymentId;\n}\n\n/**\n * Converts a cache handler path to a filesystem path.\n * ESM's import.meta.resolve() returns file:// URLs which break when concatenated\n * with path operations like path.join or path.relative.\n * @param filePath - Absolute path, relative path, or file:// URL (e.g. from import.meta.resolve)\n * @returns A filesystem path suitable for path operations\n */\nfunction resolveCacheHandlerPathToFilesystem(filePath: string): string {\n if (filePath.startsWith(\"file://\")) {\n return fileURLToPath(filePath);\n }\n return filePath;\n}\n\nfunction resolveHtmlLimitedBots(value: NextConfig[\"htmlLimitedBots\"]): string | undefined {\n const source =\n value instanceof RegExp ? value.source : typeof value === \"string\" ? value : undefined;\n if (!source) return undefined;\n\n try {\n getHtmlLimitedBotRegex(source);\n } catch (error) {\n throw new Error(\n 'Invalid next.config option \"htmlLimitedBots\": expected a valid regular expression source',\n { cause: error },\n );\n }\n\n return source;\n}\n\nfunction readOptionalRecord(value: unknown): Record<string, unknown> | undefined {\n return isUnknownRecord(value) ? value : undefined;\n}\n\nfunction readOptionalString(value: unknown): string | undefined {\n return typeof value === \"string\" ? value : undefined;\n}\n\nfunction readOptionalBodySizeLimit(value: unknown): string | number | undefined {\n return typeof value === \"string\" || typeof value === \"number\" ? value : undefined;\n}\n\nfunction readStringArray(value: unknown): string[] {\n return Array.isArray(value)\n ? value.filter((item): item is string => typeof item === \"string\")\n : [];\n}\n\n/**\n * Resolve a NextConfig into a fully-resolved ResolvedNextConfig.\n * Awaits async functions for redirects/rewrites/headers.\n */\nexport async function resolveNextConfig(\n config: NextConfig | null,\n root: string = process.cwd(),\n): Promise<ResolvedNextConfig> {\n if (!config) {\n const buildId = await resolveBuildId(undefined);\n const deploymentId = resolveDeploymentId(undefined);\n const resolved: ResolvedNextConfig = {\n env: {},\n basePath: \"\",\n assetPrefix: \"\",\n trailingSlash: false,\n output: \"\",\n pageExtensions: normalizePageExtensions(),\n cacheComponents: false,\n redirects: [],\n rewrites: { beforeFiles: [], afterFiles: [], fallback: [] },\n headers: [],\n images: undefined,\n i18n: null,\n mdx: null,\n aliases: {},\n allowedDevOrigins: [],\n serverActionsAllowedOrigins: [],\n optimizePackageImports: [],\n serverActionsBodySizeLimit: 1 * 1024 * 1024,\n expireTime: DEFAULT_EXPIRE_TIME,\n htmlLimitedBots: undefined,\n serverExternalPackages: [],\n cacheHandler: undefined,\n cacheMaxMemorySize: undefined,\n enablePrerenderSourceMaps: true,\n hashSalt: process.env.NEXT_HASH_SALT ?? \"\",\n buildId,\n deploymentId,\n sassOptions: null,\n instrumentationClientInject: [],\n };\n detectNextIntlConfig(root, resolved);\n return resolved;\n }\n\n // Resolve redirects\n let redirects: NextRedirect[] = [];\n if (config.redirects) {\n const result = await config.redirects();\n redirects = Array.isArray(result) ? result : [];\n }\n\n // Resolve rewrites\n let rewrites: {\n beforeFiles: NextRewrite[];\n afterFiles: NextRewrite[];\n fallback: NextRewrite[];\n } = {\n beforeFiles: [],\n afterFiles: [],\n fallback: [],\n };\n if (config.rewrites) {\n const result = await config.rewrites();\n if (Array.isArray(result)) {\n rewrites.afterFiles = result;\n } else {\n rewrites = {\n beforeFiles: result.beforeFiles ?? [],\n afterFiles: result.afterFiles ?? [],\n fallback: result.fallback ?? [],\n };\n }\n }\n\n {\n const allRewrites = [...rewrites.beforeFiles, ...rewrites.afterFiles, ...rewrites.fallback];\n const externalRewrites = allRewrites.filter((rewrite) => isExternalUrl(rewrite.destination));\n\n if (externalRewrites.length > 0) {\n const noun = externalRewrites.length === 1 ? \"external rewrite\" : \"external rewrites\";\n const listing = externalRewrites\n .map((rewrite) => ` ${rewrite.source} → ${rewrite.destination}`)\n .join(\"\\n\");\n\n console.warn(\n `[vinext] Found ${externalRewrites.length} ${noun} that proxy requests to external origins:\\n` +\n `${listing}\\n` +\n `Request headers, including credential headers (cookie, authorization, proxy-authorization, x-api-key), ` +\n `are forwarded to the external origin to match Next.js behavior. ` +\n `If you do not want to forward credentials, use an API route or route handler where you control exactly which headers are sent.`,\n );\n }\n }\n\n // Resolve headers\n let headers: NextHeader[] = [];\n if (config.headers) {\n headers = await config.headers();\n }\n\n // Probe wrapped webpack config once so alias extraction and MDX extraction\n // observe the same mock environment.\n const webpackProbe = await probeWebpackConfig(config, root);\n const mdx = webpackProbe.mdx;\n const aliases = {\n ...extractTurboAliases(config, root),\n ...webpackProbe.aliases,\n };\n\n const allowedDevOrigins = Array.isArray(config.allowedDevOrigins) ? config.allowedDevOrigins : [];\n\n // Resolve serverActions.allowedOrigins and bodySizeLimit from experimental config\n const experimental = readOptionalRecord(config.experimental);\n const serverActionsConfig = readOptionalRecord(experimental?.serverActions);\n const serverActionsAllowedOrigins = readStringArray(serverActionsConfig?.allowedOrigins);\n const serverActionsBodySizeLimit = parseBodySizeLimit(\n readOptionalBodySizeLimit(serverActionsConfig?.bodySizeLimit),\n );\n\n // Resolve hashSalt from experimental.outputHashSalt config + NEXT_HASH_SALT env var.\n // Next.js concatenates them: config value first, then env var.\n const configOutputHashSalt = readOptionalString(experimental?.outputHashSalt);\n const hashSalt = (configOutputHashSalt ?? \"\") + (process.env.NEXT_HASH_SALT ?? \"\");\n const htmlLimitedBots = resolveHtmlLimitedBots(config.htmlLimitedBots);\n\n // Resolve optimizePackageImports from experimental config\n const rawOptimize = experimental?.optimizePackageImports;\n const optimizePackageImports = Array.isArray(rawOptimize)\n ? rawOptimize.filter((x): x is string => typeof x === \"string\")\n : [];\n\n // Resolve serverExternalPackages — support the current top-level key and the\n // legacy experimental.serverComponentsExternalPackages name that Next.js still\n // accepts (it moved out of experimental in Next.js 14.2).\n const topLevelServerExternalPackages = Array.isArray(config.serverExternalPackages)\n ? readStringArray(config.serverExternalPackages)\n : undefined;\n const legacyServerComponentsExternal = readStringArray(\n experimental?.serverComponentsExternalPackages,\n );\n const serverExternalPackages = topLevelServerExternalPackages ?? legacyServerComponentsExternal;\n\n // Warn about unsupported experimental.swcEnvOptions. vinext uses Vite for\n // transforms, not SWC, so automatic polyfill injection is not applicable.\n if (experimental?.swcEnvOptions !== undefined) {\n console.warn(\n '[vinext] next.config option \"experimental.swcEnvOptions\" is not applicable and will be ignored (vinext uses Vite, not SWC). ' +\n \"A Vite-compatible polyfill solution may be explored in the future.\",\n );\n }\n\n // `next/root-params` is now stable — no longer requires an experimental flag.\n if (experimental?.rootParams !== undefined) {\n console.warn(\n \"[vinext] `experimental.rootParams` is no longer needed, because `next/root-params` is available by default. \" +\n \"You can remove it from next.config.(js|mjs|ts).\",\n );\n }\n\n // Warn about unsupported webpack usage. We preserve alias injection and\n // extract MDX settings, but all other webpack customization is still ignored.\n if (config.webpack !== undefined) {\n if (mdx || Object.keys(webpackProbe.aliases).length > 0) {\n console.warn(\n '[vinext] next.config option \"webpack\" is only partially supported. ' +\n \"vinext preserves resolve.alias entries and MDX loader settings, but other webpack customization is ignored\",\n );\n } else {\n console.warn(\n '[vinext] next.config option \"webpack\" is not yet supported and will be ignored',\n );\n }\n }\n\n const output = readOptionalString(config.output) ?? \"\";\n if (output && output !== \"export\" && output !== \"standalone\") {\n console.warn(`[vinext] Unknown output mode \"${output}\", ignoring`);\n }\n\n const pageExtensions = normalizePageExtensions(config.pageExtensions);\n\n // Parse i18n config\n let i18n: NextI18nConfig | null = null;\n if (config.i18n) {\n i18n = {\n locales: config.i18n.locales,\n defaultLocale: config.i18n.defaultLocale,\n localeDetection: config.i18n.localeDetection ?? true,\n domains: config.i18n.domains,\n };\n }\n\n const buildId = await resolveBuildId(config.generateBuildId);\n const deploymentId = resolveDeploymentId(config.deploymentId);\n\n // Resolve cacheHandler path — handle file:// URLs from import.meta.resolve()\n const cacheHandler: string | undefined =\n typeof config.cacheHandler === \"string\"\n ? resolveCacheHandlerPathToFilesystem(config.cacheHandler)\n : undefined;\n\n // Resolve cacheMaxMemorySize\n const cacheMaxMemorySize: number | undefined =\n typeof config.cacheMaxMemorySize === \"number\" ? config.cacheMaxMemorySize : undefined;\n\n // Apply Next.js i18n locale-prefix transformation to redirects/rewrites.\n // When i18n is configured and a rule does NOT carry `locale: false`, the\n // source is rewritten to match locale-prefixed URLs. Rules with\n // `locale: false` are left untouched so user-supplied `:locale` segments\n // can capture the prefix themselves. Mirrors processRoutes() in\n // packages/next/src/lib/load-custom-routes.ts.\n if (i18n) {\n const opts = { trailingSlash: config.trailingSlash ?? false };\n redirects = applyLocaleToRoutes(redirects, i18n, \"redirect\", opts);\n rewrites = {\n beforeFiles: applyLocaleToRoutes(rewrites.beforeFiles, i18n, \"rewrite\", opts),\n afterFiles: applyLocaleToRoutes(rewrites.afterFiles, i18n, \"rewrite\", opts),\n fallback: applyLocaleToRoutes(rewrites.fallback, i18n, \"rewrite\", opts),\n };\n }\n\n const resolved: ResolvedNextConfig = {\n env: config.env ?? {},\n basePath: config.basePath ?? \"\",\n assetPrefix: normalizeAssetPrefix(config.assetPrefix),\n trailingSlash: config.trailingSlash ?? false,\n output: output === \"export\" || output === \"standalone\" ? output : \"\",\n pageExtensions,\n instrumentationClientInject: Array.isArray(config.instrumentationClientInject)\n ? (config.instrumentationClientInject as unknown[]).filter(\n (x): x is string => typeof x === \"string\",\n )\n : [],\n cacheComponents: config.cacheComponents ?? false,\n redirects,\n rewrites,\n headers,\n images: config.images,\n i18n,\n mdx,\n aliases,\n allowedDevOrigins,\n serverActionsAllowedOrigins,\n optimizePackageImports,\n serverActionsBodySizeLimit,\n expireTime: typeof config.expireTime === \"number\" ? config.expireTime : DEFAULT_EXPIRE_TIME,\n htmlLimitedBots,\n serverExternalPackages,\n cacheHandler,\n cacheMaxMemorySize,\n enablePrerenderSourceMaps: config.enablePrerenderSourceMaps ?? true,\n hashSalt,\n buildId,\n deploymentId,\n sassOptions: readOptionalRecord(config.sassOptions) ?? null,\n };\n\n // Auto-detect next-intl (lowest priority — explicit aliases from\n // webpack/turbopack already in `aliases` take precedence)\n detectNextIntlConfig(root, resolved);\n\n // Parity with Next.js: when `basePath` is configured but `assetPrefix` is\n // not, fall back to using `basePath` as the asset prefix. This ensures the\n // on-disk layout under `dist/client` is rooted at `<basePath>/_next/static/`\n // (matching the URL Vite emits via `base + assetsDir`), so Cloudflare's\n // ASSETS binding and the prod-server static layer can serve requests\n // verbatim without any runtime path rewriting.\n //\n // Mirrors Next.js: packages/next/src/server/config.ts:509-532\n // https://github.com/vercel/next.js/blob/canary/packages/next/src/server/config.ts\n // Conditions copied verbatim:\n // - `basePath !== \"\"` (skips when basePath is unset)\n // - `basePath !== \"/\"` (Next.js rejects this earlier, but we mirror the\n // guard so we don't silently produce `assetPrefix === \"/\"`)\n // - `assetPrefix === \"\"` (user did not explicitly opt out by setting it)\n if (resolved.basePath !== \"\" && resolved.basePath !== \"/\" && resolved.assetPrefix === \"\") {\n resolved.assetPrefix = resolved.basePath;\n }\n\n return resolved;\n}\n\nfunction normalizeAliasEntries(\n aliases: Record<string, unknown> | undefined,\n root: string,\n): Record<string, string> {\n if (!aliases) return {};\n\n const normalized: Record<string, string> = {};\n for (const [key, value] of Object.entries(aliases)) {\n if (typeof value !== \"string\") continue;\n normalized[key] = path.isAbsolute(value) ? value : path.resolve(root, value);\n }\n return normalized;\n}\n\nfunction extractTurboAliases(config: NextConfig, root: string): Record<string, string> {\n const experimental = readOptionalRecord(config.experimental);\n const experimentalTurbo = readOptionalRecord(experimental?.turbo);\n const topLevelTurbopack = readOptionalRecord(config.turbopack);\n\n return {\n ...normalizeAliasEntries(readOptionalRecord(experimentalTurbo?.resolveAlias), root),\n ...normalizeAliasEntries(readOptionalRecord(topLevelTurbopack?.resolveAlias), root),\n };\n}\n\nasync function probeWebpackConfig(\n config: NextConfig,\n root: string,\n): Promise<{ aliases: Record<string, string>; mdx: MdxOptions | null }> {\n if (typeof config.webpack !== \"function\") {\n return { aliases: {}, mdx: null };\n }\n\n // oxlint-disable-next-line typescript/no-explicit-any\n const mockModuleRules: any[] = [];\n const mockResolve: { alias: Record<string, unknown> } = { alias: {} };\n const mockConfig = {\n context: root,\n resolve: mockResolve,\n module: { rules: mockModuleRules },\n // oxlint-disable-next-line typescript/no-explicit-any\n plugins: [] as any[],\n };\n const mockOptions = {\n defaultLoaders: { babel: { loader: \"next-babel-loader\" } },\n isServer: false,\n dev: false,\n dir: root,\n };\n\n try {\n // oxlint-disable-next-line typescript/no-unsafe-function-type\n const result = await (config.webpack as Function)(mockConfig, mockOptions);\n const finalConfig = result ?? mockConfig;\n // oxlint-disable-next-line typescript/no-explicit-any\n const rules: any[] = finalConfig.module?.rules ?? mockModuleRules;\n return {\n aliases: normalizeAliasEntries(finalConfig.resolve?.alias, root),\n mdx: extractMdxOptionsFromRules(rules),\n };\n } catch {\n return { aliases: {}, mdx: null };\n }\n}\n\n/**\n * Extract MDX compilation options (remark/rehype/recma plugins) from\n * a Next.js config that uses @next/mdx.\n *\n * @next/mdx wraps the config with a webpack function that injects an MDX\n * loader rule. The remark/rehype plugins are captured in that closure.\n * We probe the webpack function with a mock config to extract them.\n */\nexport async function extractMdxOptions(\n config: NextConfig,\n root: string = process.cwd(),\n): Promise<MdxOptions | null> {\n return (await probeWebpackConfig(config, root)).mdx;\n}\n\n/**\n * Probe file candidates relative to root. Returns the first one that exists,\n * or null if none match.\n */\nfunction probeFiles(root: string, candidates: string[]): string | null {\n for (const candidate of candidates) {\n const abs = path.resolve(root, candidate);\n if (fs.existsSync(abs)) return abs;\n }\n return null;\n}\n\nconst I18N_REQUEST_CANDIDATES = [\n \"i18n/request.ts\",\n \"i18n/request.tsx\",\n \"i18n/request.js\",\n \"i18n/request.jsx\",\n \"src/i18n/request.ts\",\n \"src/i18n/request.tsx\",\n \"src/i18n/request.js\",\n \"src/i18n/request.jsx\",\n];\n\n/**\n * Detect next-intl in the project and auto-register the `next-intl/config`\n * alias if needed.\n *\n * next-intl's `createNextIntlPlugin()` crashes in vinext because it calls\n * `require('next/package.json')` to check the Next.js version. Instead,\n * vinext detects next-intl and registers the alias automatically.\n *\n * Note: `require.resolve('next-intl')` walks up to parent `node_modules`\n * directories via standard Node module resolution. In a monorepo, next-intl\n * installed at the workspace root will trigger detection even if not listed\n * in the project's own package.json. This is acceptable since a workspace-root\n * install implies the user wants it available.\n *\n * Mutates `resolved.aliases` and `resolved.env` in place.\n */\nexport function detectNextIntlConfig(root: string, resolved: ResolvedNextConfig): void {\n // Explicit alias wins — user or plugin already set it\n if (resolved.aliases[\"next-intl/config\"]) return;\n\n // Check if next-intl is installed (use main entry — some packages\n // don't expose ./package.json in their exports map)\n const require = createRequire(path.join(root, \"package.json\"));\n try {\n require.resolve(\"next-intl\");\n } catch {\n return; // next-intl not installed\n }\n\n // Probe for the i18n request config file\n const configPath = probeFiles(root, I18N_REQUEST_CANDIDATES);\n if (!configPath) return;\n\n resolved.aliases[\"next-intl/config\"] = configPath;\n\n if (resolved.trailingSlash) {\n resolved.env._next_intl_trailing_slash = \"true\";\n }\n}\n\n// oxlint-disable-next-line typescript/no-explicit-any\nfunction extractMdxOptionsFromRules(rules: any[]): MdxOptions | null {\n // Search through webpack rules for the MDX loader injected by @next/mdx\n for (const rule of rules) {\n const loaders = extractMdxLoaders(rule);\n if (loaders) return loaders;\n }\n return null;\n}\n\n/**\n * Recursively search a webpack rule (which may have nested `oneOf` arrays)\n * for an MDX loader and extract its remark/rehype/recma plugin options.\n */\n// oxlint-disable-next-line typescript/no-explicit-any\nfunction extractMdxLoaders(rule: any): MdxOptions | null {\n if (!rule) return null;\n\n // Check `oneOf` arrays (Next.js uses these extensively)\n if (Array.isArray(rule.oneOf)) {\n for (const child of rule.oneOf) {\n const result = extractMdxLoaders(child);\n if (result) return result;\n }\n }\n\n // Check `use` array (loader chain)\n const use = Array.isArray(rule.use) ? rule.use : rule.use ? [rule.use] : [];\n for (const loader of use) {\n const loaderPath = typeof loader === \"string\" ? loader : loader?.loader;\n if (typeof loaderPath === \"string\" && isMdxLoader(loaderPath)) {\n const opts = typeof loader === \"object\" ? loader.options : {};\n return extractPluginsFromOptions(opts);\n }\n }\n\n // Check direct `loader` field\n if (typeof rule.loader === \"string\" && isMdxLoader(rule.loader)) {\n return extractPluginsFromOptions(rule.options);\n }\n\n return null;\n}\n\nfunction isMdxLoader(loaderPath: string): boolean {\n return (\n loaderPath.includes(\"mdx\") &&\n (loaderPath.includes(\"@next\") ||\n loaderPath.includes(\"@mdx-js\") ||\n loaderPath.includes(\"mdx-js-loader\") ||\n loaderPath.includes(\"next-mdx\"))\n );\n}\n\n// oxlint-disable-next-line typescript/no-explicit-any\nfunction extractPluginsFromOptions(opts: any): MdxOptions | null {\n if (!opts || typeof opts !== \"object\") return null;\n\n const remarkPlugins = Array.isArray(opts.remarkPlugins) ? opts.remarkPlugins : undefined;\n const rehypePlugins = Array.isArray(opts.rehypePlugins) ? opts.rehypePlugins : undefined;\n const recmaPlugins = Array.isArray(opts.recmaPlugins) ? opts.recmaPlugins : undefined;\n\n // Only return if at least one plugin array is non-empty\n if (\n (remarkPlugins && remarkPlugins.length > 0) ||\n (rehypePlugins && rehypePlugins.length > 0) ||\n (recmaPlugins && recmaPlugins.length > 0)\n ) {\n return {\n ...(remarkPlugins && remarkPlugins.length > 0 ? { remarkPlugins } : {}),\n ...(rehypePlugins && rehypePlugins.length > 0 ? { rehypePlugins } : {}),\n ...(recmaPlugins && recmaPlugins.length > 0 ? { recmaPlugins } : {}),\n };\n }\n\n return null;\n}\n\nexport { PHASE_PRODUCTION_BUILD } from \"vinext/shims/constants\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,mBAAmB,OAAmD;CACpF,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM,OAAO,IAAI,OAAO;CAC7D,IAAI,OAAO,UAAU,UAAU;EAC7B,IAAI,QAAQ,GAAG,MAAM,IAAI,MAAM,kDAAkD,QAAQ;EACzF,OAAO;;CAGT,MAAM,QADU,MAAM,MACD,CAAC,MAAM,2CAA2C;CACvE,IAAI,CAAC,OAAO;EACV,QAAQ,KACN,0CAA0C,MAAM,4EACjD;EACD,OAAO,IAAI,OAAO;;CAEpB,MAAM,MAAM,WAAW,MAAM,GAAG;CAChC,MAAM,QAAQ,MAAM,MAAM,KAAK,aAAa;CAC5C,IAAI;CACJ,QAAQ,MAAR;EACE,KAAK;GACH,QAAQ,KAAK,MAAM,IAAI;GACvB;EACF,KAAK;GACH,QAAQ,KAAK,MAAM,MAAM,KAAK;GAC9B;EACF,KAAK;GACH,QAAQ,KAAK,MAAM,MAAM,OAAO,KAAK;GACrC;EACF,KAAK;GACH,QAAQ,KAAK,MAAM,MAAM,OAAO,OAAO,KAAK;GAC5C;EACF,KAAK;GACH,QAAQ,KAAK,MAAM,MAAM,OAAO,OAAO,OAAO,KAAK;GACnD;E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iBAAiB,cAAc,SAAS,IAAI,EAAE,eAAe,GAAG,EAAE;EACtE,GAAI,iBAAiB,cAAc,SAAS,IAAI,EAAE,eAAe,GAAG,EAAE;EACtE,GAAI,gBAAgB,aAAa,SAAS,IAAI,EAAE,cAAc,GAAG,EAAE;EACpE;CAGH,OAAO"}
|
package/dist/deploy.js
CHANGED
|
@@ -273,7 +273,7 @@ function generateAppRouterWorkerEntry(hasISR = false) {
|
|
|
273
273
|
* For apps without image optimization, you can use vinext/server/app-router-entry
|
|
274
274
|
* directly in wrangler.jsonc: "main": "vinext/server/app-router-entry"
|
|
275
275
|
*/
|
|
276
|
-
import { handleImageOptimization, DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES } from "vinext/server/image-optimization";
|
|
276
|
+
import { handleImageOptimization, DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES, isImageOptimizationPath } from "vinext/server/image-optimization";
|
|
277
277
|
import type { ImageConfig } from "vinext/server/image-optimization";
|
|
278
278
|
import handler from "vinext/server/app-router-entry";
|
|
279
279
|
${hasISR ? `import { KVCacheHandler } from "vinext/cloudflare";
|
|
@@ -312,7 +312,7 @@ ${hasISR ? ` // Wire up KV-backed ISR cache. The vinext RSC entry automatical
|
|
|
312
312
|
// Image optimization via Cloudflare Images binding.
|
|
313
313
|
// The parseImageParams validation inside handleImageOptimization
|
|
314
314
|
// normalizes backslashes and validates the origin hasn't changed.
|
|
315
|
-
if (url.pathname
|
|
315
|
+
if (isImageOptimizationPath(url.pathname)) {
|
|
316
316
|
const allowedWidths = [...DEFAULT_DEVICE_SIZES, ...DEFAULT_IMAGE_SIZES];
|
|
317
317
|
return handleImageOptimization(request, {
|
|
318
318
|
fetchAsset: (path) => env.ASSETS.fetch(new Request(new URL(path, request.url))),
|
|
@@ -337,7 +337,7 @@ function generatePagesRouterWorkerEntry() {
|
|
|
337
337
|
* Cloudflare Worker entry point -- auto-generated by vinext deploy.
|
|
338
338
|
* Edit freely or delete to regenerate on next deploy.
|
|
339
339
|
*/
|
|
340
|
-
import { handleImageOptimization, DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES } from "vinext/server/image-optimization";
|
|
340
|
+
import { handleImageOptimization, DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES, isImageOptimizationPath } from "vinext/server/image-optimization";
|
|
341
341
|
import type { ImageConfig } from "vinext/server/image-optimization";
|
|
342
342
|
import {
|
|
343
343
|
matchRedirect,
|
|
@@ -446,8 +446,8 @@ export default {
|
|
|
446
446
|
const basePathState = { basePath, hadBasePath };
|
|
447
447
|
|
|
448
448
|
// ── Image optimization via Cloudflare Images binding ──────────
|
|
449
|
-
// Checked after basePath stripping so /<basePath>/
|
|
450
|
-
if (pathname
|
|
449
|
+
// Checked after basePath stripping so /<basePath>/_next/image works.
|
|
450
|
+
if (isImageOptimizationPath(pathname)) {
|
|
451
451
|
const allowedWidths = [...DEFAULT_DEVICE_SIZES, ...DEFAULT_IMAGE_SIZES];
|
|
452
452
|
return handleImageOptimization(request, {
|
|
453
453
|
fetchAsset: (path) => env.ASSETS.fetch(new Request(new URL(path, request.url))),
|
|
@@ -692,10 +692,23 @@ export default {
|
|
|
692
692
|
// ── 9. Page routes ────────────────────────────────────────────
|
|
693
693
|
let response: Response | undefined;
|
|
694
694
|
if (typeof renderPage === "function") {
|
|
695
|
-
|
|
695
|
+
const renderPageMatch =
|
|
696
|
+
typeof matchPageRoute === "function" ? matchPageRoute(resolvedPathname, request) : null;
|
|
697
|
+
const shouldDeferErrorPageOnMiss =
|
|
698
|
+
!isDataRequest && typeof matchPageRoute === "function" && !renderPageMatch;
|
|
699
|
+
const initialRenderOptions = shouldDeferErrorPageOnMiss
|
|
700
|
+
? { renderErrorPageOnMiss: false }
|
|
701
|
+
: undefined;
|
|
702
|
+
response = await renderPage(request, resolvedUrl, null, ctx, undefined, initialRenderOptions);
|
|
696
703
|
|
|
697
704
|
// ── 10. Fallback rewrites (if SSR returned 404) ─────────────
|
|
698
|
-
|
|
705
|
+
let matchedFallbackRewrite = false;
|
|
706
|
+
if (
|
|
707
|
+
response &&
|
|
708
|
+
response.status === 404 &&
|
|
709
|
+
shouldDeferErrorPageOnMiss &&
|
|
710
|
+
configRewrites.fallback?.length
|
|
711
|
+
) {
|
|
699
712
|
const fallbackRewrite = matchRewrite(
|
|
700
713
|
matchResolvedPathname(resolvedPathname),
|
|
701
714
|
configRewrites.fallback,
|
|
@@ -706,6 +719,7 @@ export default {
|
|
|
706
719
|
if (isExternalUrl(fallbackRewrite)) {
|
|
707
720
|
return proxyExternalRequest(request, fallbackRewrite);
|
|
708
721
|
}
|
|
722
|
+
matchedFallbackRewrite = true;
|
|
709
723
|
response = await renderPage(
|
|
710
724
|
request,
|
|
711
725
|
mergeRewriteQuery(resolvedUrl, fallbackRewrite),
|
|
@@ -714,6 +728,14 @@ export default {
|
|
|
714
728
|
);
|
|
715
729
|
}
|
|
716
730
|
}
|
|
731
|
+
if (
|
|
732
|
+
response &&
|
|
733
|
+
response.status === 404 &&
|
|
734
|
+
shouldDeferErrorPageOnMiss &&
|
|
735
|
+
!matchedFallbackRewrite
|
|
736
|
+
) {
|
|
737
|
+
response = await renderPage(request, resolvedUrl, null, ctx);
|
|
738
|
+
}
|
|
717
739
|
}
|
|
718
740
|
|
|
719
741
|
if (!response) {
|