Skip to content

gjsify/deno-importmap

 
 

Repository files navigation

ImportMap

Implementation of import maps.

This is a port of the Deno module importmap to Nodejs.

Example

import {
  resolveImportMap,
  resolveModuleSpecifier,
} from "deno-importmap";

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

About

Resolve specifiers with import maps.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 56.0%
  • TypeScript 44.0%