Open atipugin opened 3 months ago
I think the issue here is that templ updates the .txt
file, but also is has a file watcher on that dir. And then triggers a reload as textUpdated
is set to true: https://github.com/a-h/templ/blob/main/cmd/templ/generatecmd/eventhandler.go#L115
The only reason I can see that we would do this is if we were expecting that processes outside of templ to be able to update the dev mode files. @a-h My suggestion is that we do not return updated in this case so that text changes don't result in a double reload?
Before you begin
Done.
Describe the bug For some reason
templ generate --watch
processes same file multiple times on a single save. As result, it triggers several page reloads per change. I disabled all formatters to ensure there's nothing to emit another fs event, but it didn't help.I've tried to reproduce it inside devcontainer (used
mcr.microsoft.com/devcontainers/go:1-1.22-bookworm
) and everything works just fine. So I guess the issue is with macOS FS events stuff.To Reproduce
templ generate --watch -v --proxy="http://localhost:8080" --cmd="go run cmd/myapp/main.go"
.templ
fileExpected behavior It should emit only one reload event.
Screenshots
https://github.com/user-attachments/assets/db8c8ad0-76f0-4daf-a44b-eb9a6e94c465
Logs None.
templ info
outputDesktop (please complete the following information):
go version
): go1.23.0 darwin/arm64gopls
version (gopls version
): v0.16.1Additional context None.