nodejs / nodejs/node

Support file globs with `--watch-path`

Open
#45,182 13 comments 14 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request never-stale watch-mode
Dominant language
JavaScript
Stars
122k
Forks
37.3k
Avg merge
4d 2h
Merged PRs (30d)
283

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No implementation files or tests are named. Start by reviewing the existing --watch command and how it tracks imported files; define how optional glob arguments should be parsed and watched. Done means matching non-imported files, such as views/*.html, trigger a process restart alongside imported-file changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.