File size: 4,964 Bytes
fea495a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | import type ws from 'next/dist/compiled/ws';
import type { webpack } from 'next/dist/compiled/webpack/webpack';
import type { NextConfigComplete } from '../config-shared';
import type { CompilerNameValues } from '../../shared/lib/constants';
import type { RouteDefinition } from '../route-definitions/route-definition';
import type HotReloaderWebpack from './hot-reloader-webpack';
import { COMPILER_INDEXES } from '../../shared/lib/constants';
import { PAGE_TYPES } from '../../lib/page-types';
declare const COMPILER_KEYS: CompilerNameValues[];
/**
* format: {compiler type}@{page type}@{page path}
* e.g. client@pages@/index
* e.g. server@app@app/page
*
* This guarantees the uniqueness for each page, to avoid conflicts between app/ and pages/
*/
export declare function getEntryKey(compilerType: CompilerNameValues, pageBundleType: PAGE_TYPES, page: string): string;
export declare const ADDED: unique symbol;
export declare const BUILDING: unique symbol;
export declare const BUILT: unique symbol;
interface EntryType {
/**
* Tells if a page is scheduled to be disposed.
*/
dispose?: boolean;
/**
* Timestamp with the last time the page was active.
*/
lastActiveTime?: number;
/**
* Page build status.
*/
status?: typeof ADDED | typeof BUILDING | typeof BUILT;
/**
* Path to the page file relative to the dist folder with no extension.
* For example: `pages/about/index`
*/
bundlePath: string;
/**
* Webpack request to create a dependency for.
*/
request: string;
}
export declare const enum EntryTypes {
ENTRY = 0,
CHILD_ENTRY = 1
}
interface Entry extends EntryType {
type: EntryTypes.ENTRY;
/**
* The absolute page to the page file. Used for detecting if the file was removed. For example:
* `/Users/Rick/project/pages/about/index.js`
*/
absolutePagePath: string;
/**
* All parallel pages that match the same entry, for example:
* ['/parallel/@bar/nested/@a/page', '/parallel/@bar/nested/@b/page', '/parallel/@foo/nested/@a/page', '/parallel/@foo/nested/@b/page']
*/
appPaths: ReadonlyArray<string> | null;
}
interface ChildEntry extends EntryType {
type: EntryTypes.CHILD_ENTRY;
/**
* Which parent entries use this childEntry.
*/
parentEntries: Set<string>;
/**
* The absolute page to the entry file. Used for detecting if the file was removed. For example:
* `/Users/Rick/project/app/about/layout.js`
*/
absoluteEntryFilePath?: string;
}
declare const entriesMap: Map<string, {
/**
* The key composed of the compiler name and the page. For example:
* `edge-server/about`
*/
[entryName: string]: Entry | ChildEntry;
}>;
export declare const getEntries: (dir: string) => NonNullable<ReturnType<(typeof entriesMap)["get"]>>;
export declare const getInvalidator: (dir: string) => Invalidator | undefined;
declare class Invalidator {
private multiCompiler;
private building;
private rebuildAgain;
constructor(multiCompiler: webpack.MultiCompiler);
shouldRebuildAll(): boolean;
invalidate(compilerKeys?: typeof COMPILER_KEYS): void;
startBuilding(compilerKey: keyof typeof COMPILER_INDEXES): void;
doneBuilding(compilerKeys?: typeof COMPILER_KEYS): void;
willRebuild(compilerKey: keyof typeof COMPILER_INDEXES): boolean;
}
interface PagePathData {
filename: string;
bundlePath: string;
page: string;
}
/**
* Attempts to find a page file path from the given pages absolute directory,
* a page and allowed extensions. If the page can't be found it will throw an
* error. It defaults the `/_error` page to Next.js internal error page.
*
* @param rootDir Absolute path to the project root.
* @param page The page normalized (it will be denormalized).
* @param extensions Array of page extensions.
* @param pagesDir Absolute path to the pages folder with trailing `/pages`.
* @param appDir Absolute path to the app folder with trailing `/app`.
*/
export declare function findPagePathData(rootDir: string, page: string, extensions: string[], pagesDir: string | undefined, appDir: string | undefined, isGlobalNotFoundEnabled: boolean): Promise<PagePathData>;
export declare function onDemandEntryHandler({ hotReloader, maxInactiveAge, multiCompiler, nextConfig, pagesBufferLength, pagesDir, rootDir, appDir, }: {
hotReloader: HotReloaderWebpack;
maxInactiveAge: number;
multiCompiler: webpack.MultiCompiler;
nextConfig: NextConfigComplete;
pagesBufferLength: number;
pagesDir?: string;
rootDir: string;
appDir?: string;
}): {
ensurePage({ page, appPaths, definition, isApp, url, }: {
page: string;
appPaths?: ReadonlyArray<string> | null;
definition?: RouteDefinition;
isApp?: boolean;
url?: string;
}): Promise<void>;
onHMR(client: ws, getHmrServerError: () => Error | null): void;
};
export {};
|