Skip to content

Commit

Permalink
Extract source resolution logic into its own source loader (#4324)
Browse files Browse the repository at this point in the history
This will allow other tools to be able to reuse the typespec compiler
source resolution logic(Figure out all the imported files) without doing
a full compile and cleans up the program.ts which is doing a lot of
things.

Usage

```ts
const loader = createSourceLoader(host);

loader.importFile(resolvePath(cwd, "main.tsp", {type: "project"}));

loader.importPath("./foo.tsp", NoTarget, cwd, {type: "project"} );

loader.resolution.sourceFiles // Tsp source files loaded
loader.resolution.jsSourceFiles // Js source file loaded
```
  • Loading branch information
timotheeguerin committed Sep 6, 2024
1 parent dde8dc0 commit d2ac995
Show file tree
Hide file tree
Showing 3 changed files with 435 additions and 255 deletions.
8 changes: 8 additions & 0 deletions .chronus/changes/source-loader-2024-8-3-19-23-57.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking
changeKind: fix
packages:
- "@typespec/compiler"
---

API: Extract source resolution logic into its own source loader
Loading

0 comments on commit d2ac995

Please sign in to comment.