-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/watching nonexistant dependencies #97
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just call watcher.add()
here? What does chokidar do that filewatcher()
cant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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