fix(javascript): associate requested bindings only with resolved native addons (#6402)

* fix(javascript): associate requested bindings only with resolved native addons

* test(javascript): cover the exact native addon association

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
pablodiazjorgeandmorluto authored and GitHub committed 2026-10-23 17:55:43 +08:00
1 parent 99be47a9a3
commit 630e6becdf
2 files changed
+59 -1

No files matched your search

@@ -56,7 +56,13 @@ const addNativeBinding = (input: NativeBindingInput): void => {
? {}
: { moduleKind: value.module_kind }),
}).resolved_path;
const addon = resolved === null ? undefined : context.fileNodes.get(resolved);
// Extension probing can resolve `./addon.node` to `addon.node.js`; only a
// native-addon artifact can expose the requested binding.
const addon =
resolved === null ||
context.filesByPath.get(resolved)?.kind !== "native-addon"
? undefined
: context.fileNodes.get(resolved);
const binding = context.accumulator.addNode({
kind: "native-export",
identity: electronObservationIdentity(