Skip to content

Commit 556f830

Browse files
committed
fix: unused plugin instances store state in global
1 parent be9b171 commit 556f830

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/plugin.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,6 @@ export default class WebpackBarPlugin extends ProgressPlugin {
4242
this.updateProgress(percent, message, details);
4343
};
4444

45-
// Keep our state in shared ojbect
46-
if (!this.states[this.options.name]) {
47-
this.states[this.options.name] = {
48-
...DEFAULT_STATE,
49-
color: this.options.color,
50-
name: startCase(this.options.name),
51-
};
52-
}
53-
5445
// Reporters
5546
this.reporters = Array.from(this.options.reporters || []);
5647
if (this.options.reporter) {
@@ -145,6 +136,17 @@ export default class WebpackBarPlugin extends ProgressPlugin {
145136
}
146137
}
147138

139+
hook('afterPlugins', () => {
140+
// Keep our state in shared object
141+
if (!this.states[this.options.name]) {
142+
this.states[this.options.name] = {
143+
...DEFAULT_STATE,
144+
color: this.options.color,
145+
name: startCase(this.options.name),
146+
};
147+
}
148+
});
149+
148150
// Hook into the compiler before a new compilation is created.
149151
hook('compile', () => {
150152
Object.assign(this.state, {

0 commit comments

Comments
 (0)