fix: include darwin-arm64 native binary in npm tarball (Phase A hotfix)

The native .node binary was excluded from npm pack due to native/.gitignore
ignoring addon/. Add native/.npmignore (overrides .gitignore for npm) and
include native/addon in the files whitelist. Also improve the error message
in the native loader to list supported platforms and link to issues.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Lex Christopherson 2026-03-13 14:33:37 -06:00
parent d641a48895
commit d49af589d0
3 changed files with 12 additions and 1 deletions

1
native/.npmignore Normal file
View file

@ -0,0 +1 @@
target/

View file

@ -25,6 +25,7 @@
"pkg",
"src/resources",
"scripts/postinstall.js",
"native/addon",
"package.json",
"README.md"
],

View file

@ -33,10 +33,19 @@ function loadNative(): Record<string, unknown> {
}
const details = errors.map((e) => ` - ${e}`).join("\n");
const supportedPlatforms = [
"darwin-arm64",
"darwin-x64",
"linux-x64",
"linux-arm64",
"win32-x64",
];
throw new Error(
`Failed to load gsd_engine native addon for ${platformTag}.\n\n` +
`Tried:\n${details}\n\n` +
`Build with: npm run build:native -w @gsd/native`,
`Supported platforms: ${supportedPlatforms.join(", ")}\n` +
`If your platform is listed, try reinstalling: npm i -g gsd-pi\n` +
`Otherwise, please open an issue: https://github.com/gsd-build/gsd-2/issues`,
);
}