UNPKG

1.43 kBTypeScriptView Raw
1import type { FilterPattern } from '@rollup/pluginutils';
2import type { Plugin } from 'rollup';
3
4type ValidYamlType =
5 | number
6 | string
7 | boolean
8 | null
9 | { [key: string]: ValidYamlType }
10 | ValidYamlType[];
11
12interface RollupYamlOptions {
13 /**
14 * A picomatch pattern, or array of patterns, which specifies the files in the build the plugin
15 * should operate on.
16 * By default all files are targeted.
17 */
18 include?: FilterPattern;
19 /**
20 * A picomatch pattern, or array of patterns, which specifies the files in the build the plugin
21 * should _ignore_.
22 * By default no files are ignored.
23 */
24 exclude?: FilterPattern;
25 /**
26 * A function which can optionally mutate parsed YAML.
27 * The function should return the mutated `object`, or `undefined` which will make no changes to
28 * the parsed YAML.
29 * @default undefined
30 */
31 transform?: (data: ValidYamlType, filePath: string) => ValidYamlType | undefined;
32 /**
33 * - If `single`, specifies that the target YAML documents contain only one document in the
34 * target file(s).
35 * - If more than one [document stream](https://yaml.org/spec/1.2/spec.html#id2801681) exists in
36 * the target YAML file(s), set `documentMode: 'multi'`.
37 * @default 'single'
38 */
39 documentMode?: 'single' | 'multi';
40}
41
42/**
43 * A Rollup plugin which Converts YAML files to ES6 modules.
44 */
45export default function yaml(options?: RollupYamlOptions): Plugin;