Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#2,101 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@KyleAMathews đang làm issue này rồi.

Từ ngày 11/10/2026.

  • #2103 của @KyleAMathews — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
sqlite, typescript, wasm
Lĩnh vực
database, frontend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
3.9k
Fork
272
Merge trung bình
1 ngày 1 giờ
Pull request đã merge (30 ngày)
222

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của TanStack/db

Tất cả issue của TanStack/db

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.