Sha256: 865a643c2b126a89e6b4ef2be086c4615e04815d45a2a6f1c8552cd0227fdd00
Contents?: true
Size: 986 Bytes
Versions: 62
Compression:
Stored size: 986 Bytes
Contents
/* MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ function UnsafeCachePlugin(regExps, cache) { this.regExps = regExps || [/./]; if(this.regExps === true) this.regExps = [/./]; else if(!Array.isArray(this.regExps)) this.regExps = [this.regExps]; this.cache = cache || {}; } module.exports = UnsafeCachePlugin; UnsafeCachePlugin.prototype.apply = function(resolver) { var oldResolve = resolver.resolve; var regExps = this.regExps; var cache = this.cache; resolver.resolve = function resolve(context, request, callback) { var id = context + "->" + request; if(cache[id]) { // From cache return callback(null, cache[id]); } oldResolve.call(resolver, context, request, function(err, result) { if(err) return callback(err); var doCache = regExps.some(function(regExp) { return regExp.test(result.path); }); if(!doCache) return callback(null, result); callback(null, cache[id] = result); }); }; };
Version data entries
62 entries across 62 versions & 1 rubygems
Version | Path |
---|---|
smock-0.1.209 | node_modules/webpack/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js |
smock-0.1.208 | node_modules/webpack/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js |