From 7a3df06eb573d36142bd1a8e03c5ce8752d300b3 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 24 May 2017 15:10:37 +0200 Subject: fix build issues and add typedoc --- node_modules/webpack/lib/Compiler.js | 53 ++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 24 deletions(-) (limited to 'node_modules/webpack/lib/Compiler.js') diff --git a/node_modules/webpack/lib/Compiler.js b/node_modules/webpack/lib/Compiler.js index d9fa3d34b..dc17a89f3 100644 --- a/node_modules/webpack/lib/Compiler.js +++ b/node_modules/webpack/lib/Compiler.js @@ -6,15 +6,13 @@ var path = require("path"); var Tapable = require("tapable"); var Compilation = require("./Compilation"); - +var Stats = require("./Stats"); var NormalModuleFactory = require("./NormalModuleFactory"); var ContextModuleFactory = require("./ContextModuleFactory"); function Watching(compiler, watchOptions, handler) { this.startTime = null; this.invalid = false; - this.error = null; - this.stats = null; this.handler = handler; this.closed = false; if(typeof watchOptions === "number") { @@ -38,7 +36,7 @@ function Watching(compiler, watchOptions, handler) { Watching.prototype._go = function() { var self = this; - self.startTime = new Date().getTime(); + self.startTime = Date.now(); self.running = true; self.invalid = false; self.compiler.applyPluginsAsync("watch-run", self, function(err) { @@ -61,9 +59,9 @@ Watching.prototype._go = function() { if(compilation.applyPluginsBailResult("need-additional-pass")) { compilation.needAdditionalPass = true; - var stats = compilation.getStats(); + var stats = new Stats(compilation); stats.startTime = self.startTime; - stats.endTime = new Date().getTime(); + stats.endTime = Date.now(); self.compiler.applyPlugins("done", stats); self.compiler.applyPluginsAsync("additional-pass", function(err) { @@ -79,22 +77,29 @@ Watching.prototype._go = function() { }); }; +Watching.prototype._getStats = function(compilation) { + var stats = new Stats(compilation); + stats.startTime = this.startTime; + stats.endTime = Date.now(); + return stats; +}; + Watching.prototype._done = function(err, compilation) { this.running = false; if(this.invalid) return this._go(); - this.error = err || null; - this.stats = compilation ? compilation.getStats() : null; - if(this.stats) { - this.stats.startTime = this.startTime; - this.stats.endTime = new Date().getTime(); + + var stats = compilation ? this._getStats(compilation) : null; + if(err) { + this.compiler.applyPlugins("failed", err); + this.handler(err, stats); + return; } - if(this.stats) - this.compiler.applyPlugins("done", this.stats); - else - this.compiler.applyPlugins("failed", this.error); - this.handler(this.error, this.stats); - if(!this.error && !this.closed) + + this.compiler.applyPlugins("done", stats); + this.handler(null, stats); + if(!this.closed) { this.watch(compilation.fileDependencies, compilation.contextDependencies, compilation.missingDependencies); + } }; Watching.prototype.watch = function(files, dirs, missing) { @@ -217,7 +222,7 @@ Compiler.prototype.watch = function(watchOptions, handler) { Compiler.prototype.run = function(callback) { var self = this; - var startTime = new Date().getTime(); + var startTime = Date.now(); self.applyPluginsAsync("before-run", self, function(err) { if(err) return callback(err); @@ -232,9 +237,9 @@ Compiler.prototype.run = function(callback) { if(err) return callback(err); if(self.applyPluginsBailResult("should-emit", compilation) === false) { - var stats = compilation.getStats(); + var stats = new Stats(compilation); stats.startTime = startTime; - stats.endTime = new Date().getTime(); + stats.endTime = Date.now(); self.applyPlugins("done", stats); return callback(null, stats); } @@ -245,9 +250,9 @@ Compiler.prototype.run = function(callback) { if(compilation.applyPluginsBailResult("need-additional-pass")) { compilation.needAdditionalPass = true; - var stats = compilation.getStats(); + var stats = new Stats(compilation); stats.startTime = startTime; - stats.endTime = new Date().getTime(); + stats.endTime = Date.now(); self.applyPlugins("done", stats); self.applyPluginsAsync("additional-pass", function(err) { @@ -260,9 +265,9 @@ Compiler.prototype.run = function(callback) { self.emitRecords(function(err) { if(err) return callback(err); - var stats = compilation.getStats(); + var stats = new Stats(compilation); stats.startTime = startTime; - stats.endTime = new Date().getTime(); + stats.endTime = Date.now(); self.applyPlugins("done", stats); return callback(null, stats); }); -- cgit v1.2.3