Force await import() to import a fresh copy?
I have a Deno instance that dynamically loads a module with:
await import("some/module.js")
The module changes on disk and now I want the running deno instance to import it again getting the fresh changes. I was accomplishing this by adding a random number like await import("some/module.js?v=" + Date.now().toString())
which deno then views as a new file and happily loads it.
Problem is, over time, this caused my deno dep_analysis_cache
files on disk to become HUGE (1GB+).
Is there a magic way I can force deno when I call import() to always import a fresh copy?
Or some whay to clear the already loaded cached content?
Or should I just stay on top of the dep_analysis_Cache bloat and delete them when they get big?7 Replies
If you use
#
instead of ?
our system should know to share underlying resources like this, since it should know it's the same file. I don't know if dep_analysis_cache
does that though. cc @dsherretCool, using
#
instead of ?
does indeed work, thanks. Hopefully the cache file won't baloon over time 🙂Yeah that was the part I wasn't sure about...
Also, the balooning was seen in deno many versions ago, not sure if it still happens in more recent deno versions or not. I'll keep an eye on it and see how it does (currently running deno 1.35.0)
the dep analysis cache only gets cleared out with each deno upgrade. Makes sense it would keep growing if doing something like this
k. I'll just clear it out monthly if it gets too big, with my regular system maintenance I perform. Thanks 🙂
There's a new deno released every week and new minor every month so it might be easier to just upgrade deno monthly