The new SQLite WASM build is rather hard to use in modern JS apps, so this wrapper package tries to make this easier.
Currently only tested with Vite. According to the
yarn add sqlite-wasm-esm
// your-worker.js
import sqlite3InitModule from "sqlite-wasm-esm";
sqlite3InitModule().then((sqlite3) => {
const opfsDb = new sqlite3.opfs.OpfsDb("my-db", "c");
// or in-memory ...
const db = new sqlite3.DB();
});
{
// ...
build: { target: ['es2020'], }, // Needed in `sqlite-wasm-esm` for big-ints to work
optimizeDeps: {
exclude: ['sqlite-wasm-esm'], // TODO remove once fixed https://github.com/vitejs/vite/issues/8427
esbuildOptions: { target: 'es2020' }, // Needed in `sqlite-wasm-esm` for big-ints to work
},
}