From 65af2d4e532a18b1dd88d6b6fa8e865b1030b897 Mon Sep 17 00:00:00 2001 From: Florian Chazal Date: Thu, 11 Dec 2025 08:07:29 +0000 Subject: [PATCH 1/3] fix(node): load properly better-sqlite3 --- packages/node/src/db/SqliteWorker.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/node/src/db/SqliteWorker.ts b/packages/node/src/db/SqliteWorker.ts index a887e85e5..1fa0887f9 100644 --- a/packages/node/src/db/SqliteWorker.ts +++ b/packages/node/src/db/SqliteWorker.ts @@ -84,7 +84,9 @@ export function startPowerSyncWorker(options?: Partial) }, async loadBetterSqlite3() { const module = await dynamicImport('better-sqlite3'); - return module.default; + return module && typeof module === 'object' && 'default' in module + ? module.default + : module; }, ...options }; From af44fdbdc09eca079fba109f086422bac9ce6d33 Mon Sep 17 00:00:00 2001 From: Florian Chazal Date: Thu, 11 Dec 2025 08:24:35 +0000 Subject: [PATCH 2/3] chore: add changeset for better-sqlite3 fix --- .changeset/fix-better-sqlite3.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changeset/fix-better-sqlite3.md diff --git a/.changeset/fix-better-sqlite3.md b/.changeset/fix-better-sqlite3.md new file mode 100644 index 000000000..6464bf929 --- /dev/null +++ b/.changeset/fix-better-sqlite3.md @@ -0,0 +1,7 @@ +--- +"@powersync/node": patch +--- + +Fix loading of `better-sqlite3` in the Node worker so the module is dynamically loaded correctly. + +This ensures the Node SDK loads the correct Database constructor when `better-sqlite3` is installed. From 91190df32d0aa35a2bc163e640c053d08c9bd282 Mon Sep 17 00:00:00 2001 From: Florian Chazal Date: Fri, 12 Dec 2025 16:41:44 +0100 Subject: [PATCH 3/3] Update .changeset/fix-better-sqlite3.md Co-authored-by: Simon Binder --- .changeset/fix-better-sqlite3.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.changeset/fix-better-sqlite3.md b/.changeset/fix-better-sqlite3.md index 6464bf929..d8353bac1 100644 --- a/.changeset/fix-better-sqlite3.md +++ b/.changeset/fix-better-sqlite3.md @@ -2,6 +2,4 @@ "@powersync/node": patch --- -Fix loading of `better-sqlite3` in the Node worker so the module is dynamically loaded correctly. - -This ensures the Node SDK loads the correct Database constructor when `better-sqlite3` is installed. +Fix loading `better-sqlite3` on CommonJS builds.