Skip to content

Commit dbd7f20

Browse files
committed
Feedback
1 parent a5a5bc2 commit dbd7f20

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

internal/execute/build/orchestrator.go

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,7 @@ func (o *Orchestrator) DoCycle() {
294294
}
295295

296296
func (o *Orchestrator) buildOrClean() tsc.CommandLineResult {
297-
build := !o.opts.Command.BuildOptions.Clean.IsTrue()
298-
if build && o.opts.Command.BuildOptions.Verbose.IsTrue() {
297+
if !o.opts.Command.BuildOptions.Clean.IsTrue() && o.opts.Command.BuildOptions.Verbose.IsTrue() {
299298
o.createBuilderStatusReporter(nil)(ast.NewCompilerDiagnostic(
300299
diagnostics.Projects_in_this_build_Colon_0,
301300
strings.Join(core.Map(o.Order(), func(p string) string {
@@ -307,22 +306,12 @@ func (o *Orchestrator) buildOrClean() tsc.CommandLineResult {
307306
if len(o.errors) == 0 {
308307
buildResult.statistics.Projects = len(o.Order())
309308
if o.opts.Command.CompilerOptions.SingleThreaded.IsTrue() {
310-
for _, config := range o.Order() {
311-
path := o.toPath(config)
312-
task := o.getTask(path)
313-
o.buildOrCleanProject(task, path, &buildResult)
314-
}
309+
o.singleThreadedBuildOrClean(&buildResult)
315310
} else {
316-
wg := core.NewWorkGroup(false)
317-
o.tasks.Range(func(path tspath.Path, task *buildTask) bool {
318-
wg.Queue(func() {
319-
o.buildOrCleanProject(task, path, &buildResult)
320-
})
321-
return true
322-
})
323-
wg.RunAndWait()
311+
o.multiThreadedBuildOrClean(&buildResult)
324312
}
325313
} else {
314+
// Circularity errors prevent any project from being built
326315
buildResult.result.Status = tsc.ExitStatusProjectReferenceCycle_OutputsSkipped
327316
reportDiagnostic := o.createDiagnosticReporter(nil)
328317
for _, err := range o.errors {
@@ -334,6 +323,27 @@ func (o *Orchestrator) buildOrClean() tsc.CommandLineResult {
334323
return buildResult.result
335324
}
336325

326+
func (o *Orchestrator) singleThreadedBuildOrClean(buildResult *orchestratorResult) {
327+
// Go in the order since only one project can be built at a time so that random order isnt picked by work group creating deadlock
328+
for _, config := range o.Order() {
329+
path := o.toPath(config)
330+
task := o.getTask(path)
331+
o.buildOrCleanProject(task, path, buildResult)
332+
}
333+
}
334+
335+
func (o *Orchestrator) multiThreadedBuildOrClean(buildResult *orchestratorResult) {
336+
// Spin off the threads with waiting on upstream to build before actual project build
337+
wg := core.NewWorkGroup(false)
338+
o.tasks.Range(func(path tspath.Path, task *buildTask) bool {
339+
wg.Queue(func() {
340+
o.buildOrCleanProject(task, path, buildResult)
341+
})
342+
return true
343+
})
344+
wg.RunAndWait()
345+
}
346+
337347
func (o *Orchestrator) buildOrCleanProject(task *buildTask, path tspath.Path, buildResult *orchestratorResult) {
338348
task.result = &taskResult{}
339349
task.result.reportStatus = o.createBuilderStatusReporter(task)

internal/execute/incremental/emitfileshandler.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ func (h *emitFilesHandler) updateSnapshot() []*compiler.EmitResult {
314314
func emitFiles(ctx context.Context, program *Program, options compiler.EmitOptions, isForDtsErrors bool) *compiler.EmitResult {
315315
emitHandler := &emitFilesHandler{ctx: ctx, program: program, isForDtsErrors: isForDtsErrors}
316316

317+
// Single file emit - do direct from program
317318
if !isForDtsErrors && options.TargetSourceFile != nil {
318319
result := program.program.Emit(ctx, emitHandler.getEmitOptions(options))
319320
if ctx.Err() != nil {

0 commit comments

Comments
 (0)