Skip to content

bug: "CapacitorSQLite" plugin is not implemented on electron #667

Open

Description

@miau81

Plugin version:

version 7.0.1, 7.0.2

Platform(s):

@capacitor-community/electron v5.0.1 (WIndows 11)

Issues:

the plugin failed register while electron start;
the output of exported in rt/electron-plugins.js
module.exports = {
CapacitorCommunitySqlite
}
is: { CapacitorCommunitySqlite: { default: { CapacitorSQLite: [class CapacitorSQLite] } } }

compare with version 5, the exported which work fine is:
CapacitorCommunitySqlite: {
CapacitorSQLite: [class CapacitorSQLite], <=============== Missing this in version 7
default: { CapacitorSQLite: [class CapacitorSQLite] }
 }

i had tried manually populate it in electron-plugins.js (for version 7), then work fine too
module.exports = {
CapacitorCommunitySqlite:{
...CapacitorCommunitySqlite,
CapacitorSQLite:CapacitorCommunitySqlite.default.CapacitorSQLite
},
}

but this is not good solution, because every time ionic cap sync electron will overwrite back the rt/electron-plugins.js file.

Activity

  1. AlejandroMHOB commented on Sep 16, 2026

    @AlejandroMHOB

    Additional Context: ESM/CJS Resolution Issues in Hybrid Environments (@capacitor-community/electron)

    Hi team,

    I wanted to provide some additional context regarding module resolution failures when using @capacitor-community/sqlite (v7+) alongside @capacitor-community/electron (or legacy Electron runners).

    Problem Breakdown

    Starting with recent major updates, @capacitor-community/sqlite shifted its entry points to be ESM-first ("type": "module" in package.json), dropping fallback CommonJS exports for the web/renderer bindings.

    While this aligns with modern bundlers (Vite, esbuild, Angular 19+), it breaks the plugin generator in @capacitor-community/electron. The Electron platform runner dynamically generates an electron-plugins.js file using synchronous CommonJS require() calls:

    const CapacitorCommunitySqlite = require('..\\..\\..\\node_modules\\@capacitor-community\\sqlite\\electron\\dist\\plugin.js');

    module.exports = { CapacitorCommunitySqlite, ... }


    Workaround vs. Long-term Fix

    Long-term Fix

    Since @capacitor-community/electron is largely unmaintained and lacks support for ESM-only plugins, the community-recommended path for modern Capacitor apps (Capacitor 6/7/8 with Angular 19+, Vite, or esbuild) is to migrate to the newly built and actively maintained alternative by Capawesome:

    👉 Capawesome Capacitor Electron Platform (@capawesome/capacitor-electron)

    It has been rewritten from scratch with full native support for modern ESM packages, Node 22+, and modern build pipelines, eliminating these resolution issues altogether.

    Workaround by Sqlite dependency's developers side

    Developers currently bypass this either by patching package.json to expose a dual-package export (main / module / exports with CJS wrappers) or by manually patching the runner generator.

    Having an explicit CommonJS bundle or dual ESM/CJS export in package.json for the plugin's web/electron entry points would prevent runtime crashes for projects using CommonJS-based platform runners.


    I hope that the added information can help to understand the problem from developers and mantainers, to fix the problem by other developers facing the same issues.

    Greeting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions