UNPKG

@eik/rollup-plugin

Version:

Rollup plugin for loading import maps from a Eik server and applying the mapping to ECMAScript modules in preparation for upload to the same server.

44 lines (43 loc) 1.32 kB
/** * @typedef {object} ImportMap * @property {Record<string, string>} imports */ /** * @typedef {object} PluginOptions * @property {string} [path=process.cwd()] Path to `eik.json`. * @property {string[]} [urls=[]] URLs to import maps hosted on an Eik server. Takes precedence over `eik.json`. * @property {ImportMap[]} [maps=[]] Inline import maps that should be used. Takes precedence over `urls` and `eik.json`. */ /** * @typedef {object} Plugin * @property {string} name * @property {(options?: unknown) => Promise<void>} buildStart * @property {(importee?: string) => string} resolveId */ /** * @param {PluginOptions} options * @returns {Plugin} */ export default function esmImportToUrl({ path, maps, urls, }?: PluginOptions): Plugin; export type ImportMap = { imports: Record<string, string>; }; export type PluginOptions = { /** * Path to `eik.json`. */ path?: string; /** * URLs to import maps hosted on an Eik server. Takes precedence over `eik.json`. */ urls?: string[]; /** * Inline import maps that should be used. Takes precedence over `urls` and `eik.json`. */ maps?: ImportMap[]; }; export type Plugin = { name: string; buildStart: (options?: unknown) => Promise<void>; resolveId: (importee?: string) => string; };