powersync-web-workers

Stars
3

PowerSync Web Worker

Make PowerSync works for Expo Web!

Build PowerSync worker scripts

The dist dir of the repo ships the built worker scripts for @powersync/[email protected] and @journeyapps/[email protected].

If you need to use other versions, you need to change the version in package.json, and run:

pnpm install
pnpm build

Copy worker scripts to your projects' public folder

export PROJECT_ROOT=/path/to/your/projects
cp ./dist "$PROJECT_ROOT/public/lib/powersync/worker"

Patch the @powersync/web module

You need to patch the following files of @powersync/web module to make it use our copied worker files

  • lib/src/db/sync/SharedWebStreamingSyncImplementation.js
  • lib/src/worker/db/open-worker-database.js

Change the new URL('xxx', import.meta.url) in these files to '/public/lib/powersync/worker/xxx'. See @[email protected] file in the repo for reference.