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.
This commit is contained in:
Juan Francisco Lebrero 2026-03-13 19:20:44 -03:00 committed by GitHub
parent 4959ecfd33
commit 9b0f31e39a
2 changed files with 10 additions and 22 deletions

View file

@ -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.");

View file

@ -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": {