mirror of
https://github.com/morluto/rea.git
synced 2026-11-09 08:17:02 +00:00
test: extract shared fixtures, drop knip carve-outs (#627)
* refactor(domain): consolidate canonical ordering and digest helpers (#624) * refactor(domain): consolidate canonical ordering and digest helpers Single owner for code-point ordering (domain/canonicalOrdering.ts) and canonical JSON digests (domain/comparisonSemantics.ts). Delete all local compareCodePoints/compareText/digestCanonical duplicates and migrate every importer. No re-export shims. * fix(ci): allow slower real browser startup * chore(config): remove dead eslint, dedupe scripts, cacheable turbo tasks Delete eslint.config.js (oxlint is the linter), drop lint:dead alias, pin smol-toml, fold jscpd/scan:todos into check:pr, make test:run cacheable, align oxlint ignores. * fix(config): hash all test inputs for cached runs * docs: fix architecture diagram and pretty-print tool catalog Drop dangling REPLAY edges, add dotnet/reference/error/evaluation nodes. Emit 2-space JSON from the catalog generator and regenerate. * test: extract shared fixtures, drop knip carve-outs Dedupe android/apple session tests, bundler adapter headers, and reconstruction helpers into tests/support fixtures. Delete unused type aliases and the knip ignoreIssues block. Lower jscpd threshold 2.7 to 2.5.
This commit is contained in:
1 parent
5e7f35c7c3
commit
55e5eb090b
14 files changed
+375
-354
No files matched your search
+29
-30
@@ -184,26 +184,18 @@ it("keeps suffix-named ASAR directories in the graph and analyzes their files",
|
||||
),
|
||||
).toBe(true);
|
||||
|
||||
const result = await reconstructJavaScriptArtifact({
|
||||
input_path: archive,
|
||||
format: "asar",
|
||||
});
|
||||
|
||||
expect(result.statistics.parsed_javascript_files).toBeGreaterThan(0);
|
||||
expect(result.graph.nodes).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
kind: "javascript-asset",
|
||||
observations: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
properties: expect.objectContaining({
|
||||
path: "node_modules/@zip.js/entry.js",
|
||||
}),
|
||||
await reconstructAsarArchive(archive, [
|
||||
expect.objectContaining({
|
||||
kind: "javascript-asset",
|
||||
observations: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
properties: expect.objectContaining({
|
||||
path: "node_modules/@zip.js/entry.js",
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
]),
|
||||
);
|
||||
}),
|
||||
]),
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
it("keeps ASAR analysis usable when unpacked native companion bytes are absent", async () => {
|
||||
@@ -228,17 +220,9 @@ it("keeps ASAR analysis usable when unpacked native companion bytes are absent",
|
||||
]),
|
||||
});
|
||||
|
||||
const result = await reconstructJavaScriptArtifact({
|
||||
input_path: archive,
|
||||
format: "asar",
|
||||
});
|
||||
|
||||
expect(result.statistics.parsed_javascript_files).toBeGreaterThan(0);
|
||||
expect(result.graph.nodes).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({ kind: "javascript-asset" }),
|
||||
]),
|
||||
);
|
||||
await reconstructAsarArchive(archive, [
|
||||
expect.objectContaining({ kind: "javascript-asset" }),
|
||||
]);
|
||||
});
|
||||
|
||||
it("recurses into filesystem-backed ASAR containers without losing container-relative paths", async () => {
|
||||
@@ -360,6 +344,21 @@ const assertSemanticLinks = (
|
||||
expect(endpointJson).toContain("token=fixture-secret");
|
||||
};
|
||||
|
||||
const reconstructAsarArchive = async (
|
||||
archive: string,
|
||||
expectedNodes: readonly unknown[],
|
||||
): Promise<Awaited<ReturnType<typeof reconstructJavaScriptArtifact>>> => {
|
||||
const result = await reconstructJavaScriptArtifact({
|
||||
input_path: archive,
|
||||
format: "asar",
|
||||
});
|
||||
expect(result.statistics.parsed_javascript_files).toBeGreaterThan(0);
|
||||
expect(result.graph.nodes).toEqual(
|
||||
expect.arrayContaining([...expectedNodes]),
|
||||
);
|
||||
return result;
|
||||
};
|
||||
|
||||
const fixtureDirectory = async (): Promise<string> => {
|
||||
const root = await createTestTempDirectory("rea-javascript-artifact-");
|
||||
await writeJavaScriptArtifactFixture(root);
|
||||
|
||||
@@ -1,29 +1,43 @@
|
||||
import { mkdir, writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
|
||||
import { reconstructJavaScriptArtifact } from "../../../src/application/JavaScriptArtifactReconstruction.js";
|
||||
import type {
|
||||
ApplicationEdge,
|
||||
ApplicationNode,
|
||||
JavaScriptApplicationGraph,
|
||||
} from "../../../src/domain/javascriptApplicationGraph.js";
|
||||
import {
|
||||
findChunkNode,
|
||||
findGraphEdge,
|
||||
findModuleNodeByKey,
|
||||
reconstructJavaScriptFixture,
|
||||
writeFixtureFiles,
|
||||
} from "../../support/javascriptApplicationFixture.js";
|
||||
|
||||
describe("Webpack and Rspack runtime adapters", () => {
|
||||
it("recovers runtime entry modules, async chunks, and factory require aliases", async () => {
|
||||
const root = await bundlerFixture();
|
||||
const result = await reconstructJavaScriptArtifact({ input_path: root });
|
||||
const result = await reconstructJavaScriptFixture(root);
|
||||
const graph = result.graph;
|
||||
|
||||
const webpackEntry = chunk(graph, "webpackChunkcustomPortal", "main");
|
||||
const webpackLazy = chunk(graph, "webpackChunkcustomPortal", "lazy");
|
||||
const webpackModule = moduleNode(graph, "10");
|
||||
const rspackEntry = chunk(graph, "rspackChunkcustomPortal", "editor");
|
||||
const rspackModel = chunk(graph, "rspackChunkcustomPortal", "model");
|
||||
const rspackModule = moduleNode(graph, "src/entry.ts");
|
||||
const webpackEntry = findChunkNode(
|
||||
graph,
|
||||
"webpackChunkcustomPortal",
|
||||
"main",
|
||||
);
|
||||
const webpackLazy = findChunkNode(
|
||||
graph,
|
||||
"webpackChunkcustomPortal",
|
||||
"lazy",
|
||||
);
|
||||
const webpackModule = findModuleNodeByKey(graph, "10");
|
||||
const rspackEntry = findChunkNode(
|
||||
graph,
|
||||
"rspackChunkcustomPortal",
|
||||
"editor",
|
||||
);
|
||||
const rspackModel = findChunkNode(
|
||||
graph,
|
||||
"rspackChunkcustomPortal",
|
||||
"model",
|
||||
);
|
||||
const rspackModule = findModuleNodeByKey(graph, "src/entry.ts");
|
||||
|
||||
expect(webpackEntry?.observations[0]?.properties).toMatchObject({
|
||||
bundler: "webpack",
|
||||
@@ -49,32 +63,42 @@ describe("Webpack and Rspack runtime adapters", () => {
|
||||
runtime_entry: true,
|
||||
});
|
||||
|
||||
expect(edge(graph, webpackEntry, webpackModule, "loads")).toMatchObject({
|
||||
expect(
|
||||
findGraphEdge(graph, webpackEntry, webpackModule, "loads"),
|
||||
).toMatchObject({
|
||||
properties: expect.objectContaining({
|
||||
kind: "bundler-entry-module",
|
||||
resolution_status: "resolved",
|
||||
}),
|
||||
});
|
||||
expect(edge(graph, webpackEntry, webpackLazy, "imports")).toMatchObject({
|
||||
expect(
|
||||
findGraphEdge(graph, webpackEntry, webpackLazy, "imports"),
|
||||
).toMatchObject({
|
||||
properties: expect.objectContaining({
|
||||
kind: "bundler-async-chunk",
|
||||
resolution_status: "resolved",
|
||||
}),
|
||||
});
|
||||
expect(edge(graph, webpackModule, webpackLazy, "imports")).toMatchObject({
|
||||
expect(
|
||||
findGraphEdge(graph, webpackModule, webpackLazy, "imports"),
|
||||
).toMatchObject({
|
||||
properties: expect.objectContaining({
|
||||
kind: "dynamic-import",
|
||||
specifier: "chunk:lazy",
|
||||
resolved_path: "renderer/chunks/runtime.js#chunk:lazy",
|
||||
}),
|
||||
});
|
||||
expect(edge(graph, rspackEntry, rspackModel, "imports")).toMatchObject({
|
||||
expect(
|
||||
findGraphEdge(graph, rspackEntry, rspackModel, "imports"),
|
||||
).toMatchObject({
|
||||
properties: expect.objectContaining({
|
||||
kind: "bundler-async-chunk",
|
||||
resolution_status: "resolved",
|
||||
}),
|
||||
});
|
||||
expect(edge(graph, rspackModule, rspackModel, "imports")).toMatchObject({
|
||||
expect(
|
||||
findGraphEdge(graph, rspackModule, rspackModel, "imports"),
|
||||
).toMatchObject({
|
||||
properties: expect.objectContaining({
|
||||
kind: "dynamic-import",
|
||||
specifier: "chunk:model",
|
||||
@@ -103,11 +127,9 @@ describe("Webpack and Rspack runtime adapters", () => {
|
||||
|
||||
it("recovers esbuild wrapper modules and Vite preload dependencies", async () => {
|
||||
const root = await esmRuntimeFixture();
|
||||
const { graph } = await reconstructJavaScriptArtifact({
|
||||
input_path: root,
|
||||
});
|
||||
const commonJsModule = moduleNode(graph, "src/dep.js");
|
||||
const esmModule = moduleNode(graph, "src/core.js");
|
||||
const { graph } = await reconstructJavaScriptFixture(root);
|
||||
const commonJsModule = findModuleNodeByKey(graph, "src/dep.js");
|
||||
const esmModule = findModuleNodeByKey(graph, "src/core.js");
|
||||
|
||||
expect(commonJsModule?.observations[0]?.properties).toMatchObject({
|
||||
bundler: "esbuild",
|
||||
@@ -132,10 +154,8 @@ describe("Webpack and Rspack runtime adapters", () => {
|
||||
|
||||
const bundlerFixture = async (): Promise<string> => {
|
||||
const root = await createTestTempDirectory("rea-bundler-adapters-");
|
||||
await mkdir(join(root, "renderer", "chunks"), { recursive: true });
|
||||
await writeFile(
|
||||
join(root, "renderer", "chunks", "runtime.js"),
|
||||
`
|
||||
await writeFixtureFiles(root, {
|
||||
"renderer/chunks/runtime.js": `
|
||||
var __webpack_module_cache__ = {};
|
||||
(globalThis["webpackChunkcustomPortal"] = globalThis["webpackChunkcustomPortal"] || []).push([
|
||||
["main"],
|
||||
@@ -179,15 +199,14 @@ const bundlerFixture = async (): Promise<string> => {
|
||||
}
|
||||
]);
|
||||
`,
|
||||
);
|
||||
});
|
||||
return root;
|
||||
};
|
||||
|
||||
const esmRuntimeFixture = async (): Promise<string> => {
|
||||
const root = await createTestTempDirectory("rea-esm-runtime-adapters-");
|
||||
await writeFile(
|
||||
join(root, "main.js"),
|
||||
`
|
||||
await writeFixtureFiles(root, {
|
||||
"main.js": `
|
||||
const __vite__mapDeps = (indexes, map = __vite__mapDeps, dependencies =
|
||||
(map.f || (map.f = ["./feature.js", "./main.css"]))) =>
|
||||
indexes.map((index) => dependencies[index]);
|
||||
@@ -204,51 +223,8 @@ const esmRuntimeFixture = async (): Promise<string> => {
|
||||
__vite__mapDeps([0, 1]);
|
||||
init_core();
|
||||
`,
|
||||
);
|
||||
await writeFile(join(root, "feature.js"), "export const feature = true;");
|
||||
await writeFile(join(root, "main.css"), ".app { color: green; }");
|
||||
"feature.js": "export const feature = true;",
|
||||
"main.css": ".app { color: green; }",
|
||||
});
|
||||
return root;
|
||||
};
|
||||
|
||||
const chunk = (
|
||||
graph: JavaScriptApplicationGraph,
|
||||
runtime: string,
|
||||
chunkKey: string,
|
||||
): ApplicationNode | undefined =>
|
||||
graph.nodes.find(
|
||||
({ kind, observations }) =>
|
||||
kind === "javascript-chunk" &&
|
||||
observations.some(
|
||||
({ properties }) =>
|
||||
properties.runtime === runtime &&
|
||||
Array.isArray(properties.chunk_keys) &&
|
||||
properties.chunk_keys.includes(chunkKey),
|
||||
),
|
||||
);
|
||||
|
||||
const moduleNode = (
|
||||
graph: JavaScriptApplicationGraph,
|
||||
moduleKey: string,
|
||||
): ApplicationNode | undefined =>
|
||||
graph.nodes.find(
|
||||
({ kind, observations }) =>
|
||||
kind === "javascript-module" &&
|
||||
observations.some(
|
||||
({ properties }) => properties.module_key === moduleKey,
|
||||
),
|
||||
);
|
||||
|
||||
const edge = (
|
||||
graph: JavaScriptApplicationGraph,
|
||||
source: ApplicationNode | undefined,
|
||||
target: ApplicationNode | undefined,
|
||||
relation: string,
|
||||
): ApplicationEdge | undefined =>
|
||||
graph.edges.find(
|
||||
({ source_node_id, target_node_id, relation: edgeRelation }) =>
|
||||
source !== undefined &&
|
||||
target !== undefined &&
|
||||
source_node_id === source.node_id &&
|
||||
target_node_id === target.node_id &&
|
||||
edgeRelation === relation,
|
||||
);
|
||||
@@ -1,31 +1,32 @@
|
||||
import { mkdir, writeFile } from "node:fs/promises";
|
||||
import { writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
|
||||
import { reconstructJavaScriptArtifact } from "../../../src/application/JavaScriptArtifactReconstruction.js";
|
||||
import type {
|
||||
ApplicationEdge,
|
||||
ApplicationNode,
|
||||
JavaScriptApplicationGraph,
|
||||
} from "../../../src/domain/javascriptApplicationGraph.js";
|
||||
import {
|
||||
findExportNode,
|
||||
findRelationshipEdge,
|
||||
findSourceModule,
|
||||
reconstructJavaScriptFixture,
|
||||
writeFixtureFiles,
|
||||
} from "../../support/javascriptApplicationFixture.js";
|
||||
|
||||
describe("CommonJS and ESM module relationships", () => {
|
||||
it("composes bindings, re-exports, dynamic imports, and JSON modules", async () => {
|
||||
const root = await moduleFixture();
|
||||
const first = await reconstructJavaScriptArtifact({ input_path: root });
|
||||
const second = await reconstructJavaScriptArtifact({ input_path: root });
|
||||
const first = await reconstructJavaScriptFixture(root);
|
||||
const second = await reconstructJavaScriptFixture(root);
|
||||
const graph = first.graph;
|
||||
|
||||
expect(second.graph).toEqual(graph);
|
||||
expect(sourceModule(graph, "main.cjs")).toBeDefined();
|
||||
expect(sourceModule(graph, "consumer.mjs")).toBeDefined();
|
||||
expect(sourceModule(graph, "dependency.mjs")).toBeDefined();
|
||||
expect(findSourceModule(graph, "main.cjs")).toBeDefined();
|
||||
expect(findSourceModule(graph, "consumer.mjs")).toBeDefined();
|
||||
expect(findSourceModule(graph, "dependency.mjs")).toBeDefined();
|
||||
|
||||
expect(
|
||||
relationship(graph, {
|
||||
findRelationshipEdge(graph, {
|
||||
kind: "require",
|
||||
specifier: "./dependency.mjs",
|
||||
resolvedPath: "dependency.mjs",
|
||||
@@ -46,7 +47,7 @@ describe("CommonJS and ESM module relationships", () => {
|
||||
]),
|
||||
);
|
||||
expect(
|
||||
relationship(graph, {
|
||||
findRelationshipEdge(graph, {
|
||||
kind: "require",
|
||||
specifier: "fixture-package",
|
||||
resolvedPath: "node_modules/fixture-package/cjs.cjs",
|
||||
@@ -54,7 +55,7 @@ describe("CommonJS and ESM module relationships", () => {
|
||||
}),
|
||||
).toBeDefined();
|
||||
expect(
|
||||
relationship(graph, {
|
||||
findRelationshipEdge(graph, {
|
||||
kind: "import",
|
||||
specifier: "fixture-package",
|
||||
resolvedPath: "node_modules/fixture-package/esm.mjs",
|
||||
@@ -63,7 +64,7 @@ describe("CommonJS and ESM module relationships", () => {
|
||||
}),
|
||||
).toBeDefined();
|
||||
expect(
|
||||
relationship(graph, {
|
||||
findRelationshipEdge(graph, {
|
||||
kind: "import",
|
||||
specifier: "./values.js",
|
||||
resolvedPath: "values.js",
|
||||
@@ -72,7 +73,7 @@ describe("CommonJS and ESM module relationships", () => {
|
||||
}),
|
||||
).toBeDefined();
|
||||
expect(
|
||||
relationship(graph, {
|
||||
findRelationshipEdge(graph, {
|
||||
kind: "re-export",
|
||||
specifier: "./star.js",
|
||||
resolvedPath: "star.js",
|
||||
@@ -81,7 +82,7 @@ describe("CommonJS and ESM module relationships", () => {
|
||||
}),
|
||||
).toBeDefined();
|
||||
|
||||
const forwarded = exportNode(graph, "main.cjs", "forwarded");
|
||||
const forwarded = findExportNode(graph, "main.cjs", "forwarded");
|
||||
expect(forwarded).toBeDefined();
|
||||
expect(
|
||||
graph.edges.some(
|
||||
@@ -101,11 +102,11 @@ describe("CommonJS and ESM module relationships", () => {
|
||||
properties.resolved_path === "lazy.js",
|
||||
),
|
||||
).toMatchObject({
|
||||
source_node_id: sourceModule(graph, "consumer.mjs")?.node_id,
|
||||
source_node_id: findSourceModule(graph, "consumer.mjs")?.node_id,
|
||||
});
|
||||
|
||||
expect(
|
||||
relationship(graph, {
|
||||
findRelationshipEdge(graph, {
|
||||
kind: "require",
|
||||
specifier: "./data.json",
|
||||
resolvedPath: "data.json",
|
||||
@@ -115,7 +116,7 @@ describe("CommonJS and ESM module relationships", () => {
|
||||
target_json_status: "included",
|
||||
});
|
||||
expect(
|
||||
relationship(graph, {
|
||||
findRelationshipEdge(graph, {
|
||||
kind: "require",
|
||||
specifier: "./broken.json",
|
||||
resolvedPath: "broken.json",
|
||||
@@ -125,7 +126,7 @@ describe("CommonJS and ESM module relationships", () => {
|
||||
target_json_status: "invalid",
|
||||
});
|
||||
expect(
|
||||
relationship(graph, {
|
||||
findRelationshipEdge(graph, {
|
||||
kind: "require",
|
||||
specifier: "electron",
|
||||
})?.properties,
|
||||
@@ -164,8 +165,8 @@ describe("complete static application projections", () => {
|
||||
writeFile(join(root, "many.json"), JSON.stringify(jsonKeys)),
|
||||
]);
|
||||
|
||||
const { graph } = await reconstructJavaScriptArtifact({ input_path: root });
|
||||
const module = sourceModule(graph, "many-exports.mjs");
|
||||
const { graph } = await reconstructJavaScriptFixture(root);
|
||||
const module = findSourceModule(graph, "many-exports.mjs");
|
||||
const exportObservation = module?.observations.find(
|
||||
({ properties }) => properties.semantic_role === "source-module",
|
||||
);
|
||||
@@ -187,14 +188,9 @@ describe("complete static application projections", () => {
|
||||
|
||||
const moduleFixture = async (): Promise<string> => {
|
||||
const root = await createTestTempDirectory("rea-module-relationships-");
|
||||
await mkdir(join(root, "node_modules", "fixture-package"), {
|
||||
recursive: true,
|
||||
});
|
||||
await Promise.all([
|
||||
writeFile(join(root, "package.json"), '{"main":"main.cjs"}'),
|
||||
writeFile(
|
||||
join(root, "main.cjs"),
|
||||
`
|
||||
await writeFixtureFiles(root, {
|
||||
"package.json": '{"main":"main.cjs"}',
|
||||
"main.cjs": `
|
||||
const { value: importedValue } = require("./dependency.mjs");
|
||||
const data = require("./data.json");
|
||||
const broken = require("./broken.json");
|
||||
@@ -207,104 +203,32 @@ const moduleFixture = async (): Promise<string> => {
|
||||
exports.packageValue = packageValue;
|
||||
require(dynamicName);
|
||||
`,
|
||||
),
|
||||
writeFile(
|
||||
join(root, "dependency.mjs"),
|
||||
`
|
||||
"dependency.mjs": `
|
||||
export { value } from "./values.js";
|
||||
export * from "./star.js";
|
||||
`,
|
||||
),
|
||||
writeFile(
|
||||
join(root, "consumer.mjs"),
|
||||
`
|
||||
"consumer.mjs": `
|
||||
import { value as alias } from "./values.js";
|
||||
import packageDefault from "fixture-package";
|
||||
export { alias as relayed };
|
||||
void import("./lazy.js");
|
||||
void packageDefault;
|
||||
`,
|
||||
),
|
||||
writeFile(join(root, "values.js"), "export const value = 42;"),
|
||||
writeFile(join(root, "star.js"), "export const extra = true;"),
|
||||
writeFile(join(root, "lazy.js"), "export default 'lazy';"),
|
||||
writeFile(join(root, "data.json"), '{"name":"fixture","value":42}'),
|
||||
writeFile(join(root, "broken.json"), '{"name":'),
|
||||
writeFile(
|
||||
join(root, "node_modules", "fixture-package", "package.json"),
|
||||
JSON.stringify({
|
||||
exports: {
|
||||
".": {
|
||||
import: "./esm.mjs",
|
||||
require: "./cjs.cjs",
|
||||
},
|
||||
"values.js": "export const value = 42;",
|
||||
"star.js": "export const extra = true;",
|
||||
"lazy.js": "export default 'lazy';",
|
||||
"data.json": '{"name":"fixture","value":42}',
|
||||
"broken.json": '{"name":',
|
||||
"node_modules/fixture-package/package.json": JSON.stringify({
|
||||
exports: {
|
||||
".": {
|
||||
import: "./esm.mjs",
|
||||
require: "./cjs.cjs",
|
||||
},
|
||||
}),
|
||||
),
|
||||
writeFile(
|
||||
join(root, "node_modules", "fixture-package", "esm.mjs"),
|
||||
"export default 'esm';",
|
||||
),
|
||||
writeFile(
|
||||
join(root, "node_modules", "fixture-package", "cjs.cjs"),
|
||||
"module.exports = 'cjs';",
|
||||
),
|
||||
]);
|
||||
},
|
||||
}),
|
||||
"node_modules/fixture-package/esm.mjs": "export default 'esm';",
|
||||
"node_modules/fixture-package/cjs.cjs": "module.exports = 'cjs';",
|
||||
});
|
||||
return root;
|
||||
};
|
||||
|
||||
interface RelationshipQuery {
|
||||
readonly kind: string;
|
||||
readonly specifier: string;
|
||||
readonly resolvedPath?: string;
|
||||
readonly importedName?: string;
|
||||
readonly localName?: string;
|
||||
readonly exportedName?: string;
|
||||
}
|
||||
|
||||
const relationship = (
|
||||
graph: JavaScriptApplicationGraph,
|
||||
query: RelationshipQuery,
|
||||
): ApplicationEdge | undefined =>
|
||||
graph.edges.find(
|
||||
({ relation, properties }) =>
|
||||
relation === "imports" &&
|
||||
properties.module_link_kind === query.kind &&
|
||||
properties.specifier === query.specifier &&
|
||||
(query.resolvedPath === undefined ||
|
||||
properties.resolved_path === query.resolvedPath) &&
|
||||
(query.importedName === undefined ||
|
||||
properties.imported_name === query.importedName) &&
|
||||
(query.localName === undefined ||
|
||||
properties.local_name === query.localName) &&
|
||||
(query.exportedName === undefined ||
|
||||
properties.exported_name === query.exportedName),
|
||||
);
|
||||
|
||||
const sourceModule = (
|
||||
graph: JavaScriptApplicationGraph,
|
||||
path: string,
|
||||
): ApplicationNode | undefined =>
|
||||
graph.nodes.find(
|
||||
(node) =>
|
||||
node.kind === "javascript-module" &&
|
||||
node.observations.some(
|
||||
({ properties }) => properties.logical_module_key === path,
|
||||
),
|
||||
);
|
||||
|
||||
const exportNode = (
|
||||
graph: JavaScriptApplicationGraph,
|
||||
path: string,
|
||||
name: string,
|
||||
): ApplicationNode | undefined =>
|
||||
graph.nodes.find(
|
||||
(node) =>
|
||||
node.kind === "javascript-module" &&
|
||||
node.observations.some(
|
||||
({ properties }) =>
|
||||
properties.semantic_role === "export-binding" &&
|
||||
properties.module_path === path &&
|
||||
properties.exported_name === name,
|
||||
),
|
||||
);
|
||||
Reference in new issue
Block a user