Categories
function formatImportMap
formatImportMap(
indent?: string | number
): string

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

Examples

Example 1

// Format an import map for stdout, indented with two spaces.
import { formatImportMap } from 'jsr:@kjanat/importmapify';

const text = formatImportMap({ imports: { '#config': './src/config.ts' } }, 2);

console.log(text);

Parameters

Import map to serialize.

optional
indent: string | number

Indentation with JSON.stringify space semantics; defaults to a tab.

Return Type

string

Formatted JSON ready to print or write.