ente/desktop/docs/dependencies.md
Manav Rathi f083f0633d
Remove electron-reload
It reloads the BrowserWindow, but that already has HMR since we're connecting to
a Next dev server on localhost.

What we want is the main process to reload if the files for the main process are
changed. All options I've found so far just restart the main app on changes to
the main process code. I'm not sure that'll be useful, so not adding them right
now (and in any case, this is not a regression, it just wasn't working with
electron-reload either). For future reference if I need to revisit this, these
are the things I scouted:

- https://www.electronforge.io/config/plugins/webpack
- https://github.com/sindresorhus/electron-reloader
- https://electron-vite.org/guide/hot-reloading.html
2024-03-22 15:55:25 +05:30

2.2 KiB

Dependencies

Electron

Electron is a cross-platform (Linux, Windows, macOS) way for creating desktop apps using TypeScript.

Electron embeds Chromium and Node.js in the generated app's binary. The generated app thus consists of two separate processes - the main process, and a renderer process.

  • The main process is runs the embedded node. This process can deal with the host OS - it is conceptually like a node repl running on your machine. In our case, the TypeScript code (in the src/ directory) gets transpiled by tsc into JavaScript in the build/app/ directory, which gets bundled in the generated app's binary and is loaded by the node (main) process when the app starts.

  • The renderer process is a regular web app that gets loaded into the embedded Chromium. When the main process starts, it creates a new "window" that shows this embedded Chromium. In our case, we build and bundle a static export of the Photos web app in the generated app. This gets loaded by the embedded Chromium at runtime, acting as the app's UI.

There is also a third environment that gets temporarily created:

  • The preload script acts as a gateway between the main and the renderer process. It runs in its own isolated environment.

electron-builder

Electron Builder is used for packaging the app for distribution.

During the build it uses electron-builder-notarize to notarize the macOS binary.

next-electron-server

This spins up a server for serving files using a protocol handler inside our Electron process. This allows us to directly use the output produced by next build for loading into our renderer process.

DX

See web/docs/dependencies#DX for the general development experience related dependencies like TypeScript etc, which are similar to that in the web code.

Some extra ones specific to the code here are:

  • concurrently for spawning parallel tasks when we do yarn dev.