Emitter framework: make the language-specific Alloy peer dependencies optional

未关闭 适合新手
#12,476 1 条评论 2 个 reaction 已指派 2 人 在 GitHub 查看

维护者通常 1 天内回复

@timotheeguerin 已经在做这个了。

开始于 2026年11月4日。

  • #12495 来自 @copilot-swe-agent —— 未关闭

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
62/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
领域
tooling

调研方向

修复位于 emitter 框架的 package.json 中,那里声明 Alloy 语言 peer 时没有设置 peerDependenciesMeta。将 @alloy-js/csharp、@alloy-js/python 和 @alloy-js/typescript 标记为可选,同时保持 @alloy-js/core 和 @typespec/compiler 为必需。检查面向 emitter 作者的文档页面是否仍然准确,然后确认只安装 TypeScript 包时不会产生缺失 peer 的警告。

由索引模型根据 Issue 内容生成。

描述

emitter-framework feature triaged:core
Clear and concise description of the problem

@typespec/emitter-framework declares all of its Alloy language packages as peer dependencies, with no peerDependenciesMeta, so every one of them is required:

"peerDependencies": {
  "@alloy-js/core": "...",
  "@alloy-js/csharp": "...",
  "@alloy-js/python": "...",
  "@alloy-js/typescript": "...",
  "@typespec/compiler": "..."
}

An emitter for a single language therefore gets the other languages' packages too: package managers that install peers automatically (npm 7+, pnpm by default) download them, and the others print a missing-peer warning. A TypeScript-only emitter installs about 32 MB of C# and Python packages (27 MB and 4.8 MB unpacked) that it never loads.

Each language package is used by exactly one entry point (0.21.0, runtime imports in dist/src):

Entry point @alloy-js packages imported
@typespec/emitter-framework (root) core
@typespec/emitter-framework/typescript core, typescript
@typespec/emitter-framework/csharp core, csharp
@typespec/emitter-framework/python core, python
@typespec/emitter-framework/testing core/testing

I checked that an emitter that imports from the root and from /typescript generates and runs correctly with @alloy-js/csharp and @alloy-js/python absent. The same peers and the missing peerDependenciesMeta are on main and in 0.22.0-dev.1.

The emitter framework docs already tell emitter authors to install the packages they use as peers (npm install --save-peer @alloy-js/core @alloy-js/typescript @typespec/emitter-framework), so making the language packages optional would not change that workflow.

Proposal

Mark the language-specific peers as optional, keeping @alloy-js/core and @typespec/compiler required:

"peerDependenciesMeta": {
  "@alloy-js/csharp": { "optional": true },
  "@alloy-js/python": { "optional": true },
  "@alloy-js/typescript": { "optional": true }
}
Checklist
  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
主要语言
Java
星标
5.9k
派生
421
平均合并
2 天 3 小时
30 天内合并 PR
176

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/typespec 的其他 Issue

查看 microsoft/typespec 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。