-
-
Notifications
You must be signed in to change notification settings - Fork 288
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
refactor: complete rewrite of the generation command, adds fsnotify hot reload #470
Conversation
Still in the process of grokking the bulk of this PR! An initial comment would be on the new |
Explanation of the logic in this file: There's a There's also a The post-processing queue "debounces" messages from the generation queue. It waits until the queue has been empty for 100ms before running any configured commands, or triggering an SSE in the browser to reload the web page. Once these background queues are started, reading from the Context cancellation causes the Finally, the process waits until all background goroutines are finished, before terminating all started commands. I've added a structured logger which can be activated by using the |
Im guessing this will also work if Im running the app from a Docker container for testing ? Assuming it can be used with air. |
@FACorreiaa I don't think this would interop with air too well, it's almost an alternative. Air does the watching for you, and will rebuild your code anyway if I understand it correctly. I think we would have to have a mode where templ only regenerates templ code, and then you could leave the recompiling of Go when required to Air. |
If you run If you get If you run If you then add |
Looks good to me! |
templ/cmd/templ/generatecmd/cmd.go Lines 252 to 255 in 1a1ba97
Where is this relevant? I didn't see any code that pushes |
I don't think there is any code that does that. I think I can remove it. |
Due to the inclusion of log/slog in a-h#470, this is the new minimum version
This PR updates the generation command.
This could solve various issues, including:
This builds on top of the excellent PR from @stephenafamo (#366) which added the dev mode facility where Go recompilation isn't required if only the text changes.
Here's a video showing the updated experience:
templ.hot.reload.-.fsnotify.and.text.updates.mp4