Skip to content

Commit e554d7e

Browse files
committed
fix: clean up vite hacks
1 parent cef229d commit e554d7e

File tree

4 files changed

+3
-57
lines changed

4 files changed

+3
-57
lines changed

examples/sandbox-vercel/src/fdb-tuple-shim.mjs

Lines changed: 0 additions & 5 deletions
This file was deleted.

examples/sandbox/src/fdb-tuple-shim.mjs

Lines changed: 0 additions & 5 deletions
This file was deleted.

examples/sandbox/vite.config.ts

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rivetkit-typescript/packages/rivetkit/src/actor/definition.ts

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import type { RegistryConfig } from "@/registry/config";
2-
import { getRequireFn } from "@/utils/node";
32
import type { Actions, ActorConfig } from "./config";
43
import type { AnyDatabaseProvider } from "./database";
5-
import type { ActorInstance } from "./instance/mod";
4+
import { ActorInstance } from "./instance/mod";
65

76
export type AnyActorDefinition = ActorDefinition<
87
any,
@@ -33,48 +32,11 @@ export class ActorDefinition<
3332
return this.#config;
3433
}
3534

36-
async instantiate(): Promise<ActorInstance<S, CP, CS, V, I, DB>> {
37-
// Lazy import to avoid pulling server-only dependencies (traces, fdb-tuple, etc.)
38-
// into browser bundles. This method is only called on the server.
39-
// const requireFn = getRequireFn();
40-
// if (!requireFn) {
41-
// throw new Error(
42-
// "ActorDefinition.instantiate requires a Node.js environment",
43-
// );
44-
// }
45-
46-
try {
47-
const { ActorInstance: ActorInstanceClass } = await import(
48-
"./instance/mod"
49-
);
50-
return new ActorInstanceClass(this.#config);
51-
} catch (error) {
52-
if (!isInstanceModuleNotFound(error)) {
53-
throw error;
54-
}
55-
56-
try {
57-
// In tests, register tsx so require() can resolve .ts files.
58-
await getRequireFn()("tsx/cjs");
59-
} catch {
60-
throw error;
61-
}
62-
63-
const { ActorInstance: ActorInstanceClass } = await import(
64-
"./instance/mod"
65-
);
66-
return new ActorInstanceClass(this.#config);
67-
}
35+
instantiate(): ActorInstance<S, CP, CS, V, I, DB> {
36+
return new ActorInstance(this.#config);
6837
}
6938
}
7039

71-
function isInstanceModuleNotFound(error: unknown): boolean {
72-
if (!error || typeof error !== "object") return false;
73-
const err = error as { code?: string; message?: string };
74-
if (err.code !== "MODULE_NOT_FOUND") return false;
75-
return (err.message ?? "").includes("./instance/mod");
76-
}
77-
7840
export function lookupInRegistry(
7941
config: RegistryConfig,
8042
name: string,

0 commit comments

Comments
 (0)