diff --git a/examples/sandbox-vercel/src/fdb-tuple-shim.mjs b/examples/sandbox-vercel/src/fdb-tuple-shim.mjs deleted file mode 100644 index bc05d17a98..0000000000 --- a/examples/sandbox-vercel/src/fdb-tuple-shim.mjs +++ /dev/null @@ -1,5 +0,0 @@ -import { createRequire } from "node:module"; -const require = createRequire(import.meta.url); -const fdbTuple = require("fdb-tuple"); -export const { concat2, unboundVersionstamp, rawRange, pack, packUnboundVersionstamp, name, unpack, range, bakeVersionstamp } = fdbTuple; -export default fdbTuple; diff --git a/examples/sandbox/src/fdb-tuple-shim.mjs b/examples/sandbox/src/fdb-tuple-shim.mjs deleted file mode 100644 index bc05d17a98..0000000000 --- a/examples/sandbox/src/fdb-tuple-shim.mjs +++ /dev/null @@ -1,5 +0,0 @@ -import { createRequire } from "node:module"; -const require = createRequire(import.meta.url); -const fdbTuple = require("fdb-tuple"); -export const { concat2, unboundVersionstamp, rawRange, pack, packUnboundVersionstamp, name, unpack, range, bakeVersionstamp } = fdbTuple; -export default fdbTuple; diff --git a/examples/sandbox/vite.config.ts b/examples/sandbox/vite.config.ts index c87e296970..fabe9b5525 100644 --- a/examples/sandbox/vite.config.ts +++ b/examples/sandbox/vite.config.ts @@ -1,13 +1,7 @@ -import { resolve } from "node:path"; import react from "@vitejs/plugin-react"; import { defineConfig } from "vite"; import srvx from "vite-plugin-srvx"; export default defineConfig({ plugins: [react(), ...srvx({ entry: "src/server.ts" })], - resolve: { - alias: { - "fdb-tuple": resolve(import.meta.dirname, "src/fdb-tuple-shim.mjs"), - }, - }, }); diff --git a/rivetkit-typescript/packages/rivetkit/src/actor/definition.ts b/rivetkit-typescript/packages/rivetkit/src/actor/definition.ts index c85f95e017..53a2fc3111 100644 --- a/rivetkit-typescript/packages/rivetkit/src/actor/definition.ts +++ b/rivetkit-typescript/packages/rivetkit/src/actor/definition.ts @@ -1,8 +1,7 @@ import type { RegistryConfig } from "@/registry/config"; -import { getRequireFn } from "@/utils/node"; import type { Actions, ActorConfig } from "./config"; import type { AnyDatabaseProvider } from "./database"; -import type { ActorInstance } from "./instance/mod"; +import { ActorInstance } from "./instance/mod"; export type AnyActorDefinition = ActorDefinition< any, @@ -33,48 +32,11 @@ export class ActorDefinition< return this.#config; } - async instantiate(): Promise> { - // Lazy import to avoid pulling server-only dependencies (traces, fdb-tuple, etc.) - // into browser bundles. This method is only called on the server. - // const requireFn = getRequireFn(); - // if (!requireFn) { - // throw new Error( - // "ActorDefinition.instantiate requires a Node.js environment", - // ); - // } - - try { - const { ActorInstance: ActorInstanceClass } = await import( - "./instance/mod" - ); - return new ActorInstanceClass(this.#config); - } catch (error) { - if (!isInstanceModuleNotFound(error)) { - throw error; - } - - try { - // In tests, register tsx so require() can resolve .ts files. - await getRequireFn()("tsx/cjs"); - } catch { - throw error; - } - - const { ActorInstance: ActorInstanceClass } = await import( - "./instance/mod" - ); - return new ActorInstanceClass(this.#config); - } + instantiate(): ActorInstance { + return new ActorInstance(this.#config); } } -function isInstanceModuleNotFound(error: unknown): boolean { - if (!error || typeof error !== "object") return false; - const err = error as { code?: string; message?: string }; - if (err.code !== "MODULE_NOT_FOUND") return false; - return (err.message ?? "").includes("./instance/mod"); -} - export function lookupInRegistry( config: RegistryConfig, name: string,