Potential performance overhead in ts-loader's disabled resolver
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 55/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- typescript, webpack
- 领域
- backend, performance
调研方向
Start with src/resolver.ts and trace how servicesHost.resolveModule handles the resolver result and falls back to TypeScript. Compare the disabled resolver's behavior with the reported return false experiment, then check the existing tests for fallback and diagnostics. Done means avoiding per-call exception overhead while preserving fallback and diagnostic behavior.
由索引模型根据 Issue 内容生成。
描述
Potential performance overhead in ts-loader's disabled resolver
Problem
In ts-loader v9.6.2, makeResolver returns a function that always throws. servicesHost.resolveModule catches the exception and continues with TypeScript's resolver. Could this disabled path avoid the exception overhead while preserving the existing fallback behavior?
This is a performance question, separate from the functional enhanced-resolve issue in #1492. PR #1701 notes that the resolver was already disabled before that change. This report does not propose restoring enhanced-resolve.
Measurements
I compared v9.6.2 with an experimental change that replaces throw new Error() in src/resolver.ts with return false. false is allowed by ResolveSync, and the caller continues to TypeScript's resolver. This is one possible implementation, not a proposed definitive fix.
In our private application, two local initial-build comparisons measured:
| Run | Existing configuration | Avoiding the resolver throw | Reduction |
|---|---|---|---|
| 1 | 73.4 s | 39.0 s | 34.4 s (46.9%) |
| 2 | 75.5 s | 43.1 s | 32.4 s (42.9%) |
The generated assets matched except for webpack's compilation hash in runtime.js. The application source and CPU profile are private, so these results are specific to our project and environment.
The published resolver-overhead reproduction fixture is generated and contains no application source. It was run with Node 24.14.1, TypeScript 6.0.3, and webpack 5.112.2. With 300 view modules and a resolution fan-out of 2,100, it produced 634,051 resolver calls per build. After one warmup, the median of three paired initial builds was:
| Resolver behavior | Median initial build |
|---|---|
| Throw and catch | 51.71 s |
| Return no result | 42.71 s |
Both modes reported zero errors and warnings and emitted byte-identical bundles. The fixture's dense import fan-out was chosen to approximate our call volume; these timings do not predict a general application-level speedup.
Correctness check
In a separate small transpileOnly: false watch fixture, both variants emitted byte-identical initial bundles and reported the same TS2322 diagnostic after a source change. These checks cover only the tested configuration.
Could the disabled resolver return no result, or use another approach, to avoid throwing on every call while preserving TypeScript fallback and diagnostics?
- 主要语言
- TypeScript
- 星标
- 3.5k
- 派生
- 439
- 平均合并
- 8 小时 6 分钟
- 30 天内合并 PR
- 12
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TypeStrong/ts-loader 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 52/100
TypeStrong/ts-loader#1709 · 1 条评论 ·
维护者通常 1 天内回复
-
rspack compatibility可能已有人在做 @onigoetz 于 191 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 48/100
TypeStrong/ts-loader#1694 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 35/100
TypeStrong/ts-loader#1675 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 25/100
TypeStrong/ts-loader#1671 · 12 条评论 · 11 个 reaction ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 35/100
TypeStrong/ts-loader#1660 · 1 条评论 ·
维护者通常 1 天内回复
查看 TypeStrong/ts-loader 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
danielmiessler/LifeOS#3028 ·
维护者通常 5 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
-
iOS: last line of a long UITextView text is sometimes not drawn (frame a fraction of a point short)未关闭
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 90/100
Koenkk/zigbee2mqtt#33855 ·
维护者通常 1 天内回复