Skip to content

Integrating sql.js with SvelteKit #607

@chrisvire

Description

@chrisvire

I am creating a PWA that is reading a static database. I am including the wasm file in the bundle.

In SvelteKit, the src/routes/route_name/+page.ts is where data is loaded for the route.

I have:

import { base } from '$app/paths';
import initSqlJs from 'sql.js';

export async function load({ fetch }) {
    const SQL = await initSqlJs({
        locateFile: (file: string) => `${base}/wasm/${file}`
    });

...

}

When I run this, I get this error with SvelteKit in the console:

Loading /wasm/sql-wasm.wasm using window.fetch. For best results, use the fetch that is passed to your load function: https://svelte.dev/docs/kit/load#making-fetch-requests

How can I have initSqlJs use a provided fetch function to request the file instead of window.fetch ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions