capacitor-community / electron

Deploy your Capacitor apps to Linux, Mac, and Windows desktops, with the Electron platform! 🖥️
https://capacitor-community.github.io/electron/
MIT License
318 stars 58 forks source link

Including the package increases the build size by ~15 MB #278

Open ZimM-LostPolygon opened 5 months ago

ZimM-LostPolygon commented 5 months ago

Describe the bug Simply adding the package increases the build size by about 15 MB. It seems like the package drags along dev-only packages into production as part of node_modules. This negatively influences both the build size and the startup time.

To Reproduce Steps to reproduce the behavior:

  1. Create a new Electron Forge + Vite project with npm init electron-app@latest my-new-app -- --template=vite-typescript
  2. Run yarn package. Observe the resources in the build being around 200 KB in size.
  3. Run yarn add @capacitor-community/electron then yarn package. Observe the resources in the build being around 15 MB in size.

Expected behavior Since this package is basically a helper to glue Capacitor and Electron together, it shouldn't have any actual influence on the resulting build. Pretty much the only things normally used in runtime from the entire package are two lines:

import type { CapacitorElectronConfig } from '@capacitor-community/electron';
import { getCapacitorElectronConfig, setupElectronDeepLinking } from '@capacitor-community/electron';

Desktop (please complete the following information):

Additional context Same happens when an Electron project is created with npx cap add @capacitor-community/electron.