The best way to control Claude Code, Codex and more from any computer or phone

main
ts 18 lines 728 Bytes
Raw
1 import { join } from "node:path";
2 import { pathToFileURL } from "node:url";
3 import * as Effect from "effect/Effect";
4 import { ModuleLoadError, resolveProjectPackageDirectory } from "../core/Loader.ts";
5
6 /** Vinext exposes import-only entrypoints that require.resolve cannot resolve. */
7 export const loadVinextModule = <T>(root: string, file: string) =>
8 resolveProjectPackageDirectory(root, "vinext").pipe(
9 Effect.flatMap((directory) =>
10 Effect.tryPromise({
11 try: () =>
12 import(
13 /* @vite-ignore */ pathToFileURL(join(directory, "dist", file)).href
14 ) as Promise<T>,
15 catch: (cause) => new ModuleLoadError({ root, specifier: `vinext/${file}`, cause }),
16 }),
17 ),
18 );