Categories
interface CreateImportMapOptions

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

Examples

Example 1

import { createImportMap, type CreateImportMapOptions } from 'jsr:@kjanat/importmapify';

const options: CreateImportMapOptions = {
  root: import.meta.dirname,
  conditions: ['deno', 'import', 'default'],
  extensions: ['ts', 'tsx'],
};

createImportMap(options);

Properties

readonly
root: PathOrUrl

Project directory containing the package manifest, as a path or file:// URL.

readonly
optional
manifest: string

Manifest path relative to root. Defaults to package.json.

readonly
optional
conditions: readonly string[]

Conditional import keys to try in order. Defaults to import, then default.

readonly
optional
packages: Readonly<Record<string, string>>

Package specifiers mapped to targets, each expanded to a conformant bare and trailing-slash pair. Defaults to none.

readonly
optional
additionalImports: Readonly<Record<string, string>>

Explicit entries merged after manifest imports and packages, overriding duplicate keys. Defaults to none.

readonly
optional
scopes: Readonly<Record<string, Readonly<Record<string, string>>>>

Scope-specific import overrides keyed by scope prefix, following Deno's scoped mappings. Defaults to none.

readonly
optional
relativeTo: PathOrUrl

Directory the generated import map will be read from, as a path or file:// URL.

Manifest targets are written relative to root, but Deno resolves an import map's relative targets from the location of the map file. Each relative target is rewritten to be relative to this directory instead, so it still points at the right file once the map moves. writeImportMap and the CLI set this automatically to the output file's directory; set it yourself only when placing an in-memory map somewhere other than root. Defaults to root.

readonly
optional
extensions: readonly string[]

Extension whitelist limiting which pattern targets are kept, with or without leading dots. Combines with filter. Unset keeps every extension.

readonly
optional
filter: readonly TargetFilter[]

Matchers a candidate pattern target must pass, each tested against the target path. A target is kept only when every matcher accepts it. Combines with extensions. Unset keeps every target.