Skip to content

Support file globs with --watch-path #45182

Open
@ghost

Description

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.never-staleMark issue so that it is never considered stalewatch-modeIssues and PRs related to watch mode

    Type

    No type

    Projects

    Status

    Triaged

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions