forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.d.ts
261 lines (232 loc) · 9.71 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
// Type definitions for webpack 1.12.2
// Project: https://github.com/webpack/webpack
// Definitions by: Qubo <https://github.com/tkqubo>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "webpack" {
namespace webpack {
interface Configuration {
entry?: string|Entry;
output?: Output;
module?: Module;
plugins?: (Plugin|Function)[];
}
interface Entry {
[name: string]: string|string[];
}
interface Output {
path?: string;
filename?: string;
chunkFilename?: string;
publicPath?: string;
}
interface Module {
loaders?: Loader[];
}
interface Loader {
test: RegExp;
loader?: string;
loaders?: string[];
query?: {
[name: string]: any;
}
}
interface Plugin { }
interface Webpack {
/**
* optimize namespace
*/
optimize: Optimize;
/**
* dependencies namespace
*/
dependencies: Dependencies;
/**
* Replace resources that matches resourceRegExp with newResource.
* If newResource is relative, it is resolve relative to the previous resource.
* If newResource is a function, it is expected to overwrite the ‘request’ attribute of the supplied object.
*/
NormalModuleReplacementPlugin: NormalModuleReplacementPluginStatic;
/**
* Replaces the default resource, recursive flag or regExp generated by parsing with newContentResource,
* newContentRecursive resp. newContextRegExp if the resource (directory) matches resourceRegExp.
* If newContentResource is relative, it is resolve relative to the previous resource.
* If newContentResource is a function, it is expected to overwrite the ‘request’ attribute of the supplied object.
*/
ContextReplacementPlugin: ContextReplacementPluginStatic;
/**
* Don’t generate modules for requests matching the provided RegExp.
*/
IgnorePlugin: IgnorePluginStatic;
/**
* A request for a normal module, which is resolved and built even before a require to it occurs.
* This can boost performance. Try to profile the build first to determine clever prefetching points.
*/
PrefetchPlugin: PrefetchPluginStatic;
/**
* Apply a plugin (or array of plugins) to one or more resolvers (as specified in types).
*/
ResolverPlugin: ResolverPluginStatic;
/**
* Adds a banner to the top of each generated chunk.
*/
BannerPlugin: BannerPluginStatic;
/**
* Define free variables. Useful for having development builds with debug logging or adding global constants.
*/
DefinePlugin: DefinePluginStatic;
/**
* Automatically loaded modules.
* Module (value) is loaded when the identifier (key) is used as free variable in a module.
* The identifier is filled with the exports of the loaded module.
*/
ProvidePlugin: ProvidePluginStatic;
/**
* Adds SourceMaps for assets.
*/
SourceMapDevToolPlugin: SourceMapDevToolPluginStatic;
/**
* Enables Hot Module Replacement. (This requires records data if not in dev-server mode, recordsPath)
* Generates Hot Update Chunks of each chunk in the records.
* It also enables the API and makes __webpack_hash__ available in the bundle.
*/
HotModuleReplacementPlugin: HotModuleReplacementPluginStatic;
/**
* Adds useful free vars to the bundle.
*/
ExtendedAPIPlugin: ExtendedAPIPluginStatic;
/**
* When there are errors while compiling this plugin skips the emitting phase (and recording phase),
* so there are no assets emitted that include errors. The emitted flag in the stats is false for all assets.
*/
NoErrorsPlugin: NoErrorsPluginStatic;
/**
* Does not watch specified files matching provided paths or RegExps.
*/
WatchIgnorePlugin: WatchIgnorePluginStatic;
}
interface Optimize {
/**
* Search for equal or similar files and deduplicate them in the output.
* This comes with some overhead for the entry chunk, but can reduce file size effectively.
* This is experimental and may crash, because of some missing implementations. (Report an issue)
*/
DedupePlugin: optimize.DedupePluginStatic;
/**
* Limit the chunk count to a defined value. Chunks are merged until it fits.
*/
LimitChunkCountPlugin: optimize.LimitChunkCountPluginStatic;
/**
* Merge small chunks that are lower than this min size (in chars). Size is approximated.
*/
MinChunkSizePlugin: optimize.MinChunkSizePluginStatic;
/**
* Assign the module and chunk ids by occurrence count. Ids that are used often get lower (shorter) ids.
* This make ids predictable, reduces to total file size and is recommended.
*/
OccurenceOrderPlugin: optimize.OccurenceOrderPluginStatic;
/**
* Minimize all JavaScript output of chunks. Loaders are switched into minimizing mode.
* You can pass an object containing UglifyJs options.
*/
UglifyJsPlugin: optimize.UglifyJsPluginStatic;
CommonsChunkPlugin: optimize.CommonsChunkPluginStatic;
/**
* A plugin for a more aggressive chunk merging strategy.
* Even similar chunks are merged if the total size is reduced enough.
* As an option modules that are not common in these chunks can be moved up the chunk tree to the parents.
*/
AggressiveMergingPlugin: optimize.AggressiveMergingPluginStatic;
}
interface Dependencies {
/**
* Support Labeled Modules.
*/
LabeledModulesPlugin: dependencies.LabeledModulesPluginStatic;
}
interface DirectoryDescriptionFilePluginStatic {
new(file: string, files: string[]): Plugin;
}
interface NormalModuleReplacementPluginStatic {
new(resourceRegExp: any, newResource: any): Plugin;
}
interface ContextReplacementPluginStatic {
new(resourceRegExp: any, newContentResource?: any, newContentRecursive?: any, newContentRegExp?: any): Plugin
}
interface IgnorePluginStatic {
new(requestRegExp: any, contextRegExp?: any): Plugin;
}
interface PrefetchPluginStatic {
new(context: any, request: any): Plugin;
new(request: any): Plugin;
}
interface ResolverPluginStatic {
new(plugins: Plugin[], files?: string[]): Plugin;
DirectoryDescriptionFilePlugin: DirectoryDescriptionFilePluginStatic;
/**
* This plugin will append a path to the module directory to find a match,
* which can be useful if you have a module which has an incorrect “main” entry in its package.json/bower.json etc (e.g. "main": "Gruntfile.js").
* You can use this plugin as a special case to load the correct file for this module. Example:
*/
FileAppendPlugin: FileAppendPluginStatic;
}
interface FileAppendPluginStatic {
new(files: string[]): Plugin;
}
interface BannerPluginStatic {
new(banner: any, options: any): Plugin;
}
interface DefinePluginStatic {
new(definitions: any): Plugin;
}
interface ProvidePluginStatic {
new(definitions: any): Plugin;
}
interface SourceMapDevToolPluginStatic {
new(options: any): Plugin;
}
interface HotModuleReplacementPluginStatic {
new(): Plugin;
}
interface ExtendedAPIPluginStatic {
new(): Plugin;
}
interface NoErrorsPluginStatic {
new(): Plugin;
}
interface WatchIgnorePluginStatic {
new(paths: RegExp[]): Plugin;
}
namespace optimize {
interface DedupePluginStatic {
new(): Plugin;
}
interface LimitChunkCountPluginStatic {
new(options: any): Plugin
}
interface MinChunkSizePluginStatic {
new(options: any): Plugin;
}
interface OccurenceOrderPluginStatic {
new(preferEntry: boolean): Plugin;
}
interface UglifyJsPluginStatic {
new(options?: any): Plugin;
}
interface CommonsChunkPluginStatic {
new(chunkName: string, filenames?: string|string[]): Plugin;
new(options?: any): Plugin;
}
interface AggressiveMergingPluginStatic {
new(options: any): Plugin;
}
}
namespace dependencies {
interface LabeledModulesPluginStatic {
new(): Plugin;
}
}
}
var webpack: webpack.Webpack;
//export default webpack;
export = webpack;
}