Skip to content

Commit

Permalink
fix: unused plugin instances store state in global
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkdo committed Nov 7, 2018
1 parent be9b171 commit 556f830
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,6 @@ export default class WebpackBarPlugin extends ProgressPlugin {
this.updateProgress(percent, message, details);
};

// Keep our state in shared ojbect
if (!this.states[this.options.name]) {
this.states[this.options.name] = {
...DEFAULT_STATE,
color: this.options.color,
name: startCase(this.options.name),
};
}

// Reporters
this.reporters = Array.from(this.options.reporters || []);
if (this.options.reporter) {
Expand Down Expand Up @@ -145,6 +136,17 @@ export default class WebpackBarPlugin extends ProgressPlugin {
}
}

hook('afterPlugins', () => {
// Keep our state in shared object
if (!this.states[this.options.name]) {
this.states[this.options.name] = {
...DEFAULT_STATE,
color: this.options.color,
name: startCase(this.options.name),
};
}
});

// Hook into the compiler before a new compilation is created.
hook('compile', () => {
Object.assign(this.state, {
Expand Down

0 comments on commit 556f830

Please sign in to comment.