murat-dogan / node-datachannel

WebRTC For Node.js and Electron. libdatachannel node bindings.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wasm

jimmywarting opened this issue · comments

I digged into the construction of this, and upon examination, it appears to be utilizing NodeJS bindings. However, I believe there is room for improvement by transitioning this to WebAssembly.

By doing so, not only would it function seamlessly on NodeJS, but it could potentially be executed on Deno, Bun, and various other runtimes as well(?) It would simplify the distribution process, as we could distribute one single pre-compiled WebAssembly file that operates on any runtime or machine, eliminating the need for source code compilation upon installing the package.

While inspecting the source code on npm, I also noticed it includes cmake, src, test, and heck even node_modules (which might have been unintentional?). Consolidating everything into a single WebAssembly file would result in a fully cross-compatible executable and also being easier to install

toughts?

Something like that;
https://github.com/paullouisageneau/datachannel-wasm

Yes package on npm includes test, src folders. They are just small files. prebuild-install was a bundleddep so you see node_modules folder.
But nowadays it does not make sense to use a bundleddep. I have just deleted it.
Thanks for reporting.

Something like that;
https://github.com/paullouisageneau/datachannel-wasm

Uh, interesting 🥸

lul paullouisageneau/datachannel-wasm#43 (comment)

A: hey check out B instead
B: hey check out A instead

NodeJS and other runtimes have globalThis.WebAssembly how hard can it be? 🙃

commented

bun supports node bindings? idk about deno, wasm is also insanely slower than native bindings, so is there really a point?

its actually insanely hard to create bindings for C libraries like this with WASM, I have tried, and it's a lot more work than you'd expect

@jimmywarting Porting libdatachannel to WASI sounds like a lot of work, if it is even possible, given that the library and its dependencies rely on a lot of POSIX or OS-specific system APIs, in particular for network access and threading.

yea, WASI is probably the right thing for it...
i just wish that deno, bun and nodejs could support it right from the core.
having global WebRTC DataChannel globally would be amazing!