-
Notifications
You must be signed in to change notification settings - Fork 49
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
State of ergo-lib-wasm
#663
Comments
I really appreciate this!
Agree.
https://github.com/ross-weir/ergo-lib-wasm looks awesome! I looked into splitting up the ergo-lib-wasm myself but got cold feet since we're exposing a wrapped rust type to JS and I got stuck on how to pass these wrapped types (think box, tx, etc.) between different Wasm runtimes. I see you used serde ser/deser to pass types through Rust<->JS border. I like this and the performance penalties can be tolerated. I probably made a mistake to not have chosen this model initially. Besides that, I'm planning to migrate to
Totally agree. My fear is that might leave some edge cases unsupported (like using the node version in an electron app, etc.). If that's not the case I'm all in.
Yep.
Well, in my defense, back then I did not find a better way to avoid 53-bit mantissa limit of JS Number. I'm open to all suggestions.
This was(still is?) the limitation of wasm-bindgen. But with serde serialization we can do a native arrays anyway.
Yep, although we have some
I 100% agree! |
If it means anything, this is also how
The JS ecosystem is a mess when it comes to distribution but I'd be surprised if we encounter a edge case that is insurmountable - the edge case you mention should work with the example repo (I'll validate)
I'd suggest using
Disappointing this is still a issue in
None of this is meant as a criticism of you, I'm impressed by how much you've accomplished across so many tech stacks. We've learnt a heap about wasm bindings over the last couple of years so can probably put it to use! I have some ideas with how we proceed if you'd like to discuss at some point (after the holidays or whenever suits you) |
I'll just put my ideas on proceeding here I'm thinking:
I'm assuming ergo still has access to the |
Sounds great! I agree with the need for new repo and your take on package split. I think @deadit should have access to the ergoplatform account on npm. EDIT: I created https://github.com/ergoplatform/ergo-lib-wasm and sent you an invite. Feel free to set things up. |
Want to highlight some pain points/things I've encountered while using the wasm library and some suggestions on how I think we might be able to improve the situation. The team probably has a lot of other work/higher priorities but maybe one day we can work on improving the package 😄
Pain Point: Library size/bloat -
ergo-lib-wasm
is approaching 3mb size, that is really non-trivial for frontend applications in particularPossible solution to this could be breaking up the monolithic
ergo-lib-wasm
package into a monorepo/workspaces structure that mirrors the wrapped rust crates and publish each as their own npm package, i.e@ergoplatform/merkle-tree
,@ergoplatform/nipopow
, etc.As an example, I was looking to use NiPoPoW functionality which is a small subset of
ergo-lib-wasm
but in order to do so I need to pull in almost 3MB of extra unneeded code, which greatly impacts one of NiPoPoWs use cases of running on constrained devicesLibrary is published as
browser
andnodejs
versions leaving it up to consumers to try and figure out how to correctly use it in their projectsLooks like we may have looked into this in the past as we're defining
browser
andmain
fields inpackage.json
but still end up publishing 2 packages, it looks like its possible to start publishing as one package, some refs:API is not ergonomic and doesn't follow JS conventions
Some examples:
number
into aI64
typeErgoBoxes
,ErgoBoxCandidates
) being their own types instead of arrays ofErgoBox
with less functionality than array counterparts make them awkward to work withClass.new()
functions instead of constructors, etcI think exposing an API that makes more use of
js_sys
for types (and then converts them under the hood on the rust side where needed) would greatly reduce awkwardness. For the conventions stuff, making more use ofwasm_bindgen
annotations likewasm_bindgen(constructor)
,wasm_bindgen(getter, setter)
,wasm_bindgen(js_name = renamedToCamelCase)
I think would go a long way to improving usability and making the library more familiar for JS devsThe text was updated successfully, but these errors were encountered: