Categories
function defineConfig
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.

Examples

Example 1

import { defineConfig, writeImportMap } from 'jsr:@kjanat/importmapify';

export const config = defineConfig({
  root: import.meta.dirname,
  packages: { dreamcli: 'jsr:@kjanat/dreamcli@^3' },
});

writeImportMap(config);

Example 2

// Config file with a build hook: generate:before runs before the CLI scans.
import { execSync } from 'node:child_process';
import { defineConfig } from 'jsr:@kjanat/importmapify';

export default defineConfig({
  hooks: {
    'generate:before': () => execSync('deno task build', { stdio: 'inherit' }),
  },
});

Type Parameters

T extends Config

Parameters

config: T

Import map configuration; every field is optional.

Return Type

The same config value with its exact type preserved, so a config that includes CreateImportMapOptions.root stays assignable to writeImportMap while one that omits it is still a valid config file.