4

I have just started learning Electron from the official Quick Start guide. At the end of the guide, they've recommended to use Electron Forge as the tool to create the distributable package. Another tool for the same purpose is Electron Builder.

I've used the latter before and out of curiosity I created the quick start app build with both the tools. To my surprise, there is a huge difference between the dmg builds that were created for the same app on MacOS:

  • Electron Forge - 180.9 MB
  • Electron Builder - 315.1 MB (628.3 MB after installation)

I understand the Electron builds are fairly large in size due to the shipment of Chromium and Node along with the package but this significant difference (~134.2 MB) between the builds of a quick start app is quite not clear to me.

package.json:

{
    "name": "my-electron-app",
    "version": "1.0.0",
    "description": "Hello World",
    "main": "main.js",
    "scripts": {
        "test": "test",
        "start": "electron-forge start",
        "package": "electron-forge package",
        "make": "electron-forge make"
    },
    "license": "MIT",
    "devDependencies": {
        "@electron-forge/cli": "^6.0.0-beta.57",
        "@electron-forge/maker-deb": "^6.0.0-beta.57",
        "@electron-forge/maker-rpm": "^6.0.0-beta.57",
        "@electron-forge/maker-squirrel": "^6.0.0-beta.57",
        "@electron-forge/maker-zip": "^6.0.0-beta.57",
        "electron": "^13.1.6",
        "electron-builder": "^22.11.7",
        "electron-log": "^4.3.5",
        "electron-reloader": "^1.2.1"
    },
    "dependencies": {
        "electron-squirrel-startup": "^1.0.0"
    },
    "config": {
        "forge": {
            "packagerConfig": {},
            "makers": [
                {
                    "name": "@electron-forge/maker-squirrel",
                    "config": {
                        "name": "my_electron_app"
                    }
                },
                {
                    "name": "@electron-forge/maker-zip",
                    "platforms": [
                        "darwin"
                    ]
                },
                {
                    "name": "@electron-forge/maker-deb",
                    "config": {}
                },
                {
                    "name": "@electron-forge/maker-rpm",
                    "config": {}
                }
            ]
        }
    }
}

I need help with the following questions:

  1. Why there is a huge difference for a simple quick starter app?
  2. Is there any way or standard practice with which we could reduce the final build size in Electron (besides npm prune, deleting node_modules and then creation of build as it had no effect)?
patrick.1729
  • 4,222
  • 2
  • 20
  • 29

0 Answers0