Repository navigation
tsc: watch mode doesn't discover new files #4553
Description
Activity
looks like another place where we should use the new node watch APIs: see #4643
+1 to have this soon. Is it for 1.7 like in #5076 or for 1.8 like here?
Alex Eagle (@alexeagle) these two issues are both for 1.7
+1 to have this soon(er), this is annoying :)
- addedFixedA PR has been merged for this issueA PR has been merged for this issue
on Oct 15, 2015 Dirk Bäumer (@dbaeumer) can you give latest a try?
Hmm - I'm using 2.0.10 and tsc -w does not spot new files. If I ctrl-c and restart, it then transpiles
jmls (@jmls) Can you provide the following info:
- your os
- your node version
- are you using a network mounted file system?
- if possible, a small project that repros the issue.
Of course.
node: 4.6.1, 7.0.0 and 7.2.0
os: c9.io, running ubuntu 4.2.0-c9 #2 SMP x86_64 x86_64 x86_64 GNU/Linuxdemo project at https://github.com/jmls/tsc-watch
I've created a new file by copying in the shell (
cp part1.ts part2.ts) and creating a new file in the ideDo you run
tsc -wfrom project root path instead of fromsrc? If so this is a known issue, as node's file watcher doesn't support recursive watching on linux.I do - but I am amazed that tsc still uses fw.watch if it has such a fundamental problem.
Are you looking to fix this by using a package like chokidar ?Indeed it is not ideal and creating a file watcher for node is out of the domain of our main focus. If there are no signs in addressing this in upcoming node updates, I do think a third-party package is the most likely approach. Though we are very cautious in adding third-party dependencies (currently we have none).
This is a very relevant issue to my organization. I would like you to re-open it.
We, and I assume many others, do our building in Docker containers, with source directories mounted in volumes. This gives us the assurance that all devs use the same environment as production. The Docker container, of course, is running Linux, where node's fs.watch is broken.
We let the tsc --watch process inside Docker pick up changes made on the outside, giving us a very nice dev cycle where compilation and tests are re-run automatically whenever a file is changed.
We absolutely want to keep using the native
tsc --watch, since external modules have many issues:- Can never do as good a job with incremental recompilation as tsc can
- Stop working if tsc changes
- Maintainers stop maintaining them
So I ask you: Given the prevalence of people using Docker for development, please start considering Linux a supported platform, and ensure that your amazing
--watchmode is fully supported there as well.Since you don't want strict dependencies on external libraries, I suggest doing this with an optionalDependency.
Reacted by JunChao, 陈天寒, coldcafe, Kok-Jin Sam, NextLogic h.ono, Brice BERNARD, Jonathan Doherty, Douglas Henri, Andrey, Chris Cosgriff and 1 moreconst chokidar = require('chokidar'); const watcher = chokidar.watch(<dir>); watcher.on('add', function(p){ /// a file was added with path = p });
this should be easy to add to tsc -w, right?
Alright so I already had created a tsc --watch wrapper that could spawn separate watchers for each tsconfig.json file in a project. tsc -w only seems to be able to watch for changes that pertain to one tsconfig.json file...
So I added this chokidar watch feature to the same project that can take into account multiple tsconfig.json files, so now the watcher will restart when a new file is added. I created this recently, so it's nothing great, but star it if you are interested in me making it better.
Is this supposed to work? I don't see it with my system. Frustrating for bigger monorepos because have to restart a bunch of watchers for any file addition anywhere.
Ah figured it out, I had this in my tsconfig:
"include": ["/**/*"],Changing to this works:
"include": ["**/*"],- locked and limited conversation to collaborators
on Jul 31, 2018

Observe: it is not transpiled.