-
Notifications
You must be signed in to change notification settings - Fork 72
Description
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:
The issue is here. Vite generated the following files:
Opening a network tab reveals that requested file does not include a hash, however.
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:
- worker: https://github.com/jurerotar/Pillage-First-Ask-Questions-Later/blob/test/sqlite-3-51-error/app/(public)/(game-worlds)/(create)/workers/create-new-game-world-worker.ts,
- live reproduction: https://test-sqlite-3-51-error--pillagefirst.netlify.app/game-worlds/create
You can recreate the issue by clicking on the "Create server" button and opening the console.
Edit: updated reproduction urls