This is a tool for generating an import map for loading JavaScript modules straight from the source inside of npm packages, delivered by the jsDelivr CDN.
import {
generateImportMap,
generateTypedImports,
getDependencies,
} from "https://deno.land/x/[email protected]/mod.ts";
const dependencies = await getDependencies({ "style-mod": "*" });
const importMap = generateImportMap(dependencies);
const typedImports = generateTypedImports(dependencies);
console.log({ importMap, typedImports });
This permission is needed:
--allow-net=data.jsdelivr.com,cdn.jsdelivr.net
To install, run:
deno install --allow-net=data.jsdelivr.com,cdn.jsdelivr.net \
https://deno.land/x/[email protected]/main.ts
This will install it as deliver_importmaps
.
To run, create a Markdown file with a code block in it that has a list
of packages and version numbers in a code block called dependencies.json
and pipe it into the command:
cat input.md | deliver_importmaps
The output will contain a code block that has an import map and another with the types for creating a file. They can be put into files using md_unpack_simple:
cat input.md | deliver_importmaps | md_unpack_simple
This is generated from a markdown document, deliver_importmaps.md, using md_unpack_simple.
MIT