Skip to content

Commit

Permalink
fix: call stats.toJson on each time to aviod mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
wood1986 committed Jul 17, 2019
1 parent 44bd8d0 commit 4f409be
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 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 4f409be

Please sign in to comment.