From f083f0633ddc498dfb608566516515f0a4f90ff1 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Fri, 22 Mar 2024 15:55:25 +0530 Subject: [PATCH] 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 --- desktop/docs/dependencies.md | 7 ------- desktop/package.json | 1 - desktop/src/main.ts | 15 --------------- desktop/yarn.lock | 9 +-------- 4 files changed, 1 insertion(+), 31 deletions(-) diff --git a/desktop/docs/dependencies.md b/desktop/docs/dependencies.md index 502ea6ea9d..4f2bd152d7 100644 --- a/desktop/docs/dependencies.md +++ b/desktop/docs/dependencies.md @@ -42,13 +42,6 @@ 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. -### electron-reload - -Reloads contents of the BrowserWindow (renderer process) when source files are -changed. - -* TODO (MR): Do we need this? Isn't the next-electron-server HMR covering this? - ## DX See [web/docs/dependencies#DX](../../web/docs/dependencies.md#dx) for the diff --git a/desktop/package.json b/desktop/package.json index 39e5d8b38a..0aa24aba3d 100644 --- a/desktop/package.json +++ b/desktop/package.json @@ -25,7 +25,6 @@ "chokidar": "^3.5.3", "compare-versions": "^6.1.0", "electron-log": "^4.3.5", - "electron-reload": "^2.0.0-alpha.1", "electron-store": "^8.0.1", "electron-updater": "^4.3.8", "ffmpeg-static": "^5.1.0", diff --git a/desktop/src/main.ts b/desktop/src/main.ts index 4de93046a3..0a1fbe818a 100644 --- a/desktop/src/main.ts +++ b/desktop/src/main.ts @@ -1,5 +1,4 @@ import { app, BrowserWindow } from "electron"; -import electronReload from "electron-reload"; import serveNextAt from "next-electron-server"; import { initWatcher } from "./services/chokidar"; import { isDev } from "./utils/common"; @@ -42,19 +41,6 @@ export const setIsUpdateAvailable = (value: boolean): void => { updateIsAvailable = value; }; -/** - * Hot reload the main process if anything changes in the source directory that - * we're running from. - * - * In particular, this gets triggered when the `tsc -w` rebuilds JS files in the - * `app/` directory when we change the TS files in the `src/` directory. - */ -const setupMainHotReload = () => { - if (isDev) { - electronReload(__dirname, {}); - } -}; - /** * The URL where the renderer HTML is being served from. */ @@ -77,7 +63,6 @@ const setupRendererServer = () => { serveNextAt(rendererURL); }; -setupMainHotReload(); setupRendererServer(); setupLogging(isDev); diff --git a/desktop/yarn.lock b/desktop/yarn.lock index b341cad169..5d4016b912 100644 --- a/desktop/yarn.lock +++ b/desktop/yarn.lock @@ -789,7 +789,7 @@ chalk@^4.0.0, chalk@^4.0.2, chalk@^4.1.2: ansi-styles "^4.1.0" supports-color "^7.1.0" -chokidar@^3.5.2, chokidar@^3.5.3: +chokidar@^3.5.3: version "3.5.3" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== @@ -1162,13 +1162,6 @@ electron-publish@24.5.0: lazy-val "^1.0.5" mime "^2.5.2" -electron-reload@^2.0.0-alpha.1: - version "2.0.0-alpha.1" - resolved "https://registry.yarnpkg.com/electron-reload/-/electron-reload-2.0.0-alpha.1.tgz#6cad98df96695ca1d5462dc9407f7c620028ce99" - integrity sha512-hTde7gv0TEqxbxlB3pj2CwoyCQ9sdiQrcP8GkpzhosxyVeYM3mZbMEVKCZK3L0fED7Mz5A9IWmK7zEvi4H3P1g== - dependencies: - chokidar "^3.5.2" - electron-store@^8.0.1: version "8.0.2" resolved "https://registry.yarnpkg.com/electron-store/-/electron-store-8.0.2.tgz#95c8cf81c1e1cf48b24f3ceeea24b921c1ff62d7"