Dev & Publish
Build with the native SpacetimeDB CLI. The module entry imports the host-only compiler, imports server polyfills as a side effect, and exports the compiled schema.
import * as Stdb from "effect-spacetimedb"import { build } from "effect-spacetimedb/server-compiler"
const Module = Stdb.StdbModule.make("app")
export const compiled = build(Module, [])export const ModuleExports = compiled.exportGroup()export default compiled.schemaPublish a built bundle with the native SpacetimeDB CLI rather than a placeholder module-path publish command:
spacetime build --module-path <moduleDir>spacetime publish --js-path <moduleDir>/dist/bundle.js --server <url> <dbName>The upstream spacetime dev command needs the full module path, server,
database, identity, and publish settings for your local environment; see the
SpacetimeDB CLI docs for the
dev and publish flags.
Programmatic Dev Servers
Section titled “Programmatic Dev Servers”effect-spacetimedb/dev-server is for tests and tools that need a temporary
local spacetimedb-standalone plus a published prebuilt bundle. It does not
build the module or generate clients.
import * as Effect from "effect/Effect"import { makeDevServer } from "effect-spacetimedb/dev-server"
const program = Effect.gen(function* () { const runtime = yield* makeDevServer({ bundlePath: "dist/bundle.js", dbNamePrefix: "example", })
yield* Effect.logInfo( `published ${runtime.databaseName} at ${runtime.baseUrl}`, )
return runtime})The generated server bundle must include
effect-spacetimedb/server-compiler; native spacetime build preserves its
side-effectful server polyfill import. Off-host tests that import server modules
also need the spacetime:sys stub from
effect-spacetimedb/testing/spacetime-sys.
effect-spacetimedb controls the authored TypeScript contract and compiled module exports; SpacetimeDB still controls local dev, publish, runtime storage, and the generated client runtime. The optional quarantined codegen path bundles native output without replacing the native generator.
Not affiliated with SpacetimeDB (Clockwork Laboratories) or Effect (Effectful Technologies).