Skip to content

Commit

Permalink
Merge pull request #293 from wood1986/fix-mutating-issue
Browse files Browse the repository at this point in the history
fix: call stats.toJson on each time to avoid the stats mutation
  • Loading branch information
th0r committed Jul 29, 2019
2 parents 44bd8d0 + 1cf518d commit fa2ac7b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/BundleAnalyzerPlugin.js
Expand Up @@ -35,12 +35,11 @@ class BundleAnalyzerPlugin {

const done = (stats, callback) => {
callback = callback || (() => {});
stats = stats.toJson(this.opts.statsOptions);

const actions = [];

if (this.opts.generateStatsFile) {
actions.push(() => this.generateStatsFile(stats));
actions.push(() => this.generateStatsFile(stats.toJson(this.opts.statsOptions)));
}

// Handling deprecated `startAnalyzer` flag
Expand All @@ -49,9 +48,9 @@ class BundleAnalyzerPlugin {
}

if (this.opts.analyzerMode === 'server') {
actions.push(() => this.startAnalyzerServer(stats));
actions.push(() => this.startAnalyzerServer(stats.toJson()));
} else if (this.opts.analyzerMode === 'static') {
actions.push(() => this.generateStaticReport(stats));
actions.push(() => this.generateStaticReport(stats.toJson()));
}

if (actions.length) {
Expand Down

0 comments on commit fa2ac7b

Please sign in to comment.