Skip to content

hyperpolymath/affinescript-vite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

AffineScript-Vite

License: PMPL-1.0-or-later Component Readiness Grade: C Vite Plugin AffineScript

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.

Why AffineScript with Vite?

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 .as files 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).

Installation

# Using Deno (Recommended)
deno add npm:affinescript-vite

# Using Bun
bun add affinescript-vite

# Using NPM
npm install affinescript-vite

Usage

Add 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();

Configuration Options

Option Default Description

compilerPath

'affinescript'

The path to the AffineScript compiler executable.

wasm

true

Whether to compile to WebAssembly (true) or JavaScript (false).

strict

true

Enforce strict affine and quantity checks during dev.

License

This project is licensed under AGPL-3.0-or-later.

About

Vite plugin for AffineScript — hot-reload and bundling support for AffineScript projects

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors