invopop / gobl.wasm

WASM interface to the GOBL library
Apache License 2.0
2 stars 0 forks source link

Prepare basic interface #1

Closed samlown closed 2 years ago

samlown commented 2 years ago

The objective of the GOBL WASM library is to provide a very simple wrapper around a CLI-like interface to the base GOBL library. It should be possible to "Envelop" and/or "Complete" raw JSON documents to create complete GOBL "draft" envelopes as a first step.

We can deal with Digital Signatures a bit later, although they should be relatively easy to manipulate.

flimzy commented 2 years ago

There is no clean way to do this with modern Go/WASM. You can see the full discussion here: https://github.com/golang/go/issues/25612

But the current state of affairs is basically that the Go/WASM program has to set functions in the global JS object (aka window). There's no way to "export" functions in a way that can be imported using standard JS semantics.

An alternative might be TinyGo (referenced in the above issue), as it does provide this sort of exportability for the WASM target. TinyGo has a number of limitations, similar to GopherJS, but I haven't tried using it yet, so maybe it wouldn't be a problem for us.

flimzy commented 2 years ago

Also, just FYI, the compiled output of gobl as WASM is 17mb, even if we can make this work. That's seems like a fairly hefty JS dependency...