Skip to content

feat: ship rive-gen-types as a bin - #361

Merged
mfazekas merged 1 commit into
feat/type-safe-riv-schema-2from
feat/rive-gen-types-bin
Jul 30, 2026
Merged

feat: ship rive-gen-types as a bin#361
mfazekas merged 1 commit into
feat/type-safe-riv-schema-2from
feat/rive-gen-types-bin

Conversation

@mfazekas

Copy link
Copy Markdown
Collaborator

Stacked on #352. Implements the packaging decision from the review discussion: the schema generator ships inside @rive-app/react-native as a bin, with @rive-app/canvas as an optional (dev-time) peer dependency.

Usage in an app:

  1. yarn add -D @rive-app/canvas (one-time; the CLI prints this exact instruction if missing)
  2. npx rive-gen-types assets/rive/my.riv (or --all assets/rive) — writes my.riv.d.ts next to the asset

The published tool is plain compiled CommonJS (esbuild, target node20, built during prepare into lib/cli/, launched via a committed cli/rive-gen-types.js wrapper) — no Bun, no TypeScript runtime, no wasm download for users who don't generate types.

Verified end to end with npm pack + install into a fresh project: missing-canvas error path (clear hint, exit 1) and successful generation producing the expected .riv.d.ts.

Longer-term home (separate @rive-app/ts-schema-generator package or the future Rive CLI) intentionally stays open — migrating is a deprecation notice in a future release.

Users can now run the schema generator directly from the installed
library — npx rive-gen-types assets/rive — per the packaging discussion
in #352. @rive-app/canvas (the ~5MB wasm introspection dependency) is an
optional peer: it is only needed at codegen time, so users who generate
types add it as a devDependency (the CLI prints exactly that instruction
when it is missing) and everyone else never downloads it.

Mechanics: the generator is compiled to plain CommonJS (esbuild, target
node20) into lib/cli/ during prepare, launched by a committed shebang
wrapper in cli/ — so the published tool has no Bun or TypeScript runtime
requirement. @rive-app/canvas moves to a lazy dynamic import with a
friendly error, and runCli() is exported for the launcher.

Verified end to end: npm pack, install into a fresh project, npx
rive-gen-types without canvas (clear install hint, exit 1) and with it
(correct .riv.d.ts generated).

The longer-term home (separate package / future Rive CLI integration)
stays open; migrating later is a deprecation notice away.
@mfazekas
mfazekas force-pushed the feat/rive-gen-types-bin branch from fdc6f8e to f43b036 Compare July 30, 2026 04:54
@mfazekas
mfazekas merged commit c7ba677 into feat/type-safe-riv-schema-2 Jul 30, 2026
22 checks passed
@mfazekas
mfazekas deleted the feat/rive-gen-types-bin branch July 30, 2026 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant