From 1cf518d5c6d10c7d2b6308dbc526370957ef29e2 Mon Sep 17 00:00:00 2001 From: wood1986 <5212215+wood1986@users.noreply.github.com> Date: Tue, 16 Jul 2019 21:18:09 -0700 Subject: [PATCH] fix: call stats.toJson on each time to aviod mutation --- src/BundleAnalyzerPlugin.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/BundleAnalyzerPlugin.js b/src/BundleAnalyzerPlugin.js index 0fa1779d..44b5cdaf 100644 --- a/src/BundleAnalyzerPlugin.js +++ b/src/BundleAnalyzerPlugin.js @@ -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 @@ -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) {