Skip to content

Build Orchestrator API - #64158

Open
Isabel Duan (iisaduan) wants to merge 1 commit into
microsoft:mainfrom
iisaduan:buildOrchestrator
Open

Build Orchestrator API #64158
Isabel Duan (iisaduan) wants to merge 1 commit into
microsoft:mainfrom
iisaduan:buildOrchestrator

Conversation

@iisaduan

Copy link
Copy Markdown
Member

3B of #63875

full description in progress

This PR implements what, in TS<6, was called the SolutionBuilder. In TS7.1, it will now be called the BuildOrchestrator.

class BuildOrchestrator {
    async build(project?: string): Promise<number>
    async buildReferences(project: string): Promise<number> 
    async clean(project?: string): Promise<number> 
    async cleanReferences(project?: string): Promise<number>
}

Usage example:

const orchestrator = await api.createBuildOrchestrator(
        { cwd: "/", fs },
        ["/c/tsconfig.json"],
         commandLineOptions,
);
orchestrator.build()

notes:

  • the API client serves as what used to be the SolutionBuilderHost, so no need to create and pass an extra host
  • no distinction between a SolutionBuilder and SolutionBuilderWithWatch, both modes can be used through CreateBuildOrchestrator(), and you can activate watch by creating with watch options.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Host routing, configuration refresh, watch lifecycle, and clean-result handling contain blocking correctness issues.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds the Build Orchestrator API for building and cleaning project graphs through sync and async clients.

Changes:

  • Adds selective build, reference-build, clean, and reference-clean operations.
  • Exposes orchestration through the API protocol and clients.
  • Adds virtual filesystem deletion support and integration tests.
File summaries
File Description
tsc/internal/project/session.go Exposes the default library path.
tsc/internal/execute/build/orchestrator.go Implements reusable build and clean orchestration.
tsc/internal/execute/build/clean_test.go Tests server-side cleaning behavior.
tsc/internal/api/session.go Handles Build Orchestrator API requests.
tsc/internal/api/proto.go Defines orchestration protocol types.
tsc/internal/api/callbackfs.go Adds delegated file removal.
packages/typescript/src/api/async/api.ts Adds the asynchronous client API.
packages/typescript/src/api/sync/api.ts Adds the generated synchronous client API.
packages/typescript/src/api/proto.generated.ts Adds generated protocol declarations.
packages/typescript/src/api/fs.ts Exposes the removeFile callback.
packages/typescript/test/async/api.test.ts Tests asynchronous orchestration.
packages/typescript/test/sync/api.test.ts Tests synchronous orchestration.
Review details
  • Files reviewed: 12/12 changed files
  • Comments generated: 12
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +243 to +245
async createBuildOrchestrator(host: ClientSpawnOptions, rootNames: readonly string[], defaultOptions: ParsedCommandLine): Promise<BuildOrchestrator> {
await this.ensureInitialized();
const orchestratorResponse = await this.client.apiRequest("createBuildOrchestrator", { hostOptions: host, rootNames, defaultOptions });
s.buildMu.Lock()
defer s.buildMu.Unlock()
return &BuildResponse{
ExitStatus: s.buildOrchestrators[params.BuildOrchestratorID].Build(ctx, string(params.Project)).Status,
Comment on lines 289 to 291
if o.opts.Command.CompilerOptions.Watch.IsTrue() {
o.Watch(ctx)
result.Watcher = o
Comment on lines +304 to +306
o.rangeTasks(order, func(path tspath.Path, task *BuildTask) {
task.resetStatus()
})
Comment on lines +322 to +324
if !o.graphGenerated {
o.GenerateGraph(nil)
}
Comment on lines +337 to +340
if onlyReferences {
if project == "" {
return tsc.ExitStatusInvalidProject_OutputsSkipped
}
Comment on lines +349 to +351
if task.resolved == nil {
reportDiagnostic(ast.NewCompilerDiagnostic(diagnostics.File_0_not_found, task.config))
continue
Comment on lines +432 to +434
if err := o.host.FS().Remove(outputFile); err != nil {
reportDiagnostic(ast.NewCompilerDiagnostic(diagnostics.Failed_to_delete_file_0, outputFile))
return false
private initialized: boolean = false;
private activeSnapshots: Set<Snapshot> = new Set();
private latestSnapshot: Snapshot | undefined;
private buildOrchestrators: Map<number, BuildOrchestrator> = new Map();
Comment thread packages/typescript/test/sync/api.test.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

2 participants