UNPKG

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