Conversation
|
ping @whitecolor - separated this out now |
| var lastRequire = m.lastRequire | ||
| if (m.code === 'MODULE_NOT_FOUND' && lastRequire && lastRequire.path.startsWith('.')) { | ||
| var pathNoExt = path.normalize(path.join(path.dirname(lastRequire.filename), lastRequire.path)) | ||
| var watch = chokidar.watch([pathNoExt + '.ts', pathNoExt + '.tsx']) |
There was a problem hiding this comment.
why not just call watcher.add() here? What does chokidar do that filewatcher() cant?
There was a problem hiding this comment.
@jonjaques Please enlighten me if I missed something, but watcher.add() didn't work with non-existant files when I tried
There was a problem hiding this comment.
Naw, was legit curious.
As I understand it this PR is to handle the case where you're in an existing file and you import something that doesn't yet exist:
import {something} from './nonexistent'
This handles the error that would shut down ts-node-dev and then sets up a watcher for what would be ./nonexistent.ts|tsx.
I guess what I meant was, both filewatcher and chokidar are wrappers around the FS.watch, it just seems like conceptually this project should use one or the other.
So different question— could we switch all the filewatcher code to use chokidar instead? Last publish on filewatcher was 3 years ago.
There was a problem hiding this comment.
I'm all for doing that @jonjaques! I think chokidar is more mature
However, I'm no official contributor. Could coordinate if @whitecolor made me
|
Why need to add chokidar? And what are "nonexistant dependencies" could you elaborate workflow for this case? |
|
@whitecolor I think @jonjaques explained it quite well
That requires "watching" files that don't yet exist. I found no such support outside of chokidar. Again, I'm willing to migrate to using chokidar throughout. |
|
ping again @whitecolor |
|
This doesn't work in the general case, as it is not possible to correctly resolve not existing dependency. |
Branched off #93
Fixes for dependencies on not (yet) existing files