automerge/automerge-backend-wasm
Andrew Jeffery 01159056ef
Add dev command for building wasm backend (#199)
* Add dev command for building wasm backend

This aims to reduce the time spent building when testing with the wasm
backend. On my machine `yarn release` takes 20s while `yarn dev` takes
just 2s.

* Separate out building wasm
2021-06-29 17:12:24 +01:00
..
scripts Add dev command for building wasm backend (#199) 2021-06-29 17:12:24 +01:00
src Update interop tests + review comment 2021-06-25 11:06:25 -07:00
test Add proptest for serialization 2021-01-14 12:30:25 -05:00
tests cargo fmt --all (#30) 2020-11-08 14:47:18 +00:00
.gitignore add js interop testing (#91) 2021-04-07 16:54:51 +01:00
Cargo.toml Remove unneeded wasm-opt 2021-06-12 15:01:38 -07:00
GOALS_AND_ISSUES.md Update GOALS_AND_ISSUES.md 2020-04-16 11:31:08 -04:00
LICENSE tools for making an asmjs version 2020-04-05 10:22:45 -07:00
package.json Add dev command for building wasm backend (#199) 2021-06-29 17:12:24 +01:00
package.mjs.json reorg file for new package 2021-02-18 16:41:20 -05:00
package.pkg.json reorg file for new package 2021-02-18 16:41:20 -05:00
README.md Fix types in wasm/README.md (#66) 2021-03-27 11:12:50 +00:00
yarn.lock Bump glob-parent from 5.1.1 to 5.1.2 in /automerge-backend-wasm (#166) 2021-06-16 09:59:04 +01:00

automerge-backend-wasm

This is a wrapper for the rust implementation of automerge-backend to be used with Automerge.

Using

You can require this synchronously as a CommonJS module or import it as a ES6 module

let Automerge = require("automerge")
let Backend = require("automerge-backend-wasm")
Automerge.setDefaultBackend(Backend)
import * as Automerge from "automerge"
import * as Backend from "automerge-backend-wasm"
Automerge.setDefaultBackend(Backend)

Note that the first uses a synchronous filesystem load of the wasm and will not be transferable to a browser bundle. The second uses ES6 wasm import statements which should work in all modern browsers but require a '--experimental-wasm-modules' flag on nodejs (v13 on) unless you pack/bundle the code into compatible format.