From de98e0b232509d5f40c135d540a70e415272ff85 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 3 May 2017 15:35:00 +0200 Subject: node_modules --- .../webpack/lib/node/NodeChunkTemplatePlugin.js | 27 +++ .../webpack/lib/node/NodeEnvironmentPlugin.js | 25 +++ .../lib/node/NodeHotUpdateChunkTemplatePlugin.js | 27 +++ .../webpack/lib/node/NodeMainTemplate.runtime.js | 24 +++ .../lib/node/NodeMainTemplateAsync.runtime.js | 40 +++++ .../webpack/lib/node/NodeMainTemplatePlugin.js | 191 +++++++++++++++++++++ .../webpack/lib/node/NodeOutputFileSystem.js | 22 +++ node_modules/webpack/lib/node/NodeSourcePlugin.js | 84 +++++++++ node_modules/webpack/lib/node/NodeTargetPlugin.js | 15 ++ .../webpack/lib/node/NodeTemplatePlugin.js | 27 +++ .../webpack/lib/node/NodeWatchFileSystem.js | 72 ++++++++ 11 files changed, 554 insertions(+) create mode 100644 node_modules/webpack/lib/node/NodeChunkTemplatePlugin.js create mode 100644 node_modules/webpack/lib/node/NodeEnvironmentPlugin.js create mode 100644 node_modules/webpack/lib/node/NodeHotUpdateChunkTemplatePlugin.js create mode 100644 node_modules/webpack/lib/node/NodeMainTemplate.runtime.js create mode 100644 node_modules/webpack/lib/node/NodeMainTemplateAsync.runtime.js create mode 100644 node_modules/webpack/lib/node/NodeMainTemplatePlugin.js create mode 100644 node_modules/webpack/lib/node/NodeOutputFileSystem.js create mode 100644 node_modules/webpack/lib/node/NodeSourcePlugin.js create mode 100644 node_modules/webpack/lib/node/NodeTargetPlugin.js create mode 100644 node_modules/webpack/lib/node/NodeTemplatePlugin.js create mode 100644 node_modules/webpack/lib/node/NodeWatchFileSystem.js (limited to 'node_modules/webpack/lib/node') diff --git a/node_modules/webpack/lib/node/NodeChunkTemplatePlugin.js b/node_modules/webpack/lib/node/NodeChunkTemplatePlugin.js new file mode 100644 index 000000000..dd5e0e354 --- /dev/null +++ b/node_modules/webpack/lib/node/NodeChunkTemplatePlugin.js @@ -0,0 +1,27 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ + +"use strict"; + +const ConcatSource = require("webpack-sources").ConcatSource; + +class NodeChunkTemplatePlugin { + + apply(chunkTemplate) { + chunkTemplate.plugin("render", function(modules, chunk) { + const source = new ConcatSource(); + source.add(`exports.ids = ${JSON.stringify(chunk.ids)};\nexports.modules = `); + source.add(modules); + source.add(";"); + return source; + }); + chunkTemplate.plugin("hash", function(hash) { + hash.update("node"); + hash.update("3"); + }); + } +} + +module.exports = NodeChunkTemplatePlugin; diff --git a/node_modules/webpack/lib/node/NodeEnvironmentPlugin.js b/node_modules/webpack/lib/node/NodeEnvironmentPlugin.js new file mode 100644 index 000000000..b8200a3ca --- /dev/null +++ b/node_modules/webpack/lib/node/NodeEnvironmentPlugin.js @@ -0,0 +1,25 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const NodeWatchFileSystem = require("./NodeWatchFileSystem"); +const NodeOutputFileSystem = require("./NodeOutputFileSystem"); +const NodeJsInputFileSystem = require("enhanced-resolve/lib/NodeJsInputFileSystem"); +const CachedInputFileSystem = require("enhanced-resolve/lib/CachedInputFileSystem"); + +class NodeEnvironmentPlugin { + apply(compiler) { + compiler.inputFileSystem = new CachedInputFileSystem(new NodeJsInputFileSystem(), 60000); + const inputFileSystem = compiler.inputFileSystem; + compiler.outputFileSystem = new NodeOutputFileSystem(); + compiler.watchFileSystem = new NodeWatchFileSystem(compiler.inputFileSystem); + compiler.plugin("before-run", (compiler, callback) => { + if(compiler.inputFileSystem === inputFileSystem) + inputFileSystem.purge(); + callback(); + }); + } +} +module.exports = NodeEnvironmentPlugin; diff --git a/node_modules/webpack/lib/node/NodeHotUpdateChunkTemplatePlugin.js b/node_modules/webpack/lib/node/NodeHotUpdateChunkTemplatePlugin.js new file mode 100644 index 000000000..52239f7b6 --- /dev/null +++ b/node_modules/webpack/lib/node/NodeHotUpdateChunkTemplatePlugin.js @@ -0,0 +1,27 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const ConcatSource = require("webpack-sources").ConcatSource; + +class NodeHotUpdateChunkTemplatePlugin { + + apply(hotUpdateChunkTemplate) { + hotUpdateChunkTemplate.plugin("render", (modulesSource, modules, removedModules, hash, id) => { + const source = new ConcatSource(); + source.add("exports.id = " + JSON.stringify(id) + ";\nexports.modules = "); + source.add(modulesSource); + source.add(";"); + return source; + }); + hotUpdateChunkTemplate.plugin("hash", function(hash) { + hash.update("NodeHotUpdateChunkTemplatePlugin"); + hash.update("3"); + hash.update(this.outputOptions.hotUpdateFunction + ""); + hash.update(this.outputOptions.library + ""); + }); + } +} +module.exports = NodeHotUpdateChunkTemplatePlugin; diff --git a/node_modules/webpack/lib/node/NodeMainTemplate.runtime.js b/node_modules/webpack/lib/node/NodeMainTemplate.runtime.js new file mode 100644 index 000000000..2725e2e79 --- /dev/null +++ b/node_modules/webpack/lib/node/NodeMainTemplate.runtime.js @@ -0,0 +1,24 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +/*global installedChunks $hotChunkFilename$ hotAddUpdateChunk $hotMainFilename$ */ +module.exports = function() { + function hotDownloadUpdateChunk(chunkId) { // eslint-disable-line no-unused-vars + var chunk = require("./" + $hotChunkFilename$); + hotAddUpdateChunk(chunk.id, chunk.modules); + } + + function hotDownloadManifest() { // eslint-disable-line no-unused-vars + try { + var update = require("./" + $hotMainFilename$); + } catch(e) { + return Promise.resolve(); + } + return Promise.resolve(update); + } + + function hotDisposeChunk(chunkId) { //eslint-disable-line no-unused-vars + delete installedChunks[chunkId]; + } +}; diff --git a/node_modules/webpack/lib/node/NodeMainTemplateAsync.runtime.js b/node_modules/webpack/lib/node/NodeMainTemplateAsync.runtime.js new file mode 100644 index 000000000..673cfafd0 --- /dev/null +++ b/node_modules/webpack/lib/node/NodeMainTemplateAsync.runtime.js @@ -0,0 +1,40 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +/*global installedChunks $hotChunkFilename$ $require$ hotAddUpdateChunk $hotMainFilename$ */ +module.exports = function() { + function hotDownloadUpdateChunk(chunkId) { // eslint-disable-line no-unused-vars + var filename = require("path").join(__dirname, $hotChunkFilename$); + require("fs").readFile(filename, "utf-8", function(err, content) { + if(err) { + if($require$.onError) + return $require$.oe(err); + else + throw err; + } + var chunk = {}; + require("vm").runInThisContext("(function(exports) {" + content + "\n})", filename)(chunk); + hotAddUpdateChunk(chunk.id, chunk.modules); + }); + } + + function hotDownloadManifest() { // eslint-disable-line no-unused-vars + var filename = require("path").join(__dirname, $hotMainFilename$); + return new Promise(function(resolve, reject) { + require("fs").readFile(filename, "utf-8", function(err, content) { + if(err) return resolve(); + try { + var update = JSON.parse(content); + } catch(e) { + return reject(e); + } + resolve(update); + }); + }); + } + + function hotDisposeChunk(chunkId) { //eslint-disable-line no-unused-vars + delete installedChunks[chunkId]; + } +}; diff --git a/node_modules/webpack/lib/node/NodeMainTemplatePlugin.js b/node_modules/webpack/lib/node/NodeMainTemplatePlugin.js new file mode 100644 index 000000000..d4660dac1 --- /dev/null +++ b/node_modules/webpack/lib/node/NodeMainTemplatePlugin.js @@ -0,0 +1,191 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +var Template = require("../Template"); + +function NodeMainTemplatePlugin(asyncChunkLoading) { + this.asyncChunkLoading = asyncChunkLoading; +} +module.exports = NodeMainTemplatePlugin; +NodeMainTemplatePlugin.prototype.apply = function(mainTemplate) { + var self = this; + mainTemplate.plugin("local-vars", function(source, chunk) { + if(chunk.chunks.length > 0) { + return this.asString([ + source, + "", + "// object to store loaded chunks", + "// \"0\" means \"already loaded\"", + "var installedChunks = {", + this.indent( + chunk.ids.map(function(id) { + return id + ": 0"; + }).join(",\n") + ), + "};" + ]); + } + return source; + }); + mainTemplate.plugin("require-extensions", function(source, chunk) { + if(chunk.chunks.length > 0) { + return this.asString([ + source, + "", + "// uncatched error handler for webpack runtime", + this.requireFn + ".oe = function(err) {", + this.indent([ + "process.nextTick(function() {", + this.indent("throw err; // catch this error by using System.import().catch()"), + "});" + ]), + "};" + ]); + } + return source; + }); + mainTemplate.plugin("require-ensure", function(_, chunk, hash) { + var chunkFilename = this.outputOptions.chunkFilename; + var chunkMaps = chunk.getChunkMaps(); + var insertMoreModules = [ + "var moreModules = chunk.modules, chunkIds = chunk.ids;", + "for(var moduleId in moreModules) {", + this.indent(this.renderAddModule(hash, chunk, "moduleId", "moreModules[moduleId]")), + "}" + ]; + if(self.asyncChunkLoading) { + return this.asString([ + "// \"0\" is the signal for \"already loaded\"", + "if(installedChunks[chunkId] === 0)", + this.indent([ + "return Promise.resolve();" + ]), + "// array of [resolve, reject, promise] means \"currently loading\"", + "if(installedChunks[chunkId])", + this.indent([ + "return installedChunks[chunkId][2];" + ]), + "// load the chunk and return promise to it", + "var promise = new Promise(function(resolve, reject) {", + this.indent([ + "installedChunks[chunkId] = [resolve, reject];", + "var filename = __dirname + " + this.applyPluginsWaterfall("asset-path", JSON.stringify("/" + chunkFilename), { + hash: "\" + " + this.renderCurrentHashCode(hash) + " + \"", + hashWithLength: function(length) { + return "\" + " + this.renderCurrentHashCode(hash, length) + " + \""; + }.bind(this), + chunk: { + id: "\" + chunkId + \"", + hash: "\" + " + JSON.stringify(chunkMaps.hash) + "[chunkId] + \"", + hashWithLength: function(length) { + var shortChunkHashMap = {}; + Object.keys(chunkMaps.hash).forEach(function(chunkId) { + if(typeof chunkMaps.hash[chunkId] === "string") + shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(0, length); + }); + return "\" + " + JSON.stringify(shortChunkHashMap) + "[chunkId] + \""; + }, + name: "\" + (" + JSON.stringify(chunkMaps.name) + "[chunkId]||chunkId) + \"" + } + }) + ";", + "require('fs').readFile(filename, 'utf-8', function(err, content) {", + this.indent([ + "if(err) return reject(err);", + "var chunk = {};", + "require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)" + + "(chunk, require, require('path').dirname(filename), filename);" + ].concat(insertMoreModules).concat([ + "var callbacks = [];", + "for(var i = 0; i < chunkIds.length; i++) {", + this.indent([ + "if(installedChunks[chunkIds[i]])", + this.indent([ + "callbacks = callbacks.concat(installedChunks[chunkIds[i]][0]);" + ]), + "installedChunks[chunkIds[i]] = 0;" + ]), + "}", + "for(i = 0; i < callbacks.length; i++)", + this.indent("callbacks[i]();") + ])), + "});" + ]), + "});", + "return installedChunks[chunkId][2] = promise;" + ]); + } else { + var request = this.applyPluginsWaterfall("asset-path", JSON.stringify("./" + chunkFilename), { + hash: "\" + " + this.renderCurrentHashCode(hash) + " + \"", + hashWithLength: function(length) { + return "\" + " + this.renderCurrentHashCode(hash, length) + " + \""; + }.bind(this), + chunk: { + id: "\" + chunkId + \"", + hash: "\" + " + JSON.stringify(chunkMaps.hash) + "[chunkId] + \"", + hashWithLength: function(length) { + var shortChunkHashMap = {}; + Object.keys(chunkMaps.hash).forEach(function(chunkId) { + if(typeof chunkMaps.hash[chunkId] === "string") + shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(0, length); + }); + return "\" + " + JSON.stringify(shortChunkHashMap) + "[chunkId] + \""; + }, + name: "\" + (" + JSON.stringify(chunkMaps.name) + "[chunkId]||chunkId) + \"" + } + }); + return this.asString([ + "// \"0\" is the signal for \"already loaded\"", + "if(installedChunks[chunkId] !== 0) {", + this.indent([ + "var chunk = require(" + request + ");" + ].concat(insertMoreModules).concat([ + "for(var i = 0; i < chunkIds.length; i++)", + this.indent("installedChunks[chunkIds[i]] = 0;") + ])), + "}", + "return Promise.resolve();" + ]); + } + }); + mainTemplate.plugin("hot-bootstrap", function(source, chunk, hash) { + var hotUpdateChunkFilename = this.outputOptions.hotUpdateChunkFilename; + var hotUpdateMainFilename = this.outputOptions.hotUpdateMainFilename; + var chunkMaps = chunk.getChunkMaps(); + var currentHotUpdateChunkFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateChunkFilename), { + hash: "\" + " + this.renderCurrentHashCode(hash) + " + \"", + hashWithLength: function(length) { + return "\" + " + this.renderCurrentHashCode(hash, length) + " + \""; + }.bind(this), + chunk: { + id: "\" + chunkId + \"", + hash: "\" + " + JSON.stringify(chunkMaps.hash) + "[chunkId] + \"", + hashWithLength: function(length) { + var shortChunkHashMap = {}; + Object.keys(chunkMaps.hash).forEach(function(chunkId) { + if(typeof chunkMaps.hash[chunkId] === "string") + shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(0, length); + }); + return "\" + " + JSON.stringify(shortChunkHashMap) + "[chunkId] + \""; + }, + name: "\" + (" + JSON.stringify(chunkMaps.name) + "[chunkId]||chunkId) + \"" + } + }); + var currentHotUpdateMainFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateMainFilename), { + hash: "\" + " + this.renderCurrentHashCode(hash) + " + \"", + hashWithLength: function(length) { + return "\" + " + this.renderCurrentHashCode(hash, length) + " + \""; + }.bind(this) + }); + return Template.getFunctionContent(self.asyncChunkLoading ? require("./NodeMainTemplateAsync.runtime.js") : require("./NodeMainTemplate.runtime.js")) + .replace(/\$require\$/g, this.requireFn) + .replace(/\$hotMainFilename\$/g, currentHotUpdateMainFilename) + .replace(/\$hotChunkFilename\$/g, currentHotUpdateChunkFilename); + }); + mainTemplate.plugin("hash", function(hash) { + hash.update("node"); + hash.update("3"); + hash.update(this.outputOptions.filename + ""); + hash.update(this.outputOptions.chunkFilename + ""); + }); +}; diff --git a/node_modules/webpack/lib/node/NodeOutputFileSystem.js b/node_modules/webpack/lib/node/NodeOutputFileSystem.js new file mode 100644 index 000000000..5a6e328e1 --- /dev/null +++ b/node_modules/webpack/lib/node/NodeOutputFileSystem.js @@ -0,0 +1,22 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const fs = require("fs"); +const path = require("path"); +const mkdirp = require("mkdirp"); + +class NodeOutputFileSystem { + constructor() { + this.mkdirp = mkdirp; + this.mkdir = fs.mkdir.bind(fs); + this.rmdir = fs.rmdir.bind(fs); + this.unlink = fs.unlink.bind(fs); + this.writeFile = fs.writeFile.bind(fs); + this.join = path.join.bind(path); + } +} + +module.exports = NodeOutputFileSystem; diff --git a/node_modules/webpack/lib/node/NodeSourcePlugin.js b/node_modules/webpack/lib/node/NodeSourcePlugin.js new file mode 100644 index 000000000..4e0716a25 --- /dev/null +++ b/node_modules/webpack/lib/node/NodeSourcePlugin.js @@ -0,0 +1,84 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +var AliasPlugin = require("enhanced-resolve/lib/AliasPlugin"); +var ParserHelpers = require("../ParserHelpers"); +var nodeLibsBrowser = require("node-libs-browser"); + +function NodeSourcePlugin(options) { + this.options = options; +} +module.exports = NodeSourcePlugin; +NodeSourcePlugin.prototype.apply = function(compiler) { + var options = this.options; + + function getPathToModule(module, type) { + if(type === true || (type === undefined && nodeLibsBrowser[module])) { + if(!nodeLibsBrowser[module]) throw new Error("No browser version for node.js core module '" + module + "' available"); + return nodeLibsBrowser[module]; + } else if(type === "mock") { + return require.resolve("node-libs-browser/mock/" + module); + } else if(type === "empty") { + return require.resolve("node-libs-browser/mock/empty"); + } else return module; + } + + function addExpression(parser, name, module, type, suffix) { + suffix = suffix || ""; + parser.plugin("expression " + name, function() { + if(this.state.module && this.state.module.resource === getPathToModule(module, type)) return; + var mockModule = ParserHelpers.requireFileAsExpression(this.state.module.context, getPathToModule(module, type)); + return ParserHelpers.addParsedVariableToModule(this, name, mockModule + suffix); + }); + } + + compiler.plugin("compilation", function(compilation, params) { + params.normalModuleFactory.plugin("parser", function(parser, parserOptions) { + + if(parserOptions.node === false) + return; + + var localOptions = options; + if(parserOptions.node) + localOptions = Object.assign({}, localOptions, parserOptions.node); + + if(localOptions.global) { + parser.plugin("expression global", function() { + var retrieveGlobalModule = ParserHelpers.requireFileAsExpression(this.state.module.context, require.resolve("../../buildin/global.js")); + return ParserHelpers.addParsedVariableToModule(this, "global", retrieveGlobalModule); + }); + } + if(localOptions.process) { + var processType = localOptions.process; + addExpression(parser, "process", "process", processType); + } + if(localOptions.console) { + var consoleType = localOptions.console; + addExpression(parser, "console", "console", consoleType); + } + var bufferType = localOptions.Buffer; + if(bufferType) { + addExpression(parser, "Buffer", "buffer", bufferType, ".Buffer"); + } + if(localOptions.setImmediate) { + var setImmediateType = localOptions.setImmediate; + addExpression(parser, "setImmediate", "timers", setImmediateType, ".setImmediate"); + addExpression(parser, "clearImmediate", "timers", setImmediateType, ".clearImmediate"); + } + }); + }); + compiler.plugin("after-resolvers", function(compiler) { + Object.keys(nodeLibsBrowser).forEach(function(lib) { + if(options[lib] !== false) { + compiler.resolvers.normal.apply( + new AliasPlugin("described-resolve", { + name: lib, + onlyModule: true, + alias: getPathToModule(lib, options[lib]) + }, "resolve") + ); + } + }); + }); +}; diff --git a/node_modules/webpack/lib/node/NodeTargetPlugin.js b/node_modules/webpack/lib/node/NodeTargetPlugin.js new file mode 100644 index 000000000..528a28570 --- /dev/null +++ b/node_modules/webpack/lib/node/NodeTargetPlugin.js @@ -0,0 +1,15 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const ExternalsPlugin = require("../ExternalsPlugin"); + +class NodeTargetPlugin { + apply(compiler) { + new ExternalsPlugin("commonjs", Object.keys(process.binding("natives"))).apply(compiler); + } +} + +module.exports = NodeTargetPlugin; diff --git a/node_modules/webpack/lib/node/NodeTemplatePlugin.js b/node_modules/webpack/lib/node/NodeTemplatePlugin.js new file mode 100644 index 000000000..ed17d1937 --- /dev/null +++ b/node_modules/webpack/lib/node/NodeTemplatePlugin.js @@ -0,0 +1,27 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ + +"use strict"; + +const NodeMainTemplatePlugin = require("./NodeMainTemplatePlugin"); +const NodeChunkTemplatePlugin = require("./NodeChunkTemplatePlugin"); +const NodeHotUpdateChunkTemplatePlugin = require("./NodeHotUpdateChunkTemplatePlugin"); + +class NodeTemplatePlugin { + constructor(options) { + options = options || {}; + this.asyncChunkLoading = options.asyncChunkLoading; + } + + apply(compiler) { + compiler.plugin("this-compilation", (compilation) => { + compilation.mainTemplate.apply(new NodeMainTemplatePlugin(this.asyncChunkLoading)); + compilation.chunkTemplate.apply(new NodeChunkTemplatePlugin()); + compilation.hotUpdateChunkTemplate.apply(new NodeHotUpdateChunkTemplatePlugin()); + }); + } +} + +module.exports = NodeTemplatePlugin; diff --git a/node_modules/webpack/lib/node/NodeWatchFileSystem.js b/node_modules/webpack/lib/node/NodeWatchFileSystem.js new file mode 100644 index 000000000..a4ff6c6b5 --- /dev/null +++ b/node_modules/webpack/lib/node/NodeWatchFileSystem.js @@ -0,0 +1,72 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const Watchpack = require("watchpack"); + +class NodeWatchFileSystem { + constructor(inputFileSystem) { + this.inputFileSystem = inputFileSystem; + this.watcherOptions = { + aggregateTimeout: 0 + }; + this.watcher = new Watchpack(this.watcherOptions); + } + + watch(files, dirs, missing, startTime, options, callback, callbackUndelayed) { + if(!Array.isArray(files)) + throw new Error("Invalid arguments: 'files'"); + if(!Array.isArray(dirs)) + throw new Error("Invalid arguments: 'dirs'"); + if(!Array.isArray(missing)) + throw new Error("Invalid arguments: 'missing'"); + if(typeof callback !== "function") + throw new Error("Invalid arguments: 'callback'"); + if(typeof startTime !== "number" && startTime) + throw new Error("Invalid arguments: 'startTime'"); + if(typeof options !== "object") + throw new Error("Invalid arguments: 'options'"); + if(typeof callbackUndelayed !== "function" && callbackUndelayed) + throw new Error("Invalid arguments: 'callbackUndelayed'"); + const oldWatcher = this.watcher; + this.watcher = new Watchpack(options); + + if(callbackUndelayed) + this.watcher.once("change", callbackUndelayed); + + this.watcher.once("aggregated", (changes, removals) => { + changes = changes.concat(removals); + if(this.inputFileSystem && this.inputFileSystem.purge) { + this.inputFileSystem.purge(changes); + } + const times = this.watcher.getTimes(); + callback(null, + changes.filter(file => files.indexOf(file) >= 0).sort(), + changes.filter(file => dirs.indexOf(file) >= 0).sort(), + changes.filter(file => missing.indexOf(file) >= 0).sort(), times, times); + }); + + this.watcher.watch(files.concat(missing), dirs, startTime); + + if(oldWatcher) { + oldWatcher.close(); + } + return { + close: () => { + if(this.watcher) { + this.watcher.close(); + this.watcher = null; + } + }, + pause: () => { + if(this.watcher) { + this.watcher.pause(); + } + } + }; + } +} + +module.exports = NodeWatchFileSystem; -- cgit v1.2.3