Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

browser-db-sqlite-persistence: option to load the wa-sqlite WASM by URL instead of inlined base64

Abierto
#2,101 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
sqlite, typescript, wasm

Línea de trabajo

Start in src/opfs-worker.ts, where SQLiteESMFactory() is called with no options, and in the openBrowserWASQLiteOPFSDatabase entry point that creates the worker. Pick one of the three proposed approaches (a wasmUrl/locateFile option, a createWorker option, or an unInlined WASM asset) and confirm it with the maintainers first, since the issue leaves the choice open. Done means a consumer can supply the WASM location and the worker loads it without the inlined base64 build.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

What

@tanstack/browser-db-sqlite-persistence (seen on 0.2.30) ships its OPFS worker prebuilt as dist/assets/opfs-worker-*.js, with wa-sqlite's WebAssembly inlined as a data:application/wasm;base64,… URL. That makes the worker about 1.7 MB raw (about 573 KB brotli). Most of that is the base64 WASM, which compresses worse than the binary and cannot be compiled by WebAssembly.instantiateStreaming.

src/opfs-worker.ts calls SQLiteESMFactory() with no options, and the package offers no option to pass a locateFile, a wasmBinary or a worker of one's own.

Ask

An option for where the WASM comes from. Any of these would do:

  • a wasmUrl (or locateFile) option on openBrowserWASQLiteOPFSDatabase, passed to the worker and on to SQLiteESMFactory({ locateFile });
  • a createWorker option, so an app can build the worker from source with its own bundler;
  • or ship the worker without inlining the WASM, since @journeyapps/wa-sqlite already resolves new URL("wa-sqlite.wasm", import.meta.url), which Vite, Rollup and webpack all emit as a separate asset.
What we do meanwhile

We patch dist/esm/opfs-worker.js so the consumer's Vite build makes the worker from the package's own source:

function WorkerWrapper(options) {
  return new Worker(new URL("../../src/opfs-worker.ts", import.meta.url), {
    type: "module",
    name: options?.name
  });
}

With Vite 8 that gives an 88 KB worker plus a separate 1,129,661 B wa-sqlite-*.wasm: 468 KB brotli in total instead of 573 KB, compiled by streaming. It works in dev too, because Vite's dep optimizer rewrites the worker URL. We would like to drop the patch once the package has an option for it.

Lenguaje dominante
TypeScript
Estrellas
3.9k
Forks
272
Merge medio
1 d 1 h
PR fusionados (30 d)
210

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de TanStack/db

Todos los issues de TanStack/db

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.