Open cotyhamilton opened 6 months ago
I'm open to submitting a PR for this feature 🙂
This was suggested before here: https://github.com/ventojs/vento/pull/31
But the main problem is will make loops slower:
{{ for number of 100 }}
{{ import "./show_number.vto" { number } }}
{{ /for }}
Without cache, the "show_number.vto" file is loaded and compiled 100 times.
The recommended way is to clear the cache manually, after any file change, with env.cache.clear();
.
Is there any specific use case in which you need the cache disabled all the time?
It's just a nice to have in dev.
Running that function manually will be the same effort as any other manual action: restart the server, add that function to a route and refresh a page, etc.
if (dev) {
addEventListener("hmr", () => {
env.cache.clear();
});
}
This works okay but not when the vto
files change lol. I'll see if there's a way to configure hmr or watch for files other than js.
It's a good point about the loops and performance
Maybe --watch=*.vto,*.js,*.ts
or --unstable-hmr=*.vto,*.js,*.ts
can do the job. I didn't try.
I'd like to control caching through config.
inspiration
this is how I control caching in development in with eta
example interface
a similar api in vento could allow for this