-
Notifications
You must be signed in to change notification settings - Fork 106
Open
Description
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
- Create a new Sveltekit project: npm create svelte@latest my-app
- Install dependencies and start dev server
- Install
@jlongster/sql.jsandabsurd-sqlvia NPM - Update
/src/routes/+page.svelteto:
<script>
import { initBackend } from 'absurd-sql/dist/indexeddb-main-thread'
import { onMount } from 'svelte'
onMount(() => {
function init() {
let worker = new Worker(new URL('./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 thread
initBackend(worker)
}
init()
})
</script>
<h1>Welcome to SvelteKit</h1>
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>- Create a file
src/routes/index.worker.jswith the following code:
import initSqlJs from '@jlongster/sql.js';
import { SQLiteFS } from 'absurd-sql';
import IndexedDBBackend from 'absurd-sql/dist/indexeddb-backend';
async function run() {
let SQL = await initSqlJs({ locateFile: file => file });
let sqlFS = new SQLiteFS(SQL.FS, new IndexedDBBackend());
SQL.register_for_idb(sqlFS);
SQL.FS.mkdir('/sql');
SQL.FS.mount(sqlFS, {}, '/sql');
const path = '/sql/db.sqlite';
if (typeof SharedArrayBuffer === 'undefined') {
let stream = SQL.FS.open(path, 'a+');
await stream.node.contents.readIfFallback();
SQL.FS.close(stream);
}
let db = new SQL.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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels