next 16.1.1-canary.13 → 16.1.1-canary.14

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.
Files changed (85) hide show
  1. package/dist/.build-commit +1 -1
  2. package/dist/bin/next +2 -2
  3. package/dist/build/index.js +3 -3
  4. package/dist/build/swc/index.js +1 -1
  5. package/dist/build/type-check.js +4 -3
  6. package/dist/build/type-check.js.map +1 -1
  7. package/dist/build/webpack-config.js +3 -3
  8. package/dist/bundle-analyzer/404.html +2 -2
  9. package/dist/bundle-analyzer/__next.__PAGE__.txt +1 -1
  10. package/dist/bundle-analyzer/__next._full.txt +1 -1
  11. package/dist/bundle-analyzer/__next._head.txt +1 -1
  12. package/dist/bundle-analyzer/__next._index.txt +1 -1
  13. package/dist/bundle-analyzer/__next._tree.txt +1 -1
  14. package/dist/bundle-analyzer/_not-found/__next._full.txt +1 -1
  15. package/dist/bundle-analyzer/_not-found/__next._head.txt +1 -1
  16. package/dist/bundle-analyzer/_not-found/__next._index.txt +1 -1
  17. package/dist/bundle-analyzer/_not-found/__next._not-found.__PAGE__.txt +1 -1
  18. package/dist/bundle-analyzer/_not-found/__next._not-found.txt +1 -1
  19. package/dist/bundle-analyzer/_not-found/__next._tree.txt +1 -1
  20. package/dist/bundle-analyzer/_not-found.html +2 -2
  21. package/dist/bundle-analyzer/_not-found.txt +1 -1
  22. package/dist/bundle-analyzer/index.html +2 -2
  23. package/dist/bundle-analyzer/index.txt +1 -1
  24. package/dist/cli/next-test.js +2 -1
  25. package/dist/cli/next-test.js.map +1 -1
  26. package/dist/cli/next-typegen.js +4 -2
  27. package/dist/cli/next-typegen.js.map +1 -1
  28. package/dist/client/app-bootstrap.js +1 -1
  29. package/dist/client/index.js +1 -1
  30. package/dist/compiled/next-server/pages-api.runtime.dev.js +1 -1
  31. package/dist/compiled/next-server/pages-api.runtime.dev.js.map +1 -1
  32. package/dist/compiled/next-server/pages.runtime.dev.js +1 -1
  33. package/dist/compiled/next-server/pages.runtime.dev.js.map +1 -1
  34. package/dist/esm/build/index.js +3 -3
  35. package/dist/esm/build/swc/index.js +1 -1
  36. package/dist/esm/build/type-check.js +4 -3
  37. package/dist/esm/build/type-check.js.map +1 -1
  38. package/dist/esm/build/webpack-config.js +3 -3
  39. package/dist/esm/client/app-bootstrap.js +1 -1
  40. package/dist/esm/client/index.js +1 -1
  41. package/dist/esm/lib/typescript/writeAppTypeDeclarations.js +18 -10
  42. package/dist/esm/lib/typescript/writeAppTypeDeclarations.js.map +1 -1
  43. package/dist/esm/lib/typescript/writeConfigurationDefaults.js +8 -7
  44. package/dist/esm/lib/typescript/writeConfigurationDefaults.js.map +1 -1
  45. package/dist/esm/lib/verify-typescript-setup.js +5 -4
  46. package/dist/esm/lib/verify-typescript-setup.js.map +1 -1
  47. package/dist/esm/server/dev/hot-reloader-turbopack.js +1 -1
  48. package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
  49. package/dist/esm/server/lib/app-info-log.js +1 -1
  50. package/dist/esm/server/lib/router-utils/route-types-utils.js +0 -20
  51. package/dist/esm/server/lib/router-utils/route-types-utils.js.map +1 -1
  52. package/dist/esm/server/lib/router-utils/setup-dev-bundler.js +3 -8
  53. package/dist/esm/server/lib/router-utils/setup-dev-bundler.js.map +1 -1
  54. package/dist/esm/server/lib/router-utils/typegen.js +7 -11
  55. package/dist/esm/server/lib/router-utils/typegen.js.map +1 -1
  56. package/dist/esm/server/lib/start-server.js +1 -1
  57. package/dist/esm/shared/lib/errors/canary-only-config-error.js +1 -1
  58. package/dist/lib/typescript/writeAppTypeDeclarations.d.ts +3 -3
  59. package/dist/lib/typescript/writeAppTypeDeclarations.js +18 -10
  60. package/dist/lib/typescript/writeAppTypeDeclarations.js.map +1 -1
  61. package/dist/lib/typescript/writeConfigurationDefaults.d.ts +1 -1
  62. package/dist/lib/typescript/writeConfigurationDefaults.js +8 -7
  63. package/dist/lib/typescript/writeConfigurationDefaults.js.map +1 -1
  64. package/dist/lib/verify-typescript-setup.d.ts +3 -3
  65. package/dist/lib/verify-typescript-setup.js +5 -4
  66. package/dist/lib/verify-typescript-setup.js.map +1 -1
  67. package/dist/server/dev/hot-reloader-turbopack.js +1 -1
  68. package/dist/server/dev/hot-reloader-webpack.js +1 -1
  69. package/dist/server/lib/app-info-log.js +1 -1
  70. package/dist/server/lib/router-utils/route-types-utils.d.ts +0 -9
  71. package/dist/server/lib/router-utils/route-types-utils.js +0 -17
  72. package/dist/server/lib/router-utils/route-types-utils.js.map +1 -1
  73. package/dist/server/lib/router-utils/setup-dev-bundler.js +2 -7
  74. package/dist/server/lib/router-utils/setup-dev-bundler.js.map +1 -1
  75. package/dist/server/lib/router-utils/typegen.js +7 -11
  76. package/dist/server/lib/router-utils/typegen.js.map +1 -1
  77. package/dist/server/lib/start-server.js +1 -1
  78. package/dist/shared/lib/errors/canary-only-config-error.js +1 -1
  79. package/dist/telemetry/anonymous-meta.js +1 -1
  80. package/dist/telemetry/events/session-stopped.js +2 -2
  81. package/dist/telemetry/events/version.js +2 -2
  82. package/package.json +15 -15
  83. /package/dist/bundle-analyzer/_next/static/{bo6zOIZ5tUP7aVRjeqElS → mqnk7CZQ-0CmHbCRF2ua6}/_buildManifest.js +0 -0
  84. /package/dist/bundle-analyzer/_next/static/{bo6zOIZ5tUP7aVRjeqElS → mqnk7CZQ-0CmHbCRF2ua6}/_clientMiddlewareManifest.json +0 -0
  85. /package/dist/bundle-analyzer/_next/static/{bo6zOIZ5tUP7aVRjeqElS → mqnk7CZQ-0CmHbCRF2ua6}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/typescript/writeConfigurationDefaults.ts"],"sourcesContent":["import { readFileSync, writeFileSync } from 'fs'\nimport { bold, cyan, white } from '../picocolors'\nimport * as CommentJson from 'next/dist/compiled/comment-json'\nimport semver from 'next/dist/compiled/semver'\nimport os from 'os'\nimport type { CompilerOptions } from 'typescript'\nimport { getTypeDefinitionGlobPatterns } from './type-paths'\nimport * as Log from '../../build/output/log'\nimport { defaultConfig } from '../../server/config-shared'\n\ntype DesiredCompilerOptionsShape = {\n [K in keyof CompilerOptions]:\n | { suggested: any; reason?: string }\n | {\n parsedValue?: any\n parsedValues?: Array<any>\n value: any\n reason: string\n }\n}\n\nfunction getDesiredCompilerOptions(\n typescriptVersion: string,\n userTsConfig?: Record<string, any>\n): DesiredCompilerOptionsShape {\n // ModuleKind\n const moduleKindESNext = 'esnext'\n const moduleKindES2020 = 'es2020'\n const moduleKindPreserve = 'preserve'\n const moduleKindNodeNext = 'nodenext'\n const moduleKindNode16 = 'node16'\n const moduleKindCommonJS = 'commonjs'\n const moduleKindAMD = 'amd'\n\n // ModuleResolutionKind\n const moduleResolutionKindBundler = 'bundler'\n const moduleResolutionKindNode10 = 'node10'\n const moduleResolutionKindNode12 = 'node12'\n const moduleResolutionKindNodeJs = 'node'\n\n // Jsx\n const jsxEmitReactJSX = 'react-jsx'\n\n return {\n target: {\n suggested: 'ES2017',\n reason:\n 'For top-level `await`. Note: Next.js only polyfills for the esmodules target.',\n },\n // These are suggested values and will be set when not present in the\n // tsconfig.json\n lib: { suggested: ['dom', 'dom.iterable', 'esnext'] },\n allowJs: { suggested: true },\n skipLibCheck: { suggested: true },\n strict: { suggested: false },\n noEmit: { suggested: true },\n incremental: { suggested: true },\n\n // These values are required and cannot be changed by the user\n // Keep this in sync with the webpack config\n // 'parsedValue' matches the output value from ts.parseJsonConfigFileContent()\n module: {\n parsedValue: moduleKindESNext,\n // All of these values work:\n parsedValues: [\n semver.gte(typescriptVersion, '5.4.0') && moduleKindPreserve,\n moduleKindES2020,\n moduleKindESNext,\n moduleKindCommonJS,\n moduleKindAMD,\n moduleKindNodeNext,\n moduleKindNode16,\n ],\n value: 'esnext',\n reason: 'for dynamic import() support',\n },\n // TODO: Semver check not needed once Next.js repo uses 5.4.\n ...(semver.gte(typescriptVersion, '5.4.0') &&\n userTsConfig?.compilerOptions?.module?.toLowerCase() === moduleKindPreserve\n ? {\n // TypeScript 5.4 introduced `Preserve`. Using `Preserve` implies\n // - `moduleResolution` is `Bundler`\n // - `esModuleInterop` is `true`\n // - `resolveJsonModule` is `true`\n // This means that if the user is using Preserve, they don't need these options\n }\n : {\n esModuleInterop: {\n value: true,\n reason: 'requirement for SWC / babel',\n },\n moduleResolution: {\n // In TypeScript 5.0, `NodeJs` has renamed to `Node10`\n parsedValue: moduleResolutionKindBundler,\n // All of these values work:\n parsedValues: [\n moduleResolutionKindNode10,\n moduleResolutionKindNodeJs,\n // only newer TypeScript versions have this field, it\n // will be filtered for new versions of TypeScript\n moduleResolutionKindNode12,\n moduleKindNode16,\n moduleKindNodeNext,\n moduleResolutionKindBundler,\n ].filter((val) => typeof val !== 'undefined'),\n value: 'node',\n reason: 'to match webpack resolution',\n },\n resolveJsonModule: {\n value: true,\n reason: 'to match webpack resolution',\n },\n }),\n ...(userTsConfig?.compilerOptions?.verbatimModuleSyntax === true\n ? undefined\n : {\n isolatedModules: {\n value: true,\n reason: 'requirement for SWC / Babel',\n },\n }),\n jsx: {\n parsedValue: jsxEmitReactJSX,\n value: 'react-jsx',\n reason: 'next.js uses the React automatic runtime',\n },\n } satisfies DesiredCompilerOptionsShape\n}\n\nexport function getRequiredConfiguration(\n typescript: typeof import('typescript')\n): Partial<import('typescript').CompilerOptions> {\n const res: Partial<import('typescript').CompilerOptions> = {}\n const typescriptVersion = typescript.version\n\n const desiredCompilerOptions = getDesiredCompilerOptions(typescriptVersion)\n for (const optionKey of Object.keys(desiredCompilerOptions)) {\n const ev = desiredCompilerOptions[optionKey]\n if (!('value' in ev)) {\n continue\n }\n\n const value = ev.parsedValue ?? ev.value\n\n // Convert string values back to TypeScript enum values\n if (optionKey === 'module' && typeof value === 'string') {\n const moduleMap: Record<string, import('typescript').ModuleKind> = {\n esnext: typescript.ModuleKind.ESNext,\n es2020: typescript.ModuleKind.ES2020,\n ...(typescript.ModuleKind.Preserve !== undefined\n ? { preserve: typescript.ModuleKind.Preserve }\n : {}),\n nodenext: typescript.ModuleKind.NodeNext,\n node16: typescript.ModuleKind.Node16,\n commonjs: typescript.ModuleKind.CommonJS,\n amd: typescript.ModuleKind.AMD,\n }\n res[optionKey] = moduleMap[value.toLowerCase()] ?? value\n } else if (optionKey === 'moduleResolution' && typeof value === 'string') {\n const moduleResolutionMap: Record<\n string,\n import('typescript').ModuleResolutionKind\n > = {\n bundler: typescript.ModuleResolutionKind.Bundler,\n node10: typescript.ModuleResolutionKind.Node10,\n node12: (typescript.ModuleResolutionKind as any).Node12,\n node: typescript.ModuleResolutionKind.NodeJs,\n }\n res[optionKey] = moduleResolutionMap[value.toLowerCase()] ?? value\n } else if (optionKey === 'jsx' && typeof value === 'string') {\n const jsxMap: Record<string, import('typescript').JsxEmit> = {\n 'react-jsx': typescript.JsxEmit.ReactJSX,\n }\n res[optionKey] = jsxMap[value.toLowerCase()] ?? value\n } else {\n res[optionKey] = value\n }\n }\n\n return res\n}\n\nconst localDevTestFilesExcludeAction =\n 'NEXT_PRIVATE_LOCAL_DEV_TEST_FILES_EXCLUDE'\n\nexport async function writeConfigurationDefaults(\n typescriptVersion: string,\n tsConfigPath: string,\n isFirstTimeSetup: boolean,\n hasAppDir: boolean,\n distDir: string,\n hasPagesDir: boolean,\n isolatedDevBuild: boolean | undefined\n): Promise<void> {\n if (isFirstTimeSetup) {\n writeFileSync(tsConfigPath, '{}' + os.EOL)\n }\n\n const userTsConfigContent = readFileSync(tsConfigPath, {\n encoding: 'utf8',\n })\n const userTsConfig = CommentJson.parse(userTsConfigContent)\n\n // Bail automatic setup when the user has extended or referenced another config\n if ('extends' in userTsConfig || 'references' in userTsConfig) {\n return\n }\n\n if (userTsConfig?.compilerOptions == null) {\n userTsConfig.compilerOptions = {}\n isFirstTimeSetup = true\n }\n\n const desiredCompilerOptions = getDesiredCompilerOptions(\n typescriptVersion,\n userTsConfig\n )\n\n const suggestedActions: string[] = []\n const requiredActions: string[] = []\n for (const optionKey in desiredCompilerOptions) {\n const check = desiredCompilerOptions[optionKey]\n if ('suggested' in check) {\n if (!(optionKey in userTsConfig?.compilerOptions)) {\n userTsConfig.compilerOptions[optionKey] = check.suggested\n suggestedActions.push(\n cyan(optionKey) +\n ' was set to ' +\n bold(check.suggested) +\n (check.reason ? ` (${check.reason})` : '')\n )\n }\n } else if ('value' in check) {\n let existingValue = userTsConfig?.compilerOptions?.[optionKey]\n\n if (typeof existingValue === 'string') {\n existingValue = existingValue.toLowerCase()\n }\n\n const shouldWriteRequiredValue = () => {\n // Check if the option has multiple allowed values\n if (check.parsedValues) {\n return !check.parsedValues.includes(existingValue)\n }\n\n // Check if the option has a single parsed value\n if (check.parsedValue) {\n return check.parsedValue !== existingValue\n }\n\n // Fall back to direct value comparison\n return check.value !== existingValue\n }\n\n if (shouldWriteRequiredValue()) {\n if (!userTsConfig.compilerOptions) {\n userTsConfig.compilerOptions = {}\n }\n userTsConfig.compilerOptions[optionKey] = check.value\n requiredActions.push(\n cyan(optionKey) +\n ' was set to ' +\n bold(check.value) +\n ` (${check.reason})`\n )\n }\n } else {\n const _: never = check\n }\n }\n\n const resolvedIsolatedDevBuild =\n isolatedDevBuild === undefined\n ? defaultConfig.experimental.isolatedDevBuild\n : isolatedDevBuild\n\n // Get type definition glob patterns using shared utility to ensure consistency\n // with other TypeScript infrastructure (e.g., runTypeCheck.ts)\n const nextAppTypes = getTypeDefinitionGlobPatterns(\n distDir,\n resolvedIsolatedDevBuild\n )\n\n if (!('include' in userTsConfig)) {\n userTsConfig.include = hasAppDir\n ? ['next-env.d.ts', ...nextAppTypes, '**/*.mts', '**/*.ts', '**/*.tsx']\n : ['next-env.d.ts', '**/*.mts', '**/*.ts', '**/*.tsx']\n suggestedActions.push(\n cyan('include') +\n ' was set to ' +\n bold(\n hasAppDir\n ? `['next-env.d.ts', ${nextAppTypes.map((type) => `'${type}'`).join(', ')}, '**/*.mts', '**/*.ts', '**/*.tsx']`\n : `['next-env.d.ts', '**/*.mts', '**/*.ts', '**/*.tsx']`\n )\n )\n } else if (hasAppDir) {\n const missingFromResolved = []\n for (const type of nextAppTypes) {\n if (!userTsConfig.include.includes(type)) {\n missingFromResolved.push(type)\n }\n }\n\n if (missingFromResolved.length > 0) {\n if (!Array.isArray(userTsConfig.include)) {\n userTsConfig.include = []\n }\n\n missingFromResolved.forEach((item) => {\n userTsConfig.include.push(item)\n suggestedActions.push(\n cyan('include') + ' was updated to add ' + bold(`'${item}'`)\n )\n })\n }\n }\n\n // Enable the Next.js typescript plugin.\n if (hasAppDir) {\n // Check if the config or the resolved config has the plugin already.\n const plugins = [\n ...(Array.isArray(userTsConfig?.plugins) ? userTsConfig.plugins : []),\n ...(userTsConfig.compilerOptions &&\n Array.isArray(userTsConfig.compilerOptions.plugins)\n ? userTsConfig.compilerOptions.plugins\n : []),\n ]\n const hasNextPlugin = plugins.some(\n ({ name }: { name: string }) => name === 'next'\n )\n\n // If the TS config extends on another config, we can't add the `plugin` field\n // because that will override the parent config's plugins.\n // Instead we have to show a message to the user to add the plugin manually.\n if (\n !userTsConfig.compilerOptions ||\n (plugins.length &&\n !hasNextPlugin &&\n 'extends' in userTsConfig &&\n (!userTsConfig.compilerOptions ||\n !userTsConfig.compilerOptions.plugins))\n ) {\n Log.info(\n `\\nYour ${bold(\n 'tsconfig.json'\n )} extends another configuration, which means we cannot add the Next.js TypeScript plugin automatically. To improve your development experience, we recommend adding the Next.js plugin (\\`${cyan(\n '\"plugins\": [{ \"name\": \"next\" }]'\n )}\\`) manually to your TypeScript configuration. Learn more: https://nextjs.org/docs/app/api-reference/config/typescript#the-typescript-plugin\\n`\n )\n } else if (!hasNextPlugin) {\n if (!('plugins' in userTsConfig.compilerOptions)) {\n userTsConfig.compilerOptions.plugins = []\n }\n userTsConfig.compilerOptions.plugins.push({ name: 'next' })\n suggestedActions.push(\n cyan('plugins') + ' was updated to add ' + bold(`{ name: 'next' }`)\n )\n }\n\n // If `strict` is set to `false` and `strictNullChecks` is set to `false`,\n // then set `strictNullChecks` to `true`.\n if (\n hasPagesDir &&\n hasAppDir &&\n !userTsConfig?.compilerOptions?.strict &&\n !('strictNullChecks' in userTsConfig?.compilerOptions)\n ) {\n userTsConfig.compilerOptions.strictNullChecks = true\n suggestedActions.push(\n cyan('strictNullChecks') + ' was set to ' + bold(`true`)\n )\n }\n }\n\n if (!('exclude' in userTsConfig)) {\n userTsConfig.exclude = ['node_modules']\n suggestedActions.push(\n cyan('exclude') + ' was set to ' + bold(`['node_modules']`)\n )\n }\n\n // During local development inside Next.js repo, exclude the test files coverage by the local tsconfig\n if (process.env.NEXT_PRIVATE_LOCAL_DEV && userTsConfig.exclude) {\n const tsGlob = '**/*.test.ts'\n const tsxGlob = '**/*.test.tsx'\n let hasUpdates = false\n if (!userTsConfig.exclude.includes(tsGlob)) {\n userTsConfig.exclude.push(tsGlob)\n hasUpdates = true\n }\n if (!userTsConfig.exclude.includes(tsxGlob)) {\n userTsConfig.exclude.push(tsxGlob)\n hasUpdates = true\n }\n\n if (hasUpdates) {\n requiredActions.push(localDevTestFilesExcludeAction)\n }\n }\n\n if (suggestedActions.length < 1 && requiredActions.length < 1) {\n return\n }\n\n writeFileSync(\n tsConfigPath,\n CommentJson.stringify(userTsConfig, null, 2) + os.EOL\n )\n\n Log.info('')\n if (isFirstTimeSetup) {\n Log.info(\n `We detected TypeScript in your project and created a ${cyan(\n 'tsconfig.json'\n )} file for you.`\n )\n return\n }\n\n Log.info(\n `We detected TypeScript in your project and reconfigured your ${cyan(\n 'tsconfig.json'\n )} file for you.${\n userTsConfig.compilerOptions?.strict\n ? ''\n : ` Strict-mode is set to ${cyan('false')} by default.`\n }`\n )\n\n if (suggestedActions.length) {\n Log.info(\n `The following suggested values were added to your ${cyan(\n 'tsconfig.json'\n )}. These values ${cyan('can be changed')} to fit your project's needs:\\n`\n )\n\n suggestedActions.forEach((action) => Log.info(`\\t- ${action}`))\n\n Log.info('')\n }\n\n const requiredActionsToBeLogged = process.env.NEXT_PRIVATE_LOCAL_DEV\n ? requiredActions.filter(\n (action) => action !== localDevTestFilesExcludeAction\n )\n : requiredActions\n\n if (requiredActionsToBeLogged.length) {\n Log.info(\n `The following ${white('mandatory changes')} were made to your ${cyan(\n 'tsconfig.json'\n )}:\\n`\n )\n\n requiredActionsToBeLogged.forEach((action) => Log.info(`\\t- ${action}`))\n\n Log.info('')\n }\n}\n"],"names":["getRequiredConfiguration","writeConfigurationDefaults","getDesiredCompilerOptions","typescriptVersion","userTsConfig","moduleKindESNext","moduleKindES2020","moduleKindPreserve","moduleKindNodeNext","moduleKindNode16","moduleKindCommonJS","moduleKindAMD","moduleResolutionKindBundler","moduleResolutionKindNode10","moduleResolutionKindNode12","moduleResolutionKindNodeJs","jsxEmitReactJSX","target","suggested","reason","lib","allowJs","skipLibCheck","strict","noEmit","incremental","module","parsedValue","parsedValues","semver","gte","value","compilerOptions","toLowerCase","esModuleInterop","moduleResolution","filter","val","resolveJsonModule","verbatimModuleSyntax","undefined","isolatedModules","jsx","typescript","res","version","desiredCompilerOptions","optionKey","Object","keys","ev","moduleMap","esnext","ModuleKind","ESNext","es2020","ES2020","Preserve","preserve","nodenext","NodeNext","node16","Node16","commonjs","CommonJS","amd","AMD","moduleResolutionMap","bundler","ModuleResolutionKind","Bundler","node10","Node10","node12","Node12","node","NodeJs","jsxMap","JsxEmit","ReactJSX","localDevTestFilesExcludeAction","tsConfigPath","isFirstTimeSetup","hasAppDir","distDir","hasPagesDir","isolatedDevBuild","writeFileSync","os","EOL","userTsConfigContent","readFileSync","encoding","CommentJson","parse","suggestedActions","requiredActions","check","push","cyan","bold","existingValue","shouldWriteRequiredValue","includes","_","resolvedIsolatedDevBuild","defaultConfig","experimental","nextAppTypes","getTypeDefinitionGlobPatterns","include","map","type","join","missingFromResolved","length","Array","isArray","forEach","item","plugins","hasNextPlugin","some","name","Log","info","strictNullChecks","exclude","process","env","NEXT_PRIVATE_LOCAL_DEV","tsGlob","tsxGlob","hasUpdates","stringify","action","requiredActionsToBeLogged","white"],"mappings":";;;;;;;;;;;;;;;IAiIgBA,wBA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Content":["import { readFileSync, writeFileSync } from 'fs'\nimport { bold, cyan, white } from '../picocolors'\nimport * as CommentJson from 'next/dist/compiled/comment-json'\nimport semver from 'next/dist/compiled/semver'\nimport os from 'os'\nimport type { CompilerOptions } from 'typescript'\nimport { getTypeDefinitionGlobPatterns } from './type-paths'\nimport * as Log from '../../build/output/log'\nimport { defaultConfig } from '../../server/config-shared'\n\ntype DesiredCompilerOptionsShape = {\n [K in keyof CompilerOptions]:\n | { suggested: any; reason?: string }\n | {\n parsedValue?: any\n parsedValues?: Array<any>\n value: any\n reason: string\n }\n}\n\nfunction getDesiredCompilerOptions(\n typescriptVersion: string,\n userTsConfig?: Record<string, any>\n): DesiredCompilerOptionsShape {\n // ModuleKind\n const moduleKindESNext = 'esnext'\n const moduleKindES2020 = 'es2020'\n const moduleKindPreserve = 'preserve'\n const moduleKindNodeNext = 'nodenext'\n const moduleKindNode16 = 'node16'\n const moduleKindCommonJS = 'commonjs'\n const moduleKindAMD = 'amd'\n\n // ModuleResolutionKind\n const moduleResolutionKindBundler = 'bundler'\n const moduleResolutionKindNode10 = 'node10'\n const moduleResolutionKindNode12 = 'node12'\n const moduleResolutionKindNodeJs = 'node'\n\n // Jsx\n const jsxEmitReactJSX = 'react-jsx'\n\n return {\n target: {\n suggested: 'ES2017',\n reason:\n 'For top-level `await`. Note: Next.js only polyfills for the esmodules target.',\n },\n // These are suggested values and will be set when not present in the\n // tsconfig.json\n lib: { suggested: ['dom', 'dom.iterable', 'esnext'] },\n allowJs: { suggested: true },\n skipLibCheck: { suggested: true },\n strict: { suggested: false },\n noEmit: { suggested: true },\n incremental: { suggested: true },\n\n // These values are required and cannot be changed by the user\n // Keep this in sync with the webpack config\n // 'parsedValue' matches the output value from ts.parseJsonConfigFileContent()\n module: {\n parsedValue: moduleKindESNext,\n // All of these values work:\n parsedValues: [\n semver.gte(typescriptVersion, '5.4.0') && moduleKindPreserve,\n moduleKindES2020,\n moduleKindESNext,\n moduleKindCommonJS,\n moduleKindAMD,\n moduleKindNodeNext,\n moduleKindNode16,\n ],\n value: 'esnext',\n reason: 'for dynamic import() support',\n },\n // TODO: Semver check not needed once Next.js repo uses 5.4.\n ...(semver.gte(typescriptVersion, '5.4.0') &&\n userTsConfig?.compilerOptions?.module?.toLowerCase() === moduleKindPreserve\n ? {\n // TypeScript 5.4 introduced `Preserve`. Using `Preserve` implies\n // - `moduleResolution` is `Bundler`\n // - `esModuleInterop` is `true`\n // - `resolveJsonModule` is `true`\n // This means that if the user is using Preserve, they don't need these options\n }\n : {\n esModuleInterop: {\n value: true,\n reason: 'requirement for SWC / babel',\n },\n moduleResolution: {\n // In TypeScript 5.0, `NodeJs` has renamed to `Node10`\n parsedValue: moduleResolutionKindBundler,\n // All of these values work:\n parsedValues: [\n moduleResolutionKindNode10,\n moduleResolutionKindNodeJs,\n // only newer TypeScript versions have this field, it\n // will be filtered for new versions of TypeScript\n moduleResolutionKindNode12,\n moduleKindNode16,\n moduleKindNodeNext,\n moduleResolutionKindBundler,\n ].filter((val) => typeof val !== 'undefined'),\n value: 'node',\n reason: 'to match webpack resolution',\n },\n resolveJsonModule: {\n value: true,\n reason: 'to match webpack resolution',\n },\n }),\n ...(userTsConfig?.compilerOptions?.verbatimModuleSyntax === true\n ? undefined\n : {\n isolatedModules: {\n value: true,\n reason: 'requirement for SWC / Babel',\n },\n }),\n jsx: {\n parsedValue: jsxEmitReactJSX,\n value: 'react-jsx',\n reason: 'next.js uses the React automatic runtime',\n },\n } satisfies DesiredCompilerOptionsShape\n}\n\nexport function getRequiredConfiguration(\n typescript: typeof import('typescript')\n): Partial<import('typescript').CompilerOptions> {\n const res: Partial<import('typescript').CompilerOptions> = {}\n const typescriptVersion = typescript.version\n\n const desiredCompilerOptions = getDesiredCompilerOptions(typescriptVersion)\n for (const optionKey of Object.keys(desiredCompilerOptions)) {\n const ev = desiredCompilerOptions[optionKey]\n if (!('value' in ev)) {\n continue\n }\n\n const value = ev.parsedValue ?? ev.value\n\n // Convert string values back to TypeScript enum values\n if (optionKey === 'module' && typeof value === 'string') {\n const moduleMap: Record<string, import('typescript').ModuleKind> = {\n esnext: typescript.ModuleKind.ESNext,\n es2020: typescript.ModuleKind.ES2020,\n ...(typescript.ModuleKind.Preserve !== undefined\n ? { preserve: typescript.ModuleKind.Preserve }\n : {}),\n nodenext: typescript.ModuleKind.NodeNext,\n node16: typescript.ModuleKind.Node16,\n commonjs: typescript.ModuleKind.CommonJS,\n amd: typescript.ModuleKind.AMD,\n }\n res[optionKey] = moduleMap[value.toLowerCase()] ?? value\n } else if (optionKey === 'moduleResolution' && typeof value === 'string') {\n const moduleResolutionMap: Record<\n string,\n import('typescript').ModuleResolutionKind\n > = {\n bundler: typescript.ModuleResolutionKind.Bundler,\n node10: typescript.ModuleResolutionKind.Node10,\n node12: (typescript.ModuleResolutionKind as any).Node12,\n node: typescript.ModuleResolutionKind.NodeJs,\n }\n res[optionKey] = moduleResolutionMap[value.toLowerCase()] ?? value\n } else if (optionKey === 'jsx' && typeof value === 'string') {\n const jsxMap: Record<string, import('typescript').JsxEmit> = {\n 'react-jsx': typescript.JsxEmit.ReactJSX,\n }\n res[optionKey] = jsxMap[value.toLowerCase()] ?? value\n } else {\n res[optionKey] = value\n }\n }\n\n return res\n}\n\nconst localDevTestFilesExcludeAction =\n 'NEXT_PRIVATE_LOCAL_DEV_TEST_FILES_EXCLUDE'\n\nexport async function writeConfigurationDefaults(\n typescriptVersion: string,\n tsConfigPath: string,\n isFirstTimeSetup: boolean,\n hasAppDir: boolean,\n distDir: string,\n hasPagesDir: boolean,\n isolatedDevBuild: boolean | undefined,\n strictRouteTypes: boolean\n): Promise<void> {\n if (isFirstTimeSetup) {\n writeFileSync(tsConfigPath, '{}' + os.EOL)\n }\n\n const userTsConfigContent = readFileSync(tsConfigPath, {\n encoding: 'utf8',\n })\n const userTsConfig = CommentJson.parse(userTsConfigContent)\n\n // Bail automatic setup when the user has extended or referenced another config\n if ('extends' in userTsConfig || 'references' in userTsConfig) {\n return\n }\n\n if (userTsConfig?.compilerOptions == null) {\n userTsConfig.compilerOptions = {}\n isFirstTimeSetup = true\n }\n\n const desiredCompilerOptions = getDesiredCompilerOptions(\n typescriptVersion,\n userTsConfig\n )\n\n const suggestedActions: string[] = []\n const requiredActions: string[] = []\n for (const optionKey in desiredCompilerOptions) {\n const check = desiredCompilerOptions[optionKey]\n if ('suggested' in check) {\n if (!(optionKey in userTsConfig?.compilerOptions)) {\n userTsConfig.compilerOptions[optionKey] = check.suggested\n suggestedActions.push(\n cyan(optionKey) +\n ' was set to ' +\n bold(check.suggested) +\n (check.reason ? ` (${check.reason})` : '')\n )\n }\n } else if ('value' in check) {\n let existingValue = userTsConfig?.compilerOptions?.[optionKey]\n\n if (typeof existingValue === 'string') {\n existingValue = existingValue.toLowerCase()\n }\n\n const shouldWriteRequiredValue = () => {\n // Check if the option has multiple allowed values\n if (check.parsedValues) {\n return !check.parsedValues.includes(existingValue)\n }\n\n // Check if the option has a single parsed value\n if (check.parsedValue) {\n return check.parsedValue !== existingValue\n }\n\n // Fall back to direct value comparison\n return check.value !== existingValue\n }\n\n if (shouldWriteRequiredValue()) {\n if (!userTsConfig.compilerOptions) {\n userTsConfig.compilerOptions = {}\n }\n userTsConfig.compilerOptions[optionKey] = check.value\n requiredActions.push(\n cyan(optionKey) +\n ' was set to ' +\n bold(check.value) +\n ` (${check.reason})`\n )\n }\n } else {\n const _: never = check\n }\n }\n\n const resolvedIsolatedDevBuild =\n isolatedDevBuild === undefined\n ? defaultConfig.experimental.isolatedDevBuild\n : isolatedDevBuild\n\n // Get type definition glob patterns using shared utility to ensure consistency\n // with other TypeScript infrastructure (e.g., runTypeCheck.ts)\n const nextTypes = getTypeDefinitionGlobPatterns(\n distDir,\n resolvedIsolatedDevBuild\n )\n\n if (!('include' in userTsConfig)) {\n const defaultInclude =\n hasAppDir && !strictRouteTypes\n ? ['next-env.d.ts', ...nextTypes, '**/*.mts', '**/*.ts', '**/*.tsx']\n : ['next-env.d.ts', '**/*.mts', '**/*.ts', '**/*.tsx']\n\n userTsConfig.include = defaultInclude\n suggestedActions.push(\n cyan('include') +\n ' was set to [' +\n bold(defaultInclude.map((type) => `'${type}'`).join(', ')) +\n ']'\n )\n } else if (hasAppDir && !strictRouteTypes) {\n const missingFromResolved = []\n for (const type of nextTypes) {\n if (!userTsConfig.include.includes(type)) {\n missingFromResolved.push(type)\n }\n }\n\n if (missingFromResolved.length > 0) {\n if (!Array.isArray(userTsConfig.include)) {\n userTsConfig.include = []\n }\n\n missingFromResolved.forEach((item) => {\n userTsConfig.include.push(item)\n suggestedActions.push(\n cyan('include') + ' was updated to add ' + bold(`'${item}'`)\n )\n })\n }\n }\n\n // Enable the Next.js typescript plugin.\n if (hasAppDir) {\n // Check if the config or the resolved config has the plugin already.\n const plugins = [\n ...(Array.isArray(userTsConfig?.plugins) ? userTsConfig.plugins : []),\n ...(userTsConfig.compilerOptions &&\n Array.isArray(userTsConfig.compilerOptions.plugins)\n ? userTsConfig.compilerOptions.plugins\n : []),\n ]\n const hasNextPlugin = plugins.some(\n ({ name }: { name: string }) => name === 'next'\n )\n\n // If the TS config extends on another config, we can't add the `plugin` field\n // because that will override the parent config's plugins.\n // Instead we have to show a message to the user to add the plugin manually.\n if (\n !userTsConfig.compilerOptions ||\n (plugins.length &&\n !hasNextPlugin &&\n 'extends' in userTsConfig &&\n (!userTsConfig.compilerOptions ||\n !userTsConfig.compilerOptions.plugins))\n ) {\n Log.info(\n `\\nYour ${bold(\n 'tsconfig.json'\n )} extends another configuration, which means we cannot add the Next.js TypeScript plugin automatically. To improve your development experience, we recommend adding the Next.js plugin (\\`${cyan(\n '\"plugins\": [{ \"name\": \"next\" }]'\n )}\\`) manually to your TypeScript configuration. Learn more: https://nextjs.org/docs/app/api-reference/config/typescript#the-typescript-plugin\\n`\n )\n } else if (!hasNextPlugin) {\n if (!('plugins' in userTsConfig.compilerOptions)) {\n userTsConfig.compilerOptions.plugins = []\n }\n userTsConfig.compilerOptions.plugins.push({ name: 'next' })\n suggestedActions.push(\n cyan('plugins') + ' was updated to add ' + bold(`{ name: 'next' }`)\n )\n }\n\n // If `strict` is set to `false` and `strictNullChecks` is set to `false`,\n // then set `strictNullChecks` to `true`.\n if (\n hasPagesDir &&\n hasAppDir &&\n !userTsConfig?.compilerOptions?.strict &&\n !('strictNullChecks' in userTsConfig?.compilerOptions)\n ) {\n userTsConfig.compilerOptions.strictNullChecks = true\n suggestedActions.push(\n cyan('strictNullChecks') + ' was set to ' + bold(`true`)\n )\n }\n }\n\n if (!('exclude' in userTsConfig)) {\n userTsConfig.exclude = ['node_modules']\n suggestedActions.push(\n cyan('exclude') + ' was set to ' + bold(`['node_modules']`)\n )\n }\n\n // During local development inside Next.js repo, exclude the test files coverage by the local tsconfig\n if (process.env.NEXT_PRIVATE_LOCAL_DEV && userTsConfig.exclude) {\n const tsGlob = '**/*.test.ts'\n const tsxGlob = '**/*.test.tsx'\n let hasUpdates = false\n if (!userTsConfig.exclude.includes(tsGlob)) {\n userTsConfig.exclude.push(tsGlob)\n hasUpdates = true\n }\n if (!userTsConfig.exclude.includes(tsxGlob)) {\n userTsConfig.exclude.push(tsxGlob)\n hasUpdates = true\n }\n\n if (hasUpdates) {\n requiredActions.push(localDevTestFilesExcludeAction)\n }\n }\n\n if (suggestedActions.length < 1 && requiredActions.length < 1) {\n return\n }\n\n writeFileSync(\n tsConfigPath,\n CommentJson.stringify(userTsConfig, null, 2) + os.EOL\n )\n\n Log.info('')\n if (isFirstTimeSetup) {\n Log.info(\n `We detected TypeScript in your project and created a ${cyan(\n 'tsconfig.json'\n )} file for you.`\n )\n return\n }\n\n Log.info(\n `We detected TypeScript in your project and reconfigured your ${cyan(\n 'tsconfig.json'\n )} file for you.${\n userTsConfig.compilerOptions?.strict\n ? ''\n : ` Strict-mode is set to ${cyan('false')} by default.`\n }`\n )\n\n if (suggestedActions.length) {\n Log.info(\n `The following suggested values were added to your ${cyan(\n 'tsconfig.json'\n )}. These values ${cyan('can be changed')} to fit your project's needs:\\n`\n )\n\n suggestedActions.forEach((action) => Log.info(`\\t- ${action}`))\n\n Log.info('')\n }\n\n const requiredActionsToBeLogged = process.env.NEXT_PRIVATE_LOCAL_DEV\n ? requiredActions.filter(\n (action) => action !== localDevTestFilesExcludeAction\n )\n : requiredActions\n\n if (requiredActionsToBeLogged.length) {\n Log.info(\n `The following ${white('mandatory changes')} were made to your ${cyan(\n 'tsconfig.json'\n )}:\\n`\n )\n\n requiredActionsToBeLogged.forEach((action) => Log.info(`\\t- ${action}`))\n\n Log.info('')\n }\n}\n"],"names":["getRequiredConfiguration","writeConfigurationDefaults","getDesiredCompilerOptions","typescriptVersion","userTsConfig","moduleKindESNext","moduleKindES2020","moduleKindPreserve","moduleKindNodeNext","moduleKindNode16","moduleKindCommonJS","moduleKindAMD","moduleResolutionKindBundler","moduleResolutionKindNode10","moduleResolutionKindNode12","moduleResolutionKindNodeJs","jsxEmitReactJSX","target","suggested","reason","lib","allowJs","skipLibCheck","strict","noEmit","incremental","module","parsedValue","parsedValues","semver","gte","value","compilerOptions","toLowerCase","esModuleInterop","moduleResolution","filter","val","resolveJsonModule","verbatimModuleSyntax","undefined","isolatedModules","jsx","typescript","res","version","desiredCompilerOptions","optionKey","Object","keys","ev","moduleMap","esnext","ModuleKind","ESNext","es2020","ES2020","Preserve","preserve","nodenext","NodeNext","node16","Node16","commonjs","CommonJS","amd","AMD","moduleResolutionMap","bundler","ModuleResolutionKind","Bundler","node10","Node10","node12","Node12","node","NodeJs","jsxMap","JsxEmit","ReactJSX","localDevTestFilesExcludeAction","tsConfigPath","isFirstTimeSetup","hasAppDir","distDir","hasPagesDir","isolatedDevBuild","strictRouteTypes","writeFileSync","os","EOL","userTsConfigContent","readFileSync","encoding","CommentJson","parse","suggestedActions","requiredActions","check","push","cyan","bold","existingValue","shouldWriteRequiredValue","includes","_","resolvedIsolatedDevBuild","defaultConfig","experimental","nextTypes","getTypeDefinitionGlobPatterns","defaultInclude","include","map","type","join","missingFromResolved","length","Array","isArray","forEach","item","plugins","hasNextPlugin","some","name","Log","info","strictNullChecks","exclude","process","env","NEXT_PRIVATE_LOCAL_DEV","tsGlob","tsxGlob","hasUpdates","stringify","action","requiredActionsToBeLogged","white"],"mappings":";;;;;;;;;;;;;;;IAiIgBA,wBAAwB;eAAxBA;;IAwDMC,0BAA0B;eAA1BA;;;oBAzLsB;4BACV;qEACL;+DACV;2DACJ;2BAE+B;6DACzB;8BACS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAa9B,SAASC,0BACPC,iBAAyB,EACzBC,YAAkC;QAuDhCA,sCAAAA,+BAmCIA;IAxFN,aAAa;IACb,MAAMC,mBAAmB;IACzB,MAAMC,mBAAmB;IACzB,MAAMC,qBAAqB;IAC3B,MAAMC,qBAAqB;IAC3B,MAAMC,mBAAmB;IACzB,MAAMC,qBAAqB;IAC3B,MAAMC,gBAAgB;IAEtB,uBAAuB;IACvB,MAAMC,8BAA8B;IACpC,MAAMC,6BAA6B;IACnC,MAAMC,6BAA6B;IACnC,MAAMC,6BAA6B;IAEnC,MAAM;IACN,MAAMC,kBAAkB;IAExB,OAAO;QACLC,QAAQ;YACNC,WAAW;YACXC,QACE;QACJ;QACA,qEAAqE;QACrE,gBAAgB;QAChBC,KAAK;YAAEF,WAAW;gBAAC;gBAAO;gBAAgB;aAAS;QAAC;QACpDG,SAAS;YAAEH,WAAW;QAAK;QAC3BI,cAAc;YAAEJ,WAAW;QAAK;QAChCK,QAAQ;YAAEL,WAAW;QAAM;QAC3BM,QAAQ;YAAEN,WAAW;QAAK;QAC1BO,aAAa;YAAEP,WAAW;QAAK;QAE/B,8DAA8D;QAC9D,4CAA4C;QAC5C,8EAA8E;QAC9EQ,QAAQ;YACNC,aAAatB;YACb,4BAA4B;YAC5BuB,cAAc;gBACZC,eAAM,CAACC,GAAG,CAAC3B,mBAAmB,YAAYI;gBAC1CD;gBACAD;gBACAK;gBACAC;gBACAH;gBACAC;aACD;YACDsB,OAAO;YACPZ,QAAQ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ACiB,SAAWX,KAAIC,IAAI,CAAC,CAAC,IAAI,EAAEU,QAAQ;QAEtEX,KAAIC,IAAI,CAAC;IACX;AACF","ignoreList":[0]}
@@ -1,12 +1,12 @@
1
1
  import type { TypeCheckResult } from './typescript/runTypeCheck';
2
- export declare function verifyTypeScriptSetup({ dir, distDir, distDirRoot, cacheDir, tsconfigPath, typeCheckPreflight, disableStaticImages, hasAppDir, hasPagesDir, isolatedDevBuild, appDir, pagesDir, debugBuildPaths, }: {
2
+ export declare function verifyTypeScriptSetup({ dir, distDir, cacheDir, strictRouteTypes, tsconfigPath, typeCheckPreflight, typedRoutes, disableStaticImages, hasAppDir, hasPagesDir, isolatedDevBuild, appDir, pagesDir, debugBuildPaths, }: {
3
3
  dir: string;
4
4
  distDir: string;
5
- /** The original distDir before any modifications (e.g., for isolatedDevBuild). */
6
- distDirRoot?: string;
7
5
  cacheDir?: string;
6
+ strictRouteTypes: boolean;
8
7
  tsconfigPath: string | undefined;
9
8
  typeCheckPreflight: boolean;
9
+ typedRoutes: boolean;
10
10
  disableStaticImages: boolean;
11
11
  hasAppDir: boolean;
12
12
  hasPagesDir: boolean;
@@ -83,7 +83,7 @@ const requiredPackages = [
83
83
  exportsRestrict: true
84
84
  }
85
85
  ];
86
- async function verifyTypeScriptSetup({ dir, distDir, distDirRoot, cacheDir, tsconfigPath, typeCheckPreflight, disableStaticImages, hasAppDir, hasPagesDir, isolatedDevBuild, appDir, pagesDir, debugBuildPaths }) {
86
+ async function verifyTypeScriptSetup({ dir, distDir, cacheDir, strictRouteTypes, tsconfigPath, typeCheckPreflight, typedRoutes, disableStaticImages, hasAppDir, hasPagesDir, isolatedDevBuild, appDir, pagesDir, debugBuildPaths }) {
87
87
  const tsConfigFileName = tsconfigPath || 'tsconfig.json';
88
88
  const resolvedTsConfigPath = _path.default.join(dir, tsConfigFileName);
89
89
  // Construct intentDirs from appDir and pagesDir for getTypeScriptIntent
@@ -125,16 +125,17 @@ async function verifyTypeScriptSetup({ dir, distDir, distDirRoot, cacheDir, tsco
125
125
  _log.warn(`Minimum recommended TypeScript version is v5.1.0, older versions can potentially be incompatible with Next.js. Detected: ${typescriptVersion}`);
126
126
  }
127
127
  // Reconfigure (or create) the user's `tsconfig.json` for them:
128
- await (0, _writeConfigurationDefaults.writeConfigurationDefaults)(typescriptVersion, resolvedTsConfigPath, intent.firstTimeSetup, hasAppDir, distDir, hasPagesDir, isolatedDevBuild);
128
+ await (0, _writeConfigurationDefaults.writeConfigurationDefaults)(typescriptVersion, resolvedTsConfigPath, intent.firstTimeSetup, hasAppDir, distDir, hasPagesDir, isolatedDevBuild, strictRouteTypes);
129
129
  // Write out the necessary `next-env.d.ts` file to correctly register
130
130
  // Next.js' types:
131
131
  await (0, _writeAppTypeDeclarations.writeAppTypeDeclarations)({
132
132
  baseDir: dir,
133
133
  distDir,
134
- distDirRoot,
135
134
  imageImportsEnabled: !disableStaticImages,
136
135
  hasPagesDir,
137
- hasAppDir
136
+ hasAppDir,
137
+ strictRouteTypes,
138
+ typedRoutes
138
139
  });
139
140
  let result;
140
141
  if (typeCheckPreflight) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/lib/verify-typescript-setup.ts"],"sourcesContent":["import { bold, cyan, red, yellow } from './picocolors'\nimport path, { join } from 'path'\n\nimport { hasNecessaryDependencies } from './has-necessary-dependencies'\nimport type { NecessaryDependencies } from './has-necessary-dependencies'\nimport semver from 'next/dist/compiled/semver'\nimport { CompileError } from './compile-error'\nimport * as log from '../build/output/log'\n\nimport { getTypeScriptIntent } from './typescript/getTypeScriptIntent'\nimport type { TypeCheckResult } from './typescript/runTypeCheck'\nimport { writeAppTypeDeclarations } from './typescript/writeAppTypeDeclarations'\nimport { writeConfigurationDefaults } from './typescript/writeConfigurationDefaults'\nimport { installDependencies } from './install-dependencies'\nimport { isCI } from '../server/ci-info'\nimport { missingDepsError } from './typescript/missingDependencyError'\n\nconst requiredPackages = [\n {\n file: 'typescript/lib/typescript.js',\n pkg: 'typescript',\n exportsRestrict: true,\n },\n {\n file: '@types/react/index.d.ts',\n pkg: '@types/react',\n exportsRestrict: true,\n },\n {\n file: '@types/node/index.d.ts',\n pkg: '@types/node',\n exportsRestrict: true,\n },\n]\n\nexport async function verifyTypeScriptSetup({\n dir,\n distDir,\n distDirRoot,\n cacheDir,\n tsconfigPath,\n typeCheckPreflight,\n disableStaticImages,\n hasAppDir,\n hasPagesDir,\n isolatedDevBuild,\n appDir,\n pagesDir,\n debugBuildPaths,\n}: {\n dir: string\n distDir: string\n /** The original distDir before any modifications (e.g., for isolatedDevBuild). */\n distDirRoot?: string\n cacheDir?: string\n tsconfigPath: string | undefined\n typeCheckPreflight: boolean\n disableStaticImages: boolean\n hasAppDir: boolean\n hasPagesDir: boolean\n isolatedDevBuild: boolean | undefined\n appDir?: string\n pagesDir?: string\n debugBuildPaths?: { app?: string[]; pages?: string[] }\n}): Promise<{ result?: TypeCheckResult; version: string | null }> {\n const tsConfigFileName = tsconfigPath || 'tsconfig.json'\n const resolvedTsConfigPath = path.join(dir, tsConfigFileName)\n\n // Construct intentDirs from appDir and pagesDir for getTypeScriptIntent\n const intentDirs = [pagesDir, appDir].filter(Boolean) as string[]\n\n try {\n // Check if the project uses TypeScript:\n const intent = await getTypeScriptIntent(dir, intentDirs, tsConfigFileName)\n if (!intent) {\n return { version: null }\n }\n\n // Ensure TypeScript and necessary `@types/*` are installed:\n let deps: NecessaryDependencies = hasNecessaryDependencies(\n dir,\n requiredPackages\n )\n\n if (deps.missing?.length > 0) {\n if (isCI) {\n // we don't attempt auto install in CI to avoid side-effects\n // and instead log the error for installing needed packages\n missingDepsError(dir, deps.missing)\n }\n console.log(\n bold(\n yellow(\n `It looks like you're trying to use TypeScript but do not have the required package(s) installed.`\n )\n ) +\n '\\n' +\n 'Installing dependencies' +\n '\\n\\n' +\n bold(\n 'If you are not trying to use TypeScript, please remove the ' +\n cyan('tsconfig.json') +\n ' file from your package root (and any TypeScript files in your app and pages directories).'\n ) +\n '\\n'\n )\n await installDependencies(dir, deps.missing, true).catch((err) => {\n if (err && typeof err === 'object' && 'command' in err) {\n console.error(\n `Failed to install required TypeScript dependencies, please install them manually to continue:\\n` +\n (err as any).command +\n '\\n'\n )\n }\n throw err\n })\n deps = hasNecessaryDependencies(dir, requiredPackages)\n }\n\n // Load TypeScript after we're sure it exists:\n const tsPackageJsonPath = deps.resolved.get(\n join('typescript', 'package.json')\n )!\n const typescriptPackageJson = require(tsPackageJsonPath)\n\n const typescriptVersion = typescriptPackageJson.version\n\n if (semver.lt(typescriptVersion, '5.1.0')) {\n log.warn(\n `Minimum recommended TypeScript version is v5.1.0, older versions can potentially be incompatible with Next.js. Detected: ${typescriptVersion}`\n )\n }\n\n // Reconfigure (or create) the user's `tsconfig.json` for them:\n await writeConfigurationDefaults(\n typescriptVersion,\n resolvedTsConfigPath,\n intent.firstTimeSetup,\n hasAppDir,\n distDir,\n hasPagesDir,\n isolatedDevBuild\n )\n // Write out the necessary `next-env.d.ts` file to correctly register\n // Next.js' types:\n await writeAppTypeDeclarations({\n baseDir: dir,\n distDir,\n distDirRoot,\n imageImportsEnabled: !disableStaticImages,\n hasPagesDir,\n hasAppDir,\n })\n\n let result\n if (typeCheckPreflight) {\n const { runTypeCheck } =\n require('./typescript/runTypeCheck') as typeof import('./typescript/runTypeCheck')\n\n const tsPath = deps.resolved.get('typescript')!\n const typescript = (await Promise.resolve(\n require(tsPath)\n )) as typeof import('typescript')\n\n // Verify the project passes type-checking before we go to webpack phase:\n result = await runTypeCheck(\n typescript,\n dir,\n distDir,\n resolvedTsConfigPath,\n cacheDir,\n hasAppDir,\n isolatedDevBuild,\n { app: appDir, pages: pagesDir },\n debugBuildPaths\n )\n }\n return { result, version: typescriptVersion }\n } catch (err) {\n // These are special errors that should not show a stack trace:\n if (err instanceof CompileError) {\n console.error(red('Failed to compile.\\n'))\n console.error(err.message)\n process.exit(1)\n }\n\n /**\n * verifyTypeScriptSetup can be either invoked directly in the main thread (during next dev / next lint)\n * or run in a worker (during next build). In the latter case, we need to print the error message, as the\n * parent process will only receive an `Jest worker encountered 1 child process exceptions, exceeding retry limit`.\n */\n\n // we are in a worker, print the error message and exit the process\n if (process.env.IS_NEXT_WORKER) {\n if (err instanceof Error) {\n console.error(err.message)\n } else {\n console.error(err)\n }\n process.exit(1)\n }\n // we are in the main thread, throw the error and it will be handled by the caller\n throw err\n }\n}\n"],"names":["verifyTypeScriptSetup","requiredPackages","file","pkg","exportsRestrict","dir","distDir","distDirRoot","cacheDir","tsconfigPath","typeCheckPreflight","disableStaticImages","hasAppDir","hasPagesDir","isolatedDevBuild","appDir","pagesDir","debugBuildPaths","tsConfigFileName","resolvedTsConfigPath","path","join","intentDirs","filter","Boolean","deps","intent","getTypeScriptIntent","version","hasNecessaryDependencies","missing","length","isCI","missingDepsError","console","log","bold","yellow","cyan","installDependencies","catch","err","error","command","tsPackageJsonPath","resolved","get","typescriptPackageJson","require","typescriptVersion","semver","lt","warn","writeConfigurationDefaults","firstTimeSetup","writeAppTypeDeclarations","baseDir","imageImportsEnabled","result","runTypeCheck","tsPath","typescript","Promise","resolve","app","pages","CompileError","red","message","process","exit","env","IS_NEXT_WORKER","Error"],"mappings":";;;;+BAmCsBA;;;eAAAA;;;4BAnCkB;8DACb;0CAEc;+DAEtB;8BACU;6DACR;qCAEe;0CAEK;4CACE;qCACP;wBACf;wCACY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEjC,MAAMC,mBAAmB;IACvB;QACEC,MAAM;QACNC,KAAK;QACLC,iBAAiB;IACnB;IACA;QACEF,MAAM;QACNC,KAAK;QACLC,iBAAiB;IACnB;IACA;QACEF,MAAM;QACNC,KAAK;QACLC,iBAAiB;IACnB;CACD;AAEM,eAAeJ,sBAAsB,EAC1CK,GAAG,EACHC,OAAO,EACPC,WAAW,EACXC,QAAQ,EACRC,YAAY,EACZC,kBAAkB,EAClBC,mBAAmB,EACnBC,SAAS,EACTC,WAAW,EACXC,gBAAgB,EAChBC,M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AClF,MAAM7B;IACR;AACF","ignoreList":[0]}
1
+ {"version":3,"sources":["../../src/lib/verify-typescript-setup.ts"],"sourcesContent":["import { bold, cyan, red, yellow } from './picocolors'\nimport path, { join } from 'path'\n\nimport { hasNecessaryDependencies } from './has-necessary-dependencies'\nimport type { NecessaryDependencies } from './has-necessary-dependencies'\nimport semver from 'next/dist/compiled/semver'\nimport { CompileError } from './compile-error'\nimport * as log from '../build/output/log'\n\nimport { getTypeScriptIntent } from './typescript/getTypeScriptIntent'\nimport type { TypeCheckResult } from './typescript/runTypeCheck'\nimport { writeAppTypeDeclarations } from './typescript/writeAppTypeDeclarations'\nimport { writeConfigurationDefaults } from './typescript/writeConfigurationDefaults'\nimport { installDependencies } from './install-dependencies'\nimport { isCI } from '../server/ci-info'\nimport { missingDepsError } from './typescript/missingDependencyError'\n\nconst requiredPackages = [\n {\n file: 'typescript/lib/typescript.js',\n pkg: 'typescript',\n exportsRestrict: true,\n },\n {\n file: '@types/react/index.d.ts',\n pkg: '@types/react',\n exportsRestrict: true,\n },\n {\n file: '@types/node/index.d.ts',\n pkg: '@types/node',\n exportsRestrict: true,\n },\n]\n\nexport async function verifyTypeScriptSetup({\n dir,\n distDir,\n cacheDir,\n strictRouteTypes,\n tsconfigPath,\n typeCheckPreflight,\n typedRoutes,\n disableStaticImages,\n hasAppDir,\n hasPagesDir,\n isolatedDevBuild,\n appDir,\n pagesDir,\n debugBuildPaths,\n}: {\n dir: string\n distDir: string\n cacheDir?: string\n strictRouteTypes: boolean\n tsconfigPath: string | undefined\n typeCheckPreflight: boolean\n typedRoutes: boolean\n disableStaticImages: boolean\n hasAppDir: boolean\n hasPagesDir: boolean\n isolatedDevBuild: boolean | undefined\n appDir?: string\n pagesDir?: string\n debugBuildPaths?: { app?: string[]; pages?: string[] }\n}): Promise<{ result?: TypeCheckResult; version: string | null }> {\n const tsConfigFileName = tsconfigPath || 'tsconfig.json'\n const resolvedTsConfigPath = path.join(dir, tsConfigFileName)\n\n // Construct intentDirs from appDir and pagesDir for getTypeScriptIntent\n const intentDirs = [pagesDir, appDir].filter(Boolean) as string[]\n\n try {\n // Check if the project uses TypeScript:\n const intent = await getTypeScriptIntent(dir, intentDirs, tsConfigFileName)\n if (!intent) {\n return { version: null }\n }\n\n // Ensure TypeScript and necessary `@types/*` are installed:\n let deps: NecessaryDependencies = hasNecessaryDependencies(\n dir,\n requiredPackages\n )\n\n if (deps.missing?.length > 0) {\n if (isCI) {\n // we don't attempt auto install in CI to avoid side-effects\n // and instead log the error for installing needed packages\n missingDepsError(dir, deps.missing)\n }\n console.log(\n bold(\n yellow(\n `It looks like you're trying to use TypeScript but do not have the required package(s) installed.`\n )\n ) +\n '\\n' +\n 'Installing dependencies' +\n '\\n\\n' +\n bold(\n 'If you are not trying to use TypeScript, please remove the ' +\n cyan('tsconfig.json') +\n ' file from your package root (and any TypeScript files in your app and pages directories).'\n ) +\n '\\n'\n )\n await installDependencies(dir, deps.missing, true).catch((err) => {\n if (err && typeof err === 'object' && 'command' in err) {\n console.error(\n `Failed to install required TypeScript dependencies, please install them manually to continue:\\n` +\n (err as any).command +\n '\\n'\n )\n }\n throw err\n })\n deps = hasNecessaryDependencies(dir, requiredPackages)\n }\n\n // Load TypeScript after we're sure it exists:\n const tsPackageJsonPath = deps.resolved.get(\n join('typescript', 'package.json')\n )!\n const typescriptPackageJson = require(tsPackageJsonPath)\n\n const typescriptVersion = typescriptPackageJson.version\n\n if (semver.lt(typescriptVersion, '5.1.0')) {\n log.warn(\n `Minimum recommended TypeScript version is v5.1.0, older versions can potentially be incompatible with Next.js. Detected: ${typescriptVersion}`\n )\n }\n\n // Reconfigure (or create) the user's `tsconfig.json` for them:\n await writeConfigurationDefaults(\n typescriptVersion,\n resolvedTsConfigPath,\n intent.firstTimeSetup,\n hasAppDir,\n distDir,\n hasPagesDir,\n isolatedDevBuild,\n strictRouteTypes\n )\n // Write out the necessary `next-env.d.ts` file to correctly register\n // Next.js' types:\n await writeAppTypeDeclarations({\n baseDir: dir,\n distDir,\n imageImportsEnabled: !disableStaticImages,\n hasPagesDir,\n hasAppDir,\n strictRouteTypes,\n typedRoutes,\n })\n\n let result\n if (typeCheckPreflight) {\n const { runTypeCheck } =\n require('./typescript/runTypeCheck') as typeof import('./typescript/runTypeCheck')\n\n const tsPath = deps.resolved.get('typescript')!\n const typescript = (await Promise.resolve(\n require(tsPath)\n )) as typeof import('typescript')\n\n // Verify the project passes type-checking before we go to webpack phase:\n result = await runTypeCheck(\n typescript,\n dir,\n distDir,\n resolvedTsConfigPath,\n cacheDir,\n hasAppDir,\n isolatedDevBuild,\n { app: appDir, pages: pagesDir },\n debugBuildPaths\n )\n }\n return { result, version: typescriptVersion }\n } catch (err) {\n // These are special errors that should not show a stack trace:\n if (err instanceof CompileError) {\n console.error(red('Failed to compile.\\n'))\n console.error(err.message)\n process.exit(1)\n }\n\n /**\n * verifyTypeScriptSetup can be either invoked directly in the main thread (during next dev / next lint)\n * or run in a worker (during next build). In the latter case, we need to print the error message, as the\n * parent process will only receive an `Jest worker encountered 1 child process exceptions, exceeding retry limit`.\n */\n\n // we are in a worker, print the error message and exit the process\n if (process.env.IS_NEXT_WORKER) {\n if (err instanceof Error) {\n console.error(err.message)\n } else {\n console.error(err)\n }\n process.exit(1)\n }\n // we are in the main thread, throw the error and it will be handled by the caller\n throw err\n }\n}\n"],"names":["verifyTypeScriptSetup","requiredPackages","file","pkg","exportsRestrict","dir","distDir","cacheDir","strictRouteTypes","tsconfigPath","typeCheckPreflight","typedRoutes","disableStaticImages","hasAppDir","hasPagesDir","isolatedDevBuild","appDir","pagesDir","debugBuildPaths","tsConfigFileName","resolvedTsConfigPath","path","join","intentDirs","filter","Boolean","deps","intent","getTypeScriptIntent","version","hasNecessaryDependencies","missing","length","isCI","missingDepsError","console","log","bold","yellow","cyan","installDependencies","catch","err","error","command","tsPackageJsonPath","resolved","get","typescriptPackageJson","require","typescriptVersion","semver","lt","warn","writeConfigurationDefaults","firstTimeSetup","writeAppTypeDeclarations","baseDir","imageImportsEnabled","result","runTypeCheck","tsPath","typescript","Promise","resolve","app","pages","CompileError","red","message","process","exit","env","IS_NEXT_WORKER","Error"],"mappings":";;;;+BAmCsBA;;;eAAAA;;;4BAnCkB;8DACb;0CAEc;+DAEtB;8BACU;6DACR;qCAEe;0CAEK;4CACE;qCACP;wBACf;wCACY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEjC,MAAMC,mBAAmB;IACvB;QACEC,MAAM;QACNC,KAAK;QACLC,iBAAiB;IACnB;IACA;QACEF,MAAM;QACNC,KAAK;QACLC,iBAAiB;IACnB;IACA;QACEF,MAAM;QACNC,KAAK;QACLC,iBAAiB;IACnB;CACD;AAEM,eAAeJ,sBAAsB,EAC1CK,GAAG,EACHC,OAAO,EACPC,QAAQ,EACRC,gBAAgB,EAChBC,YAAY,EACZC,kBAAkB,EAClBC,WAAW,EACXC,mBAAmB,EACnBC,SAAS,EACTC,WAAW,EACXC,gBAAgB,EAChBC,MAAM,EACNC,QAAQ,EACRC,eAAe,EAgBhB;IACC,MAAMC,mBAAmBV,gBAAgB;IACzC,MAAMW,uBAAuBC,aAAI,CAACC,IAAI,CAACjB,KAAKc;IAE5C,wEAAwE;IACxE,MAAMI,aAAa;QAACN;QAAUD;KAAO,CAACQ,MAAM,CAACC;IAE7C,IAAI;YAaEC;QAZJ,wCAAwC;QACxC,MAAMC,SAAS,MAAMC,IAAAA,wCAAmB,EAACvB,KAAKkB,YAAYJ;QAC1D,IAAI,CAACQ,QAAQ;YACX,OAAO;gBAAEE,SAAS;YAAK;QACzB;QAEA,4DAA4D;QAC5D,IAAIH,OAA8BI,IAAAA,kDAAwB,EACxDzB,KACAJ;QAGF,IAAIyB,EAAAA,gBAAAA,KAAKK,OAAO,qBAAZL,cAAcM,MAAM,IAAG,GAAG;YAC5B,IAAIC,YAAI,EAAE;gBACR,4DAA4D;gBAC5D,2DAA2D;gBAC3DC,IAAAA,wCAAgB,EAAC7B,KAAKqB,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,QAAQY;YAGV,yEAAyE;YACzEF,SAAS,MAAMC,aACbE,YACAzD,KACAC,SACAc,sBACAb,UACAM,WACAE,kBACA;gBAAEkD,KAAKjD;gBAAQkD,OAAOjD;YAAS,GAC/BC;QAEJ;QACA,OAAO;YAAEyC;YAAQ9B,SAASqB;QAAkB;IAC9C,EAAE,OAAOR,KAAK;QACZ,+DAA+D;QAC/D,IAAIA,eAAeyB,0BAAY,EAAE;YAC/BhC,QAAQQ,KAAK,CAACyB,IAAAA,eAAG,EAAC;YAClBjC,QAAQQ,KAAK,CAACD,IAAI2B,OAAO;YACzBC,QAAQC,IAAI,CAAC;QACf;QAEA;;;;KAIC,GAED,mEAAmE;QACnE,IAAID,QAAQE,GAAG,CAACC,cAAc,EAAE;YAC9B,IAAI/B,eAAegC,OAAO;gBACxBvC,QAAQQ,KAAK,CAACD,IAAI2B,OAAO;YAC3B,OAAO;gBACLlC,QAAQQ,KAAK,CAACD;YAChB;YACA4B,QAAQC,IAAI,CAAC;QACf;QACA,kFAAkF;QAClF,MAAM7B;IACR;AACF","ignoreList":[0]}
@@ -153,7 +153,7 @@ async function createHotReloaderTurbopack(opts, serverFields, distDir, resetFetc
153
153
  }
154
154
  const hasRewrites = opts.fsChecker.rewrites.afterFiles.length > 0 || opts.fsChecker.rewrites.beforeFiles.length > 0 || opts.fsChecker.rewrites.fallback.length > 0;
155
155
  const hotReloaderSpan = (0, _trace.trace)('hot-reloader', undefined, {
156
- version: "16.1.1-canary.13"
156
+ version: "16.1.1-canary.14"
157
157
  });
158
158
  // Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
159
159
  // of the current `next dev` invocation.
@@ -233,7 +233,7 @@ class HotReloaderWebpack {
233
233
  this.previewProps = previewProps;
234
234
  this.rewrites = rewrites;
235
235
  this.hotReloaderSpan = (0, _trace.trace)('hot-reloader', undefined, {
236
- version: "16.1.1-canary.13"
236
+ version: "16.1.1-canary.14"
237
237
  });
238
238
  // Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
239
239
  // of the current `next dev` invocation.
@@ -91,7 +91,7 @@ function logStartInfo({ networkUrl, appUrl, envInfo, experimentalFeatures, logBu
91
91
  if (parts.length > 0) {
92
92
  versionSuffix = ` (${parts.join(', ')})`;
93
93
  }
94
- _log.bootstrap(`${(0, _picocolors.bold)((0, _picocolors.purple)(`${_log.prefixes.ready} Next.js ${"16.1.1-canary.13"}`))}${versionSuffix}`);
94
+ _log.bootstrap(`${(0, _picocolors.bold)((0, _picocolors.purple)(`${_log.prefixes.ready} Next.js ${"16.1.1-canary.14"}`))}${versionSuffix}`);
95
95
  if (appUrl) {
96
96
  _log.bootstrap(`- Local: ${appUrl}`);
97
97
  }
@@ -69,13 +69,4 @@ export declare function createRouteTypesManifest({ dir, pageRoutes, appRoutes, a
69
69
  }): Promise<RouteTypesManifest>;
70
70
  export declare function writeRouteTypesManifest(manifest: RouteTypesManifest, filePath: string, config: NextConfigComplete): Promise<void>;
71
71
  export declare function writeValidatorFile(manifest: RouteTypesManifest, filePath: string, strict: boolean): Promise<void>;
72
- /**
73
- * Writes a proxy routes.d.ts file at the stable path that re-exports from
74
- * the actual dev types location. This allows next-env.d.ts to always reference
75
- * the same stable path regardless of dev/build mode.
76
- *
77
- * @param stableTypesDir - The stable types directory (e.g., .next/types)
78
- * @param devTypesRelativePath - Relative path from stable dir to dev types (e.g., ../dev/types/routes.d.ts)
79
- */
80
- export declare function writeRouteTypesProxy(stableTypesDir: string, devTypesRelativePath: string): Promise<void>;
81
72
  export {};
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
7
7
  createRouteTypesManifest: null,
8
8
  extractRouteParams: null,
9
9
  writeRouteTypesManifest: null,
10
- writeRouteTypesProxy: null,
11
10
  writeValidatorFile: null
12
11
  });
13
12
  function _export(target, all) {
@@ -29,9 +28,6 @@ _export(exports, {
29
28
  writeRouteTypesManifest: function() {
30
29
  return writeRouteTypesManifest;
31
30
  },
32
- writeRouteTypesProxy: function() {
33
- return writeRouteTypesProxy;
34
- },
35
31
  writeValidatorFile: function() {
36
32
  return writeValidatorFile;
37
33
  }
@@ -286,18 +282,5 @@ async function writeValidatorFile(manifest, filePath, strict) {
286
282
  }
287
283
  await _fs.default.promises.writeFile(filePath, strict ? (0, _typegen.generateValidatorFileStrict)(manifest) : (0, _typegen.generateValidatorFile)(manifest));
288
284
  }
289
- async function writeRouteTypesProxy(stableTypesDir, devTypesRelativePath) {
290
- if (!_fs.default.existsSync(stableTypesDir)) {
291
- await _fs.default.promises.mkdir(stableTypesDir, {
292
- recursive: true
293
- });
294
- }
295
- const proxyFilePath = _path.default.join(stableTypesDir, 'routes.d.ts');
296
- const proxyContent = `// This file re-exports route types from the dev types location.
297
- // This provides a stable import path for next-env.d.ts across dev/build modes.
298
- export * from '${devTypesRelativePath}';
299
- `;
300
- await _fs.default.promises.writeFile(proxyFilePath, proxyContent);
301
- }
302
285
 
303
286
  //# sourceMappingURL=route-types-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/server/lib/router-utils/route-types-utils.ts"],"sourcesContent":["import path from 'path'\nimport {\n getRouteRegex,\n type Group,\n} from '../../../shared/lib/router/utils/route-regex'\nimport type { NextConfigComplete } from '../../config-shared'\n\nimport fs from 'fs'\nimport {\n generateRouteTypesFile,\n generateLinkTypesFile,\n generateValidatorFile,\n generateValidatorFileStrict,\n generateRouteTypesFileStrict,\n} from './typegen'\nimport { tryToParsePath } from '../../../lib/try-to-parse-path'\nimport {\n extractInterceptionRouteInformation,\n isInterceptionRouteAppPath,\n} from '../../../shared/lib/router/utils/interception-routes'\nimport {\n UNDERSCORE_GLOBAL_ERROR_ROUTE,\n UNDERSCORE_NOT_FOUND_ROUTE,\n} from '../../../shared/lib/entry-constants'\nimport { normalizePathSep } from '../../../shared/lib/page-path/normalize-path-sep'\n\ninterface RouteInfo {\n path: string\n groups: { [groupName: string]: Group }\n}\n\nexport interface RouteTypesManifest {\n appRoutes: Record<string, RouteInfo>\n pageRoutes: Record<string, RouteInfo>\n layoutRoutes: Record<string, RouteInfo & { slots: string[] }>\n appRouteHandlerRoutes: Record<string, RouteInfo>\n /** Map of redirect source => RouteInfo */\n redirectRoutes: Record<string, RouteInfo>\n /** Map of rewrite source => RouteInfo */\n rewriteRoutes: Record<string, RouteInfo>\n /** File paths for validation */\n appPagePaths: Set<string>\n pagesRouterPagePaths: Set<string>\n layoutPaths: Set<string>\n appRouteHandlers: Set<string>\n pageApiRoutes: Set<string>\n /** Direct mapping from file paths to routes for validation */\n filePathToRoute: Map<string, string>\n}\n\n// Convert a custom-route source string (`/blog/:slug`, `/docs/:path*`, ...)\n// into the bracket-syntax used by other Next.js route helpers so that we can\n// reuse `getRouteRegex()` to extract groups.\nexport function convertCustomRouteSource(source: string): string[] {\n const parseResult = tryToParsePath(source)\n\n if (parseResult.error || !parseResult.tokens) {\n // Fallback to original source if parsing fails\n return source.startsWith('/') ? [source] : ['/' + source]\n }\n\n const possibleNormalizedRoutes = ['']\n let slugCnt = 1\n\n function append(suffix: string) {\n for (let i = 0; i < possibleNormalizedRoutes.length; i++) {\n possibleNormalizedRoutes[i] += suffix\n }\n }\n\n function fork(suffix: string) {\n const currentLength = possibleNormalizedRoutes.length\n for (let i = 0; i < currentLength; i++) {\n possibleNormalizedRoutes.push(possibleNormalizedRoutes[i] + suffix)\n }\n }\n\n for (const token of parseResult.tokens) {\n if (typeof token === 'object') {\n // Make sure the slug is always named.\n const slug = token.name || (slugCnt++ === 1 ? 'slug' : `slug${slugCnt}`)\n if (token.modifier === '*') {\n append(`${token.prefix}[[...${slug}]]`)\n } else if (token.modifier === '+') {\n append(`${token.prefix}[...${slug}]`)\n } else if (token.modifier === '') {\n if (token.pattern === '[^\\\\/#\\\\?]+?') {\n // A safe slug\n append(`${token.prefix}[${slug}]`)\n } else if (token.pattern === '.*') {\n // An optional catch-all slug\n append(`${token.prefix}[[...${slug}]]`)\n } else if (token.pattern === '.+') {\n // A catch-all slug\n append(`${token.prefix}[...${slug}]`)\n } else {\n // Other regex patterns are not supported. Skip this route.\n return []\n }\n } else if (token.modifier === '?') {\n if (/^[a-zA-Z0-9_/]*$/.test(token.pattern)) {\n // An optional slug with plain text only, fork the route.\n append(token.prefix)\n fork(token.pattern)\n } else {\n // Optional modifier `?` and regex patterns are not supported.\n return []\n }\n }\n } else if (typeof token === 'string') {\n append(token)\n }\n }\n\n // Ensure leading slash\n return possibleNormalizedRoutes.map((route) =>\n route.startsWith('/') ? route : '/' + route\n )\n}\n\n/**\n * Extracts route parameters from a route pattern\n */\nexport function extractRouteParams(route: string) {\n const regex = getRouteRegex(route)\n return regex.groups\n}\n\n/**\n * Resolves an intercepting route to its canonical equivalent\n * Example: /gallery/test/(..)photo/[id] -> /gallery/photo/[id]\n */\nfunction resolveInterceptingRoute(route: string): string {\n // Reuse centralized interception route normalization logic\n try {\n if (!isInterceptionRouteAppPath(route)) return route\n const { interceptedRoute } = extractInterceptionRouteInformation(route)\n return interceptedRoute\n } catch {\n // If parsing fails, fall back to the original route\n return route\n }\n}\n\n/**\n * Creates a route types manifest from processed route data\n * (used for both build and dev)\n */\nexport async function createRouteTypesManifest({\n dir,\n pageRoutes,\n appRoutes,\n appRouteHandlers,\n pageApiRoutes,\n layoutRoutes,\n slots,\n redirects,\n rewrites,\n validatorFilePath,\n}: {\n dir: string\n pageRoutes: Array<{ route: string; filePath: string }>\n appRoutes: Array<{ route: string; filePath: string }>\n appRouteHandlers: Array<{ route: string; filePath: string }>\n pageApiRoutes: Array<{ route: string; filePath: string }>\n layoutRoutes: Array<{ route: string; filePath: string }>\n slots: Array<{ name: string; parent: string }>\n redirects?: NextConfigComplete['redirects']\n rewrites?: NextConfigComplete['rewrites']\n validatorFilePath?: string\n}): Promise<RouteTypesManifest> {\n // Helper function to calculate the correct relative path\n const getRelativePath = (filePath: string) => {\n if (validatorFilePath) {\n // For validator generation, calculate path relative to validator directory\n return normalizePathSep(\n path.relative(path.dirname(validatorFilePath), filePath)\n )\n }\n // For other uses, calculate path relative to project directory\n return normalizePathSep(path.relative(dir, filePath))\n }\n\n const manifest: RouteTypesManifest = {\n appRoutes: {},\n pageRoutes: {},\n layoutRoutes: {},\n appRouteHandlerRoutes: {},\n redirectRoutes: {},\n rewriteRoutes: {},\n appRouteHandlers: new Set(\n appRouteHandlers.map(({ filePath }) => getRelativePath(filePath))\n ),\n pageApiRoutes: new Set(\n pageApiRoutes.map(({ filePath }) => getRelativePath(filePath))\n ),\n appPagePaths: new Set(\n appRoutes.map(({ filePath }) => getRelativePath(filePath))\n ),\n pagesRouterPagePaths: new Set(\n pageRoutes.map(({ filePath }) => getRelativePath(filePath))\n ),\n layoutPaths: new Set(\n layoutRoutes.map(({ filePath }) => getRelativePath(filePath))\n ),\n filePathToRoute: new Map([\n ...appRoutes.map(\n ({ route, filePath }) =>\n [getRelativePath(filePath), resolveInterceptingRoute(route)] as [\n string,\n string,\n ]\n ),\n ...layoutRoutes.map(\n ({ route, filePath }) =>\n [getRelativePath(filePath), resolveInterceptingRoute(route)] as [\n string,\n string,\n ]\n ),\n ...appRouteHandlers.map(\n ({ route, filePath }) =>\n [getRelativePath(filePath), resolveInterceptingRoute(route)] as [\n string,\n string,\n ]\n ),\n ...pageRoutes.map(\n ({ route, filePath }) =>\n [getRelativePath(filePath), route] as [string, string]\n ),\n ...pageApiRoutes.map(\n ({ route, filePath }) =>\n [getRelativePath(filePath), route] as [string, string]\n ),\n ]),\n }\n\n // Process page routes\n for (const { route, filePath } of pageRoutes) {\n manifest.pageRoutes[route] = {\n path: getRelativePath(filePath),\n groups: extractRouteParams(route),\n }\n }\n\n // Process layout routes (exclude internal app error/not-found layouts)\n for (const { route, filePath } of layoutRoutes) {\n if (\n route === UNDERSCORE_GLOBAL_ERROR_ROUTE ||\n route === UNDERSCORE_NOT_FOUND_ROUTE\n )\n continue\n // Use the resolved route (for interception routes, this gives us the canonical route)\n const resolvedRoute = resolveInterceptingRoute(route)\n if (!manifest.layoutRoutes[resolvedRoute]) {\n manifest.layoutRoutes[resolvedRoute] = {\n path: getRelativePath(filePath),\n groups: extractRouteParams(resolvedRoute),\n slots: [],\n }\n }\n }\n\n // Process slots\n for (const slot of slots) {\n if (manifest.layoutRoutes[slot.parent]) {\n manifest.layoutRoutes[slot.parent].slots.push(slot.name)\n }\n }\n\n // Process app routes (exclude internal app routes)\n for (const { route, filePath } of appRoutes) {\n if (\n route === UNDERSCORE_GLOBAL_ERROR_ROUTE ||\n route === UNDERSCORE_NOT_FOUND_ROUTE\n )\n continue\n // Don't include metadata routes or pages\n if (\n !filePath.endsWith('page.ts') &&\n !filePath.endsWith('page.tsx') &&\n !filePath.endsWith('.mdx') &&\n !filePath.endsWith('.md')\n ) {\n continue\n }\n\n // Use the resolved route (for interception routes, this gives us the canonical route)\n const resolvedRoute = resolveInterceptingRoute(route)\n\n if (!manifest.appRoutes[resolvedRoute]) {\n manifest.appRoutes[resolvedRoute] = {\n path: getRelativePath(filePath),\n groups: extractRouteParams(resolvedRoute),\n }\n }\n }\n\n // Process app route handlers\n for (const { route, filePath } of appRouteHandlers) {\n // Use the resolved route (for interception routes, this gives us the canonical route)\n const resolvedRoute = resolveInterceptingRoute(route)\n\n if (!manifest.appRouteHandlerRoutes[resolvedRoute]) {\n manifest.appRouteHandlerRoutes[resolvedRoute] = {\n path: getRelativePath(filePath),\n groups: extractRouteParams(resolvedRoute),\n }\n }\n }\n\n // Process redirects\n if (typeof redirects === 'function') {\n const rd = await redirects()\n\n for (const item of rd) {\n const possibleRoutes = convertCustomRouteSource(item.source)\n for (const route of possibleRoutes) {\n manifest.redirectRoutes[route] = {\n path: route,\n groups: extractRouteParams(route),\n }\n }\n }\n }\n\n // Process rewrites\n if (typeof rewrites === 'function') {\n const rw = await rewrites()\n\n const allSources = Array.isArray(rw)\n ? rw\n : [\n ...(rw?.beforeFiles || []),\n ...(rw?.afterFiles || []),\n ...(rw?.fallback || []),\n ]\n\n for (const item of allSources) {\n const possibleRoutes = convertCustomRouteSource(item.source)\n for (const route of possibleRoutes) {\n manifest.rewriteRoutes[route] = {\n path: route,\n groups: extractRouteParams(route),\n }\n }\n }\n }\n\n return manifest\n}\n\nexport async function writeRouteTypesManifest(\n manifest: RouteTypesManifest,\n filePath: string,\n config: NextConfigComplete\n) {\n const dirname = path.dirname(filePath)\n\n if (!fs.existsSync(dirname)) {\n await fs.promises.mkdir(dirname, { recursive: true })\n }\n\n // Write the main routes.d.ts file\n await fs.promises.writeFile(\n filePath,\n config.experimental.strictRouteTypes\n ? generateRouteTypesFileStrict(manifest)\n : generateRouteTypesFile(manifest)\n )\n\n // Write the link.d.ts file if typedRoutes is enabled\n if (config.typedRoutes === true) {\n const linkTypesPath = path.join(dirname, 'link.d.ts')\n await fs.promises.writeFile(linkTypesPath, generateLinkTypesFile(manifest))\n }\n}\n\nexport async function writeValidatorFile(\n manifest: RouteTypesManifest,\n filePath: string,\n strict: boolean\n) {\n const dirname = path.dirname(filePath)\n\n if (!fs.existsSync(dirname)) {\n await fs.promises.mkdir(dirname, { recursive: true })\n }\n\n await fs.promises.writeFile(\n filePath,\n strict\n ? generateValidatorFileStrict(manifest)\n : generateValidatorFile(manifest)\n )\n}\n\n/**\n * Writes a proxy routes.d.ts file at the stable path that re-exports from\n * the actual dev types location. This allows next-env.d.ts to always reference\n * the same stable path regardless of dev/build mode.\n *\n * @param stableTypesDir - The stable types directory (e.g., .next/types)\n * @param devTypesRelativePath - Relative path from stable dir to dev types (e.g., ../dev/types/routes.d.ts)\n */\nexport async function writeRouteTypesProxy(\n stableTypesDir: string,\n devTypesRelativePath: string\n) {\n if (!fs.existsSync(stableTypesDir)) {\n await fs.promises.mkdir(stableTypesDir, { recursive: true })\n }\n\n const proxyFilePath = path.join(stableTypesDir, 'routes.d.ts')\n const proxyContent = `// This file re-exports route types from the dev types location.\n// This provides a stable import path for next-env.d.ts across dev/build modes.\nexport * from '${devTypesRelativePath}';\n`\n\n await fs.promises.writeFile(proxyFilePath, proxyContent)\n}\n"],"names":["convertCustomRouteSource","createRouteTypesManifest","extractRouteParams","writeRouteTypesManifest","writeRouteTypesProxy","writeValidatorFile","source","parseResult","tryToParsePath","error","tokens","startsWith","possibleNormalizedRoutes","slugCnt","append","suffix","i","length","fork","currentLength","push","token","slug","name","modifier","prefix","pattern","test","map","route","regex","getRouteRegex","groups","resolveInterceptingRoute","isInterceptionRouteAppPath","interceptedRoute","extractInterceptionRouteInformation","dir","pageRoutes","appRoutes","appRouteHandlers","pageApiRoutes","layoutRoutes","slots","redirects","rewrites","validatorFilePath","getRelativePath","filePath","normalizePathSep","path","relative","dirname","manifest","appRouteHandlerRoutes","redirectRoutes","rewriteRoutes","Set","appPagePaths","pagesRouterPagePaths","layoutPaths","filePathToRoute","Map","UNDERSCORE_GLOBAL_ERROR_ROUTE","UNDERSCORE_NOT_FOUND_ROUTE","resolvedRoute","slot","parent","endsWith","rd","item","possibleRoutes","rw","allSources","Array","isArray","beforeFiles","afterFiles","fallback","config","fs","existsSync","promises","mkdir","recursive","writeFile","experimental","strictRouteTypes","generateRouteTypesFileStrict","generateRouteTypesFile","typedRoutes","linkTypesPath","join","generateLinkTypesFile","strict","generateValidatorFileStrict","generateValidatorFile","stableTypesDir","devTypesRelativePath","proxyFilePath","proxyContent"],"mappings":";;;;;;;;;;;;;;;;;;;IAqDgBA,wBAAwB;eAAxBA;;IA+FMC,wBAAwB;eAAxBA;;IAzBNC,kBAAkB;eAAlBA;;IAsOMC,uBAAuB;eAAvBA;;IAqDAC,oBAAoB;eAApBA;;IA3BAC,kBAAkB;eAAlBA;;;6DA3XL;4BAIV;2DAGQ;yBAOR;gCACwB;oCAIxB;gCAIA;kCAC0B;;;;;;AA6B1B,SAASL,yBAAyBM,MAAc;IACrD,MAAMC,cAAcC,IAAAA,8BAAc,EAACF;IAEnC,IAAIC,YAAYE,KAAK,IAAI,CAACF,YAAYG,MAAM,EAAE;QAC5C,+CAA+C;QAC/C,OAAOJ,OAAOK,UAAU,CAAC,OAAO;YAACL;SAAO,GAAG;YAAC,MAAMA;SAAO;IAC3D;IAE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gBAAgB;IAChD,MAAMG,eAAe,CAAC;;eAET,EAAEF,qBAAqB;AACtC,CAAC;IAEC,MAAMlB,WAAE,CAACE,QAAQ,CAACG,SAAS,CAACc,eAAeC;AAC7C","ignoreList":[0]}
1
+ {"version":3,"sources":["../../../../src/server/lib/router-utils/route-types-utils.ts"],"sourcesContent":["import path from 'path'\nimport {\n getRouteRegex,\n type Group,\n} from '../../../shared/lib/router/utils/route-regex'\nimport type { NextConfigComplete } from '../../config-shared'\n\nimport fs from 'fs'\nimport {\n generateRouteTypesFile,\n generateLinkTypesFile,\n generateValidatorFile,\n generateValidatorFileStrict,\n generateRouteTypesFileStrict,\n} from './typegen'\nimport { tryToParsePath } from '../../../lib/try-to-parse-path'\nimport {\n extractInterceptionRouteInformation,\n isInterceptionRouteAppPath,\n} from '../../../shared/lib/router/utils/interception-routes'\nimport {\n UNDERSCORE_GLOBAL_ERROR_ROUTE,\n UNDERSCORE_NOT_FOUND_ROUTE,\n} from '../../../shared/lib/entry-constants'\nimport { normalizePathSep } from '../../../shared/lib/page-path/normalize-path-sep'\n\ninterface RouteInfo {\n path: string\n groups: { [groupName: string]: Group }\n}\n\nexport interface RouteTypesManifest {\n appRoutes: Record<string, RouteInfo>\n pageRoutes: Record<string, RouteInfo>\n layoutRoutes: Record<string, RouteInfo & { slots: string[] }>\n appRouteHandlerRoutes: Record<string, RouteInfo>\n /** Map of redirect source => RouteInfo */\n redirectRoutes: Record<string, RouteInfo>\n /** Map of rewrite source => RouteInfo */\n rewriteRoutes: Record<string, RouteInfo>\n /** File paths for validation */\n appPagePaths: Set<string>\n pagesRouterPagePaths: Set<string>\n layoutPaths: Set<string>\n appRouteHandlers: Set<string>\n pageApiRoutes: Set<string>\n /** Direct mapping from file paths to routes for validation */\n filePathToRoute: Map<string, string>\n}\n\n// Convert a custom-route source string (`/blog/:slug`, `/docs/:path*`, ...)\n// into the bracket-syntax used by other Next.js route helpers so that we can\n// reuse `getRouteRegex()` to extract groups.\nexport function convertCustomRouteSource(source: string): string[] {\n const parseResult = tryToParsePath(source)\n\n if (parseResult.error || !parseResult.tokens) {\n // Fallback to original source if parsing fails\n return source.startsWith('/') ? [source] : ['/' + source]\n }\n\n const possibleNormalizedRoutes = ['']\n let slugCnt = 1\n\n function append(suffix: string) {\n for (let i = 0; i < possibleNormalizedRoutes.length; i++) {\n possibleNormalizedRoutes[i] += suffix\n }\n }\n\n function fork(suffix: string) {\n const currentLength = possibleNormalizedRoutes.length\n for (let i = 0; i < currentLength; i++) {\n possibleNormalizedRoutes.push(possibleNormalizedRoutes[i] + suffix)\n }\n }\n\n for (const token of parseResult.tokens) {\n if (typeof token === 'object') {\n // Make sure the slug is always named.\n const slug = token.name || (slugCnt++ === 1 ? 'slug' : `slug${slugCnt}`)\n if (token.modifier === '*') {\n append(`${token.prefix}[[...${slug}]]`)\n } else if (token.modifier === '+') {\n append(`${token.prefix}[...${slug}]`)\n } else if (token.modifier === '') {\n if (token.pattern === '[^\\\\/#\\\\?]+?') {\n // A safe slug\n append(`${token.prefix}[${slug}]`)\n } else if (token.pattern === '.*') {\n // An optional catch-all slug\n append(`${token.prefix}[[...${slug}]]`)\n } else if (token.pattern === '.+') {\n // A catch-all slug\n append(`${token.prefix}[...${slug}]`)\n } else {\n // Other regex patterns are not supported. Skip this route.\n return []\n }\n } else if (token.modifier === '?') {\n if (/^[a-zA-Z0-9_/]*$/.test(token.pattern)) {\n // An optional slug with plain text only, fork the route.\n append(token.prefix)\n fork(token.pattern)\n } else {\n // Optional modifier `?` and regex patterns are not supported.\n return []\n }\n }\n } else if (typeof token === 'string') {\n append(token)\n }\n }\n\n // Ensure leading slash\n return possibleNormalizedRoutes.map((route) =>\n route.startsWith('/') ? route : '/' + route\n )\n}\n\n/**\n * Extracts route parameters from a route pattern\n */\nexport function extractRouteParams(route: string) {\n const regex = getRouteRegex(route)\n return regex.groups\n}\n\n/**\n * Resolves an intercepting route to its canonical equivalent\n * Example: /gallery/test/(..)photo/[id] -> /gallery/photo/[id]\n */\nfunction resolveInterceptingRoute(route: string): string {\n // Reuse centralized interception route normalization logic\n try {\n if (!isInterceptionRouteAppPath(route)) return route\n const { interceptedRoute } = extractInterceptionRouteInformation(route)\n return interceptedRoute\n } catch {\n // If parsing fails, fall back to the original route\n return route\n }\n}\n\n/**\n * Creates a route types manifest from processed route data\n * (used for both build and dev)\n */\nexport async function createRouteTypesManifest({\n dir,\n pageRoutes,\n appRoutes,\n appRouteHandlers,\n pageApiRoutes,\n layoutRoutes,\n slots,\n redirects,\n rewrites,\n validatorFilePath,\n}: {\n dir: string\n pageRoutes: Array<{ route: string; filePath: string }>\n appRoutes: Array<{ route: string; filePath: string }>\n appRouteHandlers: Array<{ route: string; filePath: string }>\n pageApiRoutes: Array<{ route: string; filePath: string }>\n layoutRoutes: Array<{ route: string; filePath: string }>\n slots: Array<{ name: string; parent: string }>\n redirects?: NextConfigComplete['redirects']\n rewrites?: NextConfigComplete['rewrites']\n validatorFilePath?: string\n}): Promise<RouteTypesManifest> {\n // Helper function to calculate the correct relative path\n const getRelativePath = (filePath: string) => {\n if (validatorFilePath) {\n // For validator generation, calculate path relative to validator directory\n return normalizePathSep(\n path.relative(path.dirname(validatorFilePath), filePath)\n )\n }\n // For other uses, calculate path relative to project directory\n return normalizePathSep(path.relative(dir, filePath))\n }\n\n const manifest: RouteTypesManifest = {\n appRoutes: {},\n pageRoutes: {},\n layoutRoutes: {},\n appRouteHandlerRoutes: {},\n redirectRoutes: {},\n rewriteRoutes: {},\n appRouteHandlers: new Set(\n appRouteHandlers.map(({ filePath }) => getRelativePath(filePath))\n ),\n pageApiRoutes: new Set(\n pageApiRoutes.map(({ filePath }) => getRelativePath(filePath))\n ),\n appPagePaths: new Set(\n appRoutes.map(({ filePath }) => getRelativePath(filePath))\n ),\n pagesRouterPagePaths: new Set(\n pageRoutes.map(({ filePath }) => getRelativePath(filePath))\n ),\n layoutPaths: new Set(\n layoutRoutes.map(({ filePath }) => getRelativePath(filePath))\n ),\n filePathToRoute: new Map([\n ...appRoutes.map(\n ({ route, filePath }) =>\n [getRelativePath(filePath), resolveInterceptingRoute(route)] as [\n string,\n string,\n ]\n ),\n ...layoutRoutes.map(\n ({ route, filePath }) =>\n [getRelativePath(filePath), resolveInterceptingRoute(route)] as [\n string,\n string,\n ]\n ),\n ...appRouteHandlers.map(\n ({ route, filePath }) =>\n [getRelativePath(filePath), resolveInterceptingRoute(route)] as [\n string,\n string,\n ]\n ),\n ...pageRoutes.map(\n ({ route, filePath }) =>\n [getRelativePath(filePath), route] as [string, string]\n ),\n ...pageApiRoutes.map(\n ({ route, filePath }) =>\n [getRelativePath(filePath), route] as [string, string]\n ),\n ]),\n }\n\n // Process page routes\n for (const { route, filePath } of pageRoutes) {\n manifest.pageRoutes[route] = {\n path: getRelativePath(filePath),\n groups: extractRouteParams(route),\n }\n }\n\n // Process layout routes (exclude internal app error/not-found layouts)\n for (const { route, filePath } of layoutRoutes) {\n if (\n route === UNDERSCORE_GLOBAL_ERROR_ROUTE ||\n route === UNDERSCORE_NOT_FOUND_ROUTE\n )\n continue\n // Use the resolved route (for interception routes, this gives us the canonical route)\n const resolvedRoute = resolveInterceptingRoute(route)\n if (!manifest.layoutRoutes[resolvedRoute]) {\n manifest.layoutRoutes[resolvedRoute] = {\n path: getRelativePath(filePath),\n groups: extractRouteParams(resolvedRoute),\n slots: [],\n }\n }\n }\n\n // Process slots\n for (const slot of slots) {\n if (manifest.layoutRoutes[slot.parent]) {\n manifest.layoutRoutes[slot.parent].slots.push(slot.name)\n }\n }\n\n // Process app routes (exclude internal app routes)\n for (const { route, filePath } of appRoutes) {\n if (\n route === UNDERSCORE_GLOBAL_ERROR_ROUTE ||\n route === UNDERSCORE_NOT_FOUND_ROUTE\n )\n continue\n // Don't include metadata routes or pages\n if (\n !filePath.endsWith('page.ts') &&\n !filePath.endsWith('page.tsx') &&\n !filePath.endsWith('.mdx') &&\n !filePath.endsWith('.md')\n ) {\n continue\n }\n\n // Use the resolved route (for interception routes, this gives us the canonical route)\n const resolvedRoute = resolveInterceptingRoute(route)\n\n if (!manifest.appRoutes[resolvedRoute]) {\n manifest.appRoutes[resolvedRoute] = {\n path: getRelativePath(filePath),\n groups: extractRouteParams(resolvedRoute),\n }\n }\n }\n\n // Process app route handlers\n for (const { route, filePath } of appRouteHandlers) {\n // Use the resolved route (for interception routes, this gives us the canonical route)\n const resolvedRoute = resolveInterceptingRoute(route)\n\n if (!manifest.appRouteHandlerRoutes[resolvedRoute]) {\n manifest.appRouteHandlerRoutes[resolvedRoute] = {\n path: getRelativePath(filePath),\n groups: extractRouteParams(resolvedRoute),\n }\n }\n }\n\n // Process redirects\n if (typeof redirects === 'function') {\n const rd = await redirects()\n\n for (const item of rd) {\n const possibleRoutes = convertCustomRouteSource(item.source)\n for (const route of possibleRoutes) {\n manifest.redirectRoutes[route] = {\n path: route,\n groups: extractRouteParams(route),\n }\n }\n }\n }\n\n // Process rewrites\n if (typeof rewrites === 'function') {\n const rw = await rewrites()\n\n const allSources = Array.isArray(rw)\n ? rw\n : [\n ...(rw?.beforeFiles || []),\n ...(rw?.afterFiles || []),\n ...(rw?.fallback || []),\n ]\n\n for (const item of allSources) {\n const possibleRoutes = convertCustomRouteSource(item.source)\n for (const route of possibleRoutes) {\n manifest.rewriteRoutes[route] = {\n path: route,\n groups: extractRouteParams(route),\n }\n }\n }\n }\n\n return manifest\n}\n\nexport async function writeRouteTypesManifest(\n manifest: RouteTypesManifest,\n filePath: string,\n config: NextConfigComplete\n) {\n const dirname = path.dirname(filePath)\n\n if (!fs.existsSync(dirname)) {\n await fs.promises.mkdir(dirname, { recursive: true })\n }\n\n // Write the main routes.d.ts file\n await fs.promises.writeFile(\n filePath,\n config.experimental.strictRouteTypes\n ? generateRouteTypesFileStrict(manifest)\n : generateRouteTypesFile(manifest)\n )\n\n // Write the link.d.ts file if typedRoutes is enabled\n if (config.typedRoutes === true) {\n const linkTypesPath = path.join(dirname, 'link.d.ts')\n await fs.promises.writeFile(linkTypesPath, generateLinkTypesFile(manifest))\n }\n}\n\nexport async function writeValidatorFile(\n manifest: RouteTypesManifest,\n filePath: string,\n strict: boolean\n) {\n const dirname = path.dirname(filePath)\n\n if (!fs.existsSync(dirname)) {\n await fs.promises.mkdir(dirname, { recursive: true })\n }\n\n await fs.promises.writeFile(\n filePath,\n strict\n ? generateValidatorFileStrict(manifest)\n : generateValidatorFile(manifest)\n )\n}\n"],"names":["convertCustomRouteSource","createRouteTypesManifest","extractRouteParams","writeRouteTypesManifest","writeValidatorFile","source","parseResult","tryToParsePath","error","tokens","startsWith","possibleNormalizedRoutes","slugCnt","append","suffix","i","length","fork","currentLength","push","token","slug","name","modifier","prefix","pattern","test","map","route","regex","getRouteRegex","groups","resolveInterceptingRoute","isInterceptionRouteAppPath","interceptedRoute","extractInterceptionRouteInformation","dir","pageRoutes","appRoutes","appRouteHandlers","pageApiRoutes","layoutRoutes","slots","redirects","rewrites","validatorFilePath","getRelativePath","filePath","normalizePathSep","path","relative","dirname","manifest","appRouteHandlerRoutes","redirectRoutes","rewriteRoutes","Set","appPagePaths","pagesRouterPagePaths","layoutPaths","filePathToRoute","Map","UNDERSCORE_GLOBAL_ERROR_ROUTE","UNDERSCORE_NOT_FOUND_ROUTE","resolvedRoute","slot","parent","endsWith","rd","item","possibleRoutes","rw","allSources","Array","isArray","beforeFiles","afterFiles","fallback","config","fs","existsSync","promises","mkdir","recursive","writeFile","experimental","strictRouteTypes","generateRouteTypesFileStrict","generateRouteTypesFile","typedRoutes","linkTypesPath","join","generateLinkTypesFile","strict","generateValidatorFileStrict","generateValidatorFile"],"mappings":";;;;;;;;;;;;;;;;;;IAqDgBA,wBAAwB;eAAxBA;;IA+FMC,wBAAwB;eAAxBA;;IAzBNC,kBAAkB;eAAlBA;;IAsOMC,uBAAuB;eAAvBA;;IA0BAC,kBAAkB;eAAlBA;;;6DA3XL;4BAIV;2DAGQ;yBAOR;gCACwB;oCAIxB;gCAIA;kCAC0B;;;;;;AA6B1B,SAASJ,yBAAyBK,MAAc;IACrD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yTypeScript(opts) {
117
117
  const verifyResult = await (0, _verifytypescriptsetup.verifyTypeScriptSetup)({
118
118
  dir: opts.dir,
119
119
  distDir: opts.nextConfig.distDir,
120
- distDirRoot: opts.nextConfig.distDirRoot,
120
+ strictRouteTypes: Boolean(opts.nextConfig.experimental.strictRouteTypes),
121
121
  typeCheckPreflight: false,
122
122
  tsconfigPath: opts.nextConfig.typescript.tsconfigPath,
123
+ typedRoutes: Boolean(opts.nextConfig.typedRoutes),
123
124
  disableStaticImages: opts.nextConfig.images.disableStaticImages,
124
125
  hasAppDir: !!opts.appDir,
125
126
  hasPagesDir: !!opts.pagesDir,
@@ -197,12 +198,6 @@ async function startWatcher(opts) {
197
198
  pageApiRoutes: new Set(),
198
199
  filePathToRoute: new Map()
199
200
  }, _path.default.join(distTypesDir, 'routes.d.ts'), opts.nextConfig);
200
- // When isolatedDevBuild is enabled, write a proxy file at the stable path
201
- // that re-exports from the dev types location
202
- if (opts.nextConfig.experimental.isolatedDevBuild) {
203
- const stableTypesDir = _path.default.join(opts.dir, opts.nextConfig.distDirRoot, 'types');
204
- await (0, _routetypesutils.writeRouteTypesProxy)(stableTypesDir, '../dev/types/routes.d.ts');
205
- }
206
201
  const routesManifestPath = _path.default.join(distDir, _constants.ROUTES_MANIFEST);
207
202
  const routesManifest = {
208
203
  version: 3,