1
1
export = NormalModuleFactory ;
2
2
declare class NormalModuleFactory extends ModuleFactory {
3
3
/**
4
- * @param {Object } param params
4
+ * @param {object } param params
5
5
* @param {string= } param.context context
6
6
* @param {InputFileSystem } param.fs file system
7
7
* @param {ResolverFactory } param.resolverFactory resolverFactory
8
8
* @param {ModuleOptions } param.options options
9
- * @param {Object = } param.associatedObjectForCache an object to which the cache will be attached
9
+ * @param {object = } param.associatedObjectForCache an object to which the cache will be attached
10
10
* @param {boolean= } param.layers enable layers
11
11
*/
12
12
constructor ( {
@@ -21,48 +21,71 @@ declare class NormalModuleFactory extends ModuleFactory {
21
21
fs : InputFileSystem ;
22
22
resolverFactory : ResolverFactory ;
23
23
options : ModuleOptions ;
24
- associatedObjectForCache ?: any | undefined ;
24
+ associatedObjectForCache ?: object | undefined ;
25
25
layers ?: boolean | undefined ;
26
26
} ) ;
27
27
hooks : Readonly < {
28
- resolve : AsyncSeriesBailHook < [ ResolveData ] , false | void | Module > ;
28
+ /** @type {AsyncSeriesBailHook<[ResolveData], Module | false | void> } */
29
+ resolve : AsyncSeriesBailHook < [ ResolveData ] , Module | false | void > ;
30
+ /** @type {HookMap<AsyncSeriesBailHook<[ResourceDataWithData, ResolveData], true | void>> } */
29
31
resolveForScheme : HookMap <
30
32
AsyncSeriesBailHook < [ ResourceDataWithData , ResolveData ] , true | void >
31
33
> ;
34
+ /** @type {HookMap<AsyncSeriesBailHook<[ResourceDataWithData, ResolveData], true | void>> } */
32
35
resolveInScheme : HookMap <
33
36
AsyncSeriesBailHook < [ ResourceDataWithData , ResolveData ] , true | void >
34
37
> ;
35
- factorize : AsyncSeriesBailHook < [ ResolveData ] , undefined | Module > ;
38
+ /** @type {AsyncSeriesBailHook<[ResolveData], Module | undefined> } */
39
+ factorize : AsyncSeriesBailHook < [ ResolveData ] , Module | undefined > ;
40
+ /** @type {AsyncSeriesBailHook<[ResolveData], false | void> } */
36
41
beforeResolve : AsyncSeriesBailHook < [ ResolveData ] , false | void > ;
42
+ /** @type {AsyncSeriesBailHook<[ResolveData], false | void> } */
37
43
afterResolve : AsyncSeriesBailHook < [ ResolveData ] , false | void > ;
44
+ /** @type {AsyncSeriesBailHook<[ResolveData["createData"], ResolveData], Module | void> } */
38
45
createModule : AsyncSeriesBailHook <
39
- [
40
- Partial < NormalModuleCreateData & { settings : ModuleSettings } > ,
41
- ResolveData ,
42
- ] ,
43
- void | Module
46
+ [ ResolveData [ 'createData' ] , ResolveData ] ,
47
+ Module | void
44
48
> ;
49
+ /** @type {SyncWaterfallHook<[Module, ResolveData["createData"], ResolveData], Module> } */
45
50
module : SyncWaterfallHook <
46
- [
47
- Module ,
48
- Partial < NormalModuleCreateData & { settings : ModuleSettings } > ,
49
- ResolveData ,
50
- ] ,
51
+ [ Module , ResolveData [ 'createData' ] , ResolveData ] ,
51
52
Module
52
53
> ;
54
+ /** @type {HookMap<SyncBailHook<[ParserOptions], Parser>> } */
53
55
createParser : HookMap < SyncBailHook < [ ParserOptions ] , Parser > > ;
54
- parser : HookMap < SyncBailHook < [ any , ParserOptions ] , void > > ;
56
+ /** @type {HookMap<SyncBailHook<[TODO, ParserOptions], void>> } */
57
+ parser : HookMap < SyncBailHook < [ TODO , ParserOptions ] , void > > ;
58
+ /** @type {HookMap<SyncBailHook<[GeneratorOptions], Generator>> } */
55
59
createGenerator : HookMap < SyncBailHook < [ GeneratorOptions ] , Generator > > ;
56
- generator : HookMap < SyncBailHook < [ any , GeneratorOptions ] , void > > ;
57
- createModuleClass : HookMap < SyncBailHook < [ any , ResolveData ] , Module > > ;
60
+ /** @type {HookMap<SyncBailHook<[TODO, GeneratorOptions], void>> } */
61
+ generator : HookMap < SyncBailHook < [ TODO , GeneratorOptions ] , void > > ;
62
+ /** @type {HookMap<SyncBailHook<[TODO, ResolveData], Module>> } */
63
+ createModuleClass : HookMap < SyncBailHook < [ TODO , ResolveData ] , Module > > ;
58
64
} > ;
59
- resolverFactory : ResolverFactory ;
60
- ruleSet : RuleSet ;
65
+ resolverFactory : import ( './ ResolverFactory' ) ;
66
+ ruleSet : RuleSetCompiler . RuleSet ;
61
67
context : string ;
62
- fs : InputFileSystem ;
68
+ fs : import ( './util/fs' ) . InputFileSystem ;
69
+ _globalParserOptions : import ( '../declarations/WebpackOptions' ) . ParserOptionsByModuleType ;
70
+ _globalGeneratorOptions : import ( '../declarations/WebpackOptions' ) . GeneratorOptionsByModuleType ;
71
+ /** @type {Map<string, WeakMap<object, Parser>> } */
63
72
parserCache : Map < string , WeakMap < object , Parser > > ;
73
+ /** @type {Map<string, WeakMap<object, Generator>> } */
64
74
generatorCache : Map < string , WeakMap < object , Generator > > ;
75
+ /** @type {Set<Module> } */
76
+ _restoredUnsafeCacheEntries : Set < Module > ;
77
+ _parseResourceWithoutFragment : import ( './util/identifier' ) . BindCacheResultFn <
78
+ import ( './util/identifier' ) . ParsedResourceWithoutFragment
79
+ > ;
65
80
cleanupForCache ( ) : void ;
81
+ /**
82
+ * @param {ModuleFactoryCreateDataContextInfo } contextInfo context info
83
+ * @param {string } context context
84
+ * @param {string } unresolvedResource unresolved resource
85
+ * @param {ResolverWithOptions } resolver resolver
86
+ * @param {ResolveContext } resolveContext resolver context
87
+ * @param {(err: null | Error, res?: string | false, req?: ResolveRequest) => void } callback callback
88
+ */
66
89
resolveResource (
67
90
contextInfo : ModuleFactoryCreateDataContextInfo ,
68
91
context : string ,
@@ -75,34 +98,85 @@ declare class NormalModuleFactory extends ModuleFactory {
75
98
req ?: ResolveRequest ,
76
99
) => void ,
77
100
) : void ;
101
+ /**
102
+ * @param {Error } error error
103
+ * @param {ModuleFactoryCreateDataContextInfo } contextInfo context info
104
+ * @param {string } context context
105
+ * @param {string } unresolvedResource unresolved resource
106
+ * @param {ResolverWithOptions } resolver resolver
107
+ * @param {ResolveContext } resolveContext resolver context
108
+ * @param {Callback<string[]> } callback callback
109
+ * @private
110
+ */
111
+ private _resolveResourceErrorHints ;
112
+ /**
113
+ * @param {ModuleFactoryCreateDataContextInfo } contextInfo context info
114
+ * @param {string } context context
115
+ * @param {LoaderItem[] } array array
116
+ * @param {ResolverWithOptions } resolver resolver
117
+ * @param {ResolveContext } resolveContext resolve context
118
+ * @param {Callback<LoaderItem[]> } callback callback
119
+ * @returns {void } result
120
+ */
78
121
resolveRequestArray (
79
122
contextInfo : ModuleFactoryCreateDataContextInfo ,
80
123
context : string ,
81
124
array : LoaderItem [ ] ,
82
125
resolver : ResolverWithOptions ,
83
126
resolveContext : ResolveContext ,
84
- callback : CallbackNormalModuleFactory < LoaderItem [ ] > ,
127
+ callback : Callback < LoaderItem [ ] > ,
85
128
) : void ;
129
+ /**
130
+ * @param {string } type type
131
+ * @param {ParserOptions } parserOptions parser options
132
+ * @returns {Parser } parser
133
+ */
86
134
getParser ( type : string , parserOptions ?: ParserOptions ) : Parser ;
135
+ /**
136
+ * @param {string } type type
137
+ * @param {ParserOptions } parserOptions parser options
138
+ * @returns {Parser } parser
139
+ */
87
140
createParser ( type : string , parserOptions ?: ParserOptions ) : Parser ;
141
+ /**
142
+ * @param {string } type type of generator
143
+ * @param {GeneratorOptions } generatorOptions generator options
144
+ * @returns {Generator } generator
145
+ */
88
146
getGenerator ( type : string , generatorOptions ?: GeneratorOptions ) : Generator ;
147
+ /**
148
+ * @param {string } type type of generator
149
+ * @param {GeneratorOptions } generatorOptions generator options
150
+ * @returns {Generator } generator
151
+ */
89
152
createGenerator ( type : string , generatorOptions ?: GeneratorOptions ) : Generator ;
153
+ /**
154
+ * @param {Parameters<ResolverFactory["get"]>[0] } type type of resolver
155
+ * @param {Parameters<ResolverFactory["get"]>[1]= } resolveOptions options
156
+ * @returns {ReturnType<ResolverFactory["get"]> } the resolver
157
+ */
90
158
getResolver (
91
- type : string ,
92
- resolveOptions ?: ResolveOptionsWithDependencyType ,
93
- ) : ResolverWithOptions ;
159
+ type : Parameters < ResolverFactory [ 'get' ] > [ 0 ] ,
160
+ resolveOptions ?: Parameters < ResolverFactory [ 'get' ] > [ 1 ] | undefined ,
161
+ ) : ReturnType < ResolverFactory [ 'get' ] > ;
94
162
}
95
-
96
163
declare namespace NormalModuleFactory {
97
164
export {
98
165
ModuleOptions ,
99
166
RuleSetRule ,
100
167
Generator ,
101
168
ModuleFactoryCreateData ,
169
+ ModuleFactoryCreateDataContextInfo ,
102
170
ModuleFactoryResult ,
171
+ GeneratorOptions ,
172
+ LoaderItem ,
103
173
NormalModuleCreateData ,
174
+ ParserOptions ,
104
175
Parser ,
105
176
ResolverFactory ,
177
+ ResolveContext ,
178
+ ResolveRequest ,
179
+ ResolverWithOptions ,
106
180
ModuleDependency ,
107
181
InputFileSystem ,
108
182
ModuleSettings ,
@@ -111,65 +185,72 @@ declare namespace NormalModuleFactory {
111
185
ResourceData ,
112
186
ResourceDataWithData ,
113
187
ParsedLoaderRequest ,
188
+ Callback ,
114
189
} ;
115
190
}
116
191
import ModuleFactory = require( './ModuleFactory' ) ;
117
192
import { AsyncSeriesBailHook } from 'tapable' ;
118
- type ResolveData = {
119
- contextInfo : ModuleFactoryCreateData [ 'contextInfo' ] ;
120
- resolveOptions : ModuleFactoryCreateData [ 'resolveOptions' ] ;
121
- context : string ;
122
- request : string ;
123
- assertions : Record < string , any > | undefined ;
124
- dependencies : ModuleDependency [ ] ;
125
- dependencyType : string ;
126
- createData : CreateData ;
127
- fileDependencies : LazySet < string > ;
128
- missingDependencies : LazySet < string > ;
129
- contextDependencies : LazySet < string > ;
130
- /**
131
- * allow to use the unsafe cache
132
- */
133
- cacheable : boolean ;
134
- } ;
135
193
import Module = require( './Module' ) ;
136
194
import { HookMap } from 'tapable' ;
137
- type ResourceDataWithData = ResourceData & {
138
- data : Record < string , any > ;
139
- } ;
140
- import NormalModule = require( './NormalModule' ) ;
141
- type ModuleSettings = Pick <
142
- RuleSetRule ,
143
- 'type' | 'sideEffects' | 'parser' | 'generator' | 'resolve' | 'layer'
144
- > ;
145
195
import { SyncWaterfallHook } from 'tapable' ;
146
196
import { SyncBailHook } from 'tapable' ;
147
- import { SyncHook } from 'tapable' ;
148
- import RuleSetCompiler from './rules/RuleSetCompiler' ;
149
- type Generator = import ( './Generator' ) ;
150
- type Parser = import ( './Parser' ) ;
151
- type InputFileSystem = import ( './util/fs' ) . InputFileSystem ;
152
- type ResolverFactory = import ( './ResolverFactory' ) ;
197
+ import RuleSetCompiler = require( './rules/RuleSetCompiler' ) ;
153
198
type ModuleOptions =
154
199
import ( '../declarations/WebpackOptions' ) . ModuleOptionsNormalized ;
155
200
type RuleSetRule = import ( '../declarations/WebpackOptions' ) . RuleSetRule ;
201
+ type Generator = import ( './Generator' ) ;
156
202
type ModuleFactoryCreateData =
157
203
import ( './ModuleFactory' ) . ModuleFactoryCreateData ;
204
+ type ModuleFactoryCreateDataContextInfo =
205
+ import ( './ModuleFactory' ) . ModuleFactoryCreateDataContextInfo ;
158
206
type ModuleFactoryResult = import ( './ModuleFactory' ) . ModuleFactoryResult ;
207
+ type GeneratorOptions = import ( './NormalModule' ) . GeneratorOptions ;
208
+ type LoaderItem = import ( './NormalModule' ) . LoaderItem ;
159
209
type NormalModuleCreateData = import ( './NormalModule' ) . NormalModuleCreateData ;
210
+ type ParserOptions = import ( './NormalModule' ) . ParserOptions ;
211
+ type Parser = import ( './Parser' ) ;
212
+ type ResolverFactory = import ( './ResolverFactory' ) ;
213
+ type ResolveContext = import ( './ResolverFactory' ) . ResolveContext ;
214
+ type ResolveRequest = import ( './ResolverFactory' ) . ResolveRequest ;
215
+ type ResolverWithOptions = import ( './ResolverFactory' ) . ResolverWithOptions ;
160
216
type ModuleDependency = import ( './dependencies/ModuleDependency' ) ;
217
+ type InputFileSystem = import ( './util/fs' ) . InputFileSystem ;
218
+ type ModuleSettings = Pick <
219
+ RuleSetRule ,
220
+ 'type' | 'sideEffects' | 'parser' | 'generator' | 'resolve' | 'layer'
221
+ > ;
161
222
type CreateData = Partial <
162
223
NormalModuleCreateData & {
163
224
settings : ModuleSettings ;
164
225
}
165
226
> ;
227
+ type ResolveData = {
228
+ contextInfo : ModuleFactoryCreateData [ 'contextInfo' ] ;
229
+ resolveOptions : ModuleFactoryCreateData [ 'resolveOptions' ] ;
230
+ context : string ;
231
+ request : string ;
232
+ assertions : Record < string , any > | undefined ;
233
+ dependencies : ModuleDependency [ ] ;
234
+ dependencyType : string ;
235
+ createData : CreateData ;
236
+ fileDependencies : LazySet < string > ;
237
+ missingDependencies : LazySet < string > ;
238
+ contextDependencies : LazySet < string > ;
239
+ /**
240
+ * allow to use the unsafe cache
241
+ */
242
+ cacheable : boolean ;
243
+ } ;
166
244
type ResourceData = {
167
245
resource : string ;
168
- path : string ;
169
- query : string ;
170
- fragment : string ;
246
+ path ? : string | undefined ;
247
+ query ? : string | undefined ;
248
+ fragment ? : string | undefined ;
171
249
context ?: string | undefined ;
172
250
} ;
251
+ type ResourceDataWithData = ResourceData & {
252
+ data : Record < string , any > ;
253
+ } ;
173
254
type ParsedLoaderRequest = {
174
255
/**
175
256
* loader
@@ -180,4 +261,8 @@ type ParsedLoaderRequest = {
180
261
*/
181
262
options : string | undefined ;
182
263
} ;
264
+ type Callback < T > = (
265
+ err ?: ( Error | null ) | undefined ,
266
+ stats ?: T | undefined ,
267
+ ) => void ;
183
268
import LazySet = require( './util/LazySet' ) ;
0 commit comments