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, ], };