get-page-static-info.d.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import type { NextConfig } from '../../server/config-shared';
  2. import type { RouteHas } from '../../lib/load-custom-routes';
  3. import { ServerRuntime } from 'next/types';
  4. export interface MiddlewareConfig {
  5. matchers: MiddlewareMatcher[];
  6. unstable_allowDynamicGlobs: string[];
  7. regions: string[] | string;
  8. }
  9. export interface MiddlewareMatcher {
  10. regexp: string;
  11. locale?: false;
  12. has?: RouteHas[];
  13. missing?: RouteHas[];
  14. }
  15. export interface PageStaticInfo {
  16. runtime?: ServerRuntime;
  17. ssg?: boolean;
  18. ssr?: boolean;
  19. rsc?: RSCModuleType;
  20. middleware?: Partial<MiddlewareConfig>;
  21. }
  22. export declare type RSCModuleType = 'server' | 'client';
  23. export declare function getRSCModuleType(source: string): RSCModuleType;
  24. /**
  25. * Receives a parsed AST from SWC and checks if it belongs to a module that
  26. * requires a runtime to be specified. Those are:
  27. * - Modules with `export function getStaticProps | getServerSideProps`
  28. * - Modules with `export { getStaticProps | getServerSideProps } <from ...>`
  29. */
  30. export declare function checkExports(swcAST: any): {
  31. ssr: boolean;
  32. ssg: boolean;
  33. };
  34. /**
  35. * For a given pageFilePath and nextConfig, if the config supports it, this
  36. * function will read the file and return the runtime that should be used.
  37. * It will look into the file content only if the page *requires* a runtime
  38. * to be specified, that is, when gSSP or gSP is used.
  39. * Related discussion: https://github.com/vercel/next.js/discussions/34179
  40. */
  41. export declare function getPageStaticInfo(params: {
  42. nextConfig: Partial<NextConfig>;
  43. pageFilePath: string;
  44. isDev?: boolean;
  45. page?: string;
  46. }): Promise<PageStaticInfo>;