Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract source resolution logic into its own source loader #4324

Merged
merged 10 commits into from
Sep 6, 2024

Conversation

timotheeguerin
Copy link
Member

@timotheeguerin timotheeguerin commented Sep 3, 2024

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

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

@microsoft-github-policy-service microsoft-github-policy-service bot added the compiler:core Issues for @typespec/compiler label Sep 3, 2024
@azure-sdk
Copy link
Collaborator

azure-sdk commented Sep 3, 2024

All changed packages have been documented.

  • @typespec/compiler
Show changes

@typespec/compiler - fix ✏️

API: Extract source resolution logic into its own source loader

@azure-sdk
Copy link
Collaborator

You can try these changes here

🛝 Playground 🌐 Website 📚 Next docs

@timotheeguerin timotheeguerin added this pull request to the merge queue Sep 6, 2024
Merged via the queue into microsoft:main with commit d2ac995 Sep 6, 2024
22 checks passed
@timotheeguerin timotheeguerin deleted the source-loader branch September 6, 2024 23:43
sarangan12 pushed a commit to sarangan12/typespec that referenced this pull request Sep 16, 2024
…#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
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:core Issues for @typespec/compiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants