capacitor-community / capacitor-community/electron

Plugins aren't auto registered with bundled Capacitor Core

Open
#115 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
398
Forks
63
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
When I use Capacitor with `bundledWebRuntime` enabled, installed Plugins aren't automatically registered. Only after the plugin is `required` it gets registered. So you can't use `Capacitor.Plugins.MyPlugin` directly, as if you're using the Android or iOS platform. You've to use `require("my-plugin")` first.

**To Reproduce**
1. Create a new basic app: `npm init @capacitor/app`
3. Add the Electron platform: `npm i @capacitor-community/electron` and `npx cap add @capacitor-community/electron`
4. Install the Dialog plugin: `npm install @capacitor/dialog`, `npx cap sync` and `npx cap sync @capacitor-community/electron`
5. Run the Electron app: `npx cap open @capacitor-community/electron`
6. Enter the following code into the console and you'll get an `Uncaught TypeError` error: `Capacitor.Plugins.Dialog.alert({ title: 'Test', message: 'This is a test', });`
7. Enter `require('@capacitor/dialog');`, repeat the above code and now it works.

**Expected behavior**
You shouldn't have to extra `require` the plugin.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.