Skip to content

Instantly share code, notes, and snippets.

@nornagon
Created November 6, 2020 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nornagon/5d0ba28f9509a85604628e70406f3f3c to your computer and use it in GitHub Desktop.
Save nornagon/5d0ba28f9509a85604628e70406f3f3c to your computer and use it in GitHub Desktop.
import('./test.mjs') // async import needed to allow for webpack download+compile
npx webpack --entry ./index.mjs --experiments-sync-web-assembly
cat <<HTML > dist/index.html
<!doctype html>
<script src="./main.js"></script>
HTML
npx serve dist
import wasmBackend from 'automerge-backend-wasm'
import Automerge from 'automerge'
wasmBackend.initCodecFunctions(Automerge)
Automerge.setDefaultBackend(wasmBackend)
let doc = Automerge.from({ cards: [] })
doc = Automerge.change(doc, d => {
d.cards.push({ title: 'foo' })
})
console.log(doc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment