Skip to content

Commit 19f942c

Browse files
committed
fixup! test(@angular/build): add library builder scaling benchmark suite
1 parent df5dc1a commit 19f942c

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

‎scripts/benchmarks/library-builder/fixtures.mts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ export function generateFixture(outDir: string, options: FixtureOptions): number
160160

161161
const angularCoreVersion = JSON.parse(
162162
fs.readFileSync(
163-
path.resolve(import.meta.dirname, '../../../node_modules/@angular/core/package.json'),
164-
'utf8',
165-
),
163+
new URL('../../../node_modules/@angular/core/package.json', import.meta.url),
164+
'utf8'
165+
)
166166
).version as string;
167167
// e.g. "22.3.0-next.0" -> "22.3.0-next" (drop the trailing prerelease build number only).
168168
const peerRange = `^${angularCoreVersion.replace(/\.\d+$/, '')}`;

‎scripts/benchmarks/library-builder/index.mts‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { spawnSync } from 'node:child_process';
1818
import fs from 'node:fs';
1919
import path from 'node:path';
2020
import { performance } from 'node:perf_hooks';
21+
import { fileURLToPath } from 'node:url';
2122
import { type FixtureOptions, type Layout, type Style, generateFixture } from './fixtures.mts';
2223

2324
export interface LibraryBuilderBenchmarkOptions {
@@ -42,7 +43,7 @@ export interface BuildMeasurement {
4243
status: 'ok' | 'fail';
4344
}
4445

45-
const repoRoot = path.resolve(import.meta.dirname, '../../..');
46+
const repoRoot = fileURLToPath(new URL('../../../', import.meta.url));
4647
const scratchRoot = path.join(repoRoot, 'dist', '.library-builder-benchmark-tmp');
4748
const rootNodeModules = path.join(repoRoot, 'node_modules');
4849
const pnpmStore = path.join(rootNodeModules, '.pnpm');
@@ -119,9 +120,21 @@ function ensureBuilderDepsLinkedAtRepoRoot(
119120

120121
function linkIfMissing(name: string, target: string): void {
121122
const linkPath = path.join(rootNodeModules, name);
122-
if (!fs.existsSync(linkPath)) {
123-
fs.symlinkSync(target, linkPath, 'dir');
123+
try {
124+
const stat = fs.lstatSync(linkPath);
125+
if (stat.isSymbolicLink() && !fs.existsSync(linkPath)) {
126+
// Remove broken symlink to avoid EEXIST error on recreation
127+
fs.unlinkSync(linkPath);
128+
} else {
129+
// Symlink already exists and is valid
130+
return;
131+
}
132+
} catch (e: any) {
133+
if (e.code !== 'ENOENT') {
134+
throw e;
135+
}
124136
}
137+
fs.symlinkSync(target, linkPath, 'dir');
125138
}
126139

127140
/** Resolves `dep` (e.g. "rxjs" or "@angular-devkit/core") to its pnpm store dir and symlinks it. */

0 commit comments

Comments
 (0)