UNPKG

1.2 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 ResolvedAlias {
17 find: string | RegExp;
18 replacement: string;
19 resolverFunction: ResolverFunction | null;
20}
21
22export interface RollupAliasOptions {
23 /**
24 * Instructs the plugin to use an alternative resolving algorithm,
25 * rather than the Rollup's resolver.
26 * @default null
27 */
28 customResolver?: ResolverFunction | ResolverObject | null;
29
30 /**
31 * Specifies an `Object`, or an `Array` of `Object`,
32 * which defines aliases used to replace values in `import` or `require` statements.
33 * With either format, the order of the entries is important,
34 * in that the first defined rules are applied first.
35 */
36 entries?: readonly Alias[] | { [find: string]: string };
37}
38
39/**
40 * 🍣 A Rollup plugin for defining aliases when bundling packages.
41 */
42export default function alias(options?: RollupAliasOptions): Plugin;