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

templ generate --watch generates code which fails to render (skaffold+ko on minikube) #711

Closed
Dmarcotrigiano opened this issue Apr 30, 2024 · 3 comments

Comments

@Dmarcotrigiano
Copy link

I have only begun using templ today, so apologies if it is simply skill issues.

I am running minikube in docker on Ubuntu, building the images using skaffold+ko.

When I make a change to a templ file without the watch command, nothing builds, this is expected because skaffold is configured to not watch templ files.

When templ generate --watch is running, a change to a templ file changes the go file and triggers a build of the http server that is serving the templ component.

When port-forwarding the load balancer service for the http server and attempting to access it locally I see the following error in my browser:

templ: failed to render template

When executing the templ generate command, the same behavior results in the Hello World HTML being properly displayed in the browser.

@a-h
Copy link
Owner

a-h commented May 6, 2024

Hi @Dmarcotrigiano - at the moment, that's expected behaviour. In --watch mode, the code that's generated by templ looks at a file on disk instead, to reduce the number of times that your program needs to be recompiled.

However, in your case, it sounds like you're rebuilding your program and creating a new Docker container for each change to a template.

You're not the first person to be surprised by the behaviour, so I think we need to change it as per #700 (comment)

It's a fairly straightforward change, just needs a little thought, and some testing of the performance implications.

@Dmarcotrigiano
Copy link
Author

Hi @a-h, thank you for the reply!

That is correct, and it's blazingly fast! Making a change to a template then building an image, then rolling out a deployment takes like 2 seconds on my machine.

This is what I've done to circumvent the caching behavior

templ generate --watch --cmd="templ generate"

@joerdav
Copy link
Collaborator

joerdav commented May 14, 2024

I believe we can close this as it should be resolved in #700 (comment)

@joerdav joerdav closed this as not planned Won't fix, can't repro, duplicate, stale May 14, 2024
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

No branches or pull requests

3 participants