/
webpack.d.ts
2393 lines (2144 loc) · 74.7 KB
/
webpack.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* eslint-disable import/no-extraneous-dependencies, @typescript-eslint/no-unused-vars , no-shadow */
// Type definitions for webpack 4.39
// Project: https://github.com/webpack/webpack
// Definitions by: Qubo <https://github.com/tkqubo>
// Benjamin Lim <https://github.com/bumbleblym>
// Boris Cherny <https://github.com/bcherny>
// Tommy Troy Lin <https://github.com/tommytroylin>
// Mohsen Azimi <https://github.com/mohsen1>
// Jonathan Creamer <https://github.com/jcreamer898>
// Alan Agius <https://github.com/alan-agius4>
// Spencer Elliott <https://github.com/elliottsj>
// Jason Cheatham <https://github.com/jason0x43>
// Dennis George <https://github.com/dennispg>
// Christophe Hurpeau <https://github.com/christophehurpeau>
// ZSkycat <https://github.com/ZSkycat>
// John Reilly <https://github.com/johnnyreilly>
// Ryan Waskiewicz <https://github.com/rwaskiewicz>
// Kyle Uehlein <https://github.com/kuehlein>
// Grgur Grisogono <https://github.com/grgur>
// Rubens Pinheiro Gonçalves Cavalcante <https://github.com/rubenspgcavalcante>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="node" />
declare module 'mini-css-extract-plugin'
declare module 'next/dist/compiled/loader-utils'
declare module 'next/dist/compiled/webpack/webpack' {
import webpackSources from 'webpack-sources'
import webpack, { loader } from 'webpack'
export let isWebpack5: boolean
export function init(useWebpack5: boolean): void
export let BasicEvaluatedExpression: any
export let GraphHelpers: any
export function onWebpackInit(cb: () => void): void
export let sources: typeof webpackSources
export { webpack, loader }
}
declare module 'webpack' {
import { RawSourceMap } from 'source-map'
import { ConcatSource } from 'webpack-sources'
export = webpack
function webpack(
options: webpack.Configuration,
handler: webpack.Compiler.Handler
): webpack.Compiler.Watching | webpack.Compiler
function webpack(options?: webpack.Configuration): webpack.Compiler
function webpack(
options: webpack.Configuration[],
handler: webpack.MultiCompiler.Handler
): webpack.MultiWatching | webpack.MultiCompiler
function webpack(options: webpack.Configuration[]): webpack.MultiCompiler
function webpack(
options: webpack.Configuration | webpack.Configuration[]
): webpack.Compiler | webpack.MultiCompiler
namespace webpack {
/** Webpack package version. */
const version: string | undefined
interface Configuration {
/** Enable production optimizations or development hints. */
mode?: 'development' | 'production' | 'none'
/** Name of the configuration. Used when loading multiple configurations. */
name?: string
/**
* The base directory (absolute path!) for resolving the `entry` option.
* If `output.pathinfo` is set, the included pathinfo is shortened to this directory.
*/
context?: string
entry?: string | string[] | Entry | EntryFunc
/** Choose a style of source mapping to enhance the debugging process. These values can affect build and rebuild speed dramatically. */
devtool?: Options.Devtool
/** Options affecting the output. */
output?: Output
/** Options affecting the normal modules (NormalModuleFactory) */
module?: Module
/** Options affecting the resolving of modules. */
resolve?: Resolve
/** Like resolve but for loaders. */
resolveLoader?: ResolveLoader
/**
* Specify dependencies that shouldn’t be resolved by webpack, but should become dependencies of the resulting bundle.
* The kind of the dependency depends on output.libraryTarget.
*/
externals?: ExternalsElement | ExternalsElement[]
/**
* - "web" Compile for usage in a browser-like environment (default).
* - "webworker" Compile as WebWorker.
* - "node" Compile for usage in a node.js-like environment (use require to load chunks).
* - "async-node" Compile for usage in a node.js-like environment (use fs and vm to load chunks async).
* - "node-webkit" Compile for usage in webkit, uses jsonp chunk loading but also supports builtin node.js modules plus require(“nw.gui”) (experimental)
* - "atom" Compile for usage in electron (formerly known as atom-shell), supports require for modules necessary to run Electron.
* - "electron-renderer" Compile for Electron for renderer process, providing a target using JsonpTemplatePlugin, FunctionModulePlugin for browser
* environments and NodeTargetPlugin and ExternalsPlugin for CommonJS and Electron built-in modules.
* - "electron-main" Compile for Electron for main process.
* - "atom" Alias for electron-main.
* - "electron" Alias for electron-main.
*/
target?:
| 'web'
| 'webworker'
| 'node'
| 'async-node'
| 'node-webkit'
| 'atom'
| 'electron'
| 'electron-renderer'
| 'electron-main'
| ((compiler?: any) => void)
/** Report the first error as a hard error instead of tolerating it. */
bail?: boolean
/** Capture timing information for each module. */
profile?: boolean
/** Cache generated modules and chunks to improve performance for multiple incremental builds. */
cache?: boolean | object
/** Enter watch mode, which rebuilds on file change. */
watch?: boolean
watchOptions?: Options.WatchOptions
/** Switch loaders to debug mode. */
debug?: boolean
/** Include polyfills or mocks for various node stuff */
node?: Node | false
/** Set the value of require.amd and define.amd. */
amd?: { [moduleName: string]: boolean }
/** Used for recordsInputPath and recordsOutputPath */
recordsPath?: string
/** Load compiler state from a json file. */
recordsInputPath?: string
/** Store compiler state to a json file. */
recordsOutputPath?: string
/** Add additional plugins to the compiler. */
plugins?: Plugin[]
/** Stats options for logging */
stats?: Options.Stats
/** Performance options */
performance?: Options.Performance | false
/** Limit the number of parallel processed modules. Can be used to fine tune performance or to get more reliable profiling results */
parallelism?: number
/** Optimization options */
optimization?: Options.Optimization
}
interface Entry {
[name: string]: string | string[]
}
type EntryFunc = () =>
| string
| string[]
| Entry
| Promise<string | string[] | Entry>
interface DevtoolModuleFilenameTemplateInfo {
identifier: string
shortIdentifier: string
resource: any
resourcePath: string
absoluteResourcePath: string
allLoaders: any[]
query: string
moduleId: string
hash: string
}
interface Output {
/** When used in tandem with output.library and output.libraryTarget, this option allows users to insert comments within the export wrapper. */
auxiliaryComment?: string | AuxiliaryCommentObject
/** The filename of the entry chunk as relative path inside the output.path directory. */
filename?: string | Function
/** The filename of non-entry chunks as relative path inside the output.path directory. */
chunkFilename?: string
/** Number of milliseconds before chunk request expires, defaults to 120,000. */
chunkLoadTimeout?: number
/** This option enables cross-origin loading of chunks. */
crossOriginLoading?: string | boolean
/** The JSONP function used by webpack for asnyc loading of chunks. */
jsonpFunction?: string
/** Allows customization of the script type webpack injects script tags into the DOM to download async chunks. */
jsonpScriptType?: 'text/javascript' | 'module'
/** Filename template string of function for the sources array in a generated SourceMap. */
devtoolModuleFilenameTemplate?:
| string
| ((info: DevtoolModuleFilenameTemplateInfo) => string)
/** Similar to output.devtoolModuleFilenameTemplate, but used in the case of duplicate module identifiers. */
devtoolFallbackModuleFilenameTemplate?:
| string
| ((info: DevtoolModuleFilenameTemplateInfo) => string)
/**
* Enable line to line mapped mode for all/specified modules.
* Line to line mapped mode uses a simple SourceMap where each line of the generated source is mapped to the same line of the original source.
* It’s a performance optimization. Only use it if your performance need to be better and you are sure that input lines match which generated lines.
* true enables it for all modules (not recommended)
*/
devtoolLineToLine?: boolean
/** This option determines the modules namespace used with the output.devtoolModuleFilenameTemplate. */
devtoolNamespace?: string
/** The filename of the Hot Update Chunks. They are inside the output.path directory. */
hotUpdateChunkFilename?: string
/** The JSONP function used by webpack for async loading of hot update chunks. */
hotUpdateFunction?: string
/** The filename of the Hot Update Main File. It is inside the output.path directory. */
hotUpdateMainFilename?: string
/** If set, export the bundle as library. output.library is the name. */
library?: string | string[] | { [key: string]: string }
/**
* Which format to export the library:
* - "var" - Export by setting a variable: var Library = xxx (default)
* - "this" - Export by setting a property of this: this["Library"] = xxx
* - "commonjs" - Export by setting a property of exports: exports["Library"] = xxx
* - "commonjs2" - Export by setting module.exports: module.exports = xxx
* - "amd" - Export to AMD (optionally named)
* - "umd" - Export to AMD, CommonJS2 or as property in root
* - "window" - Assign to window
* - "assign" - Assign to a global variable
* - "jsonp" - Generate Webpack JSONP module
*/
libraryTarget?: LibraryTarget
/** Configure which module or modules will be exposed via the `libraryTarget` */
libraryExport?: string | string[]
/** If output.libraryTarget is set to umd and output.library is set, setting this to true will name the AMD module. */
umdNamedDefine?: boolean
/** The output directory as absolute path. */
path?: string
/** Include comments with information about the modules. */
pathinfo?: boolean
/** The output.path from the view of the Javascript / HTML page. */
publicPath?: string
/** The filename of the SourceMaps for the JavaScript files. They are inside the output.path directory. */
sourceMapFilename?: string
/** Prefixes every line of the source in the bundle with this string. */
sourcePrefix?: string
/** The encoding to use when generating the hash, defaults to 'hex' */
hashDigest?: 'hex' | 'latin1' | 'base64'
/** The prefix length of the hash digest to use, defaults to 20. */
hashDigestLength?: number
/** Algorithm used for generation the hash (see node.js crypto package) */
hashFunction?: string | ((algorithm: string, options?: any) => any)
/** An optional salt to update the hash via Node.JS' hash.update. */
hashSalt?: string
/** An expression which is used to address the global object/scope in runtime code. */
globalObject?: string
/** Handles exceptions in module loading correctly at a performance cost. */
strictModuleExceptionHandling?: boolean
/**
* Use the future version of asset emitting logic, which allows freeing memory of assets after emitting.
* It could break plugins which assume that assets are still readable after they were emitted.
* @deprecated - will be removed in webpack v5.0.0 and this behavior will become the new default.
*/
futureEmitAssets?: boolean
/** The filename of WebAssembly modules as relative path inside the `output.path` directory. */
webassemblyModuleFilename?: string
}
type LibraryTarget =
| 'var'
| 'assign'
| 'this'
| 'window'
| 'global'
| 'commonjs'
| 'commonjs2'
| 'amd'
| 'umd'
| 'jsonp'
type AuxiliaryCommentObject = { [P in LibraryTarget]: string }
interface Module {
/** A array of applied pre loaders. */
preLoaders?: RuleSetRule[]
/** A array of applied post loaders. */
postLoaders?: RuleSetRule[]
/** A RegExp or an array of RegExps. Don’t parse files matching. */
noParse?: RegExp | RegExp[] | ((content: string) => boolean)
unknownContextRequest?: string
unknownContextRecursive?: boolean
unknownContextRegExp?: RegExp
unknownContextCritical?: boolean
exprContextRequest?: string
exprContextRegExp?: RegExp
exprContextRecursive?: boolean
exprContextCritical?: boolean
wrappedContextRegExp?: RegExp
wrappedContextRecursive?: boolean
wrappedContextCritical?: boolean
strictExportPresence?: boolean
/** An array of rules applied for modules. */
rules: RuleSetRule[]
}
interface Resolve {
/**
* A list of directories to resolve modules from.
*
* Absolute paths will be searched once.
*
* If an entry is relative, will be resolved using node's resolution algorithm
* relative to the requested file.
*
* Defaults to `["node_modules"]`
*/
modules?: string[]
/**
* A list of package description files to search for.
*
* Defaults to `["package.json"]`
*/
descriptionFiles?: string[]
/**
* A list of fields in a package description object to use for finding
* the entry point.
*
* Defaults to `["browser", "module", "main"]` or `["module", "main"]`,
* depending on the value of the `target` `Configuration` value.
*/
mainFields?: string[] | string[][]
/**
* A list of fields in a package description object to try to parse
* in the same format as the `alias` resolve option.
*
* Defaults to `["browser"]` or `[]`, depending on the value of the
* `target` `Configuration` value.
*
* @see alias
*/
aliasFields?: string[] | string[][]
/**
* A list of file names to search for when requiring directories that
* don't contain a package description file.
*
* Defaults to `["index"]`.
*/
mainFiles?: string[]
/**
* A list of file extensions to try when requesting files.
*
* An empty string is considered invalid.
*/
extensions?: string[]
/**
* If true, requires that all requested paths must use an extension
* from `extensions`.
*/
enforceExtension?: boolean
/**
* Replace the given module requests with other modules or paths.
*
* @see aliasFields
*/
alias?: { [key: string]: string }
/**
* Whether to use a cache for resolving, or the specific object
* to use for caching. Sharing objects may be useful when running
* multiple webpack compilers.
*
* Defaults to `true`.
*/
unsafeCache?: {} | boolean
/**
* A function used to decide whether to cache the given resolve request.
*
* Defaults to `() => true`.
*/
cachePredicate?(data: { path: string; request: string }): boolean
/**
* A list of additional resolve plugins which should be applied.
*/
plugins?: ResolvePlugin[]
/**
* Whether to resolve symlinks to their symlinked location.
*
* Defaults to `true`
*/
symlinks?: boolean
/**
* If unsafe cache is enabled, includes request.context in the cache key.
* This option is taken into account by the enhanced-resolve module.
* Since webpack 3.1.0 context in resolve caching is ignored when resolve or resolveLoader plugins are provided.
* This addresses a performance regression.
*/
cacheWithContext?: boolean
}
interface ResolveLoader extends Resolve {
/**
* List of strings to append to a loader's name when trying to resolve it.
*/
moduleExtensions?: string[]
enforceModuleExtension?: boolean
}
type ExternalsElement =
| string
| RegExp
| ExternalsObjectElement
| ExternalsFunctionElement
interface ExternalsObjectElement {
[key: string]:
| boolean
| string
| string[]
| Record<string, string | string[]>
}
type ExternalsFunctionElement = (
context: any,
request: any,
callback: (error?: any, result?: any) => void
) => any
interface Node {
console?: boolean | 'mock'
process?: boolean | 'mock'
global?: boolean
__filename?: boolean | 'mock'
__dirname?: boolean | 'mock'
Buffer?: boolean | 'mock'
setImmediate?: boolean | 'mock' | 'empty'
[nodeBuiltin: string]: boolean | 'mock' | 'empty' | undefined
}
interface NewLoader {
loader: string
options?: { [name: string]: any }
}
type Loader = string | NewLoader
interface ParserOptions {
[optName: string]: any
system?: boolean
}
type RuleSetCondition =
| RegExp
| string
| ((path: string) => boolean)
| RuleSetConditions
| {
/**
* Logical AND
*/
and?: RuleSetCondition[]
/**
* Exclude all modules matching any of these conditions
*/
exclude?: RuleSetCondition
/**
* Exclude all modules matching not any of these conditions
*/
include?: RuleSetCondition
/**
* Logical NOT
*/
not?: RuleSetCondition[]
/**
* Logical OR
*/
or?: RuleSetCondition[]
/**
* Exclude all modules matching any of these conditions
*/
test?: RuleSetCondition
}
// A hack around circular type referencing
interface RuleSetConditions extends Array<RuleSetCondition> {}
interface RuleSetRule {
/**
* Enforce this rule as pre or post step
*/
enforce?: 'pre' | 'post'
/**
* Shortcut for resource.exclude
*/
exclude?: RuleSetCondition
/**
* Shortcut for resource.include
*/
include?: RuleSetCondition
/**
* Match the issuer of the module (The module pointing to this module)
*/
issuer?: RuleSetCondition
/**
* Shortcut for use.loader
*/
loader?: RuleSetUse
/**
* Shortcut for use.loader
*/
loaders?: RuleSetUse
/**
* Only execute the first matching rule in this array
*/
oneOf?: RuleSetRule[]
/**
* Shortcut for use.options
*/
options?: RuleSetQuery
/**
* Options for parsing
*/
parser?: { [k: string]: any }
/**
* Options for the resolver
*/
resolve?: Resolve
/**
* Flags a module as with or without side effects
*/
sideEffects?: boolean
/**
* Shortcut for use.query
*/
query?: RuleSetQuery
/**
* Module type to use for the module
*/
type?:
| 'javascript/auto'
| 'javascript/dynamic'
| 'javascript/esm'
| 'json'
| 'webassembly/experimental'
/**
* Match the resource path of the module
*/
resource?: RuleSetCondition
/**
* Match the resource query of the module
*/
resourceQuery?: RuleSetCondition
/**
* Match the child compiler name
*/
compiler?: RuleSetCondition
/**
* Match and execute these rules when this rule is matched
*/
rules?: RuleSetRule[]
/**
* Shortcut for resource.test
*/
test?: RuleSetCondition
/**
* Modifiers applied to the module when rule is matched
*/
use?: RuleSetUse
}
type RuleSetUse =
| RuleSetUseItem
| RuleSetUseItem[]
| ((data: any) => RuleSetUseItem | RuleSetUseItem[])
interface RuleSetLoader {
/**
* Loader name
*/
loader?: string
/**
* Loader options
*/
options?: RuleSetQuery
/**
* Unique loader identifier
*/
ident?: string
/**
* Loader query
*/
query?: RuleSetQuery
}
type RuleSetUseItem =
| string
| RuleSetLoader
| ((data: any) => string | RuleSetLoader)
type RuleSetQuery = string | { [k: string]: any }
/**
* @deprecated Use RuleSetCondition instead
*/
type Condition = RuleSetCondition
/**
* @deprecated Use RuleSetRule instead
*/
type Rule = RuleSetRule
namespace Options {
type Devtool =
| 'eval'
| 'inline-source-map'
| 'cheap-eval-source-map'
| 'cheap-source-map'
| 'cheap-module-eval-source-map'
| 'cheap-module-source-map'
| 'eval-source-map'
| 'source-map'
| 'nosources-source-map'
| 'hidden-source-map'
| 'nosources-source-map'
| 'inline-cheap-source-map'
| 'inline-cheap-module-source-map'
| '@eval'
| '@inline-source-map'
| '@cheap-eval-source-map'
| '@cheap-source-map'
| '@cheap-module-eval-source-map'
| '@cheap-module-source-map'
| '@eval-source-map'
| '@source-map'
| '@nosources-source-map'
| '@hidden-source-map'
| '@nosources-source-map'
| '#eval'
| '#inline-source-map'
| '#cheap-eval-source-map'
| '#cheap-source-map'
| '#cheap-module-eval-source-map'
| '#cheap-module-source-map'
| '#eval-source-map'
| '#source-map'
| '#nosources-source-map'
| '#hidden-source-map'
| '#nosources-source-map'
| '#@eval'
| '#@inline-source-map'
| '#@cheap-eval-source-map'
| '#@cheap-source-map'
| '#@cheap-module-eval-source-map'
| '#@cheap-module-source-map'
| '#@eval-source-map'
| '#@source-map'
| '#@nosources-source-map'
| '#@hidden-source-map'
| '#@nosources-source-map'
| boolean
interface Performance {
/** This property allows webpack to control what files are used to calculate performance hints. */
assetFilter?(assetFilename: string): boolean
/**
* Turns hints on/off. In addition, tells webpack to throw either an error or a warning when hints are
* found. This property is set to "warning" by default.
*/
hints?: 'warning' | 'error' | false
/**
* An asset is any emitted file from webpack. This option controls when webpack emits a performance hint
* based on individual asset size. The default value is 250000 (bytes).
*/
maxAssetSize?: number
/**
* An entrypoint represents all assets that would be utilized during initial load time for a specific entry.
* This option controls when webpack should emit performance hints based on the maximum entrypoint size.
* The default value is 250000 (bytes).
*/
maxEntrypointSize?: number
}
type Stats = Stats.ToStringOptions
type WatchOptions = ICompiler.WatchOptions
interface CacheGroupsOptions {
/** Assign modules to a cache group */
test?: ((...args: any[]) => boolean) | string | RegExp
/** Select chunks for determining cache group content (defaults to \"initial\", \"initial\" and \"all\" requires adding these chunks to the HTML) */
chunks?:
| 'initial'
| 'async'
| 'all'
| ((chunk: compilation.Chunk) => boolean)
/** Ignore minimum size, minimum chunks and maximum requests and always create chunks for this cache group */
enforce?: boolean
/** Priority of this cache group */
priority?: number
/** Minimal size for the created chunk */
minSize?: number
/** Maximum size for the created chunk */
maxSize?: number
/** Minimum number of times a module has to be duplicated until it's considered for splitting */
minChunks?: number
/** Maximum number of requests which are accepted for on-demand loading */
maxAsyncRequests?: number
/** Maximum number of initial chunks which are accepted for an entry point */
maxInitialRequests?: number
/** Try to reuse existing chunk (with name) when it has matching modules */
reuseExistingChunk?: boolean
/** Give chunks created a name (chunks with equal name are merged) */
name?: boolean | string | ((...args: any[]) => any)
filename?: string
}
interface SplitChunksOptions {
/** Select chunks for determining shared modules (defaults to \"async\", \"initial\" and \"all\" requires adding these chunks to the HTML) */
chunks?:
| 'initial'
| 'async'
| 'all'
| ((chunk: compilation.Chunk) => boolean)
/** Minimal size for the created chunk */
minSize?: number
/** Maximum size for the created chunk */
maxSize?: number
/** Minimum number of times a module has to be duplicated until it's considered for splitting */
minChunks?: number
/** Maximum number of requests which are accepted for on-demand loading */
maxAsyncRequests?: number
/** Maximum number of initial chunks which are accepted for an entry point */
maxInitialRequests?: number
/** Give chunks created a name (chunks with equal name are merged) */
name?: boolean | string | ((...args: any[]) => any)
/** Assign modules to a cache group (modules from different cache groups are tried to keep in separate chunks) */
cacheGroups?:
| false
| string
| ((...args: any[]) => any)
| RegExp
| { [key: string]: CacheGroupsOptions | false }
/** Override the default name separator (~) when generating names automatically (name: true) */
automaticNameDelimiter?: string
}
interface RuntimeChunkOptions {
/** The name or name factory for the runtime chunks. */
name?: string | ((...args: any[]) => any)
}
interface Optimization {
/**
* Modules are removed from chunks when they are already available in all parent chunk groups.
* This reduces asset size. Smaller assets also result in faster builds since less code generation has to be performed.
*/
removeAvailableModules?: boolean
/** Empty chunks are removed. This reduces load in filesystem and results in faster builds. */
removeEmptyChunks?: boolean
/** Equal chunks are merged. This results in less code generation and faster builds. */
mergeDuplicateChunks?: boolean
/** Chunks which are subsets of other chunks are determined and flagged in a way that subsets don’t have to be loaded when the bigger chunk has been loaded. */
flagIncludedChunks?: boolean
/** Give more often used ids smaller (shorter) values. */
occurrenceOrder?: boolean
/** Determine exports for each module when possible. This information is used by other optimizations or code generation. I. e. to generate more efficient code for export * from. */
providedExports?: boolean
/**
* Determine used exports for each module. This depends on optimization.providedExports. This information is used by other optimizations or code generation.
* I. e. exports are not generated for unused exports, export names are mangled to single char identifiers when all usages are compatible.
* DCE in minimizers will benefit from this and can remove unused exports.
*/
usedExports?: boolean
/**
* Recognize the sideEffects flag in package.json or rules to eliminate modules. This depends on optimization.providedExports and optimization.usedExports.
* These dependencies have a cost, but eliminating modules has positive impact on performance because of less code generation. It depends on your codebase.
* Try it for possible performance wins.
*/
sideEffects?: boolean
/** Tries to find segments of the module graph which can be safely concatenated into a single module. Depends on optimization.providedExports and optimization.usedExports. */
concatenateModules?: boolean
/** Finds modules which are shared between chunk and splits them into separate chunks to reduce duplication or separate vendor modules from application modules. */
splitChunks?: SplitChunksOptions | false
/** Create a separate chunk for the webpack runtime code and chunk hash maps. This chunk should be inlined into the HTML */
runtimeChunk?: boolean | 'single' | 'multiple' | RuntimeChunkOptions
/** Avoid emitting assets when errors occur. */
noEmitOnErrors?: boolean
/** Instead of numeric ids, give modules readable names for better debugging. */
namedModules?: boolean
/** Instead of numeric ids, give chunks readable names for better debugging. */
namedChunks?: boolean
/** Tells webpack which algorithm to use when choosing module ids. Default false. */
moduleIds?:
| boolean
| 'natural'
| 'named'
| 'hashed'
| 'size'
| 'total-size'
/** Tells webpack which algorithm to use when choosing chunk ids. Default false. */
chunkIds?: boolean | 'natural' | 'named' | 'size' | 'total-size'
/** Defines the process.env.NODE_ENV constant to a compile-time-constant value. This allows to remove development only code from code. */
nodeEnv?: string | false
/** Use the minimizer (optimization.minimizer, by default uglify-js) to minimize output assets. */
minimize?: boolean
/** Minimizer(s) to use for minimizing the output */
minimizer?: Array<Plugin>
/** Generate records with relative paths to be able to move the context folder". */
portableRecords?: boolean
checkWasmTypes?: boolean
}
}
namespace debug {
interface ProfilingPluginOptions {
/** A relative path to a custom output file (json) */
outputPath?: string
}
/**
* Generate Chrome profile file which includes timings of plugins execution. Outputs `events.json` file by
* default. It is possible to provide custom file path using `outputPath` option.
*
* In order to view the profile file:
* * Run webpack with ProfilingPlugin.
* * Go to Chrome, open the Profile Tab.
* * Drag and drop generated file (events.json by default) into the profiler.
*
* It will then display timeline stats and calls per plugin!
*/
class ProfilingPlugin extends Plugin {
constructor(options?: ProfilingPluginOptions)
}
}
namespace compilation {
class Asset {}
class Module {}
class Record {}
class Chunk {
constructor(name: string)
id: any
ids: any
debugId: number
name: any
entryModule: any
files: any[]
rendered: boolean
hash: any
renderedHash: any
chunkReason: any
extraAsync: boolean
hasRuntime(): boolean
canBeInitial(): boolean
isOnlyInitial(): boolean
hasEntryModule(): boolean
addModule(module: any): boolean
removeModule(module: any): boolean
setModules(modules: any): void
getNumberOfModules(): number
modulesIterable: any[]
addGroup(chunkGroup: any): boolean
removeGroup(chunkGroup: any): boolean
isInGroup(chunkGroup: any): boolean
getNumberOfGroups(): number
groupsIterable: any[]
compareTo(otherChunk: any): -1 | 0 | 1
containsModule(module: any): boolean
getModules(): any[]
getModulesIdent(): any[]
remove(reason: any): void
moveModule(module: any, otherChunk: any): void
integrate(otherChunk: any, reason: any): boolean
split(newChunk: any): void
isEmpty(): boolean
updateHash(hash: any): void
canBeIntegrated(otherChunk: any): boolean
addMultiplierAndOverhead(size: number, options: any): number
modulesSize(): number
size(options: any): number
integratedSize(otherChunk: any, options: any): number
sortModules(sortByFn: Function): void
getAllAsyncChunks(): Set<any>
getChunkMaps(realHash: any): { hash: any; name: any }
getChunkModuleMaps(filterFn: Function): { id: any; hash: any }
hasModuleInGraph(filterFn: Function, filterChunkFn: Function): boolean
toString(): string
}
class ChunkGroup {}
class ChunkHash {}
class Dependency {
constructor()
getResourceIdentifier(): any
getReference(): any
getExports(): any
getWarnings(): any
getErrors(): any
updateHash(hash: any): void
disconnect(): void
static compare(a: any, b: any): any
}
interface NormalModuleFactoryHooks {
resolver: any
factory: any
beforeResolve: any
afterResolve: any
createModule: any
module: any
createParser: any
parser: any
createGenerator: any
generator: any
}
class NormalModuleFactory {
hooks: NormalModuleFactoryHooks
}
interface ContextModuleFactoryHooks {
beforeResolve: any
afterResolve: any
contextModuleFiles: any
alternatives: any
}
class ContextModuleFactory {
hooks: ContextModuleFactoryHooks
}
class DllModuleFactory {
hooks: {}
}
interface CompilationHooks {
buildModule: any
rebuildModule: any
failedModule: any
succeedModule: any
finishModules: any
finishRebuildingModule: any
unseal: any
seal: any
optimizeDependenciesBasic: any
optimizeDependencies: any
optimizeDependenciesAdvanced: any
afterOptimizeDependencies: any
optimize: any
optimizeModulesBasic: any
optimizeModules: any
optimizeModulesAdvanced: any
afterOptimizeModules: any
optimizeChunksBasic: {
tap: (
name: string,
callback: (chunks: compilation.Chunk[]) => void
) => void
tapAsync: (
name: string,
callback: (chunks: compilation.Chunk[], callback: any) => void
) => void
}
optimizeChunks: {
tap: (
name: string,
callback: (chunks: compilation.Chunk[]) => void
) => void
tapAsync: (
name: string,
callback: (chunks: compilation.Chunk[], callback: any) => void
) => void
}
optimizeChunksAdvanced: any
afterOptimizeChunks: any
optimizeTree: any
afterOptimizeTree: any
optimizeChunkModulesBasic: any
optimizeChunkModules: any
optimizeChunkModulesAdvanced: any
afterOptimizeChunkModules: any
shouldRecord: any
reviveModules: any
optimizeModuleOrder: any
advancedOptimizeModuleOrder: any
beforeModuleIds: any