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

main
mjs 43 lines 1.69 KB
Raw
1 import { fileURLToPath } from "node:url";
2 // Minimal manual runner for the hmr dev mode: invokes the Framework service
3 // directly (no playwright), starts `next dev` with proxied bindings, probes
4 // three routes, and exits. Useful for debugging test/hmr.test.ts failures.
5 // Run with: node scripts/hmr-repro.mjs
6 import { Text } from "@alchemy.run/cloudflare-runtime/core/bindings";
7 import { Framework } from "@alchemy.run/frontend-frameworks/core";
8 import nextjsFramework from "@alchemy.run/frontend-frameworks/nextjs";
9 import * as NodeServices from "@effect/platform-node/NodeServices";
10 import * as Exit from "effect/Exit";
11 import * as Layer from "effect/Layer";
12 import * as ManagedRuntime from "effect/ManagedRuntime";
13 import * as Scope from "effect/Scope";
14
15 const root = fileURLToPath(new URL("..", import.meta.url));
16
17 const layer = nextjsFramework({
18 root,
19 dev: { mode: "hmr" },
20 vite: {
21 compatibilityDate: "2026-05-12",
22 compatibilityFlags: ["nodejs_compat", "global_fetch_strictly_public"],
23 worker: {
24 name: "fixtures-nextjs-hmr",
25 bindings: [Text.local("TEST_TEXT", "hello-from-binding")],
26 },
27 },
28 }).pipe(Layer.provideMerge(NodeServices.layer));
29
30 const runtime = ManagedRuntime.make(layer);
31 const scope = Scope.makeUnsafe();
32 const server = await runtime.runPromise(
33 Framework.use((f) => f.dev({ root })).pipe(Scope.provide(scope)),
34 );
35 console.log("dev server:", server.url);
36 for (const path of ["/", "/hmr-probe", "/api/binding"]) {
37 const res = await fetch(new URL(path, server.url));
38 const body = await res.text();
39 console.log(path, res.status, body.slice(0, 300).replace(/\n/g, " "));
40 }
41 await runtime.runPromise(Scope.close(scope, Exit.void));
42 await runtime.dispose();
43 process.exit(0);