Skip to content

Commit 8165164

Browse files
committed
explicitly call new Stats with compilation
instead of having compilation.getStats returning a new instance of `Stats(this)`
1 parent e0ae4c8 commit 8165164

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

lib/Compilation.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const ModuleDependencyError = require("./ModuleDependencyError");
1414
const Module = require("./Module");
1515
const Chunk = require("./Chunk");
1616
const Entrypoint = require("./Entrypoint");
17-
const Stats = require("./Stats");
1817
const MainTemplate = require("./MainTemplate");
1918
const ChunkTemplate = require("./ChunkTemplate");
2019
const HotUpdateChunkTemplate = require("./HotUpdateChunkTemplate");
@@ -1214,10 +1213,6 @@ class Compilation extends Tapable {
12141213
return this.mainTemplate.applyPluginsWaterfall("asset-path", filename, data);
12151214
}
12161215

1217-
getStats() {
1218-
return new Stats(this);
1219-
}
1220-
12211216
createChildCompiler(name, outputOptions) {
12221217
return this.compiler.createChildCompiler(this, name, outputOptions);
12231218
}

lib/Compiler.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@ var path = require("path");
66
var Tapable = require("tapable");
77

88
var Compilation = require("./Compilation");
9-
9+
var Stats = require("./Stats");
1010
var NormalModuleFactory = require("./NormalModuleFactory");
1111
var ContextModuleFactory = require("./ContextModuleFactory");
1212

1313
function Watching(compiler, watchOptions, handler) {
1414
this.startTime = null;
1515
this.invalid = false;
1616
this.error = null;
17-
this.stats = null;
1817
this.handler = handler;
1918
this.closed = false;
2019
if(typeof watchOptions === "number") {
@@ -61,7 +60,7 @@ Watching.prototype._go = function() {
6160
if(compilation.applyPluginsBailResult("need-additional-pass")) {
6261
compilation.needAdditionalPass = true;
6362

64-
var stats = compilation.getStats();
63+
var stats = new Stats(compilation);
6564
stats.startTime = self.startTime;
6665
stats.endTime = new Date().getTime();
6766
self.compiler.applyPlugins("done", stats);
@@ -83,7 +82,7 @@ Watching.prototype._done = function(err, compilation) {
8382
this.running = false;
8483
if(this.invalid) return this._go();
8584
this.error = err || null;
86-
this.stats = compilation ? compilation.getStats() : null;
85+
this.stats = compilation ? new Stats(compilation) : null;
8786
if(this.stats) {
8887
this.stats.startTime = this.startTime;
8988
this.stats.endTime = new Date().getTime();
@@ -232,7 +231,7 @@ Compiler.prototype.run = function(callback) {
232231
if(err) return callback(err);
233232

234233
if(self.applyPluginsBailResult("should-emit", compilation) === false) {
235-
var stats = compilation.getStats();
234+
var stats = new Stats(compilation);
236235
stats.startTime = startTime;
237236
stats.endTime = new Date().getTime();
238237
self.applyPlugins("done", stats);
@@ -245,7 +244,7 @@ Compiler.prototype.run = function(callback) {
245244
if(compilation.applyPluginsBailResult("need-additional-pass")) {
246245
compilation.needAdditionalPass = true;
247246

248-
var stats = compilation.getStats();
247+
var stats = new Stats(compilation);
249248
stats.startTime = startTime;
250249
stats.endTime = new Date().getTime();
251250
self.applyPlugins("done", stats);
@@ -260,7 +259,7 @@ Compiler.prototype.run = function(callback) {
260259
self.emitRecords(function(err) {
261260
if(err) return callback(err);
262261

263-
var stats = compilation.getStats();
262+
var stats = new Stats(compilation);
264263
stats.startTime = startTime;
265264
stats.endTime = new Date().getTime();
266265
self.applyPlugins("done", stats);

0 commit comments

Comments
 (0)