Skip to content

Conversation

@flochaz
Copy link
Contributor

@flochaz flochaz commented Dec 11, 2025

Context

Using the default worker fail with bad import of better-sqlite3. Patching loadBetterSqlite3 function to return the default if exposed fixed the issue.

@changeset-bot
Copy link

changeset-bot bot commented Dec 11, 2025

🦋 Changeset detected

Latest commit: 91190df

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@powersync/node Patch

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

Copy link
Contributor

@simolus3 simolus3 left a comment

Choose a reason for hiding this comment

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

To help me validate this, could you share how you've reproduced this? We've obviously also using that in tests and demos and never had issues with it. I assume this only happens on CommonJS entrypoints?

This also needs a changeset (pnpm -w changeset).

Copy link
Contributor Author

@flochaz flochaz left a comment

Choose a reason for hiding this comment

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

Indeed it's on CommonJS one. Will add the changeset

Copy link
Contributor

@simolus3 simolus3 left a comment

Choose a reason for hiding this comment

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

Thanks for the fix 👍 I can reproduce the issue with a .cjs entrypoint.

Comment on lines +87 to +89
return module && typeof module === 'object' && 'default' in module
? module.default
: module;
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;

Co-authored-by: Simon Binder <oss@simonbinder.eu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants