microsoft / microsoft/TypeScript
Enable chokidar-based watch
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
Suggestion
🔍 Search Terms
idle watch watcher cpu chokidar
✅ Viability Checklist
My suggestion meets these guidelines:
- 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 feature would agree with the rest of TypeScript's Design Goals.
Would actually further goal 10, cross-platform development
⭐ Suggestion
Please add one or more of these:
- chokidar as a new option for
tsconfig::watchOptions.watchFileandtsconfig::watchOptions.watchDirectory - chokidar as a new option for
env::TSC_WATCHFILEandenv::TSC_WATCHDIRECTORY - chokidar as default watcher – maybe dependent on whether chokidar is available in the project
💻 Use Cases
While working with create-react-app, I noticed that my machine tended to get quite loud. Investigating that, I found the reason to be surprisingly large CPU utilization. That, in turn, I could trace back to this issue:
https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/issues/236
The solution there was to switch TSC to fs.watch instead of fs.watchFile. That works for the most part. However, as @sheetalkamat points out in https://github.com/microsoft/TypeScript/issues/31048#issuecomment-495659901, that implementation is known to be problematic. Which is why it is not the default and won't be in the foreseeable future.
Prior discussions
https://github.com/microsoft/TypeScript/issues/31048 talks about the background to this request. There, @nicoburns already asked about this:
Would you consider switching to Chokidar? It's a battle tested solution used very widely throughout the Node ecosystem. We're in the process of switching to TypeScript at work, and the watch processes are taking ~45% cpu each on my 2015 MacBook Pro. As far as I am aware Node's built-in file watching capabilities are generally considered broken and not suitable for production use.
In response, @jasonwilliams pointed out that webpack had switched back to fs.watch, which might indicate that it had been fixed by now. Unfortunately, node v16 still has the same warnings, and webpack's switch seems to have been less thoroughly investigated than we would have desired: https://github.com/webpack/watchpack/issues/130
https://github.com/microsoft/TypeScript/issues/19762 and https://github.com/microsoft/TypeScript/issues/17506 also showed performance issues. https://github.com/microsoft/TypeScript/issues/19762 actually has the same resolution as https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/issues/236, and https://github.com/microsoft/TypeScript/issues/17506 seems to have prompted some intensive work.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
この issue では、具体的なファイル、テスト、エントリポイントは指定されていません。まず TypeScript の既存の watch オプションとリンクされた過去の議論を確認し、その後 chokidar をオプションにするべきかデフォルトにするべきか、また設定をどのように機能させるべきかを判断してください。完了には、合意された設計と実装範囲が必要です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- node.js, typescript
- 領域
- devtools
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 25/100