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

feat: log out which files changed on HMR or watch change #25801

Merged
merged 30 commits into from
Nov 16, 2024

Conversation

HasanAlrimawi
Copy link
Contributor

This PR addresses issue #25504

Changes
When using --watch or --watch-hmr with deno serve, and when using deno run --watch then on any file specified changed, logs will be shown indicating what files changed in a numbered manner.

PS: deno run --watch-hmr already shows if the script being executed was changed.

Screenshot to show the change:
image

@HasanAlrimawi
Copy link
Contributor Author

@marvinhagemeister
Can you give it a look if you have time please?

@marvinhagemeister
Copy link
Contributor

marvinhagemeister commented Sep 23, 2024

Thanks for tackling this. The output already looks better than what we have today.

I noticed that when you change a single file and the HMR is applied successfully (like changing the body of a function), then the output looks like this:

HMR Replaced changed module file:///Users/marvinh/dev/test/deno-hmr/a.ts
Screenshot 2024-09-23 at 15 09 41

I like that it's compact and only takes up one line. The output logged by the changes in this PR always take up at least 3 lines.

HMR File change detected! Restarting!
Files Changed:
1: "/Users/marvinh/dev/test/deno-hmr/main.ts"

How do you feel about making it more compact? Maybe something like this:

# For single file updates
HMR Restarting! File change detected: "/Users/marvinh/dev/test/deno-hmr/main.ts"

# For multiple file updates
HMR Restarting! File changes detected:
- "/Users/marvinh/dev/test/deno-hmr/main.ts"
- "/Users/marvinh/dev/test/deno-hmr/b.ts"

@bartlomieju
Copy link
Member

I'm not really convinced that one can receive "multiple file change". We're restarting on every change and these changes are received one-by-one. I'd encourage to keep single line output and if multifile change happens only use the first one.

@HasanAlrimawi
Copy link
Contributor Author

@marvinhagemeister
Could you please take a look at the recent changes?

@bartlomieju bartlomieju added this to the 2.1.0 milestone Oct 1, 2024
@bartlomieju
Copy link
Member

bartlomieju commented Oct 1, 2024

@HasanAlrimawi thanks for the PR, we'll land it for Deno 2.1.

While you're looking into watcher code, could you change the output to make messages after HMR or Watcher be printed in gray?

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@bartlomieju bartlomieju merged commit abf06eb into denoland:main Nov 16, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants