From 78b95c07d852f5ce75fa894dab9d9dc84660bfe0 Mon Sep 17 00:00:00 2001 From: Robin Genz Date: Wed, 25 Nov 2026 16:43:02 +0100 Subject: [PATCH] fix(electron): export the CapacitorSQLite class from the bundle The bundle only had a default export since 7.0.0, so @capacitor-community/electron could not find the plugin class. The build now fails when the named export is missing. Co-Authored-By: Claude Fable 5.2 --- electron/rollup.config.mjs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/electron/rollup.config.mjs b/electron/rollup.config.mjs index 82532049..0f38be15 100644 --- a/electron/rollup.config.mjs +++ b/electron/rollup.config.mjs @@ -1,6 +1,15 @@ import commonjs from '@rollup/plugin-commonjs'; import nodeResolve from '@rollup/plugin-node-resolve'; +const assertCapacitorSQLiteExport = { + name: 'assert-capacitor-sqlite-export', + generateBundle(_outputOptions, bundle) { + if (!bundle['plugin.js'].exports.includes('CapacitorSQLite')) { + this.error('plugin.js has no CapacitorSQLite export, which @capacitor-community/electron looks up.'); + } + }, +}; + export default { input: 'electron/build/electron/src/index.js', output: [ @@ -28,8 +37,12 @@ export default { plugins: [ nodeResolve(), commonjs({ + // ALWAYS keep this. The default (true) drops the top level CapacitorSQLite export + // that @capacitor-community/electron looks up. + strictRequires: 'auto', ignoreDynamicRequires: true, dynamicRequireTargets: ['node_modules/@capacitor-community/sqlite/electron/dist/plugin.js'], }), + assertCapacitorSQLiteExport, ], };