chore(deps): drop better-sqlite3 and its desktop packaging support

The SQLite write into OpenCode's database was the only consumer of
better-sqlite3 in the repository. Everything that existed to ship its native
binary went with it:

- the dependency in @openchamber/web and @openchamber/electron
- the afterPack hook staging better_sqlite3.node into app.asar.unpacked
- a dedicated @electron/rebuild pass (onlyModules) and its binary assertion,
  so desktop packaging now runs one native rebuild instead of two
- the bundler external entry and the AppImage required-native-module check

Desktop packaging, the AppImage verification tests, and the extension bundle
were re-validated after a clean reinstall, so no stale module could satisfy a
missed import.
This commit is contained in:
Bohdan Triapitsyn
2026-08-03 23:38:01 +03:00
parent 4c0fc25ac8
commit 56f2b972f0
10 changed files with 6 additions and 47 deletions
-17
View File
@@ -5,23 +5,6 @@ module.exports = (context) => {
const resourcesPath = context.electronPlatformName === 'darwin'
? path.join(context.appOutDir, `${context.packager.appInfo.productFilename}.app`, 'Contents', 'Resources')
: path.join(context.appOutDir, 'resources');
const betterSqliteDir = path.dirname(require.resolve('better-sqlite3/package.json'));
const betterSqliteBinary = path.join(betterSqliteDir, 'build', 'Release', 'better_sqlite3.node');
if (!fs.existsSync(betterSqliteBinary)) {
throw new Error(`Missing rebuilt better-sqlite3 binary at ${betterSqliteBinary}`);
}
const packagedBetterSqliteBinary = path.join(
resourcesPath,
'app.asar.unpacked',
'node_modules',
'better-sqlite3',
'build',
'Release',
'better_sqlite3.node',
);
fs.mkdirSync(path.dirname(packagedBetterSqliteBinary), { recursive: true });
fs.copyFileSync(betterSqliteBinary, packagedBetterSqliteBinary);
if (context.electronPlatformName !== 'darwin') return;
const sourceAssetsPath = path.join(__dirname, '..', 'resources', 'icons', 'Assets.car');
@@ -30,7 +30,6 @@ const result = await Bun.build({
'@openchamber/web/*',
'bun-pty',
'node-pty',
'better-sqlite3',
],
minify: false,
sourcemap: 'none',
@@ -133,19 +133,6 @@ const ensureWindowsNodeAddonApiForNodePty = async (rebuildRootPath) => {
console.log(`[electron] rebuilding native modules against Electron ${electronVersion}...`);
await rebuild({
buildPath: electronDir,
electronVersion,
force: true,
arch: targetArchitecture.electronBuilder,
onlyModules: ['better-sqlite3'],
});
const betterSqliteDir = path.dirname(require.resolve('better-sqlite3/package.json'));
const betterSqliteBinary = path.join(betterSqliteDir, 'build', 'Release', 'better_sqlite3.node');
if (!existsSync(betterSqliteBinary)) {
throw new Error(`better-sqlite3 rebuild did not produce ${betterSqliteBinary}`);
}
// Rebuild against the hoisted root node_modules (bun workspace layout).
// force=true re-links regardless of cached state; prebuild-install lookup is
// bypassed by @electron/rebuild in favor of direct node-gyp builds.
@@ -13,7 +13,7 @@ const ELF_MACHINE = { x64: 62, arm64: 183 };
// sherpa-onnx-node loads this Node-API addon from its platform-specific prebuilt
// package in the separate server worker, so verify its architecture here rather
// than Electron-rebuilding it with the source-built modules.
const REQUIRED_NATIVE_MODULES = ['better_sqlite3.node', 'pty.node', 'sherpa-onnx.node'];
const REQUIRED_NATIVE_MODULES = ['pty.node', 'sherpa-onnx.node'];
/** electron-builder AppImage arch token: x64 → x86_64, arm64 → arm64 */
export const linuxAppImageArchSuffix = (architecture) => (
@@ -21,7 +21,7 @@ const createPayload = () => {
].join('\n'));
writeElf(path.join(root, 'openchamber'), 'x64');
writeElf(path.join(root, 'resources/opencode-cli/opencode'), 'x64');
for (const name of ['better_sqlite3.node', 'pty.node', 'sherpa-onnx.node']) {
for (const name of ['pty.node', 'sherpa-onnx.node']) {
writeElf(path.join(root, 'resources/app.asar.unpacked/node_modules', name), 'x64');
}
return root;
@@ -53,7 +53,7 @@ test('verifies identity, version, and native payload architecture', () => {
expectedOpenCodeVersion: '1.17.18',
runCliVersion: () => '1.17.18',
});
assert.equal(result.nativeModuleCount, 3);
assert.equal(result.nativeModuleCount, 2);
} finally {
fs.rmSync(root, { recursive: true, force: true });
}