Skip to content

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.

@FZambia
Copy link
Member Author

FZambia commented Jun 10, 2025

Closing in favour of #109

@FZambia FZambia closed this Jun 10, 2025
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.

2 participants