Skip to content

Hot reload, storage & builds

vgai hot-reloads GameComponent code while the game runs, preserving live state. Two paths share the same engine mechanism:

  • Server HMR (npm run dev) — Vite transpiles, then the edit is applied via components.hotSwap() / session.hotReload().
  • In-browser transpile (packages/editor/src/browser-transpile.ts) — esbuild-wasm transpiles TS/TSX in a Web Worker, and bare imports of the registered runtime modulesthree, gsap, and @engine/ecs/game-component — are rewritten to blob-URL shims that re-export the live, already-running singletons (registerRuntimeModules in play-mode.ts). So the swapped class shares the same THREE and extends the same GameComponent as the running runtime; an import of an unregistered module throws rather than loading a second copy.

State survives because the prototype is swapped, not the instance.

Storage backends & the browser-first editor

Section titled “Storage backends & the browser-first editor”

The editor reads/writes through a StorageBackend (packages/editor/src/storage/): Opfs (browser OPFS), Fsa (File System Access API — a real on-disk folder), Mem (tests), and Http (the server-first /__editor/* backend). Selecting OPFS/FSA gives a browser-first, server-less editornpm run build:web produces a static editor that needs no Node.

CommandDoes
npm run validate-scenesvalidate .vscn.json against the component registry
npm run generate-schemaZod → JSON Schema (.vscn/.prefab)
npm run generate-engine-manifestengine-api.json/.md (phases + GameComponent)
web shipped; desktop/Steam and mobile wired but unproven
Build targets and their status.
  • Web (shipped): npm run build:web produces a static bundle zipped to vgai-web.zip (itch.io-ready). The in-editor Build panel (/__editor/export) runs this for you.