an abstraction for import-map utilities of a general javascript runtime's package object with the schema SCHEMA.

  • in the case of node, SCHEMA would represent package.json's schema.
  • in the case of deno, SCHEMA would represent deno.json, deno.jsonc, or jsr.json's schema.

Type Parameters

  • SCHEMA extends Record<string, any>

    a record type representing the package schema.

Hierarchy (View Summary)

Constructors

  • Type Parameters

    • SCHEMA extends Record<string, any>

    Parameters

    • package_object: SCHEMA

      the parsed package metadata as an object.

      • in the case of node, this would be your json-parsed "package.json" file.
      • in the case of deno, this would be your json-parsed "deno.json" file.

    Returns RuntimePackage<SCHEMA>

Properties

packageInfo: SCHEMA

the fetched/parsed package metadata file's raw contents.

importMapSortedEntries: ImportMapSortedEntries

the import-map entries of the package, sorted from the largest key-alias to the shortest.

Note

each subclass will have to assign on their own, in addition to ensuring the required sorting order.

exportMapSortedEntries: ImportMapSortedEntries

the export-map entries of the package, sorted from the largest key-alias to the shortest.

Note

each subclass will have to assign on their own, in addition to ensuring the required sorting order.

Methods

  • this method tries to resolve the provided import path_alias done by some resource within this package, using the internal importMapSortedEntries list of import-aliases that this package uses. if no import resources match the given path_alias, then undefined will be returned (which would probably mean that the given path_alias is already either an absolute or relative path, or perhaps incorrect altogether.

    Tip

    for test case examples and configuration options, see the documentation comments of resolvePathFromImportMapEntries

    Parameters

    Returns undefined | string

  • create an instance of this class by loading a package's json(c) file from a url or local file-system path.

    Tip

    the constructor uses a "JSONC" parser (from @std/jsonc) for the fetched files. therefore, you may provide links to ".jsonc" files, instead of parsing them yourself before calling the super constructor.

    Type Parameters

    Parameters

    • this: ConstructorOf<INSTANCE, [SCHEMA]>
    • package_jsonc_path: string | URL

    Returns Promise<INSTANCE>