[POC] Dynamic Extension Loading #16
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This is a (rough) POC for loading our Rust SQLite extension dynamically instead of statically linking via a Git submodule.
This compiles WA-SQLite as a
MAIN_MODULE
which can dynamically link toSIDE_MODULE
s. JS functions to enable loading of extensions and load extension binaries are added. Currently this modifies the main dist exports to support side modules. It should be possible to add an additional dist export, along side the existing exports, which enables modules.This has been tested with the in synchronous build and in-memory filesystem. Currently the async build fails to bind to the
sqlite_load_extension
call. This needs additional investigation.The call to
sqlite3_load_extension
currently makes a network request for the extension binary. This binary has been placed in thedist
folder where it can be served for demos. This behaviour might change when other VFS's are used.Our Rust SQLite extension was compiled by running
Then in the
/target/wasm32-unknown-emscripten/release/deps
directory the bytecode was linked to a binary withemcc *.bc [path_to_shim].o -o side_module.wasm -s SIDE_MODULE
A shim was included to introduce functionality for
Since this seems to not be resolveable. Improving this requires additional investigation.
The demo can be started with

yarn start
. See the screenshot below for results: