Skip to content

Commit 74d265a

Browse files
committed
fix: refactor and memory improvements
1 parent 5dcd6bf commit 74d265a

File tree

4 files changed

+16
-19
lines changed

4 files changed

+16
-19
lines changed

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,6 @@ Display color (can be HEX like `#xxyyzz` or a web color like `green`).
9696

9797
Enable profiler.
9898

99-
### `stream`
100-
- Default: `process.stderr`
101-
102-
Output stream.
103-
10499
### `bars`
105100

106101
- Default: `true` when not in CI or testing mode.

src/plugin.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ const DEFAULTS = {
1515
name: 'webpack',
1616
color: 'green',
1717
profile: false,
18-
stream: process.stdout,
1918
reporters: [],
2019
reporter: null,
2120
simple: isMinimal,
@@ -29,7 +28,6 @@ const DEFAULT_STATE = {
2928
message: '',
3029
details: [],
3130
request: null,
32-
stats: null,
3331
hasErrors: false,
3432
};
3533

@@ -129,14 +127,13 @@ export default class WebpackBarPlugin extends webpack.ProgressPlugin {
129127

130128
Object.assign(this.state, {
131129
...DEFAULT_STATE,
132-
stats,
133130
progress: 100,
134131
message: `Compiled ${status} in ${time}`,
135132
hasErrors,
136133
});
137134

138135
this.callReporters('progress');
139-
this.callReporters('done');
136+
this.callReporters('done', { stats });
140137

141138
if (!this.hasRunning) {
142139
this.callReporters('beforeAllDone');

src/reporters/fancy.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import { formatRequest } from '../utils/request';
77
import { BULLET, TICK, CROSS } from '../utils/consts';
88
import LogUpdate from '../utils/log-update';
99

10-
let lastRender = Date.now();
11-
1210
const logUpdate = new LogUpdate();
1311

12+
let lastRender = Date.now();
13+
1414
export default class FancyReporter {
1515
beforeRun() {
1616
consola.pause();
@@ -37,7 +37,6 @@ export default class FancyReporter {
3737
const renderedStates = Object.keys(states)
3838
.sort((n1, n2) => n1.localeCompare(n2))
3939
.map((name) => ({ name, state: states[name] }))
40-
.filter((c) => c.state.progress >= 0)
4140
.map((c) => this._renderState(c))
4241
.join('\n\n');
4342

@@ -68,13 +67,19 @@ export default class FancyReporter {
6867
ellipsisLeft(formatRequest(state.request), logUpdate.columns)
6968
)
7069
: '';
71-
} else if (state.progress === 100) {
72-
// Finished
73-
line1 = color(`${state.hasErrors ? CROSS : TICK} ${name}`);
74-
line2 = chalk.grey(' ' + state.message);
7570
} else {
76-
// Invalid state
77-
return '';
71+
let icon = ' ';
72+
73+
if (state.hasErrors) {
74+
icon = CROSS;
75+
} else if (state.progress === 100) {
76+
icon = TICK;
77+
} else if (this.progress === -1) {
78+
icon = BULLET;
79+
}
80+
81+
line1 = color(`${icon} ${name}`);
82+
line2 = chalk.grey(' ' + state.message);
7883
}
7984

8085
return line1 + '\n' + line2;

src/reporters/profile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export default class ProfileReporter {
22
done(context) {
33
if (context.options.profile) {
44
const formattedStats = context.state.profile.getFormattedStats();
5-
context.options.stream.write(`\n${formattedStats}\n`);
5+
process.stderr.write(`\n${formattedStats}\n`);
66
}
77
}
88
}

0 commit comments

Comments
 (0)