UNPKG

rwsdk

Version:

Build fast, server-driven webapps on Cloudflare with SSR, RSC, and realtime

15 lines (14 loc) 571 B
import { normalizeModulePath } from "./normalizeModulePath.mjs"; /** * Resolves a module ID consistently across client and server transformations. * For node modules, uses the /rwsdk:kind/relativePath format. * For regular files, uses the raw ID. */ export function resolveModuleId(id, kind, projectRootDir) { const modulePath = normalizeModulePath(projectRootDir, id); return modulePath.includes("node_modules") ? modulePath.includes("__rwsdk_kind") ? modulePath : `${modulePath}?__rwsdk_kind=${kind}` : modulePath; }