Skip to content

timreichen/importmap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ImportMap

Implementation of import maps.

Example

import {
  resolveImportMap,
  resolveModuleSpecifier,
} from "https://deno.land/x/importmap/mod.ts";

const importMap: ImportMap = {
  imports: {
    "./foo/": "./bar/",
  },
};
const importMapBaseURL = new URL(import.meta.url);
const moduleSpecifier = "./foo/test.js";
const baseURL = new URL(import.meta.url);
const resolvedImportMap = resolveImportMap(importMap, importMapBaseURL); // { imports: { "file:///project/dir/foo/": "file:///project/dir/bar/" }, scopes: {} }
const resolvedeModuleSpecifier = resolveModuleSpecifier(
  moduleSpecifier,
  resolvedImportMap,
  baseURL,
); // file:///project/dir/bar/test.js