perf(javascript): cache canonical export comparison sort keys (#1028)

This commit is contained in:
morluto
2026-10-08 04:35:32 +08:00
committed by GitHub
parent 28d5c397c8
commit 63ba7424c0
4 changed files with 58 additions and 31 deletions
@@ -135,9 +135,13 @@ describe("source-produced export comparison inventories", () => {
`export const candidate${String(index)} = ${String(index)};`,
).join("\n");
const inventorySource = `export default function parse(value) {\n${returnSites}\n throw new Error("no match");\n}\n${extraExports}`;
const pairedVariantsSource = `export default function parse(value) {
${returnSites}
throw new Error("no match");
}`;
const [inventoryLeft, inventoryRight] = await Promise.all([
analyzeSourceEvidence(inventorySource),
analyzeSourceEvidence(inventorySource),
analyzeSourceEvidence(pairedVariantsSource),
]);
const variants = compareEvidence(inventoryLeft, inventoryRight);
expect(variants.left).toMatchObject({ status: "selected" });