Skip to content

Commit bf0e3c2

Browse files
committed
PR feedback
1 parent 52bc608 commit bf0e3c2

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

pages/Compiler Options.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Option | Type | Default
8585
`--types` | `string[]`| | List of names of type definitions to include. See [@types, --typeRoots and --types](./tsconfig.json.md#types-typeroots-and-types) for more details.
8686
`--typeRoots` | `string[]`| | List of folders to include type definitions from. See [@types, --typeRoots and --types](./tsconfig.json.md#types-typeroots-and-types) for more details.
8787
`--version`<br/>`-v` | | | Print the compiler's version.
88-
`--watch`<br/>`-w` | | | Run the compiler in watch mode. Watch input files and trigger recompilation on changes.
88+
`--watch`<br/>`-w` | | | Run the compiler in watch mode. Watch input files and trigger recompilation on changes. The implementation of watching files and directories can be configured using environment variable. See [configuring watch](./Configuring%20Watch.md) for more details.
8989

9090
* <sup>[1]</sup> These options are experimental.
9191
* <sup>[2]</sup> These options are only allowed in `tsconfig.json`, and not through command-line switches.

pages/Configuring Watch.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
## Configuring Watch of file and directory
2-
3-
`fs.watch` and `fs.watchFile` provided by node, both have pros and cons.
4-
5-
`fs.watch` uses file system events to notify the changes in the file/directory. But this is OS dependent and the notification is not completely reliable and does not work as expected on many OS. Also there could be limit on number of watches that can be created, eg. linux and we could exhaust it pretty quickly with programs that include large number of files. But because this uses file system events, there is not much CPU cycle involved. Compiler typically uses `fs.watch` to watch directories (eg. source directories included by config file, directories in which module resolution failed etc) These can handle the missing precision in notifying about the changes. But recursive watching is supported on only Windows and OSX. That means we need something to replace the recursive nature on other OS.
6-
7-
`fs.watchFile` uses polling and thus involves CPU cycles. But this is the most reliable mechanism to get the update on the status of file/directory. Compiler typically uses `fs.watchFile` to watch source files, config files and missing files (missing file references) that means the CPU usage depends on number of files in the program.
8-
91
Compiler supports configuring how to watch files and directories using the environment variables.
102

113
## Configuring file watching using environment variable `TSC_WATCHFILE`
@@ -27,4 +19,12 @@ Option | Description
2719
-----------------------------------------------|----------------------------------------------------------------------
2820
`RecursiveDirectoryUsingFsWatchFile` | Use `fs.watchFile` to watch the directories and child directories which is a polling watch (consuming CPU cycles)
2921
`RecursiveDirectoryUsingDynamicPriorityPolling`| Use dynamic polling queue to poll changes to the directory and child directories.
30-
default (no value specified) | Use `fs.watch` to watch directories and child directories
22+
default (no value specified) | Use `fs.watch` to watch directories and child directories
23+
24+
## Background
25+
26+
`--watch` implementation of the compiler relies on `fs.watch` and `fs.watchFile` provided by node, both of these methods have pros and cons.
27+
28+
`fs.watch` uses file system events to notify the changes in the file/directory. But this is OS dependent and the notification is not completely reliable and does not work as expected on many OS. Also there could be limit on number of watches that can be created, eg. linux and we could exhaust it pretty quickly with programs that include large number of files. But because this uses file system events, there is not much CPU cycle involved. Compiler typically uses `fs.watch` to watch directories (eg. source directories included by config file, directories in which module resolution failed etc) These can handle the missing precision in notifying about the changes. But recursive watching is supported on only Windows and OSX. That means we need something to replace the recursive nature on other OS.
29+
30+
`fs.watchFile` uses polling and thus involves CPU cycles. But this is the most reliable mechanism to get the update on the status of file/directory. Compiler typically uses `fs.watchFile` to watch source files, config files and missing files (missing file references) that means the CPU usage depends on number of files in the program.

0 commit comments

Comments
 (0)