Skip to content

Commit 84239b7

Browse files
authored
fix(node): load properly better-sqlite3 (#795)
1 parent 8bf5fd7 commit 84239b7

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

.changeset/fix-better-sqlite3.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@powersync/node": patch
3+
---
4+
5+
Fix loading `better-sqlite3` on CommonJS builds.

packages/node/src/db/SqliteWorker.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ export function startPowerSyncWorker(options?: Partial<PowerSyncWorkerOptions>)
8484
},
8585
async loadBetterSqlite3() {
8686
const module = await dynamicImport('better-sqlite3');
87-
return module.default;
87+
// require() gives us the default directly, for an ESM import() we need to use the default export.
88+
return isBundledToCommonJs ? module : module.default;
8889
},
8990
...options
9091
};

0 commit comments

Comments
 (0)