You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When installing absurd-sql in a new Sveltekit project, I get the following error: Unexpected token 'export' from /node_modules/absurd-sql/dist/indexeddb-main-thread.js:66: export { initBackend };.
I hope anyone can help me, thanks in advance!
Steps to reproduce
Create a new Sveltekit project: npm create svelte@latest my-app
Install dependencies and start dev server
Install @jlongster/sql.js and absurd-sql via NPM
Update /src/routes/+page.svelte to:
<script>import{initBackend}from'absurd-sql/dist/indexeddb-main-thread'import{onMount}from'svelte'onMount(()=>{functioninit(){letworker=newWorker(newURL('./index.worker.js',import.meta.url))// This is only required because Safari doesn't support nested// workers. This installs a handler that will proxy creating web// workers through the main threadinitBackend(worker)}init()})</script><h1>Welcome to SvelteKit</h1><p>Visit <ahref="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>
Create a file src/routes/index.worker.js with the following code:
importinitSqlJsfrom'@jlongster/sql.js';import{SQLiteFS}from'absurd-sql';importIndexedDBBackendfrom'absurd-sql/dist/indexeddb-backend';asyncfunctionrun(){letSQL=awaitinitSqlJs({locateFile: file=>file});letsqlFS=newSQLiteFS(SQL.FS,newIndexedDBBackend());SQL.register_for_idb(sqlFS);SQL.FS.mkdir('/sql');SQL.FS.mount(sqlFS,{},'/sql');constpath='/sql/db.sqlite';if(typeofSharedArrayBuffer==='undefined'){letstream=SQL.FS.open(path,'a+');awaitstream.node.contents.readIfFallback();SQL.FS.close(stream);}letdb=newSQL.Database(path,{filename: true});// You might want to try `PRAGMA page_size=8192;` too!db.exec(` PRAGMA journal_mode=MEMORY; `);// Your code}
Open the browser
In the browser, I get the error message.
The text was updated successfully, but these errors were encountered:
Hello,
When installing
absurd-sql
in a new Sveltekit project, I get the following error:Unexpected token 'export'
from/node_modules/absurd-sql/dist/indexeddb-main-thread.js:66
:export { initBackend };
.I hope anyone can help me, thanks in advance!
Steps to reproduce
@jlongster/sql.js
andabsurd-sql
via NPM/src/routes/+page.svelte
to:src/routes/index.worker.js
with the following code:In the browser, I get the error message.
The text was updated successfully, but these errors were encountered: