fix error loading WASM file

This commit is contained in:
2025-05-25 07:45:07 -06:00
parent 5ae3eca773
commit a48a122224
4 changed files with 25 additions and 4 deletions

View File

@@ -4,7 +4,12 @@ import IndexedDBBackend from 'absurd-sql/dist/indexeddb-backend';
async function run() {
console.log("----- initSqlJs");
let SQL = await initSqlJs({ locateFile: file => file });
let SQL = await initSqlJs({
locateFile: file => {
// In Vite, we need to use the full URL to the WASM file
return new URL(`/node_modules/@jlongster/sql.js/dist/${file}`, import.meta.url).href;
}
});
let sqlFS = new SQLiteFS(SQL.FS, new IndexedDBBackend());
SQL.register_for_idb(sqlFS);