Skip to content

Commit e7150ee

Browse files
refactor: use built-in colors
1 parent dab1b5f commit e7150ee

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
"strip-ansi": "^6.0.0",
107107
"supertest": "^7.0.0",
108108
"typescript": "^5.3.3",
109-
"webpack": "^5.93.0"
109+
"webpack": "^5.101.0"
110110
},
111111
"peerDependencies": {
112112
"webpack": "^5.0.0"

src/utils/setupHooks.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,14 @@ function setupHooks(context) {
109109
childStatsOptions = normalizeStatsOptions(childStatsOptions);
110110

111111
if (typeof childStatsOptions.colors === "undefined") {
112+
const [firstCompiler] =
113+
/** @type {MultiCompiler} */
114+
(compiler).compilers;
112115
childStatsOptions.colors =
113-
require("colorette").isColorSupported;
116+
typeof firstCompiler.webpack.cli.isColorSupported ===
117+
"function"
118+
? firstCompiler.webpack.cli.isColorSupported()
119+
: require("colorette").isColorSupported;
114120
}
115121

116122
return childStatsOptions;
@@ -122,12 +128,21 @@ function setupHooks(context) {
122128
);
123129

124130
if (typeof statsOptions.colors === "undefined") {
125-
statsOptions.colors = require("colorette").isColorSupported;
131+
// TODO remove `colorette` and set minimum supported webpack version is `5.101.0`
132+
statsOptions.colors =
133+
typeof (
134+
/** @type {Compiler} */
135+
(context.compiler).webpack.cli.isColorSupported
136+
) === "function"
137+
? /** @type {Compiler} */
138+
(context.compiler).webpack.cli.isColorSupported()
139+
: require("colorette").isColorSupported;
126140
}
127141
}
128142

129143
const printedStats = stats.toString(
130-
/** @type {StatsObjectOptions} */ (statsOptions),
144+
/** @type {StatsObjectOptions} */
145+
(statsOptions),
131146
);
132147

133148
// Avoid extra empty line when `stats: 'none'`

0 commit comments

Comments
 (0)