josephg / node-foundationdb

Modern Node.js FoundationDB bindings
Other
115 stars 17 forks source link

Deno support #51

Open Stephan-C opened 3 years ago

Stephan-C commented 3 years ago

Would it be possible to create a deno port? This might be useful: https://dev.to/craigmorten/guide-to-porting-node-modules-to-deno-41cd

josephg commented 3 years ago

I'd love to. The javascript code should mostly work without issue. The problem is porting the native bindings to deno.

It looks like deno has merged a patch to support native plugins but I can't find any documentation on it. We're blocked by this trifecta:

  1. Foundationdb doesn't have a published network protocol. If it did, we could write a fdb client in plain javascript and run that in deno.
  2. FDB's native client library doesn't support wasm. If it did, we could compile the fdb client API to wasm and include that from nodejs and deno. (And then we wouldn't need separate builds for windows/mac/linux/freebsd/etc.
  3. As far as I can tell, deno has no support for napi (node's native module API). If it did, the current native code could be imported and used as-is from deno.

Generally making noise about 1 and 2 in the fdb forums would be helpful if you want to get the ball rolling. Or doing the work yourself - I don't know enough about wasm-ir to port the pure assembly parts of the fdb client codebase to wasm.

If deno has its own native plugin API, maybe we can make an alternate version of the native code specifically for deno. But porting the native code to a different API will be a lot of work.

rojvv commented 1 year ago

Can't this be done using FFI?

rojvv commented 1 year ago

https://github.com/roj1512/foundationdb_deno might be interesting. I’ve recently worked on it.