Skip to content

Version 3.51.1-build1 breaks sqlite3.wasm file resolution on Vite #120

@jurerotar

Description

@jurerotar

After upgrading sqlite-wasm package to the 3.51.1-build1 version, internal import of the actual sqlite3.wasm file no longer works properly. The issue is that vite adds a hash to sqlite3.wasm file during build (you get something like sqlite3-abcd.wasm), but sqlite3.mjs still attempts to resolve file name without the hash. Attempting to use locateFile also doesn't solve this issue.

I've prepared a replication using your vite example: https://stackblitz.com/edit/vitejs-vite-w5cmvvub

Because the issue only happens during build, run vite build && vite preview.
You'll see the following error in the console:

Image

The issue is here. Vite generated the following files:

Image

Opening a network tab reveals that requested file does not include a hash, however.

Image

I've attempted to fix this by using the locateFile function. There's a reproduction of that available here: https://stackblitz.com/edit/vitejs-vite-itfiv34f, you can reproduce by following the same instructions as in the first example.

Live example and the actual code I used to encounter this issue is available here:

You can recreate the issue by clicking on the "Create server" button and opening the console.

Edit: updated reproduction urls

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions