Skip to content

Instantly share code, notes, and snippets.

@nornagon
Created November 6, 2020 17:59
Show Gist options
  • 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