Watch mode: Allow adding files to watch when using the --watch flag · Issue #45467 · nodejs/node · GitHub
Skip to content

Watch mode: Allow adding files to watch when using the --watch flag #45467

Description

@gustavnikolaj

What is the problem this feature will solve?

The new --watch flag will automatically restart the process when any imported file is changed.

The new related --watch-path flag will restart the process when one of the added paths change.

Using --watch-path disables the automatic restarting based on imported modules.

--watch is 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 .env when used with the dotenv module. No matter if you do it programmatically, or through the use of a -r flag 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-path feature, but have to enumerate and eagerly watch all files that could possibly be loaded. But as --watch-path does not work on Linux it will likely have to be nodemon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.watch-modeIssues and PRs related to watch mode

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions