UNPKG

esbuild-yaml

Version:

An esbuild plugin, that allows imports of YAML files

32 lines (29 loc) 1.1 kB
import { Plugin } from 'esbuild'; import { ParseOptions, DocumentOptions, SchemaOptions, ToJSOptions } from 'yaml'; type YAMLValue = number | string | boolean | null | { [key: string]: YAMLValue; } | YAMLValue[]; interface YAMLPluginOptions { /** * Options to pass to the YAML parser. * @see https://eemeli.org/yaml/#options * * NOTE: * Options inside `ToJSOptions` only works if `type` is set to "single". */ parserOptions?: ParseOptions & DocumentOptions & SchemaOptions & ToJSOptions; /** * The type of YAML file to parse. * @default "single" */ type?: "single" | "multi"; /** * A function to transform the parsed YAML data. * @param {YAMLValue} data The parsed YAML data. * @param {string} filePath The path to the YAML file. * @returns {YAMLValue | undefined} The transformed data. */ transform?: (data: YAMLValue, filePath: string) => YAMLValue | undefined; } declare function YAMLPlugin(options?: YAMLPluginOptions): Plugin; export { YAMLPlugin, type YAMLPluginOptions, YAMLPlugin as default };