extract and export buildProject for flight-instructor on-demand gener…#3795
Open
qiaozha wants to merge 3 commits intoAzure:mainfrom
Open
extract and export buildProject for flight-instructor on-demand gener…#3795qiaozha wants to merge 3 commits intoAzure:mainfrom
qiaozha wants to merge 3 commits intoAzure:mainfrom
Conversation
| tcgcContext: dpgContext | ||
| }); | ||
|
|
||
| const staticHelpers = await loadStaticHelpers( |
Member
There was a problem hiding this comment.
I may have some concerns here - if a new helper is added, we'd need to update both places, which is easy to forget and hard to contain.
| staticHelpers, | ||
| dependencies: { ...extraDependencies } | ||
| }); | ||
| provideSdkTypes(dpgContext); |
Member
There was a problem hiding this comment.
I am thinking about aggregating the code from line 729 (provideContext) to this line as a new shared method called something like initializeModularPipeline() which returns the binder, and both $onEmit and buildProject can call it. In this way, the structure would be like:
├── $onEmit(context) [ENTRY POINT — TypeSpec compiler hook]
│ │ Orchestrates the full emitter pipeline: FS setup, RLC or Modular
│ │ generation, metadata, tests, and writing files to disk.
│ │
│ ├── ...
│ │
│ ├── generateModularSources() [MODULAR — emit source files]
│ │ Calls initializeModularPipeline() → generateModularSourcesInProject()
│ │ → binder.resolveAllReferences() → writes files to disk.
│ │
│ └── ...
│
├── generateModularSourcesInProject(...) [SHARED — modular source generation]
│ Pure generation logic: emit types, build clients, operations,
│ index files. No FS, no context wiring, no binder resolution.
│ Used by both $onEmit and buildProject.
│
├── initializeModularPipeline(...) [SHARED — pipeline bootstrap] ✨ NEW
│ Wires up provideContext, loads static helpers, resolves
│ dependencies, creates binder. SINGLE SOURCE OF TRUTH for
│ helpers/deps registration.
│
├── buildProject(program, options) [ENTRY POINT — programmatic API]
│ In-memory modular generation for flight-instructor.
│ Creates fake EmitContext → initializeModularPipeline()
│ → generateModularSourcesInProject() → binder.resolveAllReferences()
│ → returns ts-morph Project (no disk writes).
Not sure if it would be better.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…ation