v0.1.0
Implementation of the import maps spec in JavaScript for the browser and Deno.
Attributes
Includes Deno configuration
Repository
Current version released
2 years ago
Import maps
This module is a JavaScript implementation of the Import maps spec.
Usage
import { parseImportMap, resolveModuleSpecifier } from "https://deno.land/x/import_maps/mod.js";
const baseUrl = new URL(import.meta.url);
const parsedImportMap = parseImportMap({
imports: {
"std/": "https://deno.land/std/",
}
}, baseUrl);
const resolved = resolveModuleSpecifier(parsedImportMap, baseUrl, "std/http/mod.ts");
console.log(resolved); // URL { href: "https://deno.land/std/http/mod.ts" }
Alternatively, you can use createEmptyImportMap()
to simulate a situation where no import map is provided.
import { createEmptyImportMap, resolveModuleSpecifier } from "https://deno.land/x/import_maps/mod.js";
const importMap = createEmptyImportMap();
resolveModuleSpecifier(parsedImportMap, baseUrl, "https://example.com");