entries.d.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import type { NextConfigComplete } from '../server/config-shared';
  2. import type { webpack } from 'next/dist/compiled/webpack/webpack';
  3. import type { MiddlewareConfig } from './analysis/get-page-static-info';
  4. import type { LoadedEnvFiles } from '@next/env';
  5. import { CompilerNameValues } from '../shared/lib/constants';
  6. import { __ApiPreviewProps } from '../server/api-utils';
  7. import { ServerRuntime } from '../types';
  8. declare type ObjectValue<T> = T extends {
  9. [key: string]: infer V;
  10. } ? V : never;
  11. /**
  12. * For a given page path removes the provided extensions.
  13. */
  14. export declare function getPageFromPath(pagePath: string, pageExtensions: string[]): string;
  15. export declare function createPagesMapping({ isDev, pageExtensions, pagePaths, pagesType, pagesDir, }: {
  16. isDev: boolean;
  17. pageExtensions: string[];
  18. pagePaths: string[];
  19. pagesType: 'pages' | 'root' | 'app';
  20. pagesDir: string | undefined;
  21. }): {
  22. [page: string]: string;
  23. };
  24. interface CreateEntrypointsParams {
  25. buildId: string;
  26. config: NextConfigComplete;
  27. envFiles: LoadedEnvFiles;
  28. isDev?: boolean;
  29. pages: {
  30. [page: string]: string;
  31. };
  32. pagesDir?: string;
  33. previewMode: __ApiPreviewProps;
  34. rootDir: string;
  35. rootPaths?: Record<string, string>;
  36. target: 'server' | 'serverless' | 'experimental-serverless-trace';
  37. appDir?: string;
  38. appPaths?: Record<string, string>;
  39. pageExtensions: string[];
  40. }
  41. export declare function getEdgeServerEntry(opts: {
  42. rootDir: string;
  43. absolutePagePath: string;
  44. buildId: string;
  45. bundlePath: string;
  46. config: NextConfigComplete;
  47. isDev: boolean;
  48. isServerComponent: boolean;
  49. page: string;
  50. pages: {
  51. [page: string]: string;
  52. };
  53. middleware?: Partial<MiddlewareConfig>;
  54. pagesType?: 'app' | 'pages' | 'root';
  55. appDirLoader?: string;
  56. }): string | {
  57. import: string;
  58. layer: string | undefined;
  59. };
  60. export declare function getAppEntry(opts: {
  61. name: string;
  62. pagePath: string;
  63. appDir: string;
  64. appPaths: string[] | null;
  65. pageExtensions: string[];
  66. }): {
  67. import: string;
  68. layer: string;
  69. };
  70. export declare function getServerlessEntry(opts: {
  71. absolutePagePath: string;
  72. buildId: string;
  73. config: NextConfigComplete;
  74. envFiles: LoadedEnvFiles;
  75. page: string;
  76. previewMode: __ApiPreviewProps;
  77. pages: {
  78. [page: string]: string;
  79. };
  80. }): ObjectValue<webpack.EntryObject>;
  81. export declare function getClientEntry(opts: {
  82. absolutePagePath: string;
  83. page: string;
  84. }): string | string[];
  85. export declare function runDependingOnPageType<T>(params: {
  86. onClient: () => T;
  87. onEdgeServer: () => T;
  88. onServer: () => T;
  89. page: string;
  90. pageRuntime: ServerRuntime;
  91. }): Promise<void>;
  92. export declare function createEntrypoints(params: CreateEntrypointsParams): Promise<{
  93. client: webpack.EntryObject;
  94. server: webpack.EntryObject;
  95. edgeServer: webpack.EntryObject;
  96. middlewareMatchers: undefined;
  97. }>;
  98. export declare function finalizeEntrypoint({ name, compilerType, value, isServerComponent, appDir, }: {
  99. compilerType?: CompilerNameValues;
  100. name: string;
  101. value: ObjectValue<webpack.EntryObject>;
  102. isServerComponent?: boolean;
  103. appDir?: boolean;
  104. }): ObjectValue<webpack.EntryObject>;
  105. export {};