Open timwis opened 2 years ago
Hey @timwis I just downloaded the .wasm
file from the examples folder.
https://github.com/jlongster/absurd-sql/blob/master/src/examples/sql-wasm.wasm
In my react application where I'm testing this library I put it in the public/wasm/bin folder and it works. When I initialize it with initSQLJs it looks like this
SQL = await initSqlJs({ locateFile: file => `/wasm/bin/${file}` });
Thanks, but:
/js/sql-wasm.wasm
, even though that my code said locateFile: file => file
@timwis
As for 1., check https://github.com/jlongster/absurd-example-project, that file is there.
As for 4., try to add /
locateFile: (file: string) => `/${file}`
I just ran into this problem myself, which had been causing me quite a headache for several hours today. Didn't realize for a while that the problem was that my browser couldn't find sql-wasm.wasm
, thought it was something wrong with my service worker setup for a while (apparently learning how to use service workers and absurd-sql
for the first time might have been a bigger task than I anticipated :laughing:). If you check your node_modules
and go into -> @jlongster
-> sql.js
-> dist
folder, the file should be there! I just went ahead and copied that file to my build tool's directory that serves static assets (for me with vite
and vite-plugin-pwa
it's /public
) and it seems to be working properly for me now! Hope that helps for anyone else who might have this issue
Overall, it's not a good practice to copy wasm file to your public dir, then you will lose ability to receive updates. It's better to import from lib. Here how you can do with CRA:
import sqlWasmUrl from "@jlongster/sql.js/dist/sql-wasm.wasm";
Or with vite:
import sqlWasmUrl from "@trong-orm/sql.js/dist/sql-wasm.wasm?url";
Also, this might help you https://trong-orm.netlify.app/core/usage https://trong-orm.netlify.app/backends/web (it's an abstraction layer, that makes it easier to use absurd-sql. There is also CRA and vite repo example)
Hi! Really excited by this project. I'm trying it out locally, using the directions in the readme, and my browser's making a request for
/js/sql-wasm.wasm
which throws a 404 as it doesn't exist. Not sure what's calling it, or where it's supposed to be. Any suggestions?I see it as a static file in the example repo, but the readme doesn't mention it 🤔