Replies: 1 comment 1 reply
-
After more closely inspecting the import * as SQLite from "wa-sqlite";
import SQLiteESMFactory from "./node_modules/wa-sqlite/dist/wa-sqlite.mjs";
import base64Wasm from "./node_modules/wa-sqlite/dist/wa-sqlite.wasm";
function base64Decode(str) {
const binaryString = typeof atob === "function"
? atob(str)
: Buffer.from(str, "base64").toString("binary");
const len = binaryString.length;
const bytes = new Uint8Array(len);
for (let i = 0; i < len; i++) {
bytes[i] = binaryString.charCodeAt(i);
}
return bytes.buffer;
}
const module = await SQLiteESMFactory({
"wasmBinary": base64Decode(base64Wasm),
}); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey,
I'm working on a rust
diesel
backend using thewa-sqlite
library. This would enable users who are using sqlite with diesel to switch to this backend and run their app with sqlite in the browser after compiling with wasm-pack, without changing any of their ORM queries that already work with diesel.It would be helpful to optionally embed the wasm in the distributed js libraries, so that no external resources are needed to load the wasm in the browser. This would make distributing
wa-sqlite
bundled with the diesel backend easier + helps w.r.t wasm-pack, since it does not support adding extra outputs to its compiled artifacts (the wasm needs to currently be manually copied).This would give the library w/ embedded a bigger footprint, but I think is a useful/nice-to-have and i'm not sure there are huge drawbacks outside of the bloated distributed JS size. I'm thinking of this in addition to the artifacts in
./dist
it should be possible to embed the wasm as a b64 string and load it directly rather than loading it from a URL afaiu.
Beta Was this translation helpful? Give feedback.
All reactions