-
Notifications
You must be signed in to change notification settings - Fork 51
feat: @powersync/dev added to support SQL.js #647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 46bd668 The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commonjs({}), | ||
alias({ | ||
entries: [ | ||
{ find: 'fs', replacement: path.resolve(__dirname, 'vendored/empty.js') }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default Emscripten output contains code like require("fs")
. This seems to be unreachable, but Metro complains when it detects it. This replaces the requires to return empty modules.
} | ||
} | ||
|
||
(globalThis as any).onSqliteUpdate = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The standard update hook function did not trigger for me. I've implemented this as a workaround.
+ /** TODO | ||
+ @return {number} the last insert id | ||
+ */ | ||
+ Database.prototype["lastInsertId"] = function lastInsertId() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was not exposed by SQL.js, but we need it in order to validate the response from checkpoint validations.
Overview
Certain environments have trouble loading PowerSync due to it requiring a SQLite implementation which supports loading our Rust core extension. One of these environments is Expo Go which is a prebuilt app container for Expo apps.
The new
dev
package uses a pure JS implementation of SQLite via SQL.js which has been forked. SQLite and our Rust core extension are compiled to JavaScript via Emscripen there. This pure JS payload can be used in environments such as Expo Go.Outstanding work
SQL.js operates in memory. We can persist the entire DB to disk on commit though. This has not yet been implemented for RN.Added Expo persister in the dev adapter's README.mdThis currently builds SQL.js in the monorepo. This requires toolchains which we should not expect all users of the monorepo to have present. We could fallback to prebuilt assets in such cases.This build was moved out to the SQL.js fork.Demo
ExpoGo2.mp4
Benchmarks
Tested 1000 separate list insertions, PowerSync not connected. Haven't been able to understand why the Expo file persister version is faster than the in-memory persister.
