Hey again~ :)
Please consider a client-side lru-cache implementation. While far from the fastest, quick-lru would get the job done for you since it has a "dispose" hook and is Map-based (OnigScanner keys will still work).
I'm also willing to author another lru module if you need me to.
Related: shikijs/shiki#22