ci+loader: build with --platform; ship napi-generated loader
The Windows Node 18 and Node 20 CI jobs failed because:
- ci.yml ran 'napi build --release' (no --platform), which produces a
filename without the target triple ('wickra.node').
- The committed loader at bindings/node/index.js looked for the
triple-suffixed file ('wickra.win32-x64-msvc.node') and then for the
per-platform npm subpackage as a fallback.
- 'wickra-win32-x64-msvc' isn't on npm yet (blocked by the spam filter),
so Windows had nothing to load. Linux and macOS passed only because
their optionalDependencies do exist on npm and got fetched.
Two-part fix:
- ci.yml now runs 'napi build --platform --release', matching release.yml.
--platform encodes the target triple in the filename, so the loader's
primary lookup always finds the freshly built binary on every host.
- bindings/node/index.js is now the canonical napi-rs auto-generated
loader (it gets regenerated by 'napi build'). It covers all the platforms
napi knows about (linux glibc/musl, Android, FreeBSD, ARM, etc.) rather
than just the four we publish, so unsupported platforms get a clear
'this binding isn't built for your system' error instead of a confusing
ENOENT.
Local sanity: 'npx napi build --platform --release' then 'node --test
__tests__/' succeeds end to end on Windows; the eight existing tests
pass.
This commit is contained in:
@@ -146,7 +146,11 @@ jobs:
|
||||
|
||||
- name: Build native module
|
||||
working-directory: bindings/node
|
||||
run: npx napi build --release
|
||||
# --platform puts the target triple into the filename so the loader's
|
||||
# `wickra.<target>.node` lookup finds the freshly built binary instead
|
||||
# of falling back to the per-platform npm subpackage (which doesn't
|
||||
# exist yet for win32-x64-msvc).
|
||||
run: npx napi build --platform --release
|
||||
|
||||
- name: Run Node tests
|
||||
working-directory: bindings/node
|
||||
|
||||
Reference in New Issue
Block a user