Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support file globs with --watch-path #45182

Open
ghost opened this issue Oct 25, 2022 · 12 comments
Open

Support file globs with --watch-path #45182

ghost opened this issue Oct 25, 2022 · 12 comments
Labels
feature request Issues that request new features to be added to Node.js. never-stale Mark issue so that it is never considered stale watch-mode Issues and PRs related to watch mode

Comments

@ghost
Copy link

ghost commented Oct 25, 2022

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.

@ghost ghost added the feature request Issues that request new features to be added to Node.js. label Oct 25, 2022
@MoLow MoLow added the watch-mode Issues and PRs related to watch mode label Oct 26, 2022
@MoLow
Copy link
Member

MoLow commented Oct 26, 2022

I would say there are two separate issues raised here:

  1. watching paths/files that are not required, which is currently supported with --watch-path
  2. using globs as an input for this flag - there have been a few discussions about adding glob support to node and I hope that will eventually happen allowing this to work, but it is currently out of the scope of watch mode.

@ghost
Copy link
Author

ghost commented Oct 26, 2022

Ah, wow, I don't know how I missed --watch-path when it's literally right below --watch in the docs, haha. The globs would definitely be a nice to have, but --watch-path does pretty much what I needed, so appreciate the reply!

EDIT: On a side note, the docs state This option is only supported on macOS and Windows., but it appears to work just fine on linux (Ubuntu).

@MoLow MoLow closed this as completed Oct 26, 2022
@karlhorky
Copy link
Contributor

karlhorky commented Oct 29, 2022

@mmarti @MoLow what do you think about reopening this for support for globs in --watch-path?

Would be great to only target certain file extensions, for example.

@MoLow MoLow reopened this Oct 29, 2022
@karlhorky
Copy link
Contributor

karlhorky commented Oct 29, 2022

Thanks for reopening! Maybe the title can be changed to Support path globs with `--watch-path` ? And I suppose the issue description text will also need to be adapted a bit...

@MoLow MoLow changed the title Support optional file globs with --watch Support file globs with --watch-path Oct 29, 2022
@MoLow
Copy link
Member

MoLow commented Oct 29, 2022

Refs: #40731

@github-actions
Copy link
Contributor

There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment.

For more information on how the project manages feature requests, please consult the feature request management document.

@github-actions github-actions bot added the stale label Apr 28, 2023
@karlhorky
Copy link
Contributor

I guess this one is still validly open, and just because it hasn't had activity, doesn't seem like that is a reason that it won't be implemented... 🤔

Probably will be a pretty common request as more people use the watch mode in the Node.js CLI.

@github-actions
Copy link
Contributor

There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment.

For more information on how the project manages feature requests, please consult the feature request management document.

@github-actions github-actions bot added the stale label Oct 26, 2023
@karlhorky
Copy link
Contributor

not stale

@github-actions github-actions bot removed the stale label Oct 27, 2023
Copy link
Contributor

There has been no activity on this feature request for 5 months. To help maintain relevant open issues, please add the never-stale Mark issue so that it is never considered stale label or close this issue if it should be closed. If not, the issue will be automatically closed 6 months after the last non-automated comment.
For more information on how the project manages feature requests, please consult the feature request management document.

@github-actions github-actions bot added the stale label Apr 24, 2024
@MoLow MoLow removed the stale label Apr 24, 2024
@RedYetiDev RedYetiDev added the never-stale Mark issue so that it is never considered stale label Jun 26, 2024
@RedYetiDev
Copy link
Member

RedYetiDev commented Jun 26, 2024

Given the repeated stale/unstale-ing of this issue, I've marked it as never-stale to save time and energy. Feel free to undo.

(Note the author is @ghost, so if more information is needed, that could be hard to obtain)

@waynesbrain
Copy link

waynesbrain commented Oct 3, 2024

One related problem that I'm having is that using --watch-path causes node to turn off watching of required or imported modules even when used in combination with --watch.

IMO it should watch required/imported modules of any watch-path that I provide. (I am here trying to fix my watch script which was node --watch-path=./src ./scripts/build.mjs until I found out it wasn't rebuilding when dependencies changed).

I ended up having to add all the node_modules I cared about as a watch-path, e.g. node --watch-path=./src --watch-path=../../node_modules/@mine/p1/lib --watch-path=../../node_modules/@mine/p2/lib ./scripts/build.mjs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. never-stale Mark issue so that it is never considered stale watch-mode Issues and PRs related to watch mode
Projects
Development

No branches or pull requests

4 participants