Skip to content

Implementation of the import maps spec in JavaScript for the browser and Deno.

Notifications You must be signed in to change notification settings

jespertheend/import_maps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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");

About

Implementation of the import maps spec in JavaScript for the browser and Deno.

Resources

Stars

Watchers

Forks

Packages

No packages published