forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodules.d.ts
More file actions
32 lines (31 loc) · 1.16 KB
/
Copy pathmodules.d.ts
File metadata and controls
32 lines (31 loc) · 1.16 KB
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
export type PackageType = 'commonjs' | 'module' | 'none'
export type PackageConfig = {
name?: string
main?: any
type: PackageType
exports?: string | string[] | Record<string, unknown>
imports?: string | string[] | Record<string, unknown>
}
export type DeserializedPackageConfig = {
data: PackageConfig,
exists: boolean,
path: string,
}
export type SerializedPackageConfig = [
PackageConfig['name'],
PackageConfig['main'],
PackageConfig['type'],
string | undefined, // exports
string | undefined, // imports
DeserializedPackageConfig['path'], // pjson file path
]
export interface ModulesBinding {
readPackageJSON(path: string): SerializedPackageConfig | undefined;
getNearestParentPackageJSONType(path: string): PackageConfig['type']
getNearestParentPackageJSON(path: string): SerializedPackageConfig | undefined
getPackageScopeConfig(path: string): SerializedPackageConfig | undefined
getPackageType(path: string): PackageConfig['type'] | undefined
enableCompileCache(path?: string): { status: number, message?: string, directory?: string }
getCompileCacheDir(): string | undefined
flushCompileCache(keepDeserializedCache?: boolean): void
}