UNPKG

plugin-preloader

Version:

This library dynamically preloads and installs Babel and ESLint plugins and presets based on your configuration, streamlining the build process without the need to include them as dependencies in your project.

29 lines (25 loc) 1.03 kB
import { TransformOptions, PluginItem, PluginTarget, PluginOptions } from '@babel/core'; import { Linter } from 'eslint'; type Name = string; type SemanticVersion = string; type NameWithVersion = [Name, SemanticVersion]; type Entity = Name | NameWithVersion; type BabelPluginExtended = PluginItem | [PluginTarget, PluginOptions, string | undefined, SemanticVersion | undefined]; interface BabelConfigBase extends Omit<TransformOptions, "plugins" | "presets" | "env"> { plugins?: BabelPluginExtended | BabelPluginExtended[] | null; presets?: BabelPluginExtended | BabelPluginExtended[] | null; } interface BabelConfig extends BabelConfigBase { env?: Record<string, BabelConfigBase>; } interface ESLintConfig extends Omit<Linter.BaseConfig, "parser" | "extends" | "plugins"> { parser?: Entity; extends?: Entity | Entity[]; plugins?: Entity[]; } interface Preload { babel?: BabelConfig; eslint?: ESLintConfig; } declare function preload({ babel, eslint }: Preload): void; export { preload as default };