UNPKG

11.5 kBTypeScriptView Raw
1/*
2 * This file was automatically generated.
3 * DO NOT MODIFY BY HAND.
4 * Run `yarn special-lint-fix` to update
5 */
6
7import { AsyncSeriesBailHook, AsyncSeriesHook, SyncHook } from "tapable";
8
9declare interface AliasOption {
10 alias: string | false | string[];
11 name: string;
12 onlyModule?: boolean;
13}
14type AliasOptionNewRequest = string | false | string[];
15declare interface AliasOptions {
16 [index: string]: AliasOptionNewRequest;
17}
18declare interface BaseResolveRequest {
19 path: string | false;
20 descriptionFilePath?: string;
21 descriptionFileRoot?: string;
22 descriptionFileData?: object;
23 relativePath?: string;
24 ignoreSymlinks?: boolean;
25 fullySpecified?: boolean;
26}
27declare class CachedInputFileSystem {
28 constructor(fileSystem?: any, duration?: any);
29 fileSystem: any;
30 lstat?: {
31 (arg0: string, arg1: FileSystemCallback<FileSystemStats>): void;
32 (
33 arg0: string,
34 arg1: object,
35 arg2: FileSystemCallback<string | Buffer>
36 ): void;
37 };
38 lstatSync?: (arg0: string, arg1?: object) => FileSystemStats;
39 stat: {
40 (arg0: string, arg1: FileSystemCallback<FileSystemStats>): void;
41 (
42 arg0: string,
43 arg1: object,
44 arg2: FileSystemCallback<string | Buffer>
45 ): void;
46 };
47 statSync: (arg0: string, arg1?: object) => FileSystemStats;
48 readdir: {
49 (
50 arg0: string,
51 arg1: FileSystemCallback<(string | Buffer)[] | FileSystemDirent[]>
52 ): void;
53 (
54 arg0: string,
55 arg1: object,
56 arg2: FileSystemCallback<(string | Buffer)[] | FileSystemDirent[]>
57 ): void;
58 };
59 readdirSync: (
60 arg0: string,
61 arg1?: object
62 ) => (string | Buffer)[] | FileSystemDirent[];
63 readFile: {
64 (arg0: string, arg1: FileSystemCallback<string | Buffer>): void;
65 (
66 arg0: string,
67 arg1: object,
68 arg2: FileSystemCallback<string | Buffer>
69 ): void;
70 };
71 readFileSync: (arg0: string, arg1?: object) => string | Buffer;
72 readJson?: {
73 (arg0: string, arg1: FileSystemCallback<object>): void;
74 (arg0: string, arg1: object, arg2: FileSystemCallback<object>): void;
75 };
76 readJsonSync?: (arg0: string, arg1?: object) => object;
77 readlink: {
78 (arg0: string, arg1: FileSystemCallback<string | Buffer>): void;
79 (
80 arg0: string,
81 arg1: object,
82 arg2: FileSystemCallback<string | Buffer>
83 ): void;
84 };
85 readlinkSync: (arg0: string, arg1?: object) => string | Buffer;
86 purge(what?: any): void;
87}
88declare class CloneBasenamePlugin {
89 constructor(source?: any, target?: any);
90 source: any;
91 target: any;
92 apply(resolver: Resolver): void;
93}
94declare interface FileSystem {
95 readFile: {
96 (arg0: string, arg1: FileSystemCallback<string | Buffer>): void;
97 (
98 arg0: string,
99 arg1: object,
100 arg2: FileSystemCallback<string | Buffer>
101 ): void;
102 };
103 readdir: {
104 (
105 arg0: string,
106 arg1: FileSystemCallback<(string | Buffer)[] | FileSystemDirent[]>
107 ): void;
108 (
109 arg0: string,
110 arg1: object,
111 arg2: FileSystemCallback<(string | Buffer)[] | FileSystemDirent[]>
112 ): void;
113 };
114 readJson?: {
115 (arg0: string, arg1: FileSystemCallback<object>): void;
116 (arg0: string, arg1: object, arg2: FileSystemCallback<object>): void;
117 };
118 readlink: {
119 (arg0: string, arg1: FileSystemCallback<string | Buffer>): void;
120 (
121 arg0: string,
122 arg1: object,
123 arg2: FileSystemCallback<string | Buffer>
124 ): void;
125 };
126 lstat?: {
127 (arg0: string, arg1: FileSystemCallback<FileSystemStats>): void;
128 (
129 arg0: string,
130 arg1: object,
131 arg2: FileSystemCallback<string | Buffer>
132 ): void;
133 };
134 stat: {
135 (arg0: string, arg1: FileSystemCallback<FileSystemStats>): void;
136 (
137 arg0: string,
138 arg1: object,
139 arg2: FileSystemCallback<string | Buffer>
140 ): void;
141 };
142}
143declare interface FileSystemCallback<T> {
144 (err?: null | (PossibleFileSystemError & Error), result?: T): any;
145}
146declare interface FileSystemDirent {
147 name: string | Buffer;
148 isDirectory: () => boolean;
149 isFile: () => boolean;
150}
151declare interface FileSystemStats {
152 isDirectory: () => boolean;
153 isFile: () => boolean;
154}
155declare class LogInfoPlugin {
156 constructor(source?: any);
157 source: any;
158 apply(resolver: Resolver): void;
159}
160declare interface ParsedIdentifier {
161 request: string;
162 query: string;
163 fragment: string;
164 directory: boolean;
165 module: boolean;
166 file: boolean;
167 internal: boolean;
168}
169type Plugin =
170 | { apply: (arg0: Resolver) => void }
171 | ((this: Resolver, arg1: Resolver) => void);
172declare interface PnpApiImpl {
173 resolveToUnqualified: (arg0: string, arg1: string, arg2: object) => string;
174}
175declare interface PossibleFileSystemError {
176 code?: string;
177 errno?: number;
178 path?: string;
179 syscall?: string;
180}
181
182/**
183 * Resolve context
184 */
185declare interface ResolveContext {
186 contextDependencies?: WriteOnlySet<string>;
187
188 /**
189 * files that was found on file system
190 */
191 fileDependencies?: WriteOnlySet<string>;
192
193 /**
194 * dependencies that was not found on file system
195 */
196 missingDependencies?: WriteOnlySet<string>;
197
198 /**
199 * set of hooks' calls. For instance, `resolve → parsedResolve → describedResolve`,
200 */
201 stack?: Set<string>;
202
203 /**
204 * log function
205 */
206 log?: (arg0: string) => void;
207}
208declare interface ResolveOptions {
209 alias: AliasOption[];
210 fallback: AliasOption[];
211 aliasFields: Set<string | string[]>;
212 cachePredicate: (arg0: ResolveRequest) => boolean;
213 cacheWithContext: boolean;
214
215 /**
216 * A list of exports field condition names.
217 */
218 conditionNames: Set<string>;
219 descriptionFiles: string[];
220 enforceExtension: boolean;
221 exportsFields: Set<string | string[]>;
222 importsFields: Set<string | string[]>;
223 extensions: Set<string>;
224 fileSystem: FileSystem;
225 unsafeCache: false | object;
226 symlinks: boolean;
227 resolver?: Resolver;
228 modules: (string | string[])[];
229 mainFields: { name: string[]; forceRelative: boolean }[];
230 mainFiles: Set<string>;
231 plugins: Plugin[];
232 pnpApi: null | PnpApiImpl;
233 roots: Set<string>;
234 fullySpecified: boolean;
235 resolveToContext: boolean;
236 restrictions: Set<string | RegExp>;
237 preferRelative: boolean;
238 preferAbsolute: boolean;
239}
240type ResolveRequest = BaseResolveRequest & Partial<ParsedIdentifier>;
241declare abstract class Resolver {
242 fileSystem: FileSystem;
243 options: ResolveOptions;
244 hooks: {
245 resolveStep: SyncHook<
246 [
247 AsyncSeriesBailHook<
248 [ResolveRequest, ResolveContext],
249 null | ResolveRequest
250 >,
251 ResolveRequest
252 ]
253 >;
254 noResolve: SyncHook<[ResolveRequest, Error]>;
255 resolve: AsyncSeriesBailHook<
256 [ResolveRequest, ResolveContext],
257 null | ResolveRequest
258 >;
259 result: AsyncSeriesHook<[ResolveRequest, ResolveContext]>;
260 };
261 ensureHook(
262 name:
263 | string
264 | AsyncSeriesBailHook<
265 [ResolveRequest, ResolveContext],
266 null | ResolveRequest
267 >
268 ): AsyncSeriesBailHook<
269 [ResolveRequest, ResolveContext],
270 null | ResolveRequest
271 >;
272 getHook(
273 name:
274 | string
275 | AsyncSeriesBailHook<
276 [ResolveRequest, ResolveContext],
277 null | ResolveRequest
278 >
279 ): AsyncSeriesBailHook<
280 [ResolveRequest, ResolveContext],
281 null | ResolveRequest
282 >;
283 resolveSync(context: object, path: string, request: string): string | false;
284 resolve(
285 context: object,
286 path: string,
287 request: string,
288 resolveContext: ResolveContext,
289 callback: (
290 arg0: null | Error,
291 arg1?: string | false,
292 arg2?: ResolveRequest
293 ) => void
294 ): void;
295 doResolve(
296 hook?: any,
297 request?: any,
298 message?: any,
299 resolveContext?: any,
300 callback?: any
301 ): any;
302 parse(identifier: string): ParsedIdentifier;
303 isModule(path?: any): boolean;
304 isPrivate(path?: any): boolean;
305 isDirectory(path: string): boolean;
306 join(path?: any, request?: any): string;
307 normalize(path?: any): string;
308}
309declare interface UserResolveOptions {
310 /**
311 * A list of module alias configurations or an object which maps key to value
312 */
313 alias?: AliasOptions | AliasOption[];
314
315 /**
316 * A list of module alias configurations or an object which maps key to value, applied only after modules option
317 */
318 fallback?: AliasOptions | AliasOption[];
319
320 /**
321 * A list of alias fields in description files
322 */
323 aliasFields?: (string | string[])[];
324
325 /**
326 * A function which decides whether a request should be cached or not. An object is passed with at least `path` and `request` properties.
327 */
328 cachePredicate?: (arg0: ResolveRequest) => boolean;
329
330 /**
331 * Whether or not the unsafeCache should include request context as part of the cache key.
332 */
333 cacheWithContext?: boolean;
334
335 /**
336 * A list of description files to read from
337 */
338 descriptionFiles?: string[];
339
340 /**
341 * A list of exports field condition names.
342 */
343 conditionNames?: string[];
344
345 /**
346 * Enforce that a extension from extensions must be used
347 */
348 enforceExtension?: boolean;
349
350 /**
351 * A list of exports fields in description files
352 */
353 exportsFields?: (string | string[])[];
354
355 /**
356 * A list of imports fields in description files
357 */
358 importsFields?: (string | string[])[];
359
360 /**
361 * A list of extensions which should be tried for files
362 */
363 extensions?: string[];
364
365 /**
366 * The file system which should be used
367 */
368 fileSystem: FileSystem;
369
370 /**
371 * Use this cache object to unsafely cache the successful requests
372 */
373 unsafeCache?: boolean | object;
374
375 /**
376 * Resolve symlinks to their symlinked location
377 */
378 symlinks?: boolean;
379
380 /**
381 * A prepared Resolver to which the plugins are attached
382 */
383 resolver?: Resolver;
384
385 /**
386 * A list of directories to resolve modules from, can be absolute path or folder name
387 */
388 modules?: string | string[];
389
390 /**
391 * A list of main fields in description files
392 */
393 mainFields?: (
394 | string
395 | string[]
396 | { name: string | string[]; forceRelative: boolean }
397 )[];
398
399 /**
400 * A list of main files in directories
401 */
402 mainFiles?: string[];
403
404 /**
405 * A list of additional resolve plugins which should be applied
406 */
407 plugins?: Plugin[];
408
409 /**
410 * A PnP API that should be used - null is "never", undefined is "auto"
411 */
412 pnpApi?: null | PnpApiImpl;
413
414 /**
415 * A list of root paths
416 */
417 roots?: string[];
418
419 /**
420 * The request is already fully specified and no extensions or directories are resolved for it
421 */
422 fullySpecified?: boolean;
423
424 /**
425 * Resolve to a context instead of a file
426 */
427 resolveToContext?: boolean;
428
429 /**
430 * A list of resolve restrictions
431 */
432 restrictions?: (string | RegExp)[];
433
434 /**
435 * Use only the sync constiants of the file system calls
436 */
437 useSyncFileSystemCalls?: boolean;
438
439 /**
440 * Prefer to resolve module requests as relative requests before falling back to modules
441 */
442 preferRelative?: boolean;
443
444 /**
445 * Prefer to resolve server-relative urls as absolute paths before falling back to resolve in roots
446 */
447 preferAbsolute?: boolean;
448}
449declare interface WriteOnlySet<T> {
450 add: (T?: any) => void;
451}
452declare function exports(
453 context?: any,
454 path?: any,
455 request?: any,
456 resolveContext?: any,
457 callback?: any
458): void;
459declare namespace exports {
460 export const sync: (
461 context?: any,
462 path?: any,
463 request?: any
464 ) => string | false;
465 export function create(
466 options?: any
467 ): (
468 context?: any,
469 path?: any,
470 request?: any,
471 resolveContext?: any,
472 callback?: any
473 ) => void;
474 export namespace create {
475 export const sync: (
476 options?: any
477 ) => (context?: any, path?: any, request?: any) => string | false;
478 }
479 export namespace ResolverFactory {
480 export let createResolver: (options: UserResolveOptions) => Resolver;
481 }
482 export const forEachBail: (
483 array?: any,
484 iterator?: any,
485 callback?: any
486 ) => any;
487 export {
488 CachedInputFileSystem,
489 CloneBasenamePlugin,
490 LogInfoPlugin,
491 PnpApiImpl as PnpApi,
492 Resolver,
493 FileSystem,
494 ResolveContext,
495 ResolveRequest,
496 Plugin,
497 UserResolveOptions as ResolveOptions
498 };
499}
500
501export = exports;