package-exports
Version:
Get the exports of a package
185 lines • 3.94 kB
TypeScript
/**
* Get the exports of a package.
*
* @param {Readonly<URL>} folder
* File URL to folder of a package.
* @returns {Promise<Result>}
* Result.
*/
export function packageExports(folder: Readonly<URL>): Promise<Result>;
export type Node = import('jsonc-parser').Node;
export type PackageJson = import('type-fest').PackageJson;
export type Location = import('vfile-location').Location;
export type Options = import('vfile-message').Options;
/**
* Export.
*/
export type Export = Omit<RawExport, 'filePath' | 'globbed' | 'jsonPathOrder'>;
/**
* Info.
*/
export type AddInfo = AddInfoExtraFields & Info;
/**
* Extra info.
*/
export type AddInfoExtraFields = {
/**
* Whether this file definitely exists.
*/
definitelyExists: boolean;
/**
* Whether this file was explicitly defined by the user.
*/
explicitlyDefined: boolean;
};
/**
* Info about the current path.
*/
export type Info = {
/**
* Conditions.
*/
conditions: ReadonlyArray<string> | undefined;
/**
* Path in `package.json`.
*/
path: ReadonlyArray<number | string>;
/**
* Order in `package.json`.
*/
pathOrder: ReadonlyArray<number>;
/**
* Specifier.
*/
specifier: string | undefined;
};
/**
* Info about mutually exclusive conditions.
*/
export type MutuallyExclusiveInfo = {
/**
* Conditions that cannot be used together.
*/
conditions: ReadonlyArray<string>;
/**
* Whether specifying all conditions in a conditions object means no
* `default` is needed.
* To illustrate, this is `true` for `import` and `require`, but not for
* `production` and `development`.
*/
exhaustive: boolean;
};
/**
* Negated export.
*/
export type NegatedExport = {
/**
* Conditions.
*/
conditions: ReadonlyArray<string> | undefined;
/**
* Path in `package.json`.
*/
jsonPath: ReadonlyArray<number | string>;
/**
* Order in `package.json`.
*/
jsonPathOrder: ReadonlyArray<number>;
/**
* Raw specifier as used in export map.
*/
specifier: string;
};
/**
* Info passed around.
*/
export type State = {
/**
* Exports.
*/
exports: Array<RawExport>;
/**
* File.
*/
file: VFile;
/**
* Location map.
*/
location: Location;
/**
* Negated exports: those set to `null`.
*/
negatedExports: Array<NegatedExport>;
/**
* URL.
*/
packageUrl: string;
/**
* Files that will be available after taking `.npmignore` and `"files"` into
* account.
*/
packagedFiles: ReadonlyArray<string>;
/**
* JSONC tree.
*/
tree: Node;
};
/**
* Export.
*/
export type RawExport = {
/**
* Conditions.
*/
conditions: ReadonlyArray<string> | undefined;
/**
* Whether this file exists.
*/
exists: boolean;
/**
* Raw path to file as used in export map.
*/
filePath: string;
/**
* Whether this file was added with a glob.
*/
globbed: boolean;
/**
* Path in `package.json`.
*/
jsonPath: ReadonlyArray<number | string>;
/**
* Order of keys;
* this is like `jsonPath`,
* but with numbers for in which order keys occurred,
* which is needed because export maps are order-sensitive.
*/
jsonPathOrder: ReadonlyArray<number>;
/**
* Specifier that exposes this.
*/
specifier: string;
/**
* Resolved URL to file.
*/
url: string;
};
/**
* Result of finding exports.
*/
export type Result = {
/**
* Exports.
*/
exports: Array<Export>;
/**
* File.
*/
file: VFile;
/**
* Package name.
*/
name: string | undefined;
};
import { VFile } from 'vfile';
//# sourceMappingURL=index.d.ts.map