fix(preload): read appVersion from package.json instead of npm_package_version
`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) <noreply@anthropic.com>
This commit is contained in:
@@ -28,6 +28,13 @@ import {
|
|||||||
type UpdateCheckResult,
|
type UpdateCheckResult,
|
||||||
type UpdateProgress,
|
type UpdateProgress,
|
||||||
} from './ipc-types';
|
} 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;
|
type Unsubscribe = () => void;
|
||||||
|
|
||||||
@@ -40,7 +47,7 @@ function on<T>(channel: string, cb: (payload: T) => void): Unsubscribe {
|
|||||||
const api = {
|
const api = {
|
||||||
platform: ELECTRON_RUNTIME_MARKER,
|
platform: ELECTRON_RUNTIME_MARKER,
|
||||||
osPlatform: process.platform as NodeJS.Platform,
|
osPlatform: process.platform as NodeJS.Platform,
|
||||||
appVersion: process.env.npm_package_version ?? '0.0.0',
|
appVersion: pkg.version,
|
||||||
|
|
||||||
// Screen sources ---------------------------------------------------------
|
// Screen sources ---------------------------------------------------------
|
||||||
getScreenSources: (): Promise<ScreenSource[]> => ipcRenderer.invoke(CHANNELS.SCREEN_GET_SOURCES),
|
getScreenSources: (): Promise<ScreenSource[]> => ipcRenderer.invoke(CHANNELS.SCREEN_GET_SOURCES),
|
||||||
|
|||||||
Reference in New Issue
Block a user