Categories
default

Examples

Example 1

// Create an import map from the current package.
import { createImportMap } from 'jsr:@kjanat/importmapify';

const importMap = createImportMap({ root: Deno.cwd() });
console.log(importMap.imports);

Example 2

// Access these docs programmatically
deno doc jsr:@kjanat/importmapify

Functions

f
createImportMap(options: CreateImportMapOptions): ImportMapDocument

Expand a package's exact and patterned imports into a Deno import map.

f
defineConfig<T extends Config>(config: T): T

Type an import map configuration for export and reuse, then pass it to createImportMap or writeImportMap. Returns its input unchanged; it exists only for inference and autocomplete.

f
formatImportMap(
map: ImportMapDocument,
indent?: string | number
): string

Serialize an import map as stable JSON with a trailing newline.

f
packageEntries(
name: string,
target: string
): Record<string, string>

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

f
writeImportMap(options: WriteImportMapOptions): string

Create an import map and write it to disk, creating parent directories as needed.

Interfaces

I
Config

An importmapify config file: the shape a config file's default export and defineConfig take. Every field is optional; the config loader and CLI supply root and the remaining defaults.

I
CreateImportMapOptions

Options for creating an import map without writing it to disk.

I
HookContext

Resolved paths shared by every generation hook.

I
ImportMapDocument

A deterministic Deno import map generated from package import entries, following the Import Maps Standard.

I
ImportMapHooks

Lifecycle hooks the CLI runs around import map generation, modeled on tsdown's hooks.

I
WriteImportMapOptions

Options for creating and writing an import map.

  • indent: string | number

    Indentation for the serialized map, with the semantics of JSON.stringify's space parameter: a number of spaces per level or a literal indent string. Defaults to a tab.

  • out: PathOrUrl

    Output path, resolved against root. Accepts a relative path, an absolute path, a file:// URL string, or a URL. Defaults to import_map.json.

Type Aliases

T
PathOrUrl = string | URL

A filesystem location as a path string or file:// URL, accepted wherever an option names a directory or file.

T
TargetFilter = RegExp | ((target: string) => boolean)

A matcher for filter, tested against a candidate target path such as ./dist/internal-qo9O8jzH.js. A target is kept only when every matcher accepts it.