UNPKG

1.11 kBTypeScriptView Raw
1import { Plugin, ResolveIdResult } from 'rollup';
2
3export interface Alias {
4 find: string | RegExp;
5 replacement: string;
6 customResolver?: ResolverFunction | ResolverObject | null;
7}
8
9export type ResolverFunction = (
10 source: string,
11 importer: string | undefined
12) => Promise<ResolveIdResult> | ResolveIdResult;
13
14export interface ResolverObject {
15 resolveId: ResolverFunction;
16}
17
18export interface RollupAliasOptions {
19 /**
20 * Instructs the plugin to use an alternative resolving algorithm,
21 * rather than the Rollup's resolver.
22 * @default null
23 */
24 customResolver?: ResolverFunction | ResolverObject | null;
25
26 /**
27 * Specifies an `Object`, or an `Array` of `Object`,
28 * which defines aliases used to replace values in `import` or `require` statements.
29 * With either format, the order of the entries is important,
30 * in that the first defined rules are applied first.
31 */
32 entries?: readonly Alias[] | { [find: string]: string };
33}
34
35/**
36 * 🍣 A Rollup plugin for defining aliases when bundling packages.
37 */
38export default function alias(options?: RollupAliasOptions): Plugin;