Skip to content

feat: PGlite support + browser-sync example app#327

Draft
tonyxiao wants to merge 13 commits intodevfrom
pglite
Draft

feat: PGlite support + browser-sync example app#327
tonyxiao wants to merge 13 commits intodevfrom
pglite

Conversation

@tonyxiao
Copy link
Copy Markdown
Collaborator

@tonyxiao tonyxiao commented May 7, 2026

Summary

  • Add PGlite as an in-process destination backend (file://, memory:// URLs)
  • Split destination-postgres client into separate client-pg.ts and client-pglite.ts files with shared ManagedClient interface
  • Add browser-sync example app: React + Vite that runs the full sync engine in-browser with PGlite at memory:// and live WebSocket updates
  • Gate PGlite behind allow_experimental_pglite config flag
  • CI: run on dev branch, only tag Docker latest on main

Test plan

  • pnpm test passes for destination-postgres (PGlite unit tests)
  • cd examples/browser-sync && pnpm dev — app starts, enter Stripe key, sync runs in-browser
  • CLI: sync-engine sync --postgres-url memory:// ... creates PGlite instance and syncs

🤖 Generated with Claude Code

tonyxiao and others added 5 commits May 6, 2026 21:58
Refactor destination-postgres to support both pg.Pool and PGlite as
backends. PGlite enables in-process WASM Postgres for testing without
Docker and lightweight embedded deployments.

- Add QueryClient/ManagedClient abstractions (src/client.ts)
- Add `pglite` config option (true for in-memory, {data_dir} for persistent)
- Refactor writeMany/upsertMany/deleteMany to accept QueryClient interface
- Add @electric-sql/pglite as optional peer dependency
- Add PGlite-specific test suite (no Docker required)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Committed-By-Agent: claude
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Committed-By-Agent: claude
…rt, upgrade to pglite 0.4.5

- Add `allow_experimental_pglite` boolean config gate
- Detect file:// and memory:// URL schemes and route to PGlite
- Upgrade @electric-sql/pglite from 0.2.17 to 0.4.5

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Committed-By-Agent: claude
PGlite's query() rejects multiple SQL statements in a single call.
Fall back to exec() when the "multiple commands" error is detected.
This fixes destination setup which uses buildCreateTableDDL (returns
a DO block + standalone DO blocks).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Committed-By-Agent: claude
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Committed-By-Agent: claude
tonyxiao and others added 5 commits May 7, 2026 07:45
…ite files

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Committed-By-Agent: claude
…tgres

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Committed-By-Agent: claude
…n process kill

Prevents data directory corruption when the process receives SIGTERM/SIGINT
mid-write. PGlite lacks WAL recovery, so unclean shutdown corrupts the data dir.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Committed-By-Agent: claude
Runs the sync engine entirely in-browser with PGlite at memory://,
including live WebSocket updates from Stripe.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Committed-By-Agent: claude
Uses vite-plugin-node-polyfills for node:* builtins, plus custom
shims for pg, ws, child_process, https-proxy-agent, and logger.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Committed-By-Agent: claude
@tonyxiao tonyxiao changed the title Pglite feat: PGlite support + browser-sync example app May 7, 2026
tonyxiao and others added 3 commits May 7, 2026 10:11
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Committed-By-Agent: claude
Add custom resolveId plugin for node: imports from linked workspace
dist files, add process globals injection, and node:url shim.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Committed-By-Agent: claude
- engine: add ./lib export (core without API/CLI node deps)
- destination-postgres: add ./pglite export (no pg import)
- util-postgres: add ./sql and ./upsert sub-path exports
- browser-sync: use new sub-paths to avoid node:fs, pg, etc.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Committed-By-Agent: claude
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant