Compiler Option to monitor external dependencies
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 45/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- typescript
调研方向
从针对独立的 package.json 和 tsconfig.json 文件所描述的 tsc --build 工作流开始,并检查 tsbuildinfo 如何记录依赖项和位置。比较普通构建和 -f 构建,然后为链接的工作区、node_modules、package.json 以及传递依赖项中的更改定义并测试 dependencyTracking=external。
由索引模型根据 Issue 内容生成。
描述
🔍 Search Terms
build, incremental, composit, tsbuildinfo, location, symlink, stale
✅ Viability Checklist
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
⭐ Suggestion
Related to: #58427
Proposal: A new option compilerOptions.dependencyTracking
Values:
local-- this is the current behaviorexternal-- this would check for both local and changes innode_modulesandpackage.json. Transitive dependencies should be accounted for if possible.
📃 Motivating Example
The motivation is related to #58427, but extends to mono repos.
The current system seems to work well for monolith repos where there is a tsconfig at the root and it coordinates building all the sub-projects. That is not what I am referring to.
I'm talking about a mono repo that is a collection of related workspaces (packages/libraries) that have their own package.json and tsconfig.json files. The package manager controls the order in which workspaces are built, not tsc. tsc is used as part of the build process in an individual workspace. The output directory is always within an individual workspace, because in theory, each of these packages could be published to NPM. Package imports are controlled by package.json#dependencies and exports are listed in package.json#exports. Interdependence between workspaces is generally handled through SymLinks. This is how PNPM and NPM handle it.
Think of a typical morning workflow:
git fetch-- grab all the changes made by my teammates.git pull --rebase origin/main-- merge in the changes since I'm working on my own branch.pnpm i-- install any updated packages.pnpm build-- pnpm will run the build script in each of the workspace based upon the dependency graph (NPM can do the same thing, but you need to define the graph yourself).
At this point, any compile errors should be in my branch, since we keep a clean main branch (always compiles and no errors). If it compiles, then all type checking should be good.
But the current tsc --build . does NOT ensure that the build is correct. It will often miss changes to the .d.ts files in the other workspaces. I was certain this was a bug, see #58427.
Typical inter-workspace workflow:
Given WorkspaceA and depends upon WorkspaceB.
repo
|- WorkspaceA/
| |- package.json#dependencies.WorkspaceB
| |- tsconfig.json
| |- src/
| |- dist/ # outDir
|- WorkspaceB/
| |- package.json#exports dist/index.js
| |- tsconfig.json
| |- src/index.ts
| |- dist/ # outDir
If I'm working on WorkspaceA and WorkspaceB by adding a new API interface to WorkspaceB/src/index.ts in WorkspaceB, I would expect the following to pick up the changes in B and work.
repo/WorkspaceB $ tsc -b .
repo/WorkspaceB $ cd ../WorkspaceA
repo/WorksapceA $ tsc -b .
But it doesn't pick up the change in WorkspaceB.
Instead I have to remember to use:
repo/WorksapceA $ tsc -b . -f
Unexpected results and errors can arise by needing to use two different build commands based upon the situation.
Strangely, things magically seem to work if I had been running the following before making changes to WorkspaceB:
repo/WorksapceA $ tsc -b . -w
In summary, I am asking for the option to have tsc --build work a bit harder and check the external dependencies by using an option like compilerOptions.dependencyTracking=external.
Please note: I rarely use the --build option in projects because of this build issue. Some times I am forced to because the only way to make something work is by using composite.
💻 Use Cases
- What do you want to use this for?
To have the compiler build reliably when there are changes, including external ones. - What shortcomings exist with current approaches?
The current option is to usetsc -b . -fall the time. - What workarounds are you using in the meantime?
Always use force build.
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.4k
- 平均合并
- 1 天 15 小时
- 30 天内合并 PR
- 106
贡献指南
从这里开始
- 先读完整个 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
-
Type/Bug
难度 2/5 1-3 小时 新手友好度 78/100
OpenNSW/nsw-srilanka#497 ·
-
难度 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 ·