on-demand-entry-handler.d.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import type ws from 'ws';
  2. import type { webpack } from 'next/dist/compiled/webpack/webpack';
  3. import type { NextConfigComplete } from '../config-shared';
  4. import { CompilerNameValues, COMPILER_INDEXES } from '../../shared/lib/constants';
  5. declare const COMPILER_KEYS: CompilerNameValues[];
  6. export declare const ADDED: unique symbol;
  7. export declare const BUILDING: unique symbol;
  8. export declare const BUILT: unique symbol;
  9. interface EntryType {
  10. /**
  11. * Tells if a page is scheduled to be disposed.
  12. */
  13. dispose?: boolean;
  14. /**
  15. * Timestamp with the last time the page was active.
  16. */
  17. lastActiveTime?: number;
  18. /**
  19. * Page build status.
  20. */
  21. status?: typeof ADDED | typeof BUILDING | typeof BUILT;
  22. /**
  23. * Path to the page file relative to the dist folder with no extension.
  24. * For example: `pages/about/index`
  25. */
  26. bundlePath: string;
  27. /**
  28. * Webpack request to create a dependency for.
  29. */
  30. request: string;
  31. }
  32. export declare const enum EntryTypes {
  33. ENTRY = 0,
  34. CHILD_ENTRY = 1
  35. }
  36. interface Entry extends EntryType {
  37. type: EntryTypes.ENTRY;
  38. /**
  39. * The absolute page to the page file. Used for detecting if the file was removed. For example:
  40. * `/Users/Rick/project/pages/about/index.js`
  41. */
  42. absolutePagePath: string;
  43. /**
  44. * All parallel pages that match the same entry, for example:
  45. * ['/parallel/@bar/nested/@a/page', '/parallel/@bar/nested/@b/page', '/parallel/@foo/nested/@a/page', '/parallel/@foo/nested/@b/page']
  46. */
  47. appPaths: string[] | null;
  48. }
  49. interface ChildEntry extends EntryType {
  50. type: EntryTypes.CHILD_ENTRY;
  51. /**
  52. * Which parent entries use this childEntry.
  53. */
  54. parentEntries: Set<string>;
  55. }
  56. export declare const entries: {
  57. /**
  58. * The key composed of the compiler name and the page. For example:
  59. * `edge-server/about`
  60. */
  61. [entryName: string]: Entry | ChildEntry;
  62. };
  63. export declare const getInvalidator: () => Invalidator;
  64. declare class Invalidator {
  65. private multiCompiler;
  66. private building;
  67. private rebuildAgain;
  68. constructor(multiCompiler: webpack.MultiCompiler);
  69. shouldRebuildAll(): boolean;
  70. invalidate(compilerKeys?: typeof COMPILER_KEYS): void;
  71. startBuilding(compilerKey: keyof typeof COMPILER_INDEXES): void;
  72. doneBuilding(): void;
  73. }
  74. export declare function onDemandEntryHandler({ maxInactiveAge, multiCompiler, nextConfig, pagesBufferLength, pagesDir, rootDir, appDir, }: {
  75. maxInactiveAge: number;
  76. multiCompiler: webpack.MultiCompiler;
  77. nextConfig: NextConfigComplete;
  78. pagesBufferLength: number;
  79. pagesDir?: string;
  80. rootDir: string;
  81. appDir?: string;
  82. }): {
  83. ensurePage({ page, clientOnly, appPaths, }: {
  84. page: string;
  85. clientOnly: boolean;
  86. appPaths?: string[] | null | undefined;
  87. }): Promise<void>;
  88. onHMR(client: ws): void;
  89. };
  90. export {};