fix(desktop): include bindings package for better-sqlite3 native module#483
Conversation
better-sqlite3 uses the `bindings` npm package to locate its native .node file at runtime. This package (and its dependency file-uri-to-path) were not being included in the electron-builder output, causing the app to crash on startup with "Cannot find module 'bindings'" error. Changes: - Add bindings and file-uri-to-path to electron-builder files section - Add both packages to asarUnpack for proper path resolution - Update copy-native-modules.ts to also handle these dependencies 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Warning Rate limit exceeded@saddlepaddle has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 3 minutes and 4 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughAdds unpack/copy rules and dependencies for native-related modules in the Electron desktop build and refactors the native-module copy script to distinguish required vs optional native modules and to replace workspace symlinks with real files before packaging. Changes
Sequence Diagram(s)(omitted) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The `bindings` package (used by better-sqlite3 to locate its native .node file) was not being installed into the local node_modules because it's a transitive dependency that bun may keep in its global cache. Adding `bindings` and `file-uri-to-path` as explicit dependencies ensures they're installed locally and can be properly packaged by electron-builder. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
In bun workspaces, packages are hoisted to the monorepo root node_modules. Updated electron-builder paths and copy-native-modules script to use ../../node_modules/ instead of the local node_modules/. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
bun creates symlinks for direct dependencies in the workspace's node_modules, not the root. The explicit dependency additions (bindings, file-uri-to-path) will make bun create those symlinks. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The better-sqlite3 native module was compiled for bun's Node.js version (NODE_MODULE_VERSION 127) but Electron 39 requires NODE_MODULE_VERSION 140. Enabling npmRebuild allows electron-builder to rebuild native modules for Electron's Node.js version. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
node-pty requires node-addon-api during @electron/rebuild compilation. Adding as explicit dependency ensures bun creates symlink for it.
Migrations must be outside the asar archive for drizzle-orm to read them. Using extraResources places them at process.resourcesPath/resources/migrations/
Summary
bindingspackagebetter-sqlite3native module usesbindingsto locate its.nodefile at runtimebindingsandfile-uri-to-pathto electron-builder configurationcopy-native-modules.tsto handle these dependenciesTest plan
🤖 Generated with Claude Code
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.