0.2.1 • Published 1 year ago
@bgotink/list-exports v0.2.1
@bgotink/list-exports
This package exposes functions that can be used to list a package's exports and imports.
listExports
The listExports function expects one or two parameters:
export function listExports(
location: string | URL,
input?: ImportExportInput
): Promise<Array<ImportExport>>;locationis the path or full file URL to thepackage.jsonfileinputcan be provided, with multiple options:packageJson(unknown), thepackage.jsonobject. If a value is passed, it won't be read fromlocation.environment(node|browser| null, default:node) Environment condition to use in resolvingtype(import|require|default| null, default:importwhen the package is imported andrequirewhen the package is required) Module type condition to load. Thedefaultcondition is added unless the valuenullis passed.extraCondition(string[], default:[]) Extra conditions to allow
The returned ImportExport objects have four properties:
nameis the export path as used to import the export. If the name is'./deep/export'and the package is namedpkg, the export can be imported aspkg/deep/export. The name of the main export is'.', not''.pathis the path to the exported file, relative to thelocation.registeredNameis the export name as configured in thepackage.jsonfile. If the export contains*, this property will still contain the*. That means that if the*export matches multiple files, more than oneImportExportwill have the sameregisteredName.registeredPathis the export path as configured in thepackage.jsonfile. If the export contains*, this property will still contain the*. That means that if the*export matches multiple files, more than oneImportExportwill have the sameregisteredPath.
listImports
The listImports function is identical to listExports, except it lists the package's imports rather than exports.
export function listImports(
location: string | URL,
input?: ImportExportInput
): Promise<Array<ImportExport>>;License & Notice
This package is licensed under the MIT license, which can be found in LICENSE.md.
Dependencies are bundled while publishing, check NOTICE.md in the published package for their licenses.