From 3cb3cf7285b5ef8aca5aa8253bb04475b895e725 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 13 May 2013 14:25:37 +0200 Subject: [PATCH] purge only changed files, longer caching --- lib/node/NodeEnvironmentPlugin.js | 7 ++++++- lib/node/NodeWatchFileSystem.js | 9 +++++++-- package.json | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/node/NodeEnvironmentPlugin.js b/lib/node/NodeEnvironmentPlugin.js index b230adf0e..f6dcf94d1 100644 --- a/lib/node/NodeEnvironmentPlugin.js +++ b/lib/node/NodeEnvironmentPlugin.js @@ -12,10 +12,15 @@ function NodeEnvironmentPlugin() { module.exports = NodeEnvironmentPlugin; NodeEnvironmentPlugin.prototype.apply = function(compiler) { compiler.inputFileSystem = new NodeJsInputFileSystem(); - compiler.inputFileSystem = new CachedInputFileSystem(compiler.inputFileSystem, 6000); + var inputFileSystem = compiler.inputFileSystem = new CachedInputFileSystem(compiler.inputFileSystem, 60000); compiler.resolvers.normal.fileSystem = compiler.inputFileSystem; compiler.resolvers.context.fileSystem = compiler.inputFileSystem; compiler.resolvers.loader.fileSystem = compiler.inputFileSystem; compiler.outputFileSystem = new NodeOutputFileSystem(); compiler.watchFileSystem = new NodeWatchFileSystem(compiler.inputFileSystem); + compiler.plugin("run", function(compiler, callback) { + if(compiler.inputFileSystem === inputFileSystem) + inputFileSystem.purge(); + callback(); + }); }; \ No newline at end of file diff --git a/lib/node/NodeWatchFileSystem.js b/lib/node/NodeWatchFileSystem.js index 8a6329e8f..a6723bf41 100644 --- a/lib/node/NodeWatchFileSystem.js +++ b/lib/node/NodeWatchFileSystem.js @@ -201,8 +201,13 @@ NodeWatchFileSystem.prototype.watch = function(files, dirs, startTime, delay, ca function onTimeout() { change = function() {}; if(closed) return; - if(inputFileSystem && inputFileSystem.purge) inputFileSystem.purge(); - callback(null, Object.keys(filesModified).sort(), Object.keys(dirsModified).sort(), fileTimestamps, dirTimestamps); + var outdatedFiles = Object.keys(filesModified).sort(); + var outdatedDirs = Object.keys(dirsModified).sort(); + if(inputFileSystem && inputFileSystem.purge) { + inputFileSystem.purge(outdatedFiles); + inputFileSystem.purge(outdatedDirs); + } + callback(null, outdatedFiles, outdatedDirs, fileTimestamps, dirTimestamps); close(); } diff --git a/package.json b/package.json index d21884257..87d779926 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "webpack", - "version": "0.10.0-beta11", + "version": "0.10.0-beta12", "author": "Tobias Koppers @sokra", "description": "Packs CommonJs/AMD/Labeled Modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jade, coffee, css, less, ... and your custom stuff.", "dependencies": {