mirror of
https://github.com/morluto/rea
synced 2026-10-25 22:08:11 -04:00
9200adea61
Route exported external import-equals declarations through the same relationship owner as plain declarations so their required target is not dropped. Fixes #6655
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import { writeFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
|
|
import { expect, it } from "vitest";
|
|
|
|
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
|
import { importReferenceSource } from "../../support/referenceSourceResourceScope.js";
|
|
|
|
it("retains external-module targets from exported and plain import-equals declarations", async () => {
|
|
const root = await createTestTempDirectory(
|
|
"rea-reference-exported-import-equals-",
|
|
);
|
|
await Promise.all([
|
|
writeFile(
|
|
join(root, "exported.cts"),
|
|
'export import dep = require("./dep.cjs");\n',
|
|
),
|
|
writeFile(
|
|
join(root, "plain.cts"),
|
|
'import dep = require("./dep.cjs"); export { dep };\n',
|
|
),
|
|
writeFile(join(root, "dep.cjs"), "module.exports = { value: 1 };\n"),
|
|
]);
|
|
|
|
const result = await importReferenceSource({
|
|
root,
|
|
caller: "reference-exported-import-equals-test",
|
|
policy: { secretPatterns: [] },
|
|
});
|
|
if (!result.ok) throw result.error;
|
|
expect(result.value.parse_failures).toEqual([]);
|
|
expect(result.value.relationships).toEqual(
|
|
expect.arrayContaining([
|
|
{
|
|
from_path: "exported.cts",
|
|
to: "dep.cjs",
|
|
kind: "requires",
|
|
resolution: "internal",
|
|
parse_state: "parsed",
|
|
},
|
|
{
|
|
from_path: "plain.cts",
|
|
to: "dep.cjs",
|
|
kind: "requires",
|
|
resolution: "internal",
|
|
parse_state: "parsed",
|
|
},
|
|
]),
|
|
);
|
|
expect(result.value.relationships).toHaveLength(2);
|
|
});
|