jspm

Class ImportMap

Hierarchy

  • ImportMap

Implements

Constructors

  • Create a new import map instance

    Parameters

    • opts: string | URL | {
          map?: IImportMap;
          mapUrl?: string | URL;
          rootUrl?: string | URL;
      }

      import map options, can be an optional bag of { map?, mapUrl?, rootUrl? } or just a direct mapUrl

    Returns ImportMap

Properties

imports: Record<string, string> = ...
mapUrl: URL

The absolute URL of the import map, for determining relative resolutions When using file:/// URLs this allows relative modules to be co-located

rootUrl: URL

The URL to use for root-level resolutions in the import map If null, root resolutions are not resolved and instead left as-is

By default, rootUrl is null unless the mapUrl is an http or https URL, in which case it is taken to be the root of the mapUrl.

scopes: Record<string, Record<string, string>> = ...

Methods

  • Groups subpath mappings into path mappings when multiple exact subpaths exist under the same path.

    For two mappings like { "base/a.js": "/a.js", "base/b.js": "/b.js" }, these will be replaced with a single path mapping { "base/": "/" }. Groupings are done throughout all import scopes individually.

    Returns

    ImportMap for chaining

    Returns ImportMap

  • Extends the import map mappings

    Returns

    ImportMap for chaining

    Parameters

    • map: IImportMap

      Import map to extend with

    • overrideScopes: boolean = false

      Set to true to have scopes be replacing instead of extending

    Returns ImportMap

  • Groups the import map scopes to shared URLs to reduce duplicate mappings.

    For two given scopes, "https://site.com/x/" and "https://site.com/y/", a single scope will be constructed for "https://site.com/" including their shared mappings, only retaining the scopes if they have differences.

    In the case where the scope is on the same origin as the mapUrl, the grouped scope is determined based on determining the common baseline over all local scopes

    Returns

    ImportMap for chaining

    Returns ImportMap

  • Rebase the entire import map to a new mapUrl and rootUrl

    If the rootUrl is not provided, it will remain null if it was already set to null.

    Otherwise, just like the constructor options, the rootUrl will default to the mapUrl base if it is an http: or https: scheme URL, and null otherwise keeping absolute URLs entirely in-tact.

    Returns

    ImportMap for chaining

    Parameters

    • mapUrl: string | URL = ...

      The new map URL to use

    • Optional rootUrl: string | URL

      The new root URL to use

    Returns ImportMap

  • Bulk replace URLs in the import map Provide a URL ending in "/" to perform path replacements

    Returns

    ImportMap for chaining

    Parameters

    • url: string

      {String} The URL to replace

    • newUrl: string

      {String} The URL to replace it with

    Returns ImportMap

  • Perform a module resolution against the import map

    Returns

    Resolved URL string

    Parameters

    • specifier: string

      Specifier to resolve

    • parentUrl: string | URL = ...

      Parent URL to resolve against

    Returns string

  • Set a specific entry in the import map

    Returns

    ImportMap for chaining

    Parameters

    • name: string

      Specifier to set

    • target: string

      Target of the map

    • Optional parent: string

      Optional parent scope

    Returns ImportMap

  • Performs an alphanumerical sort on the import map imports and scopes

    Returns

    ImportMap for chaining

    Returns ImportMap

Generated using TypeDoc