Skip to content

Commit 623ca4e

Browse files
committed
caching info
1 parent 5e9b7e9 commit 623ca4e

4 files changed

Lines changed: 11 additions & 3 deletions

File tree

‎lib/Cache.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ $.create = function(request) {
4545
var item = {
4646
files: []
4747
};
48-
return {
48+
var cacheEntry = {
4949
add: function(path) {
5050
item.files.push({
5151
path: path,
@@ -59,6 +59,8 @@ $.create = function(request) {
5959
save: function(value) {
6060
item.value = value;
6161
self.map[request] = item;
62+
cacheEntry.saved = true;
6263
}
6364
}
65+
return cacheEntry;
6466
}

‎lib/buildDeps.js‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,16 @@ function addModule(depTree, context, modu, options, reason, finalCallback) {
129129
if(options.cache) {
130130
options.cache.get(filenameWithLoaders, function(err, source) {
131131
if(err) return readFile();
132+
modu.fromCache = true;
132133
processJs(null, source);
133134
});
134135
} else
135136
readFile();
136137

137138
// Read the file and process it with loaders
139+
var cacheEntry;
138140
function readFile() {
139-
var cacheEntry = options.cache && options.cache.create(filenameWithLoaders);
141+
cacheEntry = options.cache && options.cache.create(filenameWithLoaders);
140142

141143
// read file content
142144
if(cacheEntry) cacheEntry.add(filename);
@@ -159,6 +161,8 @@ function addModule(depTree, context, modu, options, reason, finalCallback) {
159161
callback(err);
160162
return;
161163
}
164+
if(cacheEntry && cacheEntry.saved)
165+
modu.toCache = true;
162166
var deps;
163167
try {
164168
deps = parse(source, options.parse);

‎lib/formatOutput.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module.exports = function(stats, options) {
5959
buf.push(" "+c("\033[1m") + sprintf("%3s", module.id+"") + " " + (typeof module.size === "number" ? sprintf("%9s", Math.round(module.size)+"") : " ") + " " +
6060
(compressFilename(module.filename) ||
6161
(module.dirname && ("[context] " + compressFilename(module.dirname))) ||
62-
"[unknown]") + c("\033[22m"));
62+
"[unknown]") + c("\033[22m") + (module.fromCache ? " [from cache]" : module.toCache ? " [caching]" : ""));
6363
if(options.verbose) {
6464
module.reasons.forEach(function(reason) {
6565
switch(reason.type) {

‎lib/webpack.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,8 @@ function webpack(context, moduleName, options, callback) {
400400
size: modu.size,
401401
filename: modu.filename,
402402
dirname: modu.dirname,
403+
fromCache: modu.fromCache,
404+
toCache: modu.toCache,
403405
reasons: modu.reasons});
404406
sum++;
405407
}

0 commit comments

Comments
 (0)