Skip to content

Support building go-app with GopherJS (no wasm) #819

Closed
@akolybelnikov

Description

@akolybelnikov

Currently go-app assumes that the target architecture for the client side must be GOOS=js GOARCH=wasm. Here is a POC of the Lofimusic app build with GopherJS with a minor patch to the go-app:
https://github.com/nevkontakte/lofimusic/tree/0d328bf50b6fe7a3fc5f1a5d0d06a99f3e7cc368

The compiled code for GopherJS looks very different from Go-wasm, but it supports all the same APIs, including "syscall/js". The only major difference between Go-wasm and GopherJS is how the code is initialized: GopherJS produces a self-sufficient JS script, so it only needs to be included in the page via a <script> tag.

If as a go-app user you want to make a choice at the build time whether you want to use GopherJS or wasm, the framework could generate the appropriate initialization scripts.

As an aside, although GopherJS does support syscall/js API, it is a wrapper around the github.com/gopherjs/gopherjs/js package and is a bit slower than using the latter directly. It should be easy to make a GopherJS-specific implementation of that for GOOS=js GOARCH=ecmascrit target, thus gaining some performance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions