Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile to WebAssembly #68

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Compile to WebAssembly #68

wants to merge 6 commits into from

Conversation

FZambia
Copy link
Member

@FZambia FZambia commented Sep 3, 2022

Relates #67

This pull requests adds possibility to use centrifuge-go in browser using compilation to WebAssembly. The implementation here is an adapted code from https://github.com/nhooyr/websocket which supports WASM env for some time already. PR contains a simple example that demonstrates how centrifuge-go and wasm can be used together to build a browser app.

The example shown in the PR weights 12 MB when using standard Go compiler. Which is quite sad. And this makes me skeptical a bit about the idea - not sure whether someone wants to put file of this size to the browser app.

For Tinygo the situation is quite bad at the moment:

  1. We can't use segmentio/encoding package - github.com/segmentio/[email protected]/json/reflect.go:12:23: ArrayOf not declared by package reflect - may be fixed by switching to stdlib JSON and using build tags in protocol package or when mapstructure requires MapOf and friends tinygo-org/tinygo#2115 solved
  2. Tinygo does not support (reflect.Type).PkgPath() - Implement the PkgPath() method on reflect.Type tinygo-org/tinygo#2668
  3. Tinygo does not implement timers runtime timers are unimplemented tinygo-org/tinygo#1037 - Uncaught (in promise) LinkError: WebAssembly.instantiate(): Import #13 module="env" function="time.stopTimer" error: function import requires a callable

Tinygo could help reduce 12 MB to ~3 MB when all the issues mentioned above solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant