@modern-js/utils 2.31.2 → 2.32.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/LICENSE +1 -1
  3. package/dist/cjs/runtime/nestedRoutes.js +21 -8
  4. package/dist/cjs/runtime-node/index.js +1 -0
  5. package/dist/cjs/runtime-node/loaderContext/createLoaderCtx.js +34 -0
  6. package/dist/cjs/runtime-node/loaderContext/createRequestCtx.js +38 -0
  7. package/dist/cjs/runtime-node/loaderContext/index.js +22 -0
  8. package/dist/cjs/universal/constants.js +4 -0
  9. package/dist/compiled/webpack-chain/index.js +1 -1
  10. package/dist/compiled/webpack-chain/package.json +1 -1
  11. package/dist/compiled/webpack-chain/types/index.d.ts +381 -170
  12. package/dist/esm/runtime/nestedRoutes.js +47 -13
  13. package/dist/esm/runtime-node/index.js +1 -0
  14. package/dist/esm/runtime-node/loaderContext/createLoaderCtx.js +20 -0
  15. package/dist/esm/runtime-node/loaderContext/createRequestCtx.js +24 -0
  16. package/dist/esm/runtime-node/loaderContext/index.js +3 -0
  17. package/dist/esm/universal/constants.js +1 -0
  18. package/dist/esm-node/runtime/nestedRoutes.js +22 -9
  19. package/dist/esm-node/runtime-node/index.js +1 -0
  20. package/dist/esm-node/runtime-node/loaderContext/createLoaderCtx.js +15 -0
  21. package/dist/esm-node/runtime-node/loaderContext/createRequestCtx.js +19 -0
  22. package/dist/esm-node/runtime-node/loaderContext/index.js +3 -0
  23. package/dist/esm-node/universal/constants.js +1 -0
  24. package/dist/types/runtime/nestedRoutes.d.ts +3 -2
  25. package/dist/types/runtime-node/index.d.ts +2 -1
  26. package/dist/types/runtime-node/loaderContext/createLoaderCtx.d.ts +7 -0
  27. package/dist/types/runtime-node/loaderContext/createRequestCtx.d.ts +7 -0
  28. package/dist/types/runtime-node/loaderContext/index.d.ts +4 -0
  29. package/dist/types/runtime-node/nestedRoutes.d.ts +1 -1
  30. package/dist/types/universal/constants.d.ts +5 -1
  31. package/package.json +6 -6
@@ -1,24 +1,32 @@
1
- import { Tapable } from 'tapable';
2
- import * as webpack from 'webpack';
1
+ import {
2
+ Configuration,
3
+ Compiler,
4
+ WebpackPluginInstance,
5
+ RuleSetRule,
6
+ ResolveOptions,
7
+ } from 'webpack';
3
8
  import * as https from 'https';
4
9
 
5
10
  export = Config;
6
11
 
7
12
  declare namespace __Config {
8
13
  class Chained<Parent> {
14
+ batch(handler: (chained: this) => void): this;
9
15
  end(): Parent;
10
16
  }
11
-
12
- class TypedChainedMap<Parent, Value> extends Chained<Parent> {
17
+ class TypedChainedMap<Parent, OptionsType> extends Chained<Parent> {
13
18
  clear(): this;
14
19
  delete(key: string): this;
15
20
  has(key: string): boolean;
16
- get(key: string): Value;
17
- getOrCompute(key: string, compute: () => Value): Value;
18
- set(key: string, value: Value): this;
19
- merge(obj: { [key: string]: Value }): this;
20
- entries(): { [key: string]: Value };
21
- values(): Value[];
21
+ get<T extends keyof OptionsType>(key: T): OptionsType[T];
22
+ getOrCompute<T extends keyof OptionsType>(
23
+ key: T,
24
+ compute: () => OptionsType[T],
25
+ ): OptionsType[T];
26
+ set<T extends keyof OptionsType>(key: T, value: OptionsType[T]): this;
27
+ merge(obj: Partial<OptionsType>): this;
28
+ entries(): OptionsType;
29
+ values<T extends keyof OptionsType>(): [OptionsType[T]][];
22
30
  when(
23
31
  condition: boolean,
24
32
  trueBrancher: (obj: this) => void,
@@ -27,7 +35,6 @@ declare namespace __Config {
27
35
  }
28
36
 
29
37
  class ChainedMap<Parent> extends TypedChainedMap<Parent, any> {}
30
-
31
38
  class TypedChainedSet<Parent, Value> extends Chained<Parent> {
32
39
  add(value: Value): this;
33
40
  prepend(value: Value): this;
@@ -46,48 +53,59 @@ declare namespace __Config {
46
53
  class ChainedSet<Parent> extends TypedChainedSet<Parent, any> {}
47
54
  }
48
55
 
56
+ type WebpackConfig = Required<Configuration>;
49
57
  declare class Config extends __Config.ChainedMap<void> {
50
- devServer: Config.DevServer;
51
- entryPoints: Config.TypedChainedMap<Config, Config.EntryPoint>;
52
- module: Config.Module;
53
- node: Config.ChainedMap<this>;
58
+ entryPoints: Config.TypedChainedMap<
59
+ Config,
60
+ { [key: string]: Config.EntryPoint }
61
+ >;
54
62
  output: Config.Output;
63
+ module: Config.Module;
64
+ node: Config.ChainedMap<this> & ((value: boolean) => this);
55
65
  optimization: Config.Optimization;
56
- performance: Config.Performance;
57
- plugins: Config.Plugins<this, webpack.Plugin>;
66
+ performance: Config.Performance & ((value: boolean) => this);
67
+ plugins: Config.Plugins<this, WebpackPluginInstance>;
58
68
  resolve: Config.Resolve;
59
69
  resolveLoader: Config.ResolveLoader;
70
+ devServer: Config.DevServer;
60
71
 
61
- amd(value: { [moduleName: string]: boolean }): this;
62
- bail(value: boolean): this;
63
- cache(value: boolean | any): this;
72
+ context(value: WebpackConfig['context']): this;
73
+ mode(value: WebpackConfig['mode']): this;
64
74
  devtool(value: Config.DevTool): this;
65
- context(value: string): this;
66
- externals(value: webpack.ExternalsElement | webpack.ExternalsElement[]): this;
67
- loader(value: any): this;
68
- name(value: string): this;
69
- mode(value: 'none' | 'development' | 'production'): this;
70
- parallelism(value: number): this;
71
- profile(value: boolean): this;
72
- recordsPath(value: string): this;
73
- recordsInputPath(value: string): this;
74
- recordsOutputPath(value: string): this;
75
- stats(value: webpack.Options.Stats): this;
76
- target(value: string): this;
77
- watch(value: boolean): this;
78
- watchOptions(value: webpack.Options.WatchOptions): this;
75
+ target(value: WebpackConfig['target']): this;
76
+ watch(value: WebpackConfig['watch']): this;
77
+ watchOptions(value: WebpackConfig['watchOptions']): this;
78
+ externals(value: WebpackConfig['externals']): this;
79
+ externalsType(value: WebpackConfig['externalsType']): this;
80
+ externalsPresets(value: WebpackConfig['externalsPresets']): this;
81
+ stats(value: WebpackConfig['stats']): this;
82
+ experiments(value: WebpackConfig['experiments']): this;
83
+ amd(value: WebpackConfig['amd']): this;
84
+ bail(value: WebpackConfig['bail']): this;
85
+ cache(value: WebpackConfig['cache']): this;
86
+ dependencies(value: WebpackConfig['dependencies']): this;
87
+ ignoreWarnings(value: WebpackConfig['ignoreWarnings']): this;
88
+ loader(value: WebpackConfig['loader']): this;
89
+ parallelism(value: WebpackConfig['parallelism']): this;
90
+ profile(value: WebpackConfig['profile']): this;
91
+ recordsPath(value: WebpackConfig['recordsPath']): this;
92
+ recordsInputPath(value: WebpackConfig['recordsInputPath']): this;
93
+ recordsOutputPath(value: WebpackConfig['recordsOutputPath']): this;
94
+ name(value: WebpackConfig['name']): this;
95
+ infrastructureLogging(value: WebpackConfig['infrastructureLogging']): this;
96
+ snapshot(value: WebpackConfig['snapshot']): this;
79
97
 
80
98
  entry(name: string): Config.EntryPoint;
81
- plugin(name: string): Config.Plugin<this, webpack.Plugin>;
99
+ plugin(name: string): Config.Plugin<this, WebpackPluginInstance>;
82
100
 
83
- toConfig(): webpack.Configuration;
101
+ toConfig(): Configuration;
84
102
  }
85
103
 
86
104
  declare namespace Config {
87
105
  class Chained<Parent> extends __Config.Chained<Parent> {}
88
- class TypedChainedMap<Parent, Value> extends __Config.TypedChainedMap<
106
+ class TypedChainedMap<Parent, OptionsType> extends __Config.TypedChainedMap<
89
107
  Parent,
90
- Value
108
+ OptionsType
91
109
  > {}
92
110
  class ChainedMap<Parent> extends __Config.TypedChainedMap<Parent, any> {}
93
111
  class TypedChainedSet<Parent, Value> extends __Config.TypedChainedSet<
@@ -98,21 +116,29 @@ declare namespace Config {
98
116
 
99
117
  class Plugins<
100
118
  Parent,
101
- PluginType extends Tapable.Plugin = webpack.Plugin
102
- > extends TypedChainedMap<Parent, Plugin<Parent, PluginType>> {}
119
+ PluginType extends WebpackPluginInstance,
120
+ > extends TypedChainedMap<
121
+ Parent,
122
+ { [key: string]: Plugin<Parent, PluginType> }
123
+ > {}
103
124
 
104
- class Plugin<Parent, PluginType extends Tapable.Plugin = webpack.Plugin>
125
+ class Plugin<Parent, PluginType extends WebpackPluginInstance | ResolvePlugin>
105
126
  extends ChainedMap<Parent>
106
- implements Orderable {
127
+ implements Orderable
128
+ {
107
129
  init<P extends PluginType | PluginClass<PluginType>>(
108
130
  value: (
109
131
  plugin: P,
110
- args: P extends PluginClass ? ConstructorParameters<P> : any[],
132
+ args: P extends PluginClass<PluginType>
133
+ ? ConstructorParameters<P>
134
+ : any[],
111
135
  ) => PluginType,
112
136
  ): this;
113
137
  use<P extends string | PluginType | PluginClass<PluginType>>(
114
138
  plugin: P,
115
- args?: P extends PluginClass ? ConstructorParameters<P> : any[],
139
+ args?: P extends PluginClass<PluginType>
140
+ ? ConstructorParameters<P>
141
+ : any[],
116
142
  ): this;
117
143
  tap<P extends PluginClass<PluginType>>(
118
144
  f: (args: ConstructorParameters<P>) => ConstructorParameters<P>,
@@ -123,61 +149,119 @@ declare namespace Config {
123
149
  after(name: string): this;
124
150
  }
125
151
 
152
+ type WebpackEntry = NonNullable<Configuration['entry']>;
153
+
154
+ type WepackEntryObject = Exclude<
155
+ WebpackEntry,
156
+ string | string[] | Function
157
+ >[string];
158
+
159
+ class EntryPoint extends TypedChainedSet<Config, WepackEntryObject> {}
160
+
161
+ type WebpackModule = Required<NonNullable<Configuration['module']>>;
162
+
126
163
  class Module extends ChainedMap<Config> {
127
- rules: TypedChainedMap<this, Rule>;
164
+ rules: TypedChainedMap<this, { [key: string]: Rule }>;
165
+ generator: ChainedMap<this>;
166
+ parser: ChainedMap<this>;
128
167
  rule(name: string): Rule;
129
- noParse(
130
- noParse: RegExp | RegExp[] | ((contentPath: string) => boolean),
168
+ noParse(value: WebpackModule['noParse']): this;
169
+ unsafeCache(value: WebpackModule['unsafeCache']): this;
170
+ wrappedContextCritical(
171
+ value: WebpackModule['wrappedContextCritical'],
172
+ ): this;
173
+ exprContextRegExp(value: WebpackModule['exprContextRegExp']): this;
174
+ wrappedContextRecursive(
175
+ value: WebpackModule['wrappedContextRecursive'],
131
176
  ): this;
132
- strictExportPresence(value: boolean): this;
177
+ strictExportPresence(value: WebpackModule['strictExportPresence']): this;
178
+ wrappedContextRegExp(value: WebpackModule['wrappedContextRegExp']): this;
133
179
  }
134
180
 
181
+ type WebpackOutput = Required<NonNullable<Configuration['output']>>;
182
+
135
183
  class Output extends ChainedMap<Config> {
136
- auxiliaryComment(value: string | { [comment: string]: string }): this;
137
- chunkFilename(value: string): this;
138
- chunkLoadTimeout(value: number): this;
139
- crossOriginLoading(value: boolean | string): this;
140
- filename(value: string): this;
141
- library(value: string): this;
142
- libraryExport(value: string | string[]): this;
143
- libraryTarget(value: string): this;
144
- devtoolFallbackModuleFilenameTemplate(value: any): this;
145
- devtoolLineToLine(value: any): this;
146
- devtoolModuleFilenameTemplate(value: any): this;
147
- devtoolNamespace(value: string): this;
148
- globalObject(value: string): this;
149
- hashFunction(value: string): this;
150
- hashDigest(value: string): this;
151
- hashDigestLength(value: number): this;
152
- hashSalt(value: any): this;
153
- hotUpdateChunkFilename(value: string): this;
154
- hotUpdateFunction(value: any): this;
155
- hotUpdateMainFilename(value: string): this;
156
- jsonpFunction(value: string): this;
157
- path(value: string): this;
158
- pathinfo(value: boolean): this;
159
- publicPath(value: string): this;
160
- sourceMapFilename(value: string): this;
161
- sourcePrefix(value: string): this;
162
- strictModuleExceptionHandling(value: boolean): this;
163
- umdNamedDefine(value: boolean): this;
164
- futureEmitAssets(value: boolean): this;
184
+ auxiliaryComment(value: WebpackOutput['auxiliaryComment']): this;
185
+ charset(value: WebpackOutput['charset']): this;
186
+ chunkFilename(value: WebpackOutput['chunkFilename']): this;
187
+ chunkLoadTimeout(value: WebpackOutput['chunkLoadTimeout']): this;
188
+ chunkLoadingGlobal(value: WebpackOutput['chunkLoadingGlobal']): this;
189
+ chunkLoading(value: WebpackOutput['chunkLoading']): this;
190
+ chunkFormat(value: WebpackOutput['chunkFormat']): this;
191
+ enabledChunkLoadingTypes(
192
+ value: WebpackOutput['enabledChunkLoadingTypes'],
193
+ ): this;
194
+ crossOriginLoading(value: WebpackOutput['crossOriginLoading']): this;
195
+ devtoolFallbackModuleFilenameTemplate(
196
+ value: WebpackOutput['devtoolFallbackModuleFilenameTemplate'],
197
+ ): this;
198
+ devtoolModuleFilenameTemplate(
199
+ value: WebpackOutput['devtoolModuleFilenameTemplate'],
200
+ ): this;
201
+ devtoolNamespace(value: WebpackOutput['devtoolNamespace']): this;
202
+ filename(value: WebpackOutput['filename']): this;
203
+ assetModuleFilenamet(value: WebpackOutput['assetModuleFilename']): this;
204
+ globalObject(value: WebpackOutput['globalObject']): this;
205
+ uniqueName(value: WebpackOutput['uniqueName']): this;
206
+ hashDigest(value: WebpackOutput['hashDigest']): this;
207
+ hashDigestLength(value: WebpackOutput['hashDigestLength']): this;
208
+ hashFunction(value: WebpackOutput['hashFunction']): this;
209
+ hashSalt(value: WebpackOutput['hashSalt']): this;
210
+ hotUpdateChunkFilename(
211
+ value: WebpackOutput['hotUpdateChunkFilename'],
212
+ ): this;
213
+ hotUpdateGlobal(value: WebpackOutput['hotUpdateGlobal']): this;
214
+ hotUpdateMainFilename(value: WebpackOutput['hotUpdateMainFilename']): this;
215
+ library(value: WebpackOutput['library']): this;
216
+ libraryExport(value: WebpackOutput['libraryExport']): this;
217
+ libraryTarget(value: WebpackOutput['libraryTarget']): this;
218
+ importFunctionName(value: WebpackOutput['importFunctionName']): this;
219
+ path(value: WebpackOutput['path']): this;
220
+ pathinfo(value: WebpackOutput['pathinfo']): this;
221
+ publicPath(value: WebpackOutput['publicPath']): this;
222
+ scriptType(value: WebpackOutput['scriptType']): this;
223
+ sourceMapFilename(value: WebpackOutput['sourceMapFilename']): this;
224
+ sourcePrefix(value: WebpackOutput['sourcePrefix']): this;
225
+ strictModuleErrorHandling(
226
+ value: WebpackOutput['strictModuleErrorHandling'],
227
+ ): this;
228
+ strictModuleExceptionHandling(
229
+ value: WebpackOutput['strictModuleExceptionHandling'],
230
+ ): this;
231
+ umdNamedDefine(value: WebpackOutput['umdNamedDefine']): this;
232
+ workerChunkLoading(value: WebpackOutput['workerChunkLoading']): this;
233
+ enabledLibraryTypes(value: WebpackOutput['enabledLibraryTypes']): this;
234
+ environment(value: WebpackOutput['environment']): this;
235
+ compareBeforeEmit(value: WebpackOutput['compareBeforeEmit']): this;
236
+ wasmLoading(value: WebpackOutput['wasmLoading']): this;
237
+ enabledWasmLoadingTypes(
238
+ value: WebpackOutput['enabledWasmLoadingTypes'],
239
+ ): this;
240
+ iife(value: WebpackOutput['iife']): this;
241
+ module(value: WebpackOutput['module']): this;
242
+ clean(value: WebpackOutput['clean']): this;
165
243
  }
166
244
 
245
+ // await for @types/webpack-dev-server update do v4 to remove all any
167
246
  class DevServer extends ChainedMap<Config> {
168
247
  allowedHosts: TypedChainedSet<this, string>;
169
-
170
- after(
171
- value: (app: any, server: any, compiler: webpack.Compiler) => void,
172
- ): this;
173
- before(
174
- value: (app: any, server: any, compiler: webpack.Compiler) => void,
175
- ): this;
248
+ after(value: (app: any, server: any, compiler: Compiler) => void): this;
249
+ before(value: (app: any, server: any, compiler: Compiler) => void): this;
176
250
  bonjour(value: boolean): this;
177
- clientLogLevel(value: 'none' | 'error' | 'warning' | 'info'): this;
178
- color(value: boolean): this;
251
+ clientLogLevel(
252
+ value:
253
+ | 'silent'
254
+ | 'trace'
255
+ | 'debug'
256
+ | 'info'
257
+ | 'warn'
258
+ | 'error'
259
+ | 'none'
260
+ | 'warning',
261
+ ): this;
179
262
  compress(value: boolean): this;
180
263
  contentBase(value: boolean | string | string[]): this;
264
+ contentBasePublicPath(value: string): this;
181
265
  disableHostCheck(value: boolean): this;
182
266
  filename(value: string): this;
183
267
  headers(value: { [header: string]: string }): this;
@@ -188,11 +272,14 @@ declare namespace Config {
188
272
  http2(value: boolean): this;
189
273
  https(value: boolean | https.ServerOptions): this;
190
274
  index(value: string): this;
191
- info(value: boolean): this;
275
+ injectClient(value: boolean | ((compiler: Compiler) => boolean)): this;
276
+ injectHot(value: boolean | ((compiler: Compiler) => boolean)): this;
192
277
  inline(value: boolean): this;
193
278
  lazy(value: boolean): this;
279
+ liveReload(value: boolean): this;
194
280
  mimeTypes(value: Object): this;
195
281
  noInfo(value: boolean): this;
282
+ onListening(value: (server: any) => void): this;
196
283
  open(value: boolean): this;
197
284
  openPage(value: string | string[]): this;
198
285
  overlay(value: boolean | { warnings?: boolean; errors?: boolean }): this;
@@ -204,75 +291,129 @@ declare namespace Config {
204
291
  public(value: string): this;
205
292
  publicPath(publicPath: string): this;
206
293
  quiet(value: boolean): this;
294
+ serveIndex(value: boolean): this;
207
295
  setup(value: (expressApp: any) => void): this;
208
296
  socket(value: string): this;
209
297
  sockHost(value: string): this;
210
298
  sockPath(value: string): this;
211
299
  sockPort(value: number): this;
212
300
  staticOptions(value: any): this;
213
- stats(value: webpack.Options.Stats): this;
301
+ stats(value: Configuration['stats']): this;
214
302
  stdin(value: boolean): this;
303
+ transportMode(
304
+ value:
305
+ | 'sockjs'
306
+ | 'ws'
307
+ | {
308
+ server: 'ws';
309
+ client: object;
310
+ }
311
+ | {
312
+ client: 'sockjs';
313
+ server: object;
314
+ }
315
+ | {
316
+ client: object;
317
+ server: object;
318
+ },
319
+ ): this;
215
320
  useLocalIp(value: boolean): this;
216
321
  watchContentBase(value: boolean): this;
217
- watchOptions(value: any): this;
322
+ watchOptions(value: Configuration['watchOptions']): this;
218
323
  writeToDisk(value: boolean): this;
219
324
  }
220
325
 
326
+ type WebpackPerformance = Exclude<
327
+ Required<NonNullable<Configuration['performance']>>,
328
+ false
329
+ >;
221
330
  class Performance extends ChainedMap<Config> {
222
- hints(value: boolean | 'error' | 'warning'): this;
223
- maxEntrypointSize(value: number): this;
224
- maxAssetSize(value: number): this;
225
- assetFilter(value: (assetFilename: string) => boolean): this;
331
+ hints(value: WebpackPerformance['hints']): this;
332
+ maxEntrypointSize(value: WebpackPerformance['maxEntrypointSize']): this;
333
+ maxAssetSize(value: WebpackPerformance['maxAssetSize']): this;
334
+ assetFilter(value: WebpackPerformance['assetFilter']): this;
226
335
  }
227
336
 
228
- class EntryPoint extends TypedChainedSet<Config, string> {}
337
+ type WebpackResolve = Required<NonNullable<Configuration['resolve']>>;
338
+ type ResolvePlugin = Exclude<
339
+ NonNullable<ResolveOptions['plugins']>[number],
340
+ '...'
341
+ >;
229
342
 
230
343
  class Resolve<T = Config> extends ChainedMap<T> {
231
- alias: TypedChainedMap<this, string>;
232
- aliasFields: TypedChainedSet<this, string>;
233
- descriptionFiles: TypedChainedSet<this, string>;
234
- extensions: TypedChainedSet<this, string>;
235
- mainFields: TypedChainedSet<this, string>;
236
- mainFiles: TypedChainedSet<this, string>;
237
- modules: TypedChainedSet<this, string>;
238
- plugins: TypedChainedMap<this, Plugin<this, webpack.ResolvePlugin>>;
239
-
240
- enforceExtension(value: boolean): this;
241
- enforceModuleExtension(value: boolean): this;
242
- unsafeCache(value: boolean | RegExp | RegExp[]): this;
243
- symlinks(value: boolean): this;
244
- cachePredicate(
245
- value: (data: { path: string; request: string }) => boolean,
246
- ): this;
247
- cacheWithContext(value: boolean): this;
344
+ alias: TypedChainedMap<this, { [key: string]: string | false | string[] }>;
345
+ aliasFields: TypedChainedSet<this, WebpackResolve['aliasFields'][number]>;
346
+ descriptionFiles: TypedChainedSet<
347
+ this,
348
+ WebpackResolve['descriptionFiles'][number]
349
+ >;
350
+ extensions: TypedChainedSet<this, WebpackResolve['extensions'][number]>;
351
+ mainFields: TypedChainedSet<this, WebpackResolve['mainFields'][number]>;
352
+ mainFiles: TypedChainedSet<this, WebpackResolve['mainFiles'][number]>;
353
+ exportsFields: TypedChainedSet<
354
+ this,
355
+ WebpackResolve['exportsFields'][number]
356
+ >;
357
+ importsFields: TypedChainedSet<
358
+ this,
359
+ WebpackResolve['importsFields'][number]
360
+ >;
361
+ restrictions: TypedChainedSet<this, WebpackResolve['restrictions'][number]>;
362
+ roots: TypedChainedSet<this, WebpackResolve['roots'][number]>;
363
+ modules: TypedChainedSet<this, WebpackResolve['modules'][number]>;
364
+ plugins: TypedChainedMap<
365
+ this,
366
+ { [key: string]: Plugin<Resolve, ResolvePlugin> }
367
+ >;
368
+ fallback: TypedChainedMap<
369
+ this,
370
+ { [key: string]: string | false | string[] }
371
+ >;
372
+ byDependency: TypedChainedMap<this, WebpackResolve['byDependency']>;
373
+
374
+ cachePredicate(value: WebpackResolve['cachePredicate']): this;
375
+ cacheWithContext(value: WebpackResolve['cacheWithContext']): this;
376
+ enforceExtension(value: WebpackResolve['enforceExtension']): this;
377
+ symlinks(value: WebpackResolve['symlinks']): this;
378
+ unsafeCache(value: WebpackResolve['unsafeCache']): this;
379
+ preferRelative(value: WebpackResolve['preferRelative']): this;
380
+ preferAbsolute(value: WebpackResolve['preferAbsolute']): this;
381
+
382
+ plugin(name: string): Plugin<this, ResolvePlugin>;
383
+ }
248
384
 
249
- plugin(name: string): Plugin<this, webpack.ResolvePlugin>;
385
+ class RuleResolve<T = Config> extends Resolve<T> {
386
+ fullySpecified(value: boolean): this;
250
387
  }
251
388
 
252
389
  class ResolveLoader extends Resolve {
390
+ modules: ChainedSet<this>;
253
391
  moduleExtensions: ChainedSet<this>;
254
392
  packageMains: ChainedSet<this>;
255
393
  }
256
394
 
395
+ type WebpackRuleSet = Required<RuleSetRule>;
396
+
257
397
  class Rule<T = Module> extends ChainedMap<T> implements Orderable {
258
- rules: TypedChainedMap<this, Rule<Rule>>;
259
- oneOfs: TypedChainedMap<this, Rule<Rule>>;
260
- uses: TypedChainedMap<this, Use>;
261
- include: TypedChainedSet<this, webpack.Condition>;
262
- exclude: TypedChainedSet<this, webpack.Condition>;
263
- resolve: Resolve<Rule<T>>;
264
-
265
- parser(value: { [optName: string]: any }): this;
266
- test(value: webpack.Condition | webpack.Condition[]): this;
267
- type(
268
- value:
269
- | 'javascript/auto'
270
- | 'javascript/dynamic'
271
- | 'javascript/esm'
272
- | 'json'
273
- | 'webassembly/experimental',
274
- ): this;
275
- enforce(value: 'pre' | 'post'): this;
398
+ uses: TypedChainedMap<this, { [key: string]: Use }>;
399
+ include: TypedChainedSet<this, WebpackRuleSet['include']>;
400
+ exclude: TypedChainedSet<this, WebpackRuleSet['exclude']>;
401
+ rules: TypedChainedMap<this, { [key: string]: Rule<Rule> }>;
402
+ oneOfs: TypedChainedMap<this, { [key: string]: Rule<Rule> }>;
403
+ resolve: RuleResolve<Rule<T>>;
404
+
405
+ enforce(value: WebpackRuleSet['enforce']): this;
406
+ issuer(value: WebpackRuleSet['issuer']): this;
407
+ issuerLayer(value: WebpackRuleSet['issuerLayer']): this;
408
+ layer(value: WebpackRuleSet['layer']): this;
409
+ mimetype(value: WebpackRuleSet['mimetype']): this;
410
+ parser(value: WebpackRuleSet['parser']): this;
411
+ generator(value: WebpackRuleSet['generator']): this;
412
+ resource(value: WebpackRuleSet['resource']): this;
413
+ resourceQuery(value: WebpackRuleSet['resourceQuery']): this;
414
+ sideEffects(value: WebpackRuleSet['sideEffects']): this;
415
+ test(value: WebpackRuleSet['test']): this;
416
+ type(value: WebpackRuleSet['type']): this;
276
417
 
277
418
  use(name: string): Use<this>;
278
419
  rule(name: string): Rule<Rule>;
@@ -281,28 +422,40 @@ declare namespace Config {
281
422
  post(): this;
282
423
  before(name: string): this;
283
424
  after(name: string): this;
284
- resourceQuery(value: webpack.Condition | webpack.Condition[]): this;
285
425
  }
286
426
 
427
+ type WebpackOptimization = Required<
428
+ NonNullable<Configuration['optimization']>
429
+ >;
430
+ type SplitChunksObject = Exclude<WebpackOptimization['splitChunks'], false>;
287
431
  class Optimization extends ChainedMap<Config> {
288
- concatenateModules(value: boolean): this;
289
- flagIncludedChunks(value: boolean): this;
290
- mergeDuplicateChunks(value: boolean): this;
291
- minimize(value: boolean): this;
292
- minimizer(name: string): Config.Plugin<this, webpack.Plugin>;
293
- namedChunks(value: boolean): this;
294
- namedModules(value: boolean): this;
295
- nodeEnv(value: boolean | string): this;
296
- noEmitOnErrors(value: boolean): this;
297
- occurrenceOrder(value: boolean): this;
298
- portableRecords(value: boolean): this;
299
- providedExports(value: boolean): this;
300
- removeAvailableModules(value: boolean): this;
301
- removeEmptyChunks(value: boolean): this;
302
- runtimeChunk(value: boolean | 'single' | 'multiple' | RuntimeChunk): this;
303
- sideEffects(value: boolean): this;
304
- splitChunks(value: SplitChunksOptions): this;
305
- usedExports(value: boolean): this;
432
+ minimizer(name: string): Config.Plugin<this, WebpackPluginInstance>;
433
+ splitChunks: TypedChainedMap<this, SplitChunksObject> &
434
+ ((value: SplitChunksObject | false) => this);
435
+
436
+ minimize(value: WebpackOptimization['minimize']): this;
437
+ runtimeChunk(value: WebpackOptimization['runtimeChunk']): this;
438
+ emitOnErrors(value: WebpackOptimization['emitOnErrors']): this;
439
+ moduleIds(value: WebpackOptimization['moduleIds']): this;
440
+ chunkIds(value: WebpackOptimization['chunkIds']): this;
441
+ nodeEnv(value: WebpackOptimization['nodeEnv']): this;
442
+ mangleWasmImports(value: WebpackOptimization['mangleWasmImports']): this;
443
+ removeAvailableModules(
444
+ value: WebpackOptimization['removeAvailableModules'],
445
+ ): this;
446
+ removeEmptyChunks(value: WebpackOptimization['removeEmptyChunks']): this;
447
+ mergeDuplicateChunks(
448
+ value: WebpackOptimization['mergeDuplicateChunks'],
449
+ ): this;
450
+ flagIncludedChunks(value: WebpackOptimization['flagIncludedChunks']): this;
451
+ providedExports(value: WebpackOptimization['providedExports']): this;
452
+ usedExports(value: WebpackOptimization['usedExports']): this;
453
+ concatenateModules(value: WebpackOptimization['concatenateModules']): this;
454
+ sideEffects(value: WebpackOptimization['sideEffects']): this;
455
+ portableRecords(value: WebpackOptimization['portableRecords']): this;
456
+ mangleExports(value: WebpackOptimization['mangleExports']): this;
457
+ innerGraph(value: WebpackOptimization['innerGraph']): this;
458
+ realContentHash(value: WebpackOptimization['realContentHash']): this;
306
459
  }
307
460
 
308
461
  interface RuntimeChunk {
@@ -332,52 +485,110 @@ declare namespace Config {
332
485
 
333
486
  type DevTool =
334
487
  | 'eval'
335
- | 'inline-source-map'
336
- | 'cheap-eval-source-map'
488
+ | 'eval-cheap-source-map'
489
+ | 'eval-cheap-module-source-map'
490
+ | 'eval-source-map'
337
491
  | 'cheap-source-map'
338
- | 'cheap-module-eval-source-map'
339
492
  | 'cheap-module-source-map'
340
- | 'eval-source-map'
341
493
  | 'source-map'
494
+ | 'inline-cheap-source-map'
495
+ | 'inline-cheap-module-source-map'
496
+ | 'inline-source-map'
497
+ | 'eval-nosources-cheap-source-map'
498
+ | 'eval-nosources-cheap-module-source-map'
499
+ | 'eval-nosources-source-map'
500
+ | 'inline-nosources-cheap-source-map'
501
+ | 'inline-nosources-cheap-module-source-map'
502
+ | 'inline-nosources-source-map'
503
+ | 'nosources-cheap-source-map'
504
+ | 'nosources-cheap-module-source-map'
342
505
  | 'nosources-source-map'
506
+ | 'hidden-nosources-cheap-source-map'
507
+ | 'hidden-nosources-cheap-module-source-map'
508
+ | 'hidden-nosources-source-map'
509
+ | 'hidden-cheap-source-map'
510
+ | 'hidden-cheap-module-source-map'
343
511
  | 'hidden-source-map'
344
- | 'nosources-source-map'
345
512
  | '@eval'
346
- | '@inline-source-map'
347
- | '@cheap-eval-source-map'
513
+ | '@eval-cheap-source-map'
514
+ | '@eval-cheap-module-source-map'
515
+ | '@eval-source-map'
348
516
  | '@cheap-source-map'
349
- | '@cheap-module-eval-source-map'
350
517
  | '@cheap-module-source-map'
351
- | '@eval-source-map'
352
518
  | '@source-map'
519
+ | '@inline-cheap-source-map'
520
+ | '@inline-cheap-module-source-map'
521
+ | '@inline-source-map'
522
+ | '@eval-nosources-cheap-source-map'
523
+ | '@eval-nosources-cheap-module-source-map'
524
+ | '@eval-nosources-source-map'
525
+ | '@inline-nosources-cheap-source-map'
526
+ | '@inline-nosources-cheap-module-source-map'
527
+ | '@inline-nosources-source-map'
528
+ | '@nosources-cheap-source-map'
529
+ | '@nosources-cheap-module-source-map'
353
530
  | '@nosources-source-map'
531
+ | '@hidden-nosources-cheap-source-map'
532
+ | '@hidden-nosources-cheap-module-source-map'
533
+ | '@hidden-nosources-source-map'
534
+ | '@hidden-cheap-source-map'
535
+ | '@hidden-cheap-module-source-map'
354
536
  | '@hidden-source-map'
355
- | '@nosources-source-map'
356
537
  | '#eval'
357
- | '#inline-source-map'
358
- | '#cheap-eval-source-map'
538
+ | '#eval-cheap-source-map'
539
+ | '#eval-cheap-module-source-map'
540
+ | '#eval-source-map'
359
541
  | '#cheap-source-map'
360
- | '#cheap-module-eval-source-map'
361
542
  | '#cheap-module-source-map'
362
- | '#eval-source-map'
363
543
  | '#source-map'
544
+ | '#inline-cheap-source-map'
545
+ | '#inline-cheap-module-source-map'
546
+ | '#inline-source-map'
547
+ | '#eval-nosources-cheap-source-map'
548
+ | '#eval-nosources-cheap-module-source-map'
549
+ | '#eval-nosources-source-map'
550
+ | '#inline-nosources-cheap-source-map'
551
+ | '#inline-nosources-cheap-module-source-map'
552
+ | '#inline-nosources-source-map'
553
+ | '#nosources-cheap-source-map'
554
+ | '#nosources-cheap-module-source-map'
364
555
  | '#nosources-source-map'
556
+ | '#hidden-nosources-cheap-source-map'
557
+ | '#hidden-nosources-cheap-module-source-map'
558
+ | '#hidden-nosources-source-map'
559
+ | '#hidden-cheap-source-map'
560
+ | '#hidden-cheap-module-source-map'
365
561
  | '#hidden-source-map'
366
- | '#nosources-source-map'
367
562
  | '#@eval'
368
- | '#@inline-source-map'
369
- | '#@cheap-eval-source-map'
563
+ | '#@eval-cheap-source-map'
564
+ | '#@eval-cheap-module-source-map'
565
+ | '#@eval-source-map'
370
566
  | '#@cheap-source-map'
371
- | '#@cheap-module-eval-source-map'
372
567
  | '#@cheap-module-source-map'
373
- | '#@eval-source-map'
374
568
  | '#@source-map'
569
+ | '#@inline-cheap-source-map'
570
+ | '#@inline-cheap-module-source-map'
571
+ | '#@inline-source-map'
572
+ | '#@eval-nosources-cheap-source-map'
573
+ | '#@eval-nosources-cheap-module-source-map'
574
+ | '#@eval-nosources-source-map'
575
+ | '#@inline-nosources-cheap-source-map'
576
+ | '#@inline-nosources-cheap-module-source-map'
577
+ | '#@inline-nosources-source-map'
578
+ | '#@nosources-cheap-source-map'
579
+ | '#@nosources-cheap-module-source-map'
375
580
  | '#@nosources-source-map'
581
+ | '#@hidden-nosources-cheap-source-map'
582
+ | '#@hidden-nosources-cheap-module-source-map'
583
+ | '#@hidden-nosources-source-map'
584
+ | '#@hidden-cheap-source-map'
585
+ | '#@hidden-cheap-module-source-map'
376
586
  | '#@hidden-source-map'
377
- | '#@nosources-source-map'
378
587
  | boolean;
379
588
 
380
- interface PluginClass<PluginType extends Tapable.Plugin = webpack.Plugin> {
589
+ interface PluginClass<
590
+ PluginType extends WebpackPluginInstance | ResolvePlugin,
591
+ > {
381
592
  new (...opts: any[]): PluginType;
382
593
  }
383
594