0.0.2 • Published 2 years ago

altv-esbuild-rust-wasm v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

altv-esbuild-rust-wasm

esbuild plugin that helps you to use rust with wasm in alt:V on serverside and clientside.

Requirement for building rust to wasm is installed wasm-pack.

How to use?

Example resource: link.

Install package via npm

npm i altv-esbuild-rust-wasm

Add to plugins

import esbuild from "esbuild"

esbuild.build({
  // ...
  plugins: [
    altvEsbuildRustWasm(),
  ],
})

Usage in JS code

// generated .wasm file must be in the folder with generated .js file (see example resource)
import loadWasm from "./pkg/example.wasm"

const {
  // these values are exported from rust
  // (see example resource)
  ...wasmExports
} = loadWasm({
  // these values are imported to rust using:
  // #[wasm_bindgen(js_namespace = altv_imports)]
  // (see example resource)
  ...wasmImports, 
})

Rust wasm-bingen documention: exports and imports.

0.0.2

2 years ago

0.0.1

2 years ago