Bring the power of AffineScript to your Vite-powered frontend.
AffineScript-Vite is the official Vite plugin for integrating AffineScript into your web applications. It handles the compilation of .as and .affine files into optimized WebAssembly and JavaScript, enabling near-instant Hot Module Replacement (HMR) for your game logic.
Vite provides the fastest developer experience for the web. AffineScript provides the most correct developer experience for game logic. Together, they enable a "Fast & Safe" workflow:
-
✅ Near-Instant HMR: Changes to your
.asfiles are compiled and reloaded in milliseconds. -
✅ Type-Safe Frontend: Catch protocol bugs, resource leaks, and invalid state transitions before they hit the browser.
-
✅ Optimized WASM: Leverage AffineScript’s native WASM backend for high-performance game loops.
-
✅ Zero Configuration: Sensible defaults for the hyperpolymath ecosystem (Gossamer, Burble).
# Using Deno (Recommended)
deno add npm:affinescript-vite
# Using Bun
bun add affinescript-vite
# Using NPM
npm install affinescript-viteAdd the plugin to your vite.config.js:
import { defineConfig } from 'vite';
import affinePlugin from 'affinescript-vite';
export default defineConfig({
plugins: [
affinePlugin({
// Optional: path to your affinescript compiler binary
compilerPath: 'affinescript'
})
]
});Then import your AffineScript files directly in your JavaScript or ReScript:
import gameLogic from './logic.as';
// gameLogic is now available as a WASM module or JS bridge
gameLogic.init();| Option | Default | Description |
|---|---|---|
|
|
The path to the AffineScript compiler executable. |
|
|
Whether to compile to WebAssembly (true) or JavaScript (false). |
|
|
Enforce strict affine and quantity checks during dev. |