fix(javascript): preserve native export facts in comparisons

This commit is contained in:
morluto committed 2026-10-27 07:40:55 +08:00
1 parent c74059d89f
commit 046c4ce353
5 files changed
+295 -40

No files matched your search

@@ -1,3 +1,4 @@
import { nativeExportCorrespondenceKey } from "./javascriptNativeExportFacts.js";
import { canonicalJson } from "../comparisonSemantics.js";
import {
compareUnicodeCodePoints,
@@ -271,21 +272,7 @@ const semanticValue = (
exactString(properties.api_key) ??
nonEmptyString(properties.api_name)
);
if (node.kind === "native-export")
return (
joined(
properties.specifier,
compositeKey([
stringList(properties.requested_members),
typeof properties.namespace_access === "boolean"
? properties.namespace_access
: null,
typeof properties.dynamic_member_access === "boolean"
? properties.dynamic_member_access
: null,
]),
) ?? firstLabel(node)
);
if (node.kind === "native-export") return nativeExportCorrespondenceKey(node);
if (
[
"electron-main",
@@ -334,13 +321,6 @@ const nonEmptyString = (value: unknown): string | null =>
const exactString = (value: unknown): string | null =>
typeof value === "string" ? value : null;
const stringList = (value: unknown): string[] =>
Array.isArray(value)
? value
.filter((item): item is string => typeof item === "string")
.sort(compareUnicodeCodePoints)
: [];
const sortedNodes = (nodes: Iterable<ApplicationNode>): ApplicationNode[] =>
[...nodes].sort((left, right) =>
compareUnicodeCodePoints(left.node_id, right.node_id),