0.0.24 • Published 2 years ago

@geoffreylitt/sqlite-wasm-esm v0.0.24

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

sqlite-wasm-esm

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

Usage

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()
})

Vite config

{
	// ...
	// requires the following options
	build: { target: ['es2020'], },
	optimizeDeps: { esbuildOptions: { target: 'es2020' } },
}
# This is needed until Vite fixes https://github.com/vitejs/vite/issues/10761
cp node_modules/sqlite-wasm-esm/dist/sqlite3{.wasm,-opfs-async-proxy.js} node_modules/.vite/deps/