Closed modulovalue closed 1 year ago
What's the rationale for switching to top-level factory functions?
The async version is there for when we add web support. Wasmer doesn't have a built in way of compiling asynchronously, but on the web that's the main recommended way.
What's the rationale for switching to top-level factory functions?
By routing all ways to instantiate a wasmer based WasmModule through these two top level factory functions we'll be able to make everything else private in that file to explicitly exclude it from the public API. (we could use parts, but that would add a dependency on wasmer to wasm_api.dart
).
Together with wasm_api.dart
(from the other PR) we'll have a clear picture about what constitutes the public API of this package: wasm_api.dart (all sealed interfaces) and two functions for creating new wasm modules. This will give us more freedom to work on the internals without accidentally breaking users of this package.
Sounds reasonable. How would we provide a different implementation of these functions for the web? Just delegate to impl functions defined in conditionally imported scripts?
Conditional imports would be one way.
However, there are some subtleties that make conditional imports suboptimal in my opinion. One of which is that they aren't really supported all that well by the dart analyzer. (But they are the most user friendly way in the sense that users won't have to care about any implementation details.)
changelog updated (and version bumped)
I've rebased on main and squashed the commits. @liamappelbe please take a look. I don't have write permissions to merge or is there something else that you'd like me to do?
See #92 step 2.
The following are some TODOs as a note to myself: