Class ImportMap
Hierarchy
- ImportMap
Implements
Index
Constructors
Properties
Methods
Constructors
constructor
- new
Import Map(opts: string | URL | {
map?: IImportMap;
mapUrl?: string | URL;
rootUrl?: string | URL;
}): ImportMap -
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
integrity
map Url
The absolute URL of the import map, for determining relative resolutions When using file:/// URLs this allows relative modules to be co-located
root 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
Methods
clone
combine Subpaths
- combine
Subpaths(): ImportMap -
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
extend
- extend(map: IImportMap, overrideScopes?: boolean): 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
-
flatten
- flatten(): 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
get Integrity
rebase
- rebase(mapUrl?: string | URL, rootUrl?: string | URL): 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 | URLThe new root URL to use
Returns ImportMap
-
replace
resolve
set
set Integrity
sort
toJSON
- toJSON(): IImportMap
-
Get the import map JSON data
Returns
Import map data
Returns IImportMap
Generated using TypeDoc
Create a new import map instance