Fix node electron example when packaged #562
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The example in
demos/example-electron-node
has two problems that only occur when running the packaged builds (the generated app after runningpnpm package
):.app
file of the app itself by default, where we can't open databases. This changes the example to use a directory inapp.getPath('userData')
instead.app.asar
) by default. Electron patches some Node APIs to be aware of this (so e.g. callingprocess.dlopen
would automatically extract the relevant library), but SQLite obviously can't be aware of that when we're loading the extension. So:powersync/
directory.worker.ts
, we check whether__dirname
points to the archive, and, if so, use the extracted directory instead.