🐛 fix: silence Turbopack project-wide glob warning (#15194)

`path.join(this.root, sub)` still tripped Turbopack's static file-pattern
analyzer because `safeSegment`'s `|| 'unknown'` fallback gave the analyzer
a finite alternation, fanning out into a project-wide glob that matched
11k+ files at build time. Hand-roll the join with `path.sep` so the
analyzer can't see it as a path pattern; output is byte-identical to
`path.join` on both Unix and Windows.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Arvin Xu
2026-05-25 15:36:40 +08:00
committed by GitHub
parent 47b6f3503a
commit e4ad195df9
@@ -120,11 +120,14 @@ export class FileTracingStore implements ITracingStore {
}
private bucketDir(record: TracingPayload): string {
// Compose the relative segment as a single string so Turbopack / Webpack
// static analyzers don't try to enumerate path.join's multi-arg pattern
// (which fans out into a glob match against the project).
const sub = `${safeSegment(record.scenario)}/${safeSegment(record.prompt_version)}-${safeSegment(record.prompt_hash)}`;
return path.join(this.root, sub);
// Hand-roll the join with `path.sep` so Turbopack / Webpack can't statically
// analyze it. `path.join(this.root, sub)` still triggers the static file
// pattern detector because `safeSegment`'s `|| 'unknown'` fallback gives the
// analyzer a finite alternation that fans out into a project-wide glob
// (the build warning enumerated 11k+ candidate files).
const scenario = safeSegment(record.scenario);
const bucket = `${safeSegment(record.prompt_version)}-${safeSegment(record.prompt_hash)}`;
return `${this.root}${path.sep}${scenario}${path.sep}${bucket}`;
}
private async updateLatestSymlink(filePath: string): Promise<void> {