Expand a package's exact and patterned imports
into a Deno import map.
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.
Serialize an import map as stable JSON with a trailing newline.
Build the two import map entries a package needs to resolve both itself and its subpaths.
Create an import map and write it to disk, creating parent directories as needed.
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.
-
hooks: Partial<ImportMapHooks>
Lifecycle hooks the CLI runs around generation. Ignored by writeImportMap and createImportMap.
Options for creating an import map without writing it to disk.
-
additionalImports: Readonly<Record<string,
string>>
Explicit entries merged after manifest imports and packages, overriding duplicate keys. Defaults to none.
-
conditions: readonly string[]
Conditional import keys to try in order. Defaults to
import, thendefault. -
extensions: readonly string[]
Extension whitelist limiting which pattern targets are kept, with or without leading dots. Combines with filter. Unset keeps every extension.
-
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.
-
manifest: string
Manifest path relative to root. Defaults to
package.json. -
packages: Readonly<Record<string,
string>>
Package specifiers mapped to targets, each expanded to a conformant bare and trailing-slash pair. Defaults to none.
-
relativeTo: PathOrUrl
Directory the generated import map will be read from, as a path or
file://URL. -
root: PathOrUrl
Project directory containing the package
manifest, as a path orfile://URL. -
scopes: Readonly<Record<string,
Readonly<Record<string,
string>>>>
Scope-specific import overrides keyed by scope prefix, following Deno's scoped mappings. Defaults to none.
Resolved paths shared by every generation hook.
-
out: string
Absolute output path the map resolves against.
-
root: string
Absolute project root that gets scanned.
A deterministic Deno import map generated from package import entries, following the Import Maps Standard.
-
imports: Readonly<Record<string,
string>>
Exact specifier-to-target mappings, sorted by specifier, as in Deno's custom path mappings.
-
scopes: Readonly<Record<string,
Readonly<Record<string,
string>>>>
Scope prefixes mapped to sorted, scope-specific import overrides, as in Deno's scoped mappings.
Lifecycle hooks the CLI runs around import map generation, modeled on tsdown's hooks.
-
generate:before: (context: HookContext) => void
|
Promise<void>
Runs before the filesystem is scanned. Build pattern targets here so they exist when patterns expand.
-
generate:done: (context:
HookContext
&
{ readonly
map: ImportMapDocument;
}) => void | Promise<void>
Runs after the map is generated and emitted.
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 toimport_map.json.
A filesystem location as a path string or file://
URL, accepted wherever an option names a directory or file.
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.