Loading worker
Closed this issue · 1 comments
MigFerreira commented
Was having some trouble getting worker path working with vite, ran into this:
https://stackoverflow.com/questions/67995082/how-to-create-web-worker-in-a-sveltekit-app-on-vercel
Basically I got it working this way:
const sqliteWorkerPath = new URL('./sqlite-worker.mjs', import.meta.url).href
const filename = '/mydb.sqlite3';
const sqlite = new SqliteClient(filename, sqliteWorkerPath);
Problem right now I believe is with how vite manages imports, since im getting the following error:
[vite] Internal server error: Missing "./src/comlink.mjs" specifier in "@sqlite.org/sqlite-wasm" package
Plugin: vite:import-analysis
File: /home/mitch/Projects/supertokens-poc/src/lib/db/sqlite-worker.mjs
Ill be trying to tackle this but if anyone wants to help out: https://stackblitz.com/edit/sveltejs-kit-template-default-ubkpkr
MigFerreira commented
Seems I got around this by editing @sqlite.org/sqlite-wasm/package.json adding in comlink in exports.
"exports": {
".": {
"import": "./index.mjs",
"main": "./index.mjs",
"browser": "./index.mjs"
},
"./src/comlink.mjs": "./src/comlink.mjs",
"./package.json": "./package.json"
},
still unsure this is best solution on setting up worker.