1 | import * as resv from "resolve";
|
2 |
|
3 | /**
|
4 | * Resolve a module path and call cb(err, path)
|
5 | *
|
6 | * @param id Identifier to resolve
|
7 | * @param callback
|
8 | */
|
9 | declare function resolve(id: string, cb: resolve.Callback): void;
|
10 |
|
11 | /**
|
12 | * Resolve a module path and call cb(err, path)
|
13 | *
|
14 | * @param id Identifier to resolve
|
15 | * @param options Options to use for resolving, optional.
|
16 | * @param callback
|
17 | */
|
18 | declare function resolve(id: string, opts: resolve.AsyncOpts, cb: resolve.Callback): void;
|
19 |
|
20 | declare namespace resolve {
|
21 | interface Opts {
|
22 | /**
|
23 | * directory to begin resolving from
|
24 | */
|
25 | basedir?: string | undefined;
|
26 | /**
|
27 | * the 'browser' property to use from package.json
|
28 | * @default 'browser'
|
29 | */
|
30 | browser?: string | undefined;
|
31 | /**
|
32 | * the calling filename where the require() call originated (in the source)
|
33 | */
|
34 | filename?: string | undefined;
|
35 | /**
|
36 | * modules object with id to path mappings to consult before doing manual resolution
|
37 | * (use to provide core modules)
|
38 | */
|
39 | modules?: { [id: string]: string } | undefined;
|
40 | /**
|
41 | * transform the parsed package.json contents before looking at the main field
|
42 | */
|
43 | packageFilter?: ((info: any, pkgdir: string) => any) | undefined;
|
44 | /**
|
45 | * require.paths array to use if nothing is found on the normal node_modules recursive walk
|
46 | */
|
47 | paths?: string[] | undefined;
|
48 | }
|
49 |
|
50 | type AsyncOpts = resv.AsyncOpts & Opts;
|
51 | type SyncOpts = resv.SyncOpts & Opts;
|
52 |
|
53 | /**
|
54 | * Callback invoked when resolving asynchronously
|
55 | * @param error
|
56 | * @param resolved Absolute path to resolved identifier
|
57 | */
|
58 | type Callback = (err: Error | null, resolved?: string) => void;
|
59 |
|
60 | /**
|
61 | * Returns a module path
|
62 | * @param id Identifier to resolve
|
63 | * @param options Options to use for resolving.
|
64 | */
|
65 | function sync(id: string, opts?: SyncOpts): string;
|
66 | }
|
67 |
|
68 | export = resolve;
|