From e145e3f5ef6ad27bc8b1b76fe51882ea3e043a24 Mon Sep 17 00:00:00 2001 From: sbs44 <83440025+sbs44@users.noreply.github.com> Date: Sat, 8 Aug 2026 12:03:57 -0400 Subject: [PATCH] fix(patches): drop runtime semver dependency from update service MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The packaged app crashed at startup with ERR_MODULE_NOT_FOUND: upstream 1.132.0 removed semver from its production dependency tree, and with esbuild bundling disabled the main process resolves bare imports from the shipped node_modules at runtime. Replace the single semver.compareBuild() call in _isLatestVersion with a local dotted-numeric comparator (the compared strings are normalized x.y.z release versions; no prerelease/build-metadata handling needed). Audited all patches for other bare package imports into src/ — the remaining ones are node: builtins or packages the patches add to dependencies (@vscodium/native-keymap, @vscodium/policy-watcher). --- patches/11-update-use-github-release.patch | 33 +++++++++++++++++----- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/patches/11-update-use-github-release.patch b/patches/11-update-use-github-release.patch index 4622142..cb43178 100644 --- a/patches/11-update-use-github-release.patch +++ b/patches/11-update-use-github-release.patch @@ -49,7 +49,7 @@ index 1afbb0d3..87c877fd 100644 + | "user"; \ No newline at end of file diff --git a/src/vs/platform/update/electron-main/abstractUpdateService.ts b/src/vs/platform/update/electron-main/abstractUpdateService.ts -index 09971caf..92552866 100644 +index 09971caf..9ae70a23 100644 --- a/src/vs/platform/update/electron-main/abstractUpdateService.ts +++ b/src/vs/platform/update/electron-main/abstractUpdateService.ts @@ -19,3 +19,3 @@ import { ILogService } from '../../log/common/log.js'; @@ -57,13 +57,12 @@ index 09971caf..92552866 100644 -import { IRequestService } from '../../request/common/request.js'; +import { asJson, IRequestService, NO_FETCH_TELEMETRY } from '../../request/common/request.js'; import { StorageScope, StorageTarget } from '../../storage/common/storage.js'; -@@ -23,3 +23,4 @@ import { IApplicationStorageMainService } from '../../storage/electron-main/stor +@@ -23,3 +23,3 @@ import { IApplicationStorageMainService } from '../../storage/electron-main/stor import { ITelemetryService } from '../../telemetry/common/telemetry.js'; -import { AvailableForDownload, DisablementReason, IUpdateService, State, StateType, UpdateType } from '../common/update.js'; +import { Architecture, AvailableForDownload, DisablementReason, IUpdate, IUpdateService, Platform, State, StateType, Target, UpdateType } from '../common/update.js'; -+import * as semver from 'semver'; -@@ -32,12 +33,8 @@ export interface IUpdateURLOptions { +@@ -32,12 +32,8 @@ export interface IUpdateURLOptions { -export function createUpdateURL(baseUpdateUrl: string, platform: string, quality: string, commit: string, options?: IUpdateURLOptions): string { - const url = new URL(`${baseUpdateUrl}/api/update/${platform}/${quality}/${commit}`); @@ -81,12 +80,32 @@ index 09971caf..92552866 100644 - - return url.toString(); } -@@ -535,3 +532,3 @@ export abstract class AbstractUpdateService extends Disposable implements IUpdat +@@ -98,2 +94,19 @@ function isCancellableState(type: StateType): boolean { + ++// Dotted-numeric version compare (release versions only — no prerelease or ++// build-metadata handling needed for the normalized x.y.z strings compared ++// below). Local so the packaged main process doesn't need the `semver` ++// package, which is no longer in upstream's production dependency tree. ++function compareVersions(a: string, b: string): number { ++ const pa = a.split('-')[0].split('.').map(Number); ++ const pb = b.split('-')[0].split('.').map(Number); ++ for (let i = 0; i < Math.max(pa.length, pb.length); i++) { ++ const na = pa[i] ?? 0; ++ const nb = pb[i] ?? 0; ++ if (na !== nb) { ++ return na < nb ? -1 : 1; ++ } ++ } ++ return 0; ++} ++ + export abstract class AbstractUpdateService extends Disposable implements IUpdateService { +@@ -535,3 +548,3 @@ export abstract class AbstractUpdateService extends Disposable implements IUpdat - if (mode === 'none') { + if (mode === 'none' || mode === 'manual') { return undefined; -@@ -545,17 +542,37 @@ export abstract class AbstractUpdateService extends Disposable implements IUpdat +@@ -545,17 +558,37 @@ export abstract class AbstractUpdateService extends Disposable implements IUpdat + return this._isLatestVersion(url, false) + .then((result) => { @@ -131,7 +150,7 @@ index 09971caf..92552866 100644 + + this.logService.info('update#isLatestVersion() - found version', fetchedVersion, currentVersion); + -+ const lastest = semver.compareBuild(currentVersion, fetchedVersion) >= 0; ++ const lastest = compareVersions(currentVersion, fetchedVersion) >= 0; + + return Promise.resolve({ lastest, update }); + })