Running on Client vs Server
A Race Platform plugin is a single TypeScript bundle that runs identically in two runtimes. This page explains how that's guaranteed, what's wired today, and what's coming.
The two runtimes
| Runtime | Where | Engine | Adapter |
|---|---|---|---|
| Server | apps/api (Node locally / Cloudflare Workers in prod) | V8 isolates | NodeRuntime in @race/plugin-sdk |
| Client | apps/client (Flutter on any platform) | QuickJS | flutter_js package |
Both runtimes consume the same module.exports-shaped bundle.
How parity is enforced
packages/plugin-sdk/tests/parity.test.ts is a vitest suite that:
- Loads the rolling-avg-rpm bundle once
- Runs it under
NodeRuntimewith a synthetic lap context - Runs it under a QuickJS shim with the same input
- Asserts the outputs are bit-identical
The parity test is part of pnpm test and runs on every change to
the SDK or the example plugins. If a divergence creeps in, the
test breaks the build.