[英]Does tsc-watch consume TSC_NONPOLLING_WATCHER?
I am working on microservice integration project.我正在从事微服务集成项目。 I run 8 typescript services at the same time using
tsc-watch --preserveWatchOutput --onSuccess 'node build/index.js'
.我使用
tsc-watch --preserveWatchOutput --onSuccess 'node build/index.js'
同时运行 8 个打字稿服务。
The processes consume 70% of my CPU, even when I make no source code at all.这些进程消耗了我 70% 的 CPU,即使我根本没有编写源代码。 I figured there is some polling for changes going on and googled that setting environment variable TSC_NONPOLLING_WATCHER to "1" will stop the polling.
我认为对正在进行的更改进行了一些轮询,并在谷歌上搜索到将环境变量 TSC_NONPOLLING_WATCHER 设置为“1”将停止轮询。
This is the source of the hint: https://medium.com/@julioromano/writing-typescript-on-a-laptop-this-might-improve-your-battery-life-f503dd16f019这是提示的来源: https : //medium.com/@julioromano/writing-typescript-on-a-laptop-this-might-improve-your-battery-life-f503dd16f019
It does however seem to have no effect at all.然而,它似乎根本没有影响。 Also, the author mentions "tsc -w" and not tsc-watch.
此外,作者提到了“tsc -w”而不是 tsc-watch。 I do not quite understand what the difference is between tsc -w and tsc-watch.
我不太明白 tsc -w 和 tsc-watch 之间有什么区别。
I would be thankful for any help.我将不胜感激任何帮助。
Update 1 no changed in tsconfig.json
needed更新 1不需要在
tsconfig.json
更改
I run into a similar problem and are going to solve it by setting the environment variable TSC_NONPOLLING_WATCHER="1"
properly.我遇到了类似的问题,将通过正确设置环境变量
TSC_NONPOLLING_WATCHER="1"
来解决它。
In my case i had to adjust .zprofile
via在我的情况下,我不得不通过调整
.zprofile
export TSC_NONPOLLING_WATCHER="1"
You can test it in a command shell via echo $TSC_NONPOLLING_WATCHER
.您可以通过
echo $TSC_NONPOLLING_WATCHER
在命令外壳中对其进行echo $TSC_NONPOLLING_WATCHER
。
Alternative选择
If this doesn't help try to set the tsconfig.json
files to the following:如果这没有帮助,请尝试将
tsconfig.json
文件设置为以下内容:
"watchOptions": {
// Use native file system events for files and directories
"watchFile": "useFsEvents",
"watchDirectory": "useFsEvents",
// Poll files for updates more frequently
// when they're updated a lot.
"fallbackPolling": "dynamicPriority"
}
These options come from: https://www.typescriptlang.org/docs/handbook/configuring-watch.html and I highly suggest reading through it before doing any changes.这些选项来自: https : //www.typescriptlang.org/docs/handbook/configuring-watch.html ,我强烈建议在进行任何更改之前通读一遍。
tsc vs tsc-watch tsc 与 tsc-watch
About the difference between tsc -w
and tsc-watch
the project on github claimes and I quote:关于
tsc -w
和tsc-watch
项目在 github 上的声明和我引用的区别:
- tsc-watch is using the currently installed TypeScript compiler.
tsc-watch 正在使用当前安装的 TypeScript 编译器。
- tsc-watch is not changing the compiler, just adds the new arguments, compilation is the same, and all other arguments are the same.
tsc-watch 并没有改变编译器,只是增加了新的参数,编译是一样的,其他参数都是一样的。
So all settings for tsc should work as well in tsc-watch like in your case.所以 tsc 的所有设置都应该像你的情况一样在 tsc-watch 中工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.