Content mappers: more granular resolution, and default extensions in the manifest
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 30/100
- Issue 类型
- 功能
- 描述清晰度
- 需要澄清
- 活跃度
- 活跃
- 技术栈
- typescript
调研方向
Start by tracing the content-mapper initialize and transform protocol, then inspect typescript.contentMapper manifest handling and tsconfig registration. Compare the proposed filter, claim, and default-extension behaviors and determine which design is selected. Done means the chosen resolution and registration rules are specified with corresponding coverage.
由索引模型根据 Issue 内容生成。
描述
Some feedback on content mappers, based on a few limits I hit.
More granular resolution
I'm imagining a framework (let's call it "blob") with a file system router and a root config file called blob.toml. It would be cool to be able to "import" the router as a tRPC-style SDK. The obvious thing would be to import blob.toml as the "entrypoint" of the framework and get back that SDK. Perhaps this is seen as a total abuse of content mappers...but it would be cool!
Currently, since the entire system is based on extensions, you can't define one that has special handling for a file specifically called blob.toml. You'd have to register a content mapper for all TOML files, in which case no other TOML loading is possible.
Recommendations:
-
Support regex-style matching a la esbuild
onResolve/filter. In the current protocol this could be a field on theinitializeresult, tested against the absolute path of any file whose extension the mapper registered:interface InitializeResult { positionEncoding: PositionEncoding; diagnosticSource: string; /** RE2 syntax, like esbuild. When present, the mapper only receives files matching it. */ filter?: string; }The same field in the
typescript.contentMappermanifest would let TypeScript apply it without starting the process. -
Allow a dynamic
onRegister-style API where a mapper can choose to resolve or not resolve based on the path, etc. In the current protocol this could be a content-free request sent beforetransform, with several mappers allowed on one extension and tried incontentMappersorder until one claims the file:interface ClaimParams { fileName: string; projectHandle: string; } interface ClaimResult { claimed: boolean; }Content-free matters here, because a mapper that declines most files should not pay for their contents.
-
A
nameslist alongsideextensions(not my preference).
Default extensions in the manifest
If you let a content mapper define a default extensions list, the onus isn't on the user for this. I suspect these user-specified extensions lists will be pretty redundant in most cases (e.g. a content mapper called toml-loader that only ever loads TOML).
If extensions becomes optional, and the config/options object is also often optional, the registration in tsconfig can reduce to a simple string for the simple (and common) case.
"contentMappers": ["mdx-content-mapper"]
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.4k
- 平均合并
- 1 天 19 小时
- 30 天内合并 PR
- 117
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/TypeScript 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
microsoft/TypeScript#64322 · 2 条评论 · 1 个 reaction · 已指派 2 人 ·
-
Possible Improvement
难度 2/5 1-3 小时 新手友好度 78/100
microsoft/TypeScript#64278 · 1 条评论 · 1 个 reaction ·
-
Docs
难度 2/5 1-3 小时 新手友好度 70/100
microsoft/TypeScript#64118 · 1 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 88/100
microsoft/TypeScript#64094 ·
-
Docs
难度 2/5 1-3 小时 新手友好度 76/100
microsoft/TypeScript#63959 · 5 条评论 ·
查看 microsoft/TypeScript 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 92/100
milvus-io/birdwatcher#545 ·
-
kind/bug
难度 2/5 1-3 小时 新手友好度 88/100
kubernetes-sigs/prow#953 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
-
难度 2/5 1-3 小时 新手友好度 88/100
caddyserver/caddy#8046 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
jaegertracing/jaeger#9588 ·