UNPKG

2 kBTypeScriptView Raw
1// Type definitions for loader-runner v2.2.0
2// Project: https://github.com/webpack/loader-runner.git
3// Definitions by: e-cloud <https://github.com/e-cloud>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
6/// <reference types="node" />
7
8export interface Loader {
9 path: string;
10 query: string;
11 request: string;
12 options: any;
13 normal: null | ((request: string) => string);
14 pitch: null | ((request: string) => string);
15 raw: string;
16 data: any;
17 pitchExecuted: boolean;
18 normalExecuted: boolean;
19}
20
21export interface RunLoaderOption {
22 resource: string;
23 loaders: any[];
24 context: any;
25 readResource: (
26 filename: string,
27 callback: (err: NodeJS.ErrnoException | null, data: Buffer | null) => void
28 ) => void;
29}
30
31export interface RunLoaderResult {
32 result?: (Buffer | null)[] | undefined;
33 resourceBuffer?: Buffer | null | undefined;
34 cacheable: boolean;
35 fileDependencies: string[];
36 contextDependencies: string[];
37}
38
39export interface ExtendedLoaderContext {
40 context: string | null;
41 loaderIndex: number;
42 loaders: Loader[];
43 resourcePath: string | undefined;
44 resourceQuery: string | undefined;
45 async: (() => (() => void) | undefined) | null;
46 callback: (() => void) | null;
47 cacheable: (flag: boolean) => void;
48 dependency: (file: string) => void;
49 addDependency: (file: string) => void;
50 addContextDependency: (context: string) => void;
51 getDependencies: () => string[];
52 getContextDependencies: () => string[];
53 clearDependencies: () => void;
54 resource: string;
55 request: string;
56 remainingRequest: string;
57 currentRequest: string;
58 previousRequest: string;
59 query: {
60 [key: string]: any;
61 } | string;
62 data: any;
63}
64
65export function getContext(resource: string): string;
66
67export function runLoaders(
68 options: RunLoaderOption,
69 callback: (err: NodeJS.ErrnoException | null, result: RunLoaderResult) => any
70): void;
71
72