Watch mode: Allow adding files to watch when using the --watch flag #45467
Labels
feature request
Issues that request new features to be added to Node.js.
good first issue
Issues that are suitable for first-time contributors.
watch-mode
Issues and PRs related to watch mode


gustavnikolaj commentedNov 15, 2022
What is the problem this feature will solve?
The new
--watchflag will automatically restart the process when any imported file is changed.The new related
--watch-pathflag will restart the process when one of the added paths change.Using
--watch-pathdisables the automatic restarting based on imported modules.--watchis what you want 99% of the time, but there are cases where you want to extend the watched files ever-so-slightly.One such example is
.envwhen used with the dotenv module. No matter if you do it programmatically, or through the use of a-rflag to the node process, changes in the.env.file will not trigger a reload.Other examples could be configuration files in json, yaml og toml formats.
What is the feature you are proposing to solve the problem?
A new flag which will allow extending the set of watched files based on what is imported/required, with specific non-js files which are loaded through non-discoverable methods, without disabling the automatic discovery of files.
The automatic discoverability of files to watch is a killer feature! Unfortunately not being able to add individual files to the watched set is preventing me from using it.
What alternatives have you considered?
I can keep using nodemon or the current
--watch-pathfeature, but have to enumerate and eagerly watch all files that could possibly be loaded. But as--watch-pathdoes not work on Linux it will likely have to be nodemon.The text was updated successfully, but these errors were encountered: