Skip to content

fix(compiler): resolve entrypoint from exports["."]["typespec"] when tspMain is absent - #11423

Open
timotheeguerin with Copilot wants to merge 6 commits into
mainfrom
copilot/add-support-for-exports
Open

fix(compiler): resolve entrypoint from exports["."]["typespec"] when tspMain is absent#11423
timotheeguerin with Copilot wants to merge 6 commits into
mainfrom
copilot/add-support-for-exports

Conversation

Copilot AI commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

tsp compile . only checked tspMain for entrypoint resolution, ignoring the exports field. Libraries using exports["."]["typespec"] without tspMain couldn't be compiled directly from their directory.

Changes

  • packages/compiler/src/utils/misc.tsresolveTspMain now falls back to exports["."]["typespec"] when tspMain is not set. Priority order:

    1. entrypoint in tspconfig.yaml
    2. tspMain in package.json
    3. exports["."]["typespec"] in package.json ← new
    4. main.tsp (default)
  • packages/compiler/test/core/entrypoint-resolution.test.ts — added tests covering the new fallback, tspMain precedence, and tspconfig.yaml precedence.

Example

A library with this package.json (no tspMain) now works with tsp compile .:

{
  "exports": {
    ".": {
      "typespec": "./lib/main.tsp",
      "default": "./dist/index.js"
    }
  }
}

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI and others added 2 commits July 28, 2026 13:56
…ckage.json

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
…ckage.json

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for resolving entrypoints from exports in tsp compile fix(compiler): resolve entrypoint from exports["."]["typespec"] when tspMain is absent Jul 28, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added the compiler:core Issues for @typespec/compiler label Jul 28, 2026
Copilot AI requested a review from timotheeguerin July 28, 2026 13:57
… in entrypoint resolution"

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
…resolution

Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
@pkg-pr-new

pkg-pr-new Bot commented Jul 28, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/compiler@11423

commit: 9abe4ee

@timotheeguerin
timotheeguerin marked this pull request as ready for review July 28, 2026 19:31
@github-actions

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @typespec/compiler
Show changes

@typespec/compiler - fix ✏️

tsp compile . now resolves the entrypoint from exports["."]["typespec"] in package.json, taking precedence over the legacy tspMain field

@azure-sdk-automation

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@timotheeguerin
timotheeguerin enabled auto-merge July 28, 2026 20:04
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.

tsp compile . doesn't resolve entrypoints from exports

3 participants