File tree Expand file tree Collapse file tree 5 files changed +30
-22
lines changed
Expand file tree Collapse file tree 5 files changed +30
-22
lines changed Original file line number Diff line number Diff line change 9191 "ts-loader" : " ^9.3.1" ,
9292 "ts-node" : " ^10.9.1" ,
9393 "typescript" : " ^5.0.4" ,
94- "webpack" : " ^5.94.0 " ,
94+ "webpack" : " ^5.99.1 " ,
9595 "webpack-bundle-analyzer" : " ^4.5.0" ,
9696 "webpack-dev-server" : " ^5.1.0"
9797 }
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ const WEBPACK_PACKAGE = process.env.WEBPACK_PACKAGE || "webpack";
55const WEBPACK_DEV_SERVER_PACKAGE = process . env . WEBPACK_DEV_SERVER_PACKAGE || "webpack-dev-server" ;
66
77type Problem = NonNullable < ReturnType < ( typeof cli ) [ "processArguments" ] > > [ 0 ] ;
8+ type StringsKeys < T > = { [ K in keyof T ] : T [ K ] extends string ? K : never } [ keyof T ] ;
89
910class ServeCommand {
1011 async apply ( cli : IWebpackCLI ) : Promise < void > {
@@ -174,22 +175,23 @@ class ServeCommand {
174175 { } ,
175176 ) ;
176177 const result = { ...( compilerForDevServer . options . devServer || { } ) } ;
177- const problems = (
178- cli . webpack . cli && typeof cli . webpack . cli . processArguments === "function"
179- ? cli . webpack . cli
180- : DevServer . cli
181- ) . processArguments ( args , result , values ) ;
178+ const problems = cli . webpack . cli . processArguments ( args , result , values ) ;
182179
183180 if ( problems ) {
184- const groupBy = ( xs : Problem [ ] , key : keyof Problem ) => {
181+ const groupBy = < K extends keyof Problem & StringsKeys < Problem > > (
182+ xs : Problem [ ] ,
183+ key : K ,
184+ ) => {
185185 return xs . reduce ( ( rv : { [ key : string ] : Problem [ ] } , x : Problem ) => {
186- ( rv [ x [ key ] ] = rv [ x [ key ] ] || [ ] ) . push ( x ) ;
186+ const path = x [ key ] ;
187+
188+ ( rv [ path ] = rv [ path ] || [ ] ) . push ( x ) ;
187189
188190 return rv ;
189191 } , { } ) ;
190192 } ;
191193
192- const problemsByPath = groupBy ( problems , "path" ) ;
194+ const problemsByPath = groupBy < "path" > ( problems , "path" ) ;
193195
194196 for ( const path in problemsByPath ) {
195197 const problems = problemsByPath [ path ] ;
Original file line number Diff line number Diff line change @@ -133,7 +133,7 @@ interface WebpackCLIBuiltInFlag {
133133 value : string ,
134134 previous : Record < string , BasicPrimitive | object > ,
135135 ) => Record < string , BasicPrimitive | object > ;
136- configs ?: Partial < FlagConfig > [ ] ;
136+ configs ?: ArgumentConfig [ ] ;
137137 negative ?: boolean ;
138138 multiple ?: boolean ;
139139 valueName ?: string ;
@@ -191,12 +191,17 @@ type LoadableWebpackConfiguration = PotentialPromise<
191191type CallableWebpackConfiguration = ( env : Env | undefined , argv : Argv ) => WebpackConfiguration ;
192192type WebpackCompiler = Compiler | MultiCompiler ;
193193
194- type FlagType = boolean | "enum" | "string" | "path" | "number" | "boolean" | "RegExp" | "reset" ;
194+ type EnumValueObject = { [ key : string ] : EnumValue } ;
195+ type EnumValueArray = EnumValue [ ] ;
196+ type EnumValue = string | number | boolean | EnumValueObject | EnumValueArray | null ;
195197
196- type FlagConfig = {
197- negatedDescription : string ;
198- type : FlagType ;
199- values : FlagType [ ] ;
198+ type ArgumentConfig = {
199+ description ?: string ;
200+ negatedDescription ?: string ;
201+ path ?: string ;
202+ multiple ?: boolean ;
203+ type : "enum" | "string" | "path" | "number" | "boolean" | "RegExp" | "reset" ;
204+ values ?: EnumValue [ ] ;
200205} ;
201206
202207type FileSystemCacheOptions = WebpackConfiguration & {
@@ -324,7 +329,8 @@ export {
324329 LoadableWebpackConfiguration ,
325330 DynamicImport ,
326331 FileSystemCacheOptions ,
327- FlagConfig ,
332+ ArgumentConfig ,
333+ EnumValue ,
328334 ImportLoaderError ,
329335 Instantiable ,
330336 JsonExt ,
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ import type {
2424 LoadableWebpackConfiguration ,
2525 DynamicImport ,
2626 FileSystemCacheOptions ,
27- FlagConfig ,
27+ EnumValue ,
2828 ImportLoaderError ,
2929 Instantiable ,
3030 JsonExt ,
@@ -1646,7 +1646,7 @@ class WebpackCLI implements IWebpackCLI {
16461646 return accumulator ;
16471647 }
16481648 } ,
1649- < FlagConfig [ "values" ] > [ ] ,
1649+ < EnumValue [ ] > [ ] ,
16501650 ) ;
16511651
16521652 if ( possibleValues . length > 0 ) {
Original file line number Diff line number Diff line change @@ -10241,10 +10241,10 @@ webpack-sources@^3.2.3:
1024110241 resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde"
1024210242 integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==
1024310243
10244- webpack@^5.94.0 :
10245- version "5.98.0 "
10246- resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.98.0 .tgz#44ae19a8f2ba97537978246072fb89d10d1fbd17 "
10247- integrity sha512-UFynvx+gM44Gv9qFgj0acCQK2VE1CtdfwFdimkapco3hlPCJ/zeq73n2yVKimVbtm+TnApIugGhLJnkU6gjYXA ==
10244+ webpack@^5.99.1 :
10245+ version "5.99.1 "
10246+ resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.99.1 .tgz#8847e847678bcc3d1fc93a30741bbd78bccc028c "
10247+ integrity sha512-o9gY7ibHPFxLjF6NtvQ6+5CGknsPTRllsL6SEnqR2Zhjk02hiIioJYLS7dvrWaykrRbbmhvDeKp36mKHNbKYiw ==
1024810248 dependencies :
1024910249 " @types/eslint-scope" " ^3.7.7"
1025010250 " @types/estree" " ^1.0.6"
You can’t perform that action at this time.
0 commit comments