rwsdk
Version:
Build fast, server-driven webapps on Cloudflare with SSR, RSC, and realtime
32 lines (31 loc) • 1.37 kB
text/typescript
/**
* Find the number of common ancestor segments between two absolute paths.
* Returns the count of shared directory segments from the root.
*/
export declare function findCommonAncestorDepth(path1: string, path2: string): number;
/**
* Normalize a module path to a consistent form.
* Returns slash-prefixed paths for files within project root,
* or absolute paths for external files.
*
* Examples:
* /Users/justin/my-app/src/page.ts → /src/page.ts
* ../shared/utils.ts → /Users/justin/shared/utils.ts
* /src/page.ts (Vite-style) → /src/page.ts
* node_modules/foo/index.js → /node_modules/foo/index.js
*
* With { absolute: true }:
* /Users/justin/my-app/src/page.ts → /Users/justin/my-app/src/page.ts
*
* With { isViteStyle: false }:
* /opt/tools/logger.ts → /opt/tools/logger.ts (treated as external)
* /src/page.tsx → /src/page.tsx (treated as external)
*
* With { isViteStyle: true }:
* /opt/tools/logger.ts → /opt/tools/logger.ts (resolved as Vite-style)
* /src/page.tsx, { absolute: true } → /Users/justin/my-app/src/page.tsx
*/
export declare function normalizeModulePath(modulePath: string, projectRootDir: string, options?: {
absolute?: boolean;
isViteStyle?: boolean;
}): string;