Closed bogacg closed 2 years ago
I've been playing with idb in a SvelteKit project and I'm getting this error when I hit the page with SSR.
idb
Open up your editor and go to Svelte route src\routes\todos\index.svelte to add idb:
src\routes\todos\index.svelte
<script lang="ts"> import { enhance } from '$lib/form'; import { scale } from 'svelte/transition'; import { flip } from 'svelte/animate'; import { onMount } from 'svelte'; import type { DBSchema, IDBPDatabase } from 'idb/with-async-ittr' import { openDB } from 'idb/with-async-ittr' . . let db: IDBPDatabase onMount( async()=> { try { db = await openDB('test-db') } catch (error) { console.log(error) } }); . . . </script>
http://localhost:3000/todos
At this point we get error:
[vite] Error when evaluating SSR module /src/routes/todos/index.svelte: Error: Cannot find module './build/cjs/index.js' Require stack: - ...\idb-test-app\node_modules\idb\with-async-ittr.cjs
I've been trying to implement recommendations as described in SvelteKit FAQ with no luck so far.
Update: If I don't hit the page directly (opening root then click its link) I still see the error on CLI side but code seems to work fine.
Ah yes, I see the issue. Thanks for the report.
Published the fix as 7.0.1
I've been playing with
idb
in a SvelteKit project and I'm getting this error when I hit the page with SSR.Steps to reproduce
Open up your editor and go to Svelte route
src\routes\todos\index.svelte
to addidb
:http://localhost:3000/todos
At this point we get error:
I've been trying to implement recommendations as described in SvelteKit FAQ with no luck so far.
Update: If I don't hit the page directly (opening root then click its link) I still see the error on CLI side but code seems to work fine.