dart-archive / wasm

Utilities for loading and running WASM modules from Dart code
https://pub.dev/packages/wasm
BSD 3-Clause "New" or "Revised" License
312 stars 24 forks source link

Dart bindings via javascript transpilation/execution. #132

Open modulovalue opened 1 year ago

modulovalue commented 1 year ago

I think it is safe to assume that all languages that have javascript as a compilation target will eventually support targeting wasm as a compilation target as well.

As part of the compilation pipeline of languages that target wasm today, it seems to be common to also generate bindings written in javascript to the generated wasm code (e.g. see Rust).

It would be very hard to convince all the languages that target wasm to also write bindings for Dart. What if we take the javascript that those compilation pipelines produce, and extract the wasm bindings out of them, and generate Dart bindings ourselves?

The open question here is whether this approach would be feasible. I can see the following levels of difficulty:

I don't have enough insight into javascript to evaluate the Runtime-mirroring approach yet, but that would probably be the simplest.

To investigate this approach we should probably first collect some autogenerated javascript bindings and see if there's a common pattern there that we can make use of.