Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/node/src/db/SqliteWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ export function startPowerSyncWorker(options?: Partial<PowerSyncWorkerOptions>)
},
async loadBetterSqlite3() {
const module = await dynamicImport('better-sqlite3');
return module.default;
return module && typeof module === 'object' && 'default' in module
? module.default
: module;
Comment on lines +87 to +89
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might make it clearer what's going on:

Suggested change
return module && typeof module === 'object' && 'default' in module
? module.default
: module;
// require() gives us the default directly, for an ESM import() we need to use the default export.
return isBundledToCommonJs ? module : module.default;

},
...options
};
Expand Down