watchify
watchify copied to clipboard
Doesn't detect new files?
Is there a configuration needed to get watchify to recognize new files?
How do you mean new files? Like from a glob? If you require() new files in your existing code they will get included and watched. Unless perhaps there is a bug.
Here's a use case that fails for me, that might be what @chrisabrams is describing:
watchify test/*.test.js -o public/js/tests.js -v
This will build the current set of test files. If you touch test/foo.test.js to create a new spec file, it won't be picked up.
This is understandable, since the widcard is expanded by the shell before it is passed to watchify. Likewise, if you were using grunt-browserify with watch: true, it would also expand the wildcard before handing the list of files to watchify.
chokidar would have to support watching wildcards/globs, and watchify would need a special argument to pass a wildcard to be dynamically evaluated, rather than a list of files. Watching an arbitrary glob pattern for files that may not exist yet does not seem like something easy to accomplish, at least at first glance....
In the meantime, I just restart watchify when I add a new entry point.
@aearly that's what I have to end up doing as well..but I want it to pick it up for me :)
I just came across fireworm which can watch globs patterns for new files (as well as the other standard fs.watch events). It needs a basedir to start from, however.
+1, most of the gulp incremental build packages offer this.
@aearly watchify uses chokidar which does support added files & globs (perhaps it did not when you commented?).
@simonzack the issue is glob expansion before the list of files is handed to watchify.
watchify test/*.test.js -o public/js/tests.js
gets expanded to:
watchify test/foo.test.js test/bar.test.js test/baz.test.js -o public/js/tests.js
and then executed.
There is no way for watchify to know that test/qux.test.js has been added because it has no knowledge of the glob -- as far as it knows, you passed in a list of files.
watchify 'test/*.test.js' -o public/js/tests.js could be used instead. I'm switching to gulp-watch, niether has caching so there's no difference in my case.
Yep, or probably something like watchify --entry-glob 'test/*.test.js' -o public/js/tests.js to make it explicit.