next 16.0.2-canary.11 → 16.0.2-canary.12

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 (116) hide show
  1. package/dist/bin/next +1 -1
  2. package/dist/build/babel/loader/get-config.js +5 -0
  3. package/dist/build/babel/loader/get-config.js.map +1 -1
  4. package/dist/build/index.js +7 -4
  5. package/dist/build/index.js.map +1 -1
  6. package/dist/build/jest/jest.js +2 -1
  7. package/dist/build/jest/jest.js.map +1 -1
  8. package/dist/build/load-entrypoint.js +1 -2
  9. package/dist/build/load-entrypoint.js.map +1 -1
  10. package/dist/build/lockfile.d.ts +1 -1
  11. package/dist/build/lockfile.js +5 -9
  12. package/dist/build/lockfile.js.map +1 -1
  13. package/dist/build/next-config-ts/transpile-config.js +13 -3
  14. package/dist/build/next-config-ts/transpile-config.js.map +1 -1
  15. package/dist/build/swc/index.d.ts +4 -2
  16. package/dist/build/swc/index.js +54 -51
  17. package/dist/build/swc/index.js.map +1 -1
  18. package/dist/build/swc/install-bindings.d.ts +15 -0
  19. package/dist/build/swc/install-bindings.js +30 -0
  20. package/dist/build/swc/install-bindings.js.map +1 -0
  21. package/dist/build/turbopack-build/impl.js +9 -4
  22. package/dist/build/turbopack-build/impl.js.map +1 -1
  23. package/dist/build/webpack/loaders/lightningcss-loader/src/loader.js +7 -2
  24. package/dist/build/webpack/loaders/lightningcss-loader/src/loader.js.map +1 -1
  25. package/dist/build/webpack/loaders/lightningcss-loader/src/minify.js +2 -2
  26. package/dist/build/webpack/loaders/lightningcss-loader/src/minify.js.map +1 -1
  27. package/dist/build/webpack/loaders/next-app-loader/index.js +6 -0
  28. package/dist/build/webpack/loaders/next-app-loader/index.js.map +1 -1
  29. package/dist/build/webpack/loaders/next-barrel-loader.js +5 -0
  30. package/dist/build/webpack/loaders/next-barrel-loader.js.map +1 -1
  31. package/dist/build/webpack/loaders/next-metadata-image-loader.js +5 -0
  32. package/dist/build/webpack/loaders/next-metadata-image-loader.js.map +1 -1
  33. package/dist/build/webpack/loaders/next-metadata-route-loader.js +5 -0
  34. package/dist/build/webpack/loaders/next-metadata-route-loader.js.map +1 -1
  35. package/dist/build/webpack/loaders/next-swc-loader.js +10 -6
  36. package/dist/build/webpack/loaders/next-swc-loader.js.map +1 -1
  37. package/dist/build/webpack-build/impl.js +4 -1
  38. package/dist/build/webpack-build/impl.js.map +1 -1
  39. package/dist/build/webpack-config.js +2 -7
  40. package/dist/build/webpack-config.js.map +1 -1
  41. package/dist/cli/next-typegen.js +3 -0
  42. package/dist/cli/next-typegen.js.map +1 -1
  43. package/dist/client/app-bootstrap.js +1 -1
  44. package/dist/client/index.js +1 -1
  45. package/dist/compiled/next-server/pages-api-turbo.runtime.dev.js +1 -1
  46. package/dist/compiled/next-server/pages-api-turbo.runtime.dev.js.map +1 -1
  47. package/dist/compiled/next-server/pages-api-turbo.runtime.prod.js +1 -1
  48. package/dist/compiled/next-server/pages-api-turbo.runtime.prod.js.map +1 -1
  49. package/dist/compiled/next-server/pages-api.runtime.dev.js +1 -1
  50. package/dist/compiled/next-server/pages-api.runtime.dev.js.map +1 -1
  51. package/dist/compiled/next-server/pages-turbo.runtime.dev.js +1 -1
  52. package/dist/compiled/next-server/pages-turbo.runtime.dev.js.map +1 -1
  53. package/dist/compiled/next-server/pages-turbo.runtime.prod.js +1 -1
  54. package/dist/compiled/next-server/pages-turbo.runtime.prod.js.map +1 -1
  55. package/dist/compiled/next-server/pages.runtime.dev.js +1 -1
  56. package/dist/compiled/next-server/pages.runtime.dev.js.map +1 -1
  57. package/dist/esm/build/babel/loader/get-config.js +5 -0
  58. package/dist/esm/build/babel/loader/get-config.js.map +1 -1
  59. package/dist/esm/build/index.js +7 -4
  60. package/dist/esm/build/index.js.map +1 -1
  61. package/dist/esm/build/load-entrypoint.js +2 -3
  62. package/dist/esm/build/load-entrypoint.js.map +1 -1
  63. package/dist/esm/build/lockfile.js +5 -9
  64. package/dist/esm/build/lockfile.js.map +1 -1
  65. package/dist/esm/build/next-config-ts/transpile-config.js +13 -3
  66. package/dist/esm/build/next-config-ts/transpile-config.js.map +1 -1
  67. package/dist/esm/build/swc/index.js +52 -49
  68. package/dist/esm/build/swc/index.js.map +1 -1
  69. package/dist/esm/build/swc/install-bindings.js +20 -0
  70. package/dist/esm/build/swc/install-bindings.js.map +1 -0
  71. package/dist/esm/build/turbopack-build/impl.js +10 -5
  72. package/dist/esm/build/turbopack-build/impl.js.map +1 -1
  73. package/dist/esm/build/webpack/loaders/lightningcss-loader/src/loader.js +7 -2
  74. package/dist/esm/build/webpack/loaders/lightningcss-loader/src/loader.js.map +1 -1
  75. package/dist/esm/build/webpack/loaders/lightningcss-loader/src/minify.js +2 -2
  76. package/dist/esm/build/webpack/loaders/lightningcss-loader/src/minify.js.map +1 -1
  77. package/dist/esm/build/webpack/loaders/next-app-loader/index.js +6 -0
  78. package/dist/esm/build/webpack/loaders/next-app-loader/index.js.map +1 -1
  79. package/dist/esm/build/webpack/loaders/next-barrel-loader.js +5 -0
  80. package/dist/esm/build/webpack/loaders/next-barrel-loader.js.map +1 -1
  81. package/dist/esm/build/webpack/loaders/next-metadata-image-loader.js +5 -0
  82. package/dist/esm/build/webpack/loaders/next-metadata-image-loader.js.map +1 -1
  83. package/dist/esm/build/webpack/loaders/next-metadata-route-loader.js +5 -0
  84. package/dist/esm/build/webpack/loaders/next-metadata-route-loader.js.map +1 -1
  85. package/dist/esm/build/webpack/loaders/next-swc-loader.js +11 -7
  86. package/dist/esm/build/webpack/loaders/next-swc-loader.js.map +1 -1
  87. package/dist/esm/build/webpack-build/impl.js +4 -1
  88. package/dist/esm/build/webpack-build/impl.js.map +1 -1
  89. package/dist/esm/build/webpack-config.js +2 -7
  90. package/dist/esm/build/webpack-config.js.map +1 -1
  91. package/dist/esm/client/app-bootstrap.js +1 -1
  92. package/dist/esm/client/index.js +1 -1
  93. package/dist/esm/server/config.js +2 -2
  94. package/dist/esm/server/config.js.map +1 -1
  95. package/dist/esm/server/dev/hot-reloader-turbopack.js +3 -4
  96. package/dist/esm/server/dev/hot-reloader-turbopack.js.map +1 -1
  97. package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
  98. package/dist/esm/server/lib/app-info-log.js +1 -1
  99. package/dist/esm/server/lib/router-utils/setup-dev-bundler.js +3 -0
  100. package/dist/esm/server/lib/router-utils/setup-dev-bundler.js.map +1 -1
  101. package/dist/esm/server/lib/start-server.js +1 -1
  102. package/dist/esm/shared/lib/errors/canary-only-config-error.js +1 -1
  103. package/dist/server/config.js +2 -2
  104. package/dist/server/config.js.map +1 -1
  105. package/dist/server/dev/hot-reloader-turbopack.js +2 -3
  106. package/dist/server/dev/hot-reloader-turbopack.js.map +1 -1
  107. package/dist/server/dev/hot-reloader-webpack.js +1 -1
  108. package/dist/server/lib/app-info-log.js +1 -1
  109. package/dist/server/lib/router-utils/setup-dev-bundler.js +3 -0
  110. package/dist/server/lib/router-utils/setup-dev-bundler.js.map +1 -1
  111. package/dist/server/lib/start-server.js +1 -1
  112. package/dist/shared/lib/errors/canary-only-config-error.js +1 -1
  113. package/dist/telemetry/anonymous-meta.js +1 -1
  114. package/dist/telemetry/events/session-stopped.js +2 -2
  115. package/dist/telemetry/events/version.js +2 -2
  116. package/package.json +15 -15
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/build/webpack/loaders/next-app-loader/index.ts"],"sourcesContent":["import type webpack from 'next/dist/compiled/webpack/webpack'\nimport {\n UNDERSCORE_GLOBAL_ERROR_ROUTE,\n UNDERSCORE_NOT_FOUND_ROUTE,\n type ValueOf,\n} from '../../../../shared/lib/constants'\nimport {\n UNDERSCORE_GLOBAL_ERROR_ROUTE_ENTRY,\n UNDERSCORE_NOT_FOUND_ROUTE_ENTRY,\n} from '../../../../shared/lib/entry-constants'\nimport type { ModuleTuple, CollectedMetadata } from '../metadata/types'\n\nimport path from 'path'\nimport { bold } from '../../../../lib/picocolors'\nimport { getModuleBuildInfo } from '../get-module-build-info'\nimport { verifyRootLayout } from '../../../../lib/verify-root-layout'\nimport * as Log from '../../../output/log'\nimport { APP_DIR_ALIAS } from '../../../../lib/constants'\nimport {\n createMetadataExportsCode,\n createStaticMetadataFromRoute,\n} from '../metadata/discover'\nimport { promises as fs } from 'fs'\nimport { isAppRouteRoute } from '../../../../lib/is-app-route-route'\nimport type { NextConfig } from '../../../../server/config-shared'\nimport { AppPathnameNormalizer } from '../../../../server/normalizers/built/app/app-pathname-normalizer'\nimport type { ProxyConfig } from '../../../analysis/get-page-static-info'\nimport { isAppBuiltinPage } from '../../../utils'\nimport { loadEntrypoint } from '../../../load-entrypoint'\nimport {\n isGroupSegment,\n DEFAULT_SEGMENT_KEY,\n PAGE_SEGMENT_KEY,\n} from '../../../../shared/lib/segment'\nimport { getFilesInDir } from '../../../../lib/get-files-in-dir'\nimport type { PageExtensions } from '../../../page-extensions-type'\nimport { PARALLEL_ROUTE_DEFAULT_PATH } from '../../../../client/components/builtin/default'\nimport type { Compilation } from 'webpack'\nimport { createAppRouteCode } from './create-app-route-code'\nimport { MissingDefaultParallelRouteError } from '../../../../shared/lib/errors/missing-default-parallel-route-error'\nimport { normalizePathSep } from '../../../../shared/lib/page-path/normalize-path-sep'\n\nexport type AppLoaderOptions = {\n name: string\n page: string\n pagePath: string\n appDir: string\n appPaths: readonly string[] | null\n preferredRegion: string | string[] | undefined\n pageExtensions: PageExtensions\n assetPrefix: string\n rootDir?: string\n tsconfigPath?: string\n isDev?: true\n basePath: string\n nextConfigOutput?: NextConfig['output']\n middlewareConfig: string\n isGlobalNotFoundEnabled: true | undefined\n}\ntype AppLoader = webpack.LoaderDefinitionFunction<AppLoaderOptions>\n\nconst HTTP_ACCESS_FALLBACKS = {\n 'not-found': 'not-found',\n forbidden: 'forbidden',\n unauthorized: 'unauthorized',\n} as const\nconst defaultHTTPAccessFallbackPaths = {\n 'not-found': 'next/dist/client/components/builtin/not-found.js',\n forbidden: 'next/dist/client/components/builtin/forbidden.js',\n unauthorized: 'next/dist/client/components/builtin/unauthorized.js',\n} as const\n\nconst FILE_TYPES = {\n layout: 'layout',\n template: 'template',\n error: 'error',\n loading: 'loading',\n 'global-error': 'global-error',\n 'global-not-found': 'global-not-found',\n ...HTTP_ACCESS_FALLBACKS,\n} as const\n\nconst GLOBAL_ERROR_FILE_TYPE = 'global-error'\nconst GLOBAL_NOT_FOUND_FILE_TYPE = 'global-not-found'\nconst PAGE_SEGMENT = 'page$'\nconst PARALLEL_VIRTUAL_SEGMENT = 'slot$'\n\nconst defaultGlobalErrorPath =\n 'next/dist/client/components/builtin/global-error.js'\nconst defaultNotFoundPath = 'next/dist/client/components/builtin/not-found.js'\nconst defaultEmptyStubPath = 'next/dist/client/components/builtin/empty-stub.js'\nconst defaultLayoutPath = 'next/dist/client/components/builtin/layout.js'\nconst defaultGlobalNotFoundPath =\n 'next/dist/client/components/builtin/global-not-found.js'\nconst appErrorPath = 'next/dist/client/components/builtin/app-error.js'\n\ntype DirResolver = (pathToResolve: string) => string\ntype PathResolver = (\n pathname: string\n) => Promise<string | undefined> | string | undefined\nexport type MetadataResolver = (\n dir: string,\n filename: string,\n extensions: readonly string[]\n) => Promise<string | undefined>\n\nexport type AppDirModules = {\n readonly [moduleKey in ValueOf<typeof FILE_TYPES>]?: ModuleTuple\n} & {\n readonly page?: ModuleTuple\n} & {\n readonly metadata?: CollectedMetadata\n} & {\n readonly defaultPage?: ModuleTuple\n}\n\nconst normalizeParallelKey = (key: string) =>\n key.startsWith('@') ? key.slice(1) : key\n\nconst isCatchAllSegment = (segment: string) =>\n segment.startsWith('[...') || segment.startsWith('[[...')\n\nconst isDirectory = async (pathname: string) => {\n try {\n const stat = await fs.stat(pathname)\n return stat.isDirectory()\n } catch (err) {\n return false\n }\n}\n\nasync function createTreeCodeFromPath(\n pagePath: string,\n {\n page,\n resolveDir,\n resolver,\n resolveParallelSegments,\n hasChildRoutesForSegment,\n metadataResolver,\n pageExtensions,\n basePath,\n collectedDeclarations,\n isGlobalNotFoundEnabled,\n }: {\n page: string\n resolveDir: DirResolver\n resolver: PathResolver\n metadataResolver: MetadataResolver\n resolveParallelSegments: (\n pathname: string\n ) => [key: string, segment: string | string[]][]\n hasChildRoutesForSegment: (segmentPath: string) => boolean\n loaderContext: webpack.LoaderContext<AppLoaderOptions>\n pageExtensions: PageExtensions\n basePath: string\n collectedDeclarations: [string, string][]\n isGlobalNotFoundEnabled: boolean\n }\n): Promise<{\n treeCode: string\n rootLayout: string | undefined\n globalError: string\n globalNotFound: string\n}> {\n const splittedPath = pagePath.split(/[\\\\/]/, 1)\n const isNotFoundRoute = page === UNDERSCORE_NOT_FOUND_ROUTE_ENTRY\n const isAppErrorRoute = page === UNDERSCORE_GLOBAL_ERROR_ROUTE_ENTRY\n const isDefaultNotFound = isAppBuiltinPage(pagePath)\n\n const appDirPrefix = isDefaultNotFound ? APP_DIR_ALIAS : splittedPath[0]\n\n let rootLayout: string | undefined\n let globalError: string = defaultGlobalErrorPath\n let globalNotFound: string = defaultNotFoundPath\n\n async function resolveAdjacentParallelSegments(\n segmentPath: string\n ): Promise<string[]> {\n const absoluteSegmentPath = resolveDir(`${appDirPrefix}${segmentPath}`)\n\n if (!absoluteSegmentPath) {\n return []\n }\n\n const segmentIsDirectory = await isDirectory(absoluteSegmentPath)\n\n if (!segmentIsDirectory) {\n return []\n }\n\n // We need to resolve all parallel routes in this level.\n const files = await fs.opendir(absoluteSegmentPath)\n\n const parallelSegments: string[] = ['children']\n\n for await (const dirent of files) {\n // Make sure name starts with \"@\" and is a directory.\n if (dirent.isDirectory() && dirent.name.charCodeAt(0) === 64) {\n parallelSegments.push(dirent.name)\n }\n }\n\n return parallelSegments\n }\n\n async function createSubtreePropsFromSegmentPath(\n segments: string[],\n nestedCollectedDeclarations: [string, string][]\n ): Promise<{\n treeCode: string\n }> {\n const segmentPath = segments.join('/')\n\n // Existing tree are the children of the current segment\n const props: Record<string, string> = {}\n // Root layer could be 1st layer of normal routes\n const isRootLayer = segments.length === 0\n const isRootLayoutOrRootPage = segments.length <= 1\n\n // We need to resolve all parallel routes in this level.\n const parallelSegments: [key: string, segment: string | string[]][] = []\n if (isRootLayer) {\n parallelSegments.push(['children', ''])\n } else {\n parallelSegments.push(...resolveParallelSegments(segmentPath))\n }\n\n let metadata: Awaited<ReturnType<typeof createStaticMetadataFromRoute>> =\n null\n const routerDirPath = `${appDirPrefix}${segmentPath}`\n const resolvedRouteDir = resolveDir(routerDirPath)\n\n if (\n resolvedRouteDir &&\n // Do not collect metadata for app-error route as it's for generating pure static 500.html\n !normalizePathSep(pagePath).endsWith(appErrorPath)\n ) {\n metadata = await createStaticMetadataFromRoute(resolvedRouteDir, {\n basePath,\n segment: segmentPath,\n metadataResolver,\n isRootLayoutOrRootPage,\n pageExtensions,\n })\n }\n\n for (const [parallelKey, parallelSegment] of parallelSegments) {\n // if parallelSegment is the page segment (ie, `page$` and not ['page$']), it gets loaded into the __PAGE__ slot\n // as it's the page for the current route.\n if (parallelSegment === PAGE_SEGMENT) {\n const matchedPagePath = `${appDirPrefix}${segmentPath}${\n parallelKey === 'children' ? '' : `/${parallelKey}`\n }/page`\n\n const resolvedPagePath = await resolver(matchedPagePath)\n if (resolvedPagePath) {\n const varName = `page${nestedCollectedDeclarations.length}`\n nestedCollectedDeclarations.push([varName, resolvedPagePath])\n\n // Use '' for segment as it's the page. There can't be a segment called '' so this is the safest way to add it.\n props[normalizeParallelKey(parallelKey)] =\n `['${PAGE_SEGMENT_KEY}', {}, {\n page: [${varName}, ${JSON.stringify(resolvedPagePath)}],\n ${createMetadataExportsCode(metadata)}\n }]`\n continue\n } else {\n throw new Error(`Can't resolve ${matchedPagePath}`)\n }\n }\n\n // if the parallelSegment was not matched to the __PAGE__ slot, then it's a parallel route at this level.\n // the code below recursively traverses the parallel slots directory to match the corresponding __PAGE__ for each parallel slot\n // while also filling in layout/default/etc files into the loader tree at each segment level.\n\n const subSegmentPath = [...segments]\n if (parallelKey !== 'children') {\n // A `children` parallel key should have already been processed in the above segment\n // So we exclude it when constructing the subsegment path for the remaining segment levels\n subSegmentPath.push(parallelKey)\n }\n\n const normalizedParallelSegment = Array.isArray(parallelSegment)\n ? parallelSegment[0]\n : parallelSegment\n\n if (\n normalizedParallelSegment !== PAGE_SEGMENT &&\n normalizedParallelSegment !== PARALLEL_VIRTUAL_SEGMENT\n ) {\n // If we don't have a page segment, nor a special $children marker, it means we need to traverse the next directory\n // (ie, `normalizedParallelSegment` would correspond with the folder that contains the next level of pages/layout/etc)\n // we push it to the subSegmentPath so that we can fill in the loader tree for that segment.\n subSegmentPath.push(normalizedParallelSegment)\n }\n\n const parallelSegmentPath = subSegmentPath.join('/')\n\n // Fill in the loader tree for all of the special files types (layout, default, etc) at this level\n // `page` is not included here as it's added above.\n const filePathEntries = await Promise.all(\n Object.values(FILE_TYPES).map(async (file) => {\n return [\n file,\n await resolver(\n `${appDirPrefix}${\n // TODO-APP: parallelSegmentPath sometimes ends in `/` but sometimes it doesn't. This should be consistent.\n parallelSegmentPath.endsWith('/')\n ? parallelSegmentPath\n : parallelSegmentPath + '/'\n }${file}`\n ),\n ] as const\n })\n )\n const filePaths = new Map<ValueOf<typeof FILE_TYPES>, string | undefined>(\n filePathEntries\n )\n\n // Only resolve global-* convention files at the root layer\n if (isRootLayer) {\n const resolvedGlobalErrorPath = await resolver(\n `${appDirPrefix}/${GLOBAL_ERROR_FILE_TYPE}`\n )\n if (resolvedGlobalErrorPath) {\n globalError = resolvedGlobalErrorPath\n }\n // Add global-error to root layer's filePaths, so that it's always available,\n // by default it's the built-in global-error.js\n filePaths.set(GLOBAL_ERROR_FILE_TYPE, globalError)\n\n // TODO(global-not-found): remove this flag assertion condition\n // once global-not-found is stable\n if (isGlobalNotFoundEnabled) {\n const resolvedGlobalNotFoundPath = await resolver(\n `${appDirPrefix}/${GLOBAL_NOT_FOUND_FILE_TYPE}`\n )\n if (resolvedGlobalNotFoundPath) {\n globalNotFound = resolvedGlobalNotFoundPath\n }\n // Add global-not-found to root layer's filePaths, so that it's always available,\n // by default it's the built-in global-not-found.js\n filePaths.set(GLOBAL_NOT_FOUND_FILE_TYPE, globalNotFound)\n }\n }\n\n let definedFilePaths = Array.from(filePaths.entries()).filter(\n ([, filePath]) => filePath !== undefined\n ) as [ValueOf<typeof FILE_TYPES>, string][]\n\n // Add default access fallback as root fallback if not present\n const existedConventionNames = new Set(\n definedFilePaths.map(([type]) => type)\n )\n // If the first layer is a group route, we treat it as root layer\n const isFirstLayerGroupRoute =\n segments.length === 1 &&\n subSegmentPath.filter((seg) => isGroupSegment(seg)).length === 1\n\n if (isRootLayer || isFirstLayerGroupRoute) {\n const accessFallbackTypes = Object.keys(\n defaultHTTPAccessFallbackPaths\n ) as (keyof typeof defaultHTTPAccessFallbackPaths)[]\n for (const type of accessFallbackTypes) {\n const hasRootFallbackFile = await resolver(\n `${appDirPrefix}/${FILE_TYPES[type]}`\n )\n const hasLayerFallbackFile = existedConventionNames.has(type)\n\n // If you already have a root access error fallback, don't insert default access error boundary to group routes root\n if (\n // Is treated as root layout and without boundary\n !(hasRootFallbackFile && isFirstLayerGroupRoute) &&\n // Does not have a fallback boundary file\n !hasLayerFallbackFile\n ) {\n const defaultFallbackPath = defaultHTTPAccessFallbackPaths[type]\n if (!(isDefaultNotFound && type === 'not-found')) {\n definedFilePaths.push([type, defaultFallbackPath])\n }\n }\n }\n }\n\n if (!rootLayout) {\n const layoutPath = definedFilePaths.find(\n ([type]) => type === 'layout'\n )?.[1]\n rootLayout = layoutPath\n\n // When `global-not-found` is disabled, we insert a default layout if\n // root layout is presented. This logic and the default layout will be removed\n // once `global-not-found` is stabilized.\n if (\n !isGlobalNotFoundEnabled &&\n isDefaultNotFound &&\n !layoutPath &&\n !rootLayout\n ) {\n rootLayout = defaultLayoutPath\n definedFilePaths.push(['layout', rootLayout])\n }\n }\n\n let parallelSegmentKey = Array.isArray(parallelSegment)\n ? parallelSegment[0]\n : parallelSegment\n\n // normalize the parallel segment key to remove any special markers that we inserted in the\n // earlier logic (such as children$ and page$). These should never appear in the loader tree, and\n // should instead be the corresponding segment keys (ie `__PAGE__`) or the `children` parallel route.\n parallelSegmentKey =\n parallelSegmentKey === PARALLEL_VIRTUAL_SEGMENT\n ? '(slot)'\n : parallelSegmentKey === PAGE_SEGMENT\n ? PAGE_SEGMENT_KEY\n : parallelSegmentKey\n\n const normalizedParallelKey = normalizeParallelKey(parallelKey)\n let subtreeCode: string | undefined\n // If it's root not found page, set not-found boundary as children page\n if (isNotFoundRoute) {\n if (normalizedParallelKey === 'children') {\n const matchedGlobalNotFound = isGlobalNotFoundEnabled\n ? (definedFilePaths.find(\n ([type]) => type === GLOBAL_NOT_FOUND_FILE_TYPE\n )?.[1] ?? defaultGlobalNotFoundPath)\n : undefined\n\n // If custom global-not-found.js is defined, use global-not-found.js\n if (matchedGlobalNotFound) {\n const varName = `notFound${nestedCollectedDeclarations.length}`\n nestedCollectedDeclarations.push([varName, matchedGlobalNotFound])\n const layoutName = `layout${nestedCollectedDeclarations.length}`\n nestedCollectedDeclarations.push([layoutName, defaultEmptyStubPath])\n subtreeCode = `{\n children: [${JSON.stringify(UNDERSCORE_NOT_FOUND_ROUTE)}, {\n children: ['${PAGE_SEGMENT_KEY}', {}, {\n layout: [\n ${varName},\n ${JSON.stringify(matchedGlobalNotFound)}\n ],\n page: [\n ${layoutName},\n ${JSON.stringify(defaultEmptyStubPath)}\n ]\n }]\n }, {}]\n }`\n } else {\n // If custom not-found.js is found, use it and layout to compose the page,\n // and fallback to built-in not-found component if doesn't exist.\n const notFoundPath =\n definedFilePaths.find(([type]) => type === 'not-found')?.[1] ??\n defaultNotFoundPath\n const varName = `notFound${nestedCollectedDeclarations.length}`\n nestedCollectedDeclarations.push([varName, notFoundPath])\n subtreeCode = `{\n children: [${JSON.stringify(UNDERSCORE_NOT_FOUND_ROUTE.slice(1))}, {\n children: ['${PAGE_SEGMENT_KEY}', {}, {\n page: [\n ${varName},\n ${JSON.stringify(notFoundPath)}\n ]\n }]\n }, {}]\n }`\n }\n }\n }\n\n // If it's app-error route, set app-error as children page\n if (isAppErrorRoute) {\n const varName = `appError${nestedCollectedDeclarations.length}`\n nestedCollectedDeclarations.push([varName, appErrorPath])\n subtreeCode = `{\n children: [${JSON.stringify(UNDERSCORE_GLOBAL_ERROR_ROUTE.slice(1))}, {\n children: ['${PAGE_SEGMENT_KEY}', {}, {\n page: [\n ${varName},\n ${JSON.stringify(appErrorPath)}\n ]\n }]\n }, {}]\n }`\n }\n\n // For 404 route\n // if global-not-found is in definedFilePaths, remove root layout for /_not-found,\n // and change it to global-not-found route.\n // TODO: remove this once global-not-found is stable.\n if (isNotFoundRoute && isGlobalNotFoundEnabled) {\n definedFilePaths = definedFilePaths.filter(\n ([type]) => type !== 'layout'\n )\n\n // Replace the layout to global-not-found\n definedFilePaths.push([\n 'layout',\n definedFilePaths.find(\n ([type]) => type === GLOBAL_NOT_FOUND_FILE_TYPE\n )?.[1] ?? defaultGlobalNotFoundPath,\n ])\n }\n\n if (isAppErrorRoute) {\n definedFilePaths = definedFilePaths.filter(\n ([type]) => type !== 'layout'\n )\n }\n\n const modulesCode = `{\n ${definedFilePaths\n .map(([file, filePath]) => {\n const varName = `module${nestedCollectedDeclarations.length}`\n nestedCollectedDeclarations.push([varName, filePath])\n return `'${file}': [${varName}, ${JSON.stringify(filePath)}],`\n })\n .join('\\n')}\n ${createMetadataExportsCode(metadata)}\n }`\n\n if (!subtreeCode) {\n const { treeCode: pageSubtreeCode } =\n await createSubtreePropsFromSegmentPath(\n subSegmentPath,\n nestedCollectedDeclarations\n )\n\n subtreeCode = pageSubtreeCode\n }\n\n props[normalizedParallelKey] = `[\n '${parallelSegmentKey}',\n ${subtreeCode},\n ${modulesCode}\n ]`\n }\n\n const adjacentParallelSegments =\n await resolveAdjacentParallelSegments(segmentPath)\n\n for (const adjacentParallelSegment of adjacentParallelSegments) {\n if (!props[normalizeParallelKey(adjacentParallelSegment)]) {\n const actualSegment =\n adjacentParallelSegment === 'children'\n ? ''\n : `/${adjacentParallelSegment}`\n\n // Use the default path if it's found, otherwise if it's a children\n // slot, then use the fallback (which triggers a `notFound()`). If this\n // isn't a children slot, then throw an error, as it produces a silent\n // 404 if we'd used the fallback.\n const fullSegmentPath = `${appDirPrefix}${segmentPath}${actualSegment}`\n let defaultPath = await resolver(`${fullSegmentPath}/default`)\n if (!defaultPath) {\n if (adjacentParallelSegment === 'children') {\n defaultPath = PARALLEL_ROUTE_DEFAULT_PATH\n } else {\n // Check if we're inside a catch-all route (i.e., the parallel route is a child\n // of a catch-all segment). Only skip validation if the slot is UNDER a catch-all.\n // For example:\n // /[...catchAll]/@slot - isInsideCatchAll = true (skip validation) ✓\n // /@slot/[...catchAll] - isInsideCatchAll = false (require default) ✓\n // The catch-all provides fallback behavior, so default.js is not required.\n const isInsideCatchAll = segments.some(isCatchAllSegment)\n\n // Check if this is a leaf segment (no child routes).\n // Leaf segments don't need default.js because there are no child routes\n // that could cause the parallel slot to unmatch. For example:\n // /repo-overview/@slot/page with no child routes - isLeafSegment = true (skip validation) ✓\n // /repo-overview/@slot/page with /repo-overview/child/page - isLeafSegment = false (require default) ✓\n // This also handles route groups correctly by filtering them out.\n const isLeafSegment = !hasChildRoutesForSegment(segmentPath)\n\n if (!isInsideCatchAll && !isLeafSegment) {\n // Replace internal webpack alias with user-facing directory name\n const userFacingPath = fullSegmentPath.replace(\n APP_DIR_ALIAS,\n 'app'\n )\n throw new MissingDefaultParallelRouteError(\n userFacingPath,\n adjacentParallelSegment\n )\n }\n defaultPath = PARALLEL_ROUTE_DEFAULT_PATH\n }\n }\n\n const varName = `default${nestedCollectedDeclarations.length}`\n nestedCollectedDeclarations.push([varName, defaultPath])\n props[normalizeParallelKey(adjacentParallelSegment)] = `[\n '${DEFAULT_SEGMENT_KEY}',\n {},\n {\n defaultPage: [${varName}, ${JSON.stringify(defaultPath)}],\n }\n ]`\n }\n }\n return {\n treeCode: `{\n ${Object.entries(props)\n .map(([key, value]) => `${key}: ${value}`)\n .join(',\\n')}\n }`,\n }\n }\n\n const { treeCode } = await createSubtreePropsFromSegmentPath(\n [],\n collectedDeclarations\n )\n\n return {\n treeCode: `${treeCode}.children;`,\n rootLayout,\n globalError,\n globalNotFound,\n }\n}\n\nfunction createAbsolutePath(appDir: string, pathToTurnAbsolute: string) {\n return (\n pathToTurnAbsolute\n // Replace all POSIX path separators with the current OS path separator\n .replace(/\\//g, path.sep)\n .replace(/^private-next-app-dir/, appDir)\n )\n}\n\nconst filesInDirMapMap: WeakMap<\n Compilation,\n Map<string, Promise<Set<string>>>\n> = new WeakMap()\nconst nextAppLoader: AppLoader = async function nextAppLoader() {\n const loaderOptions = this.getOptions()\n const {\n name,\n appDir,\n appPaths,\n pagePath,\n pageExtensions,\n rootDir,\n tsconfigPath,\n isDev,\n nextConfigOutput,\n preferredRegion,\n basePath,\n middlewareConfig: middlewareConfigBase64,\n } = loaderOptions\n\n const isGlobalNotFoundEnabled = !!loaderOptions.isGlobalNotFoundEnabled\n\n // Update FILE_TYPES on the very top-level of the loader\n if (!isGlobalNotFoundEnabled) {\n // @ts-expect-error this delete is only necessary while experimental\n delete FILE_TYPES['global-not-found']\n }\n\n const buildInfo = getModuleBuildInfo((this as any)._module)\n const collectedDeclarations: [string, string][] = []\n const page = name.replace(/^app/, '')\n const middlewareConfig: ProxyConfig = JSON.parse(\n Buffer.from(middlewareConfigBase64, 'base64').toString()\n )\n buildInfo.route = {\n page,\n absolutePagePath: createAbsolutePath(appDir, pagePath),\n preferredRegion,\n middlewareConfig,\n relatedModules: [],\n }\n\n const extensions =\n typeof pageExtensions === 'string'\n ? [pageExtensions]\n : pageExtensions.map((extension) => `.${extension}`)\n\n const normalizedAppPaths =\n typeof appPaths === 'string' ? [appPaths] : appPaths || []\n\n const resolveParallelSegments = (\n pathname: string\n ): [string, string | string[]][] => {\n const matched: Record<string, string | string[]> = {}\n let existingChildrenPath: string | undefined\n for (const appPath of normalizedAppPaths) {\n if (appPath.startsWith(pathname + '/')) {\n const rest = appPath.slice(pathname.length + 1).split('/')\n\n // It is the actual page, mark it specially.\n if (rest.length === 1 && rest[0] === 'page') {\n existingChildrenPath = appPath\n matched.children = PAGE_SEGMENT\n continue\n }\n\n const isParallelRoute = rest[0].startsWith('@')\n if (isParallelRoute) {\n if (rest.length === 2 && rest[1] === 'page') {\n // We found a parallel route at this level. We don't want to mark it explicitly as the page segment,\n // as that should be matched to the `children` slot. Instead, we use an array, to signal to `createSubtreePropsFromSegmentPath`\n // that it needs to recursively fill in the loader tree code for the parallel route at the appropriate levels.\n matched[rest[0]] = [PAGE_SEGMENT]\n continue\n }\n // If it was a parallel route but we weren't able to find the page segment (ie, maybe the page is nested further)\n // we first insert a special marker to ensure that we still process layout/default/etc at the slot level prior to continuing\n // on to the page segment.\n matched[rest[0]] = [PARALLEL_VIRTUAL_SEGMENT, ...rest.slice(1)]\n continue\n }\n\n if (existingChildrenPath && matched.children !== rest[0]) {\n // If we get here, it means we already set a `page` segment earlier in the loop,\n // meaning we already matched a page to the `children` parallel segment.\n const isIncomingParallelPage = appPath.includes('@')\n const hasCurrentParallelPage = existingChildrenPath.includes('@')\n\n if (isIncomingParallelPage) {\n // The duplicate segment was for a parallel slot. In this case,\n // rather than throwing an error, we can ignore it since this can happen for valid reasons.\n // For example, when we attempt to normalize catch-all routes, we'll push potential slot matches so\n // that they are available in the loader tree when we go to render the page.\n // We only need to throw an error if the duplicate segment was for a regular page.\n // For example, /app/(groupa)/page & /app/(groupb)/page is an error since it corresponds\n // with the same path.\n continue\n } else if (!hasCurrentParallelPage && !isIncomingParallelPage) {\n // Both the current `children` and the incoming `children` are regular pages.\n throw new Error(\n `You cannot have two parallel pages that resolve to the same path. Please check ${existingChildrenPath} and ${appPath}. Refer to the route group docs for more information: https://nextjs.org/docs/app/building-your-application/routing/route-groups`\n )\n }\n }\n\n existingChildrenPath = appPath\n matched.children = rest[0]\n }\n }\n\n return Object.entries(matched)\n }\n\n const hasChildRoutesForSegment = (segmentPath: string): boolean => {\n const pathPrefix = segmentPath ? `${segmentPath}/` : ''\n\n for (const appPath of normalizedAppPaths) {\n if (appPath.startsWith(pathPrefix)) {\n const rest = appPath.slice(pathPrefix.length).split('/')\n\n // Filter out route groups to get the actual route segments\n // Route groups (e.g., \"(group)\") don't contribute to the URL path\n const routeSegments = rest.filter((segment) => !isGroupSegment(segment))\n\n // If it's just 'page' at this level, skip (not a child route)\n if (routeSegments.length === 1 && routeSegments[0] === 'page') {\n continue\n }\n\n // If the first segment (after filtering route groups) is a parallel route, skip\n if (routeSegments[0]?.startsWith('@')) {\n continue\n }\n\n // If we have more than just 'page', then there are child routes\n // Examples:\n // ['child', 'page'] -> true (has child route)\n // ['page'] -> false (already filtered above)\n // ['grandchild', 'deeper', 'page'] -> true (has nested child routes)\n if (\n routeSegments.length > 1 ||\n (routeSegments.length === 1 && routeSegments[0] !== 'page')\n ) {\n return true\n }\n }\n }\n\n return false\n }\n\n const resolveDir: DirResolver = (pathToResolve) => {\n return createAbsolutePath(appDir, pathToResolve)\n }\n\n const resolveAppRoute: PathResolver = (pathToResolve) => {\n return createAbsolutePath(appDir, pathToResolve)\n }\n\n // Cached checker to see if a file exists in a given directory.\n // This can be more efficient than checking them with `fs.stat` one by one\n // because all the thousands of files are likely in a few possible directories.\n // Note that it should only be cached for this compilation, not globally.\n const fileExistsInDirectory = async (dirname: string, fileName: string) => {\n // I don't think we should ever hit this code path, but if we do we should handle it gracefully.\n if (this._compilation === undefined) {\n try {\n return (await getFilesInDir(dirname).catch(() => new Set())).has(\n fileName\n )\n } catch (e) {\n return false\n }\n }\n const map =\n filesInDirMapMap.get(this._compilation) ||\n new Map<string, Promise<Set<string>>>()\n if (!filesInDirMapMap.has(this._compilation)) {\n filesInDirMapMap.set(this._compilation, map)\n }\n if (!map.has(dirname)) {\n map.set(\n dirname,\n getFilesInDir(dirname).catch(() => new Set())\n )\n }\n return ((await map.get(dirname)) || new Set()).has(fileName)\n }\n\n const resolver: PathResolver = async (pathname) => {\n const absolutePath = createAbsolutePath(appDir, pathname)\n\n const filenameIndex = absolutePath.lastIndexOf(path.sep)\n const dirname = absolutePath.slice(0, filenameIndex)\n const filename = absolutePath.slice(filenameIndex + 1)\n\n let result: string | undefined\n\n for (const ext of extensions) {\n const absolutePathWithExtension = `${absolutePath}${ext}`\n if (\n !result &&\n (await fileExistsInDirectory(dirname, `${filename}${ext}`))\n ) {\n result = absolutePathWithExtension\n }\n // Call `addMissingDependency` for all files even if they didn't match,\n // because they might be added or removed during development.\n this.addMissingDependency(absolutePathWithExtension)\n }\n\n return result\n }\n\n const metadataResolver: MetadataResolver = async (\n dirname,\n filename,\n exts\n ) => {\n const absoluteDir = createAbsolutePath(appDir, dirname)\n\n let result: string | undefined\n\n for (const ext of exts) {\n // Compared to `resolver` above the exts do not have the `.` included already, so it's added here.\n const filenameWithExt = `${filename}.${ext}`\n const absolutePathWithExtension = `${absoluteDir}${path.sep}${filenameWithExt}`\n if (!result && (await fileExistsInDirectory(dirname, filenameWithExt))) {\n result = absolutePathWithExtension\n }\n // Call `addMissingDependency` for all files even if they didn't match,\n // because they might be added or removed during development.\n this.addMissingDependency(absolutePathWithExtension)\n }\n\n return result\n }\n\n if (isAppRouteRoute(name)) {\n return createAppRouteCode({\n appDir,\n // TODO: investigate if the local `page` is the same as the loaderOptions.page\n page: loaderOptions.page,\n name,\n pagePath,\n resolveAppRoute,\n pageExtensions,\n nextConfigOutput,\n })\n }\n\n let treeCodeResult = await createTreeCodeFromPath(pagePath, {\n page,\n resolveDir,\n resolver,\n metadataResolver,\n resolveParallelSegments,\n hasChildRoutesForSegment,\n loaderContext: this,\n pageExtensions,\n basePath,\n collectedDeclarations,\n isGlobalNotFoundEnabled,\n })\n\n const isGlobalNotFoundPath =\n page === UNDERSCORE_NOT_FOUND_ROUTE_ENTRY &&\n !!treeCodeResult.globalNotFound &&\n isGlobalNotFoundEnabled\n\n const isAppErrorRoute = page === UNDERSCORE_GLOBAL_ERROR_ROUTE_ENTRY\n\n if (!treeCodeResult.rootLayout && !isGlobalNotFoundPath && !isAppErrorRoute) {\n if (!isDev) {\n // If we're building and missing a root layout, exit the build\n Log.error(\n `${bold(\n pagePath.replace(`${APP_DIR_ALIAS}/`, '')\n )} doesn't have a root layout. To fix this error, make sure every page has a root layout.`\n )\n process.exit(1)\n } else {\n // In dev we'll try to create a root layout\n const [createdRootLayout, rootLayoutPath] = await verifyRootLayout({\n appDir: appDir,\n dir: rootDir!,\n tsconfigPath: tsconfigPath,\n pagePath,\n pageExtensions,\n })\n if (!createdRootLayout) {\n let message = `${bold(\n pagePath.replace(`${APP_DIR_ALIAS}/`, '')\n )} doesn't have a root layout. `\n\n if (rootLayoutPath) {\n message += `We tried to create ${bold(\n path.relative(this._compiler?.context ?? '', rootLayoutPath)\n )} for you but something went wrong.`\n } else {\n message +=\n 'To fix this error, make sure every page has a root layout.'\n }\n\n throw new Error(message)\n }\n\n // Clear fs cache, get the new result with the created root layout.\n if (this._compilation) filesInDirMapMap.get(this._compilation)?.clear()\n treeCodeResult = await createTreeCodeFromPath(pagePath, {\n page,\n resolveDir,\n resolver,\n metadataResolver,\n resolveParallelSegments,\n hasChildRoutesForSegment,\n loaderContext: this,\n pageExtensions,\n basePath,\n collectedDeclarations,\n isGlobalNotFoundEnabled,\n })\n }\n }\n\n const pathname = new AppPathnameNormalizer().normalize(page)\n\n // Prefer to modify next/src/server/app-render/entry-base.ts since this is shared with Turbopack.\n // Any changes to this code should be reflected in Turbopack's app_source.rs and/or app-renderer.tsx as well.\n const code = await loadEntrypoint(\n 'app-page',\n {\n VAR_DEFINITION_PAGE: page,\n VAR_DEFINITION_PATHNAME: pathname,\n VAR_MODULE_GLOBAL_ERROR: treeCodeResult.globalError,\n },\n {\n tree: treeCodeResult.treeCode,\n __next_app_require__: '__webpack_require__',\n // all modules are in the entry chunk, so we never actually need to load chunks in webpack\n __next_app_load_chunk__: '() => Promise.resolve()',\n }\n )\n\n // Lazily evaluate the imported modules in the generated code\n const header = collectedDeclarations\n .map(([varName, modulePath]) => {\n return `const ${varName} = () => import(/* webpackMode: \"eager\" */ ${JSON.stringify(\n modulePath\n )});\\n`\n })\n .join('')\n\n return header + code\n}\n\nexport default nextAppLoader\n"],"names":["HTTP_ACCESS_FALLBACKS","forbidden","unauthorized","defaultHTTPAccessFallbackPaths","FILE_TYPES","layout","template","error","loading","GLOBAL_ERROR_FILE_TYPE","GLOBAL_NOT_FOUND_FILE_TYPE","PAGE_SEGMENT","PARALLEL_VIRTUAL_SEGMENT","defaultGlobalErrorPath","defaultNotFoundPath","defaultEmptyStubPath","defaultLayoutPath","defaultGlobalNotFoundPath","appErrorPath","normalizeParallelKey","key","startsWith","slice","isCatchAllSegment","segment","isDirectory","pathname","stat","fs","err","createTreeCodeFromPath","pagePath","page","resolveDir","resolver","resolveParallelSegments","hasChildRoutesForSegment","metadataResolver","pageExtensions","basePath","collectedDeclarations","isGlobalNotFoundEnabled","splittedPath","split","isNotFoundRoute","UNDERSCORE_NOT_FOUND_ROUTE_ENTRY","isAppErrorRoute","UNDERSCORE_GLOBAL_ERROR_ROUTE_ENTRY","isDefaultNotFound","isAppBuiltinPage","appDirPrefix","APP_DIR_ALIAS","rootLayout","globalError","globalNotFound","resolveAdjacentParallelSegments","segmentPath","absoluteSegmentPath","segmentIsDirectory","files","opendir","parallelSegments","dirent","name","charCodeAt","push","createSubtreePropsFromSegmentPath","segments","nestedCollectedDeclarations","join","props","isRootLayer","length","isRootLayoutOrRootPage","metadata","routerDirPath","resolvedRouteDir","normalizePathSep","endsWith","createStaticMetadataFromRoute","parallelKey","parallelSegment","matchedPagePath","resolvedPagePath","varName","PAGE_SEGMENT_KEY","JSON","stringify","createMetadataExportsCode","Error","subSegmentPath","normalizedParallelSegment","Array","isArray","parallelSegmentPath","filePathEntries","Promise","all","Object","values","map","file","filePaths","Map","resolvedGlobalErrorPath","set","resolvedGlobalNotFoundPath","definedFilePaths","from","entries","filter","filePath","undefined","existedConventionNames","Set","type","isFirstLayerGroupRoute","seg","isGroupSegment","accessFallbackTypes","keys","hasRootFallbackFile","hasLayerFallbackFile","has","defaultFallbackPath","layoutPath","find","parallelSegmentKey","normalizedParallelKey","subtreeCode","matchedGlobalNotFound","layoutName","UNDERSCORE_NOT_FOUND_ROUTE","notFoundPath","UNDERSCORE_GLOBAL_ERROR_ROUTE","modulesCode","treeCode","pageSubtreeCode","adjacentParallelSegments","adjacentParallelSegment","actualSegment","fullSegmentPath","defaultPath","PARALLEL_ROUTE_DEFAULT_PATH","isInsideCatchAll","some","isLeafSegment","userFacingPath","replace","MissingDefaultParallelRouteError","DEFAULT_SEGMENT_KEY","value","createAbsolutePath","appDir","pathToTurnAbsolute","path","sep","filesInDirMapMap","WeakMap","nextAppLoader","loaderOptions","getOptions","appPaths","rootDir","tsconfigPath","isDev","nextConfigOutput","preferredRegion","middlewareConfig","middlewareConfigBase64","buildInfo","getModuleBuildInfo","_module","parse","Buffer","toString","route","absolutePagePath","relatedModules","extensions","extension","normalizedAppPaths","matched","existingChildrenPath","appPath","rest","children","isParallelRoute","isIncomingParallelPage","includes","hasCurrentParallelPage","pathPrefix","routeSegments","pathToResolve","resolveAppRoute","fileExistsInDirectory","dirname","fileName","_compilation","getFilesInDir","catch","e","get","absolutePath","filenameIndex","lastIndexOf","filename","result","ext","absolutePathWithExtension","addMissingDependency","exts","absoluteDir","filenameWithExt","isAppRouteRoute","createAppRouteCode","treeCodeResult","loaderContext","isGlobalNotFoundPath","Log","bold","process","exit","createdRootLayout","rootLayoutPath","verifyRootLayout","dir","message","relative","_compiler","context","clear","AppPathnameNormalizer","normalize","code","loadEntrypoint","VAR_DEFINITION_PAGE","VAR_DEFINITION_PATHNAME","VAR_MODULE_GLOBAL_ERROR","tree","__next_app_require__","__next_app_load_chunk__","header","modulePath"],"mappings":";;;;+BA89BA;;;eAAA;;;2BAz9BO;gCAIA;6DAGU;4BACI;oCACc;kCACF;6DACZ;4BACS;0BAIvB;oBACwB;iCACC;uCAEM;uBAEL;gCACF;yBAKxB;+BACuB;yBAEc;oCAET;kDACc;kCAChB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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gBACAG;gBACAF;gBACAC;gBACAqL,eAAe,IAAI;gBACnBnL;gBACAC;gBACAC;gBACAC;YACF;QACF;IACF;IAEA,MAAMf,WAAW,IAAI8M,4CAAqB,GAAGC,SAAS,CAACzM;IAEvD,iGAAiG;IACjG,6GAA6G;IAC7G,MAAM0M,OAAO,MAAMC,IAAAA,8BAAc,EAC/B,YACA;QACEC,qBAAqB5M;QACrB6M,yBAAyBnN;QACzBoN,yBAAyBtB,eAAenK,WAAW;IACrD,GACA;QACE0L,MAAMvB,eAAehF,QAAQ;QAC7BwG,sBAAsB;QACtB,0FAA0F;QAC1FC,yBAAyB;IAC3B;IAGF,6DAA6D;IAC7D,MAAMC,SAAS1M,sBACZ4D,GAAG,CAAC,CAAC,CAAChB,SAAS+J,WAAW;QACzB,OAAO,CAAC,MAAM,EAAE/J,QAAQ,2CAA2C,EAAEE,KAAKC,SAAS,CACjF4J,YACA,IAAI,CAAC;IACT,GACC9K,IAAI,CAAC;IAER,OAAO6K,SAASR;AAClB;MAEA,YAAe3E","ignoreList":[0]}
1
+ {"version":3,"sources":["../../../../../src/build/webpack/loaders/next-app-loader/index.ts"],"sourcesContent":["import type webpack from 'next/dist/compiled/webpack/webpack'\nimport {\n UNDERSCORE_GLOBAL_ERROR_ROUTE,\n UNDERSCORE_NOT_FOUND_ROUTE,\n type ValueOf,\n} from '../../../../shared/lib/constants'\nimport {\n UNDERSCORE_GLOBAL_ERROR_ROUTE_ENTRY,\n UNDERSCORE_NOT_FOUND_ROUTE_ENTRY,\n} from '../../../../shared/lib/entry-constants'\nimport type { ModuleTuple, CollectedMetadata } from '../metadata/types'\n\nimport path from 'path'\nimport { bold } from '../../../../lib/picocolors'\nimport { getModuleBuildInfo } from '../get-module-build-info'\nimport { verifyRootLayout } from '../../../../lib/verify-root-layout'\nimport * as Log from '../../../output/log'\nimport { APP_DIR_ALIAS } from '../../../../lib/constants'\nimport {\n createMetadataExportsCode,\n createStaticMetadataFromRoute,\n} from '../metadata/discover'\nimport { promises as fs } from 'fs'\nimport { isAppRouteRoute } from '../../../../lib/is-app-route-route'\nimport type { NextConfig } from '../../../../server/config-shared'\nimport { AppPathnameNormalizer } from '../../../../server/normalizers/built/app/app-pathname-normalizer'\nimport type { ProxyConfig } from '../../../analysis/get-page-static-info'\nimport { isAppBuiltinPage } from '../../../utils'\nimport { loadEntrypoint } from '../../../load-entrypoint'\nimport {\n isGroupSegment,\n DEFAULT_SEGMENT_KEY,\n PAGE_SEGMENT_KEY,\n} from '../../../../shared/lib/segment'\nimport { getFilesInDir } from '../../../../lib/get-files-in-dir'\nimport type { PageExtensions } from '../../../page-extensions-type'\nimport { PARALLEL_ROUTE_DEFAULT_PATH } from '../../../../client/components/builtin/default'\nimport type { Compilation } from 'webpack'\nimport { createAppRouteCode } from './create-app-route-code'\nimport { MissingDefaultParallelRouteError } from '../../../../shared/lib/errors/missing-default-parallel-route-error'\n\nimport { normalizePathSep } from '../../../../shared/lib/page-path/normalize-path-sep'\nimport { installBindings } from '../../../swc/install-bindings'\n\nexport type AppLoaderOptions = {\n name: string\n page: string\n pagePath: string\n appDir: string\n appPaths: readonly string[] | null\n preferredRegion: string | string[] | undefined\n pageExtensions: PageExtensions\n assetPrefix: string\n rootDir?: string\n tsconfigPath?: string\n isDev?: true\n basePath: string\n nextConfigOutput?: NextConfig['output']\n middlewareConfig: string\n isGlobalNotFoundEnabled: true | undefined\n}\ntype AppLoader = webpack.LoaderDefinitionFunction<AppLoaderOptions>\n\nconst HTTP_ACCESS_FALLBACKS = {\n 'not-found': 'not-found',\n forbidden: 'forbidden',\n unauthorized: 'unauthorized',\n} as const\nconst defaultHTTPAccessFallbackPaths = {\n 'not-found': 'next/dist/client/components/builtin/not-found.js',\n forbidden: 'next/dist/client/components/builtin/forbidden.js',\n unauthorized: 'next/dist/client/components/builtin/unauthorized.js',\n} as const\n\nconst FILE_TYPES = {\n layout: 'layout',\n template: 'template',\n error: 'error',\n loading: 'loading',\n 'global-error': 'global-error',\n 'global-not-found': 'global-not-found',\n ...HTTP_ACCESS_FALLBACKS,\n} as const\n\nconst GLOBAL_ERROR_FILE_TYPE = 'global-error'\nconst GLOBAL_NOT_FOUND_FILE_TYPE = 'global-not-found'\nconst PAGE_SEGMENT = 'page$'\nconst PARALLEL_VIRTUAL_SEGMENT = 'slot$'\n\nconst defaultGlobalErrorPath =\n 'next/dist/client/components/builtin/global-error.js'\nconst defaultNotFoundPath = 'next/dist/client/components/builtin/not-found.js'\nconst defaultEmptyStubPath = 'next/dist/client/components/builtin/empty-stub.js'\nconst defaultLayoutPath = 'next/dist/client/components/builtin/layout.js'\nconst defaultGlobalNotFoundPath =\n 'next/dist/client/components/builtin/global-not-found.js'\nconst appErrorPath = 'next/dist/client/components/builtin/app-error.js'\n\ntype DirResolver = (pathToResolve: string) => string\ntype PathResolver = (\n pathname: string\n) => Promise<string | undefined> | string | undefined\nexport type MetadataResolver = (\n dir: string,\n filename: string,\n extensions: readonly string[]\n) => Promise<string | undefined>\n\nexport type AppDirModules = {\n readonly [moduleKey in ValueOf<typeof FILE_TYPES>]?: ModuleTuple\n} & {\n readonly page?: ModuleTuple\n} & {\n readonly metadata?: CollectedMetadata\n} & {\n readonly defaultPage?: ModuleTuple\n}\n\nconst normalizeParallelKey = (key: string) =>\n key.startsWith('@') ? key.slice(1) : key\n\nconst isCatchAllSegment = (segment: string) =>\n segment.startsWith('[...') || segment.startsWith('[[...')\n\nconst isDirectory = async (pathname: string) => {\n try {\n const stat = await fs.stat(pathname)\n return stat.isDirectory()\n } catch (err) {\n return false\n }\n}\n\nasync function createTreeCodeFromPath(\n pagePath: string,\n {\n page,\n resolveDir,\n resolver,\n resolveParallelSegments,\n hasChildRoutesForSegment,\n metadataResolver,\n pageExtensions,\n basePath,\n collectedDeclarations,\n isGlobalNotFoundEnabled,\n }: {\n page: string\n resolveDir: DirResolver\n resolver: PathResolver\n metadataResolver: MetadataResolver\n resolveParallelSegments: (\n pathname: string\n ) => [key: string, segment: string | string[]][]\n hasChildRoutesForSegment: (segmentPath: string) => boolean\n loaderContext: webpack.LoaderContext<AppLoaderOptions>\n pageExtensions: PageExtensions\n basePath: string\n collectedDeclarations: [string, string][]\n isGlobalNotFoundEnabled: boolean\n }\n): Promise<{\n treeCode: string\n rootLayout: string | undefined\n globalError: string\n globalNotFound: string\n}> {\n const splittedPath = pagePath.split(/[\\\\/]/, 1)\n const isNotFoundRoute = page === UNDERSCORE_NOT_FOUND_ROUTE_ENTRY\n const isAppErrorRoute = page === UNDERSCORE_GLOBAL_ERROR_ROUTE_ENTRY\n const isDefaultNotFound = isAppBuiltinPage(pagePath)\n\n const appDirPrefix = isDefaultNotFound ? APP_DIR_ALIAS : splittedPath[0]\n\n let rootLayout: string | undefined\n let globalError: string = defaultGlobalErrorPath\n let globalNotFound: string = defaultNotFoundPath\n\n async function resolveAdjacentParallelSegments(\n segmentPath: string\n ): Promise<string[]> {\n const absoluteSegmentPath = resolveDir(`${appDirPrefix}${segmentPath}`)\n\n if (!absoluteSegmentPath) {\n return []\n }\n\n const segmentIsDirectory = await isDirectory(absoluteSegmentPath)\n\n if (!segmentIsDirectory) {\n return []\n }\n\n // We need to resolve all parallel routes in this level.\n const files = await fs.opendir(absoluteSegmentPath)\n\n const parallelSegments: string[] = ['children']\n\n for await (const dirent of files) {\n // Make sure name starts with \"@\" and is a directory.\n if (dirent.isDirectory() && dirent.name.charCodeAt(0) === 64) {\n parallelSegments.push(dirent.name)\n }\n }\n\n return parallelSegments\n }\n\n async function createSubtreePropsFromSegmentPath(\n segments: string[],\n nestedCollectedDeclarations: [string, string][]\n ): Promise<{\n treeCode: string\n }> {\n const segmentPath = segments.join('/')\n\n // Existing tree are the children of the current segment\n const props: Record<string, string> = {}\n // Root layer could be 1st layer of normal routes\n const isRootLayer = segments.length === 0\n const isRootLayoutOrRootPage = segments.length <= 1\n\n // We need to resolve all parallel routes in this level.\n const parallelSegments: [key: string, segment: string | string[]][] = []\n if (isRootLayer) {\n parallelSegments.push(['children', ''])\n } else {\n parallelSegments.push(...resolveParallelSegments(segmentPath))\n }\n\n let metadata: Awaited<ReturnType<typeof createStaticMetadataFromRoute>> =\n null\n const routerDirPath = `${appDirPrefix}${segmentPath}`\n const resolvedRouteDir = resolveDir(routerDirPath)\n\n if (\n resolvedRouteDir &&\n // Do not collect metadata for app-error route as it's for generating pure static 500.html\n !normalizePathSep(pagePath).endsWith(appErrorPath)\n ) {\n metadata = await createStaticMetadataFromRoute(resolvedRouteDir, {\n basePath,\n segment: segmentPath,\n metadataResolver,\n isRootLayoutOrRootPage,\n pageExtensions,\n })\n }\n\n for (const [parallelKey, parallelSegment] of parallelSegments) {\n // if parallelSegment is the page segment (ie, `page$` and not ['page$']), it gets loaded into the __PAGE__ slot\n // as it's the page for the current route.\n if (parallelSegment === PAGE_SEGMENT) {\n const matchedPagePath = `${appDirPrefix}${segmentPath}${\n parallelKey === 'children' ? '' : `/${parallelKey}`\n }/page`\n\n const resolvedPagePath = await resolver(matchedPagePath)\n if (resolvedPagePath) {\n const varName = `page${nestedCollectedDeclarations.length}`\n nestedCollectedDeclarations.push([varName, resolvedPagePath])\n\n // Use '' for segment as it's the page. There can't be a segment called '' so this is the safest way to add it.\n props[normalizeParallelKey(parallelKey)] =\n `['${PAGE_SEGMENT_KEY}', {}, {\n page: [${varName}, ${JSON.stringify(resolvedPagePath)}],\n ${createMetadataExportsCode(metadata)}\n }]`\n continue\n } else {\n throw new Error(`Can't resolve ${matchedPagePath}`)\n }\n }\n\n // if the parallelSegment was not matched to the __PAGE__ slot, then it's a parallel route at this level.\n // the code below recursively traverses the parallel slots directory to match the corresponding __PAGE__ for each parallel slot\n // while also filling in layout/default/etc files into the loader tree at each segment level.\n\n const subSegmentPath = [...segments]\n if (parallelKey !== 'children') {\n // A `children` parallel key should have already been processed in the above segment\n // So we exclude it when constructing the subsegment path for the remaining segment levels\n subSegmentPath.push(parallelKey)\n }\n\n const normalizedParallelSegment = Array.isArray(parallelSegment)\n ? parallelSegment[0]\n : parallelSegment\n\n if (\n normalizedParallelSegment !== PAGE_SEGMENT &&\n normalizedParallelSegment !== PARALLEL_VIRTUAL_SEGMENT\n ) {\n // If we don't have a page segment, nor a special $children marker, it means we need to traverse the next directory\n // (ie, `normalizedParallelSegment` would correspond with the folder that contains the next level of pages/layout/etc)\n // we push it to the subSegmentPath so that we can fill in the loader tree for that segment.\n subSegmentPath.push(normalizedParallelSegment)\n }\n\n const parallelSegmentPath = subSegmentPath.join('/')\n\n // Fill in the loader tree for all of the special files types (layout, default, etc) at this level\n // `page` is not included here as it's added above.\n const filePathEntries = await Promise.all(\n Object.values(FILE_TYPES).map(async (file) => {\n return [\n file,\n await resolver(\n `${appDirPrefix}${\n // TODO-APP: parallelSegmentPath sometimes ends in `/` but sometimes it doesn't. This should be consistent.\n parallelSegmentPath.endsWith('/')\n ? parallelSegmentPath\n : parallelSegmentPath + '/'\n }${file}`\n ),\n ] as const\n })\n )\n const filePaths = new Map<ValueOf<typeof FILE_TYPES>, string | undefined>(\n filePathEntries\n )\n\n // Only resolve global-* convention files at the root layer\n if (isRootLayer) {\n const resolvedGlobalErrorPath = await resolver(\n `${appDirPrefix}/${GLOBAL_ERROR_FILE_TYPE}`\n )\n if (resolvedGlobalErrorPath) {\n globalError = resolvedGlobalErrorPath\n }\n // Add global-error to root layer's filePaths, so that it's always available,\n // by default it's the built-in global-error.js\n filePaths.set(GLOBAL_ERROR_FILE_TYPE, globalError)\n\n // TODO(global-not-found): remove this flag assertion condition\n // once global-not-found is stable\n if (isGlobalNotFoundEnabled) {\n const resolvedGlobalNotFoundPath = await resolver(\n `${appDirPrefix}/${GLOBAL_NOT_FOUND_FILE_TYPE}`\n )\n if (resolvedGlobalNotFoundPath) {\n globalNotFound = resolvedGlobalNotFoundPath\n }\n // Add global-not-found to root layer's filePaths, so that it's always available,\n // by default it's the built-in global-not-found.js\n filePaths.set(GLOBAL_NOT_FOUND_FILE_TYPE, globalNotFound)\n }\n }\n\n let definedFilePaths = Array.from(filePaths.entries()).filter(\n ([, filePath]) => filePath !== undefined\n ) as [ValueOf<typeof FILE_TYPES>, string][]\n\n // Add default access fallback as root fallback if not present\n const existedConventionNames = new Set(\n definedFilePaths.map(([type]) => type)\n )\n // If the first layer is a group route, we treat it as root layer\n const isFirstLayerGroupRoute =\n segments.length === 1 &&\n subSegmentPath.filter((seg) => isGroupSegment(seg)).length === 1\n\n if (isRootLayer || isFirstLayerGroupRoute) {\n const accessFallbackTypes = Object.keys(\n defaultHTTPAccessFallbackPaths\n ) as (keyof typeof defaultHTTPAccessFallbackPaths)[]\n for (const type of accessFallbackTypes) {\n const hasRootFallbackFile = await resolver(\n `${appDirPrefix}/${FILE_TYPES[type]}`\n )\n const hasLayerFallbackFile = existedConventionNames.has(type)\n\n // If you already have a root access error fallback, don't insert default access error boundary to group routes root\n if (\n // Is treated as root layout and without boundary\n !(hasRootFallbackFile && isFirstLayerGroupRoute) &&\n // Does not have a fallback boundary file\n !hasLayerFallbackFile\n ) {\n const defaultFallbackPath = defaultHTTPAccessFallbackPaths[type]\n if (!(isDefaultNotFound && type === 'not-found')) {\n definedFilePaths.push([type, defaultFallbackPath])\n }\n }\n }\n }\n\n if (!rootLayout) {\n const layoutPath = definedFilePaths.find(\n ([type]) => type === 'layout'\n )?.[1]\n rootLayout = layoutPath\n\n // When `global-not-found` is disabled, we insert a default layout if\n // root layout is presented. This logic and the default layout will be removed\n // once `global-not-found` is stabilized.\n if (\n !isGlobalNotFoundEnabled &&\n isDefaultNotFound &&\n !layoutPath &&\n !rootLayout\n ) {\n rootLayout = defaultLayoutPath\n definedFilePaths.push(['layout', rootLayout])\n }\n }\n\n let parallelSegmentKey = Array.isArray(parallelSegment)\n ? parallelSegment[0]\n : parallelSegment\n\n // normalize the parallel segment key to remove any special markers that we inserted in the\n // earlier logic (such as children$ and page$). These should never appear in the loader tree, and\n // should instead be the corresponding segment keys (ie `__PAGE__`) or the `children` parallel route.\n parallelSegmentKey =\n parallelSegmentKey === PARALLEL_VIRTUAL_SEGMENT\n ? '(slot)'\n : parallelSegmentKey === PAGE_SEGMENT\n ? PAGE_SEGMENT_KEY\n : parallelSegmentKey\n\n const normalizedParallelKey = normalizeParallelKey(parallelKey)\n let subtreeCode: string | undefined\n // If it's root not found page, set not-found boundary as children page\n if (isNotFoundRoute) {\n if (normalizedParallelKey === 'children') {\n const matchedGlobalNotFound = isGlobalNotFoundEnabled\n ? (definedFilePaths.find(\n ([type]) => type === GLOBAL_NOT_FOUND_FILE_TYPE\n )?.[1] ?? defaultGlobalNotFoundPath)\n : undefined\n\n // If custom global-not-found.js is defined, use global-not-found.js\n if (matchedGlobalNotFound) {\n const varName = `notFound${nestedCollectedDeclarations.length}`\n nestedCollectedDeclarations.push([varName, matchedGlobalNotFound])\n const layoutName = `layout${nestedCollectedDeclarations.length}`\n nestedCollectedDeclarations.push([layoutName, defaultEmptyStubPath])\n subtreeCode = `{\n children: [${JSON.stringify(UNDERSCORE_NOT_FOUND_ROUTE)}, {\n children: ['${PAGE_SEGMENT_KEY}', {}, {\n layout: [\n ${varName},\n ${JSON.stringify(matchedGlobalNotFound)}\n ],\n page: [\n ${layoutName},\n ${JSON.stringify(defaultEmptyStubPath)}\n ]\n }]\n }, {}]\n }`\n } else {\n // If custom not-found.js is found, use it and layout to compose the page,\n // and fallback to built-in not-found component if doesn't exist.\n const notFoundPath =\n definedFilePaths.find(([type]) => type === 'not-found')?.[1] ??\n defaultNotFoundPath\n const varName = `notFound${nestedCollectedDeclarations.length}`\n nestedCollectedDeclarations.push([varName, notFoundPath])\n subtreeCode = `{\n children: [${JSON.stringify(UNDERSCORE_NOT_FOUND_ROUTE.slice(1))}, {\n children: ['${PAGE_SEGMENT_KEY}', {}, {\n page: [\n ${varName},\n ${JSON.stringify(notFoundPath)}\n ]\n }]\n }, {}]\n }`\n }\n }\n }\n\n // If it's app-error route, set app-error as children page\n if (isAppErrorRoute) {\n const varName = `appError${nestedCollectedDeclarations.length}`\n nestedCollectedDeclarations.push([varName, appErrorPath])\n subtreeCode = `{\n children: [${JSON.stringify(UNDERSCORE_GLOBAL_ERROR_ROUTE.slice(1))}, {\n children: ['${PAGE_SEGMENT_KEY}', {}, {\n page: [\n ${varName},\n ${JSON.stringify(appErrorPath)}\n ]\n }]\n }, {}]\n }`\n }\n\n // For 404 route\n // if global-not-found is in definedFilePaths, remove root layout for /_not-found,\n // and change it to global-not-found route.\n // TODO: remove this once global-not-found is stable.\n if (isNotFoundRoute && isGlobalNotFoundEnabled) {\n definedFilePaths = definedFilePaths.filter(\n ([type]) => type !== 'layout'\n )\n\n // Replace the layout to global-not-found\n definedFilePaths.push([\n 'layout',\n definedFilePaths.find(\n ([type]) => type === GLOBAL_NOT_FOUND_FILE_TYPE\n )?.[1] ?? defaultGlobalNotFoundPath,\n ])\n }\n\n if (isAppErrorRoute) {\n definedFilePaths = definedFilePaths.filter(\n ([type]) => type !== 'layout'\n )\n }\n\n const modulesCode = `{\n ${definedFilePaths\n .map(([file, filePath]) => {\n const varName = `module${nestedCollectedDeclarations.length}`\n nestedCollectedDeclarations.push([varName, filePath])\n return `'${file}': [${varName}, ${JSON.stringify(filePath)}],`\n })\n .join('\\n')}\n ${createMetadataExportsCode(metadata)}\n }`\n\n if (!subtreeCode) {\n const { treeCode: pageSubtreeCode } =\n await createSubtreePropsFromSegmentPath(\n subSegmentPath,\n nestedCollectedDeclarations\n )\n\n subtreeCode = pageSubtreeCode\n }\n\n props[normalizedParallelKey] = `[\n '${parallelSegmentKey}',\n ${subtreeCode},\n ${modulesCode}\n ]`\n }\n\n const adjacentParallelSegments =\n await resolveAdjacentParallelSegments(segmentPath)\n\n for (const adjacentParallelSegment of adjacentParallelSegments) {\n if (!props[normalizeParallelKey(adjacentParallelSegment)]) {\n const actualSegment =\n adjacentParallelSegment === 'children'\n ? ''\n : `/${adjacentParallelSegment}`\n\n // Use the default path if it's found, otherwise if it's a children\n // slot, then use the fallback (which triggers a `notFound()`). If this\n // isn't a children slot, then throw an error, as it produces a silent\n // 404 if we'd used the fallback.\n const fullSegmentPath = `${appDirPrefix}${segmentPath}${actualSegment}`\n let defaultPath = await resolver(`${fullSegmentPath}/default`)\n if (!defaultPath) {\n if (adjacentParallelSegment === 'children') {\n defaultPath = PARALLEL_ROUTE_DEFAULT_PATH\n } else {\n // Check if we're inside a catch-all route (i.e., the parallel route is a child\n // of a catch-all segment). Only skip validation if the slot is UNDER a catch-all.\n // For example:\n // /[...catchAll]/@slot - isInsideCatchAll = true (skip validation) ✓\n // /@slot/[...catchAll] - isInsideCatchAll = false (require default) ✓\n // The catch-all provides fallback behavior, so default.js is not required.\n const isInsideCatchAll = segments.some(isCatchAllSegment)\n\n // Check if this is a leaf segment (no child routes).\n // Leaf segments don't need default.js because there are no child routes\n // that could cause the parallel slot to unmatch. For example:\n // /repo-overview/@slot/page with no child routes - isLeafSegment = true (skip validation) ✓\n // /repo-overview/@slot/page with /repo-overview/child/page - isLeafSegment = false (require default) ✓\n // This also handles route groups correctly by filtering them out.\n const isLeafSegment = !hasChildRoutesForSegment(segmentPath)\n\n if (!isInsideCatchAll && !isLeafSegment) {\n // Replace internal webpack alias with user-facing directory name\n const userFacingPath = fullSegmentPath.replace(\n APP_DIR_ALIAS,\n 'app'\n )\n throw new MissingDefaultParallelRouteError(\n userFacingPath,\n adjacentParallelSegment\n )\n }\n defaultPath = PARALLEL_ROUTE_DEFAULT_PATH\n }\n }\n\n const varName = `default${nestedCollectedDeclarations.length}`\n nestedCollectedDeclarations.push([varName, defaultPath])\n props[normalizeParallelKey(adjacentParallelSegment)] = `[\n '${DEFAULT_SEGMENT_KEY}',\n {},\n {\n defaultPage: [${varName}, ${JSON.stringify(defaultPath)}],\n }\n ]`\n }\n }\n return {\n treeCode: `{\n ${Object.entries(props)\n .map(([key, value]) => `${key}: ${value}`)\n .join(',\\n')}\n }`,\n }\n }\n\n const { treeCode } = await createSubtreePropsFromSegmentPath(\n [],\n collectedDeclarations\n )\n\n return {\n treeCode: `${treeCode}.children;`,\n rootLayout,\n globalError,\n globalNotFound,\n }\n}\n\nfunction createAbsolutePath(appDir: string, pathToTurnAbsolute: string) {\n return (\n pathToTurnAbsolute\n // Replace all POSIX path separators with the current OS path separator\n .replace(/\\//g, path.sep)\n .replace(/^private-next-app-dir/, appDir)\n )\n}\n\nconst filesInDirMapMap: WeakMap<\n Compilation,\n Map<string, Promise<Set<string>>>\n> = new WeakMap()\nconst nextAppLoader: AppLoader = async function nextAppLoader() {\n // install native bindings early so they are always available.\n // When run by webpack, next will have already done this, so this will be fast,\n // but if run by turbopack in a subprocess it is required. In that case we cannot pass the\n // `useWasmBinary` flag, but that is ok since turbopack doesn't currently support wasm.\n await installBindings()\n const loaderOptions = this.getOptions()\n const {\n name,\n appDir,\n appPaths,\n pagePath,\n pageExtensions,\n rootDir,\n tsconfigPath,\n isDev,\n nextConfigOutput,\n preferredRegion,\n basePath,\n middlewareConfig: middlewareConfigBase64,\n } = loaderOptions\n\n const isGlobalNotFoundEnabled = !!loaderOptions.isGlobalNotFoundEnabled\n\n // Update FILE_TYPES on the very top-level of the loader\n if (!isGlobalNotFoundEnabled) {\n // @ts-expect-error this delete is only necessary while experimental\n delete FILE_TYPES['global-not-found']\n }\n\n const buildInfo = getModuleBuildInfo((this as any)._module)\n const collectedDeclarations: [string, string][] = []\n const page = name.replace(/^app/, '')\n const middlewareConfig: ProxyConfig = JSON.parse(\n Buffer.from(middlewareConfigBase64, 'base64').toString()\n )\n buildInfo.route = {\n page,\n absolutePagePath: createAbsolutePath(appDir, pagePath),\n preferredRegion,\n middlewareConfig,\n relatedModules: [],\n }\n\n const extensions =\n typeof pageExtensions === 'string'\n ? [pageExtensions]\n : pageExtensions.map((extension) => `.${extension}`)\n\n const normalizedAppPaths =\n typeof appPaths === 'string' ? [appPaths] : appPaths || []\n\n const resolveParallelSegments = (\n pathname: string\n ): [string, string | string[]][] => {\n const matched: Record<string, string | string[]> = {}\n let existingChildrenPath: string | undefined\n for (const appPath of normalizedAppPaths) {\n if (appPath.startsWith(pathname + '/')) {\n const rest = appPath.slice(pathname.length + 1).split('/')\n\n // It is the actual page, mark it specially.\n if (rest.length === 1 && rest[0] === 'page') {\n existingChildrenPath = appPath\n matched.children = PAGE_SEGMENT\n continue\n }\n\n const isParallelRoute = rest[0].startsWith('@')\n if (isParallelRoute) {\n if (rest.length === 2 && rest[1] === 'page') {\n // We found a parallel route at this level. We don't want to mark it explicitly as the page segment,\n // as that should be matched to the `children` slot. Instead, we use an array, to signal to `createSubtreePropsFromSegmentPath`\n // that it needs to recursively fill in the loader tree code for the parallel route at the appropriate levels.\n matched[rest[0]] = [PAGE_SEGMENT]\n continue\n }\n // If it was a parallel route but we weren't able to find the page segment (ie, maybe the page is nested further)\n // we first insert a special marker to ensure that we still process layout/default/etc at the slot level prior to continuing\n // on to the page segment.\n matched[rest[0]] = [PARALLEL_VIRTUAL_SEGMENT, ...rest.slice(1)]\n continue\n }\n\n if (existingChildrenPath && matched.children !== rest[0]) {\n // If we get here, it means we already set a `page` segment earlier in the loop,\n // meaning we already matched a page to the `children` parallel segment.\n const isIncomingParallelPage = appPath.includes('@')\n const hasCurrentParallelPage = existingChildrenPath.includes('@')\n\n if (isIncomingParallelPage) {\n // The duplicate segment was for a parallel slot. In this case,\n // rather than throwing an error, we can ignore it since this can happen for valid reasons.\n // For example, when we attempt to normalize catch-all routes, we'll push potential slot matches so\n // that they are available in the loader tree when we go to render the page.\n // We only need to throw an error if the duplicate segment was for a regular page.\n // For example, /app/(groupa)/page & /app/(groupb)/page is an error since it corresponds\n // with the same path.\n continue\n } else if (!hasCurrentParallelPage && !isIncomingParallelPage) {\n // Both the current `children` and the incoming `children` are regular pages.\n throw new Error(\n `You cannot have two parallel pages that resolve to the same path. Please check ${existingChildrenPath} and ${appPath}. Refer to the route group docs for more information: https://nextjs.org/docs/app/building-your-application/routing/route-groups`\n )\n }\n }\n\n existingChildrenPath = appPath\n matched.children = rest[0]\n }\n }\n\n return Object.entries(matched)\n }\n\n const hasChildRoutesForSegment = (segmentPath: string): boolean => {\n const pathPrefix = segmentPath ? `${segmentPath}/` : ''\n\n for (const appPath of normalizedAppPaths) {\n if (appPath.startsWith(pathPrefix)) {\n const rest = appPath.slice(pathPrefix.length).split('/')\n\n // Filter out route groups to get the actual route segments\n // Route groups (e.g., \"(group)\") don't contribute to the URL path\n const routeSegments = rest.filter((segment) => !isGroupSegment(segment))\n\n // If it's just 'page' at this level, skip (not a child route)\n if (routeSegments.length === 1 && routeSegments[0] === 'page') {\n continue\n }\n\n // If the first segment (after filtering route groups) is a parallel route, skip\n if (routeSegments[0]?.startsWith('@')) {\n continue\n }\n\n // If we have more than just 'page', then there are child routes\n // Examples:\n // ['child', 'page'] -> true (has child route)\n // ['page'] -> false (already filtered above)\n // ['grandchild', 'deeper', 'page'] -> true (has nested child routes)\n if (\n routeSegments.length > 1 ||\n (routeSegments.length === 1 && routeSegments[0] !== 'page')\n ) {\n return true\n }\n }\n }\n\n return false\n }\n\n const resolveDir: DirResolver = (pathToResolve) => {\n return createAbsolutePath(appDir, pathToResolve)\n }\n\n const resolveAppRoute: PathResolver = (pathToResolve) => {\n return createAbsolutePath(appDir, pathToResolve)\n }\n\n // Cached checker to see if a file exists in a given directory.\n // This can be more efficient than checking them with `fs.stat` one by one\n // because all the thousands of files are likely in a few possible directories.\n // Note that it should only be cached for this compilation, not globally.\n const fileExistsInDirectory = async (dirname: string, fileName: string) => {\n // I don't think we should ever hit this code path, but if we do we should handle it gracefully.\n if (this._compilation === undefined) {\n try {\n return (await getFilesInDir(dirname).catch(() => new Set())).has(\n fileName\n )\n } catch (e) {\n return false\n }\n }\n const map =\n filesInDirMapMap.get(this._compilation) ||\n new Map<string, Promise<Set<string>>>()\n if (!filesInDirMapMap.has(this._compilation)) {\n filesInDirMapMap.set(this._compilation, map)\n }\n if (!map.has(dirname)) {\n map.set(\n dirname,\n getFilesInDir(dirname).catch(() => new Set())\n )\n }\n return ((await map.get(dirname)) || new Set()).has(fileName)\n }\n\n const resolver: PathResolver = async (pathname) => {\n const absolutePath = createAbsolutePath(appDir, pathname)\n\n const filenameIndex = absolutePath.lastIndexOf(path.sep)\n const dirname = absolutePath.slice(0, filenameIndex)\n const filename = absolutePath.slice(filenameIndex + 1)\n\n let result: string | undefined\n\n for (const ext of extensions) {\n const absolutePathWithExtension = `${absolutePath}${ext}`\n if (\n !result &&\n (await fileExistsInDirectory(dirname, `${filename}${ext}`))\n ) {\n result = absolutePathWithExtension\n }\n // Call `addMissingDependency` for all files even if they didn't match,\n // because they might be added or removed during development.\n this.addMissingDependency(absolutePathWithExtension)\n }\n\n return result\n }\n\n const metadataResolver: MetadataResolver = async (\n dirname,\n filename,\n exts\n ) => {\n const absoluteDir = createAbsolutePath(appDir, dirname)\n\n let result: string | undefined\n\n for (const ext of exts) {\n // Compared to `resolver` above the exts do not have the `.` included already, so it's added here.\n const filenameWithExt = `${filename}.${ext}`\n const absolutePathWithExtension = `${absoluteDir}${path.sep}${filenameWithExt}`\n if (!result && (await fileExistsInDirectory(dirname, filenameWithExt))) {\n result = absolutePathWithExtension\n }\n // Call `addMissingDependency` for all files even if they didn't match,\n // because they might be added or removed during development.\n this.addMissingDependency(absolutePathWithExtension)\n }\n\n return result\n }\n\n if (isAppRouteRoute(name)) {\n return createAppRouteCode({\n appDir,\n // TODO: investigate if the local `page` is the same as the loaderOptions.page\n page: loaderOptions.page,\n name,\n pagePath,\n resolveAppRoute,\n pageExtensions,\n nextConfigOutput,\n })\n }\n\n let treeCodeResult = await createTreeCodeFromPath(pagePath, {\n page,\n resolveDir,\n resolver,\n metadataResolver,\n resolveParallelSegments,\n hasChildRoutesForSegment,\n loaderContext: this,\n pageExtensions,\n basePath,\n collectedDeclarations,\n isGlobalNotFoundEnabled,\n })\n\n const isGlobalNotFoundPath =\n page === UNDERSCORE_NOT_FOUND_ROUTE_ENTRY &&\n !!treeCodeResult.globalNotFound &&\n isGlobalNotFoundEnabled\n\n const isAppErrorRoute = page === UNDERSCORE_GLOBAL_ERROR_ROUTE_ENTRY\n\n if (!treeCodeResult.rootLayout && !isGlobalNotFoundPath && !isAppErrorRoute) {\n if (!isDev) {\n // If we're building and missing a root layout, exit the build\n Log.error(\n `${bold(\n pagePath.replace(`${APP_DIR_ALIAS}/`, '')\n )} doesn't have a root layout. To fix this error, make sure every page has a root layout.`\n )\n process.exit(1)\n } else {\n // In dev we'll try to create a root layout\n const [createdRootLayout, rootLayoutPath] = await verifyRootLayout({\n appDir: appDir,\n dir: rootDir!,\n tsconfigPath: tsconfigPath,\n pagePath,\n pageExtensions,\n })\n if (!createdRootLayout) {\n let message = `${bold(\n pagePath.replace(`${APP_DIR_ALIAS}/`, '')\n )} doesn't have a root layout. `\n\n if (rootLayoutPath) {\n message += `We tried to create ${bold(\n path.relative(this._compiler?.context ?? '', rootLayoutPath)\n )} for you but something went wrong.`\n } else {\n message +=\n 'To fix this error, make sure every page has a root layout.'\n }\n\n throw new Error(message)\n }\n\n // Clear fs cache, get the new result with the created root layout.\n if (this._compilation) filesInDirMapMap.get(this._compilation)?.clear()\n treeCodeResult = await createTreeCodeFromPath(pagePath, {\n page,\n resolveDir,\n resolver,\n metadataResolver,\n resolveParallelSegments,\n hasChildRoutesForSegment,\n loaderContext: this,\n pageExtensions,\n basePath,\n collectedDeclarations,\n isGlobalNotFoundEnabled,\n })\n }\n }\n\n const pathname = new AppPathnameNormalizer().normalize(page)\n\n // Prefer to modify next/src/server/app-render/entry-base.ts since this is shared with Turbopack.\n // Any changes to this code should be reflected in Turbopack's app_source.rs and/or app-renderer.tsx as well.\n const code = await loadEntrypoint(\n 'app-page',\n {\n VAR_DEFINITION_PAGE: page,\n VAR_DEFINITION_PATHNAME: pathname,\n VAR_MODULE_GLOBAL_ERROR: treeCodeResult.globalError,\n },\n {\n tree: treeCodeResult.treeCode,\n __next_app_require__: '__webpack_require__',\n // all modules are in the entry chunk, so we never actually need to load chunks in webpack\n __next_app_load_chunk__: '() => Promise.resolve()',\n }\n )\n\n // Lazily evaluate the imported modules in the generated code\n const header = collectedDeclarations\n .map(([varName, modulePath]) => {\n return `const ${varName} = () => import(/* webpackMode: \"eager\" */ ${JSON.stringify(\n modulePath\n )});\\n`\n })\n .join('')\n\n return header + code\n}\n\nexport default nextAppLoader\n"],"names":["HTTP_ACCESS_FALLBACKS","forbidden","unauthorized","defaultHTTPAccessFallbackPaths","FILE_TYPES","layout","template","error","loading","GLOBAL_ERROR_FILE_TYPE","GLOBAL_NOT_FOUND_FILE_TYPE","PAGE_SEGMENT","PARALLEL_VIRTUAL_SEGMENT","defaultGlobalErrorPath","defaultNotFoundPath","defaultEmptyStubPath","defaultLayoutPath","defaultGlobalNotFoundPath","appErrorPath","normalizeParallelKey","key","startsWith","slice","isCatchAllSegment","segment","isDirectory","pathname","stat","fs","err","createTreeCodeFromPath","pagePath","page","resolveDir","resolver","resolveParallelSegments","hasChildRoutesForSegment","metadataResolver","pageExtensions","basePath","collectedDeclarations","isGlobalNotFoundEnabled","splittedPath","split","isNotFoundRoute","UNDERSCORE_NOT_FOUND_ROUTE_ENTRY","isAppErrorRoute","UNDERSCORE_GLOBAL_ERROR_ROUTE_ENTRY","isDefaultNotFound","isAppBuiltinPage","appDirPrefix","APP_DIR_ALIAS","rootLayout","globalError","globalNotFound","resolveAdjacentParallelSegments","segmentPath","absoluteSegmentPath","segmentIsDirectory","files","opendir","parallelSegments","dirent","name","charCodeAt","push","createSubtreePropsFromSegmentPath","segments","nestedCollectedDeclarations","join","props","isRootLayer","length","isRootLayoutOrRootPage","metadata","routerDirPath","resolvedRouteDir","normalizePathSep","endsWith","createStaticMetadataFromRoute","parallelKey","parallelSegment","matchedPagePath","resolvedPagePath","varName","PAGE_SEGMENT_KEY","JSON","stringify","createMetadataExportsCode","Error","subSegmentPath","normalizedParallelSegment","Array","isArray","parallelSegmentPath","filePathEntries","Promise","all","Object","values","map","file","filePaths","Map","resolvedGlobalErrorPath","set","resolvedGlobalNotFoundPath","definedFilePaths","from","entries","filter","filePath","undefined","existedConventionNames","Set","type","isFirstLayerGroupRoute","seg","isGroupSegment","accessFallbackTypes","keys","hasRootFallbackFile","hasLayerFallbackFile","has","defaultFallbackPath","layoutPath","find","parallelSegmentKey","normalizedParallelKey","subtreeCode","matchedGlobalNotFound","layoutName","UNDERSCORE_NOT_FOUND_ROUTE","notFoundPath","UNDERSCORE_GLOBAL_ERROR_ROUTE","modulesCode","treeCode","pageSubtreeCode","adjacentParallelSegments","adjacentParallelSegment","actualSegment","fullSegmentPath","defaultPath","PARALLEL_ROUTE_DEFAULT_PATH","isInsideCatchAll","some","isLeafSegment","userFacingPath","replace","MissingDefaultParallelRouteError","DEFAULT_SEGMENT_KEY","value","createAbsolutePath","appDir","pathToTurnAbsolute","path","sep","filesInDirMapMap","WeakMap","nextAppLoader","installBindings","loaderOptions","getOptions","appPaths","rootDir","tsconfigPath","isDev","nextConfigOutput","preferredRegion","middlewareConfig","middlewareConfigBase64","buildInfo","getModuleBuildInfo","_module","parse","Buffer","toString","route","absolutePagePath","relatedModules","extensions","extension","normalizedAppPaths","matched","existingChildrenPath","appPath","rest","children","isParallelRoute","isIncomingParallelPage","includes","hasCurrentParallelPage","pathPrefix","routeSegments","pathToResolve","resolveAppRoute","fileExistsInDirectory","dirname","fileName","_compilation","getFilesInDir","catch","e","get","absolutePath","filenameIndex","lastIndexOf","filename","result","ext","absolutePathWithExtension","addMissingDependency","exts","absoluteDir","filenameWithExt","isAppRouteRoute","createAppRouteCode","treeCodeResult","loaderContext","isGlobalNotFoundPath","Log","bold","process","exit","createdRootLayout","rootLayoutPath","verifyRootLayout","dir","message","relative","_compiler","context","clear","AppPathnameNormalizer","normalize","code","loadEntrypoint","VAR_DEFINITION_PAGE","VAR_DEFINITION_PATHNAME","VAR_MODULE_GLOBAL_ERROR","tree","__next_app_require__","__next_app_load_chunk__","header","modulePath"],"mappings":";;;;+BAq+BA;;;eAAA;;;2BAh+BO;gCAIA;6DAGU;4BACI;oCACc;kCACF;6DACZ;4BACS;0BAIvB;oBACwB;iCACC;uCAEM;uBAEL;gCACF;yBAKxB;+BACuB;yBAEc;oCAET;kDACc;kCA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AE1C,wBAAAA,iBAAiB8C,GAAG,CAAC,IAAI,CAACJ,YAAY,sBAAtC1C,sBAAyC2E,KAAK;YACrEf,iBAAiB,MAAM3L,uBAAuBC,UAAU;gBACtDC;gBACAC;gBACAC;gBACAG;gBACAF;gBACAC;gBACAsL,eAAe,IAAI;gBACnBpL;gBACAC;gBACAC;gBACAC;YACF;QACF;IACF;IAEA,MAAMf,WAAW,IAAI+M,4CAAqB,GAAGC,SAAS,CAAC1M;IAEvD,iGAAiG;IACjG,6GAA6G;IAC7G,MAAM2M,OAAO,MAAMC,IAAAA,8BAAc,EAC/B,YACA;QACEC,qBAAqB7M;QACrB8M,yBAAyBpN;QACzBqN,yBAAyBtB,eAAepK,WAAW;IACrD,GACA;QACE2L,MAAMvB,eAAejF,QAAQ;QAC7ByG,sBAAsB;QACtB,0FAA0F;QAC1FC,yBAAyB;IAC3B;IAGF,6DAA6D;IAC7D,MAAMC,SAAS3M,sBACZ4D,GAAG,CAAC,CAAC,CAAChB,SAASgK,WAAW;QACzB,OAAO,CAAC,MAAM,EAAEhK,QAAQ,2CAA2C,EAAEE,KAAKC,SAAS,CACjF6J,YACA,IAAI,CAAC;IACT,GACC/K,IAAI,CAAC;IAER,OAAO8K,SAASR;AAClB;MAEA,YAAe5E","ignoreList":[0]}
@@ -94,6 +94,7 @@ Object.defineProperty(exports, "default", {
94
94
  });
95
95
  const _path = /*#__PURE__*/ _interop_require_default(require("path"));
96
96
  const _swc = require("../../swc");
97
+ const _installbindings = require("../../swc/install-bindings");
97
98
  function _interop_require_default(obj) {
98
99
  return obj && obj.__esModule ? obj : {
99
100
  default: obj
@@ -194,6 +195,10 @@ async function getBarrelMapping(resourcePath, swcCacheDir, resolve, fs) {
194
195
  const NextBarrelLoader = async function() {
195
196
  this.async();
196
197
  this.cacheable(true);
198
+ // Install bindings early so they are definitely available.
199
+ // When run by webpack in next this is already done with correct configuration so this is a no-op.
200
+ // In turbopack loaders are run in a subprocess so it may or may not be done.
201
+ await (0, _installbindings.installBindings)();
197
202
  const { names, swcCacheDir } = this.getOptions();
198
203
  // For barrel optimizations, we always prefer the "module" field over the
199
204
  // "main" field because ESM handling is more robust with better tree-shaking.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/build/webpack/loaders/next-barrel-loader.ts"],"sourcesContent":["/**\n * ## Barrel Optimizations\n *\n * This loader is used to optimize the imports of \"barrel\" files that have many\n * re-exports. Currently, both Node.js and Webpack have to enter all of these\n * submodules even if we only need a few of them.\n *\n * For example, say a file `foo.js` with the following contents:\n *\n * export { a } from './a'\n * export { b } from './b'\n * export { c } from './c'\n * ...\n *\n * If the user imports `a` only, this loader will accept the `names` option to\n * be `['a']`. Then, it request the \"__barrel_transform__\" SWC transform to load\n * `foo.js` and receive the following output:\n *\n * export const __next_private_export_map__ = '[[\"a\",\"./a\",\"a\"],[\"b\",\"./b\",\"b\"],[\"c\",\"./c\",\"c\"],...]'\n *\n * format: '[\"<imported identifier>\", \"<import path>\", \"<exported name>\"]'\n * e.g.: import { a as b } from './module-a' => '[\"b\", \"./module-a\", \"a\"]'\n *\n * The export map, generated by SWC, is a JSON that represents the exports of\n * that module, their original file, and their original name (since you can do\n * `export { a as b }`).\n *\n * Then, this loader can safely remove all the exports that are not needed and\n * re-export the ones from `names`:\n *\n * export { a } from './a'\n *\n * That's the basic situation and also the happy path.\n *\n *\n *\n * ## Wildcard Exports\n *\n * For wildcard exports (e.g. `export * from './a'`), it becomes a bit more complicated.\n * Say `foo.js` with the following contents:\n *\n * export * from './a'\n * export * from './b'\n * export * from './c'\n * ...\n *\n * If the user imports `bar` from it, SWC can never know which files are going to be\n * exporting `bar`. So, we have to keep all the wildcard exports and do the same\n * process recursively. This loader will return the following output:\n *\n * export * from '__barrel_optimize__?names=bar&wildcard!=!./a'\n * export * from '__barrel_optimize__?names=bar&wildcard!=!./b'\n * export * from '__barrel_optimize__?names=bar&wildcard!=!./c'\n * ...\n *\n * The \"!=!\" tells Webpack to use the same loader to process './a', './b', and './c'.\n * After the recursive process, the \"inner loaders\" will either return an empty string\n * or:\n *\n * export * from './target'\n *\n * Where `target` is the file that exports `bar`.\n *\n *\n *\n * ## Non-Barrel Files\n *\n * If the file is not a barrel, we can't apply any optimizations. That's because\n * we can't easily remove things from the file. For example, say `foo.js` with:\n *\n * const v = 1\n * export function b () {\n * return v\n * }\n *\n * If the user imports `b` only, we can't remove the `const v = 1` even though\n * the file is side-effect free. In these caes, this loader will simply re-export\n * `foo.js`:\n *\n * export * from './foo'\n *\n * Besides these cases, this loader also carefully handles the module cache so\n * SWC won't analyze the same file twice, and no instance of the same file will\n * be accidentally created as different instances.\n */\n\nimport type webpack from 'webpack'\n\nimport path from 'path'\nimport { transform } from '../../swc'\n\n// This is a in-memory cache for the mapping of barrel exports. This only applies\n// to the packages that we optimize. It will never change (e.g. upgrading packages)\n// during the lifetime of the server so we can safely cache it.\n// There is also no need to collect the cache for the same reason.\nconst barrelTransformMappingCache = new Map<\n string,\n {\n exportList: [string, string, string][]\n wildcardExports: string[]\n isClientEntry: boolean\n } | null\n>()\n\nasync function getBarrelMapping(\n resourcePath: string,\n swcCacheDir: string,\n resolve: (context: string, request: string) => Promise<string>,\n fs: {\n readFile: (\n path: string,\n callback: (err: any, data: string | Buffer | undefined) => void\n ) => void\n }\n) {\n if (barrelTransformMappingCache.has(resourcePath)) {\n return barrelTransformMappingCache.get(resourcePath)!\n }\n\n // This is a SWC transform specifically for `optimizeBarrelExports`. We don't\n // care about other things but the export map only.\n async function transpileSource(\n filename: string,\n source: string,\n isWildcard: boolean\n ) {\n const isTypeScript = filename.endsWith('.ts') || filename.endsWith('.tsx')\n return new Promise<string>((res) =>\n transform(source, {\n filename,\n inputSourceMap: undefined,\n sourceFileName: filename,\n optimizeBarrelExports: {\n wildcard: isWildcard,\n },\n jsc: {\n parser: {\n syntax: isTypeScript ? 'typescript' : 'ecmascript',\n [isTypeScript ? 'tsx' : 'jsx']: true,\n },\n experimental: {\n cacheRoot: swcCacheDir,\n },\n },\n }).then((output) => {\n res(output.code)\n })\n )\n }\n\n // Avoid circular `export *` dependencies\n const visited = new Set<string>()\n async function getMatches(\n file: string,\n isWildcard: boolean,\n isClientEntry: boolean\n ) {\n if (visited.has(file)) {\n return null\n }\n visited.add(file)\n\n const source = await new Promise<string>((res, rej) => {\n fs.readFile(file, (err, data) => {\n if (err || data === undefined) {\n rej(err)\n } else {\n res(data.toString())\n }\n })\n })\n\n const output = await transpileSource(file, source, isWildcard)\n\n const matches = output.match(\n /^([^]*)export (const|var) __next_private_export_map__ = ('[^']+'|\"[^\"]+\")/\n )\n if (!matches) {\n return null\n }\n\n const matchedDirectives = output.match(\n /^([^]*)export (const|var) __next_private_directive_list__ = '([^']+)'/\n )\n const directiveList = matchedDirectives\n ? JSON.parse(matchedDirectives[3])\n : []\n // \"use client\" in barrel files has to be transferred to the target file.\n isClientEntry = directiveList.includes('use client')\n\n let exportList = JSON.parse(matches[3].slice(1, -1)) as [\n string,\n string,\n string,\n ][]\n const wildcardExports = [\n ...output.matchAll(/export \\* from \"([^\"]+)\"/g),\n ].map((match) => match[1])\n\n // In the wildcard case, if the value is exported from another file, we\n // redirect to that file (decl[0]). Otherwise, export from the current\n // file itself.\n if (isWildcard) {\n for (const decl of exportList) {\n decl[1] = file\n decl[2] = decl[0]\n }\n }\n\n // This recursively handles the wildcard exports (e.g. `export * from './a'`)\n if (wildcardExports.length) {\n await Promise.all(\n wildcardExports.map(async (req) => {\n const targetPath = await resolve(\n path.dirname(file),\n req.replace('__barrel_optimize__?names=__PLACEHOLDER__!=!', '')\n )\n\n const targetMatches = await getMatches(\n targetPath,\n true,\n isClientEntry\n )\n\n if (targetMatches) {\n // Merge the export list\n exportList = exportList.concat(targetMatches.exportList)\n }\n })\n )\n }\n\n return {\n exportList,\n wildcardExports,\n isClientEntry,\n }\n }\n\n const res = await getMatches(resourcePath, false, false)\n barrelTransformMappingCache.set(resourcePath, res)\n\n return res\n}\n\nconst NextBarrelLoader = async function (\n this: webpack.LoaderContext<{\n names: string[]\n swcCacheDir: string\n }>\n) {\n this.async()\n this.cacheable(true)\n\n const { names, swcCacheDir } = this.getOptions()\n\n // For barrel optimizations, we always prefer the \"module\" field over the\n // \"main\" field because ESM handling is more robust with better tree-shaking.\n const resolve = this.getResolve({\n mainFields: ['module', 'main'],\n })\n\n const mapping = await getBarrelMapping(\n this.resourcePath,\n swcCacheDir,\n resolve,\n this.fs\n )\n\n // `resolve` adds all sub-paths to the dependency graph. However, we already\n // cached the mapping and we assume them to not change. So, we can safely\n // clear the dependencies here to avoid unnecessary watchers which turned out\n // to be very expensive.\n this.clearDependencies()\n\n if (!mapping) {\n // This file isn't a barrel and we can't apply any optimizations. Let's re-export everything.\n // Since this loader accepts `names` and the request is keyed with `names`, we can't simply\n // return the original source here. That will create these imports with different names as\n // different modules instances.\n this.callback(null, `export * from ${JSON.stringify(this.resourcePath)}`)\n return\n }\n\n const exportList = mapping.exportList\n const isClientEntry = mapping.isClientEntry\n const exportMap = new Map<string, [string, string]>()\n for (const [name, filePath, orig] of exportList) {\n exportMap.set(name, [filePath, orig])\n }\n\n let output = ''\n let missedNames: string[] = []\n for (const name of names) {\n // If the name matches\n if (exportMap.has(name)) {\n const decl = exportMap.get(name)!\n\n if (decl[1] === '*') {\n output += `\\nexport * as ${name} from ${JSON.stringify(decl[0])}`\n } else if (decl[1] === 'default') {\n output += `\\nexport { default as ${name} } from ${JSON.stringify(\n decl[0]\n )}`\n } else if (decl[1] === name) {\n output += `\\nexport { ${name} } from ${JSON.stringify(decl[0])}`\n } else {\n output += `\\nexport { ${decl[1]} as ${name} } from ${JSON.stringify(\n decl[0]\n )}`\n }\n } else {\n missedNames.push(name)\n }\n }\n\n // These are from wildcard exports.\n if (missedNames.length > 0) {\n for (const req of mapping.wildcardExports) {\n output += `\\nexport * from ${JSON.stringify(\n req.replace('__PLACEHOLDER__', missedNames.join(',') + '&wildcard')\n )}`\n }\n }\n\n // When it has `\"use client\"` inherited from its barrel files, we need to\n // prefix it to this target file as well.\n if (isClientEntry) {\n output = `\"use client\";\\n${output}`\n }\n\n this.callback(null, output)\n}\n\nexport default NextBarrelLoader\n"],"names":["barrelTransformMappingCache","Map","getBarrelMapping","resourcePath","swcCacheDir","resolve","fs","has","get","transpileSource","filename","source","isWildcard","isTypeScript","endsWith","Promise","res","transform","inputSourceMap","undefined","sourceFileName","optimizeBarrelExports","wildcard","jsc","parser","syntax","experimental","cacheRoot","then","output","code","visited","Set","getMatches","file","isClientEntry","add","rej","readFile","err","data","toString","matches","match","matchedDirectives","directiveList","JSON","parse","includes","exportList","slice","wildcardExports","matchAll","map","decl","length","all","req","targetPath","path","dirname","replace","targetMatches","concat","set","NextBarrelLoader","async","cacheable","names","getOptions","getResolve","mainFields","mapping","clearDependencies","callback","stringify","exportMap","name","filePath","orig","missedNames","push","join"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoFC;;;;+BA0PD;;;eAAA;;;6DAtPiB;qBACS;;;;;;AAE1B,iFAAiF;AACjF,mFAAmF;AACnF,+DAA+D;AAC/D,kEAAkE;AAClE,MAAMA,8BAA8B,IAAIC;AASxC,eAAeC,iBACbC,YAAoB,EACpBC,WAAmB,EACnBC,OAA8D,EAC9DC,EAKC;IAED,IAAIN,4BAA4BO,GAAG,CAACJ,eAAe;QACjD,OAAOH,4BAA4BQ,GAAG,CAACL;IACzC;IAEA,6EAA6E;IAC7E,mDAAmD;IACnD,eAAeM,gBACbC,QAAgB,EAChBC,MAAc,EACdC,UAAmB;QAEnB,MAAMC,eAAeH,SAASI,QAAQ,CAAC,UAAUJ,SAASI,QAAQ,CAAC;QACnE,OAAO,IAAIC,QAAgB,CAACC,MAC1BC,IAAAA,cAAS,EAACN,QAAQ;gBAChBD;gBACAQ,gBAAgBC;gBAChBC,gBAAgBV;gBAChBW,uBAAuB;oBACrBC,UAAUV;gBACZ;gBACAW,KAAK;oBACHC,QA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,OAAO,CAAC,mBAAmBmB,YAAYE,IAAI,CAAC,OAAO,eACtD;QACL;IACF;IAEA,yEAAyE;IACzE,yCAAyC;IACzC,IAAI/C,eAAe;QACjBN,SAAS,CAAC,eAAe,EAAEA,QAAQ;IACrC;IAEA,IAAI,CAAC6C,QAAQ,CAAC,MAAM7C;AACtB;MAEA,WAAeoC","ignoreList":[0]}
1
+ {"version":3,"sources":["../../../../src/build/webpack/loaders/next-barrel-loader.ts"],"sourcesContent":["/**\n * ## Barrel Optimizations\n *\n * This loader is used to optimize the imports of \"barrel\" files that have many\n * re-exports. Currently, both Node.js and Webpack have to enter all of these\n * submodules even if we only need a few of them.\n *\n * For example, say a file `foo.js` with the following contents:\n *\n * export { a } from './a'\n * export { b } from './b'\n * export { c } from './c'\n * ...\n *\n * If the user imports `a` only, this loader will accept the `names` option to\n * be `['a']`. Then, it request the \"__barrel_transform__\" SWC transform to load\n * `foo.js` and receive the following output:\n *\n * export const __next_private_export_map__ = '[[\"a\",\"./a\",\"a\"],[\"b\",\"./b\",\"b\"],[\"c\",\"./c\",\"c\"],...]'\n *\n * format: '[\"<imported identifier>\", \"<import path>\", \"<exported name>\"]'\n * e.g.: import { a as b } from './module-a' => '[\"b\", \"./module-a\", \"a\"]'\n *\n * The export map, generated by SWC, is a JSON that represents the exports of\n * that module, their original file, and their original name (since you can do\n * `export { a as b }`).\n *\n * Then, this loader can safely remove all the exports that are not needed and\n * re-export the ones from `names`:\n *\n * export { a } from './a'\n *\n * That's the basic situation and also the happy path.\n *\n *\n *\n * ## Wildcard Exports\n *\n * For wildcard exports (e.g. `export * from './a'`), it becomes a bit more complicated.\n * Say `foo.js` with the following contents:\n *\n * export * from './a'\n * export * from './b'\n * export * from './c'\n * ...\n *\n * If the user imports `bar` from it, SWC can never know which files are going to be\n * exporting `bar`. So, we have to keep all the wildcard exports and do the same\n * process recursively. This loader will return the following output:\n *\n * export * from '__barrel_optimize__?names=bar&wildcard!=!./a'\n * export * from '__barrel_optimize__?names=bar&wildcard!=!./b'\n * export * from '__barrel_optimize__?names=bar&wildcard!=!./c'\n * ...\n *\n * The \"!=!\" tells Webpack to use the same loader to process './a', './b', and './c'.\n * After the recursive process, the \"inner loaders\" will either return an empty string\n * or:\n *\n * export * from './target'\n *\n * Where `target` is the file that exports `bar`.\n *\n *\n *\n * ## Non-Barrel Files\n *\n * If the file is not a barrel, we can't apply any optimizations. That's because\n * we can't easily remove things from the file. For example, say `foo.js` with:\n *\n * const v = 1\n * export function b () {\n * return v\n * }\n *\n * If the user imports `b` only, we can't remove the `const v = 1` even though\n * the file is side-effect free. In these caes, this loader will simply re-export\n * `foo.js`:\n *\n * export * from './foo'\n *\n * Besides these cases, this loader also carefully handles the module cache so\n * SWC won't analyze the same file twice, and no instance of the same file will\n * be accidentally created as different instances.\n */\n\nimport type webpack from 'webpack'\n\nimport path from 'path'\nimport { transform } from '../../swc'\nimport { installBindings } from '../../swc/install-bindings'\n\n// This is a in-memory cache for the mapping of barrel exports. This only applies\n// to the packages that we optimize. It will never change (e.g. upgrading packages)\n// during the lifetime of the server so we can safely cache it.\n// There is also no need to collect the cache for the same reason.\nconst barrelTransformMappingCache = new Map<\n string,\n {\n exportList: [string, string, string][]\n wildcardExports: string[]\n isClientEntry: boolean\n } | null\n>()\n\nasync function getBarrelMapping(\n resourcePath: string,\n swcCacheDir: string,\n resolve: (context: string, request: string) => Promise<string>,\n fs: {\n readFile: (\n path: string,\n callback: (err: any, data: string | Buffer | undefined) => void\n ) => void\n }\n) {\n if (barrelTransformMappingCache.has(resourcePath)) {\n return barrelTransformMappingCache.get(resourcePath)!\n }\n\n // This is a SWC transform specifically for `optimizeBarrelExports`. We don't\n // care about other things but the export map only.\n async function transpileSource(\n filename: string,\n source: string,\n isWildcard: boolean\n ) {\n const isTypeScript = filename.endsWith('.ts') || filename.endsWith('.tsx')\n return new Promise<string>((res) =>\n transform(source, {\n filename,\n inputSourceMap: undefined,\n sourceFileName: filename,\n optimizeBarrelExports: {\n wildcard: isWildcard,\n },\n jsc: {\n parser: {\n syntax: isTypeScript ? 'typescript' : 'ecmascript',\n [isTypeScript ? 'tsx' : 'jsx']: true,\n },\n experimental: {\n cacheRoot: swcCacheDir,\n },\n },\n }).then((output) => {\n res(output.code)\n })\n )\n }\n\n // Avoid circular `export *` dependencies\n const visited = new Set<string>()\n async function getMatches(\n file: string,\n isWildcard: boolean,\n isClientEntry: boolean\n ) {\n if (visited.has(file)) {\n return null\n }\n visited.add(file)\n\n const source = await new Promise<string>((res, rej) => {\n fs.readFile(file, (err, data) => {\n if (err || data === undefined) {\n rej(err)\n } else {\n res(data.toString())\n }\n })\n })\n\n const output = await transpileSource(file, source, isWildcard)\n\n const matches = output.match(\n /^([^]*)export (const|var) __next_private_export_map__ = ('[^']+'|\"[^\"]+\")/\n )\n if (!matches) {\n return null\n }\n\n const matchedDirectives = output.match(\n /^([^]*)export (const|var) __next_private_directive_list__ = '([^']+)'/\n )\n const directiveList = matchedDirectives\n ? JSON.parse(matchedDirectives[3])\n : []\n // \"use client\" in barrel files has to be transferred to the target file.\n isClientEntry = directiveList.includes('use client')\n\n let exportList = JSON.parse(matches[3].slice(1, -1)) as [\n string,\n string,\n string,\n ][]\n const wildcardExports = [\n ...output.matchAll(/export \\* from \"([^\"]+)\"/g),\n ].map((match) => match[1])\n\n // In the wildcard case, if the value is exported from another file, we\n // redirect to that file (decl[0]). Otherwise, export from the current\n // file itself.\n if (isWildcard) {\n for (const decl of exportList) {\n decl[1] = file\n decl[2] = decl[0]\n }\n }\n\n // This recursively handles the wildcard exports (e.g. `export * from './a'`)\n if (wildcardExports.length) {\n await Promise.all(\n wildcardExports.map(async (req) => {\n const targetPath = await resolve(\n path.dirname(file),\n req.replace('__barrel_optimize__?names=__PLACEHOLDER__!=!', '')\n )\n\n const targetMatches = await getMatches(\n targetPath,\n true,\n isClientEntry\n )\n\n if (targetMatches) {\n // Merge the export list\n exportList = exportList.concat(targetMatches.exportList)\n }\n })\n )\n }\n\n return {\n exportList,\n wildcardExports,\n isClientEntry,\n }\n }\n\n const res = await getMatches(resourcePath, false, false)\n barrelTransformMappingCache.set(resourcePath, res)\n\n return res\n}\n\nconst NextBarrelLoader = async function (\n this: webpack.LoaderContext<{\n names: string[]\n swcCacheDir: string\n }>\n) {\n this.async()\n this.cacheable(true)\n // Install bindings early so they are definitely available.\n // When run by webpack in next this is already done with correct configuration so this is a no-op.\n // In turbopack loaders are run in a subprocess so it may or may not be done.\n await installBindings()\n\n const { names, swcCacheDir } = this.getOptions()\n\n // For barrel optimizations, we always prefer the \"module\" field over the\n // \"main\" field because ESM handling is more robust with better tree-shaking.\n const resolve = this.getResolve({\n mainFields: ['module', 'main'],\n })\n\n const mapping = await getBarrelMapping(\n this.resourcePath,\n swcCacheDir,\n resolve,\n this.fs\n )\n\n // `resolve` adds all sub-paths to the dependency graph. However, we already\n // cached the mapping and we assume them to not change. So, we can safely\n // clear the dependencies here to avoid unnecessary watchers which turned out\n // to be very expensive.\n this.clearDependencies()\n\n if (!mapping) {\n // This file isn't a barrel and we can't apply any optimizations. Let's re-export everything.\n // Since this loader accepts `names` and the request is keyed with `names`, we can't simply\n // return the original source here. That will create these imports with different names as\n // different modules instances.\n this.callback(null, `export * from ${JSON.stringify(this.resourcePath)}`)\n return\n }\n\n const exportList = mapping.exportList\n const isClientEntry = mapping.isClientEntry\n const exportMap = new Map<string, [string, string]>()\n for (const [name, filePath, orig] of exportList) {\n exportMap.set(name, [filePath, orig])\n }\n\n let output = ''\n let missedNames: string[] = []\n for (const name of names) {\n // If the name matches\n if (exportMap.has(name)) {\n const decl = exportMap.get(name)!\n\n if (decl[1] === '*') {\n output += `\\nexport * as ${name} from ${JSON.stringify(decl[0])}`\n } else if (decl[1] === 'default') {\n output += `\\nexport { default as ${name} } from ${JSON.stringify(\n decl[0]\n )}`\n } else if (decl[1] === name) {\n output += `\\nexport { ${name} } from ${JSON.stringify(decl[0])}`\n } else {\n output += `\\nexport { ${decl[1]} as ${name} } from ${JSON.stringify(\n decl[0]\n )}`\n }\n } else {\n missedNames.push(name)\n }\n }\n\n // These are from wildcard exports.\n if (missedNames.length > 0) {\n for (const req of mapping.wildcardExports) {\n output += `\\nexport * from ${JSON.stringify(\n req.replace('__PLACEHOLDER__', missedNames.join(',') + '&wildcard')\n )}`\n }\n }\n\n // When it has `\"use client\"` inherited from its barrel files, we need to\n // prefix it to this target file as well.\n if (isClientEntry) {\n output = `\"use client\";\\n${output}`\n }\n\n this.callback(null, output)\n}\n\nexport default NextBarrelLoader\n"],"names":["barrelTransformMappingCache","Map","getBarrelMapping","resourcePath","swcCacheDir","resolve","fs","has","get","transpileSource","filename","source","isWildcard","isTypeScript","endsWith","Promise","res","transform","inputSourceMap","undefined","sourceFileName","optimizeBarrelExports","wildcard","jsc","parser","syntax","experimental","cacheRoot","then","output","code","visited","Set","getMatches","file","isClientEntry","add","rej","readFile","err","data","toString","matches","match","matchedDirectives","directiveList","JSON","parse","includes","exportList","slice","wildcardExports","matchAll","map","decl","length","all","req","targetPath","path","dirname","replace","targetMatches","concat","set","NextBarrelLoader","async","cacheable","installBindings","names","getOptions","getResolve","mainFields","mapping","clearDependencies","callback","stringify","exportMap","name","filePath","orig","missedNames","push","join"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoFC;;;;+BA+PD;;;eAAA;;;6DA3PiB;qBACS;iCACM;;;;;;AAEhC,iFAAiF;AACjF,mFAAmF;AACnF,+DAA+D;AAC/D,kEAAkE;AAClE,MAAMA,8BAA8B,IAAIC;AASxC,eAAeC,iBACbC,YAAoB,EACpBC,WAAmB,EACnBC,OAA8D,EAC9DC,EAKC;IAED,IAAIN,4BAA4BO,GAAG,CAACJ,eAAe;QACjD,OAAOH,4BAA4BQ,GAAG,CAACL;IACzC;IAEA,6EAA6E;IAC7E,mDAAmD;IACnD,eAAeM,gBACbC,QAAgB,EAChBC,MAAc,EACdC,UA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,CAAC,EAAE,CAAC,IAAI,EAAEwB,KAAK,QAAQ,EAAEhC,KAAK8B,SAAS,CACjEtB,IAAI,CAAC,EAAE,GACN;YACL;QACF,OAAO;YACL2B,YAAYC,IAAI,CAACJ;QACnB;IACF;IAEA,mCAAmC;IACnC,IAAIG,YAAY1B,MAAM,GAAG,GAAG;QAC1B,KAAK,MAAME,OAAOgB,QAAQtB,eAAe,CAAE;YACzCtB,UAAU,CAAC,gBAAgB,EAAEiB,KAAK8B,SAAS,CACzCnB,IAAII,OAAO,CAAC,mBAAmBoB,YAAYE,IAAI,CAAC,OAAO,eACtD;QACL;IACF;IAEA,yEAAyE;IACzE,yCAAyC;IACzC,IAAIhD,eAAe;QACjBN,SAAS,CAAC,eAAe,EAAEA,QAAQ;IACrC;IAEA,IAAI,CAAC8C,QAAQ,CAAC,MAAM9C;AACtB;MAEA,WAAeoC","ignoreList":[0]}
@@ -30,6 +30,7 @@ const _mimetype = require("../../../lib/mime-type");
30
30
  const _constants = require("../../../lib/constants");
31
31
  const _normalizepathsep = require("../../../shared/lib/page-path/normalize-path-sep");
32
32
  const _utils = require("./utils");
33
+ const _installbindings = require("../../swc/install-bindings");
33
34
  function _interop_require_default(obj) {
34
35
  return obj && obj.__esModule ? obj : {
35
36
  default: obj
@@ -38,6 +39,10 @@ function _interop_require_default(obj) {
38
39
  // [NOTE] For turbopack, refer to app_page_loader_tree's write_metadata_item for
39
40
  // corresponding features.
40
41
  async function nextMetadataImageLoader(content) {
42
+ // Install bindings early so they are definitely available to the loader.
43
+ // When run by webpack in next this is already done with correct configuration so this is a no-op.
44
+ // In turbopack loaders are run in a subprocess so it may or may not be done.
45
+ await (0, _installbindings.installBindings)();
41
46
  const options = this.getOptions();
42
47
  const { type, segment, pageExtensions, basePath } = options;
43
48
  const { resourcePath, rootContext: context } = this;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/build/webpack/loaders/next-metadata-image-loader.ts"],"sourcesContent":["/*\n * This loader is responsible for extracting the metadata image info for rendering in html\n */\n\nimport type webpack from 'webpack'\nimport type {\n MetadataImageModule,\n PossibleImageFileNameConvention,\n} from './metadata/types'\nimport { existsSync, promises as fs } from 'fs'\nimport path from 'path'\nimport loaderUtils from 'next/dist/compiled/loader-utils3'\nimport { getImageSize } from '../../../server/image-optimizer'\nimport { imageExtMimeTypeMap } from '../../../lib/mime-type'\nimport { WEBPACK_RESOURCE_QUERIES } from '../../../lib/constants'\nimport { normalizePathSep } from '../../../shared/lib/page-path/normalize-path-sep'\nimport type { PageExtensions } from '../../page-extensions-type'\nimport { getLoaderModuleNamedExports } from './utils'\n\ninterface Options {\n segment: string\n type: PossibleImageFileNameConvention\n pageExtensions: PageExtensions\n basePath: string\n}\n\n// [NOTE] For turbopack, refer to app_page_loader_tree's write_metadata_item for\n// corresponding features.\nasync function nextMetadataImageLoader(\n this: webpack.LoaderContext<Options>,\n content: Buffer\n) {\n const options: Options = this.getOptions()\n const { type, segment, pageExtensions, basePath } = options\n const { resourcePath, rootContext: context } = this\n const { name: fileNameBase, ext } = path.parse(resourcePath)\n const useNumericSizes = type === 'twitter' || type === 'openGraph'\n\n let extension = ext.slice(1)\n if (extension === 'jpg') {\n extension = 'jpeg'\n }\n\n const opts = { context, content }\n\n const contentHash = loaderUtils.interpolateName(this, '[contenthash]', opts)\n\n const interpolatedName = loaderUtils.interpolateName(\n this,\n '[name].[ext]',\n opts\n )\n\n const isDynamicResource = pageExtensions.includes(extension)\n const pageSegment = isDynamicResource ? fileNameBase : interpolatedName\n const hashQuery = contentHash ? '?' + contentHash : ''\n const pathnamePrefix = normalizePathSep(path.join(basePath, segment))\n\n if (isDynamicResource) {\n const exportedFieldsExcludingDefault = (\n await getLoaderModuleNamedExports(resourcePath, this)\n ).filter((name) => name !== 'default')\n\n // re-export and spread as `exportedImageData` to avoid non-exported error\n return `\\\n import {\n ${exportedFieldsExcludingDefault\n .map((field) => `${field} as _${field}`)\n .join(',')}\n } from ${JSON.stringify(\n // This is an arbitrary resource query to ensure it's a new request, instead\n // of sharing the same module with next-metadata-route-loader.\n // Since here we only need export fields such as `size`, `alt` and\n // `generateImageMetadata`, avoid sharing the same module can make this entry\n // smaller.\n resourcePath + '?' + WEBPACK_RESOURCE_QUERIES.metadataImageMeta\n )}\n import { fillMetadataSegment } from 'next/dist/lib/metadata/get-metadata-route'\n\n const imageModule = {\n ${exportedFieldsExcludingDefault\n .map((field) => `${field}: _${field}`)\n .join(',')}\n }\n\n function getImageMetadata(imageMetadata, idParam, resolvedParams) {\n const imageUrl = fillMetadataSegment(${JSON.stringify(\n pathnamePrefix\n )}, resolvedParams, ${JSON.stringify(pageSegment)})\n const data = {\n alt: imageMetadata.alt,\n type: imageMetadata.contentType || 'image/png',\n url: imageUrl + (idParam ? ('/' + idParam) : '') + ${JSON.stringify(\n hashQuery\n )},\n }\n const { size } = imageMetadata\n if (size) {\n ${\n type === 'twitter' || type === 'openGraph'\n ? 'data.width = size.width; data.height = size.height;'\n : 'data.sizes = size.width + \"x\" + size.height;'\n }\n }\n return data\n }\n\n export default async function (props) {\n const { generateImageMetadata } = imageModule\n const resolvedParams = await props.params\n\n if (generateImageMetadata) {\n const imageMetadataArray = await generateImageMetadata({ params: resolvedParams })\n return imageMetadataArray.map((imageMetadata, index) => {\n const idParam = imageMetadata.id + ''\n return getImageMetadata(imageMetadata, idParam, resolvedParams)\n })\n } else {\n return [getImageMetadata(imageModule, '', resolvedParams)]\n }\n }`\n }\n\n let imageError\n const imageSize: { width?: number; height?: number } = await getImageSize(\n content\n ).catch((error) => {\n const message = `Process image \"${path.posix.join(segment || '/', interpolatedName)}\" failed: ${error}`\n imageError = new Error(message)\n return {}\n })\n\n if (imageError) {\n throw imageError\n }\n\n const imageData: Omit<MetadataImageModule, 'url'> = {\n ...(extension in imageExtMimeTypeMap && {\n type: imageExtMimeTypeMap[extension as keyof typeof imageExtMimeTypeMap],\n }),\n ...(useNumericSizes && imageSize.width != null && imageSize.height != null\n ? imageSize\n : {\n sizes:\n // For SVGs, skip sizes and use \"any\" to let it scale automatically based on viewport,\n // For the images doesn't provide the size properly, use \"any\" as well.\n // If the size is presented, use the actual size for the image.\n extension !== 'svg' &&\n imageSize.width != null &&\n imageSize.height != null\n ? `${imageSize.width}x${imageSize.height}`\n : 'any',\n }),\n }\n if (type === 'openGraph' || type === 'twitter') {\n const altPath = path.join(\n path.dirname(resourcePath),\n fileNameBase + '.alt.txt'\n )\n\n if (existsSync(altPath)) {\n imageData.alt = await fs.readFile(altPath, 'utf8')\n }\n }\n\n return `\\\n import { fillMetadataSegment } from 'next/dist/lib/metadata/get-metadata-route'\n\n export default async (props) => {\n const imageData = ${JSON.stringify(imageData)}\n const imageUrl = fillMetadataSegment(${JSON.stringify(\n pathnamePrefix\n )}, await props.params, ${JSON.stringify(pageSegment)})\n\n return [{\n ...imageData,\n url: imageUrl + ${JSON.stringify(hashQuery)},\n }]\n }`\n}\n\nexport const raw = true\nexport default nextMetadataImageLoader\n"],"names":["raw","nextMetadataImageLoader","content","options","getOptions","type","segment","pageExtensions","basePath","resourcePath","rootContext","context","name","fileNameBase","ext","path","parse","useNumericSizes","extension","slice","opts","contentHash","loaderUtils","interpolateName","interpolatedName","isDynamicResource","includes","pageSegment","hashQuery","pathnamePrefix","normalizePathSep","join","exportedFieldsExcludingDefault","getLoaderModuleNamedExports","filter","map","field","JSON","stringify","WEBPACK_RESOURCE_QUERIES","metadataImageMeta","imageError","imageSize","getImageSize","catch","error","message","posix","Error","imageData","imageExtMimeTypeMap","width","height","sizes","altPath","dirname","existsSync","alt","fs","readFile"],"mappings":"AAAA;;CAEC;;;;;;;;;;;;;;;IAoLD,OAAsC;eAAtC;;IADaA,GAAG;eAAHA;;;oBA5K8B;6DAC1B;qEACO;gCACK;0BACO;2BACK;kCACR;uBAEW;;;;;;AAS5C,gFAAgF;AAChF,0BAA0B;AAC1B,eAAeC,wBAEbC,OAAe;IAEf,MAAMC,UAAmB,IAAI,CAACC,UAAU;IACxC,MAAM,EAAEC,IAAI,EAAEC,OAA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IAEA,OAAO,CAAC;;;;sBAIY,EAAEjB,KAAKC,SAAS,CAACW,WAAW;yCACT,EAAEZ,KAAKC,SAAS,CACnDT,gBACA,sBAAsB,EAAEQ,KAAKC,SAAS,CAACX,aAAa;;;;sBAIpC,EAAEU,KAAKC,SAAS,CAACV,WAAW;;GAE/C,CAAC;AACJ;AAEO,MAAM5B,MAAM;MACnB,WAAeC","ignoreList":[0]}
1
+ {"version":3,"sources":["../../../../src/build/webpack/loaders/next-metadata-image-loader.ts"],"sourcesContent":["/*\n * This loader is responsible for extracting the metadata image info for rendering in html\n */\n\nimport type webpack from 'webpack'\nimport type {\n MetadataImageModule,\n PossibleImageFileNameConvention,\n} from './metadata/types'\nimport { existsSync, promises as fs } from 'fs'\nimport path from 'path'\nimport loaderUtils from 'next/dist/compiled/loader-utils3'\nimport { getImageSize } from '../../../server/image-optimizer'\nimport { imageExtMimeTypeMap } from '../../../lib/mime-type'\nimport { WEBPACK_RESOURCE_QUERIES } from '../../../lib/constants'\nimport { normalizePathSep } from '../../../shared/lib/page-path/normalize-path-sep'\nimport type { PageExtensions } from '../../page-extensions-type'\nimport { getLoaderModuleNamedExports } from './utils'\nimport { installBindings } from '../../swc/install-bindings'\n\ninterface Options {\n segment: string\n type: PossibleImageFileNameConvention\n pageExtensions: PageExtensions\n basePath: string\n}\n\n// [NOTE] For turbopack, refer to app_page_loader_tree's write_metadata_item for\n// corresponding features.\nasync function nextMetadataImageLoader(\n this: webpack.LoaderContext<Options>,\n content: Buffer\n) {\n // Install bindings early so they are definitely available to the loader.\n // When run by webpack in next this is already done with correct configuration so this is a no-op.\n // In turbopack loaders are run in a subprocess so it may or may not be done.\n await installBindings()\n const options: Options = this.getOptions()\n const { type, segment, pageExtensions, basePath } = options\n const { resourcePath, rootContext: context } = this\n const { name: fileNameBase, ext } = path.parse(resourcePath)\n const useNumericSizes = type === 'twitter' || type === 'openGraph'\n\n let extension = ext.slice(1)\n if (extension === 'jpg') {\n extension = 'jpeg'\n }\n\n const opts = { context, content }\n\n const contentHash = loaderUtils.interpolateName(this, '[contenthash]', opts)\n\n const interpolatedName = loaderUtils.interpolateName(\n this,\n '[name].[ext]',\n opts\n )\n\n const isDynamicResource = pageExtensions.includes(extension)\n const pageSegment = isDynamicResource ? fileNameBase : interpolatedName\n const hashQuery = contentHash ? '?' + contentHash : ''\n const pathnamePrefix = normalizePathSep(path.join(basePath, segment))\n\n if (isDynamicResource) {\n const exportedFieldsExcludingDefault = (\n await getLoaderModuleNamedExports(resourcePath, this)\n ).filter((name) => name !== 'default')\n\n // re-export and spread as `exportedImageData` to avoid non-exported error\n return `\\\n import {\n ${exportedFieldsExcludingDefault\n .map((field) => `${field} as _${field}`)\n .join(',')}\n } from ${JSON.stringify(\n // This is an arbitrary resource query to ensure it's a new request, instead\n // of sharing the same module with next-metadata-route-loader.\n // Since here we only need export fields such as `size`, `alt` and\n // `generateImageMetadata`, avoid sharing the same module can make this entry\n // smaller.\n resourcePath + '?' + WEBPACK_RESOURCE_QUERIES.metadataImageMeta\n )}\n import { fillMetadataSegment } from 'next/dist/lib/metadata/get-metadata-route'\n\n const imageModule = {\n ${exportedFieldsExcludingDefault\n .map((field) => `${field}: _${field}`)\n .join(',')}\n }\n\n function getImageMetadata(imageMetadata, idParam, resolvedParams) {\n const imageUrl = fillMetadataSegment(${JSON.stringify(\n pathnamePrefix\n )}, resolvedParams, ${JSON.stringify(pageSegment)})\n const data = {\n alt: imageMetadata.alt,\n type: imageMetadata.contentType || 'image/png',\n url: imageUrl + (idParam ? ('/' + idParam) : '') + ${JSON.stringify(\n hashQuery\n )},\n }\n const { size } = imageMetadata\n if (size) {\n ${\n type === 'twitter' || type === 'openGraph'\n ? 'data.width = size.width; data.height = size.height;'\n : 'data.sizes = size.width + \"x\" + size.height;'\n }\n }\n return data\n }\n\n export default async function (props) {\n const { generateImageMetadata } = imageModule\n const resolvedParams = await props.params\n\n if (generateImageMetadata) {\n const imageMetadataArray = await generateImageMetadata({ params: resolvedParams })\n return imageMetadataArray.map((imageMetadata, index) => {\n const idParam = imageMetadata.id + ''\n return getImageMetadata(imageMetadata, idParam, resolvedParams)\n })\n } else {\n return [getImageMetadata(imageModule, '', resolvedParams)]\n }\n }`\n }\n\n let imageError\n const imageSize: { width?: number; height?: number } = await getImageSize(\n content\n ).catch((error) => {\n const message = `Process image \"${path.posix.join(segment || '/', interpolatedName)}\" failed: ${error}`\n imageError = new Error(message)\n return {}\n })\n\n if (imageError) {\n throw imageError\n }\n\n const imageData: Omit<MetadataImageModule, 'url'> = {\n ...(extension in imageExtMimeTypeMap && {\n type: imageExtMimeTypeMap[extension as keyof typeof imageExtMimeTypeMap],\n }),\n ...(useNumericSizes && imageSize.width != null && imageSize.height != null\n ? imageSize\n : {\n sizes:\n // For SVGs, skip sizes and use \"any\" to let it scale automatically based on viewport,\n // For the images doesn't provide the size properly, use \"any\" as well.\n // If the size is presented, use the actual size for the image.\n extension !== 'svg' &&\n imageSize.width != null &&\n imageSize.height != null\n ? `${imageSize.width}x${imageSize.height}`\n : 'any',\n }),\n }\n if (type === 'openGraph' || type === 'twitter') {\n const altPath = path.join(\n path.dirname(resourcePath),\n fileNameBase + '.alt.txt'\n )\n\n if (existsSync(altPath)) {\n imageData.alt = await fs.readFile(altPath, 'utf8')\n }\n }\n\n return `\\\n import { fillMetadataSegment } from 'next/dist/lib/metadata/get-metadata-route'\n\n export default async (props) => {\n const imageData = ${JSON.stringify(imageData)}\n const imageUrl = fillMetadataSegment(${JSON.stringify(\n pathnamePrefix\n )}, await props.params, ${JSON.stringify(pageSegment)})\n\n return [{\n ...imageData,\n url: imageUrl + ${JSON.stringify(hashQuery)},\n }]\n }`\n}\n\nexport const raw = true\nexport default nextMetadataImageLoader\n"],"names":["raw","nextMetadataImageLoader","content","installBindings","options","getOptions","type","segment","pageExtensions","basePath","resourcePath","rootContext","context","name","fileNameBase","ext","path","parse","useNumericSizes","extension","slice","opts","contentHash","loaderUtils","interpolateName","interpolatedName","isDynamicResource","includes","pageSegment","hashQuery","pathnamePrefix","normalizePathSep","join","exportedFieldsExcludingDefault","getLoaderModuleNamedExports","filter","map","field","JSON","stringify","WEBPACK_RESOURCE_QUERIES","metadataImageMeta","imageError","imageSize","getImageSize","catch","error","message","posix","Error","imageData","imageExtMimeTypeMap","width","height","sizes","altPath","dirname","existsSync","alt","fs","readFile"],"mappings":"AAAA;;CAEC;;;;;;;;;;;;;;;IAyLD,OAAsC;eAAtC;;IADaA,GAAG;eAAHA;;;oBAjL8B;6DAC1B;qEACO;gCACK;0BACO;2BACK;kCACR;uBAEW;iCACZ;;;;;;AAShC,gFAAgF;AAChF,0BAA0B;AAC1B,eAAeC,wBAEbC,OAAe;IAEf,yEAAyE;IACzE,kGAAkG;IAClG,6EAA6E;IAC7E,MAAMC,IAAAA,gCAAe;IACrB,MAAMC,UAAmB,IAAI,CAACC,UAAU;IACxC,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,cAAc,EAAEC,QAAQ,EAAE,GAAGL;IACpD,MAAM,EAAEM,YAAY,EAAEC,aAAaC,OAAO,EAAE,GAAG,IAAI;IACnD,MAAM,EAAEC,MAAMC,YAAY,EAAEC,GAAG,EAAE,GAAGC,aAAI,CAACC,KAAK,CAACP;IAC/C,MAAMQ,kBAAkBZ,SAAS,aAAaA,SAAS;IAEvD,IAAIa,YAAYJ,IAAIK,KAAK,CAAC;IAC1B,IAAID,cAAc,OAAO;QACvBA,YAAY;IACd;IAEA,MAAME,OAAO;QAAET;QAASV;IAAQ;IAEhC,MAAMoB,cAAcC,qBAAW,CAACC,eAAe,CAAC,IAAI,EAAE,iBAAiBH;IAEvE,MAAMI,mBAAmBF,qBAAW,CAACC,eAAe,CAClD,IAAI,EACJ,gBACAH;IAGF,MAAMK,oBAAoBlB,eAAemB,QAAQ,CAACR;IAClD,MAAMS,cAAcF,oBAAoBZ,eAAeW;IACvD,MAAMI,YAAYP,cAAc,MAAMA,cAAc;IACpD,MAAMQ,iBAAiBC,IAAAA,kCAAgB,EAACf,aAA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AAmB,CAAChC,UAA8C;QAC1E,CAAC;QACD,GAAID,mBAAmByB,UAAUS,KAAK,IAAI,QAAQT,UAAUU,MAAM,IAAI,OAClEV,YACA;YACEW,OACE,sFAAsF;YACtF,uEAAuE;YACvE,+DAA+D;YAC/DnC,cAAc,SACdwB,UAAUS,KAAK,IAAI,QACnBT,UAAUU,MAAM,IAAI,OAChB,GAAGV,UAAUS,KAAK,CAAC,CAAC,EAAET,UAAUU,MAAM,EAAE,GACxC;QACR,CAAC;IACP;IACA,IAAI/C,SAAS,eAAeA,SAAS,WAAW;QAC9C,MAAMiD,UAAUvC,aAAI,CAACgB,IAAI,CACvBhB,aAAI,CAACwC,OAAO,CAAC9C,eACbI,eAAe;QAGjB,IAAI2C,IAAAA,cAAU,EAACF,UAAU;YACvBL,UAAUQ,GAAG,GAAG,MAAMC,YAAE,CAACC,QAAQ,CAACL,SAAS;QAC7C;IACF;IAEA,OAAO,CAAC;;;;sBAIY,EAAEjB,KAAKC,SAAS,CAACW,WAAW;yCACT,EAAEZ,KAAKC,SAAS,CACnDT,gBACA,sBAAsB,EAAEQ,KAAKC,SAAS,CAACX,aAAa;;;;sBAIpC,EAAEU,KAAKC,SAAS,CAACV,WAAW;;GAE/C,CAAC;AACJ;AAEO,MAAM7B,MAAM;MACnB,WAAeC","ignoreList":[0]}
@@ -24,6 +24,7 @@ const _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
24
24
  const _path = /*#__PURE__*/ _interop_require_default(require("path"));
25
25
  const _mimetype = require("../../../lib/mime-type");
26
26
  const _utils = require("./utils");
27
+ const _installbindings = require("../../swc/install-bindings");
27
28
  function _interop_require_default(obj) {
28
29
  return obj && obj.__esModule ? obj : {
29
30
  default: obj
@@ -315,6 +316,10 @@ async function getSitemapRouteCode(resourcePath, loaderContext) {
315
316
  // When it's static route, it could be favicon.ico, sitemap.xml, robots.txt etc.
316
317
  // TODO-METADATA: improve the cache control strategy
317
318
  const nextMetadataRouterLoader = async function() {
319
+ // Install bindings early so they are definitely available to the loader.
320
+ // When run by webpack in next this is already done with correct configuration so this is a no-op.
321
+ // In turbopack loaders are run in a subprocess so it may or may not be done.
322
+ await (0, _installbindings.installBindings)();
318
323
  const { isDynamicRouteExtension, filePath } = this.getOptions();
319
324
  const { name: fileBaseName } = getFilenameAndExtension(filePath);
320
325
  this.addDependency(filePath);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/build/webpack/loaders/next-metadata-route-loader.ts"],"sourcesContent":["import type webpack from 'webpack'\nimport fs from 'fs'\nimport path from 'path'\nimport { imageExtMimeTypeMap } from '../../../lib/mime-type'\nimport { getLoaderModuleNamedExports } from './utils'\n\nfunction errorOnBadHandler(resourcePath: string) {\n return `\n if (typeof handler !== 'function') {\n throw new Error('Default export is missing in ${JSON.stringify(\n resourcePath\n )}')\n }\n `\n}\n\n/* re-export the userland route configs */\nasync function createReExportsCode(\n resourcePath: string,\n loaderContext: webpack.LoaderContext<any>\n) {\n const exportNames = await getLoaderModuleNamedExports(\n resourcePath,\n loaderContext\n )\n // Re-export configs but avoid conflicted exports\n const reExportNames = exportNames.filter(\n (name) =>\n name !== 'default' &&\n name !== 'generateSitemaps' &&\n name !== 'dynamicParams'\n )\n\n return reExportNames.length > 0\n ? `export { ${reExportNames.join(', ')} } from ${JSON.stringify(\n resourcePath\n )}\\n`\n : ''\n}\n\nconst CACHE_HEADERS = {\n NO_CACHE: 'no-cache, no-store',\n REVALIDATE: 'public, max-age=0, must-revalidate',\n}\n\nexport type MetadataRouteLoaderOptions = {\n // Using separate argument to avoid json being parsed and hit error\n // x-ref: https://github.com/vercel/next.js/pull/62615\n filePath: string\n isDynamicRouteExtension: '1' | '0'\n}\n\nexport function getFilenameAndExtension(resourcePath: string) {\n const filename = path.basename(resourcePath)\n const [name, ext] = filename.split('.', 2)\n return {\n name,\n ext,\n }\n}\n\nfunction getContentType(resourcePath: string) {\n let { name, ext } = getFilenameAndExtension(resourcePath)\n if (ext === 'jpg') ext = 'jpeg'\n\n if (name === 'favicon' && ext === 'ico') return 'image/x-icon'\n if (name === 'sitemap') return 'application/xml'\n if (name === 'robots') return 'text/plain'\n if (name === 'manifest') return 'application/manifest+json'\n\n if (ext === 'png' || ext === 'jpeg' || ext === 'ico' || ext === 'svg') {\n return imageExtMimeTypeMap[ext]\n }\n return 'text/plain'\n}\n\nasync function getStaticAssetRouteCode(\n resourcePath: string,\n fileBaseName: string\n) {\n const cache =\n process.env.NODE_ENV !== 'production'\n ? CACHE_HEADERS.NO_CACHE\n : CACHE_HEADERS.REVALIDATE\n\n const isTwitter = fileBaseName === 'twitter-image'\n const isOpenGraph = fileBaseName === 'opengraph-image'\n // Twitter image file size limit is 5MB.\n // General Open Graph image file size limit is 8MB.\n // x-ref: https://developer.x.com/en/docs/x-for-websites/cards/overview/summary\n // x-ref(facebook): https://developers.facebook.com/docs/sharing/webmasters/images\n const fileSizeLimit = isTwitter ? 5 : 8\n const imgName = isTwitter ? 'Twitter' : 'Open Graph'\n\n const code = `\\\n/* static asset route */\nimport { NextResponse } from 'next/server'\n\nconst contentType = ${JSON.stringify(getContentType(resourcePath))}\nconst buffer = Buffer.from(${JSON.stringify(\n (await fs.promises.readFile(resourcePath)).toString('base64')\n )}, 'base64'\n )\n\nif (${isTwitter || isOpenGraph}) {\n const fileSizeInMB = buffer.byteLength / 1024 / 1024\n if (fileSizeInMB > ${fileSizeLimit}) {\n throw new Error('File size for ${imgName} image ${JSON.stringify(resourcePath)} exceeds ${fileSizeLimit}MB. ' +\n \\`(Current: \\${fileSizeInMB.toFixed(2)}MB)\\n\\` +\n 'Read more: https://nextjs.org/docs/app/api-reference/file-conventions/metadata/opengraph-image#image-files-jpg-png-gif'\n )\n }\n}\n\nexport function GET() {\n return new NextResponse(buffer, {\n headers: {\n 'Content-Type': contentType,\n 'Cache-Control': ${JSON.stringify(cache)},\n },\n })\n}\n\nexport const dynamic = 'force-static'\n`\n return code\n}\n\nasync function getDynamicTextRouteCode(\n resourcePath: string,\n loaderContext: webpack.LoaderContext<any>\n) {\n return `\\\n/* dynamic asset route */\nimport { NextResponse } from 'next/server'\nimport handler from ${JSON.stringify(resourcePath)}\nimport { resolveRouteData } from 'next/dist/build/webpack/loaders/metadata/resolve-route-data'\n\nconst contentType = ${JSON.stringify(getContentType(resourcePath))}\nconst fileType = ${JSON.stringify(getFilenameAndExtension(resourcePath).name)}\n\n${errorOnBadHandler(resourcePath)}\n${await createReExportsCode(resourcePath, loaderContext)}\n\nexport async function GET() {\n const data = await handler()\n const content = resolveRouteData(data, fileType)\n\n return new NextResponse(content, {\n headers: {\n 'Content-Type': contentType,\n 'Cache-Control': ${JSON.stringify(CACHE_HEADERS.REVALIDATE)},\n },\n })\n}\n`\n}\n\nasync function getDynamicImageRouteCode(\n resourcePath: string,\n loaderContext: webpack.LoaderContext<any>\n) {\n return `\\\n/* dynamic image route with generateImageMetadata */\nimport { NextResponse } from 'next/server'\nimport { default as handler, generateImageMetadata } from ${JSON.stringify(resourcePath)}\n\n${errorOnBadHandler(resourcePath)}\n${await createReExportsCode(resourcePath, loaderContext)}\n\nexport async function GET(_, ctx) {\n const paramsPromise = ctx.params\n const idPromise = paramsPromise.then(params => params?.__metadata_id__)\n const restParamsPromise = paramsPromise.then(params => {\n if (!params) return undefined\n const { __metadata_id__, ...rest } = params\n return rest\n })\n\n const restParams = await restParamsPromise\n const __metadata_id__ = await idPromise\n const imageMetadata = await generateImageMetadata({ params: restParams })\n const id = imageMetadata.find((item) => {\n if (item?.id == null) {\n throw new Error('id property is required for every item returned from generateImageMetadata')\n }\n\n return item.id.toString() === __metadata_id__\n })?.id\n\n if (id == null) {\n return new NextResponse('Not Found', {\n status: 404,\n })\n }\n\n return handler({ params: restParamsPromise, id: idPromise })\n}\n\nexport async function generateStaticParams({ params }) {\n const imageMetadata = await generateImageMetadata({ params })\n const staticParams = []\n\n for (const item of imageMetadata) {\n if (item?.id == null) {\n throw new Error('id property is required for every item returned from generateImageMetadata')\n }\n staticParams.push({ __metadata_id__: item.id.toString() })\n }\n return staticParams\n}\n`\n}\n\nasync function getSingleImageRouteCode(\n resourcePath: string,\n loaderContext: webpack.LoaderContext<any>\n) {\n return `\\\n/* dynamic image route without generateImageMetadata */\nimport { NextResponse } from 'next/server'\nimport { default as handler } from ${JSON.stringify(resourcePath)}\n\n${errorOnBadHandler(resourcePath)}\n${await createReExportsCode(resourcePath, loaderContext)}\n\nexport async function GET(_, ctx) {\n return handler({ params: ctx.params })\n}\n`\n}\n\n// <metadata-image>/[id]/route.js\nasync function getImageRouteCode(\n resourcePath: string,\n loaderContext: webpack.LoaderContext<any>\n) {\n const exportNames = await getLoaderModuleNamedExports(\n resourcePath,\n loaderContext\n )\n\n const hasGenerateParamsExport = exportNames.includes('generateImageMetadata')\n\n if (hasGenerateParamsExport) {\n return getDynamicImageRouteCode(resourcePath, loaderContext)\n } else {\n return getSingleImageRouteCode(resourcePath, loaderContext)\n }\n}\n\nasync function getSingleSitemapRouteCode(\n resourcePath: string,\n loaderContext: webpack.LoaderContext<any>\n) {\n return `\\\n/* single sitemap route */\nimport { NextResponse } from 'next/server'\nimport { default as handler } from ${JSON.stringify(resourcePath)}\nimport { resolveRouteData } from 'next/dist/build/webpack/loaders/metadata/resolve-route-data'\n\nconst contentType = ${JSON.stringify(getContentType(resourcePath))}\nconst fileType = ${JSON.stringify(getFilenameAndExtension(resourcePath).name)}\n\n${errorOnBadHandler(resourcePath)}\n${await createReExportsCode(resourcePath, loaderContext)}\n\nexport async function GET() {\n const data = await handler()\n const content = resolveRouteData(data, fileType)\n\n return new NextResponse(content, {\n headers: {\n 'Content-Type': contentType,\n 'Cache-Control': ${JSON.stringify(CACHE_HEADERS.REVALIDATE)},\n },\n })\n}\n`\n}\n\nasync function getDynamicSitemapRouteCode(\n resourcePath: string,\n loaderContext: webpack.LoaderContext<any>\n) {\n const code = `\\\n/* dynamic sitemap route with generateSitemaps */\nimport { NextResponse } from 'next/server'\nimport { default as handler, generateSitemaps } from ${JSON.stringify(resourcePath)}\nimport { resolveRouteData } from 'next/dist/build/webpack/loaders/metadata/resolve-route-data'\n\nconst contentType = ${JSON.stringify(getContentType(resourcePath))}\nconst fileType = ${JSON.stringify(getFilenameAndExtension(resourcePath).name)}\n\n${errorOnBadHandler(resourcePath)}\n${await createReExportsCode(resourcePath, loaderContext)}\n\nexport async function GET(_, ctx) {\n const paramsPromise = ctx.params\n const idPromise = paramsPromise.then(params => params?.__metadata_id__)\n\n const id = await idPromise\n const hasXmlExtension = id ? id.endsWith('.xml') : false\n const sitemaps = await generateSitemaps()\n let foundId\n for (const item of sitemaps) {\n if (item?.id == null) {\n throw new Error('id property is required for every item returned from generateSitemaps')\n }\n\n const baseId = id && hasXmlExtension ? id.slice(0, -4) : undefined\n if (item.id.toString() === baseId) {\n foundId = item.id\n }\n }\n if (foundId == null) {\n return new NextResponse('Not Found', {\n status: 404,\n })\n }\n\n const targetIdPromise = idPromise.then(id => {\n const hasXmlExtension = id ? id.endsWith('.xml') : false\n return id && hasXmlExtension ? id.slice(0, -4) : undefined\n })\n const data = await handler({ id: targetIdPromise })\n const content = resolveRouteData(data, fileType)\n\n return new NextResponse(content, {\n headers: {\n 'Content-Type': contentType,\n 'Cache-Control': ${JSON.stringify(CACHE_HEADERS.REVALIDATE)},\n },\n })\n}\n\nexport async function generateStaticParams() {\n const sitemaps = await generateSitemaps()\n const params = []\n\n for (const item of sitemaps) {\n if (item?.id == null) {\n throw new Error('id property is required for every item returned from generateSitemaps')\n }\n params.push({ __metadata_id__: item.id.toString() + '.xml' })\n }\n return params\n}\n`\n return code\n}\n\n// <metadata-sitemap>/[id]/route.js\nasync function getSitemapRouteCode(\n resourcePath: string,\n loaderContext: webpack.LoaderContext<any>\n) {\n const exportNames = await getLoaderModuleNamedExports(\n resourcePath,\n loaderContext\n )\n\n const hasGenerateSitemaps = exportNames.includes('generateSitemaps')\n\n if (hasGenerateSitemaps) {\n return getDynamicSitemapRouteCode(resourcePath, loaderContext)\n } else {\n return getSingleSitemapRouteCode(resourcePath, loaderContext)\n }\n}\n\n// When it's static route, it could be favicon.ico, sitemap.xml, robots.txt etc.\n// TODO-METADATA: improve the cache control strategy\nconst nextMetadataRouterLoader: webpack.LoaderDefinitionFunction<MetadataRouteLoaderOptions> =\n async function () {\n const { isDynamicRouteExtension, filePath } = this.getOptions()\n const { name: fileBaseName } = getFilenameAndExtension(filePath)\n this.addDependency(filePath)\n\n let code = ''\n if (isDynamicRouteExtension === '1') {\n if (fileBaseName === 'robots' || fileBaseName === 'manifest') {\n code = await getDynamicTextRouteCode(filePath, this)\n } else if (fileBaseName === 'sitemap') {\n code = await getSitemapRouteCode(filePath, this)\n } else {\n code = await getImageRouteCode(filePath, this)\n }\n } else {\n code = await getStaticAssetRouteCode(filePath, fileBaseName)\n }\n\n return code\n }\n\nexport default nextMetadataRouterLoader\n"],"names":["getFilenameAndExtension","errorOnBadHandler","resourcePath","JSON","stringify","createReExportsCode","loaderContext","exportNames","getLoaderModuleNamedExports","reExportNames","filter","name","length","join","CACHE_HEADERS","NO_CACHE","REVALIDATE","filename","path","basename","ext","split","getContentType","imageExtMimeTypeMap","getStaticAssetRouteCode","fileBaseName","cache","process","env","NODE_ENV","isTwitter","isOpenGraph","fileSizeLimit","imgName","code","fs","promises","readFile","toString","getDynamicTextRouteCode","getDynamicImageRouteCode","getSingleImageRouteCode","getImageRouteCode","hasGenerateParamsExport","includes","getSingleSitemapRouteCode","getDynamicSitemapRouteCode","getSitemapRouteCode","hasGenerateSitemaps","nextMetadataRouterLoader","isDynamicRouteExtension","filePath","getOptions","addDependency"],"mappings":";;;;;;;;;;;;;;;IA2YA,OAAuC;eAAvC;;IAvVgBA,uBAAuB;eAAvBA;;;2DAnDD;6DACE;0BACmB;uBACQ;;;;;;AAE5C,SAASC,kBAAkBC,YAAoB;IAC7C,OAAO,CAAC;;kDAEwC,EAAEC,KAAKC,SAAS,CAC5DF,cACA;;EAEJ,CAAC;AACH;AAEA,wCAAwC,GACxC,eAAeG,oBACbH,YAAoB,EACpBI,aAAyC;IAEzC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EACnDN,cACAI;IAGF,MAAM0C,sBAAsBzC,YAAYqC,QAAQ,CAAC;IAEjD,IAAII,qBAAqB;QACvB,OAAOF,2BAA2B5C,cAAcI;IAClD,OAAO;QACL,OAAOuC,0BAA0B3C,cAAcI;IACjD;AACF;AAEA,gFAAgF;AAChF,oDAAoD;AACpD,MAAM2C,2BACJ;IACE,MAAM,EAAEC,uBAAuB,EAAEC,QAAQ,EAAE,GAAG,IAAI,CAACC,UAAU;IAC7D,MAAM,EAAEzC,MAAMc,YAAY,EAAE,GAAGzB,wBAAwBmD;IACvD,IAAI,CAACE,aAAa,CAACF;IAEnB,IAAIjB,OAAO;IACX,IAAIgB,4BAA4B,KAAK;QACnC,IAAIzB,iBAAiB,YAAYA,iBAAiB,YAAY;YAC5DS,OAAO,MAAMK,wBAAwBY,UAAU,IAAI;QACrD,OAAO,IAAI1B,iBAAiB,WAAW;YACrCS,OAAO,MAAMa,oBAAoBI,UAAU,IAAI;QACjD,OAAO;YACLjB,OAAO,MAAMQ,kBAAkBS,UAAU,IAAI;QAC/C;IACF,OAAO;QACLjB,OAAO,MAAMV,wBAAwB2B,UAAU1B;IACjD;IAEA,OAAOS;AACT;MAEF,WAAee","ignoreList":[0]}
1
+ {"version":3,"sources":["../../../../src/build/webpack/loaders/next-metadata-route-loader.ts"],"sourcesContent":["import type webpack from 'webpack'\nimport fs from 'fs'\nimport path from 'path'\nimport { imageExtMimeTypeMap } from '../../../lib/mime-type'\nimport { getLoaderModuleNamedExports } from './utils'\nimport { installBindings } from '../../swc/install-bindings'\n\nfunction errorOnBadHandler(resourcePath: string) {\n return `\n if (typeof handler !== 'function') {\n throw new Error('Default export is missing in ${JSON.stringify(\n resourcePath\n )}')\n }\n `\n}\n\n/* re-export the userland route configs */\nasync function createReExportsCode(\n resourcePath: string,\n loaderContext: webpack.LoaderContext<any>\n) {\n const exportNames = await getLoaderModuleNamedExports(\n resourcePath,\n loaderContext\n )\n // Re-export configs but avoid conflicted exports\n const reExportNames = exportNames.filter(\n (name) =>\n name !== 'default' &&\n name !== 'generateSitemaps' &&\n name !== 'dynamicParams'\n )\n\n return reExportNames.length > 0\n ? `export { ${reExportNames.join(', ')} } from ${JSON.stringify(\n resourcePath\n )}\\n`\n : ''\n}\n\nconst CACHE_HEADERS = {\n NO_CACHE: 'no-cache, no-store',\n REVALIDATE: 'public, max-age=0, must-revalidate',\n}\n\nexport type MetadataRouteLoaderOptions = {\n // Using separate argument to avoid json being parsed and hit error\n // x-ref: https://github.com/vercel/next.js/pull/62615\n filePath: string\n isDynamicRouteExtension: '1' | '0'\n}\n\nexport function getFilenameAndExtension(resourcePath: string) {\n const filename = path.basename(resourcePath)\n const [name, ext] = filename.split('.', 2)\n return {\n name,\n ext,\n }\n}\n\nfunction getContentType(resourcePath: string) {\n let { name, ext } = getFilenameAndExtension(resourcePath)\n if (ext === 'jpg') ext = 'jpeg'\n\n if (name === 'favicon' && ext === 'ico') return 'image/x-icon'\n if (name === 'sitemap') return 'application/xml'\n if (name === 'robots') return 'text/plain'\n if (name === 'manifest') return 'application/manifest+json'\n\n if (ext === 'png' || ext === 'jpeg' || ext === 'ico' || ext === 'svg') {\n return imageExtMimeTypeMap[ext]\n }\n return 'text/plain'\n}\n\nasync function getStaticAssetRouteCode(\n resourcePath: string,\n fileBaseName: string\n) {\n const cache =\n process.env.NODE_ENV !== 'production'\n ? CACHE_HEADERS.NO_CACHE\n : CACHE_HEADERS.REVALIDATE\n\n const isTwitter = fileBaseName === 'twitter-image'\n const isOpenGraph = fileBaseName === 'opengraph-image'\n // Twitter image file size limit is 5MB.\n // General Open Graph image file size limit is 8MB.\n // x-ref: https://developer.x.com/en/docs/x-for-websites/cards/overview/summary\n // x-ref(facebook): https://developers.facebook.com/docs/sharing/webmasters/images\n const fileSizeLimit = isTwitter ? 5 : 8\n const imgName = isTwitter ? 'Twitter' : 'Open Graph'\n\n const code = `\\\n/* static asset route */\nimport { NextResponse } from 'next/server'\n\nconst contentType = ${JSON.stringify(getContentType(resourcePath))}\nconst buffer = Buffer.from(${JSON.stringify(\n (await fs.promises.readFile(resourcePath)).toString('base64')\n )}, 'base64'\n )\n\nif (${isTwitter || isOpenGraph}) {\n const fileSizeInMB = buffer.byteLength / 1024 / 1024\n if (fileSizeInMB > ${fileSizeLimit}) {\n throw new Error('File size for ${imgName} image ${JSON.stringify(resourcePath)} exceeds ${fileSizeLimit}MB. ' +\n \\`(Current: \\${fileSizeInMB.toFixed(2)}MB)\\n\\` +\n 'Read more: https://nextjs.org/docs/app/api-reference/file-conventions/metadata/opengraph-image#image-files-jpg-png-gif'\n )\n }\n}\n\nexport function GET() {\n return new NextResponse(buffer, {\n headers: {\n 'Content-Type': contentType,\n 'Cache-Control': ${JSON.stringify(cache)},\n },\n })\n}\n\nexport const dynamic = 'force-static'\n`\n return code\n}\n\nasync function getDynamicTextRouteCode(\n resourcePath: string,\n loaderContext: webpack.LoaderContext<any>\n) {\n return `\\\n/* dynamic asset route */\nimport { NextResponse } from 'next/server'\nimport handler from ${JSON.stringify(resourcePath)}\nimport { resolveRouteData } from 'next/dist/build/webpack/loaders/metadata/resolve-route-data'\n\nconst contentType = ${JSON.stringify(getContentType(resourcePath))}\nconst fileType = ${JSON.stringify(getFilenameAndExtension(resourcePath).name)}\n\n${errorOnBadHandler(resourcePath)}\n${await createReExportsCode(resourcePath, loaderContext)}\n\nexport async function GET() {\n const data = await handler()\n const content = resolveRouteData(data, fileType)\n\n return new NextResponse(content, {\n headers: {\n 'Content-Type': contentType,\n 'Cache-Control': ${JSON.stringify(CACHE_HEADERS.REVALIDATE)},\n },\n })\n}\n`\n}\n\nasync function getDynamicImageRouteCode(\n resourcePath: string,\n loaderContext: webpack.LoaderContext<any>\n) {\n return `\\\n/* dynamic image route with generateImageMetadata */\nimport { NextResponse } from 'next/server'\nimport { default as handler, generateImageMetadata } from ${JSON.stringify(resourcePath)}\n\n${errorOnBadHandler(resourcePath)}\n${await createReExportsCode(resourcePath, loaderContext)}\n\nexport async function GET(_, ctx) {\n const paramsPromise = ctx.params\n const idPromise = paramsPromise.then(params => params?.__metadata_id__)\n const restParamsPromise = paramsPromise.then(params => {\n if (!params) return undefined\n const { __metadata_id__, ...rest } = params\n return rest\n })\n\n const restParams = await restParamsPromise\n const __metadata_id__ = await idPromise\n const imageMetadata = await generateImageMetadata({ params: restParams })\n const id = imageMetadata.find((item) => {\n if (item?.id == null) {\n throw new Error('id property is required for every item returned from generateImageMetadata')\n }\n\n return item.id.toString() === __metadata_id__\n })?.id\n\n if (id == null) {\n return new NextResponse('Not Found', {\n status: 404,\n })\n }\n\n return handler({ params: restParamsPromise, id: idPromise })\n}\n\nexport async function generateStaticParams({ params }) {\n const imageMetadata = await generateImageMetadata({ params })\n const staticParams = []\n\n for (const item of imageMetadata) {\n if (item?.id == null) {\n throw new Error('id property is required for every item returned from generateImageMetadata')\n }\n staticParams.push({ __metadata_id__: item.id.toString() })\n }\n return staticParams\n}\n`\n}\n\nasync function getSingleImageRouteCode(\n resourcePath: string,\n loaderContext: webpack.LoaderContext<any>\n) {\n return `\\\n/* dynamic image route without generateImageMetadata */\nimport { NextResponse } from 'next/server'\nimport { default as handler } from ${JSON.stringify(resourcePath)}\n\n${errorOnBadHandler(resourcePath)}\n${await createReExportsCode(resourcePath, loaderContext)}\n\nexport async function GET(_, ctx) {\n return handler({ params: ctx.params })\n}\n`\n}\n\n// <metadata-image>/[id]/route.js\nasync function getImageRouteCode(\n resourcePath: string,\n loaderContext: webpack.LoaderContext<any>\n) {\n const exportNames = await getLoaderModuleNamedExports(\n resourcePath,\n loaderContext\n )\n\n const hasGenerateParamsExport = exportNames.includes('generateImageMetadata')\n\n if (hasGenerateParamsExport) {\n return getDynamicImageRouteCode(resourcePath, loaderContext)\n } else {\n return getSingleImageRouteCode(resourcePath, loaderContext)\n }\n}\n\nasync function getSingleSitemapRouteCode(\n resourcePath: string,\n loaderContext: webpack.LoaderContext<any>\n) {\n return `\\\n/* single sitemap route */\nimport { NextResponse } from 'next/server'\nimport { default as handler } from ${JSON.stringify(resourcePath)}\nimport { resolveRouteData } from 'next/dist/build/webpack/loaders/metadata/resolve-route-data'\n\nconst contentType = ${JSON.stringify(getContentType(resourcePath))}\nconst fileType = ${JSON.stringify(getFilenameAndExtension(resourcePath).name)}\n\n${errorOnBadHandler(resourcePath)}\n${await createReExportsCode(resourcePath, loaderContext)}\n\nexport async function GET() {\n const data = await handler()\n const content = resolveRouteData(data, fileType)\n\n return new NextResponse(content, {\n headers: {\n 'Content-Type': contentType,\n 'Cache-Control': ${JSON.stringify(CACHE_HEADERS.REVALIDATE)},\n },\n })\n}\n`\n}\n\nasync function getDynamicSitemapRouteCode(\n resourcePath: string,\n loaderContext: webpack.LoaderContext<any>\n) {\n const code = `\\\n/* dynamic sitemap route with generateSitemaps */\nimport { NextResponse } from 'next/server'\nimport { default as handler, generateSitemaps } from ${JSON.stringify(resourcePath)}\nimport { resolveRouteData } from 'next/dist/build/webpack/loaders/metadata/resolve-route-data'\n\nconst contentType = ${JSON.stringify(getContentType(resourcePath))}\nconst fileType = ${JSON.stringify(getFilenameAndExtension(resourcePath).name)}\n\n${errorOnBadHandler(resourcePath)}\n${await createReExportsCode(resourcePath, loaderContext)}\n\nexport async function GET(_, ctx) {\n const paramsPromise = ctx.params\n const idPromise = paramsPromise.then(params => params?.__metadata_id__)\n\n const id = await idPromise\n const hasXmlExtension = id ? id.endsWith('.xml') : false\n const sitemaps = await generateSitemaps()\n let foundId\n for (const item of sitemaps) {\n if (item?.id == null) {\n throw new Error('id property is required for every item returned from generateSitemaps')\n }\n\n const baseId = id && hasXmlExtension ? id.slice(0, -4) : undefined\n if (item.id.toString() === baseId) {\n foundId = item.id\n }\n }\n if (foundId == null) {\n return new NextResponse('Not Found', {\n status: 404,\n })\n }\n\n const targetIdPromise = idPromise.then(id => {\n const hasXmlExtension = id ? id.endsWith('.xml') : false\n return id && hasXmlExtension ? id.slice(0, -4) : undefined\n })\n const data = await handler({ id: targetIdPromise })\n const content = resolveRouteData(data, fileType)\n\n return new NextResponse(content, {\n headers: {\n 'Content-Type': contentType,\n 'Cache-Control': ${JSON.stringify(CACHE_HEADERS.REVALIDATE)},\n },\n })\n}\n\nexport async function generateStaticParams() {\n const sitemaps = await generateSitemaps()\n const params = []\n\n for (const item of sitemaps) {\n if (item?.id == null) {\n throw new Error('id property is required for every item returned from generateSitemaps')\n }\n params.push({ __metadata_id__: item.id.toString() + '.xml' })\n }\n return params\n}\n`\n return code\n}\n\n// <metadata-sitemap>/[id]/route.js\nasync function getSitemapRouteCode(\n resourcePath: string,\n loaderContext: webpack.LoaderContext<any>\n) {\n const exportNames = await getLoaderModuleNamedExports(\n resourcePath,\n loaderContext\n )\n\n const hasGenerateSitemaps = exportNames.includes('generateSitemaps')\n\n if (hasGenerateSitemaps) {\n return getDynamicSitemapRouteCode(resourcePath, loaderContext)\n } else {\n return getSingleSitemapRouteCode(resourcePath, loaderContext)\n }\n}\n\n// When it's static route, it could be favicon.ico, sitemap.xml, robots.txt etc.\n// TODO-METADATA: improve the cache control strategy\nconst nextMetadataRouterLoader: webpack.LoaderDefinitionFunction<MetadataRouteLoaderOptions> =\n async function () {\n // Install bindings early so they are definitely available to the loader.\n // When run by webpack in next this is already done with correct configuration so this is a no-op.\n // In turbopack loaders are run in a subprocess so it may or may not be done.\n await installBindings()\n const { isDynamicRouteExtension, filePath } = this.getOptions()\n const { name: fileBaseName } = getFilenameAndExtension(filePath)\n this.addDependency(filePath)\n\n let code = ''\n if (isDynamicRouteExtension === '1') {\n if (fileBaseName === 'robots' || fileBaseName === 'manifest') {\n code = await getDynamicTextRouteCode(filePath, this)\n } else if (fileBaseName === 'sitemap') {\n code = await getSitemapRouteCode(filePath, this)\n } else {\n code = await getImageRouteCode(filePath, this)\n }\n } else {\n code = await getStaticAssetRouteCode(filePath, fileBaseName)\n }\n\n return code\n }\n\nexport default nextMetadataRouterLoader\n"],"names":["getFilenameAndExtension","errorOnBadHandler","resourcePath","JSON","stringify","createReExportsCode","loaderContext","exportNames","getLoaderModuleNamedExports","reExportNames","filter","name","length","join","CACHE_HEADERS","NO_CACHE","REVALIDATE","filename","path","basename","ext","split","getContentType","imageExtMimeTypeMap","getStaticAssetRouteCode","fileBaseName","cache","process","env","NODE_ENV","isTwitter","isOpenGraph","fileSizeLimit","imgName","code","fs","promises","readFile","toString","getDynamicTextRouteCode","getDynamicImageRouteCode","getSingleImageRouteCode","getImageRouteCode","hasGenerateParamsExport","includes","getSingleSitemapRouteCode","getDynamicSitemapRouteCode","getSitemapRouteCode","hasGenerateSitemaps","nextMetadataRouterLoader","installBindings","isDynamicRouteExtension","filePath","getOptions","addDependency"],"mappings":";;;;;;;;;;;;;;;IAgZA,OAAuC;eAAvC;;IA3VgBA,uBAAuB;eAAvBA;;;2DApDD;6DACE;0BACmB;uBACQ;iCACZ;;;;;;AAEhC,SAASC,kBAAkBC,YAAoB;IAC7C,OAAO,CAAC;;kDAEwC,EAAEC,KAAKC,SAAS,CAC5DF,cACA;;EAEJ,CAAC;AACH;AAEA,wCAAwC,GACxC,eAAeG,oBACbH,YAAoB,EACpBI,aAAyC;IAEzC,MAAMC,cAAc,MAAMC,IAAAA,kCAA2B,EACnDN,cACAI;IAEF,iDAAiD;IACjD,MAAMG,gBAAgBF,YAAYG,MAAM,CACtC,CAACC,OACCA,SAAS,aACTA,SAAS,sBACTA,SAAS;IAGb,OAAOF,cAAcG,MAAM,GAAG,IAC1B,CAAC,SAAS,EAAEH,cAAcI,IAAI,CAAC,MAAM,QAAQ,EAAEV,KAAKC,SAAS,CAC3DF,cACA,EAAE,CAAC,GACL;AACN;AAEA,MAAMY,gBAAgB;IACpBC,UAAU;IACVC,YAAY;AACd;AASO,SAAShB,wBAAwBE,YAAoB;IAC1D,MAAMe,WAAWC,aAAI,CAACC,QAAQ,CAACjB;IAC/B,MAAM,CAACS,MAAMS,IAAI,GAAGH,SAASI,KAAK,CAAC,KAAK;IACxC,OAAO;QACLV;QACAS;IACF;AACF;AAEA,SAASE,eAAepB,YAAoB;IAC1C,IAAI,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