From 9b0f31e39af295a8311a4d4a9317b679071c7464 Mon Sep 17 00:00:00 2001 From: Juan Francisco Lebrero <101231690+frizynn@users.noreply.github.com> Date: Fri, 13 Mar 2026 19:20:44 -0300 Subject: [PATCH] fix: use version ranges for native engine optional dependencies (#286) The v2.10.5 release broke on darwin-arm64 because the main package was published before the native CI built and published the platform packages. With exact version pinning, npm silently skips the optional dep when the version doesn't exist, causing a fatal crash. Change to >=2.10.2 range so npm installs the latest available binary. The native API is stable across patch versions. Also stop sync-platform-versions.cjs from overwriting the ranges back to exact versions during CI. --- native/scripts/sync-platform-versions.cjs | 22 +++++----------------- package.json | 10 +++++----- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/native/scripts/sync-platform-versions.cjs b/native/scripts/sync-platform-versions.cjs index 13f152af2..60c7a388c 100644 --- a/native/scripts/sync-platform-versions.cjs +++ b/native/scripts/sync-platform-versions.cjs @@ -44,22 +44,10 @@ for (const platform of platformPackages) { } } -// Update optionalDependencies in root package.json -let rootChanged = false; -const optDeps = rootPkg.optionalDependencies || {}; -for (const platform of platformPackages) { - const depName = `@gsd-build/engine-${platform}`; - if (optDeps[depName] && optDeps[depName] !== version) { - console.log(` root optionalDependencies ${depName}: ${optDeps[depName]} -> ${version}`); - optDeps[depName] = version; - rootChanged = true; - } -} - -if (rootChanged) { - rootPkg.optionalDependencies = optDeps; - fs.writeFileSync(rootPkgPath, JSON.stringify(rootPkg, null, 2) + "\n"); - console.log(" Updated root package.json optionalDependencies"); -} +// Skip updating root optionalDependencies — they use a >=2.10.2 range +// intentionally so that npm can fall back to the latest available +// platform binary when the exact version hasn't been published yet +// (e.g. main package published before native CI finishes). +console.log(" root optionalDependencies: using range specifiers (not updating)"); console.log("[sync-platform-versions] Done."); diff --git a/package.json b/package.json index afb2a7f76..70365f92d 100644 --- a/package.json +++ b/package.json @@ -82,11 +82,11 @@ "typescript": "^5.4.0" }, "optionalDependencies": { - "@gsd-build/engine-darwin-arm64": "2.10.5", - "@gsd-build/engine-darwin-x64": "2.10.5", - "@gsd-build/engine-linux-x64-gnu": "2.10.5", - "@gsd-build/engine-linux-arm64-gnu": "2.10.5", - "@gsd-build/engine-win32-x64-msvc": "2.10.5", + "@gsd-build/engine-darwin-arm64": ">=2.10.2", + "@gsd-build/engine-darwin-x64": ">=2.10.2", + "@gsd-build/engine-linux-x64-gnu": ">=2.10.2", + "@gsd-build/engine-linux-arm64-gnu": ">=2.10.2", + "@gsd-build/engine-win32-x64-msvc": ">=2.10.2", "fsevents": "~2.3.3" }, "overrides": {