@@ -13,10 +13,8 @@ import {
13
13
WebpackCLICommandOptions ,
14
14
WebpackCLIMainOption ,
15
15
WebpackCLILogger ,
16
- WebpackV4LegacyStats ,
17
16
WebpackDevServerOptions ,
18
17
WebpackRunOptions ,
19
- WebpackV4Compiler ,
20
18
WebpackCompiler ,
21
19
WebpackConfiguration ,
22
20
Argv ,
@@ -34,7 +32,6 @@ import {
34
32
Instantiable ,
35
33
JsonExt ,
36
34
ModuleName ,
37
- MultipleCompilerStatsOptions ,
38
35
PackageInstallOptions ,
39
36
PackageManager ,
40
37
Path ,
@@ -2226,40 +2223,12 @@ class WebpackCLI implements IWebpackCLI {
2226
2223
}
2227
2224
2228
2225
// Setup stats
2229
- // TODO remove after drop webpack@4
2230
- const statsForWebpack4 =
2231
- this . webpack . Stats &&
2232
- ( this . webpack . Stats as unknown as Partial < WebpackV4LegacyStats > ) . presetToOptions ;
2233
-
2234
- if ( statsForWebpack4 ) {
2235
- if ( typeof item . stats === "undefined" ) {
2236
- item . stats = { } ;
2237
- } else if ( typeof item . stats === "boolean" ) {
2238
- item . stats = ( this . webpack . Stats as unknown as WebpackV4LegacyStats ) . presetToOptions (
2239
- item . stats ,
2240
- ) ;
2241
- } else if (
2242
- typeof item . stats === "string" &&
2243
- ( item . stats === "none" ||
2244
- item . stats === "verbose" ||
2245
- item . stats === "detailed" ||
2246
- item . stats === "normal" ||
2247
- item . stats === "minimal" ||
2248
- item . stats === "errors-only" ||
2249
- item . stats === "errors-warnings" )
2250
- ) {
2251
- item . stats = ( this . webpack . Stats as unknown as WebpackV4LegacyStats ) . presetToOptions (
2252
- item . stats ,
2253
- ) ;
2254
- }
2255
- } else {
2256
- if ( typeof item . stats === "undefined" ) {
2257
- item . stats = { preset : "normal" } ;
2258
- } else if ( typeof item . stats === "boolean" ) {
2259
- item . stats = item . stats ? { preset : "normal" } : { preset : "none" } ;
2260
- } else if ( typeof item . stats === "string" ) {
2261
- item . stats = { preset : item . stats } ;
2262
- }
2226
+ if ( typeof item . stats === "undefined" ) {
2227
+ item . stats = { preset : "normal" } ;
2228
+ } else if ( typeof item . stats === "boolean" ) {
2229
+ item . stats = item . stats ? { preset : "normal" } : { preset : "none" } ;
2230
+ } else if ( typeof item . stats === "string" ) {
2231
+ item . stats = { preset : item . stats } ;
2263
2232
}
2264
2233
2265
2234
let colors ;
@@ -2277,10 +2246,7 @@ class WebpackCLI implements IWebpackCLI {
2277
2246
colors = Boolean ( this . colors . isColorSupported ) ;
2278
2247
}
2279
2248
2280
- // TODO remove after drop webpack v4
2281
- if ( typeof item . stats === "object" && item . stats !== null ) {
2282
- item . stats . colors = colors ;
2283
- }
2249
+ item . stats . colors = colors ;
2284
2250
2285
2251
// Apply CLI plugin
2286
2252
if ( ! item . plugins ) {
@@ -2305,12 +2271,7 @@ class WebpackCLI implements IWebpackCLI {
2305
2271
}
2306
2272
2307
2273
isValidationError ( error : Error ) : error is WebpackError {
2308
- // https://github.com/webpack/webpack/blob/master/lib/index.js#L267
2309
- // https://github.com/webpack/webpack/blob/v4.44.2/lib/webpack.js#L90
2310
- const ValidationError =
2311
- this . webpack . ValidationError || this . webpack . WebpackOptionsValidationError ;
2312
-
2313
- return error instanceof ValidationError || error . name === "ValidationError" ;
2274
+ return error instanceof this . webpack . ValidationError || error . name === "ValidationError" ;
2314
2275
}
2315
2276
2316
2277
async createCompiler (
@@ -2350,11 +2311,6 @@ class WebpackCLI implements IWebpackCLI {
2350
2311
process . exit ( 2 ) ;
2351
2312
}
2352
2313
2353
- // TODO webpack@4 return Watching and MultiWatching instead Compiler and MultiCompiler, remove this after drop webpack@4
2354
- if ( compiler && ( compiler as WebpackV4Compiler ) . compiler ) {
2355
- compiler = ( compiler as WebpackV4Compiler ) . compiler ;
2356
- }
2357
-
2358
2314
return compiler ;
2359
2315
}
2360
2316
@@ -2406,17 +2362,6 @@ class WebpackCLI implements IWebpackCLI {
2406
2362
? compiler . options . stats
2407
2363
: undefined ;
2408
2364
2409
- // TODO webpack@4 doesn't support `{ children: [{ colors: true }, { colors: true }] }` for stats
2410
- const statsForWebpack4 =
2411
- this . webpack . Stats &&
2412
- ( this . webpack . Stats as unknown as Partial < WebpackV4LegacyStats > ) . presetToOptions ;
2413
-
2414
- if ( this . isMultipleCompiler ( compiler ) && statsForWebpack4 ) {
2415
- ( statsOptions as StatsOptions ) . colors = (
2416
- statsOptions as MultipleCompilerStatsOptions
2417
- ) . children . some ( ( child ) => child . colors ) ;
2418
- }
2419
-
2420
2365
if ( options . json && createJsonStringifyStream ) {
2421
2366
const handleWriteError = ( error : WebpackError ) => {
2422
2367
this . logger . error ( error ) ;
0 commit comments