diff --git a/tsc/internal/compiler/filesparser.go b/tsc/internal/compiler/filesparser.go index dcf9843de84bb..6d2a2e704908f 100644 --- a/tsc/internal/compiler/filesparser.go +++ b/tsc/internal/compiler/filesparser.go @@ -308,6 +308,28 @@ func (w *filesParser) start(ctx context.Context, loader *fileLoader, tasks []*pa if task.path == "" { panic("parse task must have a path key: " + task.normalizedFilePath.AsString()) } + if existing, ok := w.taskDataByPath.Load(task.path); ok { + if existing.mu.TryLock() { + if existingTask, ok := existing.tasks[task.normalizedFilePath]; ok && existingTask.loaded { + currentDepth := core.IfElse(task.increaseDepth, depth+1, depth) + if currentDepth >= existing.lowestDepth && (existing.packageId.Name != "" || task.packageId == nil) { + allLoaded := true + for _, t := range existing.tasks { + if !t.loaded { + allLoaded = false + break + } + } + if allLoaded { + tasks[i].loadedTask = existingTask + existing.mu.Unlock() + continue + } + } + } + existing.mu.Unlock() + } + } candidate := getParseTaskData(task) data, loaded := w.taskDataByPath.LoadOrStore(task.path, candidate) if loaded {