-
Notifications
You must be signed in to change notification settings - Fork 61
fix(node): load properly better-sqlite3 #795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 91190df The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
simolus3
left a comment
There was a problem hiding this 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).
flochaz
left a comment
There was a problem hiding this 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
simolus3
left a comment
There was a problem hiding this 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.
| return module && typeof module === 'object' && 'default' in module | ||
| ? module.default | ||
| : module; |
There was a problem hiding this comment.
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:
| 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>
Context
Using the default worker fail with bad import of better-sqlite3. Patching
loadBetterSqlite3function to return thedefaultif exposed fixed the issue.