enhanced-resolve
enhanced-resolve copied to clipboard
Callback for whether `unsafeCache` was used to respond to a request
Would be useful to know what requests are cached by the UnsafeCachePlugin.
A cacheStatusFn or something like that would be useful. I think modifying the return value might be too intrusive.
Workaround
Use a proxy/getter on the cache object.
const proxiedCache = new Proxy(cache, {
get: function (target, name, receiver) {
if (!(name in target)) {
console.log('not cached')
return undefined
}
return Reflect.get(target, name, receiver)
},
set: function (target, name, value, receiver) {
if (!(name in target)) {
console.log('caching')
}
return Reflect.set(target, name, value, receiver)
},
})
Or just implement a new UnsafeCachePlugin, but not sure how to report back...