From 87c2e45bb43a0bf0104006d536f7b42b64749679 Mon Sep 17 00:00:00 2001 From: byGalax Date: Wed, 13 May 2026 22:33:18 +0200 Subject: [PATCH] fix(preload): read appVersion from package.json instead of npm_package_version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `appVersion: process.env.npm_package_version ?? '0.0.0'` only worked in dev — pnpm sets that env var while running its lifecycle scripts. In the packaged Electron build npm_package_version is unset, so every installed user saw `v0.0.0` on the Changelog page and the version badge permanently flagged them as "Update verfügbar" against their own actually-current version. Replace with a static `import pkg from '../package.json'` so Vite inlines the version string into the preload bundle at build time. The release script bumps package.json before electron-builder runs, so the inlined value always matches the freshly-released version. resolveJsonModule + esModuleInterop are already on in tsconfig.node. Co-Authored-By: Claude Opus 4.7 (1M context) --- apps/desktop/electron/preload.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/desktop/electron/preload.ts b/apps/desktop/electron/preload.ts index 17ed4b6..55da108 100644 --- a/apps/desktop/electron/preload.ts +++ b/apps/desktop/electron/preload.ts @@ -28,6 +28,13 @@ import { type UpdateCheckResult, type UpdateProgress, } from './ipc-types'; +// Static import of the desktop package.json so the bundler inlines the +// version string at build time. The previous `process.env.npm_package_- +// version` approach worked in dev (pnpm sets it as a script env var) but +// fell back to '0.0.0' in packaged builds — every installed user got +// flagged as "Update verfügbar" against their own actually-current +// version. resolveJsonModule + esModuleInterop are on in tsconfig.node. +import pkg from '../package.json'; type Unsubscribe = () => void; @@ -40,7 +47,7 @@ function on(channel: string, cb: (payload: T) => void): Unsubscribe { const api = { platform: ELECTRON_RUNTIME_MARKER, osPlatform: process.platform as NodeJS.Platform, - appVersion: process.env.npm_package_version ?? '0.0.0', + appVersion: pkg.version, // Screen sources --------------------------------------------------------- getScreenSources: (): Promise => ipcRenderer.invoke(CHANNELS.SCREEN_GET_SOURCES),