Categories
function packageEntries
packageEntries(
name: string,
target: string
): Record<string, string>

Build the two import map entries a package needs to resolve both itself and its subpaths.

Deno's importMap resolution requires a trailing-slash entry for subpath imports, and a jsr: or npm: trailing-slash target only resolves in the jsr:/ or npm:/ form.

Examples

Example 1

import { packageEntries } from 'jsr:@kjanat/importmapify';

packageEntries('@std/async', 'jsr:@std/async@^1.0.0');
// { '@std/async': 'jsr:@std/async@^1.0.0', '@std/async/': 'jsr:/@std/async@^1.0.0/' }

Parameters

name: string

Bare package specifier.

target: string

Exact target for name.

Return Type

Record<string, string>

The bare entry and its trailing-slash subpath entry.