Skip to content

Commit

Permalink
Extract source resolution logic into its own source loader (microsoft…
Browse files Browse the repository at this point in the history
…#4324)

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 authored and sarangan12 committed Sep 16, 2024
1 parent 8c426d3 commit e08807a
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 e08807a

Please sign in to comment.