electric-sql / pglite

Lightweight WASM Postgres with real-time, reactive bindings.
https://pglite.dev
Apache License 2.0
9.46k stars 204 forks source link

feature: wasmModule and fsBundle options and caching of module+fsBundle #335

Closed samwillis closed 1 month ago

samwillis commented 2 months ago

This adds additional options for the wasmModule and fsBundle, along with caching of the default ones if used.

This should enable a route to running in a Cloudflare worker (pending further changes) as you can do something like:

import { PGlite } from '@electric-sql/pglite';
import wasm from '@electric-sql/pglite/dist/postgres.wasm';
import fsBundle from '@electric-sql/pglite/dist/postgres.wasm';

pg = await PGlite.create({
    wasmModule: wasm,
    fsBundle: fsBinary,
});

We had something working similar to this in the old v0.1.n version of PGlite on Cloudflare

Fixes: #329 #81

github-actions[bot] commented 2 months ago

Built bundles:

github-actions[bot] commented 2 months ago

🚀 Deployed on https://66f30841814dd9060fe0066b--pglite.netlify.app