Skip to content

Commit 63a7566

Browse files
committed
refactor(depgraph): simplify build assets
1 parent b111f5a commit 63a7566

3 files changed

Lines changed: 7 additions & 17 deletions

File tree

‎scripts/depgraph/structure-summary.test.ts‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { resolveImportEdges } from '../layering/model.ts';
44
import { buildGraph } from './model.ts';
55
import {
66
computeCohesionSummary,
7-
computeDominatorSummary,
87
createDominatorAnalyzer,
98
computeZoneSccSummary,
109
} from './structure-summary.ts';
@@ -13,7 +12,7 @@ function sources(entries: Record<string, string>): Map<string, string> {
1312
return new Map(Object.entries(entries));
1413
}
1514

16-
test('computeDominatorSummary excludes the dynamic-import seam and ranks bottlenecks by dominated subtree size', () => {
15+
test('the dominator analyzer excludes dynamic imports and ranks dominated subtrees', () => {
1716
const files = sources({
1817
'src/core/entry.ts': [
1918
"import { a } from './a.ts';",
@@ -31,7 +30,7 @@ test('computeDominatorSummary excludes the dynamic-import seam and ranks bottlen
3130
});
3231
const graph = buildGraph(files, resolveImportEdges(files));
3332

34-
const summary = computeDominatorSummary('src/core/entry.ts', graph);
33+
const summary = createDominatorAnalyzer(graph)('src/core/entry.ts');
3534

3635
// `lazy.ts` is reached only through a dynamic import, so it never joins the eager closure —
3736
// reachableFiles counts entry + a + b + shared + only-a, not the dynamically-loaded sixth file.
@@ -52,12 +51,12 @@ test('computeDominatorSummary excludes the dynamic-import seam and ranks bottlen
5251
);
5352
});
5453

55-
test('computeDominatorSummary rejects an entry outside the layering graph', () => {
54+
test('the dominator analyzer rejects an entry outside the layering graph', () => {
5655
const files = sources({ 'src/core/entry.ts': 'export const entry = 1;' });
5756
const graph = buildGraph(files, resolveImportEdges(files));
5857

5958
assert.throws(
60-
() => computeDominatorSummary('src/core/missing.ts', graph),
59+
() => createDominatorAnalyzer(graph)('src/core/missing.ts'),
6160
/src\/core\/missing\.ts is not a production source file/,
6261
);
6362
});

‎scripts/depgraph/structure-summary.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,6 @@ function summarizeDominator(
100100
};
101101
}
102102

103-
export function computeDominatorSummary(entry: string, graph: GraphData): DominatorSummary {
104-
return createDominatorAnalyzer(graph)(entry);
105-
}
106-
107103
export type ZoneComponent = { zones: string[]; size: number };
108104

109105
export type ZoneSccSummary = {

‎website/scripts/build-depgraph.mjs‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
mkdirSync,
77
mkdtempSync,
88
readFileSync,
9+
readdirSync,
910
rmSync,
1011
writeFileSync,
1112
} from 'node:fs';
@@ -28,6 +29,7 @@ try {
2829
execFileSync('git', ['init', '--bare', '--quiet', temporaryGit]);
2930
env.GIT_DIR = temporaryGit;
3031
env.GIT_WORK_TREE = root;
32+
// tracked-sources.ts limits production sources and package manifests to these roots.
3133
execFileSync('git', ['add', '--', 'src', 'packages'], { cwd: root, env });
3234
}
3335

@@ -42,14 +44,7 @@ try {
4244
'<link rel="stylesheet" href="./brand.css" /><link rel="stylesheet" href="./fonts/font-face.css" /></head>',
4345
),
4446
);
45-
for (const file of [
46-
'app.js',
47-
'layout.js',
48-
'analysis.js',
49-
'graph-model.js',
50-
'simulation.js',
51-
'html.js',
52-
])
47+
for (const file of readdirSync(viewer).filter((name) => name.endsWith('.js')))
5348
copyFileSync(path.join(viewer, file), path.join(output, file));
5449
execFileSync(
5550
process.execPath,

0 commit comments

Comments
 (0)