hexops / vecty

Vecty lets you build responsive and dynamic web frontends in Go using WebAssembly, competing with modern web frameworks like React & VueJS.
BSD 3-Clause "New" or "Revised" License
2.8k stars 143 forks source link

Add WebAssembly support #232

Closed slimsag closed 5 years ago

slimsag commented 5 years ago

Prior to this PR, Vecty was only usable with GopherJS which would compile Go to JS code.

After this PR, Vecty can be used with:

All examples in the example directory work under both GopherJS and WebAssembly, and a README is added to describe how to compile for each.

TinyGo future support

In the future, Vecty will automatically gain support for TinyGo once it supports the subset of reflection and syscall/js that we make use of.

See https://github.com/aykevl/tinygo/issues/93 for more discussion around this.

Prior work

Supersedes the prior PR for this by using build tags instead of exposing a gopherwasm API directly. See https://github.com/gopherjs/vecty/pull/215#issuecomment-455829781 for discussion around this.

Fixes #211

slimsag commented 5 years ago

It will likely be a few more weeks before I have time to begin working on this again and finish the remaining bits / merge it.

slimsag commented 5 years ago

Looks like the ecosystem is maturing a bit so we're pretty closer to being able to merge this. Notable things that have happened recently:

Remaining work:

No other errors, logs, etc. Unsure why. Doesn't affect other examples. cc @hajimehoshi if you have any ideas, otherwise I'll find more minimal case and file/fix upstream.

(Just checkout this branch and cd example/markdown && wasmserve if you are keen to reproduce)

aykevl commented 5 years ago

I don't think the reflect support in TinyGo is good enough: it still doesn't support inspecting structs for example. However, I have been working on a better map implementation which is a prerequisite to js.FuncOf support so there is still progress.

hajimehoshi commented 5 years ago

wasmserve has a bug only affecting example/markdown where it returns:

That's a strange error message I've never seen. I'll take a look later, but now I'm on a business trip, so I cannot guarantee when :-)

slimsag commented 5 years ago

Confirmed the wasmserve issue is actually a bug in WSL not wasmserve: https://github.com/hajimehoshi/wasmserve/issues/5

johanbrandhorst commented 5 years ago

What is the status of this? I think vecty could move to using syscall/js for both WebAssembly and GopherJS now that GopherJS has syscall/js too. What do you think?

codecov-io commented 5 years ago

Codecov Report

Merging #232 into master will increase coverage by 1.77%. The diff coverage is 57.89%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #232      +/-   ##
==========================================
+ Coverage   57.64%   59.41%   +1.77%     
==========================================
  Files           3        4       +1     
  Lines         654      653       -1     
==========================================
+ Hits          377      388      +11     
+ Misses        219      208      -11     
+ Partials       58       57       -1
Impacted Files Coverage Δ
markup.go 70.96% <ø> (ø) :arrow_up:
dom_native.go 53.84% <53.84%> (ø)
dom.go 57.45% <60%> (+2.16%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 216758a...9cf66b5. Read the comment docs.

slimsag commented 5 years ago

Good news! It's finally time for this to be merged: Vecty now has WebAssembly support! 😃 🎉