UNPKG

2.5 kBTypeScriptView Raw
1/**
2 * A Babel plugin is typically specified as a string representing a module to be
3 * loaded, either a package name or a full path. It's also possible for the actual
4 * implementation to be supplied, in which case we check the value of a `name` field.
5 */
6export declare type BabelPlugin = string | {
7 name?: string;
8};
9/**
10 * Configuration for a Babel plugin may be the bare plugin itself, or a tuple
11 * optionally containing configuration for the plugin and a possible unique
12 * identifier to allow for multiple instances of the same plugin.
13 */
14export declare type BabelPluginConfig = BabelPlugin | [BabelPlugin, unknown?, unknown?];
15/**
16 * A configuration target is typically an `EmberApp` or `Addon` instance, which
17 * may already have plugins configured or other options set.
18 */
19export interface ConfigurationTarget {
20 options?: {
21 babel?: {
22 plugins?: BabelPluginConfig[];
23 };
24 };
25}
26/**
27 * Locates the existing configuration, if any, for a given plugin.
28 *
29 * @param config An array of plugin configuration or an `EmberApp` or `Addon`
30 * instance whose configuration should be checked
31 * @param plugin The name of the plugin to be located
32 */
33export declare function findPlugin(config: ConfigurationTarget | BabelPluginConfig[], plugin: string): BabelPluginConfig | undefined;
34/**
35 * Indicates whether the given plugin is already present in the target's configuration.
36 *
37 * @param config An array of plugin configuration or an `EmberApp` or `Addon`
38 * instance whose configuration should be checked
39 * @param plugin The name of the plugin to be located
40 */
41export declare function hasPlugin(config: BabelPluginConfig[] | ConfigurationTarget, plugin: string): boolean;
42export interface AddPluginOptions {
43 /**
44 * Any plugins that the given one must appear *before* in the plugins array.
45 */
46 before?: string[];
47 /**
48 * Any plugins that the given one must appear *after* in the plugins array.
49 */
50 after?: string[];
51}
52/**
53 * Add a plugin to the Babel configuration for the given target.
54 *
55 * @param config An array of plugin configuration or an `EmberApp` or `Addon`
56 * instance for which the plugin should be set up
57 * @param plugin Configuration for the Babel plugin to add
58 * @param options Optional constraints around where the plugin should appear in the array
59 */
60export declare function addPlugin(config: ConfigurationTarget | BabelPluginConfig[], plugin: BabelPluginConfig, options?: AddPluginOptions): void;