@modern-js/utils
Version:
A Progressive React Framework for modern web development.
26 lines (25 loc) • 1.28 kB
TypeScript
/**
* Normalize a path so that route-component collection and `module.resource`
* comparison use the exact same form: resolve symlinks (best effort), make it
* absolute, and use POSIX separators. Used on both sides of the `test` match so
* Windows / symlink / mixed-separator paths still line up.
*/
export declare function normalizeModulePath(filePath: string): string;
export type RouteComponentFileCollection = {
/** Normalized absolute paths of resolved route component files. */
resolvedFiles: Set<string>;
/** `_component` specifiers that could not be mapped to a real file. */
unresolvedSpecifiers: string[];
};
/**
* Per-entry route component files, keyed by entry name. Collected by the router
* plugin from the FINAL routes and consumed (currently by stream SSR lazy
* compilation) to force route components eager.
*/
export type EagerRouteComponentFilesByEntry = Map<string, RouteComponentFileCollection>;
/**
* Walk the file-system route tree and collect the normalized absolute file
* paths of every route component, plus any `_component` specifiers that could
* not be resolved to a real file.
*/
export declare function collectRouteComponentFiles(routes: unknown, srcDirectory: string, srcAlias: string): RouteComponentFileCollection;