mirror of
https://github.com/nodejs/node.git
synced 2024-11-22 07:37:56 +01:00
df4a0c996d
PR-URL: https://github.com/nodejs/node/pull/55549 Refs: https://github.com/nodejs/node/pull/55412/files#r1817708918 Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
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
|
|
enableCompileCache(path?: string): { status: number, message?: string, directory?: string }
|
|
getCompileCacheDir(): string | undefined
|
|
flushCompileCache(keepDeserializedCache?: boolean): void
|
|
}
|