node
node copied to clipboard
Support file globs with `--watch-path`
What is the problem this feature will solve?
The new experimental watch feature is awesome, but sometimes apps depend on non-imported files or data. For example, if your app has a set of templates that are read/cached at server start, updating an HTML file won't restart the process.
What is the feature you are proposing to solve the problem?
It would be extremely useful to provide an optional list of file globs that would also trigger a process restart. For example:
# current
$ node --watch app.mjs
# proposed
$ node --watch app.mjs views/*.html
Note: this syntax is just to illustrate the idea.
What alternatives have you considered?
Some template engines/libraries have caching logic built in so it's disabled during local development, but supporting this in a more generic way would open up a lot of additional use cases without having to explicitly code against NODE_ENV
or enabling/disabling caching. Since the watch feature already seems to do exactly what would be needed to make this work, it would simply have to accept an optional glob or list of globs to also watch along with any imports.