mirror of
https://github.com/lobehub/lobe-chat.git
synced 2026-06-13 19:20:04 +00:00
🐛 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:
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user