Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: call stats.toJson on each time to avoid the stats mutation #293

Merged
merged 1 commit into from Jul 29, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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